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 _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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 parameters.push_back(CJS_Value(isolate, info[i], VT_unknown)); | 130 parameters.push_back(CJS_Value(isolate, info[i], VT_unknown)); |
131 } | 131 } |
132 CJS_Value valueRes(isolate); | 132 CJS_Value valueRes(isolate); |
133 CJS_Object* pJSObj = (CJS_Object *)JS_GetPrivate(isolate,info.Holder()); | 133 CJS_Object* pJSObj = (CJS_Object *)JS_GetPrivate(isolate,info.Holder()); |
134 C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); | 134 C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); |
135 CFX_WideString sError; | 135 CFX_WideString sError; |
136 if (!(pObj->*M)(cc, parameters, valueRes, sError)) { | 136 if (!(pObj->*M)(cc, parameters, valueRes, sError)) { |
137 JS_Error(isolate, JSFormatErrorString(class_name_string, method_name_strin
g, sError)); | 137 JS_Error(isolate, JSFormatErrorString(class_name_string, method_name_strin
g, sError)); |
138 return; | 138 return; |
139 } | 139 } |
140 info.GetReturnValue().Set(valueRes.ToJSValue()); | 140 info.GetReturnValue().Set(valueRes.ToV8Value()); |
141 } | 141 } |
142 | 142 |
143 #define JS_STATIC_METHOD(method_name, class_name) \ | 143 #define JS_STATIC_METHOD(method_name, class_name) \ |
144 static void method_name##_static( \ | 144 static void method_name##_static( \ |
145 const v8::FunctionCallbackInfo<v8::Value>& info) { \ | 145 const v8::FunctionCallbackInfo<v8::Value>& info) { \ |
146 JSMethod<class_name, &class_name::method_name>( \ | 146 JSMethod<class_name, &class_name::method_name>( \ |
147 #method_name, #class_name, info); \ | 147 #method_name, #class_name, info); \ |
148 } | 148 } |
149 | 149 |
150 #define JS_SPECIAL_STATIC_METHOD(method_name, class_alternate, class_name) \ | 150 #define JS_SPECIAL_STATIC_METHOD(method_name, class_alternate, class_name) \ |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 for (unsigned int i = 0; i<(unsigned int)info.Length(); i++) { | 397 for (unsigned int i = 0; i<(unsigned int)info.Length(); i++) { |
398 parameters.push_back(CJS_Value(isolate, info[i], VT_unknown)); | 398 parameters.push_back(CJS_Value(isolate, info[i], VT_unknown)); |
399 } | 399 } |
400 CJS_Value valueRes(isolate); | 400 CJS_Value valueRes(isolate); |
401 CFX_WideString sError; | 401 CFX_WideString sError; |
402 if (!(*F)(cc, parameters, valueRes, sError)) | 402 if (!(*F)(cc, parameters, valueRes, sError)) |
403 { | 403 { |
404 JS_Error(isolate, JSFormatErrorString(func_name_string, nullptr, sError)); | 404 JS_Error(isolate, JSFormatErrorString(func_name_string, nullptr, sError)); |
405 return; | 405 return; |
406 } | 406 } |
407 info.GetReturnValue().Set(valueRes.ToJSValue()); | 407 info.GetReturnValue().Set(valueRes.ToV8Value()); |
408 } | 408 } |
409 | 409 |
410 #define JS_STATIC_GLOBAL_FUN(fun_name) \ | 410 #define JS_STATIC_GLOBAL_FUN(fun_name) \ |
411 static void fun_name##_static(const v8::FunctionCallbackInfo<v8::Value>& info)
{ \ | 411 static void fun_name##_static(const v8::FunctionCallbackInfo<v8::Value>& info)
{ \ |
412 JSGlobalFunc<fun_name>(#fun_name, info); \ | 412 JSGlobalFunc<fun_name>(#fun_name, info); \ |
413 } | 413 } |
414 | 414 |
415 #define JS_STATIC_DECLARE_GLOBAL_FUN() \ | 415 #define JS_STATIC_DECLARE_GLOBAL_FUN() \ |
416 static JSMethodSpec global_methods[]; \ | 416 static JSMethodSpec global_methods[]; \ |
417 static int Init(IJS_Runtime* pRuntime) | 417 static int Init(IJS_Runtime* pRuntime) |
(...skipping 27 matching lines...) Expand all Loading... |
445 /* ======================================== GLOBAL ARRAYS ======================
====================== */ | 445 /* ======================================== GLOBAL ARRAYS ======================
====================== */ |
446 | 446 |
447 #define DEFINE_GLOBAL_ARRAY(pRuntime)\ | 447 #define DEFINE_GLOBAL_ARRAY(pRuntime)\ |
448 int size = FX_ArraySize(ArrayContent);\ | 448 int size = FX_ArraySize(ArrayContent);\ |
449 \ | 449 \ |
450 CJS_Array array(pRuntime);\ | 450 CJS_Array array(pRuntime);\ |
451 for (int i=0; i<size; i++) array.SetElement(i,CJS_Value(pRuntime,ArrayContent[i]
));\ | 451 for (int i=0; i<size; i++) array.SetElement(i,CJS_Value(pRuntime,ArrayContent[i]
));\ |
452 \ | 452 \ |
453 CJS_PropValue prop(pRuntime);\ | 453 CJS_PropValue prop(pRuntime);\ |
454 prop << array;\ | 454 prop << array;\ |
455 if (JS_DefineGlobalConst(pRuntime, (const wchar_t*)ArrayName, prop.ToJSValue())
< 0)\ | 455 if (JS_DefineGlobalConst(pRuntime, (const wchar_t*)ArrayName, prop.ToV8Value())
< 0)\ |
456 return -1 | 456 return -1 |
457 | 457 |
458 /* ============================================================ */ | 458 /* ============================================================ */ |
459 | 459 |
460 #define VALUE_NAME_STRING L"string" | 460 #define VALUE_NAME_STRING L"string" |
461 #define VALUE_NAME_NUMBER L"number" | 461 #define VALUE_NAME_NUMBER L"number" |
462 #define VALUE_NAME_BOOLEAN L"boolean" | 462 #define VALUE_NAME_BOOLEAN L"boolean" |
463 #define VALUE_NAME_DATE L"date" | 463 #define VALUE_NAME_DATE L"date" |
464 #define VALUE_NAME_OBJECT L"object" | 464 #define VALUE_NAME_OBJECT L"object" |
465 #define VALUE_NAME_FXOBJ L"fxobj" | 465 #define VALUE_NAME_FXOBJ L"fxobj" |
466 #define VALUE_NAME_NULL L"null" | 466 #define VALUE_NAME_NULL L"null" |
467 #define VALUE_NAME_UNDEFINED L"undefined" | 467 #define VALUE_NAME_UNDEFINED L"undefined" |
468 | 468 |
469 FXJSVALUETYPE GET_VALUE_TYPE(v8::Handle<v8::Value> p); | 469 FXJSVALUETYPE GET_VALUE_TYPE(v8::Handle<v8::Value> p); |
470 | 470 |
471 #endif //_JS_DEFINE_H_ | 471 #endif //_JS_DEFINE_H_ |
OLD | NEW |