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