Make CJS_Object's ObjDefnID be one-based.
Then use 0 as the invalid object id instead of -1.
Then stop shipping about 80 bytes of "-1" as mutable data, since
zero-initialized .bss doesn't cost anything size-wise.
Change-Id: I79956d85e0e2114038d6f67e11954451097d7d19
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/74970
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fxjs/cfxjs_engine.cpp b/fxjs/cfxjs_engine.cpp
index ae1a9bc..95a03dc 100644
--- a/fxjs/cfxjs_engine.cpp
+++ b/fxjs/cfxjs_engine.cpp
@@ -100,7 +100,7 @@
class CFXJS_PerObjectData {
public:
- explicit CFXJS_PerObjectData(int nObjDefID) : m_ObjDefID(nObjDefID) {}
+ explicit CFXJS_PerObjectData(uint32_t nObjDefnID) : m_ObjDefnID(nObjDefnID) {}
~CFXJS_PerObjectData() = default;
@@ -123,7 +123,7 @@
pObj->GetAlignedPointerFromInternalField(1));
}
- const int m_ObjDefID;
+ const uint32_t m_ObjDefnID;
std::unique_ptr<CJS_Object> m_pPrivate;
};
@@ -223,7 +223,7 @@
static v8::Local<v8::ObjectTemplate> GetGlobalObjectTemplate(
v8::Isolate* pIsolate) {
FXJS_PerIsolateData* pIsolateData = FXJS_PerIsolateData::Get(pIsolate);
- for (int i = 0; i < pIsolateData->MaxObjDefinitionID(); ++i) {
+ for (uint32_t i = 1; i <= pIsolateData->CurrentMaxObjDefinitionID(); ++i) {
CFXJS_ObjDefinition* pObjDef = pIsolateData->ObjDefinitionForID(i);
if (pObjDef->m_ObjType == FXJSOBJTYPE_GLOBAL)
return pObjDef->GetInstanceTemplate();
@@ -245,8 +245,8 @@
v8::Local<v8::Object> obj = value.Get(isolate);
if (obj.IsEmpty())
return;
- int id = CFXJS_Engine::GetObjDefnID(obj);
- if (id == -1)
+ uint32_t id = CFXJS_Engine::GetObjDefnID(obj);
+ if (id == 0)
return;
FXJS_PerIsolateData* pIsolateData = FXJS_PerIsolateData::Get(isolate);
CFXJS_ObjDefinition* pObjDef = pIsolateData->ObjDefinitionForID(id);
@@ -321,22 +321,24 @@
pIsolate->GetData(g_embedderDataSlot));
}
-int FXJS_PerIsolateData::MaxObjDefinitionID() const {
- return pdfium::CollectionSize<int>(m_ObjectDefnArray);
+uint32_t FXJS_PerIsolateData::CurrentMaxObjDefinitionID() const {
+ return pdfium::CollectionSize<uint32_t>(m_ObjectDefnArray);
}
FXJS_PerIsolateData::FXJS_PerIsolateData(v8::Isolate* pIsolate)
- : m_pDynamicObjsMap(new V8TemplateMap(pIsolate)) {}
+ : m_pDynamicObjsMap(std::make_unique<V8TemplateMap>(pIsolate)) {}
-CFXJS_ObjDefinition* FXJS_PerIsolateData::ObjDefinitionForID(int id) const {
- return (id >= 0 && id < MaxObjDefinitionID()) ? m_ObjectDefnArray[id].get()
- : nullptr;
+CFXJS_ObjDefinition* FXJS_PerIsolateData::ObjDefinitionForID(
+ uint32_t id) const {
+ return id > 0 && id <= CurrentMaxObjDefinitionID()
+ ? m_ObjectDefnArray[id - 1].get()
+ : nullptr;
}
-int FXJS_PerIsolateData::AssignIDForObjDefinition(
+uint32_t FXJS_PerIsolateData::AssignIDForObjDefinition(
std::unique_ptr<CFXJS_ObjDefinition> pDefn) {
m_ObjectDefnArray.push_back(std::move(pDefn));
- return m_ObjectDefnArray.size() - 1;
+ return CurrentMaxObjDefinitionID();
}
CFXJS_Engine::CFXJS_Engine() : CFX_V8(nullptr) {}
@@ -346,9 +348,9 @@
CFXJS_Engine::~CFXJS_Engine() = default;
// static
-int CFXJS_Engine::GetObjDefnID(v8::Local<v8::Object> pObj) {
+uint32_t CFXJS_Engine::GetObjDefnID(v8::Local<v8::Object> pObj) {
CFXJS_PerObjectData* pData = CFXJS_PerObjectData::GetFromObject(pObj);
- return pData ? pData->m_ObjDefID : -1;
+ return pData ? pData->m_ObjDefnID : 0;
}
// static
@@ -369,10 +371,10 @@
delete pData;
}
-int CFXJS_Engine::DefineObj(const char* sObjName,
- FXJSOBJTYPE eObjType,
- CFXJS_Engine::Constructor pConstructor,
- CFXJS_Engine::Destructor pDestructor) {
+uint32_t CFXJS_Engine::DefineObj(const char* sObjName,
+ FXJSOBJTYPE eObjType,
+ CFXJS_Engine::Constructor pConstructor,
+ CFXJS_Engine::Destructor pDestructor) {
v8::Isolate::Scope isolate_scope(GetIsolate());
v8::HandleScope handle_scope(GetIsolate());
FXJS_PerIsolateData::SetUp(GetIsolate());
@@ -382,7 +384,7 @@
pConstructor, pDestructor));
}
-void CFXJS_Engine::DefineObjMethod(int nObjDefnID,
+void CFXJS_Engine::DefineObjMethod(uint32_t nObjDefnID,
const char* sMethodName,
v8::FunctionCallback pMethodCall) {
v8::Isolate::Scope isolate_scope(GetIsolate());
@@ -392,7 +394,7 @@
pObjDef->DefineMethod(NewString(sMethodName), pMethodCall);
}
-void CFXJS_Engine::DefineObjProperty(int nObjDefnID,
+void CFXJS_Engine::DefineObjProperty(uint32_t nObjDefnID,
const char* sPropName,
v8::AccessorGetterCallback pPropGet,
v8::AccessorSetterCallback pPropPut) {
@@ -404,7 +406,7 @@
}
void CFXJS_Engine::DefineObjAllProperties(
- int nObjDefnID,
+ uint32_t nObjDefnID,
v8::GenericNamedPropertyQueryCallback pPropQurey,
v8::GenericNamedPropertyGetterCallback pPropGet,
v8::GenericNamedPropertySetterCallback pPropPut,
@@ -416,7 +418,7 @@
pObjDef->DefineAllProperties(pPropQurey, pPropGet, pPropPut, pPropDel);
}
-void CFXJS_Engine::DefineObjConst(int nObjDefnID,
+void CFXJS_Engine::DefineObjConst(uint32_t nObjDefnID,
const char* sConstName,
v8::Local<v8::Value> pDefault) {
v8::Isolate::Scope isolate_scope(GetIsolate());
@@ -476,9 +478,9 @@
v8::Context::Scope context_scope(v8Context);
FXJS_PerIsolateData* pIsolateData = FXJS_PerIsolateData::Get(GetIsolate());
- int maxID = pIsolateData->MaxObjDefinitionID();
+ uint32_t maxID = pIsolateData->CurrentMaxObjDefinitionID();
m_StaticObjects.resize(maxID + 1);
- for (int i = 0; i < maxID; ++i) {
+ for (uint32_t i = 1; i <= maxID; ++i) {
CFXJS_ObjDefinition* pObjDef = pIsolateData->ObjDefinitionForID(i);
if (pObjDef->m_ObjType == FXJSOBJTYPE_GLOBAL) {
CFXJS_PerObjectData::SetInObject(new CFXJS_PerObjectData(i),
@@ -515,7 +517,7 @@
m_ConstArrays.clear();
- for (int i = 0; i < pIsolateData->MaxObjDefinitionID(); ++i) {
+ for (uint32_t i = 1; i <= pIsolateData->CurrentMaxObjDefinitionID(); ++i) {
CFXJS_ObjDefinition* pObjDef = pIsolateData->ObjDefinitionForID(i);
v8::Local<v8::Object> pObj;
if (pObjDef->m_ObjType == FXJSOBJTYPE_GLOBAL) {
@@ -569,7 +571,7 @@
return pdfium::nullopt;
}
-v8::Local<v8::Object> CFXJS_Engine::NewFXJSBoundObject(int nObjDefnID,
+v8::Local<v8::Object> CFXJS_Engine::NewFXJSBoundObject(uint32_t nObjDefnID,
FXJSOBJTYPE type) {
v8::Isolate::Scope isolate_scope(GetIsolate());
v8::Local<v8::Context> context = GetIsolate()->GetCurrentContext();
@@ -640,7 +642,7 @@
return nullptr;
CFXJS_ObjDefinition* pObjDef =
- pIsolateData->ObjDefinitionForID(pProtoData->m_ObjDefID);
+ pIsolateData->ObjDefinitionForID(pProtoData->m_ObjDefnID);
if (!pObjDef || pObjDef->m_ObjType != FXJSOBJTYPE_GLOBAL)
return nullptr;
diff --git a/fxjs/cfxjs_engine.h b/fxjs/cfxjs_engine.h
index 933c250..d4781b2 100644
--- a/fxjs/cfxjs_engine.h
+++ b/fxjs/cfxjs_engine.h
@@ -51,9 +51,9 @@
static void SetUp(v8::Isolate* pIsolate);
static FXJS_PerIsolateData* Get(v8::Isolate* pIsolate);
- int MaxObjDefinitionID() const;
- CFXJS_ObjDefinition* ObjDefinitionForID(int id) const;
- int AssignIDForObjDefinition(std::unique_ptr<CFXJS_ObjDefinition> pDefn);
+ uint32_t CurrentMaxObjDefinitionID() const;
+ CFXJS_ObjDefinition* ObjDefinitionForID(uint32_t id) const;
+ uint32_t AssignIDForObjDefinition(std::unique_ptr<CFXJS_ObjDefinition> pDefn);
std::vector<std::unique_ptr<CFXJS_ObjDefinition>> m_ObjectDefnArray;
std::unique_ptr<V8TemplateMap> m_pDynamicObjsMap;
@@ -83,31 +83,31 @@
std::function<void(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj)>;
using Destructor = std::function<void(v8::Local<v8::Object> obj)>;
- static int GetObjDefnID(v8::Local<v8::Object> pObj);
+ static uint32_t GetObjDefnID(v8::Local<v8::Object> pObj);
static CJS_Object* GetObjectPrivate(v8::Local<v8::Object> pObj);
static void SetObjectPrivate(v8::Local<v8::Object> pObj,
std::unique_ptr<CJS_Object> p);
static void FreeObjectPrivate(v8::Local<v8::Object> pObj);
- // Always returns a valid, newly-created objDefnID.
- int DefineObj(const char* sObjName,
- FXJSOBJTYPE eObjType,
- Constructor pConstructor,
- Destructor pDestructor);
+ // Always returns a valid (i.e. non-zero), newly-created objDefnID.
+ uint32_t DefineObj(const char* sObjName,
+ FXJSOBJTYPE eObjType,
+ Constructor pConstructor,
+ Destructor pDestructor);
- void DefineObjMethod(int nObjDefnID,
+ void DefineObjMethod(uint32_t nObjDefnID,
const char* sMethodName,
v8::FunctionCallback pMethodCall);
- void DefineObjProperty(int nObjDefnID,
+ void DefineObjProperty(uint32_t nObjDefnID,
const char* sPropName,
v8::AccessorGetterCallback pPropGet,
v8::AccessorSetterCallback pPropPut);
- void DefineObjAllProperties(int nObjDefnID,
+ void DefineObjAllProperties(uint32_t nObjDefnID,
v8::GenericNamedPropertyQueryCallback pPropQurey,
v8::GenericNamedPropertyGetterCallback pPropGet,
v8::GenericNamedPropertySetterCallback pPropPut,
v8::GenericNamedPropertyDeleterCallback pPropDel);
- void DefineObjConst(int nObjDefnID,
+ void DefineObjConst(uint32_t nObjDefnID,
const char* sConstName,
v8::Local<v8::Value> pDefault);
void DefineGlobalMethod(const char* sMethodName,
@@ -123,7 +123,8 @@
Optional<IJS_Runtime::JS_Error> Execute(const WideString& script);
v8::Local<v8::Object> GetThisObj();
- v8::Local<v8::Object> NewFXJSBoundObject(int nObjDefnID, FXJSOBJTYPE type);
+ v8::Local<v8::Object> NewFXJSBoundObject(uint32_t nObjDefnID,
+ FXJSOBJTYPE type);
void Error(const WideString& message);
v8::Local<v8::Context> GetV8Context();
diff --git a/fxjs/cfxjs_engine_unittest.cpp b/fxjs/cfxjs_engine_unittest.cpp
index c4644bf..d62e69c 100644
--- a/fxjs/cfxjs_engine_unittest.cpp
+++ b/fxjs/cfxjs_engine_unittest.cpp
@@ -38,7 +38,7 @@
v8::Isolate::Scope isolate_scope(isolate());
v8::HandleScope handle_scope(isolate());
- // Object: 0
+ // Object: 1
engine()->DefineObj(
"perm", FXJSOBJTYPE_DYNAMIC,
[](CFXJS_Engine* pEngine, v8::Local<v8::Object> obj) {
@@ -51,7 +51,7 @@
CFXJS_Engine::SetObjectPrivate(obj, nullptr);
});
- // Object: 1
+ // Object: 2
engine()->DefineObj(
"temp", FXJSOBJTYPE_DYNAMIC,
[](CFXJS_Engine* pEngine, v8::Local<v8::Object> obj) {
@@ -68,7 +68,7 @@
v8::Context::Scope context_scope(engine()->GetV8Context());
v8::Local<v8::Object> perm =
- engine()->NewFXJSBoundObject(0, FXJSOBJTYPE_DYNAMIC);
+ engine()->NewFXJSBoundObject(1, FXJSOBJTYPE_DYNAMIC);
EXPECT_FALSE(perm.IsEmpty());
EXPECT_TRUE(perm_created);
EXPECT_FALSE(perm_destroyed);
@@ -76,7 +76,7 @@
{
v8::HandleScope inner_handle_scope(isolate());
v8::Local<v8::Object> temp =
- engine()->NewFXJSBoundObject(1, FXJSOBJTYPE_DYNAMIC);
+ engine()->NewFXJSBoundObject(2, FXJSOBJTYPE_DYNAMIC);
EXPECT_FALSE(temp.IsEmpty());
EXPECT_TRUE(temp_created);
EXPECT_FALSE(temp_destroyed);
diff --git a/fxjs/cjs_annot.cpp b/fxjs/cjs_annot.cpp
index 292e586..f13479c 100644
--- a/fxjs/cjs_annot.cpp
+++ b/fxjs/cjs_annot.cpp
@@ -18,12 +18,12 @@
{"name", get_name_static, set_name_static},
{"type", get_type_static, set_type_static}};
-int CJS_Annot::ObjDefnID = -1;
+uint32_t CJS_Annot::ObjDefnID = 0;
const char CJS_Annot::kName[] = "Annot";
// static
-int CJS_Annot::GetObjDefnID() {
+uint32_t CJS_Annot::GetObjDefnID() {
return ObjDefnID;
}
diff --git a/fxjs/cjs_annot.h b/fxjs/cjs_annot.h
index ceb2615..4328a90 100644
--- a/fxjs/cjs_annot.h
+++ b/fxjs/cjs_annot.h
@@ -14,7 +14,7 @@
class CJS_Annot final : public CJS_Object {
public:
- static int GetObjDefnID();
+ static uint32_t GetObjDefnID();
static void DefineJSObjects(CFXJS_Engine* pEngine);
CJS_Annot(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime);
@@ -27,7 +27,7 @@
JS_STATIC_PROP(type, type, CJS_Annot)
private:
- static int ObjDefnID;
+ static uint32_t ObjDefnID;
static const char kName[];
static const JSPropertySpec PropertySpecs[];
diff --git a/fxjs/cjs_app.cpp b/fxjs/cjs_app.cpp
index bc71094..80d9224 100644
--- a/fxjs/cjs_app.cpp
+++ b/fxjs/cjs_app.cpp
@@ -63,12 +63,12 @@
{"setInterval", setInterval_static},
{"setTimeOut", setTimeOut_static}};
-int CJS_App::ObjDefnID = -1;
+uint32_t CJS_App::ObjDefnID = 0;
const char CJS_App::kName[] = "app";
// static
-int CJS_App::GetObjDefnID() {
+uint32_t CJS_App::GetObjDefnID() {
return ObjDefnID;
}
diff --git a/fxjs/cjs_app.h b/fxjs/cjs_app.h
index 524a7f0..26184f2 100644
--- a/fxjs/cjs_app.h
+++ b/fxjs/cjs_app.h
@@ -19,7 +19,7 @@
class CJS_App final : public CJS_Object {
public:
- static int GetObjDefnID();
+ static uint32_t GetObjDefnID();
static void DefineJSObjects(CFXJS_Engine* pEngine);
CJS_App(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime);
@@ -66,7 +66,7 @@
JS_STATIC_METHOD(setTimeOut, CJS_App)
private:
- static int ObjDefnID;
+ static uint32_t ObjDefnID;
static const char kName[];
static const JSPropertySpec PropertySpecs[];
static const JSMethodSpec MethodSpecs[];
diff --git a/fxjs/cjs_border.cpp b/fxjs/cjs_border.cpp
index 35204d7..1e8bb10 100644
--- a/fxjs/cjs_border.cpp
+++ b/fxjs/cjs_border.cpp
@@ -13,7 +13,7 @@
{"i", JSConstSpec::String, 0, "inset"},
{"u", JSConstSpec::String, 0, "underline"}};
-int CJS_Border::ObjDefnID = -1;
+uint32_t CJS_Border::ObjDefnID = 0;
// static
void CJS_Border::DefineJSObjects(CFXJS_Engine* pEngine) {
diff --git a/fxjs/cjs_border.h b/fxjs/cjs_border.h
index 0a306f7..735821d 100644
--- a/fxjs/cjs_border.h
+++ b/fxjs/cjs_border.h
@@ -16,7 +16,7 @@
CJS_Border() = delete;
private:
- static int ObjDefnID;
+ static uint32_t ObjDefnID;
static const JSConstSpec ConstSpecs[];
};
diff --git a/fxjs/cjs_color.cpp b/fxjs/cjs_color.cpp
index 2b75e75..b9e415e 100644
--- a/fxjs/cjs_color.cpp
+++ b/fxjs/cjs_color.cpp
@@ -33,11 +33,11 @@
const JSMethodSpec CJS_Color::MethodSpecs[] = {{"convert", convert_static},
{"equal", equal_static}};
-int CJS_Color::ObjDefnID = -1;
+uint32_t CJS_Color::ObjDefnID = 0;
const char CJS_Color::kName[] = "color";
// static
-int CJS_Color::GetObjDefnID() {
+uint32_t CJS_Color::GetObjDefnID() {
return ObjDefnID;
}
diff --git a/fxjs/cjs_color.h b/fxjs/cjs_color.h
index c758fdc..8953241 100644
--- a/fxjs/cjs_color.h
+++ b/fxjs/cjs_color.h
@@ -15,7 +15,7 @@
class CJS_Color final : public CJS_Object {
public:
- static int GetObjDefnID();
+ static uint32_t GetObjDefnID();
static void DefineJSObjects(CFXJS_Engine* pEngine);
static v8::Local<v8::Array> ConvertPWLColorToArray(CJS_Runtime* pRuntime,
const CFX_Color& color);
@@ -42,7 +42,7 @@
JS_STATIC_METHOD(equal, CJS_Color)
private:
- static int ObjDefnID;
+ static uint32_t ObjDefnID;
static const char kName[];
static const JSPropertySpec PropertySpecs[];
static const JSMethodSpec MethodSpecs[];
diff --git a/fxjs/cjs_console.cpp b/fxjs/cjs_console.cpp
index c696bbd..9cd0f36 100644
--- a/fxjs/cjs_console.cpp
+++ b/fxjs/cjs_console.cpp
@@ -18,11 +18,11 @@
{"println", println_static},
{"show", show_static}};
-int CJS_Console::ObjDefnID = -1;
+uint32_t CJS_Console::ObjDefnID = 0;
const char CJS_Console::kName[] = "console";
// static
-int CJS_Console::GetObjDefnID() {
+uint32_t CJS_Console::GetObjDefnID() {
return ObjDefnID;
}
diff --git a/fxjs/cjs_console.h b/fxjs/cjs_console.h
index 2bc118a..37dda9d 100644
--- a/fxjs/cjs_console.h
+++ b/fxjs/cjs_console.h
@@ -14,7 +14,7 @@
class CJS_Console final : public CJS_Object {
public:
- static int GetObjDefnID();
+ static uint32_t GetObjDefnID();
static void DefineJSObjects(CFXJS_Engine* pEngine);
CJS_Console(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime);
@@ -26,7 +26,7 @@
JS_STATIC_METHOD(show, CJS_Console)
private:
- static int ObjDefnID;
+ static uint32_t ObjDefnID;
static const char kName[];
static const JSMethodSpec MethodSpecs[];
diff --git a/fxjs/cjs_display.cpp b/fxjs/cjs_display.cpp
index 71d6c02..a39de17 100644
--- a/fxjs/cjs_display.cpp
+++ b/fxjs/cjs_display.cpp
@@ -12,7 +12,7 @@
{"noPrint", JSConstSpec::Number, 2, 0},
{"noView", JSConstSpec::Number, 3, 0}};
-int CJS_Display::ObjDefnID = -1;
+uint32_t CJS_Display::ObjDefnID = 0;
// static
void CJS_Display::DefineJSObjects(CFXJS_Engine* pEngine) {
diff --git a/fxjs/cjs_display.h b/fxjs/cjs_display.h
index 59b6e9c..43236cd 100644
--- a/fxjs/cjs_display.h
+++ b/fxjs/cjs_display.h
@@ -16,7 +16,7 @@
CJS_Display() = delete;
private:
- static int ObjDefnID;
+ static uint32_t ObjDefnID;
static const JSConstSpec ConstSpecs[];
};
diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp
index a7de0be..5c5a10b 100644
--- a/fxjs/cjs_document.cpp
+++ b/fxjs/cjs_document.cpp
@@ -110,11 +110,11 @@
{"submitForm", submitForm_static},
{"syncAnnotScan", syncAnnotScan_static}};
-int CJS_Document::ObjDefnID = -1;
+uint32_t CJS_Document::ObjDefnID = 0;
const char CJS_Document::kName[] = "Document";
// static
-int CJS_Document::GetObjDefnID() {
+uint32_t CJS_Document::GetObjDefnID() {
return ObjDefnID;
}
diff --git a/fxjs/cjs_document.h b/fxjs/cjs_document.h
index 49448fc..ae855f5 100644
--- a/fxjs/cjs_document.h
+++ b/fxjs/cjs_document.h
@@ -22,7 +22,7 @@
class CJS_Document final : public CJS_Object, public Observable {
public:
- static int GetObjDefnID();
+ static uint32_t GetObjDefnID();
static void DefineJSObjects(CFXJS_Engine* pEngine);
CJS_Document(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime);
@@ -112,7 +112,7 @@
JS_STATIC_METHOD(syncAnnotScan, CJS_Document)
private:
- static int ObjDefnID;
+ static uint32_t ObjDefnID;
static const char kName[];
static const JSPropertySpec PropertySpecs[];
static const JSMethodSpec MethodSpecs[];
diff --git a/fxjs/cjs_event.cpp b/fxjs/cjs_event.cpp
index a16ee6c..ceb1201 100644
--- a/fxjs/cjs_event.cpp
+++ b/fxjs/cjs_event.cpp
@@ -34,11 +34,11 @@
{"value", get_value_static, set_value_static},
{"willCommit", get_will_commit_static, set_will_commit_static}};
-int CJS_Event::ObjDefnID = -1;
+uint32_t CJS_Event::ObjDefnID = 0;
const char CJS_Event::kName[] = "event";
// static
-int CJS_Event::GetObjDefnID() {
+uint32_t CJS_Event::GetObjDefnID() {
return ObjDefnID;
}
diff --git a/fxjs/cjs_event.h b/fxjs/cjs_event.h
index b2fa4dc..d2147cf 100644
--- a/fxjs/cjs_event.h
+++ b/fxjs/cjs_event.h
@@ -12,7 +12,7 @@
class CJS_Event final : public CJS_Object {
public:
- static int GetObjDefnID();
+ static uint32_t GetObjDefnID();
static void DefineJSObjects(CFXJS_Engine* pEngine);
CJS_Event(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime);
@@ -40,7 +40,7 @@
JS_STATIC_PROP(willCommit, will_commit, CJS_Event)
private:
- static int ObjDefnID;
+ static uint32_t ObjDefnID;
static const char kName[];
static const JSPropertySpec PropertySpecs[];
diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp
index 17b6a40..fe762ff 100644
--- a/fxjs/cjs_field.cpp
+++ b/fxjs/cjs_field.cpp
@@ -586,11 +586,11 @@
{"signatureSign", signatureSign_static},
{"signatureValidate", signatureValidate_static}};
-int CJS_Field::ObjDefnID = -1;
+uint32_t CJS_Field::ObjDefnID = 0;
const char CJS_Field::kName[] = "Field";
// static
-int CJS_Field::GetObjDefnID() {
+uint32_t CJS_Field::GetObjDefnID() {
return ObjDefnID;
}
diff --git a/fxjs/cjs_field.h b/fxjs/cjs_field.h
index d772e66..fca91ea 100644
--- a/fxjs/cjs_field.h
+++ b/fxjs/cjs_field.h
@@ -29,7 +29,7 @@
class CJS_Field final : public CJS_Object {
public:
- static int GetObjDefnID();
+ static uint32_t GetObjDefnID();
static void DefineJSObjects(CFXJS_Engine* pEngine);
static void DoDelay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
CJS_DelayData* pData);
@@ -123,7 +123,7 @@
CJS_Result set_text_color(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
private:
- static int ObjDefnID;
+ static uint32_t ObjDefnID;
static const char kName[];
static const JSPropertySpec PropertySpecs[];
static const JSMethodSpec MethodSpecs[];
diff --git a/fxjs/cjs_font.cpp b/fxjs/cjs_font.cpp
index 0e6e94b..22ff950 100644
--- a/fxjs/cjs_font.cpp
+++ b/fxjs/cjs_font.cpp
@@ -22,7 +22,7 @@
{"Symbol", JSConstSpec::String, 0, "Symbol"},
{"ZapfD", JSConstSpec::String, 0, "ZapfDingbats"}};
-int CJS_Font::ObjDefnID = -1;
+uint32_t CJS_Font::ObjDefnID = 0;
// static
void CJS_Font::DefineJSObjects(CFXJS_Engine* pEngine) {
diff --git a/fxjs/cjs_font.h b/fxjs/cjs_font.h
index d3cf159..04b15c0 100644
--- a/fxjs/cjs_font.h
+++ b/fxjs/cjs_font.h
@@ -16,7 +16,7 @@
CJS_Font() = delete;
private:
- static int ObjDefnID;
+ static uint32_t ObjDefnID;
static const JSConstSpec ConstSpecs[];
};
diff --git a/fxjs/cjs_global.cpp b/fxjs/cjs_global.cpp
index a45ccea..3ea04bb 100644
--- a/fxjs/cjs_global.cpp
+++ b/fxjs/cjs_global.cpp
@@ -121,7 +121,7 @@
const JSMethodSpec CJS_Global::MethodSpecs[] = {
{"setPersistent", setPersistent_static}};
-int CJS_Global::ObjDefnID = -1;
+uint32_t CJS_Global::ObjDefnID = 0;
// static
void CJS_Global::setPersistent_static(
@@ -183,7 +183,7 @@
}
// static
-int CJS_Global::GetObjDefnID() {
+uint32_t CJS_Global::GetObjDefnID() {
return ObjDefnID;
}
diff --git a/fxjs/cjs_global.h b/fxjs/cjs_global.h
index 893a69e..0580dbb 100644
--- a/fxjs/cjs_global.h
+++ b/fxjs/cjs_global.h
@@ -29,7 +29,7 @@
class CJS_Global final : public CJS_Object {
public:
- static int GetObjDefnID();
+ static uint32_t GetObjDefnID();
static void DefineJSObjects(CFXJS_Engine* pEngine);
static void DefineAllProperties(CFXJS_Engine* pEngine);
@@ -71,7 +71,7 @@
bool bDeleted = false;
};
- static int ObjDefnID;
+ static uint32_t ObjDefnID;
static const JSMethodSpec MethodSpecs[];
void UpdateGlobalPersistentVariables();
diff --git a/fxjs/cjs_highlight.cpp b/fxjs/cjs_highlight.cpp
index 4ada397..87fc1a9 100644
--- a/fxjs/cjs_highlight.cpp
+++ b/fxjs/cjs_highlight.cpp
@@ -12,7 +12,7 @@
{"p", JSConstSpec::String, 0, "push"},
{"o", JSConstSpec::String, 0, "outline"}};
-int CJS_Highlight::ObjDefnID = -1;
+uint32_t CJS_Highlight::ObjDefnID = 0;
// static
void CJS_Highlight::DefineJSObjects(CFXJS_Engine* pEngine) {
diff --git a/fxjs/cjs_highlight.h b/fxjs/cjs_highlight.h
index efec127..102161a 100644
--- a/fxjs/cjs_highlight.h
+++ b/fxjs/cjs_highlight.h
@@ -16,7 +16,7 @@
CJS_Highlight() = delete;
private:
- static int ObjDefnID;
+ static uint32_t ObjDefnID;
static const JSConstSpec ConstSpecs[];
};
diff --git a/fxjs/cjs_icon.cpp b/fxjs/cjs_icon.cpp
index 80be5c8..f3a2247 100644
--- a/fxjs/cjs_icon.cpp
+++ b/fxjs/cjs_icon.cpp
@@ -9,11 +9,11 @@
const JSPropertySpec CJS_Icon::PropertySpecs[] = {
{"name", get_name_static, set_name_static}};
-int CJS_Icon::ObjDefnID = -1;
+uint32_t CJS_Icon::ObjDefnID = 0;
const char CJS_Icon::kName[] = "Icon";
// static
-int CJS_Icon::GetObjDefnID() {
+uint32_t CJS_Icon::GetObjDefnID() {
return ObjDefnID;
}
diff --git a/fxjs/cjs_icon.h b/fxjs/cjs_icon.h
index 321f508..29f1305 100644
--- a/fxjs/cjs_icon.h
+++ b/fxjs/cjs_icon.h
@@ -12,7 +12,7 @@
class CJS_Icon final : public CJS_Object {
public:
- static int GetObjDefnID();
+ static uint32_t GetObjDefnID();
static void DefineJSObjects(CFXJS_Engine* pEngine);
CJS_Icon(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime);
@@ -24,7 +24,7 @@
JS_STATIC_PROP(name, name, CJS_Icon)
private:
- static int ObjDefnID;
+ static uint32_t ObjDefnID;
static const char kName[];
static const JSPropertySpec PropertySpecs[];
diff --git a/fxjs/cjs_object.cpp b/fxjs/cjs_object.cpp
index b65c4fc..817b4fa 100644
--- a/fxjs/cjs_object.cpp
+++ b/fxjs/cjs_object.cpp
@@ -10,11 +10,11 @@
// static
void CJS_Object::DefineConsts(CFXJS_Engine* pEngine,
- int objId,
+ uint32_t nObjDefnID,
pdfium::span<const JSConstSpec> consts) {
for (const auto& item : consts) {
pEngine->DefineObjConst(
- objId, item.pName,
+ nObjDefnID, item.pName,
item.eType == JSConstSpec::Number
? pEngine->NewNumber(item.number).As<v8::Value>()
: pEngine->NewString(item.pStr).As<v8::Value>());
@@ -23,18 +23,19 @@
// static
void CJS_Object::DefineProps(CFXJS_Engine* pEngine,
- int objId,
+ uint32_t nObjDefnID,
pdfium::span<const JSPropertySpec> props) {
for (const auto& item : props)
- pEngine->DefineObjProperty(objId, item.pName, item.pPropGet, item.pPropPut);
+ pEngine->DefineObjProperty(nObjDefnID, item.pName, item.pPropGet,
+ item.pPropPut);
}
// static
void CJS_Object::DefineMethods(CFXJS_Engine* pEngine,
- int objId,
+ uint32_t nObjDefnID,
pdfium::span<const JSMethodSpec> methods) {
for (const auto& item : methods)
- pEngine->DefineObjMethod(objId, item.pName, item.pMethodCall);
+ pEngine->DefineObjMethod(nObjDefnID, item.pName, item.pMethodCall);
}
CJS_Object::CJS_Object(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime)
diff --git a/fxjs/cjs_object.h b/fxjs/cjs_object.h
index 5da72ff..e451f25 100644
--- a/fxjs/cjs_object.h
+++ b/fxjs/cjs_object.h
@@ -36,13 +36,13 @@
class CJS_Object {
public:
static void DefineConsts(CFXJS_Engine* pEngine,
- int objId,
+ uint32_t nObjDefnID,
pdfium::span<const JSConstSpec> consts);
static void DefineProps(CFXJS_Engine* pEngine,
- int objId,
+ uint32_t nObjDefnID,
pdfium::span<const JSPropertySpec> consts);
static void DefineMethods(CFXJS_Engine* pEngine,
- int objId,
+ uint32_t nObjDefnID,
pdfium::span<const JSMethodSpec> consts);
CJS_Object(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime);
diff --git a/fxjs/cjs_position.cpp b/fxjs/cjs_position.cpp
index dc9594e..c6e2bfa 100644
--- a/fxjs/cjs_position.cpp
+++ b/fxjs/cjs_position.cpp
@@ -15,7 +15,7 @@
{"textIconH", JSConstSpec::Number, 5, 0},
{"overlay", JSConstSpec::Number, 6, 0}};
-int CJS_Position::ObjDefnID = -1;
+uint32_t CJS_Position::ObjDefnID = 0;
// static
void CJS_Position::DefineJSObjects(CFXJS_Engine* pEngine) {
diff --git a/fxjs/cjs_position.h b/fxjs/cjs_position.h
index ae951bf..7319733 100644
--- a/fxjs/cjs_position.h
+++ b/fxjs/cjs_position.h
@@ -16,7 +16,7 @@
CJS_Position() = delete;
private:
- static int ObjDefnID;
+ static uint32_t ObjDefnID;
static const JSConstSpec ConstSpecs[];
};
diff --git a/fxjs/cjs_scalehow.cpp b/fxjs/cjs_scalehow.cpp
index 999949c..2a5fd9f 100644
--- a/fxjs/cjs_scalehow.cpp
+++ b/fxjs/cjs_scalehow.cpp
@@ -10,7 +10,7 @@
{"proportional", JSConstSpec::Number, 0, 0},
{"anamorphic", JSConstSpec::Number, 1, 0}};
-int CJS_ScaleHow::ObjDefnID = -1;
+uint32_t CJS_ScaleHow::ObjDefnID = 0;
// static
void CJS_ScaleHow::DefineJSObjects(CFXJS_Engine* pEngine) {
diff --git a/fxjs/cjs_scalehow.h b/fxjs/cjs_scalehow.h
index f8c7eb5..c71cc70 100644
--- a/fxjs/cjs_scalehow.h
+++ b/fxjs/cjs_scalehow.h
@@ -16,7 +16,7 @@
CJS_ScaleHow() = delete;
private:
- static int ObjDefnID;
+ static uint32_t ObjDefnID;
static const JSConstSpec ConstSpecs[];
};
diff --git a/fxjs/cjs_scalewhen.cpp b/fxjs/cjs_scalewhen.cpp
index 5f39153..dc60aac 100644
--- a/fxjs/cjs_scalewhen.cpp
+++ b/fxjs/cjs_scalewhen.cpp
@@ -12,7 +12,7 @@
{"tooBig", JSConstSpec::Number, 2, 0},
{"tooSmall", JSConstSpec::Number, 3, 0}};
-int CJS_ScaleWhen::ObjDefnID = -1;
+uint32_t CJS_ScaleWhen::ObjDefnID = 0;
// static
void CJS_ScaleWhen::DefineJSObjects(CFXJS_Engine* pEngine) {
diff --git a/fxjs/cjs_scalewhen.h b/fxjs/cjs_scalewhen.h
index ef046f9..df2affc 100644
--- a/fxjs/cjs_scalewhen.h
+++ b/fxjs/cjs_scalewhen.h
@@ -16,7 +16,7 @@
CJS_ScaleWhen() = delete;
private:
- static int ObjDefnID;
+ static uint32_t ObjDefnID;
static const JSConstSpec ConstSpecs[];
};
diff --git a/fxjs/cjs_style.cpp b/fxjs/cjs_style.cpp
index c068702..9c4de87 100644
--- a/fxjs/cjs_style.cpp
+++ b/fxjs/cjs_style.cpp
@@ -14,7 +14,7 @@
{"st", JSConstSpec::String, 0, "star"},
{"sq", JSConstSpec::String, 0, "square"}};
-int CJS_Style::ObjDefnID = -1;
+uint32_t CJS_Style::ObjDefnID = 0;
// static
void CJS_Style::DefineJSObjects(CFXJS_Engine* pEngine) {
diff --git a/fxjs/cjs_style.h b/fxjs/cjs_style.h
index 6e3ee2f..9af4e49 100644
--- a/fxjs/cjs_style.h
+++ b/fxjs/cjs_style.h
@@ -16,7 +16,7 @@
CJS_Style() = delete;
private:
- static int ObjDefnID;
+ static uint32_t ObjDefnID;
static const JSConstSpec ConstSpecs[];
};
diff --git a/fxjs/cjs_timerobj.cpp b/fxjs/cjs_timerobj.cpp
index 5fa1ac3..e19ee19 100644
--- a/fxjs/cjs_timerobj.cpp
+++ b/fxjs/cjs_timerobj.cpp
@@ -9,10 +9,10 @@
#include "fxjs/global_timer.h"
#include "fxjs/js_define.h"
-int CJS_TimerObj::ObjDefnID = -1;
+uint32_t CJS_TimerObj::ObjDefnID = 0;
// static
-int CJS_TimerObj::GetObjDefnID() {
+uint32_t CJS_TimerObj::GetObjDefnID() {
return ObjDefnID;
}
diff --git a/fxjs/cjs_timerobj.h b/fxjs/cjs_timerobj.h
index 69effa6..6a1f80f 100644
--- a/fxjs/cjs_timerobj.h
+++ b/fxjs/cjs_timerobj.h
@@ -13,7 +13,7 @@
class CJS_TimerObj final : public CJS_Object {
public:
- static int GetObjDefnID();
+ static uint32_t GetObjDefnID();
static void DefineJSObjects(CFXJS_Engine* pEngine);
CJS_TimerObj(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime);
@@ -23,7 +23,7 @@
int GetTimerID() const { return m_nTimerID; }
private:
- static int ObjDefnID;
+ static uint32_t ObjDefnID;
int m_nTimerID = 0; // Weak reference to GlobalTimer through global map.
};
diff --git a/fxjs/cjs_util.cpp b/fxjs/cjs_util.cpp
index 029ed7a..f33ac83 100644
--- a/fxjs/cjs_util.cpp
+++ b/fxjs/cjs_util.cpp
@@ -77,11 +77,11 @@
{"scand", scand_static},
{"byteToChar", byteToChar_static}};
-int CJS_Util::ObjDefnID = -1;
+uint32_t CJS_Util::ObjDefnID = 0;
const char CJS_Util::kName[] = "util";
// static
-int CJS_Util::GetObjDefnID() {
+uint32_t CJS_Util::GetObjDefnID() {
return ObjDefnID;
}
diff --git a/fxjs/cjs_util.h b/fxjs/cjs_util.h
index 6f55b3a..e565520 100644
--- a/fxjs/cjs_util.h
+++ b/fxjs/cjs_util.h
@@ -20,7 +20,7 @@
class CJS_Util final : public CJS_Object {
public:
- static int GetObjDefnID();
+ static uint32_t GetObjDefnID();
static void DefineJSObjects(CFXJS_Engine* pEngine);
CJS_Util(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime);
@@ -46,7 +46,7 @@
JS_STATIC_METHOD(byteToChar, CJS_Util)
private:
- static int ObjDefnID;
+ static uint32_t ObjDefnID;
static const char kName[];
static const JSMethodSpec MethodSpecs[];
diff --git a/fxjs/cjs_zoomtype.cpp b/fxjs/cjs_zoomtype.cpp
index cdaa2d5..c64be98 100644
--- a/fxjs/cjs_zoomtype.cpp
+++ b/fxjs/cjs_zoomtype.cpp
@@ -15,7 +15,7 @@
{"pref", JSConstSpec::String, 0, "Preferred"},
{"refW", JSConstSpec::String, 0, "ReflowWidth"}};
-int CJS_Zoomtype::ObjDefnID = -1;
+uint32_t CJS_Zoomtype::ObjDefnID = 0;
// static
void CJS_Zoomtype::DefineJSObjects(CFXJS_Engine* pEngine) {
diff --git a/fxjs/cjs_zoomtype.h b/fxjs/cjs_zoomtype.h
index de268cd..b27deb3 100644
--- a/fxjs/cjs_zoomtype.h
+++ b/fxjs/cjs_zoomtype.h
@@ -16,7 +16,7 @@
CJS_Zoomtype() = delete;
private:
- static int ObjDefnID;
+ static uint32_t ObjDefnID;
static const JSConstSpec ConstSpecs[];
};