Index: fxjs/include/fxjs_v8.h |
diff --git a/fxjs/include/fxjs_v8.h b/fxjs/include/fxjs_v8.h |
index 5e12b082be1bf705acae39daa75158787e8b7e83..bc7d21b3cfcc351d2bbc8b1af0622cc2d93fc6af 100644 |
--- a/fxjs/include/fxjs_v8.h |
+++ b/fxjs/include/fxjs_v8.h |
@@ -21,12 +21,12 @@ |
dsinclair
2016/08/15 13:13:32
#include <map>
Tom Sepez
2016/08/15 16:37:55
Done.
|
#include "core/fxcrt/include/fx_string.h" |
+class CFXJS_Engine; |
class CFXJS_ObjDefinition; |
-// FXJS_V8 places no restrictions on these two classes; it merely passes them |
+// FXJS_V8 places no restrictions on this class; it merely passes it |
// on to caller-provided methods. |
class IJS_Context; // A description of the event that caused JS execution. |
-class IJS_Runtime; // A native runtime, typically owns the v8::Context. |
#ifdef PDF_ENABLE_XFA |
// FXJS_V8 places no interpreation on this calass; it merely passes it |
@@ -124,12 +124,26 @@ class FXJS_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { |
void Free(void* data, size_t length) override; |
}; |
-using FXJS_CONSTRUCTOR = void (*)(IJS_Runtime* cc, v8::Local<v8::Object> obj); |
+using FXJS_CONSTRUCTOR = void (*)(CFXJS_Engine* fxjs, |
+ v8::Local<v8::Object> obj); |
using FXJS_DESTRUCTOR = void (*)(v8::Local<v8::Object> obj); |
void FXJS_Initialize(unsigned int embedderDataSlot, v8::Isolate* pIsolate); |
void FXJS_Release(); |
+class CFXJS_Engine { |
dsinclair
2016/08/15 13:13:32
Any reason to not put this in it's own file?
Tom Sepez
2016/08/15 16:37:55
There's a follow-on CL that puts most of this file
|
+ public: |
+ CFXJS_Engine(); |
+ ~CFXJS_Engine(); |
+ |
+ protected: |
+ v8::Isolate* m_isolate; |
+ bool m_isolateManaged; |
+ v8::Global<v8::Context> m_context; |
+ std::vector<v8::Global<v8::Object>*> m_StaticObjects; |
+ std::map<CFX_WideString, v8::Global<v8::Array>> m_ConstArrays; |
+}; |
+ |
// Gets the global isolate set by FXJS_Initialize(), or makes a new one each |
// time if there is no such isolate. Returns true if a new isolate had to be |
// created. |
@@ -172,30 +186,30 @@ void FXJS_DefineGlobalConst(v8::Isolate* pIsolate, |
v8::FunctionCallback pConstGetter); |
// Called after FXJS_Define* calls made. |
-void FXJS_InitializeRuntime( |
+void FXJS_InitializeEngine( |
v8::Isolate* pIsolate, |
- IJS_Runtime* pIRuntime, |
+ CFXJS_Engine* pEngine, |
v8::Global<v8::Context>* pV8PersistentContext, |
std::vector<v8::Global<v8::Object>*>* pStaticObjects); |
-void FXJS_ReleaseRuntime(v8::Isolate* pIsolate, |
- v8::Global<v8::Context>* pV8PersistentContext, |
- std::vector<v8::Global<v8::Object>*>* pStaticObjects); |
-IJS_Runtime* FXJS_GetRuntimeFromIsolate(v8::Isolate* pIsolate); |
+void FXJS_ReleaseEngine(v8::Isolate* pIsolate, |
+ v8::Global<v8::Context>* pV8PersistentContext, |
+ std::vector<v8::Global<v8::Object>*>* pStaticObjects); |
+CFXJS_Engine* FXJS_GetEngineFromIsolate(v8::Isolate* pIsolate); |
#ifdef PDF_ENABLE_XFA |
-// Called as part of FXJS_InitializeRuntime, exposed so PDF can make its |
+// Called as part of FXJS_InitializeEngine, exposed so PDF can make its |
// own contexts compatible with XFA or vice versa. |
-void FXJS_SetRuntimeForV8Context(v8::Local<v8::Context> v8Context, |
- IJS_Runtime* pIRuntime); |
+void FXJS_SetEngineForV8Context(v8::Local<v8::Context> v8Context, |
+ CFXJS_Engine* pEngine); |
#endif // PDF_ENABLE_XFA |
-// Called after FXJS_InitializeRuntime call made. |
+// Called after FXJS_InitializeEngine call made. |
int FXJS_Execute(v8::Isolate* pIsolate, |
const CFX_WideString& script, |
FXJSErr* perror); |
v8::Local<v8::Object> FXJS_NewFxDynamicObj(v8::Isolate* pIsolate, |
- IJS_Runtime* pJSContext, |
+ CFXJS_Engine* pEngine, |
int nObjDefnID, |
bool bStatic = false); |
v8::Local<v8::Object> FXJS_GetThisObj(v8::Isolate* pIsolate); |