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_SRC_JAVASCRIPT_JS_DEFINE_H_ | 7 #ifndef FPDFSDK_SRC_JAVASCRIPT_JS_DEFINE_H_ |
8 #define FPDFSDK_SRC_JAVASCRIPT_JS_DEFINE_H_ | 8 #define FPDFSDK_SRC_JAVASCRIPT_JS_DEFINE_H_ |
9 | 9 |
10 #include "../../include/jsapi/fxjs_v8.h" | 10 #include "../../include/jsapi/fxjs_v8.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 #define JS_STATIC_METHOD_ENTRY(method_name) \ | 65 #define JS_STATIC_METHOD_ENTRY(method_name) \ |
66 { JS_WIDESTRING(method_name), method_name##_static } \ | 66 { JS_WIDESTRING(method_name), method_name##_static } \ |
67 , | 67 , |
68 | 68 |
69 #define END_JS_STATIC_METHOD() \ | 69 #define END_JS_STATIC_METHOD() \ |
70 { 0, 0 } \ | 70 { 0, 0 } \ |
71 } \ | 71 } \ |
72 ; | 72 ; |
73 | 73 |
74 template <class C, | 74 template <class C, |
75 FX_BOOL (C::*M)(IFXJS_Context*, CJS_PropValue&, CFX_WideString&)> | 75 FX_BOOL (C::*M)(IJS_Context*, CJS_PropValue&, CFX_WideString&)> |
76 void JSPropGetter(const char* prop_name_string, | 76 void JSPropGetter(const char* prop_name_string, |
77 const char* class_name_string, | 77 const char* class_name_string, |
78 v8::Local<v8::String> property, | 78 v8::Local<v8::String> property, |
79 const v8::PropertyCallbackInfo<v8::Value>& info) { | 79 const v8::PropertyCallbackInfo<v8::Value>& info) { |
80 v8::Isolate* isolate = info.GetIsolate(); | 80 v8::Isolate* isolate = info.GetIsolate(); |
81 IFXJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); | 81 IJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); |
82 if (!pRuntime) | 82 if (!pRuntime) |
83 return; | 83 return; |
84 IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); | 84 IJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); |
85 CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder()); | 85 CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder()); |
86 C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); | 86 C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); |
87 CFX_WideString sError; | 87 CFX_WideString sError; |
88 CJS_PropValue value(isolate); | 88 CJS_PropValue value(isolate); |
89 value.StartGetting(); | 89 value.StartGetting(); |
90 if (!(pObj->*M)(pRuntimeContext, value, sError)) { | 90 if (!(pObj->*M)(pRuntimeContext, value, sError)) { |
91 FXJS_Error(isolate, JSFormatErrorString(class_name_string, prop_name_string, | 91 FXJS_Error(isolate, JSFormatErrorString(class_name_string, prop_name_string, |
92 sError)); | 92 sError)); |
93 return; | 93 return; |
94 } | 94 } |
95 info.GetReturnValue().Set((v8::Local<v8::Value>)value); | 95 info.GetReturnValue().Set((v8::Local<v8::Value>)value); |
96 } | 96 } |
97 | 97 |
98 template <class C, | 98 template <class C, |
99 FX_BOOL (C::*M)(IFXJS_Context*, CJS_PropValue&, CFX_WideString&)> | 99 FX_BOOL (C::*M)(IJS_Context*, CJS_PropValue&, CFX_WideString&)> |
100 void JSPropSetter(const char* prop_name_string, | 100 void JSPropSetter(const char* prop_name_string, |
101 const char* class_name_string, | 101 const char* class_name_string, |
102 v8::Local<v8::String> property, | 102 v8::Local<v8::String> property, |
103 v8::Local<v8::Value> value, | 103 v8::Local<v8::Value> value, |
104 const v8::PropertyCallbackInfo<void>& info) { | 104 const v8::PropertyCallbackInfo<void>& info) { |
105 v8::Isolate* isolate = info.GetIsolate(); | 105 v8::Isolate* isolate = info.GetIsolate(); |
106 IFXJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); | 106 IJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); |
107 if (!pRuntime) | 107 if (!pRuntime) |
108 return; | 108 return; |
109 IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); | 109 IJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); |
110 CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder()); | 110 CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder()); |
111 C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); | 111 C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); |
112 CFX_WideString sError; | 112 CFX_WideString sError; |
113 CJS_PropValue propValue(CJS_Value(isolate, value, CJS_Value::VT_unknown)); | 113 CJS_PropValue propValue(CJS_Value(isolate, value, CJS_Value::VT_unknown)); |
114 propValue.StartSetting(); | 114 propValue.StartSetting(); |
115 if (!(pObj->*M)(pRuntimeContext, propValue, sError)) { | 115 if (!(pObj->*M)(pRuntimeContext, propValue, sError)) { |
116 FXJS_Error(isolate, JSFormatErrorString(class_name_string, prop_name_string, | 116 FXJS_Error(isolate, JSFormatErrorString(class_name_string, prop_name_string, |
117 sError)); | 117 sError)); |
118 } | 118 } |
119 } | 119 } |
120 | 120 |
121 #define JS_STATIC_PROP(prop_name, class_name) \ | 121 #define JS_STATIC_PROP(prop_name, class_name) \ |
122 static void get_##prop_name##_static( \ | 122 static void get_##prop_name##_static( \ |
123 v8::Local<v8::String> property, \ | 123 v8::Local<v8::String> property, \ |
124 const v8::PropertyCallbackInfo<v8::Value>& info) { \ | 124 const v8::PropertyCallbackInfo<v8::Value>& info) { \ |
125 JSPropGetter<class_name, &class_name::prop_name>(#prop_name, #class_name, \ | 125 JSPropGetter<class_name, &class_name::prop_name>(#prop_name, #class_name, \ |
126 property, info); \ | 126 property, info); \ |
127 } \ | 127 } \ |
128 static void set_##prop_name##_static( \ | 128 static void set_##prop_name##_static( \ |
129 v8::Local<v8::String> property, v8::Local<v8::Value> value, \ | 129 v8::Local<v8::String> property, v8::Local<v8::Value> value, \ |
130 const v8::PropertyCallbackInfo<void>& info) { \ | 130 const v8::PropertyCallbackInfo<void>& info) { \ |
131 JSPropSetter<class_name, &class_name::prop_name>(#prop_name, #class_name, \ | 131 JSPropSetter<class_name, &class_name::prop_name>(#prop_name, #class_name, \ |
132 property, value, info); \ | 132 property, value, info); \ |
133 } | 133 } |
134 | 134 |
135 template <class C, | 135 template <class C, |
136 FX_BOOL (C::*M)(IFXJS_Context*, | 136 FX_BOOL (C::*M)(IJS_Context*, |
137 const CJS_Parameters&, | 137 const CJS_Parameters&, |
138 CJS_Value&, | 138 CJS_Value&, |
139 CFX_WideString&)> | 139 CFX_WideString&)> |
140 void JSMethod(const char* method_name_string, | 140 void JSMethod(const char* method_name_string, |
141 const char* class_name_string, | 141 const char* class_name_string, |
142 const v8::FunctionCallbackInfo<v8::Value>& info) { | 142 const v8::FunctionCallbackInfo<v8::Value>& info) { |
143 v8::Isolate* isolate = info.GetIsolate(); | 143 v8::Isolate* isolate = info.GetIsolate(); |
144 IFXJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); | 144 IJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); |
145 if (!pRuntime) | 145 if (!pRuntime) |
146 return; | 146 return; |
147 IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); | 147 IJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); |
148 CJS_Parameters parameters; | 148 CJS_Parameters parameters; |
149 for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) { | 149 for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) { |
150 parameters.push_back(CJS_Value(isolate, info[i], CJS_Value::VT_unknown)); | 150 parameters.push_back(CJS_Value(isolate, info[i], CJS_Value::VT_unknown)); |
151 } | 151 } |
152 CJS_Value valueRes(isolate); | 152 CJS_Value valueRes(isolate); |
153 CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder()); | 153 CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder()); |
154 C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); | 154 C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); |
155 CFX_WideString sError; | 155 CFX_WideString sError; |
156 if (!(pObj->*M)(pRuntimeContext, parameters, valueRes, sError)) { | 156 if (!(pObj->*M)(pRuntimeContext, parameters, valueRes, sError)) { |
157 FXJS_Error(isolate, JSFormatErrorString(class_name_string, | 157 FXJS_Error(isolate, JSFormatErrorString(class_name_string, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 IMPLEMENT_JS_CLASS_RICH_PART(js_class_name, class_alternate, class_name) \ | 235 IMPLEMENT_JS_CLASS_RICH_PART(js_class_name, class_alternate, class_name) \ |
236 void js_class_name::DefineJSObjects(v8::Isolate* pIsolate, \ | 236 void js_class_name::DefineJSObjects(v8::Isolate* pIsolate, \ |
237 FXJSOBJTYPE eObjType) { \ | 237 FXJSOBJTYPE eObjType) { \ |
238 g_nObjDefnID = FXJS_DefineObj(pIsolate, js_class_name::g_pClassName, \ | 238 g_nObjDefnID = FXJS_DefineObj(pIsolate, js_class_name::g_pClassName, \ |
239 eObjType, JSConstructor, JSDestructor); \ | 239 eObjType, JSConstructor, JSDestructor); \ |
240 DefineConsts(pIsolate); \ | 240 DefineConsts(pIsolate); \ |
241 DefineProps(pIsolate); \ | 241 DefineProps(pIsolate); \ |
242 DefineMethods(pIsolate); \ | 242 DefineMethods(pIsolate); \ |
243 } | 243 } |
244 | 244 |
245 #define DECLARE_JS_CLASS_RICH_PART() \ | 245 #define DECLARE_JS_CLASS_RICH_PART() \ |
246 static void JSConstructor(IFXJS_Context* cc, v8::Local<v8::Object> obj); \ | 246 static void JSConstructor(IJS_Context* cc, v8::Local<v8::Object> obj); \ |
247 static void JSDestructor(v8::Local<v8::Object> obj); \ | 247 static void JSDestructor(v8::Local<v8::Object> obj); \ |
248 static void DefineProps(v8::Isolate* pIsoalte); \ | 248 static void DefineProps(v8::Isolate* pIsoalte); \ |
249 static void DefineMethods(v8::Isolate* pIsoalte); \ | 249 static void DefineMethods(v8::Isolate* pIsoalte); \ |
250 static JSPropertySpec JS_Class_Properties[]; \ | 250 static JSPropertySpec JS_Class_Properties[]; \ |
251 static JSMethodSpec JS_Class_Methods[]; | 251 static JSMethodSpec JS_Class_Methods[]; |
252 | 252 |
253 #define IMPLEMENT_JS_CLASS_RICH_PART(js_class_name, class_alternate, \ | 253 #define IMPLEMENT_JS_CLASS_RICH_PART(js_class_name, class_alternate, \ |
254 class_name) \ | 254 class_name) \ |
255 void js_class_name::JSConstructor(IFXJS_Context* cc, \ | 255 void js_class_name::JSConstructor(IJS_Context* cc, \ |
256 v8::Local<v8::Object> obj) { \ | 256 v8::Local<v8::Object> obj) { \ |
257 CJS_Object* pObj = new js_class_name(obj); \ | 257 CJS_Object* pObj = new js_class_name(obj); \ |
258 pObj->SetEmbedObject(new class_alternate(pObj)); \ | 258 pObj->SetEmbedObject(new class_alternate(pObj)); \ |
259 FXJS_SetPrivate(nullptr, obj, (void*)pObj); \ | 259 FXJS_SetPrivate(nullptr, obj, (void*)pObj); \ |
260 pObj->InitInstance(cc); \ | 260 pObj->InitInstance(cc); \ |
261 } \ | 261 } \ |
262 void js_class_name::JSDestructor(v8::Local<v8::Object> obj) { \ | 262 void js_class_name::JSDestructor(v8::Local<v8::Object> obj) { \ |
263 js_class_name* pObj = (js_class_name*)FXJS_GetPrivate(nullptr, obj); \ | 263 js_class_name* pObj = (js_class_name*)FXJS_GetPrivate(nullptr, obj); \ |
264 pObj->ExitInstance(); \ | 264 pObj->ExitInstance(); \ |
265 delete pObj; \ | 265 delete pObj; \ |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject()); | 356 Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject()); |
357 FX_BOOL bRet = pObj->QueryProperty(propname.c_str()); | 357 FX_BOOL bRet = pObj->QueryProperty(propname.c_str()); |
358 info.GetReturnValue().Set(bRet ? 4 : 0); | 358 info.GetReturnValue().Set(bRet ? 4 : 0); |
359 } | 359 } |
360 | 360 |
361 template <class Alt> | 361 template <class Alt> |
362 void JSSpecialPropGet(const char* class_name, | 362 void JSSpecialPropGet(const char* class_name, |
363 v8::Local<v8::String> property, | 363 v8::Local<v8::String> property, |
364 const v8::PropertyCallbackInfo<v8::Value>& info) { | 364 const v8::PropertyCallbackInfo<v8::Value>& info) { |
365 v8::Isolate* isolate = info.GetIsolate(); | 365 v8::Isolate* isolate = info.GetIsolate(); |
366 IFXJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); | 366 IJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); |
367 if (!pRuntime) | 367 if (!pRuntime) |
368 return; | 368 return; |
369 IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); | 369 IJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); |
370 CJS_Object* pJSObj = | 370 CJS_Object* pJSObj = |
371 reinterpret_cast<CJS_Object*>(FXJS_GetPrivate(isolate, info.Holder())); | 371 reinterpret_cast<CJS_Object*>(FXJS_GetPrivate(isolate, info.Holder())); |
372 Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject()); | 372 Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject()); |
373 v8::String::Utf8Value utf8_value(property); | 373 v8::String::Utf8Value utf8_value(property); |
374 CFX_WideString propname = | 374 CFX_WideString propname = |
375 CFX_WideString::FromUTF8(*utf8_value, utf8_value.length()); | 375 CFX_WideString::FromUTF8(*utf8_value, utf8_value.length()); |
376 CFX_WideString sError; | 376 CFX_WideString sError; |
377 CJS_PropValue value(isolate); | 377 CJS_PropValue value(isolate); |
378 value.StartGetting(); | 378 value.StartGetting(); |
379 if (!pObj->DoProperty(pRuntimeContext, propname.c_str(), value, sError)) { | 379 if (!pObj->DoProperty(pRuntimeContext, propname.c_str(), value, sError)) { |
380 FXJS_Error(isolate, JSFormatErrorString(class_name, "GetProperty", sError)); | 380 FXJS_Error(isolate, JSFormatErrorString(class_name, "GetProperty", sError)); |
381 return; | 381 return; |
382 } | 382 } |
383 info.GetReturnValue().Set((v8::Local<v8::Value>)value); | 383 info.GetReturnValue().Set((v8::Local<v8::Value>)value); |
384 } | 384 } |
385 | 385 |
386 template <class Alt> | 386 template <class Alt> |
387 void JSSpecialPropPut(const char* class_name, | 387 void JSSpecialPropPut(const char* class_name, |
388 v8::Local<v8::String> property, | 388 v8::Local<v8::String> property, |
389 v8::Local<v8::Value> value, | 389 v8::Local<v8::Value> value, |
390 const v8::PropertyCallbackInfo<v8::Value>& info) { | 390 const v8::PropertyCallbackInfo<v8::Value>& info) { |
391 v8::Isolate* isolate = info.GetIsolate(); | 391 v8::Isolate* isolate = info.GetIsolate(); |
392 IFXJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); | 392 IJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); |
393 if (!pRuntime) | 393 if (!pRuntime) |
394 return; | 394 return; |
395 IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); | 395 IJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); |
396 CJS_Object* pJSObj = | 396 CJS_Object* pJSObj = |
397 reinterpret_cast<CJS_Object*>(FXJS_GetPrivate(isolate, info.Holder())); | 397 reinterpret_cast<CJS_Object*>(FXJS_GetPrivate(isolate, info.Holder())); |
398 Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject()); | 398 Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject()); |
399 v8::String::Utf8Value utf8_value(property); | 399 v8::String::Utf8Value utf8_value(property); |
400 CFX_WideString propname = | 400 CFX_WideString propname = |
401 CFX_WideString::FromUTF8(*utf8_value, utf8_value.length()); | 401 CFX_WideString::FromUTF8(*utf8_value, utf8_value.length()); |
402 CFX_WideString sError; | 402 CFX_WideString sError; |
403 CJS_PropValue PropValue(CJS_Value(isolate, value, CJS_Value::VT_unknown)); | 403 CJS_PropValue PropValue(CJS_Value(isolate, value, CJS_Value::VT_unknown)); |
404 PropValue.StartSetting(); | 404 PropValue.StartSetting(); |
405 if (!pObj->DoProperty(pRuntimeContext, propname.c_str(), PropValue, sError)) { | 405 if (!pObj->DoProperty(pRuntimeContext, propname.c_str(), PropValue, sError)) { |
406 FXJS_Error(isolate, JSFormatErrorString(class_name, "PutProperty", sError)); | 406 FXJS_Error(isolate, JSFormatErrorString(class_name, "PutProperty", sError)); |
407 } | 407 } |
408 } | 408 } |
409 | 409 |
410 template <class Alt> | 410 template <class Alt> |
411 void JSSpecialPropDel(const char* class_name, | 411 void JSSpecialPropDel(const char* class_name, |
412 v8::Local<v8::String> property, | 412 v8::Local<v8::String> property, |
413 const v8::PropertyCallbackInfo<v8::Boolean>& info) { | 413 const v8::PropertyCallbackInfo<v8::Boolean>& info) { |
414 v8::Isolate* isolate = info.GetIsolate(); | 414 v8::Isolate* isolate = info.GetIsolate(); |
415 IFXJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); | 415 IJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); |
416 if (!pRuntime) | 416 if (!pRuntime) |
417 return; | 417 return; |
418 IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); | 418 IJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); |
419 CJS_Object* pJSObj = | 419 CJS_Object* pJSObj = |
420 reinterpret_cast<CJS_Object*>(FXJS_GetPrivate(isolate, info.Holder())); | 420 reinterpret_cast<CJS_Object*>(FXJS_GetPrivate(isolate, info.Holder())); |
421 Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject()); | 421 Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject()); |
422 v8::String::Utf8Value utf8_value(property); | 422 v8::String::Utf8Value utf8_value(property); |
423 CFX_WideString propname = | 423 CFX_WideString propname = |
424 CFX_WideString::FromUTF8(*utf8_value, utf8_value.length()); | 424 CFX_WideString::FromUTF8(*utf8_value, utf8_value.length()); |
425 CFX_WideString sError; | 425 CFX_WideString sError; |
426 if (!pObj->DelProperty(pRuntimeContext, propname.c_str(), sError)) { | 426 if (!pObj->DelProperty(pRuntimeContext, propname.c_str(), sError)) { |
427 CFX_ByteString cbName; | 427 CFX_ByteString cbName; |
428 cbName.Format("%s.%s", class_name, "DelProperty"); | 428 cbName.Format("%s.%s", class_name, "DelProperty"); |
429 // Probably a missing call to JSFX_Error(). | 429 // Probably a missing call to JSFX_Error(). |
430 } | 430 } |
431 } | 431 } |
432 | 432 |
433 template <FX_BOOL (*F)(IFXJS_Context* cc, | 433 template <FX_BOOL (*F)(IJS_Context* cc, |
434 const CJS_Parameters& params, | 434 const CJS_Parameters& params, |
435 CJS_Value& vRet, | 435 CJS_Value& vRet, |
436 CFX_WideString& sError)> | 436 CFX_WideString& sError)> |
437 void JSGlobalFunc(const char* func_name_string, | 437 void JSGlobalFunc(const char* func_name_string, |
438 const v8::FunctionCallbackInfo<v8::Value>& info) { | 438 const v8::FunctionCallbackInfo<v8::Value>& info) { |
439 v8::Isolate* isolate = info.GetIsolate(); | 439 v8::Isolate* isolate = info.GetIsolate(); |
440 IFXJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); | 440 IJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); |
441 if (!pRuntime) | 441 if (!pRuntime) |
442 return; | 442 return; |
443 IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); | 443 IJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); |
444 CJS_Parameters parameters; | 444 CJS_Parameters parameters; |
445 for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) { | 445 for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) { |
446 parameters.push_back(CJS_Value(isolate, info[i], CJS_Value::VT_unknown)); | 446 parameters.push_back(CJS_Value(isolate, info[i], CJS_Value::VT_unknown)); |
447 } | 447 } |
448 CJS_Value valueRes(isolate); | 448 CJS_Value valueRes(isolate); |
449 CFX_WideString sError; | 449 CFX_WideString sError; |
450 if (!(*F)(pRuntimeContext, parameters, valueRes, sError)) { | 450 if (!(*F)(pRuntimeContext, parameters, valueRes, sError)) { |
451 FXJS_Error(isolate, JSFormatErrorString(func_name_string, nullptr, sError)); | 451 FXJS_Error(isolate, JSFormatErrorString(func_name_string, nullptr, sError)); |
452 return; | 452 return; |
453 } | 453 } |
(...skipping 22 matching lines...) Expand all Loading... |
476 for (size_t i = 0; i < FX_ArraySize(global_methods) - 1; ++i) { \ | 476 for (size_t i = 0; i < FX_ArraySize(global_methods) - 1; ++i) { \ |
477 FXJS_DefineGlobalMethod(pIsolate, \ | 477 FXJS_DefineGlobalMethod(pIsolate, \ |
478 js_class_name::global_methods[i].pName, \ | 478 js_class_name::global_methods[i].pName, \ |
479 js_class_name::global_methods[i].pMethodCall); \ | 479 js_class_name::global_methods[i].pMethodCall); \ |
480 } \ | 480 } \ |
481 } | 481 } |
482 | 482 |
483 CJS_Value::Type GET_VALUE_TYPE(v8::Local<v8::Value> p); | 483 CJS_Value::Type GET_VALUE_TYPE(v8::Local<v8::Value> p); |
484 | 484 |
485 #endif // FPDFSDK_SRC_JAVASCRIPT_JS_DEFINE_H_ | 485 #endif // FPDFSDK_SRC_JAVASCRIPT_JS_DEFINE_H_ |
OLD | NEW |