![]() |
Gray C++ Libraries
0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
|
#include <cJSXEngine.h>
Public Member Functions | |
| virtual cXObjPackPtr | CreateXObjFile (const FILECHAR_t *pszFilePath) override |
| cJSXEngine () | |
| virtual | ~cJSXEngine () |
| bool | InitJSX () |
| void | ExitJSX () |
| bool | IsInitJSX () const noexcept |
| cJSXContextPtr | CreateJSXContext () |
| cJSXContextPtr | GetJSXContextCurrent (bool bCreate=true) |
| int | CvtVartoJSValArray (cNewPtr< GRAY_jsval > &rVals, cJSContext *pjsCx, const cVariant &vVal) |
| bool | CvtVartoJSVal (cJSContext *pjsCx, GRAY_jsval *vp, const cVariant &vVal) |
| cJSXObjectPtr | AssocJSXObject (cJSContext *pjsCx, cXObject *pObj, cJSObject *pjsObject) |
| cJSXObjectPtr | NewJSXObject (cJSContext *pjsCx, cXObject *pObj, cJSObject *pjsObjProto, cJSObject *pjsObjParent) |
| cJSXObjectPtr | FindJSXObject (cXObject *pObj) const |
| cJSXObjectPtr | GetJSXObject (cJSContext *pjsCx, cXObject *pObj) |
| cJSXObjectPtr | FindJSXObject (cJSContext *pjsCx, cJSObject *pjsObject) |
| cJSObject * | get_JSObjectGlobal () const |
| cJSXObjectPtr | CreateJSXObjectGlobal (cJSContext *pjsCx) |
| void | CheckJSObjectsCache (cJSContext *pjsCx) |
| void | FinalizeJSObject (cJSContext *pjsCx, cJSObject *pjsObject) |
| UNITTEST_FRIEND (cJSXEngine) | |
Public Member Functions inherited from GrayLib::cXObjPackFactory | |
| cXObjPackFactory (const FILECHAR_t *pszExt) | |
| virtual | ~cXObjPackFactory () |
| bool | IsFileExt (const FILECHAR_t *pszExt) const |
Public Member Functions inherited from Gray::CObject | |
| virtual | ~CObject () |
| virtual bool | isValidCheck () const noexcept |
| < memory allocation and structure definitions are valid. More... | |
| virtual void | AssertValid () const |
| < memory allocation and structure definitions are valid. More... | |
| virtual void | Serialize (cArchive &a) |
Public Member Functions inherited from Gray::cHeapObject | |
| cHeapObject () | |
| virtual | ~cHeapObject () |
| bool | IsValidInsideN (INT_PTR index) const |
| bool | IsValidInsidePtr (void const *pTest) const |
| virtual size_t | GetHeapStatsThis (OUT ITERATE_t &iAllocCount) const |
| virtual bool | isValidCheck () const noexcept |
Public Member Functions inherited from Gray::cRefBase | |
| cRefBase (int iRefCount=0) noexcept | |
| virtual | ~cRefBase () |
| int | get_RefCount () const noexcept |
| HASHCODE_t | get_HashCode () const noexcept |
| STDMETHOD_ (HASHCODE_t, get_HashCodeX)() const noexcept | |
| virtual void | onFinalRelease () |
| bool | isValidObj () const noexcept |
| STDMETHOD_ (ULONG, AddRef)(void) override | |
| STDMETHOD_ (ULONG, Release)(void) override | |
| STDMETHOD() | QueryInterface (const IID &riid, void __RPC_FAR *__RPC_FAR *ppvObject) override |
| void | IncRefCount () |
| void | DecRefCount () |
| bool | isStaticConstruct () const noexcept |
| void | StaticConstruct () |
| void | StaticDestruct () |
| bool | isDestructing () noexcept |
| void | SetDestructing () |
Static Public Member Functions | |
| static GRAY_JSBool _cdecl | SetProperty (JSContext *pjsCx, JSObject *pjsObj, GRAY_jsval id, GRAY_jsval *vp) |
| static GRAY_JSBool _cdecl | GetProperty (JSContext *pjsCx, JSObject *pjsObj, GRAY_jsval idPropRaw, GRAY_jsval *pvalRet) |
| static GRAY_JSBool _cdecl | MethodInvoke (JSContext *pjsCx, JSObject *pjsObj, UINT argc, GRAY_jsval *pargv, GRAY_jsval *prval) |
| static void _cdecl | Finalize (JSContext *pjsCx, JSObject *pjsObj) |
| static GRAY_JSBool _cdecl | Resolve (JSContext *pjsCx, JSObject *pjsObj, GRAY_jsval id, GRAY_uintN flags, JSObject **ppjsObj) |
| static GRAY_JSBool _cdecl | Construct (JSContext *pjsCx, JSObject *pjsObj, GRAY_uintN argc, GRAY_jsval *argv, GRAY_jsval *rval) |
| static GRAY_JSBool _cdecl | AddProperty (JSContext *pjsCx, JSObject *pjsObj, GRAY_jsval idPropRaw, GRAY_jsval *vp) |
| static GRAY_JSBool _cdecl | DelProperty (JSContext *pjsCx, JSObject *pjsObj, GRAY_jsval idPropRaw, GRAY_jsval *vp) |
| static void _cdecl | ErrorReporter (JSContext *pjsCx, const LOGCHAR_t *message, JSErrorReport *report) |
| static cJSXContextPtr GRAYCALL | GetJSXContext (cJSContext *pjsCx) |
| static int GRAYCALL | CvtJSValArraytoVar (cVariant &vVal, cJSContext *pjsCx, const GRAY_jsval *argv, int argc) |
| static bool GRAYCALL | CvtJSValtoVar (cJSContext *pjsCx, const GRAY_jsval *vp, cVariant &vVal) |
| static cXObjectPtr GRAYCALL | GetXObject (cJSContext *pjsCx, cJSObject *pjsObj) |
| static bool | IsClassJSXProto (const cScriptableInterfaceDef *pClassDef) |
Static Public Member Functions inherited from Gray::cSingleton< TYPE > | |
| static TYPE *__stdcall | get_Single () |
| template<class TYPE2 > | |
| static TYPE2 *__stdcall | get_SingleT () |
| static TYPE &__stdcall | I () |
Static Public Member Functions inherited from Gray::cSingletonStatic< TYPE > | |
| static bool | isSingleCreated () noexcept |
| static TYPE * | get_SingleU () noexcept |
| static TYPE * | get_Single () |
| template<class TYPE2 > | |
| static TYPE2 *__stdcall | get_SingleCast () |
| static TYPE & | I () noexcept |
Static Public Member Functions inherited from Gray::cSingletonRegister | |
| static void __stdcall | ReleaseModule (HMODULE hMod) |
Public Attributes | |
| cJSRuntime * | m_pjsRuntime |
| library reference. More... | |
| cJSXContextPtr | m_pJSXContextDef |
| the default/global context. used to create m_pJSXObjGlobal More... | |
| cArrayRef< cJSXClass > | m_aJSXClasses |
| cache of cJSXClass for each interface. More... | |
| cThreadLocalTypeSmart< cJSXContext > | m_aJSXContexts |
| cache of all cJSXContext being used and not used. More... | |
| cArraySortHash< cJSXObject > | m_aJSXObjects |
| cache of all cJSXObjectPtr = JSObject/cXObject created. More... | |
| cJSXClassPtr | m_pJSXClassBase |
| object to ref the common base class. XObject More... | |
| cThreadLockCount | m_Lock |
Public Attributes inherited from GrayLib::cXObjPackFactory | |
| const FILECHAR_t * | m_pszFileExt |
| What file extension are we supporting? i.e. MIME_EXT_scp, etc (includes dot). More... | |
Additional Inherited Members | |
Static Public Attributes inherited from Gray::cSingletonRegister | |
| static cThreadLockFast | sm_LockSingle |
| common lock for all cSingleton. More... | |
Protected Member Functions inherited from Gray::cSingletonSmart< cJSXEngine > | |
| cSingletonSmart (cJSXEngine *pObject, const TYPEINFO_t &rAddrCode, int iRefCountStart=0) | |
| const void * | get_HeapPtr () const noexcept override |
| Get the top level (outermost, freeable) class pointer. I can delete get_HeapPtr(). More... | |
Protected Member Functions inherited from Gray::cSingleton< TYPE > | |
| cSingleton (TYPE *pObject, const TYPEINFO_t &rAddrCode=typeid(TYPE)) noexcept | |
| virtual | ~cSingleton () |
Protected Member Functions inherited from Gray::cSingletonStatic< TYPE > | |
| cSingletonStatic (TYPE *pObject) noexcept | |
| virtual | ~cSingletonStatic () noexcept |
Protected Member Functions inherited from Gray::cSingletonRegister | |
| cSingletonRegister (const TYPEINFO_t &rAddrCode) noexcept | |
| virtual | ~cSingletonRegister () |
| void | RegisterSingleton () |
Protected Attributes inherited from Gray::cSingletonRegister | |
| HMODULE | m_hModuleLoaded |
| What modules loaded this ? So singletons can be destroyed if DLL/SO unloads. More... | |
Static Protected Attributes inherited from Gray::cSingletonStatic< TYPE > | |
| static TYPE * | sm_pThe = nullptr |
| pointer to the one and only object of this TYPE. ASSUME automatically init to = nullptr. More... | |
Just one connection to the JavaScript engine (runtime) per process. cJSXEngine This can be shared across multi threads/contexts. You always need: a JSRuntime per process, cJSXEngine a context per thread, a global object per context, standard classes (e.g. Date).
| GrayJS::cJSXEngine::cJSXEngine | ( | ) |
|
virtual |
|
static |
| cJSXObjectPtr GrayJS::cJSXEngine::AssocJSXObject | ( | cJSContext * | pjsCx, |
| cXObject * | pObj, | ||
| cJSObject * | pjsObject | ||
| ) |
Create the association object. Create a binding for a cXObject and a EXISTING JSObject
| void GrayJS::cJSXEngine::CheckJSObjectsCache | ( | cJSContext * | pjsCx | ) |
Make sure all my objects are still valid. Throttle this to get called ONLY periodically
|
static |
| cJSXContextPtr GrayJS::cJSXEngine::CreateJSXContext | ( | ) |
| cJSXObjectPtr GrayJS::cJSXEngine::CreateJSXObjectGlobal | ( | cJSContext * | pjsCx | ) |
Given a new context. add global objects to it.
|
overridevirtual |
when i have a file of type MIME_EXT_js don't compile it until we need to. assume LoadXObjPack() will be called later.
Implements GrayLib::cXObjPackFactory.
|
static |
|
static |
| bool GrayJS::cJSXEngine::CvtVartoJSVal | ( | cJSContext * | pjsCx, |
| GRAY_jsval * | vp, | ||
| const cVariant & | vVal | ||
| ) |
Convert a cVariant to the equiv JavaScript jsval GRAY_jsval
| int GrayJS::cJSXEngine::CvtVartoJSValArray | ( | cNewPtr< GRAY_jsval > & | rVals, |
| cJSContext * | pjsCx, | ||
| const cVariant & | vVal | ||
| ) |
Assuming vVal is an array. convert it to an array of JSVal
|
static |
|
static |
Pipe this error out to a console that issued a command?
| void GrayJS::cJSXEngine::ExitJSX | ( | ) |
| void GrayJS::cJSXEngine::FinalizeJSObject | ( | cJSContext * | pjsCx, |
| cJSObject * | pjsObject | ||
| ) |
pjsObject is being deleted.
| cJSXObjectPtr GrayJS::cJSXEngine::FindJSXObject | ( | cJSContext * | pjsCx, |
| cJSObject * | pjsObject | ||
| ) |
| cJSXObjectPtr GrayJS::cJSXEngine::FindJSXObject | ( | cXObject * | pObj | ) | const |
Find the cJSXObject that corresponds to this IXObject.
| cJSObject * GrayJS::cJSXEngine::get_JSObjectGlobal | ( | ) | const |
|
static |
Get cJSXContextPtr from JSContext
| cJSXContextPtr GrayJS::cJSXEngine::GetJSXContextCurrent | ( | bool | bCreate = true | ) |
get a cJSXContext that is attached to the current thread. Create if necessary
| cJSXObjectPtr GrayJS::cJSXEngine::GetJSXObject | ( | cJSContext * | pjsCx, |
| cXObject * | pObj | ||
| ) |
Find (or Create) a JSObject to represent the cXObject Is the cXObject already in my cache?
|
static |
JavaScript Gets the property of a cXObject.
|
static |
Find the cJSXObject/cXObject attached to this JSObject pjsObj. if any.
| bool GrayJS::cJSXEngine::InitJSX | ( | ) |
Init the engine
|
static |
Could use JS_GetClass() on object as well?
|
inlinenoexcept |
|
static |
Invoke a C++ method from JavaScript stub. JSNative
| cJSXObjectPtr GrayJS::cJSXEngine::NewJSXObject | ( | cJSContext * | pjsCx, |
| cXObject * | pObj, | ||
| cJSObject * | pjsObjProto, | ||
| cJSObject * | pjsObjParent | ||
| ) |
Create a binding for a cXObject and a NEW JSObject
|
static |
|
static |
| GrayJS::cJSXEngine::UNITTEST_FRIEND | ( | cJSXEngine | ) |
cache of cJSXClass for each interface.
!< [ SCRIPTINTERFACEID_MAX ]
| cThreadLocalTypeSmart< cJSXContext > GrayJS::cJSXEngine::m_aJSXContexts |
cache of all cJSXContext being used and not used.
| cArraySortHash<cJSXObject> GrayJS::cJSXEngine::m_aJSXObjects |
cache of all cJSXObjectPtr = JSObject/cXObject created.
|
mutable |
| cJSRuntime* GrayJS::cJSXEngine::m_pjsRuntime |
library reference.
| cJSXClassPtr GrayJS::cJSXEngine::m_pJSXClassBase |
object to ref the common base class. XObject
| cJSXContextPtr GrayJS::cJSXEngine::m_pJSXContextDef |
the default/global context. used to create m_pJSXObjGlobal