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_JAVASCRIPT_JS_DEFINE_H_ | 7 #ifndef FPDFSDK_JAVASCRIPT_JS_DEFINE_H_ |
8 #define FPDFSDK_JAVASCRIPT_JS_DEFINE_H_ | 8 #define FPDFSDK_JAVASCRIPT_JS_DEFINE_H_ |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 v8::Local<v8::Object> obj) { \ | 254 v8::Local<v8::Object> obj) { \ |
255 CJS_Object* pObj = new js_class_name(obj); \ | 255 CJS_Object* pObj = new js_class_name(obj); \ |
256 pObj->SetEmbedObject(new class_alternate(pObj)); \ | 256 pObj->SetEmbedObject(new class_alternate(pObj)); \ |
257 pEngine->SetObjectPrivate(obj, (void*)pObj); \ | 257 pEngine->SetObjectPrivate(obj, (void*)pObj); \ |
258 pObj->InitInstance(static_cast<CJS_Runtime*>(pEngine)); \ | 258 pObj->InitInstance(static_cast<CJS_Runtime*>(pEngine)); \ |
259 } \ | 259 } \ |
260 void js_class_name::JSDestructor(CFXJS_Engine* pEngine, \ | 260 void js_class_name::JSDestructor(CFXJS_Engine* pEngine, \ |
261 v8::Local<v8::Object> obj) { \ | 261 v8::Local<v8::Object> obj) { \ |
262 js_class_name* pObj = \ | 262 js_class_name* pObj = \ |
263 static_cast<js_class_name*>(pEngine->GetObjectPrivate(obj)); \ | 263 static_cast<js_class_name*>(pEngine->GetObjectPrivate(obj)); \ |
264 pObj->ExitInstance(); \ | |
265 delete pObj; \ | 264 delete pObj; \ |
266 } \ | 265 } \ |
267 void js_class_name::DefineProps(CFXJS_Engine* pEngine) { \ | 266 void js_class_name::DefineProps(CFXJS_Engine* pEngine) { \ |
268 for (size_t i = 0; i < FX_ArraySize(JS_Class_Properties) - 1; ++i) { \ | 267 for (size_t i = 0; i < FX_ArraySize(JS_Class_Properties) - 1; ++i) { \ |
269 pEngine->DefineObjProperty(g_nObjDefnID, JS_Class_Properties[i].pName, \ | 268 pEngine->DefineObjProperty(g_nObjDefnID, JS_Class_Properties[i].pName, \ |
270 JS_Class_Properties[i].pPropGet, \ | 269 JS_Class_Properties[i].pPropGet, \ |
271 JS_Class_Properties[i].pPropPut); \ | 270 JS_Class_Properties[i].pPropPut); \ |
272 } \ | 271 } \ |
273 } \ | 272 } \ |
274 void js_class_name::DefineMethods(CFXJS_Engine* pEngine) { \ | 273 void js_class_name::DefineMethods(CFXJS_Engine* pEngine) { \ |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 #define IMPLEMENT_JS_STATIC_GLOBAL_FUN(js_class_name) \ | 473 #define IMPLEMENT_JS_STATIC_GLOBAL_FUN(js_class_name) \ |
475 void js_class_name::DefineJSObjects(CFXJS_Engine* pEngine) { \ | 474 void js_class_name::DefineJSObjects(CFXJS_Engine* pEngine) { \ |
476 for (size_t i = 0; i < FX_ArraySize(global_methods) - 1; ++i) { \ | 475 for (size_t i = 0; i < FX_ArraySize(global_methods) - 1; ++i) { \ |
477 pEngine->DefineGlobalMethod( \ | 476 pEngine->DefineGlobalMethod( \ |
478 js_class_name::global_methods[i].pName, \ | 477 js_class_name::global_methods[i].pName, \ |
479 js_class_name::global_methods[i].pMethodCall); \ | 478 js_class_name::global_methods[i].pMethodCall); \ |
480 } \ | 479 } \ |
481 } | 480 } |
482 | 481 |
483 #endif // FPDFSDK_JAVASCRIPT_JS_DEFINE_H_ | 482 #endif // FPDFSDK_JAVASCRIPT_JS_DEFINE_H_ |
OLD | NEW |