Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cJSXObject.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cJSXObject_H
7 #define _INC_cJSXObject_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "GrayJSX.h"
13 
14 namespace GrayJS
15 {
16  class cJSObject;
17  class cJSContext;
18 
19  class cJSXObject : public cRefBase
20  {
24  public:
26  private:
27  cJSObject* m_pjsObj;
28  public:
29  cJSXObject();
30  cJSXObject(cJSContext* pjsCx, cXObject* pObj, cJSObject* pjsObj);
31  virtual ~cJSXObject();
32 
33  static HASHCODE_t GetHashCode(cXObject* pXObj) noexcept
34  {
37  DEBUG_CHECK(pXObj != nullptr);
38  return((HASHCODE_t)(void*)pXObj);
39  }
40  STDMETHOD_(HASHCODE_t, get_HashCodeX)() const noexcept
41  {
42  return GetHashCode(m_pXObj);
43  }
44  HASHCODE_t get_HashCode() const noexcept
45  {
46  return GetHashCode(m_pXObj); // so we can look this up via UID. HashCode
47  }
48  cJSObject* get_JSObject() const noexcept
49  {
50  return m_pjsObj;
51  }
52 
53  void RemoveRoot(cJSContext* pjsCx);
54  };
55 
56  typedef cRefPtr<cJSXObject> cJSXObjectPtr;
57 }
58 
59 #endif // _INC_cJSXObject_H
#define DEBUG_CHECK(exp)
Definition: cDebugAssert.h:90
Definition: cJSObject.h:56
Definition: cJSObject.h:47
Definition: cJSXObject.h:20
cJSXObject()
Definition: cJSXObject.cpp:13
STDMETHOD_(HASHCODE_t, get_HashCodeX)() const noexcept
Definition: cJSXObject.h:40
static HASHCODE_t GetHashCode(cXObject *pXObj) noexcept
Definition: cJSXObject.h:33
cXObjectPtr m_pXObj
keep a ref count to the cXObject we represent.
Definition: cJSXObject.h:25
void RemoveRoot(cJSContext *pjsCx)
Definition: cJSXObject.cpp:51
virtual ~cJSXObject()
Definition: cJSXObject.cpp:35
HASHCODE_t get_HashCode() const noexcept
Definition: cJSXObject.h:44
cJSObject * get_JSObject() const noexcept
Definition: cJSXObject.h:48
Definition: cXObject.h:78
Definition: cRefPtr.h:22
Definition: cJSObject.h:36
cRefPtr< cJSXObject > cJSXObjectPtr
Definition: cJSXEngine.h:29
UINT_PTR HASHCODE_t
could hold a pointer converted to a number? maybe 64 or 32 bit ? same as size_t.
Definition: GrayCore.h:116