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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 IMPLEMENT_JS_CLASS_RICH_PART(js_class_name, class_alternate, class_name) \ | 238 IMPLEMENT_JS_CLASS_RICH_PART(js_class_name, class_alternate, class_name) \ |
239 void js_class_name::DefineJSObjects(v8::Isolate* pIsolate, \ | 239 void js_class_name::DefineJSObjects(v8::Isolate* pIsolate, \ |
240 FXJSOBJTYPE eObjType) { \ | 240 FXJSOBJTYPE eObjType) { \ |
241 g_nObjDefnID = FXJS_DefineObj(pIsolate, js_class_name::g_pClassName, \ | 241 g_nObjDefnID = FXJS_DefineObj(pIsolate, js_class_name::g_pClassName, \ |
242 eObjType, JSConstructor, JSDestructor); \ | 242 eObjType, JSConstructor, JSDestructor); \ |
243 DefineConsts(pIsolate); \ | 243 DefineConsts(pIsolate); \ |
244 DefineProps(pIsolate); \ | 244 DefineProps(pIsolate); \ |
245 DefineMethods(pIsolate); \ | 245 DefineMethods(pIsolate); \ |
246 } | 246 } |
247 | 247 |
248 #define DECLARE_JS_CLASS_RICH_PART() \ | 248 #define DECLARE_JS_CLASS_RICH_PART() \ |
249 static void JSConstructor(IJS_Context* cc, v8::Local<v8::Object> obj); \ | 249 static void JSConstructor(IJS_Runtime* pRuntime, v8::Local<v8::Object> obj); \ |
250 static void JSDestructor(v8::Local<v8::Object> obj); \ | 250 static void JSDestructor(v8::Local<v8::Object> obj); \ |
251 static void DefineProps(v8::Isolate* pIsoalte); \ | 251 static void DefineProps(v8::Isolate* pIsoalte); \ |
252 static void DefineMethods(v8::Isolate* pIsoalte); \ | 252 static void DefineMethods(v8::Isolate* pIsoalte); \ |
253 static JSPropertySpec JS_Class_Properties[]; \ | 253 static JSPropertySpec JS_Class_Properties[]; \ |
254 static JSMethodSpec JS_Class_Methods[]; | 254 static JSMethodSpec JS_Class_Methods[]; |
255 | 255 |
256 #define IMPLEMENT_JS_CLASS_RICH_PART(js_class_name, class_alternate, \ | 256 #define IMPLEMENT_JS_CLASS_RICH_PART(js_class_name, class_alternate, \ |
257 class_name) \ | 257 class_name) \ |
258 void js_class_name::JSConstructor(IJS_Context* cc, \ | 258 void js_class_name::JSConstructor(IJS_Runtime* pIRuntime, \ |
259 v8::Local<v8::Object> obj) { \ | 259 v8::Local<v8::Object> obj) { \ |
260 CJS_Object* pObj = new js_class_name(obj); \ | 260 CJS_Object* pObj = new js_class_name(obj); \ |
261 pObj->SetEmbedObject(new class_alternate(pObj)); \ | 261 pObj->SetEmbedObject(new class_alternate(pObj)); \ |
262 FXJS_SetPrivate(nullptr, obj, (void*)pObj); \ | 262 FXJS_SetPrivate(nullptr, obj, (void*)pObj); \ |
263 pObj->InitInstance(cc); \ | 263 pObj->InitInstance(pIRuntime); \ |
264 } \ | 264 } \ |
265 void js_class_name::JSDestructor(v8::Local<v8::Object> obj) { \ | 265 void js_class_name::JSDestructor(v8::Local<v8::Object> obj) { \ |
266 js_class_name* pObj = (js_class_name*)FXJS_GetPrivate(nullptr, obj); \ | 266 js_class_name* pObj = (js_class_name*)FXJS_GetPrivate(nullptr, obj); \ |
267 pObj->ExitInstance(); \ | 267 pObj->ExitInstance(); \ |
268 delete pObj; \ | 268 delete pObj; \ |
269 } \ | 269 } \ |
270 void js_class_name::DefineProps(v8::Isolate* pIsolate) { \ | 270 void js_class_name::DefineProps(v8::Isolate* pIsolate) { \ |
271 for (size_t i = 0; i < FX_ArraySize(JS_Class_Properties) - 1; ++i) { \ | 271 for (size_t i = 0; i < FX_ArraySize(JS_Class_Properties) - 1; ++i) { \ |
272 FXJS_DefineObjProperty( \ | 272 FXJS_DefineObjProperty( \ |
273 pIsolate, g_nObjDefnID, JS_Class_Properties[i].pName, \ | 273 pIsolate, g_nObjDefnID, JS_Class_Properties[i].pName, \ |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 for (size_t i = 0; i < FX_ArraySize(global_methods) - 1; ++i) { \ | 482 for (size_t i = 0; i < FX_ArraySize(global_methods) - 1; ++i) { \ |
483 FXJS_DefineGlobalMethod(pIsolate, \ | 483 FXJS_DefineGlobalMethod(pIsolate, \ |
484 js_class_name::global_methods[i].pName, \ | 484 js_class_name::global_methods[i].pName, \ |
485 js_class_name::global_methods[i].pMethodCall); \ | 485 js_class_name::global_methods[i].pMethodCall); \ |
486 } \ | 486 } \ |
487 } | 487 } |
488 | 488 |
489 CJS_Value::Type GET_VALUE_TYPE(v8::Local<v8::Value> p); | 489 CJS_Value::Type GET_VALUE_TYPE(v8::Local<v8::Value> p); |
490 | 490 |
491 #endif // FPDFSDK_SRC_JAVASCRIPT_JS_DEFINE_H_ | 491 #endif // FPDFSDK_SRC_JAVASCRIPT_JS_DEFINE_H_ |
OLD | NEW |