summaryrefslogtreecommitdiff
path: root/fpdfsdk/include
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-04-23 17:50:57 -0700
committerTom Sepez <tsepez@chromium.org>2015-04-23 17:50:57 -0700
commitef25d9995e494bd596ffea8fb8c09c2e48daa9a0 (patch)
tree53e22c58375eb36abe97f5b8f2631b4eba111fbc /fpdfsdk/include
parente4fde52cc2c827e637c96e8e1f76ba4644cf718a (diff)
downloadpdfium-ef25d9995e494bd596ffea8fb8c09c2e48daa9a0.tar.xz
Remove unused nParamNum values from JS method tables.
The code to validate the number of parameters happens inside each particular method, rather than prior to method dispatch. As such, there's no point in having this number take up space in the table. Add some test to cover at least some of the per-method validations, and update error messages to be more useful. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1084183008
Diffstat (limited to 'fpdfsdk/include')
-rw-r--r--fpdfsdk/include/javascript/JS_Define.h14
-rw-r--r--fpdfsdk/include/javascript/resource.h2
-rw-r--r--fpdfsdk/include/jsapi/fxjs_v8.h4
3 files changed, 10 insertions, 10 deletions
diff --git a/fpdfsdk/include/javascript/JS_Define.h b/fpdfsdk/include/javascript/JS_Define.h
index 2a033d15c5..1c3c64e4dd 100644
--- a/fpdfsdk/include/javascript/JS_Define.h
+++ b/fpdfsdk/include/javascript/JS_Define.h
@@ -32,7 +32,6 @@ struct JSMethodSpec
{
const wchar_t* pName;
v8::FunctionCallback pMethodCall;
- unsigned nParamNum;
};
/* ====================================== PUBLIC DEFINE SPEC ============================================== */
@@ -48,8 +47,8 @@ struct JSMethodSpec
#define END_JS_STATIC_PROP() {0, 0, 0}};
#define BEGIN_JS_STATIC_METHOD(js_class_name) JSMethodSpec js_class_name::JS_Class_Methods[] = {
-#define JS_STATIC_METHOD_ENTRY(method_name, nargs) {JS_WIDESTRING(method_name), method_name##_static, nargs},
-#define END_JS_STATIC_METHOD() {0, 0, 0}};
+#define JS_STATIC_METHOD_ENTRY(method_name) {JS_WIDESTRING(method_name), method_name##_static},
+#define END_JS_STATIC_METHOD() {0, 0}};
/* ======================================== PROP CALLBACK ============================================ */
@@ -194,7 +193,7 @@ int js_class_name::Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType)\
}\
for (int k=0, szk=sizeof(JS_Class_Methods)/sizeof(JSMethodSpec)-1; k<szk; k++)\
{\
- if (JS_DefineObjMethod(pRuntime, nObjDefnID,JS_Class_Methods[k].pName, JS_Class_Methods[k].pMethodCall, JS_Class_Methods[k].nParamNum) < 0) return -1;\
+ if (JS_DefineObjMethod(pRuntime, nObjDefnID,JS_Class_Methods[k].pName, JS_Class_Methods[k].pMethodCall) < 0) return -1;\
}\
return nObjDefnID;\
}\
@@ -372,7 +371,7 @@ int js_class_name::Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType)\
\
for (int k=0, szk=sizeof(JS_Class_Methods)/sizeof(JSMethodSpec)-1; k<szk; k++)\
{\
- if (JS_DefineObjMethod(pRuntime, nObjDefnID,JS_Class_Methods[k].pName,JS_Class_Methods[k].pMethodCall,JS_Class_Methods[k].nParamNum)<0)return -1;\
+ if (JS_DefineObjMethod(pRuntime, nObjDefnID,JS_Class_Methods[k].pName,JS_Class_Methods[k].pMethodCall)<0)return -1;\
}\
if (JS_DefineObjAllProperties(pRuntime, 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;\
\
@@ -419,7 +418,7 @@ static int Init(IJS_Runtime* pRuntime)
#define BEGIN_JS_STATIC_GLOBAL_FUN(js_class_name) \
JSMethodSpec js_class_name::global_methods[] = {
-#define JS_STATIC_GLOBAL_FUN_ENTRY(method_name,nargs) JS_STATIC_METHOD_ENTRY(method_name,nargs)
+#define JS_STATIC_GLOBAL_FUN_ENTRY(method_name) JS_STATIC_METHOD_ENTRY(method_name)
#define END_JS_STATIC_GLOBAL_FUN() END_JS_STATIC_METHOD()
@@ -430,8 +429,7 @@ int js_class_name::Init(IJS_Runtime* pRuntime)\
{\
if (JS_DefineGlobalMethod(pRuntime,\
js_class_name::global_methods[i].pName,\
- js_class_name::global_methods[i].pMethodCall,\
- js_class_name::global_methods[i].nParamNum\
+ js_class_name::global_methods[i].pMethodCall\
) < 0\
)return -1;\
}\
diff --git a/fpdfsdk/include/javascript/resource.h b/fpdfsdk/include/javascript/resource.h
index 8f0a25061e..88011f2bb0 100644
--- a/fpdfsdk/include/javascript/resource.h
+++ b/fpdfsdk/include/javascript/resource.h
@@ -28,6 +28,8 @@ class CJS_Context;
#define IDS_STRING_JSPRINT2 25633
#define IDS_STRING_JSNOGLOBAL 25635
#define IDS_STRING_JSREADONLY 25636
+#define IDS_STRING_JSTYPEERROR 25637
+#define IDS_STRING_JSVALUEERROR 25638
CFX_WideString JSGetStringFromID(CJS_Context* pContext, FX_UINT id);
CFX_WideString JSFormatErrorString(const char* class_name,
diff --git a/fpdfsdk/include/jsapi/fxjs_v8.h b/fpdfsdk/include/jsapi/fxjs_v8.h
index 739fd2d4c0..a32ace674b 100644
--- a/fpdfsdk/include/jsapi/fxjs_v8.h
+++ b/fpdfsdk/include/jsapi/fxjs_v8.h
@@ -54,11 +54,11 @@ typedef void (*LP_DESTRUCTOR)(v8::Handle<v8::Object> obj);
int JS_DefineObj(IJS_Runtime* pJSRuntime, const wchar_t* sObjName, FXJSOBJTYPE eObjType, LP_CONSTRUCTOR pConstructor, LP_DESTRUCTOR pDestructor, unsigned bApplyNew);
-int JS_DefineObjMethod(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sMethodName, v8::FunctionCallback pMethodCall, unsigned nParamNum);
+int JS_DefineObjMethod(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sMethodName, v8::FunctionCallback pMethodCall);
int JS_DefineObjProperty(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sPropName, v8::AccessorGetterCallback pPropGet, v8::AccessorSetterCallback pPropPut);
int JS_DefineObjAllProperties(IJS_Runtime* pJSRuntime, int nObjDefnID, v8::NamedPropertyQueryCallback pPropQurey, v8::NamedPropertyGetterCallback pPropGet, v8::NamedPropertySetterCallback pPropPut, v8::NamedPropertyDeleterCallback pPropDel);
int JS_DefineObjConst(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sConstName, v8::Handle<v8::Value> pDefault);
-int JS_DefineGlobalMethod(IJS_Runtime* pJSRuntime, const wchar_t* sMethodName, v8::FunctionCallback pMethodCall, unsigned nParamNum);
+int JS_DefineGlobalMethod(IJS_Runtime* pJSRuntime, const wchar_t* sMethodName, v8::FunctionCallback pMethodCall);
int JS_DefineGlobalConst(IJS_Runtime* pJSRuntime, const wchar_t* sConstName, v8::Handle<v8::Value> pDefault);
void JS_InitialRuntime(IJS_Runtime* pJSRuntime,IFXJS_Runtime* pFXRuntime, IFXJS_Context* context, v8::Persistent<v8::Context>& v8PersistentContext);