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

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

Issue 1334833003: Merge to XFA: Remove some abstractions in fxjs_v8.h. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 3 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/Icon.h ('k') | fpdfsdk/include/javascript/JS_Object.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 FPDFSDK_INCLUDE_JAVASCRIPT_JS_DEFINE_H_ 7 #ifndef FPDFSDK_INCLUDE_JAVASCRIPT_JS_DEFINE_H_
8 #define FPDFSDK_INCLUDE_JAVASCRIPT_JS_DEFINE_H_ 8 #define FPDFSDK_INCLUDE_JAVASCRIPT_JS_DEFINE_H_
9 9
10 #include "../jsapi/fxjs_v8.h" 10 #include "../jsapi/fxjs_v8.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 #define JS_SPECIAL_STATIC_METHOD(method_name, class_alternate, class_name) \ 169 #define JS_SPECIAL_STATIC_METHOD(method_name, class_alternate, class_name) \
170 static void method_name##_static( \ 170 static void method_name##_static( \
171 const v8::FunctionCallbackInfo<v8::Value>& info) { \ 171 const v8::FunctionCallbackInfo<v8::Value>& info) { \
172 JSMethod<class_alternate, &class_alternate::method_name>( \ 172 JSMethod<class_alternate, &class_alternate::method_name>( \
173 #method_name, #class_name, info); \ 173 #method_name, #class_name, info); \
174 } 174 }
175 175
176 /* ===================================== JS CLASS 176 /* ===================================== JS CLASS
177 * =============================================== */ 177 * =============================================== */
178 178
179 #define DECLARE_JS_CLASS(js_class_name) \ 179 #define DECLARE_JS_CLASS(js_class_name) \
180 static void JSConstructor(IFXJS_Context* cc, JSFXObject obj, \ 180 static void JSConstructor(IFXJS_Context* cc, v8::Local<v8::Object> obj, \
181 JSFXObject global); \ 181 v8::Local<v8::Object> global); \
182 static void JSDestructor(JSFXObject obj); \ 182 static void JSDestructor(v8::Local<v8::Object> obj); \
183 static int Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType); \ 183 static int Init(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType); \
184 static JSConstSpec JS_Class_Consts[]; \ 184 static JSConstSpec JS_Class_Consts[]; \
185 static JSPropertySpec JS_Class_Properties[]; \ 185 static JSPropertySpec JS_Class_Properties[]; \
186 static JSMethodSpec JS_Class_Methods[]; \ 186 static JSMethodSpec JS_Class_Methods[]; \
187 static const wchar_t* m_pClassName 187 static const wchar_t* m_pClassName
188 188
189 #define IMPLEMENT_JS_CLASS_RICH(js_class_name, class_alternate, class_name) \ 189 #define IMPLEMENT_JS_CLASS_RICH(js_class_name, class_alternate, class_name) \
190 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name); \ 190 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name); \
191 void js_class_name::JSConstructor(IFXJS_Context* cc, JSFXObject obj, \ 191 void js_class_name::JSConstructor(IFXJS_Context* cc, \
192 JSFXObject global) { \ 192 v8::Local<v8::Object> obj, \
193 v8::Local<v8::Object> global) { \
193 CJS_Object* pObj = new js_class_name(obj); \ 194 CJS_Object* pObj = new js_class_name(obj); \
194 pObj->SetEmbedObject(new class_alternate(pObj)); \ 195 pObj->SetEmbedObject(new class_alternate(pObj)); \
195 JS_SetPrivate(NULL, obj, (void*)pObj); \ 196 JS_SetPrivate(NULL, obj, (void*)pObj); \
196 pObj->InitInstance(cc); \ 197 pObj->InitInstance(cc); \
197 } \ 198 } \
198 \ 199 \
199 void js_class_name::JSDestructor(JSFXObject obj) { \ 200 void js_class_name::JSDestructor(v8::Local<v8::Object> obj) { \
200 js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL, obj); \ 201 js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL, obj); \
201 ASSERT(pObj != NULL); \ 202 ASSERT(pObj != NULL); \
202 pObj->ExitInstance(); \ 203 pObj->ExitInstance(); \
203 delete pObj; \ 204 delete pObj; \
204 } \ 205 } \
205 \ 206 \
206 int js_class_name::Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType) { \ 207 int js_class_name::Init(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType) { \
207 int nObjDefnID = JS_DefineObj(pRuntime, js_class_name::m_pClassName, \ 208 int nObjDefnID = JS_DefineObj(pIsolate, js_class_name::m_pClassName, \
208 eObjType, JSConstructor, JSDestructor); \ 209 eObjType, JSConstructor, JSDestructor); \
209 if (nObjDefnID >= 0) { \ 210 if (nObjDefnID >= 0) { \
210 for (int j = 0, \ 211 for (int j = 0, \
211 szj = sizeof(JS_Class_Properties) / sizeof(JSPropertySpec) - 1; \ 212 szj = sizeof(JS_Class_Properties) / sizeof(JSPropertySpec) - 1; \
212 j < szj; j++) { \ 213 j < szj; j++) { \
213 if (JS_DefineObjProperty(pRuntime, nObjDefnID, \ 214 if (JS_DefineObjProperty(pIsolate, nObjDefnID, \
214 JS_Class_Properties[j].pName, \ 215 JS_Class_Properties[j].pName, \
215 JS_Class_Properties[j].pPropGet, \ 216 JS_Class_Properties[j].pPropGet, \
216 JS_Class_Properties[j].pPropPut) < 0) \ 217 JS_Class_Properties[j].pPropPut) < 0) \
217 return -1; \ 218 return -1; \
218 } \ 219 } \
219 for (int k = 0, \ 220 for (int k = 0, \
220 szk = sizeof(JS_Class_Methods) / sizeof(JSMethodSpec) - 1; \ 221 szk = sizeof(JS_Class_Methods) / sizeof(JSMethodSpec) - 1; \
221 k < szk; k++) { \ 222 k < szk; k++) { \
222 if (JS_DefineObjMethod(pRuntime, nObjDefnID, \ 223 if (JS_DefineObjMethod(pIsolate, nObjDefnID, \
223 JS_Class_Methods[k].pName, \ 224 JS_Class_Methods[k].pName, \
224 JS_Class_Methods[k].pMethodCall) < 0) \ 225 JS_Class_Methods[k].pMethodCall) < 0) \
225 return -1; \ 226 return -1; \
226 } \ 227 } \
227 return nObjDefnID; \ 228 return nObjDefnID; \
228 } \ 229 } \
229 return -1; \ 230 return -1; \
230 } 231 }
231 232
232 #define IMPLEMENT_JS_CLASS(js_class_name, class_name) \ 233 #define IMPLEMENT_JS_CLASS(js_class_name, class_name) \
233 IMPLEMENT_JS_CLASS_RICH(js_class_name, class_name, class_name) 234 IMPLEMENT_JS_CLASS_RICH(js_class_name, class_name, class_name)
234 235
235 /* ======================================== CONST CLASS 236 /* ======================================== CONST CLASS
236 * ============================================ */ 237 * ============================================ */
237 238
238 #define DECLARE_JS_CLASS_CONST() \ 239 #define DECLARE_JS_CLASS_CONST() \
239 static int Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType); \ 240 static int Init(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType); \
240 static JSConstSpec JS_Class_Consts[]; \ 241 static JSConstSpec JS_Class_Consts[]; \
241 static const wchar_t* m_pClassName 242 static const wchar_t* m_pClassName
242 243
243 #define IMPLEMENT_JS_CLASS_CONST(js_class_name, class_name) \ 244 #define IMPLEMENT_JS_CLASS_CONST(js_class_name, class_name) \
244 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name); \ 245 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name); \
245 int js_class_name::Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType) { \ 246 int js_class_name::Init(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType) { \
246 int nObjDefnID = JS_DefineObj(pRuntime, js_class_name::m_pClassName, \ 247 int nObjDefnID = JS_DefineObj(pIsolate, js_class_name::m_pClassName, \
247 eObjType, NULL, NULL); \ 248 eObjType, NULL, NULL); \
248 if (nObjDefnID >= 0) { \ 249 if (nObjDefnID >= 0) { \
249 for (int i = 0, sz = sizeof(JS_Class_Consts) / sizeof(JSConstSpec) - 1; \ 250 for (int i = 0, sz = sizeof(JS_Class_Consts) / sizeof(JSConstSpec) - 1; \
250 i < sz; i++) { \ 251 i < sz; i++) { \
251 if (JS_Class_Consts[i].t == 0) { \ 252 if (JS_Class_Consts[i].t == 0) { \
252 if (JS_DefineObjConst( \ 253 if (JS_DefineObjConst( \
253 pRuntime, nObjDefnID, JS_Class_Consts[i].pName, \ 254 pIsolate, nObjDefnID, JS_Class_Consts[i].pName, \
254 JS_NewNumber(pRuntime, JS_Class_Consts[i].number)) < 0) \ 255 JS_NewNumber(pIsolate, JS_Class_Consts[i].number)) < 0) \
255 return -1; \ 256 return -1; \
256 } else { \ 257 } else { \
257 if (JS_DefineObjConst( \ 258 if (JS_DefineObjConst( \
258 pRuntime, nObjDefnID, JS_Class_Consts[i].pName, \ 259 pIsolate, nObjDefnID, JS_Class_Consts[i].pName, \
259 JS_NewString(pRuntime, JS_Class_Consts[i].string)) < 0) \ 260 JS_NewString(pIsolate, JS_Class_Consts[i].string)) < 0) \
260 return -1; \ 261 return -1; \
261 } \ 262 } \
262 } \ 263 } \
263 return nObjDefnID; \ 264 return nObjDefnID; \
264 } \ 265 } \
265 return -1; \ 266 return -1; \
266 } 267 }
267 268
268 /* ===================================== SPECIAL JS CLASS 269 /* ===================================== SPECIAL JS CLASS
269 * =============================================== */ 270 * =============================================== */
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 CFX_WideString propname = 346 CFX_WideString propname =
346 CFX_WideString::FromUTF8(*utf8_value, utf8_value.length()); 347 CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());
347 CFX_WideString sError; 348 CFX_WideString sError;
348 if (!pObj->DelProperty(pRuntimeContext, propname.c_str(), sError)) { 349 if (!pObj->DelProperty(pRuntimeContext, propname.c_str(), sError)) {
349 CFX_ByteString cbName; 350 CFX_ByteString cbName;
350 cbName.Format("%s.%s", class_name, "DelProperty"); 351 cbName.Format("%s.%s", class_name, "DelProperty");
351 // Probably a missing call to JS_Error(). 352 // Probably a missing call to JS_Error().
352 } 353 }
353 } 354 }
354 355
355 #define DECLARE_SPECIAL_JS_CLASS(js_class_name) \ 356 #define DECLARE_SPECIAL_JS_CLASS(js_class_name) \
356 static void JSConstructor(IFXJS_Context* cc, JSFXObject obj, \ 357 static void JSConstructor(IFXJS_Context* cc, v8::Local<v8::Object> obj, \
357 JSFXObject global); \ 358 v8::Local<v8::Object> global); \
358 static void JSDestructor(JSFXObject obj); \ 359 static void JSDestructor(v8::Local<v8::Object> obj); \
359 static JSConstSpec JS_Class_Consts[]; \ 360 static JSConstSpec JS_Class_Consts[]; \
360 static JSPropertySpec JS_Class_Properties[]; \ 361 static JSPropertySpec JS_Class_Properties[]; \
361 static JSMethodSpec JS_Class_Methods[]; \ 362 static JSMethodSpec JS_Class_Methods[]; \
362 static int Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType); \ 363 static int Init(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType); \
363 static const wchar_t* m_pClassName; \ 364 static const wchar_t* m_pClassName; \
364 static void queryprop_##js_class_name##_static( \ 365 static void queryprop_##js_class_name##_static( \
365 v8::Local<v8::String> property, \ 366 v8::Local<v8::String> property, \
366 const v8::PropertyCallbackInfo<v8::Integer>& info); \ 367 const v8::PropertyCallbackInfo<v8::Integer>& info); \
367 static void getprop_##js_class_name##_static( \ 368 static void getprop_##js_class_name##_static( \
368 v8::Local<v8::String> property, \ 369 v8::Local<v8::String> property, \
369 const v8::PropertyCallbackInfo<v8::Value>& info); \ 370 const v8::PropertyCallbackInfo<v8::Value>& info); \
370 static void putprop_##js_class_name##_static( \ 371 static void putprop_##js_class_name##_static( \
371 v8::Local<v8::String> property, v8::Local<v8::Value> value, \ 372 v8::Local<v8::String> property, v8::Local<v8::Value> value, \
372 const v8::PropertyCallbackInfo<v8::Value>& info); \ 373 const v8::PropertyCallbackInfo<v8::Value>& info); \
373 static void delprop_##js_class_name##_static( \ 374 static void delprop_##js_class_name##_static( \
374 v8::Local<v8::String> property, \ 375 v8::Local<v8::String> property, \
375 const v8::PropertyCallbackInfo<v8::Boolean>& info) 376 const v8::PropertyCallbackInfo<v8::Boolean>& info)
376 377
377 #define IMPLEMENT_SPECIAL_JS_CLASS(js_class_name, class_alternate, class_name) \ 378 #define IMPLEMENT_SPECIAL_JS_CLASS(js_class_name, class_alternate, class_name) \
378 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name); \ 379 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name); \
379 void js_class_name::queryprop_##js_class_name##_static( \ 380 void js_class_name::queryprop_##js_class_name##_static( \
380 v8::Local<v8::String> property, \ 381 v8::Local<v8::String> property, \
381 const v8::PropertyCallbackInfo<v8::Integer>& info) { \ 382 const v8::PropertyCallbackInfo<v8::Integer>& info) { \
382 JSSpecialPropQuery<class_alternate>(#class_name, property, info); \ 383 JSSpecialPropQuery<class_alternate>(#class_name, property, info); \
383 } \ 384 } \
384 void js_class_name::getprop_##js_class_name##_static( \ 385 void js_class_name::getprop_##js_class_name##_static( \
385 v8::Local<v8::String> property, \ 386 v8::Local<v8::String> property, \
386 const v8::PropertyCallbackInfo<v8::Value>& info) { \ 387 const v8::PropertyCallbackInfo<v8::Value>& info) { \
387 JSSpecialPropGet<class_alternate>(#class_name, property, info); \ 388 JSSpecialPropGet<class_alternate>(#class_name, property, info); \
388 } \ 389 } \
389 void js_class_name::putprop_##js_class_name##_static( \ 390 void js_class_name::putprop_##js_class_name##_static( \
390 v8::Local<v8::String> property, v8::Local<v8::Value> value, \ 391 v8::Local<v8::String> property, v8::Local<v8::Value> value, \
391 const v8::PropertyCallbackInfo<v8::Value>& info) { \ 392 const v8::PropertyCallbackInfo<v8::Value>& info) { \
392 JSSpecialPropPut<class_alternate>(#class_name, property, value, info); \ 393 JSSpecialPropPut<class_alternate>(#class_name, property, value, info); \
393 } \ 394 } \
394 void js_class_name::delprop_##js_class_name##_static( \ 395 void js_class_name::delprop_##js_class_name##_static( \
395 v8::Local<v8::String> property, \ 396 v8::Local<v8::String> property, \
396 const v8::PropertyCallbackInfo<v8::Boolean>& info) { \ 397 const v8::PropertyCallbackInfo<v8::Boolean>& info) { \
397 JSSpecialPropDel<class_alternate>(#class_name, property, info); \ 398 JSSpecialPropDel<class_alternate>(#class_name, property, info); \
398 } \ 399 } \
399 void js_class_name::JSConstructor(IFXJS_Context* cc, JSFXObject obj, \ 400 void js_class_name::JSConstructor(IFXJS_Context* cc, \
400 JSFXObject global) { \ 401 v8::Local<v8::Object> obj, \
402 v8::Local<v8::Object> global) { \
401 CJS_Object* pObj = new js_class_name(obj); \ 403 CJS_Object* pObj = new js_class_name(obj); \
402 pObj->SetEmbedObject(new class_alternate(pObj)); \ 404 pObj->SetEmbedObject(new class_alternate(pObj)); \
403 JS_SetPrivate(NULL, obj, (void*)pObj); \ 405 JS_SetPrivate(NULL, obj, (void*)pObj); \
404 pObj->InitInstance(cc); \ 406 pObj->InitInstance(cc); \
405 } \ 407 } \
406 \ 408 \
407 void js_class_name::JSDestructor(JSFXObject obj) { \ 409 void js_class_name::JSDestructor(v8::Local<v8::Object> obj) { \
408 js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL, obj); \ 410 js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL, obj); \
409 ASSERT(pObj != NULL); \ 411 ASSERT(pObj != NULL); \
410 pObj->ExitInstance(); \ 412 pObj->ExitInstance(); \
411 delete pObj; \ 413 delete pObj; \
412 } \ 414 } \
413 \ 415 \
414 int js_class_name::Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType) { \ 416 int js_class_name::Init(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType) { \
415 int nObjDefnID = JS_DefineObj(pRuntime, js_class_name::m_pClassName, \ 417 int nObjDefnID = JS_DefineObj(pIsolate, js_class_name::m_pClassName, \
416 eObjType, JSConstructor, JSDestructor); \ 418 eObjType, JSConstructor, JSDestructor); \
417 \ 419 \
418 if (nObjDefnID >= 0) { \ 420 if (nObjDefnID >= 0) { \
419 for (int j = 0, \ 421 for (int j = 0, \
420 szj = sizeof(JS_Class_Properties) / sizeof(JSPropertySpec) - 1; \ 422 szj = sizeof(JS_Class_Properties) / sizeof(JSPropertySpec) - 1; \
421 j < szj; j++) { \ 423 j < szj; j++) { \
422 if (JS_DefineObjProperty(pRuntime, nObjDefnID, \ 424 if (JS_DefineObjProperty(pIsolate, nObjDefnID, \
423 JS_Class_Properties[j].pName, \ 425 JS_Class_Properties[j].pName, \
424 JS_Class_Properties[j].pPropGet, \ 426 JS_Class_Properties[j].pPropGet, \
425 JS_Class_Properties[j].pPropPut) < 0) \ 427 JS_Class_Properties[j].pPropPut) < 0) \
426 return -1; \ 428 return -1; \
427 } \ 429 } \
428 \ 430 \
429 for (int k = 0, \ 431 for (int k = 0, \
430 szk = sizeof(JS_Class_Methods) / sizeof(JSMethodSpec) - 1; \ 432 szk = sizeof(JS_Class_Methods) / sizeof(JSMethodSpec) - 1; \
431 k < szk; k++) { \ 433 k < szk; k++) { \
432 if (JS_DefineObjMethod(pRuntime, nObjDefnID, \ 434 if (JS_DefineObjMethod(pIsolate, nObjDefnID, \
433 JS_Class_Methods[k].pName, \ 435 JS_Class_Methods[k].pName, \
434 JS_Class_Methods[k].pMethodCall) < 0) \ 436 JS_Class_Methods[k].pMethodCall) < 0) \
435 return -1; \ 437 return -1; \
436 } \ 438 } \
437 if (JS_DefineObjAllProperties( \ 439 if (JS_DefineObjAllProperties( \
438 pRuntime, nObjDefnID, \ 440 pIsolate, nObjDefnID, \
439 js_class_name::queryprop_##js_class_name##_static, \ 441 js_class_name::queryprop_##js_class_name##_static, \
440 js_class_name::getprop_##js_class_name##_static, \ 442 js_class_name::getprop_##js_class_name##_static, \
441 js_class_name::putprop_##js_class_name##_static, \ 443 js_class_name::putprop_##js_class_name##_static, \
442 js_class_name::delprop_##js_class_name##_static) < 0) \ 444 js_class_name::delprop_##js_class_name##_static) < 0) \
443 return -1; \ 445 return -1; \
444 \ 446 \
445 return nObjDefnID; \ 447 return nObjDefnID; \
446 } \ 448 } \
447 \ 449 \
448 return -1; \ 450 return -1; \
(...skipping 23 matching lines...) Expand all
472 } 474 }
473 475
474 #define JS_STATIC_GLOBAL_FUN(fun_name) \ 476 #define JS_STATIC_GLOBAL_FUN(fun_name) \
475 static void fun_name##_static( \ 477 static void fun_name##_static( \
476 const v8::FunctionCallbackInfo<v8::Value>& info) { \ 478 const v8::FunctionCallbackInfo<v8::Value>& info) { \
477 JSGlobalFunc<fun_name>(#fun_name, info); \ 479 JSGlobalFunc<fun_name>(#fun_name, info); \
478 } 480 }
479 481
480 #define JS_STATIC_DECLARE_GLOBAL_FUN() \ 482 #define JS_STATIC_DECLARE_GLOBAL_FUN() \
481 static JSMethodSpec global_methods[]; \ 483 static JSMethodSpec global_methods[]; \
482 static int Init(IJS_Runtime* pRuntime) 484 static int Init(v8::Isolate* pIsolate)
483 485
484 #define BEGIN_JS_STATIC_GLOBAL_FUN(js_class_name) \ 486 #define BEGIN_JS_STATIC_GLOBAL_FUN(js_class_name) \
485 JSMethodSpec js_class_name::global_methods[] = { 487 JSMethodSpec js_class_name::global_methods[] = {
486 #define JS_STATIC_GLOBAL_FUN_ENTRY(method_name) \ 488 #define JS_STATIC_GLOBAL_FUN_ENTRY(method_name) \
487 JS_STATIC_METHOD_ENTRY(method_name) 489 JS_STATIC_METHOD_ENTRY(method_name)
488 490
489 #define END_JS_STATIC_GLOBAL_FUN() END_JS_STATIC_METHOD() 491 #define END_JS_STATIC_GLOBAL_FUN() END_JS_STATIC_METHOD()
490 492
491 #define IMPLEMENT_JS_STATIC_GLOBAL_FUN(js_class_name) \ 493 #define IMPLEMENT_JS_STATIC_GLOBAL_FUN(js_class_name) \
492 int js_class_name::Init(IJS_Runtime* pRuntime) { \ 494 int js_class_name::Init(v8::Isolate* pIsolate) { \
493 for (int i = 0, sz = sizeof(js_class_name::global_methods) / \ 495 for (int i = 0, sz = sizeof(js_class_name::global_methods) / \
494 sizeof(JSMethodSpec) - \ 496 sizeof(JSMethodSpec) - \
495 1; \ 497 1; \
496 i < sz; i++) { \ 498 i < sz; i++) { \
497 if (JS_DefineGlobalMethod( \ 499 if (JS_DefineGlobalMethod( \
498 pRuntime, js_class_name::global_methods[i].pName, \ 500 pIsolate, js_class_name::global_methods[i].pName, \
499 js_class_name::global_methods[i].pMethodCall) < 0) \ 501 js_class_name::global_methods[i].pMethodCall) < 0) \
500 return -1; \ 502 return -1; \
501 } \ 503 } \
502 return 0; \ 504 return 0; \
503 } 505 }
504 506
505 /* ======================================== GLOBAL CONSTS 507 /* ======================================== GLOBAL CONSTS
506 * ============================================ */ 508 * ============================================ */
507 #define DEFINE_GLOBAL_CONST(pRuntime, const_name, const_value) \ 509 #define DEFINE_GLOBAL_CONST(pIsolate, const_name, const_value) \
508 if (JS_DefineGlobalConst( \ 510 if (JS_DefineGlobalConst( \
509 pRuntime, JS_WIDESTRING(const_name), \ 511 pIsolate, JS_WIDESTRING(const_name), \
510 JS_NewString(pRuntime, JS_WIDESTRING(const_value)))) \ 512 JS_NewString(pIsolate, JS_WIDESTRING(const_value)))) \
511 return -1 513 return -1
512 514
513 /* ======================================== GLOBAL ARRAYS 515 /* ======================================== GLOBAL ARRAYS
514 * ============================================ */ 516 * ============================================ */
515 517
516 #define DEFINE_GLOBAL_ARRAY(pRuntime) \ 518 #define DEFINE_GLOBAL_ARRAY(pIsolate) \
517 int size = FX_ArraySize(ArrayContent); \ 519 int size = FX_ArraySize(ArrayContent); \
518 \ 520 \
519 CJS_Array array(pRuntime); \ 521 CJS_Array array(pIsolate); \
520 for (int i = 0; i < size; i++) \ 522 for (int i = 0; i < size; i++) \
521 array.SetElement(i, CJS_Value(pRuntime, ArrayContent[i])); \ 523 array.SetElement(i, CJS_Value(pIsolate, ArrayContent[i])); \
522 \ 524 \
523 CJS_PropValue prop(pRuntime); \ 525 CJS_PropValue prop(pIsolate); \
524 prop << array; \ 526 prop << array; \
525 if (JS_DefineGlobalConst(pRuntime, (const wchar_t*)ArrayName, \ 527 if (JS_DefineGlobalConst(pIsolate, (const wchar_t*)ArrayName, \
526 prop.ToV8Value()) < 0) \ 528 prop.ToV8Value()) < 0) \
527 return -1 529 return -1
528 530
529 /* ============================================================ */ 531 /* ============================================================ */
530 532
531 #define VALUE_NAME_STRING L"string" 533 #define VALUE_NAME_STRING L"string"
532 #define VALUE_NAME_NUMBER L"number" 534 #define VALUE_NAME_NUMBER L"number"
533 #define VALUE_NAME_BOOLEAN L"boolean" 535 #define VALUE_NAME_BOOLEAN L"boolean"
534 #define VALUE_NAME_DATE L"date" 536 #define VALUE_NAME_DATE L"date"
535 #define VALUE_NAME_OBJECT L"object" 537 #define VALUE_NAME_OBJECT L"object"
536 #define VALUE_NAME_FXOBJ L"fxobj" 538 #define VALUE_NAME_FXOBJ L"fxobj"
537 #define VALUE_NAME_NULL L"null" 539 #define VALUE_NAME_NULL L"null"
538 #define VALUE_NAME_UNDEFINED L"undefined" 540 #define VALUE_NAME_UNDEFINED L"undefined"
539 541
540 FXJSVALUETYPE GET_VALUE_TYPE(v8::Local<v8::Value> p); 542 FXJSVALUETYPE GET_VALUE_TYPE(v8::Local<v8::Value> p);
541 543
542 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_DEFINE_H_ 544 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_DEFINE_H_
OLDNEW
« no previous file with comments | « fpdfsdk/include/javascript/Icon.h ('k') | fpdfsdk/include/javascript/JS_Object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698