From 6cf117caa54c3bbf5a787c9ae9ca517a4ac98a16 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 6 Nov 2015 14:52:10 -0800 Subject: Merge to XFA: Rename CFXJS_PrivateData to CFXJS_PerObjectData. Original Review URL: https://codereview.chromium.org/1424933012 . (cherry picked from commit b2dd2c96f6271a1520c36d707b626a34c72f7fb6) R=thestig@chromium.org TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1411333006 . --- fpdfsdk/src/jsapi/fxjs_v8.cpp | 48 ++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 23 deletions(-) (limited to 'fpdfsdk/src/jsapi') diff --git a/fpdfsdk/src/jsapi/fxjs_v8.cpp b/fpdfsdk/src/jsapi/fxjs_v8.cpp index 1801f661ab..5340ff4fd9 100644 --- a/fpdfsdk/src/jsapi/fxjs_v8.cpp +++ b/fpdfsdk/src/jsapi/fxjs_v8.cpp @@ -28,12 +28,13 @@ static size_t g_isolate_ref_count = 0; static FXJS_ArrayBufferAllocator* g_arrayBufferAllocator = nullptr; static v8::Global* g_DefaultGlobalObjectTemplate = nullptr; -class CFXJS_PrivateData { +class CFXJS_PerObjectData { public: - CFXJS_PrivateData(int nObjDefID) : ObjDefID(nObjDefID), pPrivate(NULL) {} + CFXJS_PerObjectData(int nObjDefID) + : m_ObjDefID(nObjDefID), m_pPrivate(nullptr) {} - int ObjDefID; - void* pPrivate; + int m_ObjDefID; + void* m_pPrivate; }; class CFXJS_ObjDefinition { @@ -302,7 +303,7 @@ void FXJS_InitializeRuntime(v8::Isolate* pIsolate, ->GetPrototype() ->ToObject(v8Context) .ToLocalChecked() - ->SetAlignedPointerInInternalField(0, new CFXJS_PrivateData(i)); + ->SetAlignedPointerInInternalField(0, new CFXJS_PerObjectData(i)); if (pObjDef->m_pConstructor) pObjDef->m_pConstructor(pIRuntime, v8Context->Global() @@ -420,7 +421,7 @@ v8::Local FXJS_NewFxDynamicObj(v8::Isolate* pIsolate, if (!pObjDef->GetInstanceTemplate()->NewInstance(context).ToLocal(&obj)) return v8::Local(); - obj->SetAlignedPointerInInternalField(0, new CFXJS_PrivateData(nObjDefnID)); + obj->SetAlignedPointerInInternalField(0, new CFXJS_PerObjectData(nObjDefnID)); if (pObjDef->m_pConstructor) pObjDef->m_pConstructor(pIRuntime, obj); @@ -440,10 +441,10 @@ v8::Local FXJS_GetThisObj(v8::Isolate* pIsolate) { int FXJS_GetObjDefnID(v8::Local pObj) { if (pObj.IsEmpty() || !pObj->InternalFieldCount()) return -1; - CFXJS_PrivateData* pPrivateData = - (CFXJS_PrivateData*)pObj->GetAlignedPointerFromInternalField(0); - if (pPrivateData) - return pPrivateData->ObjDefID; + CFXJS_PerObjectData* pPerObjectData = static_cast( + pObj->GetAlignedPointerFromInternalField(0)); + if (pPerObjectData) + return pPerObjectData->m_ObjDefID; return -1; } @@ -482,35 +483,36 @@ void FXJS_SetPrivate(v8::Isolate* pIsolate, void* p) { if (pObj.IsEmpty() || !pObj->InternalFieldCount()) return; - CFXJS_PrivateData* pPrivateData = - (CFXJS_PrivateData*)pObj->GetAlignedPointerFromInternalField(0); - if (!pPrivateData) + CFXJS_PerObjectData* pPerObjectData = static_cast( + pObj->GetAlignedPointerFromInternalField(0)); + if (!pPerObjectData) return; - pPrivateData->pPrivate = p; + pPerObjectData->m_pPrivate = p; } void* FXJS_GetPrivate(v8::Isolate* pIsolate, v8::Local pObj) { if (pObj.IsEmpty()) return nullptr; - CFXJS_PrivateData* pPrivateData = nullptr; + CFXJS_PerObjectData* pPerObjectData = nullptr; if (pObj->InternalFieldCount()) { - pPrivateData = - (CFXJS_PrivateData*)pObj->GetAlignedPointerFromInternalField(0); + pPerObjectData = static_cast( + pObj->GetAlignedPointerFromInternalField(0)); } else { // It could be a global proxy object. v8::Local v = pObj->GetPrototype(); v8::Local context = pIsolate->GetCurrentContext(); if (v->IsObject()) { - pPrivateData = (CFXJS_PrivateData*)v->ToObject(context) - .ToLocalChecked() - ->GetAlignedPointerFromInternalField(0); + pPerObjectData = static_cast( + v->ToObject(context) + .ToLocalChecked() + ->GetAlignedPointerFromInternalField(0)); } } - return pPrivateData ? pPrivateData->pPrivate : nullptr; + return pPerObjectData ? pPerObjectData->m_pPrivate : nullptr; } -void FXJS_FreePrivate(void* pPrivateData) { - delete (CFXJS_PrivateData*)pPrivateData; +void FXJS_FreePrivate(void* pPerObjectData) { + delete static_cast(pPerObjectData); } void FXJS_FreePrivate(v8::Local pObj) { -- cgit v1.2.3