| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 parameters.push_back(CJS_Value(isolate, info[i], VT_unknown)); | 121 parameters.push_back(CJS_Value(isolate, info[i], VT_unknown)); |
| 122 } | 122 } |
| 123 CJS_Value valueRes(isolate); | 123 CJS_Value valueRes(isolate); |
| 124 CJS_Object* pJSObj = (CJS_Object *)JS_GetPrivate(isolate,info.Holder()); | 124 CJS_Object* pJSObj = (CJS_Object *)JS_GetPrivate(isolate,info.Holder()); |
| 125 C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); | 125 C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); |
| 126 CFX_WideString sError; | 126 CFX_WideString sError; |
| 127 if (!(pObj->*M)(pRuntimeContext, parameters, valueRes, sError)) { | 127 if (!(pObj->*M)(pRuntimeContext, parameters, valueRes, sError)) { |
| 128 JS_Error(isolate, JSFormatErrorString(class_name_string, method_name_string,
sError)); | 128 JS_Error(isolate, JSFormatErrorString(class_name_string, method_name_string,
sError)); |
| 129 return; | 129 return; |
| 130 } | 130 } |
| 131 info.GetReturnValue().Set(valueRes.ToJSValue()); | 131 info.GetReturnValue().Set(valueRes.ToV8Value()); |
| 132 } | 132 } |
| 133 | 133 |
| 134 #define JS_STATIC_METHOD(method_name, class_name) \ | 134 #define JS_STATIC_METHOD(method_name, class_name) \ |
| 135 static void method_name##_static( \ | 135 static void method_name##_static( \ |
| 136 const v8::FunctionCallbackInfo<v8::Value>& info) { \ | 136 const v8::FunctionCallbackInfo<v8::Value>& info) { \ |
| 137 JSMethod<class_name, &class_name::method_name>( \ | 137 JSMethod<class_name, &class_name::method_name>( \ |
| 138 #method_name, #class_name, info); \ | 138 #method_name, #class_name, info); \ |
| 139 } | 139 } |
| 140 | 140 |
| 141 #define JS_SPECIAL_STATIC_METHOD(method_name, class_alternate, class_name) \ | 141 #define JS_SPECIAL_STATIC_METHOD(method_name, class_alternate, class_name) \ |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 CJS_Parameters parameters; | 378 CJS_Parameters parameters; |
| 379 for (unsigned int i = 0; i<(unsigned int)info.Length(); i++) { | 379 for (unsigned int i = 0; i<(unsigned int)info.Length(); i++) { |
| 380 parameters.push_back(CJS_Value(isolate, info[i], VT_unknown)); | 380 parameters.push_back(CJS_Value(isolate, info[i], VT_unknown)); |
| 381 } | 381 } |
| 382 CJS_Value valueRes(isolate); | 382 CJS_Value valueRes(isolate); |
| 383 CFX_WideString sError; | 383 CFX_WideString sError; |
| 384 if (!(*F)(pRuntimeContext, parameters, valueRes, sError)) { | 384 if (!(*F)(pRuntimeContext, parameters, valueRes, sError)) { |
| 385 JS_Error(isolate, JSFormatErrorString(func_name_string, nullptr, sError)); | 385 JS_Error(isolate, JSFormatErrorString(func_name_string, nullptr, sError)); |
| 386 return; | 386 return; |
| 387 } | 387 } |
| 388 info.GetReturnValue().Set(valueRes.ToJSValue()); | 388 info.GetReturnValue().Set(valueRes.ToV8Value()); |
| 389 } | 389 } |
| 390 | 390 |
| 391 #define JS_STATIC_GLOBAL_FUN(fun_name) \ | 391 #define JS_STATIC_GLOBAL_FUN(fun_name) \ |
| 392 static void fun_name##_static(const v8::FunctionCallbackInfo<v8::Value>& info)
{ \ | 392 static void fun_name##_static(const v8::FunctionCallbackInfo<v8::Value>& info)
{ \ |
| 393 JSGlobalFunc<fun_name>(#fun_name, info); \ | 393 JSGlobalFunc<fun_name>(#fun_name, info); \ |
| 394 } | 394 } |
| 395 | 395 |
| 396 #define JS_STATIC_DECLARE_GLOBAL_FUN() \ | 396 #define JS_STATIC_DECLARE_GLOBAL_FUN() \ |
| 397 static JSMethodSpec global_methods[]; \ | 397 static JSMethodSpec global_methods[]; \ |
| 398 static int Init(IJS_Runtime* pRuntime) | 398 static int Init(IJS_Runtime* pRuntime) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 426 /* ======================================== GLOBAL ARRAYS ======================
====================== */ | 426 /* ======================================== GLOBAL ARRAYS ======================
====================== */ |
| 427 | 427 |
| 428 #define DEFINE_GLOBAL_ARRAY(pRuntime)\ | 428 #define DEFINE_GLOBAL_ARRAY(pRuntime)\ |
| 429 int size = FX_ArraySize(ArrayContent);\ | 429 int size = FX_ArraySize(ArrayContent);\ |
| 430 \ | 430 \ |
| 431 CJS_Array array(pRuntime);\ | 431 CJS_Array array(pRuntime);\ |
| 432 for (int i=0; i<size; i++) array.SetElement(i,CJS_Value(pRuntime,ArrayContent[i]
));\ | 432 for (int i=0; i<size; i++) array.SetElement(i,CJS_Value(pRuntime,ArrayContent[i]
));\ |
| 433 \ | 433 \ |
| 434 CJS_PropValue prop(pRuntime);\ | 434 CJS_PropValue prop(pRuntime);\ |
| 435 prop << array;\ | 435 prop << array;\ |
| 436 if (JS_DefineGlobalConst(pRuntime, (const wchar_t*)ArrayName, prop.ToJSValue())
< 0)\ | 436 if (JS_DefineGlobalConst(pRuntime, (const wchar_t*)ArrayName, prop.ToV8Value())
< 0)\ |
| 437 return -1 | 437 return -1 |
| 438 | 438 |
| 439 /* ============================================================ */ | 439 /* ============================================================ */ |
| 440 | 440 |
| 441 #define VALUE_NAME_STRING L"string" | 441 #define VALUE_NAME_STRING L"string" |
| 442 #define VALUE_NAME_NUMBER L"number" | 442 #define VALUE_NAME_NUMBER L"number" |
| 443 #define VALUE_NAME_BOOLEAN L"boolean" | 443 #define VALUE_NAME_BOOLEAN L"boolean" |
| 444 #define VALUE_NAME_DATE L"date" | 444 #define VALUE_NAME_DATE L"date" |
| 445 #define VALUE_NAME_OBJECT L"object" | 445 #define VALUE_NAME_OBJECT L"object" |
| 446 #define VALUE_NAME_FXOBJ L"fxobj" | 446 #define VALUE_NAME_FXOBJ L"fxobj" |
| 447 #define VALUE_NAME_NULL L"null" | 447 #define VALUE_NAME_NULL L"null" |
| 448 #define VALUE_NAME_UNDEFINED L"undefined" | 448 #define VALUE_NAME_UNDEFINED L"undefined" |
| 449 | 449 |
| 450 FXJSVALUETYPE GET_VALUE_TYPE(v8::Handle<v8::Value> p); | 450 FXJSVALUETYPE GET_VALUE_TYPE(v8::Handle<v8::Value> p); |
| 451 | 451 |
| 452 #endif //_JS_DEFINE_H_ | 452 #endif //_JS_DEFINE_H_ |
| OLD | NEW |