diff options
-rw-r--r-- | fpdfsdk/javascript/Document.cpp | 47 | ||||
-rw-r--r-- | fpdfsdk/javascript/Document.h | 20 | ||||
-rw-r--r-- | fpdfsdk/javascript/Field.cpp | 13 | ||||
-rw-r--r-- | fpdfsdk/javascript/Field.h | 10 | ||||
-rw-r--r-- | fpdfsdk/javascript/Icon.cpp | 23 | ||||
-rw-r--r-- | fpdfsdk/javascript/Icon.h | 10 | ||||
-rw-r--r-- | fpdfsdk/javascript/app.cpp | 47 | ||||
-rw-r--r-- | fpdfsdk/javascript/app.h | 20 | ||||
-rw-r--r-- | fpdfsdk/javascript/cjs_annot.cpp | 23 | ||||
-rw-r--r-- | fpdfsdk/javascript/cjs_annot.h | 10 | ||||
-rw-r--r-- | fpdfsdk/javascript/color.cpp | 13 | ||||
-rw-r--r-- | fpdfsdk/javascript/color.h | 10 | ||||
-rw-r--r-- | fpdfsdk/javascript/console.cpp | 24 | ||||
-rw-r--r-- | fpdfsdk/javascript/console.h | 10 | ||||
-rw-r--r-- | fpdfsdk/javascript/event.cpp | 23 | ||||
-rw-r--r-- | fpdfsdk/javascript/event.h | 10 | ||||
-rw-r--r-- | fpdfsdk/javascript/report.cpp | 24 | ||||
-rw-r--r-- | fpdfsdk/javascript/report.h | 10 | ||||
-rw-r--r-- | fpdfsdk/javascript/util.cpp | 24 | ||||
-rw-r--r-- | fpdfsdk/javascript/util.h | 10 |
20 files changed, 50 insertions, 331 deletions
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp index 940b7b7bd5..a5724e8f76 100644 --- a/fpdfsdk/javascript/Document.cpp +++ b/fpdfsdk/javascript/Document.cpp @@ -38,25 +38,9 @@ #include "third_party/base/numerics/safe_math.h" #include "third_party/base/ptr_util.h" -JSConstSpec CJS_PrintParamsObj::ConstSpecs[] = {{0, JSConstSpec::Number, 0, 0}}; - -JSPropertySpec CJS_PrintParamsObj::PropertySpecs[] = {{0, 0, 0}}; - -JSMethodSpec CJS_PrintParamsObj::MethodSpecs[] = {{0, 0}}; - const char* CJS_PrintParamsObj::g_pClassName = "PrintParamsObj"; int CJS_PrintParamsObj::g_nObjDefnID = -1; -void CJS_PrintParamsObj::DefineConsts(CFXJS_Engine* pEngine) { - for (size_t i = 0; i < FX_ArraySize(ConstSpecs) - 1; ++i) { - pEngine->DefineObjConst( - g_nObjDefnID, ConstSpecs[i].pName, - ConstSpecs[i].eType == JSConstSpec::Number - ? pEngine->NewNumber(ConstSpecs[i].number).As<v8::Value>() - : pEngine->NewString(ConstSpecs[i].pStr).As<v8::Value>()); - } -} - void CJS_PrintParamsObj::JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj) { CJS_Object* pObj = new CJS_PrintParamsObj(obj); @@ -70,28 +54,10 @@ void CJS_PrintParamsObj::JSDestructor(CFXJS_Engine* pEngine, delete static_cast<CJS_PrintParamsObj*>(pEngine->GetObjectPrivate(obj)); } -void CJS_PrintParamsObj::DefineProps(CFXJS_Engine* pEngine) { - for (size_t i = 0; i < FX_ArraySize(PropertySpecs) - 1; ++i) { - pEngine->DefineObjProperty(g_nObjDefnID, PropertySpecs[i].pName, - PropertySpecs[i].pPropGet, - PropertySpecs[i].pPropPut); - } -} - -void CJS_PrintParamsObj::DefineMethods(CFXJS_Engine* pEngine) { - for (size_t i = 0; i < FX_ArraySize(MethodSpecs) - 1; ++i) { - pEngine->DefineObjMethod(g_nObjDefnID, MethodSpecs[i].pName, - MethodSpecs[i].pMethodCall); - } -} - void CJS_PrintParamsObj::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) { g_nObjDefnID = pEngine->DefineObj(CJS_PrintParamsObj::g_pClassName, eObjType, JSConstructor, JSDestructor); - DefineConsts(pEngine); - DefineProps(pEngine); - DefineMethods(pEngine); } PrintParamsObj::PrintParamsObj(CJS_Object* pJSObject) @@ -109,8 +75,6 @@ PrintParamsObj::PrintParamsObj(CJS_Object* pJSObject) #define MINWIDTH 5.0f #define MINHEIGHT 5.0f -JSConstSpec CJS_Document::ConstSpecs[] = {{0, JSConstSpec::Number, 0, 0}}; - JSPropertySpec CJS_Document::PropertySpecs[] = { {"ADBE", get_ADBE_static, set_ADBE_static}, {"author", get_author_static, set_author_static}, @@ -196,16 +160,6 @@ JSMethodSpec CJS_Document::MethodSpecs[] = { const char* CJS_Document::g_pClassName = "Document"; int CJS_Document::g_nObjDefnID = -1; -void CJS_Document::DefineConsts(CFXJS_Engine* pEngine) { - for (size_t i = 0; i < FX_ArraySize(ConstSpecs) - 1; ++i) { - pEngine->DefineObjConst( - g_nObjDefnID, ConstSpecs[i].pName, - ConstSpecs[i].eType == JSConstSpec::Number - ? pEngine->NewNumber(ConstSpecs[i].number).As<v8::Value>() - : pEngine->NewString(ConstSpecs[i].pStr).As<v8::Value>()); - } -} - void CJS_Document::JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj) { CJS_Object* pObj = new CJS_Document(obj); @@ -238,7 +192,6 @@ void CJS_Document::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) { g_nObjDefnID = pEngine->DefineObj(CJS_Document::g_pClassName, eObjType, JSConstructor, JSDestructor); - DefineConsts(pEngine); DefineProps(pEngine); DefineMethods(pEngine); } diff --git a/fpdfsdk/javascript/Document.h b/fpdfsdk/javascript/Document.h index 3c6c388e0a..6ec916ca14 100644 --- a/fpdfsdk/javascript/Document.h +++ b/fpdfsdk/javascript/Document.h @@ -40,15 +40,11 @@ class CJS_PrintParamsObj : public CJS_Object { static const char* g_pClassName; static int g_nObjDefnID; - static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType); - static JSConstSpec ConstSpecs[]; - static void DefineConsts(CFXJS_Engine* pEngine); + static void JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); static void JSDestructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); - static void DefineProps(CFXJS_Engine* pEngine); - static void DefineMethods(CFXJS_Engine* pEngine); - static JSPropertySpec PropertySpecs[]; - static JSMethodSpec MethodSpecs[]; + + static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType); }; struct CJS_AnnotObj; @@ -281,15 +277,15 @@ class CJS_Document : public CJS_Object { static const char* g_pClassName; static int g_nObjDefnID; - static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType); - static JSConstSpec ConstSpecs[]; - static void DefineConsts(CFXJS_Engine* pEngine); + static JSPropertySpec PropertySpecs[]; + static JSMethodSpec MethodSpecs[]; + static void JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); static void JSDestructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); + + static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType); static void DefineProps(CFXJS_Engine* pEngine); static void DefineMethods(CFXJS_Engine* pEngine); - static JSPropertySpec PropertySpecs[]; - static JSMethodSpec MethodSpecs[]; JS_STATIC_PROP(ADBE, ADBE, Document); JS_STATIC_PROP(author, author, Document); diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp index 0729292f53..34c0c7a89e 100644 --- a/fpdfsdk/javascript/Field.cpp +++ b/fpdfsdk/javascript/Field.cpp @@ -72,8 +72,6 @@ bool SetWidgetDisplayStatus(CPDFSDK_Widget* pWidget, int value) { } // namespace -JSConstSpec CJS_Field::ConstSpecs[] = {{0, JSConstSpec::Number, 0, 0}}; - JSPropertySpec CJS_Field::PropertySpecs[] = { {"alignment", get_alignment_static, set_alignment_static}, {"borderStyle", get_border_style_static, set_border_style_static}, @@ -170,16 +168,6 @@ JSMethodSpec CJS_Field::MethodSpecs[] = { const char* CJS_Field::g_pClassName = "Field"; int CJS_Field::g_nObjDefnID = -1; -void CJS_Field::DefineConsts(CFXJS_Engine* pEngine) { - for (size_t i = 0; i < FX_ArraySize(ConstSpecs) - 1; ++i) { - pEngine->DefineObjConst( - g_nObjDefnID, ConstSpecs[i].pName, - ConstSpecs[i].eType == JSConstSpec::Number - ? pEngine->NewNumber(ConstSpecs[i].number).As<v8::Value>() - : pEngine->NewString(ConstSpecs[i].pStr).As<v8::Value>()); - } -} - void CJS_Field::JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj) { CJS_Object* pObj = new CJS_Field(obj); @@ -210,7 +198,6 @@ void CJS_Field::DefineMethods(CFXJS_Engine* pEngine) { void CJS_Field::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) { g_nObjDefnID = pEngine->DefineObj(CJS_Field::g_pClassName, eObjType, JSConstructor, JSDestructor); - DefineConsts(pEngine); DefineProps(pEngine); DefineMethods(pEngine); } diff --git a/fpdfsdk/javascript/Field.h b/fpdfsdk/javascript/Field.h index 41f85350f7..cd43b601d9 100644 --- a/fpdfsdk/javascript/Field.h +++ b/fpdfsdk/javascript/Field.h @@ -366,15 +366,15 @@ class CJS_Field : public CJS_Object { static const char* g_pClassName; static int g_nObjDefnID; - static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType); - static JSConstSpec ConstSpecs[]; - static void DefineConsts(CFXJS_Engine* pEngine); + static JSPropertySpec PropertySpecs[]; + static JSMethodSpec MethodSpecs[]; + static void JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); static void JSDestructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); + + static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType); static void DefineProps(CFXJS_Engine* pEngine); static void DefineMethods(CFXJS_Engine* pEngine); - static JSPropertySpec PropertySpecs[]; - static JSMethodSpec MethodSpecs[]; JS_STATIC_PROP(alignment, alignment, Field); JS_STATIC_PROP(borderStyle, border_style, Field); diff --git a/fpdfsdk/javascript/Icon.cpp b/fpdfsdk/javascript/Icon.cpp index 0d9b1d5538..d64878bcc9 100644 --- a/fpdfsdk/javascript/Icon.cpp +++ b/fpdfsdk/javascript/Icon.cpp @@ -10,27 +10,13 @@ #include "fpdfsdk/javascript/JS_Object.h" #include "fpdfsdk/javascript/JS_Value.h" -JSConstSpec CJS_Icon::ConstSpecs[] = {{0, JSConstSpec::Number, 0, 0}}; - JSPropertySpec CJS_Icon::PropertySpecs[] = { {"name", get_name_static, set_name_static}, {0, 0, 0}}; -JSMethodSpec CJS_Icon::MethodSpecs[] = {{0, 0}}; - const char* CJS_Icon::g_pClassName = "Icon"; int CJS_Icon::g_nObjDefnID = -1; -void CJS_Icon::DefineConsts(CFXJS_Engine* pEngine) { - for (size_t i = 0; i < FX_ArraySize(ConstSpecs) - 1; ++i) { - pEngine->DefineObjConst( - g_nObjDefnID, ConstSpecs[i].pName, - ConstSpecs[i].eType == JSConstSpec::Number - ? pEngine->NewNumber(ConstSpecs[i].number).As<v8::Value>() - : pEngine->NewString(ConstSpecs[i].pStr).As<v8::Value>()); - } -} - void CJS_Icon::JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj) { CJS_Object* pObj = new CJS_Icon(obj); pObj->SetEmbedObject(new Icon(pObj)); @@ -50,19 +36,10 @@ void CJS_Icon::DefineProps(CFXJS_Engine* pEngine) { } } -void CJS_Icon::DefineMethods(CFXJS_Engine* pEngine) { - for (size_t i = 0; i < FX_ArraySize(MethodSpecs) - 1; ++i) { - pEngine->DefineObjMethod(g_nObjDefnID, MethodSpecs[i].pName, - MethodSpecs[i].pMethodCall); - } -} - void CJS_Icon::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) { g_nObjDefnID = pEngine->DefineObj(CJS_Icon::g_pClassName, eObjType, JSConstructor, JSDestructor); - DefineConsts(pEngine); DefineProps(pEngine); - DefineMethods(pEngine); } Icon::Icon(CJS_Object* pJSObject) diff --git a/fpdfsdk/javascript/Icon.h b/fpdfsdk/javascript/Icon.h index 60a5c30066..8f2c8fc411 100644 --- a/fpdfsdk/javascript/Icon.h +++ b/fpdfsdk/javascript/Icon.h @@ -33,15 +33,13 @@ class CJS_Icon : public CJS_Object { static const char* g_pClassName; static int g_nObjDefnID; - static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType); - static JSConstSpec ConstSpecs[]; - static void DefineConsts(CFXJS_Engine* pEngine); + static JSPropertySpec PropertySpecs[]; + static void JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); static void JSDestructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); + + static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType); static void DefineProps(CFXJS_Engine* pEngine); - static void DefineMethods(CFXJS_Engine* pEngine); - static JSPropertySpec PropertySpecs[]; - static JSMethodSpec MethodSpecs[]; JS_STATIC_PROP(name, name, Icon); }; diff --git a/fpdfsdk/javascript/app.cpp b/fpdfsdk/javascript/app.cpp index 486c74dc8f..84bca4a26d 100644 --- a/fpdfsdk/javascript/app.cpp +++ b/fpdfsdk/javascript/app.cpp @@ -142,25 +142,9 @@ GlobalTimer::TimerMap* GlobalTimer::GetGlobalTimerMap() { return s_TimerMap; } -JSConstSpec CJS_TimerObj::ConstSpecs[] = {{0, JSConstSpec::Number, 0, 0}}; - -JSPropertySpec CJS_TimerObj::PropertySpecs[] = {{0, 0, 0}}; - -JSMethodSpec CJS_TimerObj::MethodSpecs[] = {{0, 0}}; - const char* CJS_TimerObj::g_pClassName = "TimerObj"; int CJS_TimerObj::g_nObjDefnID = -1; -void CJS_TimerObj::DefineConsts(CFXJS_Engine* pEngine) { - for (size_t i = 0; i < FX_ArraySize(ConstSpecs) - 1; ++i) { - pEngine->DefineObjConst( - g_nObjDefnID, ConstSpecs[i].pName, - ConstSpecs[i].eType == JSConstSpec::Number - ? pEngine->NewNumber(ConstSpecs[i].number).As<v8::Value>() - : pEngine->NewString(ConstSpecs[i].pStr).As<v8::Value>()); - } -} - void CJS_TimerObj::JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj) { CJS_Object* pObj = new CJS_TimerObj(obj); @@ -174,28 +158,10 @@ void CJS_TimerObj::JSDestructor(CFXJS_Engine* pEngine, delete static_cast<CJS_TimerObj*>(pEngine->GetObjectPrivate(obj)); } -void CJS_TimerObj::DefineProps(CFXJS_Engine* pEngine) { - for (size_t i = 0; i < FX_ArraySize(PropertySpecs) - 1; ++i) { - pEngine->DefineObjProperty(g_nObjDefnID, PropertySpecs[i].pName, - PropertySpecs[i].pPropGet, - PropertySpecs[i].pPropPut); - } -} - -void CJS_TimerObj::DefineMethods(CFXJS_Engine* pEngine) { - for (size_t i = 0; i < FX_ArraySize(MethodSpecs) - 1; ++i) { - pEngine->DefineObjMethod(g_nObjDefnID, MethodSpecs[i].pName, - MethodSpecs[i].pMethodCall); - } -} - void CJS_TimerObj::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) { g_nObjDefnID = pEngine->DefineObj(CJS_TimerObj::g_pClassName, eObjType, JSConstructor, JSDestructor); - DefineConsts(pEngine); - DefineProps(pEngine); - DefineMethods(pEngine); } TimerObj::TimerObj(CJS_Object* pJSObject) @@ -217,8 +183,6 @@ void TimerObj::SetTimer(GlobalTimer* pTimer) { #endif // PDF_ENABLE_XFA #define JS_NUM_FORMSVERSION 7 -JSConstSpec CJS_App::ConstSpecs[] = {{0, JSConstSpec::Number, 0, 0}}; - JSPropertySpec CJS_App::PropertySpecs[] = { {"activeDocs", get_active_docs_static, set_active_docs_static}, {"calculate", get_calculate_static, set_calculate_static}, @@ -262,16 +226,6 @@ JSMethodSpec CJS_App::MethodSpecs[] = {{"alert", alert_static}, const char* CJS_App::g_pClassName = "app"; int CJS_App::g_nObjDefnID = -1; -void CJS_App::DefineConsts(CFXJS_Engine* pEngine) { - for (size_t i = 0; i < FX_ArraySize(ConstSpecs) - 1; ++i) { - pEngine->DefineObjConst( - g_nObjDefnID, ConstSpecs[i].pName, - ConstSpecs[i].eType == JSConstSpec::Number - ? pEngine->NewNumber(ConstSpecs[i].number).As<v8::Value>() - : pEngine->NewString(ConstSpecs[i].pStr).As<v8::Value>()); - } -} - void CJS_App::JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj) { CJS_Object* pObj = new CJS_App(obj); pObj->SetEmbedObject(new app(pObj)); @@ -301,7 +255,6 @@ void CJS_App::DefineMethods(CFXJS_Engine* pEngine) { void CJS_App::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) { g_nObjDefnID = pEngine->DefineObj(CJS_App::g_pClassName, eObjType, JSConstructor, JSDestructor); - DefineConsts(pEngine); DefineProps(pEngine); DefineMethods(pEngine); } diff --git a/fpdfsdk/javascript/app.h b/fpdfsdk/javascript/app.h index 41190ca0d7..36d2a84bdd 100644 --- a/fpdfsdk/javascript/app.h +++ b/fpdfsdk/javascript/app.h @@ -35,15 +35,11 @@ class CJS_TimerObj : public CJS_Object { static const char* g_pClassName; static int g_nObjDefnID; - static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType); - static JSConstSpec ConstSpecs[]; - static void DefineConsts(CFXJS_Engine* pEngine); + static void JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); static void JSDestructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); - static void DefineProps(CFXJS_Engine* pEngine); - static void DefineMethods(CFXJS_Engine* pEngine); - static JSPropertySpec PropertySpecs[]; - static JSMethodSpec MethodSpecs[]; + + static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType); }; class app : public CJS_EmbedObj { @@ -155,15 +151,15 @@ class CJS_App : public CJS_Object { static const char* g_pClassName; static int g_nObjDefnID; - static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType); - static JSConstSpec ConstSpecs[]; - static void DefineConsts(CFXJS_Engine* pEngine); + static JSPropertySpec PropertySpecs[]; + static JSMethodSpec MethodSpecs[]; + static void JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); static void JSDestructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); + + static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType); static void DefineProps(CFXJS_Engine* pEngine); static void DefineMethods(CFXJS_Engine* pEngine); - static JSPropertySpec PropertySpecs[]; - static JSMethodSpec MethodSpecs[]; JS_STATIC_PROP(activeDocs, active_docs, app); JS_STATIC_PROP(calculate, calculate, app); diff --git a/fpdfsdk/javascript/cjs_annot.cpp b/fpdfsdk/javascript/cjs_annot.cpp index 82d11cc15e..8847642d13 100644 --- a/fpdfsdk/javascript/cjs_annot.cpp +++ b/fpdfsdk/javascript/cjs_annot.cpp @@ -19,29 +19,15 @@ CPDFSDK_BAAnnot* ToBAAnnot(CPDFSDK_Annot* annot) { } // namespace -JSConstSpec CJS_Annot::ConstSpecs[] = {{0, JSConstSpec::Number, 0, 0}}; - JSPropertySpec CJS_Annot::PropertySpecs[] = { {"hidden", get_hidden_static, set_hidden_static}, {"name", get_name_static, set_name_static}, {"type", get_type_static, set_type_static}, {0, 0, 0}}; -JSMethodSpec CJS_Annot::MethodSpecs[] = {{0, 0}}; - const char* CJS_Annot::g_pClassName = "Annot"; int CJS_Annot::g_nObjDefnID = -1; -void CJS_Annot::DefineConsts(CFXJS_Engine* pEngine) { - for (size_t i = 0; i < FX_ArraySize(ConstSpecs) - 1; ++i) { - pEngine->DefineObjConst( - g_nObjDefnID, ConstSpecs[i].pName, - ConstSpecs[i].eType == JSConstSpec::Number - ? pEngine->NewNumber(ConstSpecs[i].number).As<v8::Value>() - : pEngine->NewString(ConstSpecs[i].pStr).As<v8::Value>()); - } -} - void CJS_Annot::JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj) { CJS_Object* pObj = new CJS_Annot(obj); @@ -62,19 +48,10 @@ void CJS_Annot::DefineProps(CFXJS_Engine* pEngine) { } } -void CJS_Annot::DefineMethods(CFXJS_Engine* pEngine) { - for (size_t i = 0; i < FX_ArraySize(MethodSpecs) - 1; ++i) { - pEngine->DefineObjMethod(g_nObjDefnID, MethodSpecs[i].pName, - MethodSpecs[i].pMethodCall); - } -} - void CJS_Annot::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) { g_nObjDefnID = pEngine->DefineObj(CJS_Annot::g_pClassName, eObjType, JSConstructor, JSDestructor); - DefineConsts(pEngine); DefineProps(pEngine); - DefineMethods(pEngine); } Annot::Annot(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {} diff --git a/fpdfsdk/javascript/cjs_annot.h b/fpdfsdk/javascript/cjs_annot.h index 74162ea87f..086392c225 100644 --- a/fpdfsdk/javascript/cjs_annot.h +++ b/fpdfsdk/javascript/cjs_annot.h @@ -37,15 +37,13 @@ class CJS_Annot : public CJS_Object { static const char* g_pClassName; static int g_nObjDefnID; - static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType); - static JSConstSpec ConstSpecs[]; - static void DefineConsts(CFXJS_Engine* pEngine); + static JSPropertySpec PropertySpecs[]; + static void JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); static void JSDestructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); + + static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType); static void DefineProps(CFXJS_Engine* pEngine); - static void DefineMethods(CFXJS_Engine* pEngine); - static JSPropertySpec PropertySpecs[]; - static JSMethodSpec MethodSpecs[]; JS_STATIC_PROP(hidden, hidden, Annot); JS_STATIC_PROP(name, name, Annot); diff --git a/fpdfsdk/javascript/color.cpp b/fpdfsdk/javascript/color.cpp index 6c80ca0886..25008b4452 100644 --- a/fpdfsdk/javascript/color.cpp +++ b/fpdfsdk/javascript/color.cpp @@ -15,8 +15,6 @@ #include "fpdfsdk/javascript/cjs_eventhandler.h" #include "fpdfsdk/javascript/cjs_runtime.h" -JSConstSpec CJS_Color::ConstSpecs[] = {{0, JSConstSpec::Number, 0, 0}}; - JSPropertySpec CJS_Color::PropertySpecs[] = { {"black", get_black_static, set_black_static}, {"blue", get_blue_static, set_blue_static}, @@ -39,16 +37,6 @@ JSMethodSpec CJS_Color::MethodSpecs[] = {{"convert", convert_static}, const char* CJS_Color::g_pClassName = "color"; int CJS_Color::g_nObjDefnID = -1; -void CJS_Color::DefineConsts(CFXJS_Engine* pEngine) { - for (size_t i = 0; i < FX_ArraySize(ConstSpecs) - 1; ++i) { - pEngine->DefineObjConst( - g_nObjDefnID, ConstSpecs[i].pName, - ConstSpecs[i].eType == JSConstSpec::Number - ? pEngine->NewNumber(ConstSpecs[i].number).As<v8::Value>() - : pEngine->NewString(ConstSpecs[i].pStr).As<v8::Value>()); - } -} - void CJS_Color::JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj) { CJS_Object* pObj = new CJS_Color(obj); @@ -79,7 +67,6 @@ void CJS_Color::DefineMethods(CFXJS_Engine* pEngine) { void CJS_Color::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) { g_nObjDefnID = pEngine->DefineObj(CJS_Color::g_pClassName, eObjType, JSConstructor, JSDestructor); - DefineConsts(pEngine); DefineProps(pEngine); DefineMethods(pEngine); } diff --git a/fpdfsdk/javascript/color.h b/fpdfsdk/javascript/color.h index 17a00eb16f..dd5ca412c0 100644 --- a/fpdfsdk/javascript/color.h +++ b/fpdfsdk/javascript/color.h @@ -90,15 +90,15 @@ class CJS_Color : public CJS_Object { static const char* g_pClassName; static int g_nObjDefnID; - static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType); - static JSConstSpec ConstSpecs[]; - static void DefineConsts(CFXJS_Engine* pEngine); + static JSPropertySpec PropertySpecs[]; + static JSMethodSpec MethodSpecs[]; + static void JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); static void JSDestructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); + + static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType); static void DefineProps(CFXJS_Engine* pEngine); static void DefineMethods(CFXJS_Engine* pEngine); - static JSPropertySpec PropertySpecs[]; - static JSMethodSpec MethodSpecs[]; JS_STATIC_PROP(black, black, color); JS_STATIC_PROP(blue, blue, color); diff --git a/fpdfsdk/javascript/console.cpp b/fpdfsdk/javascript/console.cpp index d3528ee7b2..eb566b0756 100644 --- a/fpdfsdk/javascript/console.cpp +++ b/fpdfsdk/javascript/console.cpp @@ -14,10 +14,6 @@ #include "fpdfsdk/javascript/cjs_event_context.h" #include "fpdfsdk/javascript/cjs_eventhandler.h" -JSConstSpec CJS_Console::ConstSpecs[] = {{0, JSConstSpec::Number, 0, 0}}; - -JSPropertySpec CJS_Console::PropertySpecs[] = {{0, 0, 0}}; - JSMethodSpec CJS_Console::MethodSpecs[] = {{"clear", clear_static}, {"hide", hide_static}, {"println", println_static}, @@ -27,16 +23,6 @@ JSMethodSpec CJS_Console::MethodSpecs[] = {{"clear", clear_static}, const char* CJS_Console::g_pClassName = "console"; int CJS_Console::g_nObjDefnID = -1; -void CJS_Console::DefineConsts(CFXJS_Engine* pEngine) { - for (size_t i = 0; i < FX_ArraySize(ConstSpecs) - 1; ++i) { - pEngine->DefineObjConst( - g_nObjDefnID, ConstSpecs[i].pName, - ConstSpecs[i].eType == JSConstSpec::Number - ? pEngine->NewNumber(ConstSpecs[i].number).As<v8::Value>() - : pEngine->NewString(ConstSpecs[i].pStr).As<v8::Value>()); - } -} - void CJS_Console::JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj) { CJS_Object* pObj = new CJS_Console(obj); @@ -50,14 +36,6 @@ void CJS_Console::JSDestructor(CFXJS_Engine* pEngine, delete static_cast<CJS_Console*>(pEngine->GetObjectPrivate(obj)); } -void CJS_Console::DefineProps(CFXJS_Engine* pEngine) { - for (size_t i = 0; i < FX_ArraySize(PropertySpecs) - 1; ++i) { - pEngine->DefineObjProperty(g_nObjDefnID, PropertySpecs[i].pName, - PropertySpecs[i].pPropGet, - PropertySpecs[i].pPropPut); - } -} - void CJS_Console::DefineMethods(CFXJS_Engine* pEngine) { for (size_t i = 0; i < FX_ArraySize(MethodSpecs) - 1; ++i) { pEngine->DefineObjMethod(g_nObjDefnID, MethodSpecs[i].pName, @@ -68,8 +46,6 @@ void CJS_Console::DefineMethods(CFXJS_Engine* pEngine) { void CJS_Console::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) { g_nObjDefnID = pEngine->DefineObj(CJS_Console::g_pClassName, eObjType, JSConstructor, JSDestructor); - DefineConsts(pEngine); - DefineProps(pEngine); DefineMethods(pEngine); } diff --git a/fpdfsdk/javascript/console.h b/fpdfsdk/javascript/console.h index 07ee292cd4..1d85765648 100644 --- a/fpdfsdk/javascript/console.h +++ b/fpdfsdk/javascript/console.h @@ -34,15 +34,13 @@ class CJS_Console : public CJS_Object { static const char* g_pClassName; static int g_nObjDefnID; - static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType); - static JSConstSpec ConstSpecs[]; - static void DefineConsts(CFXJS_Engine* pEngine); + static JSMethodSpec MethodSpecs[]; + static void JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); static void JSDestructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); - static void DefineProps(CFXJS_Engine* pEngine); + + static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType); static void DefineMethods(CFXJS_Engine* pEngine); - static JSPropertySpec PropertySpecs[]; - static JSMethodSpec MethodSpecs[]; JS_STATIC_METHOD(clear, console); JS_STATIC_METHOD(hide, console); diff --git a/fpdfsdk/javascript/event.cpp b/fpdfsdk/javascript/event.cpp index 4744f37090..f20ac40374 100644 --- a/fpdfsdk/javascript/event.cpp +++ b/fpdfsdk/javascript/event.cpp @@ -13,8 +13,6 @@ #include "fpdfsdk/javascript/cjs_event_context.h" #include "fpdfsdk/javascript/cjs_eventhandler.h" -JSConstSpec CJS_Event::ConstSpecs[] = {{0, JSConstSpec::Number, 0, 0}}; - JSPropertySpec CJS_Event::PropertySpecs[] = { {"change", get_change_static, set_change_static}, {"changeEx", get_change_ex_static, set_change_ex_static}, @@ -38,21 +36,9 @@ JSPropertySpec CJS_Event::PropertySpecs[] = { {"willCommit", get_will_commit_static, set_will_commit_static}, {0, 0, 0}}; -JSMethodSpec CJS_Event::MethodSpecs[] = {{0, 0}}; - const char* CJS_Event::g_pClassName = "event"; int CJS_Event::g_nObjDefnID = -1; -void CJS_Event::DefineConsts(CFXJS_Engine* pEngine) { - for (size_t i = 0; i < FX_ArraySize(ConstSpecs) - 1; ++i) { - pEngine->DefineObjConst( - g_nObjDefnID, ConstSpecs[i].pName, - ConstSpecs[i].eType == JSConstSpec::Number - ? pEngine->NewNumber(ConstSpecs[i].number).As<v8::Value>() - : pEngine->NewString(ConstSpecs[i].pStr).As<v8::Value>()); - } -} - void CJS_Event::JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj) { CJS_Object* pObj = new CJS_Event(obj); @@ -73,19 +59,10 @@ void CJS_Event::DefineProps(CFXJS_Engine* pEngine) { } } -void CJS_Event::DefineMethods(CFXJS_Engine* pEngine) { - for (size_t i = 0; i < FX_ArraySize(MethodSpecs) - 1; ++i) { - pEngine->DefineObjMethod(g_nObjDefnID, MethodSpecs[i].pName, - MethodSpecs[i].pMethodCall); - } -} - void CJS_Event::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) { g_nObjDefnID = pEngine->DefineObj(CJS_Event::g_pClassName, eObjType, JSConstructor, JSDestructor); - DefineConsts(pEngine); DefineProps(pEngine); - DefineMethods(pEngine); } event::event(CJS_Object* pJsObject) : CJS_EmbedObj(pJsObject) {} diff --git a/fpdfsdk/javascript/event.h b/fpdfsdk/javascript/event.h index 1d5c262bbb..4d03f45edd 100644 --- a/fpdfsdk/javascript/event.h +++ b/fpdfsdk/javascript/event.h @@ -82,15 +82,13 @@ class CJS_Event : public CJS_Object { static const char* g_pClassName; static int g_nObjDefnID; - static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType); - static JSConstSpec ConstSpecs[]; - static void DefineConsts(CFXJS_Engine* pEngine); + static JSPropertySpec PropertySpecs[]; + static void JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); static void JSDestructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); + + static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType); static void DefineProps(CFXJS_Engine* pEngine); - static void DefineMethods(CFXJS_Engine* pEngine); - static JSPropertySpec PropertySpecs[]; - static JSMethodSpec MethodSpecs[]; JS_STATIC_PROP(change, change, event); JS_STATIC_PROP(changeEx, change_ex, event); diff --git a/fpdfsdk/javascript/report.cpp b/fpdfsdk/javascript/report.cpp index 0c96139fc6..7652ce4fb2 100644 --- a/fpdfsdk/javascript/report.cpp +++ b/fpdfsdk/javascript/report.cpp @@ -12,10 +12,6 @@ #include "fpdfsdk/javascript/JS_Object.h" #include "fpdfsdk/javascript/JS_Value.h" -JSConstSpec CJS_Report::ConstSpecs[] = {{0, JSConstSpec::Number, 0, 0}}; - -JSPropertySpec CJS_Report::PropertySpecs[] = {{0, 0, 0}}; - JSMethodSpec CJS_Report::MethodSpecs[] = {{"save", save_static}, {"writeText", writeText_static}, {0, 0}}; @@ -23,16 +19,6 @@ JSMethodSpec CJS_Report::MethodSpecs[] = {{"save", save_static}, const char* CJS_Report::g_pClassName = "Report"; int CJS_Report::g_nObjDefnID = -1; -void CJS_Report::DefineConsts(CFXJS_Engine* pEngine) { - for (size_t i = 0; i < FX_ArraySize(ConstSpecs) - 1; ++i) { - pEngine->DefineObjConst( - g_nObjDefnID, ConstSpecs[i].pName, - ConstSpecs[i].eType == JSConstSpec::Number - ? pEngine->NewNumber(ConstSpecs[i].number).As<v8::Value>() - : pEngine->NewString(ConstSpecs[i].pStr).As<v8::Value>()); - } -} - void CJS_Report::JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj) { CJS_Object* pObj = new CJS_Report(obj); @@ -46,14 +32,6 @@ void CJS_Report::JSDestructor(CFXJS_Engine* pEngine, delete static_cast<CJS_Report*>(pEngine->GetObjectPrivate(obj)); } -void CJS_Report::DefineProps(CFXJS_Engine* pEngine) { - for (size_t i = 0; i < FX_ArraySize(PropertySpecs) - 1; ++i) { - pEngine->DefineObjProperty(g_nObjDefnID, PropertySpecs[i].pName, - PropertySpecs[i].pPropGet, - PropertySpecs[i].pPropPut); - } -} - void CJS_Report::DefineMethods(CFXJS_Engine* pEngine) { for (size_t i = 0; i < FX_ArraySize(MethodSpecs) - 1; ++i) { pEngine->DefineObjMethod(g_nObjDefnID, MethodSpecs[i].pName, @@ -64,8 +42,6 @@ void CJS_Report::DefineMethods(CFXJS_Engine* pEngine) { void CJS_Report::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) { g_nObjDefnID = pEngine->DefineObj(CJS_Report::g_pClassName, eObjType, JSConstructor, JSDestructor); - DefineConsts(pEngine); - DefineProps(pEngine); DefineMethods(pEngine); } diff --git a/fpdfsdk/javascript/report.h b/fpdfsdk/javascript/report.h index a733f14f36..d6fe4e7f61 100644 --- a/fpdfsdk/javascript/report.h +++ b/fpdfsdk/javascript/report.h @@ -30,15 +30,13 @@ class CJS_Report : public CJS_Object { static const char* g_pClassName; static int g_nObjDefnID; - static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType); - static JSConstSpec ConstSpecs[]; - static void DefineConsts(CFXJS_Engine* pEngine); + static JSMethodSpec MethodSpecs[]; + static void JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); static void JSDestructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); - static void DefineProps(CFXJS_Engine* pEngine); + + static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType); static void DefineMethods(CFXJS_Engine* pEngine); - static JSPropertySpec PropertySpecs[]; - static JSMethodSpec MethodSpecs[]; JS_STATIC_METHOD(save, Report) JS_STATIC_METHOD(writeText, Report); diff --git a/fpdfsdk/javascript/util.cpp b/fpdfsdk/javascript/util.cpp index a0d0a57542..08846c18b1 100644 --- a/fpdfsdk/javascript/util.cpp +++ b/fpdfsdk/javascript/util.cpp @@ -28,10 +28,6 @@ #include <ctype.h> #endif -JSConstSpec CJS_Util::ConstSpecs[] = {{0, JSConstSpec::Number, 0, 0}}; - -JSPropertySpec CJS_Util::PropertySpecs[] = {{0, 0, 0}}; - JSMethodSpec CJS_Util::MethodSpecs[] = { {"printd", printd_static}, {"printf", printf_static}, {"printx", printx_static}, {"scand", scand_static}, @@ -40,16 +36,6 @@ JSMethodSpec CJS_Util::MethodSpecs[] = { const char* CJS_Util::g_pClassName = "util"; int CJS_Util::g_nObjDefnID = -1; -void CJS_Util::DefineConsts(CFXJS_Engine* pEngine) { - for (size_t i = 0; i < FX_ArraySize(ConstSpecs) - 1; ++i) { - pEngine->DefineObjConst( - g_nObjDefnID, ConstSpecs[i].pName, - ConstSpecs[i].eType == JSConstSpec::Number - ? pEngine->NewNumber(ConstSpecs[i].number).As<v8::Value>() - : pEngine->NewString(ConstSpecs[i].pStr).As<v8::Value>()); - } -} - void CJS_Util::JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj) { CJS_Object* pObj = new CJS_Util(obj); pObj->SetEmbedObject(new util(pObj)); @@ -61,14 +47,6 @@ void CJS_Util::JSDestructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj) { delete static_cast<CJS_Util*>(pEngine->GetObjectPrivate(obj)); } -void CJS_Util::DefineProps(CFXJS_Engine* pEngine) { - for (size_t i = 0; i < FX_ArraySize(PropertySpecs) - 1; ++i) { - pEngine->DefineObjProperty(g_nObjDefnID, PropertySpecs[i].pName, - PropertySpecs[i].pPropGet, - PropertySpecs[i].pPropPut); - } -} - void CJS_Util::DefineMethods(CFXJS_Engine* pEngine) { for (size_t i = 0; i < FX_ArraySize(MethodSpecs) - 1; ++i) { pEngine->DefineObjMethod(g_nObjDefnID, MethodSpecs[i].pName, @@ -79,8 +57,6 @@ void CJS_Util::DefineMethods(CFXJS_Engine* pEngine) { void CJS_Util::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) { g_nObjDefnID = pEngine->DefineObj(CJS_Util::g_pClassName, eObjType, JSConstructor, JSDestructor); - DefineConsts(pEngine); - DefineProps(pEngine); DefineMethods(pEngine); } diff --git a/fpdfsdk/javascript/util.h b/fpdfsdk/javascript/util.h index 05492f33ae..8903eb9c95 100644 --- a/fpdfsdk/javascript/util.h +++ b/fpdfsdk/javascript/util.h @@ -49,15 +49,13 @@ class CJS_Util : public CJS_Object { static const char* g_pClassName; static int g_nObjDefnID; - static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType); - static JSConstSpec ConstSpecs[]; - static void DefineConsts(CFXJS_Engine* pEngine); + static JSMethodSpec MethodSpecs[]; + static void JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); static void JSDestructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); - static void DefineProps(CFXJS_Engine* pEngine); + + static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType); static void DefineMethods(CFXJS_Engine* pEngine); - static JSPropertySpec PropertySpecs[]; - static JSMethodSpec MethodSpecs[]; JS_STATIC_METHOD(printd, util); JS_STATIC_METHOD(printf, util); |