From ef299534cce8cc42f1bd13665a75947c88195ce0 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 26 Oct 2017 16:48:30 -0400 Subject: Cleanup statics in JS classes This CL removes the static object IDs from each of the CJS_Object subclasses and moves them to anonymous namespaces. The Spec arrays are moved to private members of the object classes. Change-Id: I5dcdb87ef57e4b374b5431580fb55cb75023f8fb Reviewed-on: https://pdfium-review.googlesource.com/16950 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- fpdfsdk/javascript/Field.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'fpdfsdk/javascript/Field.cpp') diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp index 0a35bf5dd4..2a1040655e 100644 --- a/fpdfsdk/javascript/Field.cpp +++ b/fpdfsdk/javascript/Field.cpp @@ -165,14 +165,20 @@ JSMethodSpec CJS_Field::MethodSpecs[] = { {"signatureValidate", signatureValidate_static}, {0, 0}}; -int CJS_Field::g_nObjDefnID = -1; +int CJS_Field::ObjDefnID = -1; +// static +int CJS_Field::GetObjDefnID() { + return ObjDefnID; +} + +// static void CJS_Field::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) { - g_nObjDefnID = + ObjDefnID = pEngine->DefineObj("Field", eObjType, JSConstructor, JSDestructor); - DefineProps(pEngine, g_nObjDefnID, PropertySpecs); - DefineMethods(pEngine, g_nObjDefnID, MethodSpecs); + DefineProps(pEngine, ObjDefnID, PropertySpecs); + DefineMethods(pEngine, ObjDefnID, MethodSpecs); } CJS_DelayData::CJS_DelayData(FIELD_PROP prop, int idx, const WideString& name) @@ -2271,7 +2277,7 @@ CJS_Return Field::buttonGetIcon( return CJS_Return(false); v8::Local pObj = - pRuntime->NewFxDynamicObj(CJS_Icon::g_nObjDefnID); + pRuntime->NewFxDynamicObj(CJS_Icon::GetObjDefnID()); if (pObj.IsEmpty()) return CJS_Return(false); @@ -2391,7 +2397,7 @@ CJS_Return Field::getArray(CJS_Runtime* pRuntime, int j = 0; for (const auto& pStr : swSort) { v8::Local pObj = - pRuntime->NewFxDynamicObj(CJS_Field::g_nObjDefnID); + pRuntime->NewFxDynamicObj(CJS_Field::GetObjDefnID()); if (pObj.IsEmpty()) return CJS_Return(false); -- cgit v1.2.3