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