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