Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cJSXClass.h
Go to the documentation of this file.
1 //
4 //
5 #ifndef _INC_cJSXClass_H
6 #define _INC_cJSXClass_H
7 #ifndef NO_PRAGMA_ONCE
8 #pragma once
9 #endif
10 
11 #include "GrayJSX.h"
12 
13 namespace GrayLib
14 {
16 };
17 namespace GrayJS
18 {
19  static const size_t k_JSX_STACK_CHUNK_SIZE = 8*1024;
20 
21 #ifdef USE_JS_CUSTOM_THUNK
22 #pragma pack(push,1)
23  struct CATTR_PACKED CJSXThunk
24  {
26  BYTE m_nIMov;
27  UINT_PTR m_nAddrMov;
28  BYTE m_nIJump;
29  UINT_PTR m_nAddrJump;
30  };
31 #pragma pack(pop)
32 #endif
33 
34  class cJSXClass : public cRefBase
35  {
39  public:
40  // Dynamically allocated tables filled in at InitScriptInterfaceDef() time
41 
44 
45  private:
46  const cScriptableInterfaceDef* m_pInterfaceDef;
47  cNewPtr<JSClass> m_pjsClass;
48 
49  int m_iPropsQty;
51 
52  int m_iFunctionsQty;
54 
55 #ifdef USE_JS_CUSTOM_THUNK
56  CJSXThunk* m_pFunctionThunks;
57 #endif
58 
59  static const JSClass sm_global_class;
60 
61 #ifdef USE_JS_PROTO
62  // object prototype for 'typeof XXX is object' or 'instanceof' stuff.
63  cJSObject* m_pjsObjProto;
64  bool m_bConstructing;
65 #endif
66 
67  private:
68 #ifdef USE_JS_CUSTOM_THUNK
69  bool InitThunkTable();
70  void DeleteThunkTable();
71 #endif
72 
73  bool InitProp(int i, const cScriptableProp* pProp);
74  bool InitMethod(int i, const cScriptableMethod* pMethod);
75  bool InitClass();
76 
77  public:
78  cJSXClass( const cScriptableInterfaceDef* pInterfaceDef );
79  virtual ~cJSXClass();
80 
82  {
83  return m_pInterfaceDef->get_InterfaceID();
84  }
85 
86  cString get_Name() const;
87  JSClass* get_JSClass() const
88  {
89  return m_pjsClass;
90  }
93  {
94  return m_pInterfaceDef;
95  }
96  const cScriptableProp* GetPropPtr(int i) const
97  {
99  if ( IS_INDEX_BAD(i,m_iPropsQty))
100  return NULL;
101  return m_aProps[i];
102  }
103  };
104 
106 };
107 
108 #endif // cJSXClass
#define CATTR_PACKED
Definition: GrayCore.h:87
#define IS_INDEX_BAD(i, q)
cast the (likely) int to unsigned to check for negatives.
Definition: Index.h:34
Definition: cJSObject.h:56
Definition: cJSObject.h:47
Definition: cJSXClass.h:35
virtual ~cJSXClass()
Definition: cJSXClass.cpp:52
cString get_Name() const
Definition: cJSXClass.cpp:297
cJSObject * GetJSObjProto(cJSContext *pjsCx)
Definition: cJSXClass.cpp:303
cJSXClass(const cScriptableInterfaceDef *pInterfaceDef)
Definition: cJSXClass.cpp:33
cNewPtr< JSPropertySpec > m_ajsProps
array of props. NOT exactly Equiv to m_aPropsAll
Definition: cJSXClass.h:42
JSClass * get_JSClass() const
Definition: cJSXClass.h:87
const cScriptableInterfaceDef * get_InterfaceDef() const
Definition: cJSXClass.h:92
const cScriptableProp * GetPropPtr(int i) const
Definition: cJSXClass.h:96
SCRIPTINTERFACEID_t get_HashCode() const noexcept
Definition: cJSXClass.h:81
cNewPtr< JSFunctionSpec > m_ajsFunctions
NOT exactly Equiv to m_aMethodsAll.
Definition: cJSXClass.h:43
Definition: cScriptableInterface.h:300
SCRIPTINTERFACEID_t get_InterfaceID() const noexcept
Definition: cScriptableInterface.h:371
Definition: cScriptableInterface.h:97
Definition: cRefPtr.h:22
Definition: cJSObject.h:36
cJSXClass * cJSXClassPtr
Definition: cJSXClass.h:105
Definition: cMesh.h:22
class __DECL_IMPORT cScriptableInterfaceDef
Definition: cScriptableEventsMask.h:31
BYTE SCRIPTINTERFACEID_t
enumerate all the defined interface definitions.
Definition: cScriptableInterface.h:35