diff options
author | dsinclair <dsinclair@chromium.org> | 2016-05-26 09:40:27 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-26 09:40:27 -0700 |
commit | 7f2abcc015583e63cceb52acde757cb2111420bd (patch) | |
tree | e8dc22bf5164f0c703ff4dda86447b85002c865d /xfa | |
parent | cfaffc09b1d62a81679fb01b0cc85e050be969b7 (diff) | |
download | pdfium-7f2abcc015583e63cceb52acde757cb2111420bd.tar.xz |
Replace FXJSE_HCONTEXT with CFXJSE_Context*
This Cl removes FXJSE_HCONTEXT and replaces it with the concrete CFXJSE_Context.
All varibles have been updated as well to match the new type.
Review-Url: https://codereview.chromium.org/2013963005
Diffstat (limited to 'xfa')
-rw-r--r-- | xfa/fxfa/fm2js/xfa_fm2jsapi.cpp | 6 | ||||
-rw-r--r-- | xfa/fxfa/fm2js/xfa_fm2jsapi.h | 4 | ||||
-rw-r--r-- | xfa/fxfa/fm2js/xfa_fm2jscontext.cpp | 16 | ||||
-rw-r--r-- | xfa/fxfa/fm2js/xfa_fm2jscontext.h | 4 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_script_imp.cpp | 62 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_script_imp.h | 12 | ||||
-rw-r--r-- | xfa/fxjse/class.cpp | 7 | ||||
-rw-r--r-- | xfa/fxjse/context.cpp | 32 | ||||
-rw-r--r-- | xfa/fxjse/context.h | 1 | ||||
-rw-r--r-- | xfa/fxjse/include/fxjse.h | 19 | ||||
-rw-r--r-- | xfa/fxjse/value.h | 22 |
11 files changed, 83 insertions, 102 deletions
diff --git a/xfa/fxfa/fm2js/xfa_fm2jsapi.cpp b/xfa/fxfa/fm2js/xfa_fm2jsapi.cpp index a5992a9709..df817606e2 100644 --- a/xfa/fxfa/fm2js/xfa_fm2jsapi.cpp +++ b/xfa/fxfa/fm2js/xfa_fm2jsapi.cpp @@ -44,12 +44,12 @@ XFA_HFM2JSCONTEXT XFA_FM2JS_ContextCreate() { } void XFA_FM2JS_ContextInitialize(XFA_HFM2JSCONTEXT hFM2JSContext, - v8::Isolate* pScriptRuntime, - FXJSE_HCONTEXT hScriptContext, + v8::Isolate* pScriptIsolate, + CFXJSE_Context* pScriptContext, CXFA_Document* pDocument) { CXFA_FM2JSContext* pContext = reinterpret_cast<CXFA_FM2JSContext*>(hFM2JSContext); - pContext->Initialize(pScriptRuntime, hScriptContext, pDocument); + pContext->Initialize(pScriptIsolate, pScriptContext, pDocument); } void XFA_FM2JS_GlobalPropertyGetter(XFA_HFM2JSCONTEXT hFM2JSContext, diff --git a/xfa/fxfa/fm2js/xfa_fm2jsapi.h b/xfa/fxfa/fm2js/xfa_fm2jsapi.h index 4b0045accf..011ae76ac6 100644 --- a/xfa/fxfa/fm2js/xfa_fm2jsapi.h +++ b/xfa/fxfa/fm2js/xfa_fm2jsapi.h @@ -23,8 +23,8 @@ int32_t XFA_FM2JS_Translate(const CFX_WideStringC& wsFormcalc, CFX_WideString& wsError); XFA_HFM2JSCONTEXT XFA_FM2JS_ContextCreate(); void XFA_FM2JS_ContextInitialize(XFA_HFM2JSCONTEXT hFM2JSContext, - v8::Isolate* pScriptRuntime, - FXJSE_HCONTEXT hScriptContext, + v8::Isolate* pScriptIsolate, + CFXJSE_Context* pScriptContext, CXFA_Document* pDocument); void XFA_FM2JS_GlobalPropertyGetter(XFA_HFM2JSCONTEXT hFM2JSContext, FXJSE_HVALUE hValue); diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp index 7f0514eca0..f875ad2713 100644 --- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp +++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp @@ -3239,16 +3239,16 @@ void CXFA_FM2JSContext::Eval(FXJSE_HOBJECT hThis, XFA_FM2JS_Translate( CFX_WideString::FromUTF8(utf8ScriptString.AsStringC()).AsStringC(), wsJavaScriptBuf, wsError); - FXJSE_HCONTEXT hContext = FXJSE_Context_Create(pIsolate); + CFXJSE_Context* pContext = FXJSE_Context_Create(pIsolate); FXJSE_HVALUE returnValue = FXJSE_Value_Create(pIsolate); javaScript = wsJavaScriptBuf.AsStringC(); FXJSE_ExecuteScript( - hContext, + pContext, FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(), returnValue); FXJSE_Value_Set(args.GetReturnValue(), returnValue); FXJSE_Value_Release(returnValue); - FXJSE_Context_Release(hContext); + FXJSE_Context_Release(pContext); } FXJSE_Value_Release(scriptValue); } else { @@ -7175,11 +7175,11 @@ CXFA_FM2JSContext::~CXFA_FM2JSContext() { } m_pIsolate = NULL; } -void CXFA_FM2JSContext::Initialize(v8::Isolate* hScriptRuntime, - FXJSE_HCONTEXT hScriptContext, +void CXFA_FM2JSContext::Initialize(v8::Isolate* pScriptIsolate, + CFXJSE_Context* pScriptContext, CXFA_Document* pDoc) { m_pDocument = pDoc; - m_pIsolate = hScriptRuntime; + m_pIsolate = pScriptIsolate; m_fmClass.name = "XFA_FM2JS_FormCalcClass"; m_fmClass.constructor = NULL; m_fmClass.properties = NULL; @@ -7187,8 +7187,8 @@ void CXFA_FM2JSContext::Initialize(v8::Isolate* hScriptRuntime, m_fmClass.propNum = 0; m_fmClass.methNum = sizeof(formcalc_fm2js_functions) / sizeof(formcalc_fm2js_functions[0]); - m_hFMClass = FXJSE_DefineClass(hScriptContext, &m_fmClass); - m_hValue = FXJSE_Value_Create(hScriptRuntime); + m_hFMClass = FXJSE_DefineClass(pScriptContext, &m_fmClass); + m_hValue = FXJSE_Value_Create(pScriptIsolate); FXJSE_Value_SetNull(m_hValue); FXJSE_Value_SetObject(m_hValue, this, m_hFMClass); } diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.h b/xfa/fxfa/fm2js/xfa_fm2jscontext.h index 3cd4a0b763..997b32fe59 100644 --- a/xfa/fxfa/fm2js/xfa_fm2jscontext.h +++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.h @@ -435,8 +435,8 @@ class CXFA_FM2JSContext { CXFA_FM2JSContext(); ~CXFA_FM2JSContext(); - void Initialize(v8::Isolate* pScriptRuntime, - FXJSE_HCONTEXT hScriptContext, + void Initialize(v8::Isolate* pScriptIsolate, + CFXJSE_Context* pScriptContext, CXFA_Document* pDoc); void GlobalPropertyGetter(FXJSE_HVALUE hValue); diff --git a/xfa/fxfa/parser/xfa_script_imp.cpp b/xfa/fxfa/parser/xfa_script_imp.cpp index 50810305e4..c29e7a88d0 100644 --- a/xfa/fxfa/parser/xfa_script_imp.cpp +++ b/xfa/fxfa/parser/xfa_script_imp.cpp @@ -22,7 +22,7 @@ CXFA_ScriptContext::CXFA_ScriptContext(CXFA_Document* pDocument) : m_pDocument(pDocument), - m_hJsContext(nullptr), + m_pJsContext(nullptr), m_pIsolate(nullptr), m_hJsClass(nullptr), m_eScriptType(XFA_SCRIPTLANGTYPE_Unkown), @@ -49,9 +49,9 @@ CXFA_ScriptContext::~CXFA_ScriptContext() { XFA_FM2JS_ContextRelease(m_hFM2JSContext); m_hFM2JSContext = NULL; } - if (m_hJsContext) { - FXJSE_Context_Release(m_hJsContext); - m_hJsContext = NULL; + if (m_pJsContext) { + FXJSE_Context_Release(m_pJsContext); + m_pJsContext = NULL; } delete m_pResolveProcessor; m_upObjectArray.RemoveAll(); @@ -74,7 +74,7 @@ FX_BOOL CXFA_ScriptContext::RunScript(XFA_SCRIPTLANGTYPE eScriptType, if (eScriptType == XFA_SCRIPTLANGTYPE_Formcalc) { if (!m_hFM2JSContext) { m_hFM2JSContext = XFA_FM2JS_ContextCreate(); - XFA_FM2JS_ContextInitialize(m_hFM2JSContext, m_pIsolate, m_hJsContext, + XFA_FM2JS_ContextInitialize(m_hFM2JSContext, m_pIsolate, m_pJsContext, m_pDocument); } CFX_WideTextBuf wsJavaScript; @@ -93,7 +93,7 @@ FX_BOOL CXFA_ScriptContext::RunScript(XFA_SCRIPTLANGTYPE eScriptType, m_pThisObject = pThisObject; FXJSE_HVALUE pValue = pThisObject ? GetJSValueFromMap(pThisObject) : NULL; FX_BOOL bRet = - FXJSE_ExecuteScript(m_hJsContext, btScript.c_str(), hRetValue, pValue); + FXJSE_ExecuteScript(m_pJsContext, btScript.c_str(), hRetValue, pValue); m_pThisObject = pOriginalObject; m_eScriptType = eSaveType; return bRet; @@ -384,19 +384,19 @@ void CXFA_ScriptContext::DefineJsContext() { m_JsGlobalClass.dynPropTypeGetter = CXFA_ScriptContext::GlobalPropTypeGetter; m_JsGlobalClass.dynPropDeleter = NULL; m_JsGlobalClass.dynMethodCall = CXFA_ScriptContext::NormalMethodCall; - m_hJsContext = FXJSE_Context_Create(m_pIsolate, &m_JsGlobalClass, + m_pJsContext = FXJSE_Context_Create(m_pIsolate, &m_JsGlobalClass, m_pDocument->GetRoot()); - RemoveBuiltInObjs(m_hJsContext); + RemoveBuiltInObjs(m_pJsContext); FXJSE_Context_EnableCompatibleMode( - m_hJsContext, FXJSE_COMPATIBLEMODEFLAG_CONSTRUCTOREXTRAMETHODS); + m_pJsContext, FXJSE_COMPATIBLEMODEFLAG_CONSTRUCTOREXTRAMETHODS); } -FXJSE_HCONTEXT CXFA_ScriptContext::CreateVariablesContext( +CFXJSE_Context* CXFA_ScriptContext::CreateVariablesContext( CXFA_Node* pScriptNode, CXFA_Node* pSubform) { if (!pScriptNode || !pSubform) return nullptr; - if (m_mapVariableToHValue.GetCount() == 0) { + if (m_mapVariableToContext.GetCount() == 0) { m_JsGlobalVariablesClass.constructor = nullptr; m_JsGlobalVariablesClass.name = "XFAScriptObject"; m_JsGlobalVariablesClass.propNum = 0; @@ -413,14 +413,14 @@ FXJSE_HCONTEXT CXFA_ScriptContext::CreateVariablesContext( m_JsGlobalVariablesClass.dynMethodCall = CXFA_ScriptContext::NormalMethodCall; } - FXJSE_HCONTEXT hVariablesContext = + CFXJSE_Context* pVariablesContext = FXJSE_Context_Create(m_pIsolate, &m_JsGlobalVariablesClass, new CXFA_ThisProxy(pSubform, pScriptNode)); - RemoveBuiltInObjs(hVariablesContext); + RemoveBuiltInObjs(pVariablesContext); FXJSE_Context_EnableCompatibleMode( - hVariablesContext, FXJSE_COMPATIBLEMODEFLAG_CONSTRUCTOREXTRAMETHODS); - m_mapVariableToHValue.SetAt(pScriptNode, hVariablesContext); - return hVariablesContext; + pVariablesContext, FXJSE_COMPATIBLEMODEFLAG_CONSTRUCTOREXTRAMETHODS); + m_mapVariableToContext.SetAt(pScriptNode, pVariablesContext); + return pVariablesContext; } CXFA_Object* CXFA_ScriptContext::GetVariablesThis(CXFA_Object* pObject, FX_BOOL bScriptNode) { @@ -442,7 +442,7 @@ FX_BOOL CXFA_ScriptContext::RunVariablesScript(CXFA_Node* pScriptNode) { if (!pParent || pParent->GetClassID() != XFA_ELEMENT_Variables) return FALSE; - if (m_mapVariableToHValue.GetValueAt(pScriptNode)) + if (m_mapVariableToContext.GetValueAt(pScriptNode)) return TRUE; CXFA_Node* pTextNode = pScriptNode->GetNodeItem(XFA_NODEITEM_FirstChild); @@ -457,12 +457,12 @@ FX_BOOL CXFA_ScriptContext::RunVariablesScript(CXFA_Node* pScriptNode) { FX_UTF8Encode(wsScript.c_str(), wsScript.GetLength()); FXJSE_HVALUE hRetValue = FXJSE_Value_Create(m_pIsolate); CXFA_Node* pThisObject = pParent->GetNodeItem(XFA_NODEITEM_Parent); - FXJSE_HCONTEXT hVariablesContext = + CFXJSE_Context* pVariablesContext = CreateVariablesContext(pScriptNode, pThisObject); CXFA_Object* pOriginalObject = m_pThisObject; m_pThisObject = pThisObject; FX_BOOL bRet = - FXJSE_ExecuteScript(hVariablesContext, btScript.c_str(), hRetValue); + FXJSE_ExecuteScript(pVariablesContext, btScript.c_str(), hRetValue); m_pThisObject = pOriginalObject; FXJSE_Value_Release(hRetValue); return bRet; @@ -480,13 +480,13 @@ FX_BOOL CXFA_ScriptContext::QueryVariableHValue( if (!variablesNode || variablesNode->GetClassID() != XFA_ELEMENT_Variables) return FALSE; - void* lpVariables = m_mapVariableToHValue.GetValueAt(pScriptNode); + void* lpVariables = m_mapVariableToContext.GetValueAt(pScriptNode); if (!lpVariables) return FALSE; FX_BOOL bRes = FALSE; - FXJSE_HCONTEXT hVariableContext = (FXJSE_HCONTEXT)lpVariables; - FXJSE_HVALUE hObject = FXJSE_Context_GetGlobalObject(hVariableContext); + CFXJSE_Context* pVariableContext = static_cast<CFXJSE_Context*>(lpVariables); + FXJSE_HVALUE hObject = FXJSE_Context_GetGlobalObject(pVariableContext); FXJSE_HVALUE hVariableValue = FXJSE_Value_Create(m_pIsolate); if (!bGetter) { FXJSE_Value_SetObjectOwnProp(hObject, szPropName, hValue); @@ -507,17 +507,17 @@ FX_BOOL CXFA_ScriptContext::QueryVariableHValue( } void CXFA_ScriptContext::ReleaseVariablesMap() { - FX_POSITION ps = m_mapVariableToHValue.GetStartPosition(); + FX_POSITION ps = m_mapVariableToContext.GetStartPosition(); while (ps) { CXFA_Object* pScriptNode; - FXJSE_HCONTEXT hVariableContext = nullptr; - m_mapVariableToHValue.GetNextAssoc(ps, pScriptNode, hVariableContext); - FXJSE_HVALUE hObject = FXJSE_Context_GetGlobalObject(hVariableContext); + CFXJSE_Context* pVariableContext = nullptr; + m_mapVariableToContext.GetNextAssoc(ps, pScriptNode, pVariableContext); + FXJSE_HVALUE hObject = FXJSE_Context_GetGlobalObject(pVariableContext); delete static_cast<CXFA_ThisProxy*>(FXJSE_Value_ToObject(hObject, nullptr)); FXJSE_Value_Release(hObject); - FXJSE_Context_Release(hVariableContext); + FXJSE_Context_Release(pVariableContext); } - m_mapVariableToHValue.RemoveAll(); + m_mapVariableToContext.RemoveAll(); } void CXFA_ScriptContext::DefineJsClass() { @@ -532,11 +532,11 @@ void CXFA_ScriptContext::DefineJsClass() { m_JsNormalClass.dynPropTypeGetter = CXFA_ScriptContext::NormalPropTypeGetter; m_JsNormalClass.dynPropDeleter = NULL; m_JsNormalClass.dynMethodCall = CXFA_ScriptContext::NormalMethodCall; - m_hJsClass = FXJSE_DefineClass(m_hJsContext, &m_JsNormalClass); + m_hJsClass = FXJSE_DefineClass(m_pJsContext, &m_JsNormalClass); } -void CXFA_ScriptContext::RemoveBuiltInObjs(FXJSE_HCONTEXT jsContext) const { +void CXFA_ScriptContext::RemoveBuiltInObjs(CFXJSE_Context* pContext) const { static const CFX_ByteStringC OBJ_NAME[2] = {"Number", "Date"}; - FXJSE_HVALUE hObject = FXJSE_Context_GetGlobalObject(jsContext); + FXJSE_HVALUE hObject = FXJSE_Context_GetGlobalObject(pContext); FXJSE_HVALUE hProp = FXJSE_Value_Create(m_pIsolate); for (int i = 0; i < 2; ++i) { if (FXJSE_Value_GetObjectProp(hObject, OBJ_NAME[i], hProp)) diff --git a/xfa/fxfa/parser/xfa_script_imp.h b/xfa/fxfa/parser/xfa_script_imp.h index 7a9f8ae3ff..2efd58914b 100644 --- a/xfa/fxfa/parser/xfa_script_imp.h +++ b/xfa/fxfa/parser/xfa_script_imp.h @@ -93,15 +93,15 @@ class CXFA_ScriptContext { CXFA_NodeArray& GetUpObjectArray() { return m_upObjectArray; } CXFA_Document* GetDocument() const { return m_pDocument; } - protected: + private: void DefineJsContext(); - FXJSE_HCONTEXT CreateVariablesContext(CXFA_Node* pScriptNode, - CXFA_Node* pSubform); + CFXJSE_Context* CreateVariablesContext(CXFA_Node* pScriptNode, + CXFA_Node* pSubform); void DefineJsClass(); - void RemoveBuiltInObjs(FXJSE_HCONTEXT jsContext) const; + void RemoveBuiltInObjs(CFXJSE_Context* pContext) const; CXFA_Document* m_pDocument; - FXJSE_HCONTEXT m_hJsContext; + CFXJSE_Context* m_pJsContext; v8::Isolate* m_pIsolate; FXJSE_HCLASS m_hJsClass; XFA_SCRIPTLANGTYPE m_eScriptType; @@ -109,7 +109,7 @@ class CXFA_ScriptContext { FXJSE_CLASS m_JsNormalClass; CFX_MapPtrTemplate<CXFA_Object*, FXJSE_HVALUE> m_mapXFAToHValue; FXJSE_CLASS m_JsGlobalVariablesClass; - CFX_MapPtrTemplate<CXFA_Object*, FXJSE_HCONTEXT> m_mapVariableToHValue; + CFX_MapPtrTemplate<CXFA_Object*, CFXJSE_Context*> m_mapVariableToContext; CXFA_EventParam m_eventParam; CXFA_NodeArray m_upObjectArray; CFX_ArrayTemplate<CXFA_NodeList*> m_CacheListArray; diff --git a/xfa/fxjse/class.cpp b/xfa/fxjse/class.cpp index ff5990aa85..b7637455fd 100644 --- a/xfa/fxjse/class.cpp +++ b/xfa/fxjse/class.cpp @@ -24,12 +24,11 @@ static void FXJSE_V8SetterCallback_Wrapper( v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info); -FXJSE_HCLASS FXJSE_DefineClass(FXJSE_HCONTEXT hContext, +FXJSE_HCLASS FXJSE_DefineClass(CFXJSE_Context* pContext, const FXJSE_CLASS* lpClass) { - CFXJSE_Context* lpContext = reinterpret_cast<CFXJSE_Context*>(hContext); - ASSERT(lpContext); + ASSERT(pContext); return reinterpret_cast<FXJSE_HCLASS>( - CFXJSE_Class::Create(lpContext, lpClass, FALSE)); + CFXJSE_Class::Create(pContext, lpClass, FALSE)); } static void FXJSE_V8FunctionCallback_Wrapper( diff --git a/xfa/fxjse/context.cpp b/xfa/fxjse/context.cpp index b125177617..76df5616e5 100644 --- a/xfa/fxjse/context.cpp +++ b/xfa/fxjse/context.cpp @@ -11,28 +11,17 @@ #include "xfa/fxjse/util_inline.h" #include "xfa/fxjse/value.h" -namespace { - -CFXJSE_Context* CFXContextFromHContext(FXJSE_HCONTEXT hContext) { - return reinterpret_cast<CFXJSE_Context*>(hContext); -} - -} // namespace - -FXJSE_HCONTEXT FXJSE_Context_Create(v8::Isolate* pIsolate, - const FXJSE_CLASS* lpGlobalClass, - void* lpGlobalObject) { - CFXJSE_Context* pContext = - CFXJSE_Context::Create(pIsolate, lpGlobalClass, lpGlobalObject); - return reinterpret_cast<FXJSE_HCONTEXT>(pContext); +CFXJSE_Context* FXJSE_Context_Create(v8::Isolate* pIsolate, + const FXJSE_CLASS* lpGlobalClass, + void* lpGlobalObject) { + return CFXJSE_Context::Create(pIsolate, lpGlobalClass, lpGlobalObject); } -void FXJSE_Context_Release(FXJSE_HCONTEXT hContext) { - delete CFXContextFromHContext(hContext); +void FXJSE_Context_Release(CFXJSE_Context* pContext) { + delete pContext; } -FXJSE_HVALUE FXJSE_Context_GetGlobalObject(FXJSE_HCONTEXT hContext) { - CFXJSE_Context* pContext = CFXContextFromHContext(hContext); +FXJSE_HVALUE FXJSE_Context_GetGlobalObject(CFXJSE_Context* pContext) { if (!pContext) return nullptr; @@ -68,20 +57,19 @@ static const FX_CHAR* szCompatibleModeScripts[] = { " }\n" " }\n" "}(this, {String: ['substr', 'toUpperCase']}));"}; -void FXJSE_Context_EnableCompatibleMode(FXJSE_HCONTEXT hContext, +void FXJSE_Context_EnableCompatibleMode(CFXJSE_Context* pContext, uint32_t dwCompatibleFlags) { for (uint32_t i = 0; i < (uint32_t)FXJSE_COMPATIBLEMODEFLAGCOUNT; i++) { if (dwCompatibleFlags & (1 << i)) { - FXJSE_ExecuteScript(hContext, szCompatibleModeScripts[i], NULL, NULL); + FXJSE_ExecuteScript(pContext, szCompatibleModeScripts[i], NULL, NULL); } } } -FX_BOOL FXJSE_ExecuteScript(FXJSE_HCONTEXT hContext, +FX_BOOL FXJSE_ExecuteScript(CFXJSE_Context* pContext, const FX_CHAR* szScript, FXJSE_HVALUE hRetValue, FXJSE_HVALUE hNewThisObject) { - CFXJSE_Context* pContext = CFXContextFromHContext(hContext); return pContext->ExecuteScript( szScript, reinterpret_cast<CFXJSE_Value*>(hRetValue), reinterpret_cast<CFXJSE_Value*>(hNewThisObject)); diff --git a/xfa/fxjse/context.h b/xfa/fxjse/context.h index 0092aac7f3..38338311e3 100644 --- a/xfa/fxjse/context.h +++ b/xfa/fxjse/context.h @@ -16,6 +16,7 @@ class CFXJSE_Class; class CFXJSE_Value; +struct FXJSE_CLASS; class CFXJSE_Context { public: diff --git a/xfa/fxjse/include/fxjse.h b/xfa/fxjse/include/fxjse.h index d009372c54..207d86e68c 100644 --- a/xfa/fxjse/include/fxjse.h +++ b/xfa/fxjse/include/fxjse.h @@ -11,10 +11,9 @@ #include "core/fxcrt/include/fx_system.h" #include "v8/include/v8.h" -struct FXJSE_CLASS; class CFXJSE_Arguments; +class CFXJSE_Context; -typedef struct FXJSE_HCONTEXT_ { void* pData; } * FXJSE_HCONTEXT; typedef struct FXJSE_HCLASS_ { void* pData; } * FXJSE_HCLASS; typedef struct FXJSE_HVALUE_ { void* pData; } * FXJSE_HVALUE; // NOLINTNEXTLINE @@ -74,16 +73,16 @@ void FXJSE_Finalize(); v8::Isolate* FXJSE_Runtime_Create(); void FXJSE_Runtime_Release(v8::Isolate* pIsolate, bool bOwnedRuntime); -FXJSE_HCONTEXT FXJSE_Context_Create(v8::Isolate* pIsolate, - const FXJSE_CLASS* lpGlobalClass = nullptr, - void* lpGlobalObject = nullptr); -void FXJSE_Context_Release(FXJSE_HCONTEXT hContext); -FXJSE_HVALUE FXJSE_Context_GetGlobalObject(FXJSE_HCONTEXT hContext); +CFXJSE_Context* FXJSE_Context_Create(v8::Isolate* pIsolate, + const FXJSE_CLASS* lpGlobalClass = nullptr, + void* lpGlobalObject = nullptr); +void FXJSE_Context_Release(CFXJSE_Context* pContext); +FXJSE_HVALUE FXJSE_Context_GetGlobalObject(CFXJSE_Context* pContext); -void FXJSE_Context_EnableCompatibleMode(FXJSE_HCONTEXT hContext, +void FXJSE_Context_EnableCompatibleMode(CFXJSE_Context* pContext, uint32_t dwCompatibleFlags); -FXJSE_HCLASS FXJSE_DefineClass(FXJSE_HCONTEXT hContext, +FXJSE_HCLASS FXJSE_DefineClass(CFXJSE_Context* pContext, const FXJSE_CLASS* lpClass); FXJSE_HVALUE FXJSE_Value_Create(v8::Isolate* pIsolate); @@ -143,7 +142,7 @@ FX_BOOL FXJSE_Value_SetFunctionBind(FXJSE_HVALUE hValue, FXJSE_HVALUE hOldFunction, FXJSE_HVALUE hNewThis); -FX_BOOL FXJSE_ExecuteScript(FXJSE_HCONTEXT hContext, +FX_BOOL FXJSE_ExecuteScript(CFXJSE_Context* pContext, const FX_CHAR* szScript, FXJSE_HVALUE hRetValue, FXJSE_HVALUE hNewThisObject = nullptr); diff --git a/xfa/fxjse/value.h b/xfa/fxjse/value.h index 2939ac34f7..576d092bce 100644 --- a/xfa/fxjse/value.h +++ b/xfa/fxjse/value.h @@ -13,12 +13,6 @@ class CFXJSE_Value { public: CFXJSE_Value(v8::Isolate* pIsolate) : m_pIsolate(pIsolate) {} - protected: - CFXJSE_Value(); - CFXJSE_Value(const CFXJSE_Value&); - CFXJSE_Value& operator=(const CFXJSE_Value&); - - public: V8_INLINE FX_BOOL IsUndefined() const { if (m_hValue.IsEmpty()) { return FALSE; @@ -110,7 +104,6 @@ class CFXJSE_Value { return hValue->IsDate(); } - public: V8_INLINE FX_BOOL ToBoolean() const { ASSERT(!m_hValue.IsEmpty()); CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); @@ -150,7 +143,6 @@ class CFXJSE_Value { } void* ToObject(CFXJSE_Class* lpClass) const; - public: V8_INLINE void SetUndefined() { CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); v8::Local<v8::Value> hValue = v8::Undefined(m_pIsolate); @@ -194,7 +186,6 @@ class CFXJSE_Value { void SetArray(uint32_t uValueCount, CFXJSE_Value** rgValues); void SetDate(double dDouble); - public: FX_BOOL GetObjectProperty(const CFX_ByteStringC& szPropName, CFXJSE_Value* lpPropValue); FX_BOOL SetObjectProperty(const CFX_ByteStringC& szPropName, @@ -212,7 +203,6 @@ class CFXJSE_Value { uint32_t nArgCount, FXJSE_HVALUE* lpArgs); - public: V8_INLINE v8::Isolate* GetIsolate() const { return m_pIsolate; } V8_INLINE const v8::Global<v8::Value>& DirectGetValue() const { return m_hValue; @@ -228,14 +218,18 @@ class CFXJSE_Value { } } - public: static CFXJSE_Value* Create(v8::Isolate* pIsolate); - protected: + private: + friend class CFXJSE_Class; + friend class CFXJSE_Context; + + CFXJSE_Value(); + CFXJSE_Value(const CFXJSE_Value&); + CFXJSE_Value& operator=(const CFXJSE_Value&); + v8::Isolate* m_pIsolate; v8::Global<v8::Value> m_hValue; - friend class CFXJSE_Context; - friend class CFXJSE_Class; }; #endif // XFA_FXJSE_VALUE_H_ |