Rename Init methods to more accurately describe purpose
authorTom Sepez <tsepez@chromium.org>
Fri, 11 Sep 2015 15:18:47 +0000 (08:18 -0700)
committerTom Sepez <tsepez@chromium.org>
Fri, 11 Sep 2015 15:18:47 +0000 (08:18 -0700)
R=thestig@chromium.org

Review URL: https://codereview.chromium.org/1335763002 .

fpdfsdk/include/javascript/Consts.h
fpdfsdk/include/javascript/JS_Define.h
fpdfsdk/include/javascript/JS_Runtime.h
fpdfsdk/src/javascript/Consts.cpp
fpdfsdk/src/javascript/JS_Runtime.cpp

index 1650017..778e221 100644 (file)
@@ -103,14 +103,14 @@ class CJS_Zoomtype : public CJS_Object {
 
 class CJS_GlobalConsts : public CJS_Object {
  public:
-  static int Init(v8::Isolate* pIsolate);
+  static int DefineJSObjects(v8::Isolate* pIsolate);
 };
 
 /* ------------------------------ CJS_GlobalArrays -------------------------- */
 
 class CJS_GlobalArrays : public CJS_Object {
  public:
-  static int Init(v8::Isolate* pIsolate);
+  static int DefineJSObjects(v8::Isolate* pIsolate);
 };
 
 #endif  // FPDFSDK_INCLUDE_JAVASCRIPT_CONSTS_H_
index b850fbe..0731212 100644 (file)
@@ -189,58 +189,52 @@ void JSMethod(const char* method_name_string,
 /* ===================================== JS CLASS
  * =============================================== */
 
-#define DECLARE_JS_CLASS(js_class_name)                                   \
-  static void JSConstructor(IFXJS_Context* cc, v8::Local<v8::Object> obj, \
-                            v8::Local<v8::Object> global);                \
-  static void JSDestructor(v8::Local<v8::Object> obj);                    \
-  static int Init(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType);           \
-  static JSConstSpec JS_Class_Consts[];                                   \
-  static JSPropertySpec JS_Class_Properties[];                            \
-  static JSMethodSpec JS_Class_Methods[];                                 \
+#define DECLARE_JS_CLASS(js_class_name)                                    \
+  static void JSConstructor(IFXJS_Context* cc, v8::Local<v8::Object> obj,  \
+                            v8::Local<v8::Object> global);                 \
+  static void JSDestructor(v8::Local<v8::Object> obj);                     \
+  static int DefineJSObjects(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType); \
+  static JSConstSpec JS_Class_Consts[];                                    \
+  static JSPropertySpec JS_Class_Properties[];                             \
+  static JSMethodSpec JS_Class_Methods[];                                  \
   static const wchar_t* m_pClassName
 
-#define IMPLEMENT_JS_CLASS_RICH(js_class_name, class_alternate, class_name)    \
-  const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name);      \
-  void js_class_name::JSConstructor(IFXJS_Context* cc,                         \
-                                    v8::Local<v8::Object> obj,                 \
-                                    v8::Local<v8::Object> global) {            \
-    CJS_Object* pObj = new js_class_name(obj);                                 \
-    pObj->SetEmbedObject(new class_alternate(pObj));                           \
-    JS_SetPrivate(NULL, obj, (void*)pObj);                                     \
-    pObj->InitInstance(cc);                                                    \
-  }                                                                            \
-                                                                               \
-  void js_class_name::JSDestructor(v8::Local<v8::Object> obj) {                \
-    js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL, obj);            \
-    ASSERT(pObj != NULL);                                                      \
-    pObj->ExitInstance();                                                      \
-    delete pObj;                                                               \
-  }                                                                            \
-                                                                               \
-  int js_class_name::Init(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType) {       \
-    int nObjDefnID = JS_DefineObj(pIsolate, js_class_name::m_pClassName,       \
-                                  eObjType, JSConstructor, JSDestructor);      \
-    if (nObjDefnID >= 0) {                                                     \
-      for (int j = 0,                                                          \
-               szj = sizeof(JS_Class_Properties) / sizeof(JSPropertySpec) - 1; \
-           j < szj; j++) {                                                     \
-        if (JS_DefineObjProperty(pIsolate, nObjDefnID,                         \
-                                 JS_Class_Properties[j].pName,                 \
-                                 JS_Class_Properties[j].pPropGet,              \
-                                 JS_Class_Properties[j].pPropPut) < 0)         \
-          return -1;                                                           \
-      }                                                                        \
-      for (int k = 0,                                                          \
-               szk = sizeof(JS_Class_Methods) / sizeof(JSMethodSpec) - 1;      \
-           k < szk; k++) {                                                     \
-        if (JS_DefineObjMethod(pIsolate, nObjDefnID,                           \
-                               JS_Class_Methods[k].pName,                      \
-                               JS_Class_Methods[k].pMethodCall) < 0)           \
-          return -1;                                                           \
-      }                                                                        \
-      return nObjDefnID;                                                       \
-    }                                                                          \
-    return -1;                                                                 \
+#define IMPLEMENT_JS_CLASS_RICH(js_class_name, class_alternate, class_name)   \
+  const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name);     \
+  void js_class_name::JSConstructor(IFXJS_Context* cc,                        \
+                                    v8::Local<v8::Object> obj,                \
+                                    v8::Local<v8::Object> global) {           \
+    CJS_Object* pObj = new js_class_name(obj);                                \
+    pObj->SetEmbedObject(new class_alternate(pObj));                          \
+    JS_SetPrivate(NULL, obj, (void*)pObj);                                    \
+    pObj->InitInstance(cc);                                                   \
+  }                                                                           \
+                                                                              \
+  void js_class_name::JSDestructor(v8::Local<v8::Object> obj) {               \
+    js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL, obj);           \
+    pObj->ExitInstance();                                                     \
+    delete pObj;                                                              \
+  }                                                                           \
+                                                                              \
+  int js_class_name::DefineJSObjects(v8::Isolate* pIsolate,                   \
+                                     FXJSOBJTYPE eObjType) {                  \
+    int nObjDefnID = JS_DefineObj(pIsolate, js_class_name::m_pClassName,      \
+                                  eObjType, JSConstructor, JSDestructor);     \
+    if (nObjDefnID < 0)                                                       \
+      return -1;                                                              \
+    for (int i = 0; i < FX_ArraySize(JS_Class_Properties) - 1; ++i) {         \
+      if (JS_DefineObjProperty(pIsolate, nObjDefnID,                          \
+                               JS_Class_Properties[i].pName,                  \
+                               JS_Class_Properties[i].pPropGet,               \
+                               JS_Class_Properties[i].pPropPut) < 0)          \
+        return -1;                                                            \
+    }                                                                         \
+    for (int i = 0; i < FX_ArraySize(JS_Class_Methods) - 1; ++i) {            \
+      if (JS_DefineObjMethod(pIsolate, nObjDefnID, JS_Class_Methods[i].pName, \
+                             JS_Class_Methods[i].pMethodCall) < 0)            \
+        return -1;                                                            \
+    }                                                                         \
+    return nObjDefnID;                                                        \
   }
 
 #define IMPLEMENT_JS_CLASS(js_class_name, class_name) \
@@ -249,14 +243,15 @@ void JSMethod(const char* method_name_string,
 /* ======================================== CONST CLASS
  * ============================================ */
 
-#define DECLARE_JS_CLASS_CONST()                                \
-  static int Init(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType); \
-  static JSConstSpec JS_Class_Consts[];                         \
+#define DECLARE_JS_CLASS_CONST()                                           \
+  static int DefineJSObjects(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType); \
+  static JSConstSpec JS_Class_Consts[];                                    \
   static const wchar_t* m_pClassName
 
 #define IMPLEMENT_JS_CLASS_CONST(js_class_name, class_name)                   \
   const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name);     \
-  int js_class_name::Init(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType) {      \
+  int js_class_name::DefineJSObjects(v8::Isolate* pIsolate,                   \
+                                     FXJSOBJTYPE eObjType) {                  \
     int nObjDefnID = JS_DefineObj(pIsolate, js_class_name::m_pClassName,      \
                                   eObjType, NULL, NULL);                      \
     if (nObjDefnID >= 0) {                                                    \
@@ -372,26 +367,26 @@ void JSSpecialPropDel(const char* class_name,
   }
 }
 
-#define DECLARE_SPECIAL_JS_CLASS(js_class_name)                           \
-  static void JSConstructor(IFXJS_Context* cc, v8::Local<v8::Object> obj, \
-                            v8::Local<v8::Object> global);                \
-  static void JSDestructor(v8::Local<v8::Object> obj);                    \
-  static JSConstSpec JS_Class_Consts[];                                   \
-  static JSPropertySpec JS_Class_Properties[];                            \
-  static JSMethodSpec JS_Class_Methods[];                                 \
-  static int Init(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType);           \
-  static const wchar_t* m_pClassName;                                     \
-  static void queryprop_##js_class_name##_static(                         \
-      v8::Local<v8::String> property,                                     \
-      const v8::PropertyCallbackInfo<v8::Integer>& info);                 \
-  static void getprop_##js_class_name##_static(                           \
-      v8::Local<v8::String> property,                                     \
-      const v8::PropertyCallbackInfo<v8::Value>& info);                   \
-  static void putprop_##js_class_name##_static(                           \
-      v8::Local<v8::String> property, v8::Local<v8::Value> value,         \
-      const v8::PropertyCallbackInfo<v8::Value>& info);                   \
-  static void delprop_##js_class_name##_static(                           \
-      v8::Local<v8::String> property,                                     \
+#define DECLARE_SPECIAL_JS_CLASS(js_class_name)                            \
+  static void JSConstructor(IFXJS_Context* cc, v8::Local<v8::Object> obj,  \
+                            v8::Local<v8::Object> global);                 \
+  static void JSDestructor(v8::Local<v8::Object> obj);                     \
+  static JSConstSpec JS_Class_Consts[];                                    \
+  static JSPropertySpec JS_Class_Properties[];                             \
+  static JSMethodSpec JS_Class_Methods[];                                  \
+  static int DefineJSObjects(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType); \
+  static const wchar_t* m_pClassName;                                      \
+  static void queryprop_##js_class_name##_static(                          \
+      v8::Local<v8::String> property,                                      \
+      const v8::PropertyCallbackInfo<v8::Integer>& info);                  \
+  static void getprop_##js_class_name##_static(                            \
+      v8::Local<v8::String> property,                                      \
+      const v8::PropertyCallbackInfo<v8::Value>& info);                    \
+  static void putprop_##js_class_name##_static(                            \
+      v8::Local<v8::String> property, v8::Local<v8::Value> value,          \
+      const v8::PropertyCallbackInfo<v8::Value>& info);                    \
+  static void delprop_##js_class_name##_static(                            \
+      v8::Local<v8::String> property,                                      \
       const v8::PropertyCallbackInfo<v8::Boolean>& info)
 
 #define IMPLEMENT_SPECIAL_JS_CLASS(js_class_name, class_alternate, class_name) \
@@ -432,41 +427,34 @@ void JSSpecialPropDel(const char* class_name,
     delete pObj;                                                               \
   }                                                                            \
                                                                                \
-  int js_class_name::Init(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType) {       \
+  int js_class_name::DefineJSObjects(v8::Isolate* pIsolate,                    \
+                                     FXJSOBJTYPE eObjType) {                   \
     int nObjDefnID = JS_DefineObj(pIsolate, js_class_name::m_pClassName,       \
                                   eObjType, JSConstructor, JSDestructor);      \
                                                                                \
-    if (nObjDefnID >= 0) {                                                     \
-      for (int j = 0,                                                          \
-               szj = sizeof(JS_Class_Properties) / sizeof(JSPropertySpec) - 1; \
-           j < szj; j++) {                                                     \
-        if (JS_DefineObjProperty(pIsolate, nObjDefnID,                         \
-                                 JS_Class_Properties[j].pName,                 \
-                                 JS_Class_Properties[j].pPropGet,              \
-                                 JS_Class_Properties[j].pPropPut) < 0)         \
-          return -1;                                                           \
-      }                                                                        \
-                                                                               \
-      for (int k = 0,                                                          \
-               szk = sizeof(JS_Class_Methods) / sizeof(JSMethodSpec) - 1;      \
-           k < szk; k++) {                                                     \
-        if (JS_DefineObjMethod(pIsolate, nObjDefnID,                           \
-                               JS_Class_Methods[k].pName,                      \
-                               JS_Class_Methods[k].pMethodCall) < 0)           \
-          return -1;                                                           \
-      }                                                                        \
-      if (JS_DefineObjAllProperties(                                           \
-              pIsolate, nObjDefnID,                                            \
-              js_class_name::queryprop_##js_class_name##_static,               \
-              js_class_name::getprop_##js_class_name##_static,                 \
-              js_class_name::putprop_##js_class_name##_static,                 \
-              js_class_name::delprop_##js_class_name##_static) < 0)            \
+    if (nObjDefnID < 0)                                                        \
+      return -1;                                                               \
+    for (int i = 0; i < FX_ArraySize(JS_Class_Properties) - 1; ++i) {          \
+      if (JS_DefineObjProperty(pIsolate, nObjDefnID,                           \
+                               JS_Class_Properties[i].pName,                   \
+                               JS_Class_Properties[i].pPropGet,                \
+                               JS_Class_Properties[i].pPropPut) < 0)           \
         return -1;                                                             \
-                                                                               \
-      return nObjDefnID;                                                       \
     }                                                                          \
                                                                                \
-    return -1;                                                                 \
+    for (int i = 0; i < FX_ArraySize(JS_Class_Methods) - 1; ++i) {             \
+      if (JS_DefineObjMethod(pIsolate, nObjDefnID, JS_Class_Methods[i].pName,  \
+                             JS_Class_Methods[i].pMethodCall) < 0)             \
+        return -1;                                                             \
+    }                                                                          \
+    if (JS_DefineObjAllProperties(                                             \
+            pIsolate, nObjDefnID,                                              \
+            js_class_name::queryprop_##js_class_name##_static,                 \
+            js_class_name::getprop_##js_class_name##_static,                   \
+            js_class_name::putprop_##js_class_name##_static,                   \
+            js_class_name::delprop_##js_class_name##_static) < 0)              \
+      return -1;                                                               \
+    return nObjDefnID;                                                         \
   }
 
 /* ======================================== GLOBAL METHODS
@@ -505,7 +493,7 @@ void JSGlobalFunc(const char* func_name_string,
 
 #define JS_STATIC_DECLARE_GLOBAL_FUN()  \
   static JSMethodSpec global_methods[]; \
-  static int Init(v8::Isolate* pIsolate)
+  static int DefineJSObjects(v8::Isolate* pIsolate)
 
 #define BEGIN_JS_STATIC_GLOBAL_FUN(js_class_name) \
   JSMethodSpec js_class_name::global_methods[] = {
@@ -515,11 +503,8 @@ void JSGlobalFunc(const char* func_name_string,
 #define END_JS_STATIC_GLOBAL_FUN() END_JS_STATIC_METHOD()
 
 #define IMPLEMENT_JS_STATIC_GLOBAL_FUN(js_class_name)            \
-  int js_class_name::Init(v8::Isolate* pIsolate) {               \
-    for (int i = 0, sz = sizeof(js_class_name::global_methods) / \
-                             sizeof(JSMethodSpec) -              \
-                         1;                                      \
-         i < sz; i++) {                                          \
+  int js_class_name::DefineJSObjects(v8::Isolate* pIsolate) {    \
+    for (int i = 0; i < FX_ArraySize(global_methods) - 1; ++i) { \
       if (JS_DefineGlobalMethod(                                 \
               pIsolate, js_class_name::global_methods[i].pName,  \
               js_class_name::global_methods[i].pMethodCall) < 0) \
@@ -528,30 +513,6 @@ void JSGlobalFunc(const char* func_name_string,
     return 0;                                                    \
   }
 
-/* ======================================== GLOBAL CONSTS
- * ============================================ */
-#define DEFINE_GLOBAL_CONST(pIsolate, const_name, const_value) \
-  if (JS_DefineGlobalConst(                                    \
-          pIsolate, JS_WIDESTRING(const_name),                 \
-          JS_NewString(pIsolate, JS_WIDESTRING(const_value)))) \
-  return -1
-
-/* ======================================== GLOBAL ARRAYS
- * ============================================ */
-
-#define DEFINE_GLOBAL_ARRAY(pIsolate)                           \
-  int size = FX_ArraySize(ArrayContent);                        \
-                                                                \
-  CJS_Array array(pIsolate);                                    \
-  for (int i = 0; i < size; i++)                                \
-    array.SetElement(i, CJS_Value(pIsolate, ArrayContent[i]));  \
-                                                                \
-  CJS_PropValue prop(pIsolate);                                 \
-  prop << array;                                                \
-  if (JS_DefineGlobalConst(pIsolate, (const wchar_t*)ArrayName, \
-                           prop.ToV8Value()) < 0)               \
-  return -1
-
 /* ============================================================ */
 
 #define VALUE_NAME_STRING L"string"
index 314330c..e93f8b3 100644 (file)
@@ -42,8 +42,6 @@ class CJS_Runtime : public IFXJS_Runtime {
 
   CPDFDoc_Environment* GetReaderApp() const { return m_pApp; }
 
-  FX_BOOL InitJSObjects();
-
   FX_BOOL AddEventToLoop(const CFX_WideString& sTargetName,
                          JS_EVENT_T eEventType);
   void RemoveEventInLoop(const CFX_WideString& sTargetName,
@@ -57,7 +55,9 @@ class CJS_Runtime : public IFXJS_Runtime {
   v8::Isolate* GetIsolate() const { return m_isolate; }
   v8::Local<v8::Context> NewJSContext();
 
- protected:
+ private:
+  FX_BOOL DefineJSObjects();
+
   CFX_ArrayTemplate<CJS_Context*> m_ContextArray;
   CPDFDoc_Environment* m_pApp;
   CPDFSDK_Document* m_pDocument;
index 77cf445..b534d2b 100644 (file)
@@ -127,10 +127,16 @@ END_JS_STATIC_CONST()
 
 IMPLEMENT_JS_CLASS_CONST(CJS_Zoomtype, zoomtype)
 
-/* ------------------------------ CJS_GlobalConsts
- * ------------------------------ */
+/* ------------------------------ CJS_GlobalConsts ------------------------- */
 
-int CJS_GlobalConsts::Init(v8::Isolate* pIsolate) {
+#define DEFINE_GLOBAL_CONST(pIsolate, const_name, const_value)   \
+  if (JS_DefineGlobalConst(                                      \
+          pIsolate, JS_WIDESTRING(const_name),                   \
+          JS_NewString(pIsolate, JS_WIDESTRING(const_value)))) { \
+    return -1;                                                   \
+  }
+
+int CJS_GlobalConsts::DefineJSObjects(v8::Isolate* pIsolate) {
   DEFINE_GLOBAL_CONST(pIsolate, IDS_GREATER_THAN, Invalid value
                       : must be greater than or equal to % s.);
   DEFINE_GLOBAL_CONST(
@@ -156,10 +162,23 @@ int CJS_GlobalConsts::Init(v8::Isolate* pIsolate) {
   return 0;
 }
 
-/* ------------------------------ CJS_GlobalArrays
- * ------------------------------ */
+/* ------------------------------ CJS_GlobalArrays  ------------------------ */
+
+#define DEFINE_GLOBAL_ARRAY(pIsolate)                           \
+  int size = FX_ArraySize(ArrayContent);                        \
+                                                                \
+  CJS_Array array(pIsolate);                                    \
+  for (int i = 0; i < size; i++)                                \
+    array.SetElement(i, CJS_Value(pIsolate, ArrayContent[i]));  \
+                                                                \
+  CJS_PropValue prop(pIsolate);                                 \
+  prop << array;                                                \
+  if (JS_DefineGlobalConst(pIsolate, (const wchar_t*)ArrayName, \
+                           prop.ToV8Value()) < 0) {             \
+    return -1;                                                  \
+  }
 
-int CJS_GlobalArrays::Init(v8::Isolate* pIsolate) {
+int CJS_GlobalArrays::DefineJSObjects(v8::Isolate* pIsolate) {
   {
     const FX_WCHAR* ArrayName = L"RE_NUMBER_ENTRY_DOT_SEP";
     const FX_WCHAR* ArrayContent[] = {L"[+-]?\\d*\\.?\\d*"};
index e3b3ed0..5f4a473 100644 (file)
@@ -113,7 +113,7 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp)
     m_isolateManaged = true;
   }
 
-  InitJSObjects();
+  DefineJSObjects();
 
   CJS_Context* pContext = (CJS_Context*)NewContext();
   JS_InitialRuntime(GetIsolate(), this, pContext, m_context);
@@ -137,65 +137,72 @@ CJS_Runtime::~CJS_Runtime() {
     m_isolate->Dispose();
 }
 
-FX_BOOL CJS_Runtime::InitJSObjects() {
+FX_BOOL CJS_Runtime::DefineJSObjects() {
   v8::Isolate::Scope isolate_scope(GetIsolate());
   v8::HandleScope handle_scope(GetIsolate());
   v8::Local<v8::Context> context = v8::Context::New(GetIsolate());
   v8::Context::Scope context_scope(context);
-  // 0 - 8
-  if (CJS_Border::Init(GetIsolate(), JS_STATIC) < 0)
+
+  // The call order determines the "ObjDefID" assigned to each class.
+  // ObjDefIDs 0 - 2
+  if (CJS_Border::DefineJSObjects(GetIsolate(), JS_STATIC) < 0)
     return FALSE;
-  if (CJS_Display::Init(GetIsolate(), JS_STATIC) < 0)
+  if (CJS_Display::DefineJSObjects(GetIsolate(), JS_STATIC) < 0)
     return FALSE;
-  if (CJS_Font::Init(GetIsolate(), JS_STATIC) < 0)
+  if (CJS_Font::DefineJSObjects(GetIsolate(), JS_STATIC) < 0)
     return FALSE;
-  if (CJS_Highlight::Init(GetIsolate(), JS_STATIC) < 0)
+
+  // ObjDefIDs 3 - 5
+  if (CJS_Highlight::DefineJSObjects(GetIsolate(), JS_STATIC) < 0)
     return FALSE;
-  if (CJS_Position::Init(GetIsolate(), JS_STATIC) < 0)
+  if (CJS_Position::DefineJSObjects(GetIsolate(), JS_STATIC) < 0)
     return FALSE;
-  if (CJS_ScaleHow::Init(GetIsolate(), JS_STATIC) < 0)
+  if (CJS_ScaleHow::DefineJSObjects(GetIsolate(), JS_STATIC) < 0)
     return FALSE;
-  if (CJS_ScaleWhen::Init(GetIsolate(), JS_STATIC) < 0)
+
+  // ObjDefIDs 6 - 8
+  if (CJS_ScaleWhen::DefineJSObjects(GetIsolate(), JS_STATIC) < 0)
     return FALSE;
-  if (CJS_Style::Init(GetIsolate(), JS_STATIC) < 0)
+  if (CJS_Style::DefineJSObjects(GetIsolate(), JS_STATIC) < 0)
     return FALSE;
-  if (CJS_Zoomtype::Init(GetIsolate(), JS_STATIC) < 0)
+  if (CJS_Zoomtype::DefineJSObjects(GetIsolate(), JS_STATIC) < 0)
     return FALSE;
 
-  // 9 - 11
-  if (CJS_App::Init(GetIsolate(), JS_STATIC) < 0)
+  // ObjDefIDs 9 - 11
+  if (CJS_App::DefineJSObjects(GetIsolate(), JS_STATIC) < 0)
     return FALSE;
-  if (CJS_Color::Init(GetIsolate(), JS_STATIC) < 0)
+  if (CJS_Color::DefineJSObjects(GetIsolate(), JS_STATIC) < 0)
     return FALSE;
-  if (CJS_Console::Init(GetIsolate(), JS_STATIC) < 0)
+  if (CJS_Console::DefineJSObjects(GetIsolate(), JS_STATIC) < 0)
     return FALSE;
 
-  // 12 - 14
-  if (CJS_Document::Init(GetIsolate(), JS_DYNAMIC) < 0)
+  // ObjDefIDs 12 - 14
+  if (CJS_Document::DefineJSObjects(GetIsolate(), JS_DYNAMIC) < 0)
     return FALSE;
-  if (CJS_Event::Init(GetIsolate(), JS_STATIC) < 0)
+  if (CJS_Event::DefineJSObjects(GetIsolate(), JS_STATIC) < 0)
     return FALSE;
-  if (CJS_Field::Init(GetIsolate(), JS_DYNAMIC) < 0)
+  if (CJS_Field::DefineJSObjects(GetIsolate(), JS_DYNAMIC) < 0)
     return FALSE;
 
-  // 15 - 17
-  if (CJS_Global::Init(GetIsolate(), JS_STATIC) < 0)
+  // ObjDefIDs 15 - 17
+  if (CJS_Global::DefineJSObjects(GetIsolate(), JS_STATIC) < 0)
     return FALSE;
-  if (CJS_Icon::Init(GetIsolate(), JS_DYNAMIC) < 0)
+  if (CJS_Icon::DefineJSObjects(GetIsolate(), JS_DYNAMIC) < 0)
     return FALSE;
-  if (CJS_Util::Init(GetIsolate(), JS_STATIC) < 0)
+  if (CJS_Util::DefineJSObjects(GetIsolate(), JS_STATIC) < 0)
     return FALSE;
 
-  if (CJS_PublicMethods::Init(GetIsolate()) < 0)
+  // ObjDefIDs 18 - 20
+  if (CJS_PublicMethods::DefineJSObjects(GetIsolate()) < 0)
     return FALSE;
-  if (CJS_GlobalConsts::Init(GetIsolate()) < 0)
+  if (CJS_GlobalConsts::DefineJSObjects(GetIsolate()) < 0)
     return FALSE;
-  if (CJS_GlobalArrays::Init(GetIsolate()) < 0)
+  if (CJS_GlobalArrays::DefineJSObjects(GetIsolate()) < 0)
     return FALSE;
 
-  if (CJS_TimerObj::Init(GetIsolate(), JS_DYNAMIC) < 0)
+  if (CJS_TimerObj::DefineJSObjects(GetIsolate(), JS_DYNAMIC) < 0)
     return FALSE;
-  if (CJS_PrintParamsObj::Init(GetIsolate(), JS_DYNAMIC) < 0)
+  if (CJS_PrintParamsObj::DefineJSObjects(GetIsolate(), JS_DYNAMIC) < 0)
     return FALSE;
 
   return TRUE;