OLD | NEW |
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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 #define JS_SPECIAL_STATIC_METHOD(method_name, class_alternate, class_name) \ | 182 #define JS_SPECIAL_STATIC_METHOD(method_name, class_alternate, class_name) \ |
183 static void method_name##_static( \ | 183 static void method_name##_static( \ |
184 const v8::FunctionCallbackInfo<v8::Value>& info) { \ | 184 const v8::FunctionCallbackInfo<v8::Value>& info) { \ |
185 JSMethod<class_alternate, &class_alternate::method_name>( \ | 185 JSMethod<class_alternate, &class_alternate::method_name>( \ |
186 #method_name, #class_name, info); \ | 186 #method_name, #class_name, info); \ |
187 } | 187 } |
188 | 188 |
189 /* ===================================== JS CLASS | 189 /* ===================================== JS CLASS |
190 * =============================================== */ | 190 * =============================================== */ |
191 | 191 |
192 #define DECLARE_JS_CLASS(js_class_name) \ | 192 #define DECLARE_JS_CLASS(js_class_name) \ |
193 static void JSConstructor(IFXJS_Context* cc, v8::Local<v8::Object> obj, \ | 193 static void JSConstructor(IFXJS_Context* cc, v8::Local<v8::Object> obj, \ |
194 v8::Local<v8::Object> global); \ | 194 v8::Local<v8::Object> global); \ |
195 static void JSDestructor(v8::Local<v8::Object> obj); \ | 195 static void JSDestructor(v8::Local<v8::Object> obj); \ |
196 static int Init(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType); \ | 196 static int DefineJSObjects(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType); \ |
197 static JSConstSpec JS_Class_Consts[]; \ | 197 static JSConstSpec JS_Class_Consts[]; \ |
198 static JSPropertySpec JS_Class_Properties[]; \ | 198 static JSPropertySpec JS_Class_Properties[]; \ |
199 static JSMethodSpec JS_Class_Methods[]; \ | 199 static JSMethodSpec JS_Class_Methods[]; \ |
200 static const wchar_t* m_pClassName | 200 static const wchar_t* m_pClassName |
201 | 201 |
202 #define IMPLEMENT_JS_CLASS_RICH(js_class_name, class_alternate, class_name) \ | 202 #define IMPLEMENT_JS_CLASS_RICH(js_class_name, class_alternate, class_name) \ |
203 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name); \ | 203 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name); \ |
204 void js_class_name::JSConstructor(IFXJS_Context* cc, \ | 204 void js_class_name::JSConstructor(IFXJS_Context* cc, \ |
205 v8::Local<v8::Object> obj, \ | 205 v8::Local<v8::Object> obj, \ |
206 v8::Local<v8::Object> global) { \ | 206 v8::Local<v8::Object> global) { \ |
207 CJS_Object* pObj = new js_class_name(obj); \ | 207 CJS_Object* pObj = new js_class_name(obj); \ |
208 pObj->SetEmbedObject(new class_alternate(pObj)); \ | 208 pObj->SetEmbedObject(new class_alternate(pObj)); \ |
209 JS_SetPrivate(NULL, obj, (void*)pObj); \ | 209 JS_SetPrivate(NULL, obj, (void*)pObj); \ |
210 pObj->InitInstance(cc); \ | 210 pObj->InitInstance(cc); \ |
211 } \ | 211 } \ |
212 \ | 212 \ |
213 void js_class_name::JSDestructor(v8::Local<v8::Object> obj) { \ | 213 void js_class_name::JSDestructor(v8::Local<v8::Object> obj) { \ |
214 js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL, obj); \ | 214 js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL, obj); \ |
215 ASSERT(pObj != NULL); \ | 215 pObj->ExitInstance(); \ |
216 pObj->ExitInstance(); \ | 216 delete pObj; \ |
217 delete pObj; \ | 217 } \ |
218 } \ | 218 \ |
219 \ | 219 int js_class_name::DefineJSObjects(v8::Isolate* pIsolate, \ |
220 int js_class_name::Init(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType) { \ | 220 FXJSOBJTYPE eObjType) { \ |
221 int nObjDefnID = JS_DefineObj(pIsolate, js_class_name::m_pClassName, \ | 221 int nObjDefnID = JS_DefineObj(pIsolate, js_class_name::m_pClassName, \ |
222 eObjType, JSConstructor, JSDestructor); \ | 222 eObjType, JSConstructor, JSDestructor); \ |
223 if (nObjDefnID >= 0) { \ | 223 if (nObjDefnID < 0) \ |
224 for (int j = 0, \ | 224 return -1; \ |
225 szj = sizeof(JS_Class_Properties) / sizeof(JSPropertySpec) - 1; \ | 225 for (int i = 0; i < FX_ArraySize(JS_Class_Properties) - 1; ++i) { \ |
226 j < szj; j++) { \ | 226 if (JS_DefineObjProperty(pIsolate, nObjDefnID, \ |
227 if (JS_DefineObjProperty(pIsolate, nObjDefnID, \ | 227 JS_Class_Properties[i].pName, \ |
228 JS_Class_Properties[j].pName, \ | 228 JS_Class_Properties[i].pPropGet, \ |
229 JS_Class_Properties[j].pPropGet, \ | 229 JS_Class_Properties[i].pPropPut) < 0) \ |
230 JS_Class_Properties[j].pPropPut) < 0) \ | 230 return -1; \ |
231 return -1; \ | 231 } \ |
232 } \ | 232 for (int i = 0; i < FX_ArraySize(JS_Class_Methods) - 1; ++i) { \ |
233 for (int k = 0, \ | 233 if (JS_DefineObjMethod(pIsolate, nObjDefnID, JS_Class_Methods[i].pName, \ |
234 szk = sizeof(JS_Class_Methods) / sizeof(JSMethodSpec) - 1; \ | 234 JS_Class_Methods[i].pMethodCall) < 0) \ |
235 k < szk; k++) { \ | 235 return -1; \ |
236 if (JS_DefineObjMethod(pIsolate, nObjDefnID, \ | 236 } \ |
237 JS_Class_Methods[k].pName, \ | 237 return nObjDefnID; \ |
238 JS_Class_Methods[k].pMethodCall) < 0) \ | |
239 return -1; \ | |
240 } \ | |
241 return nObjDefnID; \ | |
242 } \ | |
243 return -1; \ | |
244 } | 238 } |
245 | 239 |
246 #define IMPLEMENT_JS_CLASS(js_class_name, class_name) \ | 240 #define IMPLEMENT_JS_CLASS(js_class_name, class_name) \ |
247 IMPLEMENT_JS_CLASS_RICH(js_class_name, class_name, class_name) | 241 IMPLEMENT_JS_CLASS_RICH(js_class_name, class_name, class_name) |
248 | 242 |
249 /* ======================================== CONST CLASS | 243 /* ======================================== CONST CLASS |
250 * ============================================ */ | 244 * ============================================ */ |
251 | 245 |
252 #define DECLARE_JS_CLASS_CONST() \ | 246 #define DECLARE_JS_CLASS_CONST() \ |
253 static int Init(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType); \ | 247 static int DefineJSObjects(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType); \ |
254 static JSConstSpec JS_Class_Consts[]; \ | 248 static JSConstSpec JS_Class_Consts[]; \ |
255 static const wchar_t* m_pClassName | 249 static const wchar_t* m_pClassName |
256 | 250 |
257 #define IMPLEMENT_JS_CLASS_CONST(js_class_name, class_name) \ | 251 #define IMPLEMENT_JS_CLASS_CONST(js_class_name, class_name) \ |
258 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name); \ | 252 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name); \ |
259 int js_class_name::Init(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType) { \ | 253 int js_class_name::DefineJSObjects(v8::Isolate* pIsolate, \ |
| 254 FXJSOBJTYPE eObjType) { \ |
260 int nObjDefnID = JS_DefineObj(pIsolate, js_class_name::m_pClassName, \ | 255 int nObjDefnID = JS_DefineObj(pIsolate, js_class_name::m_pClassName, \ |
261 eObjType, NULL, NULL); \ | 256 eObjType, NULL, NULL); \ |
262 if (nObjDefnID >= 0) { \ | 257 if (nObjDefnID >= 0) { \ |
263 for (int i = 0, sz = sizeof(JS_Class_Consts) / sizeof(JSConstSpec) - 1; \ | 258 for (int i = 0, sz = sizeof(JS_Class_Consts) / sizeof(JSConstSpec) - 1; \ |
264 i < sz; i++) { \ | 259 i < sz; i++) { \ |
265 if (JS_Class_Consts[i].t == 0) { \ | 260 if (JS_Class_Consts[i].t == 0) { \ |
266 if (JS_DefineObjConst( \ | 261 if (JS_DefineObjConst( \ |
267 pIsolate, nObjDefnID, JS_Class_Consts[i].pName, \ | 262 pIsolate, nObjDefnID, JS_Class_Consts[i].pName, \ |
268 JS_NewNumber(pIsolate, JS_Class_Consts[i].number)) < 0) \ | 263 JS_NewNumber(pIsolate, JS_Class_Consts[i].number)) < 0) \ |
269 return -1; \ | 264 return -1; \ |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 CFX_WideString propname = | 360 CFX_WideString propname = |
366 CFX_WideString::FromUTF8(*utf8_value, utf8_value.length()); | 361 CFX_WideString::FromUTF8(*utf8_value, utf8_value.length()); |
367 CFX_WideString sError; | 362 CFX_WideString sError; |
368 if (!pObj->DelProperty(pRuntimeContext, propname.c_str(), sError)) { | 363 if (!pObj->DelProperty(pRuntimeContext, propname.c_str(), sError)) { |
369 CFX_ByteString cbName; | 364 CFX_ByteString cbName; |
370 cbName.Format("%s.%s", class_name, "DelProperty"); | 365 cbName.Format("%s.%s", class_name, "DelProperty"); |
371 // Probably a missing call to JS_Error(). | 366 // Probably a missing call to JS_Error(). |
372 } | 367 } |
373 } | 368 } |
374 | 369 |
375 #define DECLARE_SPECIAL_JS_CLASS(js_class_name) \ | 370 #define DECLARE_SPECIAL_JS_CLASS(js_class_name) \ |
376 static void JSConstructor(IFXJS_Context* cc, v8::Local<v8::Object> obj, \ | 371 static void JSConstructor(IFXJS_Context* cc, v8::Local<v8::Object> obj, \ |
377 v8::Local<v8::Object> global); \ | 372 v8::Local<v8::Object> global); \ |
378 static void JSDestructor(v8::Local<v8::Object> obj); \ | 373 static void JSDestructor(v8::Local<v8::Object> obj); \ |
379 static JSConstSpec JS_Class_Consts[]; \ | 374 static JSConstSpec JS_Class_Consts[]; \ |
380 static JSPropertySpec JS_Class_Properties[]; \ | 375 static JSPropertySpec JS_Class_Properties[]; \ |
381 static JSMethodSpec JS_Class_Methods[]; \ | 376 static JSMethodSpec JS_Class_Methods[]; \ |
382 static int Init(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType); \ | 377 static int DefineJSObjects(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType); \ |
383 static const wchar_t* m_pClassName; \ | 378 static const wchar_t* m_pClassName; \ |
384 static void queryprop_##js_class_name##_static( \ | 379 static void queryprop_##js_class_name##_static( \ |
385 v8::Local<v8::String> property, \ | 380 v8::Local<v8::String> property, \ |
386 const v8::PropertyCallbackInfo<v8::Integer>& info); \ | 381 const v8::PropertyCallbackInfo<v8::Integer>& info); \ |
387 static void getprop_##js_class_name##_static( \ | 382 static void getprop_##js_class_name##_static( \ |
388 v8::Local<v8::String> property, \ | 383 v8::Local<v8::String> property, \ |
389 const v8::PropertyCallbackInfo<v8::Value>& info); \ | 384 const v8::PropertyCallbackInfo<v8::Value>& info); \ |
390 static void putprop_##js_class_name##_static( \ | 385 static void putprop_##js_class_name##_static( \ |
391 v8::Local<v8::String> property, v8::Local<v8::Value> value, \ | 386 v8::Local<v8::String> property, v8::Local<v8::Value> value, \ |
392 const v8::PropertyCallbackInfo<v8::Value>& info); \ | 387 const v8::PropertyCallbackInfo<v8::Value>& info); \ |
393 static void delprop_##js_class_name##_static( \ | 388 static void delprop_##js_class_name##_static( \ |
394 v8::Local<v8::String> property, \ | 389 v8::Local<v8::String> property, \ |
395 const v8::PropertyCallbackInfo<v8::Boolean>& info) | 390 const v8::PropertyCallbackInfo<v8::Boolean>& info) |
396 | 391 |
397 #define IMPLEMENT_SPECIAL_JS_CLASS(js_class_name, class_alternate, class_name) \ | 392 #define IMPLEMENT_SPECIAL_JS_CLASS(js_class_name, class_alternate, class_name) \ |
398 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name); \ | 393 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name); \ |
399 void js_class_name::queryprop_##js_class_name##_static( \ | 394 void js_class_name::queryprop_##js_class_name##_static( \ |
400 v8::Local<v8::String> property, \ | 395 v8::Local<v8::String> property, \ |
401 const v8::PropertyCallbackInfo<v8::Integer>& info) { \ | 396 const v8::PropertyCallbackInfo<v8::Integer>& info) { \ |
402 JSSpecialPropQuery<class_alternate>(#class_name, property, info); \ | 397 JSSpecialPropQuery<class_alternate>(#class_name, property, info); \ |
403 } \ | 398 } \ |
404 void js_class_name::getprop_##js_class_name##_static( \ | 399 void js_class_name::getprop_##js_class_name##_static( \ |
(...skipping 20 matching lines...) Expand all Loading... |
425 pObj->InitInstance(cc); \ | 420 pObj->InitInstance(cc); \ |
426 } \ | 421 } \ |
427 \ | 422 \ |
428 void js_class_name::JSDestructor(v8::Local<v8::Object> obj) { \ | 423 void js_class_name::JSDestructor(v8::Local<v8::Object> obj) { \ |
429 js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL, obj); \ | 424 js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL, obj); \ |
430 ASSERT(pObj != NULL); \ | 425 ASSERT(pObj != NULL); \ |
431 pObj->ExitInstance(); \ | 426 pObj->ExitInstance(); \ |
432 delete pObj; \ | 427 delete pObj; \ |
433 } \ | 428 } \ |
434 \ | 429 \ |
435 int js_class_name::Init(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType) { \ | 430 int js_class_name::DefineJSObjects(v8::Isolate* pIsolate, \ |
| 431 FXJSOBJTYPE eObjType) { \ |
436 int nObjDefnID = JS_DefineObj(pIsolate, js_class_name::m_pClassName, \ | 432 int nObjDefnID = JS_DefineObj(pIsolate, js_class_name::m_pClassName, \ |
437 eObjType, JSConstructor, JSDestructor); \ | 433 eObjType, JSConstructor, JSDestructor); \ |
438 \ | 434 \ |
439 if (nObjDefnID >= 0) { \ | 435 if (nObjDefnID < 0) \ |
440 for (int j = 0, \ | 436 return -1; \ |
441 szj = sizeof(JS_Class_Properties) / sizeof(JSPropertySpec) - 1; \ | 437 for (int i = 0; i < FX_ArraySize(JS_Class_Properties) - 1; ++i) { \ |
442 j < szj; j++) { \ | 438 if (JS_DefineObjProperty(pIsolate, nObjDefnID, \ |
443 if (JS_DefineObjProperty(pIsolate, nObjDefnID, \ | 439 JS_Class_Properties[i].pName, \ |
444 JS_Class_Properties[j].pName, \ | 440 JS_Class_Properties[i].pPropGet, \ |
445 JS_Class_Properties[j].pPropGet, \ | 441 JS_Class_Properties[i].pPropPut) < 0) \ |
446 JS_Class_Properties[j].pPropPut) < 0) \ | |
447 return -1; \ | |
448 } \ | |
449 \ | |
450 for (int k = 0, \ | |
451 szk = sizeof(JS_Class_Methods) / sizeof(JSMethodSpec) - 1; \ | |
452 k < szk; k++) { \ | |
453 if (JS_DefineObjMethod(pIsolate, nObjDefnID, \ | |
454 JS_Class_Methods[k].pName, \ | |
455 JS_Class_Methods[k].pMethodCall) < 0) \ | |
456 return -1; \ | |
457 } \ | |
458 if (JS_DefineObjAllProperties( \ | |
459 pIsolate, nObjDefnID, \ | |
460 js_class_name::queryprop_##js_class_name##_static, \ | |
461 js_class_name::getprop_##js_class_name##_static, \ | |
462 js_class_name::putprop_##js_class_name##_static, \ | |
463 js_class_name::delprop_##js_class_name##_static) < 0) \ | |
464 return -1; \ | 442 return -1; \ |
465 \ | |
466 return nObjDefnID; \ | |
467 } \ | 443 } \ |
468 \ | 444 \ |
469 return -1; \ | 445 for (int i = 0; i < FX_ArraySize(JS_Class_Methods) - 1; ++i) { \ |
| 446 if (JS_DefineObjMethod(pIsolate, nObjDefnID, JS_Class_Methods[i].pName, \ |
| 447 JS_Class_Methods[i].pMethodCall) < 0) \ |
| 448 return -1; \ |
| 449 } \ |
| 450 if (JS_DefineObjAllProperties( \ |
| 451 pIsolate, nObjDefnID, \ |
| 452 js_class_name::queryprop_##js_class_name##_static, \ |
| 453 js_class_name::getprop_##js_class_name##_static, \ |
| 454 js_class_name::putprop_##js_class_name##_static, \ |
| 455 js_class_name::delprop_##js_class_name##_static) < 0) \ |
| 456 return -1; \ |
| 457 return nObjDefnID; \ |
470 } | 458 } |
471 | 459 |
472 /* ======================================== GLOBAL METHODS | 460 /* ======================================== GLOBAL METHODS |
473 * ============================================ */ | 461 * ============================================ */ |
474 | 462 |
475 template <FX_BOOL (*F)(IFXJS_Context* cc, | 463 template <FX_BOOL (*F)(IFXJS_Context* cc, |
476 const CJS_Parameters& params, | 464 const CJS_Parameters& params, |
477 CJS_Value& vRet, | 465 CJS_Value& vRet, |
478 CFX_WideString& sError)> | 466 CFX_WideString& sError)> |
479 void JSGlobalFunc(const char* func_name_string, | 467 void JSGlobalFunc(const char* func_name_string, |
(...skipping 18 matching lines...) Expand all Loading... |
498 } | 486 } |
499 | 487 |
500 #define JS_STATIC_GLOBAL_FUN(fun_name) \ | 488 #define JS_STATIC_GLOBAL_FUN(fun_name) \ |
501 static void fun_name##_static( \ | 489 static void fun_name##_static( \ |
502 const v8::FunctionCallbackInfo<v8::Value>& info) { \ | 490 const v8::FunctionCallbackInfo<v8::Value>& info) { \ |
503 JSGlobalFunc<fun_name>(#fun_name, info); \ | 491 JSGlobalFunc<fun_name>(#fun_name, info); \ |
504 } | 492 } |
505 | 493 |
506 #define JS_STATIC_DECLARE_GLOBAL_FUN() \ | 494 #define JS_STATIC_DECLARE_GLOBAL_FUN() \ |
507 static JSMethodSpec global_methods[]; \ | 495 static JSMethodSpec global_methods[]; \ |
508 static int Init(v8::Isolate* pIsolate) | 496 static int DefineJSObjects(v8::Isolate* pIsolate) |
509 | 497 |
510 #define BEGIN_JS_STATIC_GLOBAL_FUN(js_class_name) \ | 498 #define BEGIN_JS_STATIC_GLOBAL_FUN(js_class_name) \ |
511 JSMethodSpec js_class_name::global_methods[] = { | 499 JSMethodSpec js_class_name::global_methods[] = { |
512 #define JS_STATIC_GLOBAL_FUN_ENTRY(method_name) \ | 500 #define JS_STATIC_GLOBAL_FUN_ENTRY(method_name) \ |
513 JS_STATIC_METHOD_ENTRY(method_name) | 501 JS_STATIC_METHOD_ENTRY(method_name) |
514 | 502 |
515 #define END_JS_STATIC_GLOBAL_FUN() END_JS_STATIC_METHOD() | 503 #define END_JS_STATIC_GLOBAL_FUN() END_JS_STATIC_METHOD() |
516 | 504 |
517 #define IMPLEMENT_JS_STATIC_GLOBAL_FUN(js_class_name) \ | 505 #define IMPLEMENT_JS_STATIC_GLOBAL_FUN(js_class_name) \ |
518 int js_class_name::Init(v8::Isolate* pIsolate) { \ | 506 int js_class_name::DefineJSObjects(v8::Isolate* pIsolate) { \ |
519 for (int i = 0, sz = sizeof(js_class_name::global_methods) / \ | 507 for (int i = 0; i < FX_ArraySize(global_methods) - 1; ++i) { \ |
520 sizeof(JSMethodSpec) - \ | |
521 1; \ | |
522 i < sz; i++) { \ | |
523 if (JS_DefineGlobalMethod( \ | 508 if (JS_DefineGlobalMethod( \ |
524 pIsolate, js_class_name::global_methods[i].pName, \ | 509 pIsolate, js_class_name::global_methods[i].pName, \ |
525 js_class_name::global_methods[i].pMethodCall) < 0) \ | 510 js_class_name::global_methods[i].pMethodCall) < 0) \ |
526 return -1; \ | 511 return -1; \ |
527 } \ | 512 } \ |
528 return 0; \ | 513 return 0; \ |
529 } | 514 } |
530 | 515 |
531 /* ======================================== GLOBAL CONSTS | |
532 * ============================================ */ | |
533 #define DEFINE_GLOBAL_CONST(pIsolate, const_name, const_value) \ | |
534 if (JS_DefineGlobalConst( \ | |
535 pIsolate, JS_WIDESTRING(const_name), \ | |
536 JS_NewString(pIsolate, JS_WIDESTRING(const_value)))) \ | |
537 return -1 | |
538 | |
539 /* ======================================== GLOBAL ARRAYS | |
540 * ============================================ */ | |
541 | |
542 #define DEFINE_GLOBAL_ARRAY(pIsolate) \ | |
543 int size = FX_ArraySize(ArrayContent); \ | |
544 \ | |
545 CJS_Array array(pIsolate); \ | |
546 for (int i = 0; i < size; i++) \ | |
547 array.SetElement(i, CJS_Value(pIsolate, ArrayContent[i])); \ | |
548 \ | |
549 CJS_PropValue prop(pIsolate); \ | |
550 prop << array; \ | |
551 if (JS_DefineGlobalConst(pIsolate, (const wchar_t*)ArrayName, \ | |
552 prop.ToV8Value()) < 0) \ | |
553 return -1 | |
554 | |
555 /* ============================================================ */ | 516 /* ============================================================ */ |
556 | 517 |
557 #define VALUE_NAME_STRING L"string" | 518 #define VALUE_NAME_STRING L"string" |
558 #define VALUE_NAME_NUMBER L"number" | 519 #define VALUE_NAME_NUMBER L"number" |
559 #define VALUE_NAME_BOOLEAN L"boolean" | 520 #define VALUE_NAME_BOOLEAN L"boolean" |
560 #define VALUE_NAME_DATE L"date" | 521 #define VALUE_NAME_DATE L"date" |
561 #define VALUE_NAME_OBJECT L"object" | 522 #define VALUE_NAME_OBJECT L"object" |
562 #define VALUE_NAME_FXOBJ L"fxobj" | 523 #define VALUE_NAME_FXOBJ L"fxobj" |
563 #define VALUE_NAME_NULL L"null" | 524 #define VALUE_NAME_NULL L"null" |
564 #define VALUE_NAME_UNDEFINED L"undefined" | 525 #define VALUE_NAME_UNDEFINED L"undefined" |
565 | 526 |
566 FXJSVALUETYPE GET_VALUE_TYPE(v8::Local<v8::Value> p); | 527 FXJSVALUETYPE GET_VALUE_TYPE(v8::Local<v8::Value> p); |
567 | 528 |
568 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_DEFINE_H_ | 529 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_DEFINE_H_ |
OLD | NEW |