Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: fpdfsdk/include/javascript/JS_Define.h

Issue 1105813002: Merge to XFA: Remove unused nParamNum values from JS method tables. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | fpdfsdk/include/javascript/resource.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #ifndef _JS_DEFINE_H_ 7 #ifndef _JS_DEFINE_H_
8 #define _JS_DEFINE_H_ 8 #define _JS_DEFINE_H_
9 9
10 #include "../jsapi/fxjs_v8.h" 10 #include "../jsapi/fxjs_v8.h"
(...skipping 14 matching lines...) Expand all
25 { 25 {
26 const wchar_t* pName; 26 const wchar_t* pName;
27 v8::AccessorGetterCallback pPropGet; 27 v8::AccessorGetterCallback pPropGet;
28 v8::AccessorSetterCallback pPropPut; 28 v8::AccessorSetterCallback pPropPut;
29 }; 29 };
30 30
31 struct JSMethodSpec 31 struct JSMethodSpec
32 { 32 {
33 const wchar_t* pName; 33 const wchar_t* pName;
34 v8::FunctionCallback pMethodCall; 34 v8::FunctionCallback pMethodCall;
35 unsigned nParamNum;
36 }; 35 };
37 36
38 /* ====================================== PUBLIC DEFINE SPEC =================== =========================== */ 37 /* ====================================== PUBLIC DEFINE SPEC =================== =========================== */
39 #define JS_WIDESTRING(widestring) L###widestring 38 #define JS_WIDESTRING(widestring) L###widestring
40 39
41 #define BEGIN_JS_STATIC_CONST(js_class_name) JSConstSpec js_class_name::JS_Class _Consts[] = { 40 #define BEGIN_JS_STATIC_CONST(js_class_name) JSConstSpec js_class_name::JS_Class _Consts[] = {
42 #define JS_STATIC_CONST_ENTRY_NUMBER(const_name, pValue) {JS_WIDESTRING(const_na me), pValue, L"", 0}, 41 #define JS_STATIC_CONST_ENTRY_NUMBER(const_name, pValue) {JS_WIDESTRING(const_na me), pValue, L"", 0},
43 #define JS_STATIC_CONST_ENTRY_STRING(const_name, pValue) {JS_WIDESTRING(const_na me), 0, JS_WIDESTRING(pValue), 1}, 42 #define JS_STATIC_CONST_ENTRY_STRING(const_name, pValue) {JS_WIDESTRING(const_na me), 0, JS_WIDESTRING(pValue), 1},
44 #define END_JS_STATIC_CONST() {0, 0, 0, 0}}; 43 #define END_JS_STATIC_CONST() {0, 0, 0, 0}};
45 44
46 #define BEGIN_JS_STATIC_PROP(js_class_name) JSPropertySpec js_class_name::JS_Cla ss_Properties[] = { 45 #define BEGIN_JS_STATIC_PROP(js_class_name) JSPropertySpec js_class_name::JS_Cla ss_Properties[] = {
47 #define JS_STATIC_PROP_ENTRY(prop_name) {JS_WIDESTRING(prop_name), get_##prop_na me##_static, set_##prop_name##_static}, 46 #define JS_STATIC_PROP_ENTRY(prop_name) {JS_WIDESTRING(prop_name), get_##prop_na me##_static, set_##prop_name##_static},
48 #define END_JS_STATIC_PROP() {0, 0, 0}}; 47 #define END_JS_STATIC_PROP() {0, 0, 0}};
49 48
50 #define BEGIN_JS_STATIC_METHOD(js_class_name) JSMethodSpec js_class_name::JS_Cla ss_Methods[] = { 49 #define BEGIN_JS_STATIC_METHOD(js_class_name) JSMethodSpec js_class_name::JS_Cla ss_Methods[] = {
51 #define JS_STATIC_METHOD_ENTRY(method_name, nargs) {JS_WIDESTRING(method_name), method_name##_static, nargs}, 50 #define JS_STATIC_METHOD_ENTRY(method_name) {JS_WIDESTRING(method_name), method_ name##_static},
52 #define END_JS_STATIC_METHOD() {0, 0, 0}}; 51 #define END_JS_STATIC_METHOD() {0, 0}};
53 52
54 /* ======================================== PROP CALLBACK ====================== ====================== */ 53 /* ======================================== PROP CALLBACK ====================== ====================== */
55 54
56 template <class C, FX_BOOL (C::*M)(IFXJS_Context*, CJS_PropValue&, CFX_WideStrin g&)> 55 template <class C, FX_BOOL (C::*M)(IFXJS_Context*, CJS_PropValue&, CFX_WideStrin g&)>
57 void JSPropGetter(const char* prop_name_string, 56 void JSPropGetter(const char* prop_name_string,
58 const char* class_name_string, 57 const char* class_name_string,
59 v8::Local<v8::String> property, 58 v8::Local<v8::String> property,
60 const v8::PropertyCallbackInfo<v8::Value>& info) { 59 const v8::PropertyCallbackInfo<v8::Value>& info) {
61 v8::Isolate* isolate = info.GetIsolate(); 60 v8::Isolate* isolate = info.GetIsolate();
62 IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2); 61 IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 {\ 177 {\
179 int nObjDefnID = JS_DefineObj(pRuntime, js_class_name::m_pClassName, eOb jType, JSConstructor, JSDestructor, 0);\ 178 int nObjDefnID = JS_DefineObj(pRuntime, js_class_name::m_pClassName, eOb jType, JSConstructor, JSDestructor, 0);\
180 if (nObjDefnID >= 0)\ 179 if (nObjDefnID >= 0)\
181 {\ 180 {\
182 for (int j=0, szj=sizeof(JS_Class_Properties)/sizeof(JSPropertyS pec)-1; j<szj; j++)\ 181 for (int j=0, szj=sizeof(JS_Class_Properties)/sizeof(JSPropertyS pec)-1; j<szj; j++)\
183 {\ 182 {\
184 if (JS_DefineObjProperty(pRuntime, nObjDefnID, JS_Class_ Properties[j].pName, JS_Class_Properties[j].pPropGet, JS_Class_Properties[j].pPr opPut) < 0) return -1;\ 183 if (JS_DefineObjProperty(pRuntime, nObjDefnID, JS_Class_ Properties[j].pName, JS_Class_Properties[j].pPropGet, JS_Class_Properties[j].pPr opPut) < 0) return -1;\
185 }\ 184 }\
186 for (int k=0, szk=sizeof(JS_Class_Methods)/sizeof(JSMethodSpec)- 1; k<szk; k++)\ 185 for (int k=0, szk=sizeof(JS_Class_Methods)/sizeof(JSMethodSpec)- 1; k<szk; k++)\
187 {\ 186 {\
188 » » » if (JS_DefineObjMethod(pRuntime, nObjDefnID,JS_Class_Met hods[k].pName, JS_Class_Methods[k].pMethodCall, JS_Class_Methods[k].nParamNum) < 0) return -1;\ 187 » » » if (JS_DefineObjMethod(pRuntime, nObjDefnID,JS_Class_Met hods[k].pName, JS_Class_Methods[k].pMethodCall) < 0) return -1;\
189 }\ 188 }\
190 return nObjDefnID;\ 189 return nObjDefnID;\
191 }\ 190 }\
192 return -1;\ 191 return -1;\
193 } 192 }
194 193
195 #define IMPLEMENT_JS_CLASS(js_class_name, class_name) IMPLEMENT_JS_CLASS_RICH(js _class_name, class_name, class_name) 194 #define IMPLEMENT_JS_CLASS(js_class_name, class_name) IMPLEMENT_JS_CLASS_RICH(js _class_name, class_name, class_name)
196 195
197 /* ======================================== CONST CLASS ======================== ==================== */ 196 /* ======================================== CONST CLASS ======================== ==================== */
198 197
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 \ 349 \
351 if (nObjDefnID >= 0)\ 350 if (nObjDefnID >= 0)\
352 {\ 351 {\
353 for (int j=0, szj=sizeof(JS_Class_Properties)/sizeof(JSPropertyS pec)-1; j<szj; j++)\ 352 for (int j=0, szj=sizeof(JS_Class_Properties)/sizeof(JSPropertyS pec)-1; j<szj; j++)\
354 {\ 353 {\
355 if (JS_DefineObjProperty(pRuntime, nObjDefnID, JS_Class_ Properties[j].pName, JS_Class_Properties[j].pPropGet,JS_Class_Properties[j].pPro pPut)<0)return -1;\ 354 if (JS_DefineObjProperty(pRuntime, nObjDefnID, JS_Class_ Properties[j].pName, JS_Class_Properties[j].pPropGet,JS_Class_Properties[j].pPro pPut)<0)return -1;\
356 }\ 355 }\
357 \ 356 \
358 for (int k=0, szk=sizeof(JS_Class_Methods)/sizeof(JSMethodSpec)- 1; k<szk; k++)\ 357 for (int k=0, szk=sizeof(JS_Class_Methods)/sizeof(JSMethodSpec)- 1; k<szk; k++)\
359 {\ 358 {\
360 » » » if (JS_DefineObjMethod(pRuntime, nObjDefnID,JS_Class_Met hods[k].pName,JS_Class_Methods[k].pMethodCall,JS_Class_Methods[k].nParamNum)<0)r eturn -1;\ 359 » » » if (JS_DefineObjMethod(pRuntime, nObjDefnID,JS_Class_Met hods[k].pName,JS_Class_Methods[k].pMethodCall)<0)return -1;\
361 }\ 360 }\
362 if (JS_DefineObjAllProperties(pRuntime, nObjDefnID, js_class_nam e::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;\ 361 if (JS_DefineObjAllProperties(pRuntime, nObjDefnID, js_class_nam e::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;\
363 \ 362 \
364 return nObjDefnID;\ 363 return nObjDefnID;\
365 }\ 364 }\
366 \ 365 \
367 return -1;\ 366 return -1;\
368 } 367 }
369 368
370 /* ======================================== GLOBAL METHODS ===================== ======================= */ 369 /* ======================================== GLOBAL METHODS ===================== ======================= */
(...skipping 22 matching lines...) Expand all
393 JSGlobalFunc<fun_name>(#fun_name, info); \ 392 JSGlobalFunc<fun_name>(#fun_name, info); \
394 } 393 }
395 394
396 #define JS_STATIC_DECLARE_GLOBAL_FUN() \ 395 #define JS_STATIC_DECLARE_GLOBAL_FUN() \
397 static JSMethodSpec global_methods[]; \ 396 static JSMethodSpec global_methods[]; \
398 static int Init(IJS_Runtime* pRuntime) 397 static int Init(IJS_Runtime* pRuntime)
399 398
400 #define BEGIN_JS_STATIC_GLOBAL_FUN(js_class_name) \ 399 #define BEGIN_JS_STATIC_GLOBAL_FUN(js_class_name) \
401 JSMethodSpec js_class_name::global_methods[] = { 400 JSMethodSpec js_class_name::global_methods[] = {
402 401
403 #define JS_STATIC_GLOBAL_FUN_ENTRY(method_name,nargs) JS_STATIC_METHOD_ENTRY(met hod_name,nargs) 402 #define JS_STATIC_GLOBAL_FUN_ENTRY(method_name) JS_STATIC_METHOD_ENTRY(method_na me)
404 403
405 #define END_JS_STATIC_GLOBAL_FUN() END_JS_STATIC_METHOD() 404 #define END_JS_STATIC_GLOBAL_FUN() END_JS_STATIC_METHOD()
406 405
407 #define IMPLEMENT_JS_STATIC_GLOBAL_FUN(js_class_name) \ 406 #define IMPLEMENT_JS_STATIC_GLOBAL_FUN(js_class_name) \
408 int js_class_name::Init(IJS_Runtime* pRuntime)\ 407 int js_class_name::Init(IJS_Runtime* pRuntime)\
409 {\ 408 {\
410 for (int i=0, sz=sizeof(js_class_name::global_methods)/sizeof(JSMethodSp ec)-1; i<sz; i++)\ 409 for (int i=0, sz=sizeof(js_class_name::global_methods)/sizeof(JSMethodSp ec)-1; i<sz; i++)\
411 {\ 410 {\
412 if (JS_DefineGlobalMethod(pRuntime,\ 411 if (JS_DefineGlobalMethod(pRuntime,\
413 js_class_name::global_methods[i].pName,\ 412 js_class_name::global_methods[i].pName,\
414 » » » » js_class_name::global_methods[i].pMethodCall,\ 413 » » » » js_class_name::global_methods[i].pMethodCall\
415 » » » » js_class_name::global_methods[i].nParamNum\
416 ) < 0\ 414 ) < 0\
417 )return -1;\ 415 )return -1;\
418 }\ 416 }\
419 return 0;\ 417 return 0;\
420 } 418 }
421 419
422 /* ======================================== GLOBAL CONSTS ====================== ====================== */ 420 /* ======================================== GLOBAL CONSTS ====================== ====================== */
423 #define DEFINE_GLOBAL_CONST(pRuntime, const_name , const_value)\ 421 #define DEFINE_GLOBAL_CONST(pRuntime, const_name , const_value)\
424 if (JS_DefineGlobalConst(pRuntime,JS_WIDESTRING(const_name),JS_NewString(pRuntim e,JS_WIDESTRING(const_value)))) return -1 422 if (JS_DefineGlobalConst(pRuntime,JS_WIDESTRING(const_name),JS_NewString(pRuntim e,JS_WIDESTRING(const_value)))) return -1
425 423
(...skipping 17 matching lines...) Expand all
443 #define VALUE_NAME_BOOLEAN L"boolean" 441 #define VALUE_NAME_BOOLEAN L"boolean"
444 #define VALUE_NAME_DATE L"date" 442 #define VALUE_NAME_DATE L"date"
445 #define VALUE_NAME_OBJECT L"object" 443 #define VALUE_NAME_OBJECT L"object"
446 #define VALUE_NAME_FXOBJ L"fxobj" 444 #define VALUE_NAME_FXOBJ L"fxobj"
447 #define VALUE_NAME_NULL L"null" 445 #define VALUE_NAME_NULL L"null"
448 #define VALUE_NAME_UNDEFINED L"undefined" 446 #define VALUE_NAME_UNDEFINED L"undefined"
449 447
450 FXJSVALUETYPE GET_VALUE_TYPE(v8::Handle<v8::Value> p); 448 FXJSVALUETYPE GET_VALUE_TYPE(v8::Handle<v8::Value> p);
451 449
452 #endif //_JS_DEFINE_H_ 450 #endif //_JS_DEFINE_H_
OLDNEW
« no previous file with comments | « no previous file | fpdfsdk/include/javascript/resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698