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

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

Issue 954923004: Kill off unused IFXJS interface methods. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 9 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 | « fpdfsdk/include/javascript/IJavaScript.h ('k') | fpdfsdk/include/javascript/JS_Runtime.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 typedef v8::Value JSValue; 10 typedef v8::Value JSValue;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 JSMethod<class_alternate, &class_alternate::method_name>( \ 169 JSMethod<class_alternate, &class_alternate::method_name>( \
170 #class_name, #method_name, info); \ 170 #class_name, #method_name, info); \
171 } 171 }
172 172
173 /* ===================================== JS CLASS ============================== ================= */ 173 /* ===================================== JS CLASS ============================== ================= */
174 174
175 #define DECLARE_JS_CLASS(js_class_name) \ 175 #define DECLARE_JS_CLASS(js_class_name) \
176 static JSBool JSConstructor(IFXJS_Context* cc, JSFXObject obj,JSFXObject global);\ 176 static JSBool JSConstructor(IFXJS_Context* cc, JSFXObject obj,JSFXObject global);\
177 static JSBool JSDestructor(JSFXObject obj);\ 177 static JSBool JSDestructor(JSFXObject obj);\
178 static int Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType);\ 178 static int Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType);\
179 static void GetConsts(JSConstSpec*& pConsts, int& nSize);\
180 static void GetProperties(JSPropertySpec*& pProperties, int& nSize);\
181 static void GetMethods(JSMethodSpec*& pMethods, int& nSize);\
182 static JSConstSpec JS_Class_Consts[];\ 179 static JSConstSpec JS_Class_Consts[];\
183 static JSPropertySpec JS_Class_Properties[];\ 180 static JSPropertySpec JS_Class_Properties[];\
184 static JSMethodSpec JS_Class_Methods[];\ 181 static JSMethodSpec JS_Class_Methods[];\
185 static const wchar_t* m_pClassName 182 static const wchar_t* m_pClassName
186 183
187 #define IMPLEMENT_JS_CLASS_RICH(js_class_name, class_alternate, class_name) \ 184 #define IMPLEMENT_JS_CLASS_RICH(js_class_name, class_alternate, class_name) \
188 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name);\ 185 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name);\
189 JSBool js_class_name::JSConstructor(IFXJS_Context* cc, JSFXObject obj, JSFXObjec t global)\ 186 JSBool js_class_name::JSConstructor(IFXJS_Context* cc, JSFXObject obj, JSFXObjec t global)\
190 {\ 187 {\
191 CJS_Object* pObj = FX_NEW js_class_name(obj);\ 188 CJS_Object* pObj = FX_NEW js_class_name(obj);\
(...skipping 21 matching lines...) Expand all
213 {\ 210 {\
214 if (JS_DefineObjProperty(pRuntime, nObjDefnID, JS_Class_ Properties[j].pName, JS_Class_Properties[j].pPropGet, JS_Class_Properties[j].pPr opPut) < 0) return -1;\ 211 if (JS_DefineObjProperty(pRuntime, nObjDefnID, JS_Class_ Properties[j].pName, JS_Class_Properties[j].pPropGet, JS_Class_Properties[j].pPr opPut) < 0) return -1;\
215 }\ 212 }\
216 for (int k=0, szk=sizeof(JS_Class_Methods)/sizeof(JSMethodSpec)- 1; k<szk; k++)\ 213 for (int k=0, szk=sizeof(JS_Class_Methods)/sizeof(JSMethodSpec)- 1; k<szk; k++)\
217 {\ 214 {\
218 if (JS_DefineObjMethod(pRuntime, nObjDefnID,JS_Class_Met hods[k].pName, JS_Class_Methods[k].pMethodCall, JS_Class_Methods[k].nParamNum) < 0) return -1;\ 215 if (JS_DefineObjMethod(pRuntime, nObjDefnID,JS_Class_Met hods[k].pName, JS_Class_Methods[k].pMethodCall, JS_Class_Methods[k].nParamNum) < 0) return -1;\
219 }\ 216 }\
220 return nObjDefnID;\ 217 return nObjDefnID;\
221 }\ 218 }\
222 return -1;\ 219 return -1;\
223 }\
224 void js_class_name::GetConsts(JSConstSpec*& pConsts, int& nSize)\
225 {\
226 pConsts = JS_Class_Consts;\
227 nSize = sizeof(JS_Class_Consts) / sizeof(JSConstSpec) - 1;\
228 }\
229 void js_class_name::GetProperties(JSPropertySpec*& pProperties, int& nSize)\
230 {\
231 pProperties = JS_Class_Properties;\
232 nSize = sizeof(JS_Class_Properties) / sizeof(JSPropertySpec) - 1;\
233 }\
234 void js_class_name::GetMethods(JSMethodSpec*& pMethods, int& nSize)\
235 {\
236 pMethods = JS_Class_Methods;\
237 nSize = sizeof(JS_Class_Methods) / sizeof(JSMethodSpec) - 1;\
238 } 220 }
239 221
240 #define IMPLEMENT_JS_CLASS(js_class_name, class_name) IMPLEMENT_JS_CLASS_RICH(js _class_name, class_name, class_name) 222 #define IMPLEMENT_JS_CLASS(js_class_name, class_name) IMPLEMENT_JS_CLASS_RICH(js _class_name, class_name, class_name)
241 223
242 /* ======================================== CONST CLASS ======================== ==================== */ 224 /* ======================================== CONST CLASS ======================== ==================== */
243 225
244 #define DECLARE_JS_CLASS_CONST() \ 226 #define DECLARE_JS_CLASS_CONST() \
245 static int Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType);\ 227 static int Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType);\
246 static void GetConsts(JSConstSpec*& pConsts, int& nSize);\
247 static JSConstSpec JS_Class_Consts[];\ 228 static JSConstSpec JS_Class_Consts[];\
248 static const wchar_t* m_pClassName 229 static const wchar_t* m_pClassName
249 230
250 #define IMPLEMENT_JS_CLASS_CONST(js_class_name, class_name) \ 231 #define IMPLEMENT_JS_CLASS_CONST(js_class_name, class_name) \
251 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name);\ 232 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name);\
252 int js_class_name::Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType)\ 233 int js_class_name::Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType)\
253 {\ 234 {\
254 int nObjDefnID = JS_DefineObj(pRuntime, js_class_name::m_pClassName, eOb jType, NULL, NULL, 0);\ 235 int nObjDefnID = JS_DefineObj(pRuntime, js_class_name::m_pClassName, eOb jType, NULL, NULL, 0);\
255 if (nObjDefnID >=0)\ 236 if (nObjDefnID >=0)\
256 {\ 237 {\
257 for (int i=0, sz=sizeof(JS_Class_Consts)/sizeof(JSConstSpec)-1; i<sz; i++)\ 238 for (int i=0, sz=sizeof(JS_Class_Consts)/sizeof(JSConstSpec)-1; i<sz; i++)\
258 {\ 239 {\
259 if (JS_Class_Consts[i].t == 0)\ 240 if (JS_Class_Consts[i].t == 0)\
260 {\ 241 {\
261 if (JS_DefineObjConst(pRuntime, nObjDefnID, JS_C lass_Consts[i].pName, JS_NewNumber(pRuntime,JS_Class_Consts[i].number)) < 0) ret urn -1;\ 242 if (JS_DefineObjConst(pRuntime, nObjDefnID, JS_C lass_Consts[i].pName, JS_NewNumber(pRuntime,JS_Class_Consts[i].number)) < 0) ret urn -1;\
262 }\ 243 }\
263 else\ 244 else\
264 {\ 245 {\
265 if (JS_DefineObjConst(pRuntime, nObjDefnID, JS_Class_Con sts[i].pName, JS_NewString(pRuntime,JS_Class_Consts[i].string)) < 0) return -1;\ 246 if (JS_DefineObjConst(pRuntime, nObjDefnID, JS_Class_Con sts[i].pName, JS_NewString(pRuntime,JS_Class_Consts[i].string)) < 0) return -1;\
266 }\ 247 }\
267 }\ 248 }\
268 return nObjDefnID;\ 249 return nObjDefnID;\
269 }\ 250 }\
270 return -1;\ 251 return -1;\
271 }\
272 void js_class_name::GetConsts(JSConstSpec*& pConsts, int& nSize)\
273 {\
274 pConsts = JS_Class_Consts;\
275 nSize = sizeof(JS_Class_Consts)/sizeof(JSConstSpec)-1;\
276 } 252 }
277 253
278 /* ===================================== SPECIAL JS CLASS ====================== ========================= */ 254 /* ===================================== SPECIAL JS CLASS ====================== ========================= */
279 255
280 template <class Alt> 256 template <class Alt>
281 void JSSpecialPropQuery(const char *, v8::Local<v8::String> property,const v8::P ropertyCallbackInfo<v8::Integer>& info) { 257 void JSSpecialPropQuery(const char *, v8::Local<v8::String> property,const v8::P ropertyCallbackInfo<v8::Integer>& info) {
282 v8::Isolate* isolate = info.GetIsolate(); 258 v8::Isolate* isolate = info.GetIsolate();
283 v8::String::Utf8Value utf8_value(property); 259 v8::String::Utf8Value utf8_value(property);
284 CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_value.len gth()); 260 CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_value.len gth());
285 CJS_Object* pJSObj = reinterpret_cast<CJS_Object*>(JS_GetPrivate(isolate, info .Holder())); 261 CJS_Object* pJSObj = reinterpret_cast<CJS_Object*>(JS_GetPrivate(isolate, info .Holder()));
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 if (!pObj->DelProperty(pRuntimeContext, propname.c_str(), sError)) { 333 if (!pObj->DelProperty(pRuntimeContext, propname.c_str(), sError)) {
358 CFX_ByteString cbName; 334 CFX_ByteString cbName;
359 cbName.Format("%s.%s", class_name, "DelProperty"); 335 cbName.Format("%s.%s", class_name, "DelProperty");
360 // Probably a missing call to JS_Error(). 336 // Probably a missing call to JS_Error().
361 } 337 }
362 } 338 }
363 339
364 #define DECLARE_SPECIAL_JS_CLASS(js_class_name) \ 340 #define DECLARE_SPECIAL_JS_CLASS(js_class_name) \
365 static JSBool JSConstructor(IFXJS_Context* cc, JSFXObject obj, JSFXObjec t global);\ 341 static JSBool JSConstructor(IFXJS_Context* cc, JSFXObject obj, JSFXObjec t global);\
366 static JSBool JSDestructor(JSFXObject obj);\ 342 static JSBool JSDestructor(JSFXObject obj);\
367 static void GetConsts(JSConstSpec*& pConsts, int& nSize);\
368 static void GetProperties(JSPropertySpec*& pProperties, int& nSize);\
369 static void GetMethods(JSMethodSpec*& pMethods, int& nSize);\
370 static JSConstSpec JS_Class_Consts[];\ 343 static JSConstSpec JS_Class_Consts[];\
371 static JSPropertySpec JS_Class_Properties[];\ 344 static JSPropertySpec JS_Class_Properties[];\
372 static JSMethodSpec JS_Class_Methods[];\ 345 static JSMethodSpec JS_Class_Methods[];\
373 static int Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType);\ 346 static int Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType);\
374 static const wchar_t* m_pClassName;\ 347 static const wchar_t* m_pClassName;\
375 static void queryprop_##js_class_name##_static(v8::Local<v8::String> pro perty,const v8::PropertyCallbackInfo<v8::Integer>& info);\ 348 static void queryprop_##js_class_name##_static(v8::Local<v8::String> pro perty,const v8::PropertyCallbackInfo<v8::Integer>& info);\
376 static void getprop_##js_class_name##_static(v8::Local<v8::String> prope rty, const v8::PropertyCallbackInfo<v8::Value>& info);\ 349 static void getprop_##js_class_name##_static(v8::Local<v8::String> prope rty, const v8::PropertyCallbackInfo<v8::Value>& info);\
377 static void putprop_##js_class_name##_static(v8::Local<v8::String> prope rty,v8::Local<v8::Value> value,const v8::PropertyCallbackInfo<v8::Value>& info); \ 350 static void putprop_##js_class_name##_static(v8::Local<v8::String> prope rty,v8::Local<v8::Value> value,const v8::PropertyCallbackInfo<v8::Value>& info); \
378 static void delprop_##js_class_name##_static(v8::Local<v8::String> prope rty,const v8::PropertyCallbackInfo<v8::Boolean>& info) 351 static void delprop_##js_class_name##_static(v8::Local<v8::String> prope rty,const v8::PropertyCallbackInfo<v8::Boolean>& info)
379 352
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 for (int k=0, szk=sizeof(JS_Class_Methods)/sizeof(JSMethodSpec)- 1; k<szk; k++)\ 397 for (int k=0, szk=sizeof(JS_Class_Methods)/sizeof(JSMethodSpec)- 1; k<szk; k++)\
425 {\ 398 {\
426 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;\ 399 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;\
427 }\ 400 }\
428 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;\ 401 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;\
429 \ 402 \
430 return nObjDefnID;\ 403 return nObjDefnID;\
431 }\ 404 }\
432 \ 405 \
433 return -1;\ 406 return -1;\
434 }\
435 void js_class_name::GetConsts(JSConstSpec*& pConsts, int& nSize)\
436 {\
437 pConsts = JS_Class_Consts;\
438 nSize = sizeof(JS_Class_Consts)/sizeof(JSConstSpec)-1;\
439 }\
440 void js_class_name::GetProperties(JSPropertySpec*& pProperties, int& nSize)\
441 {\
442 pProperties = JS_Class_Properties;\
443 nSize = sizeof(JS_Class_Properties)/sizeof(JSPropertySpec)-1;\
444 }\
445 void js_class_name::GetMethods(JSMethodSpec*& pMethods, int& nSize)\
446 {\
447 pMethods = JS_Class_Methods;\
448 nSize = sizeof(JS_Class_Methods)/sizeof(JSMethodSpec)-1;\
449 } 407 }
450 408
451 /* ======================================== GLOBAL METHODS ===================== ======================= */ 409 /* ======================================== GLOBAL METHODS ===================== ======================= */
452 410
453 template <FX_BOOL (*F)(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu e& vRet, JS_ErrorString& sError)> 411 template <FX_BOOL (*F)(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu e& vRet, JS_ErrorString& sError)>
454 void JSGlobalFunc(const char *func_name_string, 412 void JSGlobalFunc(const char *func_name_string,
455 const v8::FunctionCallbackInfo<v8::Value>& info) { 413 const v8::FunctionCallbackInfo<v8::Value>& info) {
456 v8::Isolate* isolate = info.GetIsolate(); 414 v8::Isolate* isolate = info.GetIsolate();
457 v8::Local<v8::Context> context = isolate->GetCurrentContext(); 415 v8::Local<v8::Context> context = isolate->GetCurrentContext();
458 v8::Local<v8::Value> v = context->GetEmbedderData(1); 416 v8::Local<v8::Value> v = context->GetEmbedderData(1);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 #define VALUE_NAME_BOOLEAN L"boolean" 486 #define VALUE_NAME_BOOLEAN L"boolean"
529 #define VALUE_NAME_DATE L"date" 487 #define VALUE_NAME_DATE L"date"
530 #define VALUE_NAME_OBJECT L"object" 488 #define VALUE_NAME_OBJECT L"object"
531 #define VALUE_NAME_FXOBJ L"fxobj" 489 #define VALUE_NAME_FXOBJ L"fxobj"
532 #define VALUE_NAME_NULL L"null" 490 #define VALUE_NAME_NULL L"null"
533 #define VALUE_NAME_UNDEFINED L"undefined" 491 #define VALUE_NAME_UNDEFINED L"undefined"
534 492
535 FXJSVALUETYPE GET_VALUE_TYPE(v8::Handle<v8::Value> p); 493 FXJSVALUETYPE GET_VALUE_TYPE(v8::Handle<v8::Value> p);
536 494
537 #endif //_JS_DEFINE_H_ 495 #endif //_JS_DEFINE_H_
OLDNEW
« no previous file with comments | « fpdfsdk/include/javascript/IJavaScript.h ('k') | fpdfsdk/include/javascript/JS_Runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698