diff options
Diffstat (limited to 'xfa/fxjse')
-rw-r--r-- | xfa/fxjse/context.cpp | 25 | ||||
-rw-r--r-- | xfa/fxjse/context.h | 9 | ||||
-rw-r--r-- | xfa/fxjse/include/fxjse.h | 9 | ||||
-rw-r--r-- | xfa/fxjse/value.cpp | 14 | ||||
-rw-r--r-- | xfa/fxjse/value.h | 4 |
5 files changed, 35 insertions, 26 deletions
diff --git a/xfa/fxjse/context.cpp b/xfa/fxjse/context.cpp index d40e2af223..a277d4d412 100644 --- a/xfa/fxjse/context.cpp +++ b/xfa/fxjse/context.cpp @@ -16,27 +16,29 @@ v8::Local<v8::Object> FXJSE_GetGlobalObjectFromContext( } void FXJSE_UpdateObjectBinding(v8::Local<v8::Object>& hObject, - void* lpNewBinding) { + CFXJSE_HostObject* lpNewBinding) { ASSERT(!hObject.IsEmpty()); ASSERT(hObject->InternalFieldCount() > 0); - hObject->SetAlignedPointerInInternalField(0, lpNewBinding); + hObject->SetAlignedPointerInInternalField(0, + static_cast<void*>(lpNewBinding)); } -void* FXJSE_RetrieveObjectBinding(const v8::Local<v8::Object>& hJSObject, - CFXJSE_Class* lpClass) { +CFXJSE_HostObject* FXJSE_RetrieveObjectBinding( + const v8::Local<v8::Object>& hJSObject, + CFXJSE_Class* lpClass) { ASSERT(!hJSObject.IsEmpty()); if (!hJSObject->IsObject()) { - return NULL; + return nullptr; } v8::Local<v8::Object> hObject = hJSObject; if (hObject->InternalFieldCount() == 0) { v8::Local<v8::Value> hProtoObject = hObject->GetPrototype(); if (hProtoObject.IsEmpty() || !hProtoObject->IsObject()) { - return NULL; + return nullptr; } hObject = hProtoObject.As<v8::Object>(); if (hObject->InternalFieldCount() == 0) { - return NULL; + return nullptr; } } if (lpClass) { @@ -44,16 +46,17 @@ void* FXJSE_RetrieveObjectBinding(const v8::Local<v8::Object>& hJSObject, v8::Local<v8::FunctionTemplate>::New( lpClass->GetContext()->GetRuntime(), lpClass->GetTemplate()); if (!hClass->HasInstance(hObject)) { - return NULL; + return nullptr; } } - return hObject->GetAlignedPointerFromInternalField(0); + return static_cast<CFXJSE_HostObject*>( + hObject->GetAlignedPointerFromInternalField(0)); } CFXJSE_Context* FXJSE_Context_Create( v8::Isolate* pIsolate, const FXJSE_CLASS_DESCRIPTOR* lpGlobalClass, - void* lpGlobalObject) { + CFXJSE_HostObject* lpGlobalObject) { return CFXJSE_Context::Create(pIsolate, lpGlobalClass, lpGlobalObject); } @@ -153,7 +156,7 @@ v8::Local<v8::Object> FXJSE_CreateReturnValue(v8::Isolate* pIsolate, CFXJSE_Context* CFXJSE_Context::Create( v8::Isolate* pIsolate, const FXJSE_CLASS_DESCRIPTOR* lpGlobalClass, - void* lpGlobalObject) { + CFXJSE_HostObject* lpGlobalObject) { CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); CFXJSE_Context* pContext = new CFXJSE_Context(pIsolate); CFXJSE_Class* lpGlobalClassObj = NULL; diff --git a/xfa/fxjse/context.h b/xfa/fxjse/context.h index 79e5e0a740..e475752dad 100644 --- a/xfa/fxjse/context.h +++ b/xfa/fxjse/context.h @@ -23,7 +23,7 @@ class CFXJSE_Context { static CFXJSE_Context* Create( v8::Isolate* pIsolate, const FXJSE_CLASS_DESCRIPTOR* lpGlobalClass = nullptr, - void* lpGlobalObject = nullptr); + CFXJSE_HostObject* lpGlobalObject = nullptr); ~CFXJSE_Context(); V8_INLINE v8::Isolate* GetRuntime(void) { return m_pIsolate; } @@ -54,9 +54,10 @@ v8::Local<v8::Object> FXJSE_GetGlobalObjectFromContext( const v8::Local<v8::Context>& hContext); void FXJSE_UpdateObjectBinding(v8::Local<v8::Object>& hObject, - void* lpNewBinding = nullptr); + CFXJSE_HostObject* lpNewBinding = nullptr); -void* FXJSE_RetrieveObjectBinding(const v8::Local<v8::Object>& hJSObject, - CFXJSE_Class* lpClass = nullptr); +CFXJSE_HostObject* FXJSE_RetrieveObjectBinding( + const v8::Local<v8::Object>& hJSObject, + CFXJSE_Class* lpClass = nullptr); #endif // XFA_FXJSE_CONTEXT_H_ diff --git a/xfa/fxjse/include/fxjse.h b/xfa/fxjse/include/fxjse.h index e432858603..4a85251c03 100644 --- a/xfa/fxjse/include/fxjse.h +++ b/xfa/fxjse/include/fxjse.h @@ -16,6 +16,8 @@ class CFXJSE_Class; class CFXJSE_Context; class CFXJSE_Value; +class CFXJSE_HostObject {}; // C++ object which can be wrapped by CFXJSE_value. + typedef void (*FXJSE_FuncCallback)(CFXJSE_Value* pThis, const CFX_ByteStringC& szFuncName, CFXJSE_Arguments& args); @@ -73,7 +75,7 @@ void FXJSE_Runtime_Release(v8::Isolate* pIsolate, bool bOwnedRuntime); CFXJSE_Context* FXJSE_Context_Create( v8::Isolate* pIsolate, const FXJSE_CLASS_DESCRIPTOR* lpGlobalClass, - void* lpGlobalObject); + CFXJSE_HostObject* lpGlobalObject); void FXJSE_Context_Release(CFXJSE_Context* pContext); CFXJSE_Value* FXJSE_Context_GetGlobalObject(CFXJSE_Context* pContext); @@ -98,7 +100,8 @@ double FXJSE_Value_ToDouble(CFXJSE_Value* pValue); int32_t FXJSE_Value_ToInteger(CFXJSE_Value* pValue); void FXJSE_Value_ToUTF8String(CFXJSE_Value* pValue, CFX_ByteString& szStrOutput); -void* FXJSE_Value_ToObject(CFXJSE_Value* pValue, CFXJSE_Class* pClass); +CFXJSE_HostObject* FXJSE_Value_ToObject(CFXJSE_Value* pValue, + CFXJSE_Class* pClass); void FXJSE_Value_SetUndefined(CFXJSE_Value* pValue); void FXJSE_Value_SetNull(CFXJSE_Value* pValue); @@ -109,7 +112,7 @@ void FXJSE_Value_SetInteger(CFXJSE_Value* pValue, int32_t nInteger); void FXJSE_Value_SetFloat(CFXJSE_Value* pValue, FX_FLOAT fFloat); void FXJSE_Value_SetDouble(CFXJSE_Value* pValue, double dDouble); void FXJSE_Value_SetObject(CFXJSE_Value* pValue, - void* lpObject, + CFXJSE_HostObject* lpObject, CFXJSE_Class* pClass); void FXJSE_Value_SetArray(CFXJSE_Value* pValue, uint32_t uValueCount, diff --git a/xfa/fxjse/value.cpp b/xfa/fxjse/value.cpp index 6cdbb14aa3..b369c0bf3b 100644 --- a/xfa/fxjse/value.cpp +++ b/xfa/fxjse/value.cpp @@ -64,7 +64,8 @@ int32_t FXJSE_Value_ToInteger(CFXJSE_Value* pValue) { return pValue->ToInteger(); } -void* FXJSE_Value_ToObject(CFXJSE_Value* pValue, CFXJSE_Class* pClass) { +CFXJSE_HostObject* FXJSE_Value_ToObject(CFXJSE_Value* pValue, + CFXJSE_Class* pClass) { return pValue->ToObject(pClass); } @@ -98,14 +99,14 @@ void FXJSE_Value_SetDouble(CFXJSE_Value* pValue, double dDouble) { } void FXJSE_Value_SetObject(CFXJSE_Value* pValue, - void* lpObject, + CFXJSE_HostObject* lpObject, CFXJSE_Class* pClass) { if (!pClass) { ASSERT(!lpObject); pValue->SetJSObject(); - } else { - pValue->SetHostObject(lpObject, pClass); + return; } + pValue->SetHostObject(lpObject, pClass); } void FXJSE_Value_SetArray(CFXJSE_Value* pValue, @@ -197,7 +198,7 @@ void FXJSE_ThrowMessage(const CFX_ByteStringC& utf8Name, pIsolate->ThrowException(hError); } -void* CFXJSE_Value::ToObject(CFXJSE_Class* lpClass) const { +CFXJSE_HostObject* CFXJSE_Value::ToObject(CFXJSE_Class* lpClass) const { ASSERT(!m_hValue.IsEmpty()); CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); @@ -256,7 +257,8 @@ void CFXJSE_Value::SetFloat(FX_FLOAT fFloat) { m_hValue.Reset(m_pIsolate, pValue); } -void CFXJSE_Value::SetHostObject(void* lpObject, CFXJSE_Class* lpClass) { +void CFXJSE_Value::SetHostObject(CFXJSE_HostObject* lpObject, + CFXJSE_Class* lpClass) { CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); ASSERT(lpClass); v8::Local<v8::FunctionTemplate> hClass = diff --git a/xfa/fxjse/value.h b/xfa/fxjse/value.h index 2dec5824b3..362cd64ace 100644 --- a/xfa/fxjse/value.h +++ b/xfa/fxjse/value.h @@ -141,7 +141,7 @@ class CFXJSE_Value { v8::String::Utf8Value hStringVal(hString); szStrOutput = *hStringVal; } - void* ToObject(CFXJSE_Class* lpClass) const; + CFXJSE_HostObject* ToObject(CFXJSE_Class* lpClass) const; V8_INLINE void SetUndefined() { CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); @@ -182,7 +182,7 @@ class CFXJSE_Value { v8::Local<v8::Value> hValue = v8::Object::New(m_pIsolate); m_hValue.Reset(m_pIsolate, hValue); } - void SetHostObject(void* lpObject, CFXJSE_Class* lpClass); + void SetHostObject(CFXJSE_HostObject* lpObject, CFXJSE_Class* lpClass); void SetArray(uint32_t uValueCount, CFXJSE_Value** rgValues); void SetDate(double dDouble); |