From e3b2a4eca66e357df663a6f7464ef9af5e85883f Mon Sep 17 00:00:00 2001 From: tsepez Date: Thu, 26 May 2016 12:39:34 -0700 Subject: Rename FXJSE_CLASS to avoid confusion with CFXJSE_CLASS BUG= Review-Url: https://codereview.chromium.org/2010013003 --- xfa/fxjse/class.cpp | 61 +++++++++++++++++++++++++++-------------------- xfa/fxjse/class.h | 6 ++--- xfa/fxjse/context.cpp | 14 ++++++----- xfa/fxjse/context.h | 9 +++---- xfa/fxjse/dynprop.cpp | 42 ++++++++++++++++---------------- xfa/fxjse/include/fxjse.h | 19 ++++++++------- 6 files changed, 83 insertions(+), 68 deletions(-) (limited to 'xfa/fxjse') diff --git a/xfa/fxjse/class.cpp b/xfa/fxjse/class.cpp index a2f4146208..dcc370306a 100644 --- a/xfa/fxjse/class.cpp +++ b/xfa/fxjse/class.cpp @@ -25,15 +25,16 @@ static void FXJSE_V8SetterCallback_Wrapper( const v8::PropertyCallbackInfo& info); CFXJSE_Class* FXJSE_DefineClass(CFXJSE_Context* pContext, - const FXJSE_CLASS* lpClass) { + const FXJSE_CLASS_DESCRIPTOR* lpClass) { ASSERT(pContext); return CFXJSE_Class::Create(pContext, lpClass, FALSE); } static void FXJSE_V8FunctionCallback_Wrapper( const v8::FunctionCallbackInfo& info) { - const FXJSE_FUNCTION* lpFunctionInfo = - static_cast(info.Data().As()->Value()); + const FXJSE_FUNCTION_DESCRIPTOR* lpFunctionInfo = + static_cast( + info.Data().As()->Value()); if (!lpFunctionInfo) { return; } @@ -55,8 +56,9 @@ static void FXJSE_V8FunctionCallback_Wrapper( static void FXJSE_V8ClassGlobalConstructorCallback_Wrapper( const v8::FunctionCallbackInfo& info) { - const FXJSE_CLASS* lpClassDefinition = - static_cast(info.Data().As()->Value()); + const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition = + static_cast( + info.Data().As()->Value()); if (!lpClassDefinition) { return; } @@ -79,8 +81,9 @@ static void FXJSE_V8ClassGlobalConstructorCallback_Wrapper( static void FXJSE_V8GetterCallback_Wrapper( v8::Local property, const v8::PropertyCallbackInfo& info) { - const FXJSE_PROPERTY* lpPropertyInfo = - static_cast(info.Data().As()->Value()); + const FXJSE_PROPERTY_DESCRIPTOR* lpPropertyInfo = + static_cast( + info.Data().As()->Value()); if (!lpPropertyInfo) { return; } @@ -100,8 +103,9 @@ static void FXJSE_V8SetterCallback_Wrapper( v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) { - const FXJSE_PROPERTY* lpPropertyInfo = - static_cast(info.Data().As()->Value()); + const FXJSE_PROPERTY_DESCRIPTOR* lpPropertyInfo = + static_cast( + info.Data().As()->Value()); if (!lpPropertyInfo) { return; } @@ -119,8 +123,9 @@ static void FXJSE_V8SetterCallback_Wrapper( static void FXJSE_V8ConstructorCallback_Wrapper( const v8::FunctionCallbackInfo& info) { - const FXJSE_CLASS* lpClassDefinition = - static_cast(info.Data().As()->Value()); + const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition = + static_cast( + info.Data().As()->Value()); if (!lpClassDefinition) { return; } @@ -193,8 +198,8 @@ CFXJSE_Value* CFXJSE_Arguments::GetReturnValue() { } static void FXJSE_Context_GlobalObjToString( const v8::FunctionCallbackInfo& info) { - const FXJSE_CLASS* lpClass = - static_cast(info.Data().As()->Value()); + const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast( + info.Data().As()->Value()); if (!lpClass) { return; } @@ -213,9 +218,10 @@ static void FXJSE_Context_GlobalObjToString( } } -CFXJSE_Class* CFXJSE_Class::Create(CFXJSE_Context* lpContext, - const FXJSE_CLASS* lpClassDefinition, - FX_BOOL bIsJSGlobal) { +CFXJSE_Class* CFXJSE_Class::Create( + CFXJSE_Context* lpContext, + const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition, + FX_BOOL bIsJSGlobal) { if (!lpContext || !lpClassDefinition) { return NULL; } @@ -231,7 +237,8 @@ CFXJSE_Class* CFXJSE_Class::Create(CFXJSE_Context* lpContext, CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); v8::Local hFunctionTemplate = v8::FunctionTemplate::New( pIsolate, bIsJSGlobal ? 0 : FXJSE_V8ConstructorCallback_Wrapper, - v8::External::New(pIsolate, const_cast(lpClassDefinition))); + v8::External::New( + pIsolate, const_cast(lpClassDefinition))); hFunctionTemplate->SetClassName( v8::String::NewFromUtf8(pIsolate, lpClassDefinition->name)); hFunctionTemplate->InstanceTemplate()->SetInternalFieldCount(1); @@ -250,7 +257,7 @@ CFXJSE_Class* CFXJSE_Class::Create(CFXJSE_Context* lpContext, lpClassDefinition->properties[i].setProc ? FXJSE_V8SetterCallback_Wrapper : NULL, - v8::External::New(pIsolate, const_cast( + v8::External::New(pIsolate, const_cast( lpClassDefinition->properties + i)), static_cast(v8::DontDelete)); } @@ -261,8 +268,9 @@ CFXJSE_Class* CFXJSE_Class::Create(CFXJSE_Context* lpContext, v8::String::NewFromUtf8(pIsolate, lpClassDefinition->methods[i].name), v8::FunctionTemplate::New( pIsolate, FXJSE_V8FunctionCallback_Wrapper, - v8::External::New(pIsolate, const_cast( - lpClassDefinition->methods + i))), + v8::External::New(pIsolate, + const_cast( + lpClassDefinition->methods + i))), static_cast(v8::ReadOnly | v8::DontDelete)); } } @@ -272,8 +280,8 @@ CFXJSE_Class* CFXJSE_Class::Create(CFXJSE_Context* lpContext, v8::String::NewFromUtf8(pIsolate, lpClassDefinition->name), v8::FunctionTemplate::New( pIsolate, FXJSE_V8ClassGlobalConstructorCallback_Wrapper, - v8::External::New(pIsolate, - const_cast(lpClassDefinition))), + v8::External::New(pIsolate, const_cast( + lpClassDefinition))), static_cast(v8::ReadOnly | v8::DontDelete)); } else { v8::Local hLocalContext = @@ -282,8 +290,9 @@ CFXJSE_Class* CFXJSE_Class::Create(CFXJSE_Context* lpContext, ->Set(v8::String::NewFromUtf8(pIsolate, lpClassDefinition->name), v8::Function::New( pIsolate, FXJSE_V8ClassGlobalConstructorCallback_Wrapper, - v8::External::New(pIsolate, const_cast( - lpClassDefinition)))); + v8::External::New(pIsolate, + const_cast( + lpClassDefinition)))); } } if (bIsJSGlobal) { @@ -291,8 +300,8 @@ CFXJSE_Class* CFXJSE_Class::Create(CFXJSE_Context* lpContext, v8::String::NewFromUtf8(pIsolate, "toString"), v8::FunctionTemplate::New( pIsolate, FXJSE_Context_GlobalObjToString, - v8::External::New(pIsolate, - const_cast(lpClassDefinition)))); + v8::External::New(pIsolate, const_cast( + lpClassDefinition)))); } pClass->m_hTemplate.Reset(lpContext->m_pIsolate, hFunctionTemplate); lpContext->m_rgClasses.push_back(std::unique_ptr(pClass)); diff --git a/xfa/fxjse/class.h b/xfa/fxjse/class.h index db52979589..344adf4a47 100644 --- a/xfa/fxjse/class.h +++ b/xfa/fxjse/class.h @@ -25,18 +25,18 @@ class CFXJSE_Class { public: static CFXJSE_Class* Create(CFXJSE_Context* pContext, - const FXJSE_CLASS* lpClassDefintion, + const FXJSE_CLASS_DESCRIPTOR* lpClassDefintion, FX_BOOL bIsJSGlobal = FALSE); static CFXJSE_Class* GetClassFromContext(CFXJSE_Context* pContext, const CFX_ByteStringC& szName); static void SetUpNamedPropHandler( v8::Isolate* pIsolate, v8::Local& hObjectTemplate, - const FXJSE_CLASS* lpClassDefinition); + const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition); protected: CFX_ByteString m_szClassName; - const FXJSE_CLASS* m_lpClassDefinition; + const FXJSE_CLASS_DESCRIPTOR* m_lpClassDefinition; CFXJSE_Context* m_pContext; v8::Global m_hTemplate; friend class CFXJSE_Context; diff --git a/xfa/fxjse/context.cpp b/xfa/fxjse/context.cpp index bdc31e4594..333b2abe57 100644 --- a/xfa/fxjse/context.cpp +++ b/xfa/fxjse/context.cpp @@ -11,9 +11,10 @@ #include "xfa/fxjse/util_inline.h" #include "xfa/fxjse/value.h" -CFXJSE_Context* FXJSE_Context_Create(v8::Isolate* pIsolate, - const FXJSE_CLASS* lpGlobalClass, - void* lpGlobalObject) { +CFXJSE_Context* FXJSE_Context_Create( + v8::Isolate* pIsolate, + const FXJSE_CLASS_DESCRIPTOR* lpGlobalClass, + void* lpGlobalObject) { return CFXJSE_Context::Create(pIsolate, lpGlobalClass, lpGlobalObject); } @@ -111,9 +112,10 @@ v8::Local FXJSE_CreateReturnValue(v8::Isolate* pIsolate, return hReturnValue; } -CFXJSE_Context* CFXJSE_Context::Create(v8::Isolate* pIsolate, - const FXJSE_CLASS* lpGlobalClass, - void* lpGlobalObject) { +CFXJSE_Context* CFXJSE_Context::Create( + v8::Isolate* pIsolate, + const FXJSE_CLASS_DESCRIPTOR* lpGlobalClass, + void* 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 38338311e3..96b93faffd 100644 --- a/xfa/fxjse/context.h +++ b/xfa/fxjse/context.h @@ -16,13 +16,14 @@ class CFXJSE_Class; class CFXJSE_Value; -struct FXJSE_CLASS; +struct FXJSE_CLASS_DESCRIPTOR; class CFXJSE_Context { public: - static CFXJSE_Context* Create(v8::Isolate* pIsolate, - const FXJSE_CLASS* lpGlobalClass = nullptr, - void* lpGlobalObject = nullptr); + static CFXJSE_Context* Create( + v8::Isolate* pIsolate, + const FXJSE_CLASS_DESCRIPTOR* lpGlobalClass = nullptr, + void* lpGlobalObject = nullptr); ~CFXJSE_Context(); V8_INLINE v8::Isolate* GetRuntime(void) { return m_pIsolate; } diff --git a/xfa/fxjse/dynprop.cpp b/xfa/fxjse/dynprop.cpp index 514f1b3a9d..8a2c67126a 100644 --- a/xfa/fxjse/dynprop.cpp +++ b/xfa/fxjse/dynprop.cpp @@ -11,7 +11,7 @@ static void FXJSE_DynPropGetterAdapter_MethodCallback( const v8::FunctionCallbackInfo& info) { v8::Local hCallBackInfo = info.Data().As(); - FXJSE_CLASS* lpClass = static_cast( + FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast( hCallBackInfo->GetAlignedPointerFromInternalField(0)); v8::Local hPropName = hCallBackInfo->GetInternalField(1).As(); @@ -33,7 +33,7 @@ static void FXJSE_DynPropGetterAdapter_MethodCallback( lpThisValue = nullptr; } -static void FXJSE_DynPropGetterAdapter(const FXJSE_CLASS* lpClass, +static void FXJSE_DynPropGetterAdapter(const FXJSE_CLASS_DESCRIPTOR* lpClass, CFXJSE_Value* pObject, const CFX_ByteStringC& szPropName, CFXJSE_Value* pValue) { @@ -56,7 +56,7 @@ static void FXJSE_DynPropGetterAdapter(const FXJSE_CLASS* lpClass, v8::Local hCallBackInfo = hCallBackInfoTemplate->NewInstance(); hCallBackInfo->SetAlignedPointerInInternalField( - 0, const_cast(lpClass)); + 0, const_cast(lpClass)); hCallBackInfo->SetInternalField( 1, v8::String::NewFromUtf8( pIsolate, reinterpret_cast(szPropName.raw_str()), @@ -68,7 +68,7 @@ static void FXJSE_DynPropGetterAdapter(const FXJSE_CLASS* lpClass, } } -static void FXJSE_DynPropSetterAdapter(const FXJSE_CLASS* lpClass, +static void FXJSE_DynPropSetterAdapter(const FXJSE_CLASS_DESCRIPTOR* lpClass, CFXJSE_Value* pObject, const CFX_ByteStringC& szPropName, CFXJSE_Value* pValue) { @@ -84,7 +84,7 @@ static void FXJSE_DynPropSetterAdapter(const FXJSE_CLASS* lpClass, } } -static FX_BOOL FXJSE_DynPropQueryAdapter(const FXJSE_CLASS* lpClass, +static FX_BOOL FXJSE_DynPropQueryAdapter(const FXJSE_CLASS_DESCRIPTOR* lpClass, CFXJSE_Value* pObject, const CFX_ByteStringC& szPropName) { ASSERT(lpClass); @@ -95,9 +95,10 @@ static FX_BOOL FXJSE_DynPropQueryAdapter(const FXJSE_CLASS* lpClass, return nPropType != FXJSE_ClassPropType_None; } -static FX_BOOL FXJSE_DynPropDeleterAdapter(const FXJSE_CLASS* lpClass, - CFXJSE_Value* pObject, - const CFX_ByteStringC& szPropName) { +static FX_BOOL FXJSE_DynPropDeleterAdapter( + const FXJSE_CLASS_DESCRIPTOR* lpClass, + CFXJSE_Value* pObject, + const CFX_ByteStringC& szPropName) { ASSERT(lpClass); int32_t nPropType = lpClass->dynPropTypeGetter == nullptr @@ -117,8 +118,8 @@ static void FXJSE_V8_GenericNamedPropertyQueryCallback( v8::Local property, const v8::PropertyCallbackInfo& info) { v8::Local thisObject = info.This(); - const FXJSE_CLASS* lpClass = - static_cast(info.Data().As()->Value()); + const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast( + info.Data().As()->Value()); v8::Isolate* pIsolate = info.GetIsolate(); v8::HandleScope scope(pIsolate); v8::String::Utf8Value szPropName(property); @@ -139,8 +140,8 @@ static void FXJSE_V8_GenericNamedPropertyDeleterCallback( v8::Local property, const v8::PropertyCallbackInfo& info) { v8::Local thisObject = info.This(); - const FXJSE_CLASS* lpClass = - static_cast(info.Data().As()->Value()); + const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast( + info.Data().As()->Value()); v8::Isolate* pIsolate = info.GetIsolate(); v8::HandleScope scope(pIsolate); v8::String::Utf8Value szPropName(property); @@ -157,8 +158,8 @@ static void FXJSE_V8_GenericNamedPropertyGetterCallback( v8::Local property, const v8::PropertyCallbackInfo& info) { v8::Local thisObject = info.This(); - const FXJSE_CLASS* lpClass = - static_cast(info.Data().As()->Value()); + const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast( + info.Data().As()->Value()); v8::String::Utf8Value szPropName(property); CFX_ByteStringC szFxPropName(*szPropName, szPropName.length()); CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate()); @@ -175,8 +176,8 @@ static void FXJSE_V8_GenericNamedPropertySetterCallback( v8::Local value, const v8::PropertyCallbackInfo& info) { v8::Local thisObject = info.This(); - const FXJSE_CLASS* lpClass = - static_cast(info.Data().As()->Value()); + const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast( + info.Data().As()->Value()); v8::String::Utf8Value szPropName(property); CFX_ByteStringC szFxPropName(*szPropName, szPropName.length()); CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate()); @@ -191,8 +192,8 @@ static void FXJSE_V8_GenericNamedPropertySetterCallback( static void FXJSE_V8_GenericNamedPropertyEnumeratorCallback( const v8::PropertyCallbackInfo& info) { - const FXJSE_CLASS* lpClass = - static_cast(info.Data().As()->Value()); + const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast( + info.Data().As()->Value()); v8::Isolate* pIsolate = info.GetIsolate(); v8::Local newArray = v8::Array::New(pIsolate, lpClass->propNum); for (int i = 0; i < lpClass->propNum; i++) { @@ -205,7 +206,7 @@ static void FXJSE_V8_GenericNamedPropertyEnumeratorCallback( void CFXJSE_Class::SetUpNamedPropHandler( v8::Isolate* pIsolate, v8::Local& hObjectTemplate, - const FXJSE_CLASS* lpClassDefinition) { + const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition) { v8::NamedPropertyHandlerConfiguration configuration( lpClassDefinition->dynPropGetter ? FXJSE_V8_GenericNamedPropertyGetterCallback @@ -220,7 +221,8 @@ void CFXJSE_Class::SetUpNamedPropHandler( ? FXJSE_V8_GenericNamedPropertyDeleterCallback : 0, FXJSE_V8_GenericNamedPropertyEnumeratorCallback, - v8::External::New(pIsolate, const_cast(lpClassDefinition)), + v8::External::New(pIsolate, + const_cast(lpClassDefinition)), v8::PropertyHandlerFlags::kNonMasking); hObjectTemplate->SetHandler(configuration); } diff --git a/xfa/fxjse/include/fxjse.h b/xfa/fxjse/include/fxjse.h index 4484303046..e5d80ca245 100644 --- a/xfa/fxjse/include/fxjse.h +++ b/xfa/fxjse/include/fxjse.h @@ -39,22 +39,22 @@ enum FXJSE_CompatibleModeFlags { FXJSE_COMPATIBLEMODEFLAGCOUNT = 1, }; -struct FXJSE_FUNCTION { +struct FXJSE_FUNCTION_DESCRIPTOR { const FX_CHAR* name; FXJSE_FuncCallback callbackProc; }; -struct FXJSE_PROPERTY { +struct FXJSE_PROPERTY_DESCRIPTOR { const FX_CHAR* name; FXJSE_PropAccessor getProc; FXJSE_PropAccessor setProc; }; -struct FXJSE_CLASS { +struct FXJSE_CLASS_DESCRIPTOR { const FX_CHAR* name; FXJSE_FuncCallback constructor; - FXJSE_PROPERTY* properties; - FXJSE_FUNCTION* methods; + FXJSE_PROPERTY_DESCRIPTOR* properties; + FXJSE_FUNCTION_DESCRIPTOR* methods; int32_t propNum; int32_t methNum; FXJSE_PropTypeGetter dynPropTypeGetter; @@ -70,9 +70,10 @@ void FXJSE_Finalize(); v8::Isolate* FXJSE_Runtime_Create(); void FXJSE_Runtime_Release(v8::Isolate* pIsolate, bool bOwnedRuntime); -CFXJSE_Context* FXJSE_Context_Create(v8::Isolate* pIsolate, - const FXJSE_CLASS* lpGlobalClass = nullptr, - void* lpGlobalObject = nullptr); +CFXJSE_Context* FXJSE_Context_Create( + v8::Isolate* pIsolate, + const FXJSE_CLASS_DESCRIPTOR* lpGlobalClass = nullptr, + void* lpGlobalObject = nullptr); void FXJSE_Context_Release(CFXJSE_Context* pContext); CFXJSE_Value* FXJSE_Context_GetGlobalObject(CFXJSE_Context* pContext); @@ -80,7 +81,7 @@ void FXJSE_Context_EnableCompatibleMode(CFXJSE_Context* pContext, uint32_t dwCompatibleFlags); CFXJSE_Class* FXJSE_DefineClass(CFXJSE_Context* pContext, - const FXJSE_CLASS* lpClass); + const FXJSE_CLASS_DESCRIPTOR* lpClass); CFXJSE_Value* FXJSE_Value_Create(v8::Isolate* pIsolate); void FXJSE_Value_Release(CFXJSE_Value* pValue); -- cgit v1.2.3