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_INCLUDE_JAVASCRIPT_JS_DEFINE_H_ | 7 #ifndef FPDFSDK_INCLUDE_JAVASCRIPT_JS_DEFINE_H_ |
8 #define FPDFSDK_INCLUDE_JAVASCRIPT_JS_DEFINE_H_ | 8 #define FPDFSDK_INCLUDE_JAVASCRIPT_JS_DEFINE_H_ |
9 | 9 |
10 #include "../jsapi/fxjs_v8.h" | 10 #include "../jsapi/fxjs_v8.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 v8::FunctionCallback pMethodCall; | 30 v8::FunctionCallback pMethodCall; |
31 }; | 31 }; |
32 | 32 |
33 /* ====================================== PUBLIC DEFINE SPEC | 33 /* ====================================== PUBLIC DEFINE SPEC |
34 * ============================================== */ | 34 * ============================================== */ |
35 #define JS_WIDESTRING(widestring) L## #widestring | 35 #define JS_WIDESTRING(widestring) L## #widestring |
36 | 36 |
37 #define BEGIN_JS_STATIC_CONST(js_class_name) \ | 37 #define BEGIN_JS_STATIC_CONST(js_class_name) \ |
38 JSConstSpec js_class_name::JS_Class_Consts[] = { | 38 JSConstSpec js_class_name::JS_Class_Consts[] = { |
39 #define JS_STATIC_CONST_ENTRY_NUMBER(const_name, pValue) \ | 39 #define JS_STATIC_CONST_ENTRY_NUMBER(const_name, pValue) \ |
40 { const_name, pValue, L"", 0 } \ | 40 { const_name, pValue, L"", 0 } \ |
41 , | 41 , |
42 #define JS_STATIC_CONST_ENTRY_STRING(const_name, pValue) \ | 42 #define JS_STATIC_CONST_ENTRY_STRING(const_name, pValue) \ |
43 { const_name, 0, pValue, 1 } \ | 43 { const_name, 0, pValue, 1 } \ |
44 , | 44 , |
45 #define END_JS_STATIC_CONST() \ | 45 #define END_JS_STATIC_CONST() \ |
46 { 0, 0, 0, 0 } \ | 46 { 0, 0, 0, 0 } \ |
47 } \ | 47 } \ |
48 ; | 48 ; |
49 | 49 |
50 #define BEGIN_JS_STATIC_PROP(js_class_name) \ | 50 #define BEGIN_JS_STATIC_PROP(js_class_name) \ |
51 JSPropertySpec js_class_name::JS_Class_Properties[] = { | 51 JSPropertySpec js_class_name::JS_Class_Properties[] = { |
52 #define JS_STATIC_PROP_ENTRY(prop_name)
\ | 52 #define JS_STATIC_PROP_ENTRY(prop_name)
\ |
53 {
\ | 53 {
\ |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 static int Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType); \ | 183 static int Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType); \ |
184 static JSConstSpec JS_Class_Consts[]; \ | 184 static JSConstSpec JS_Class_Consts[]; \ |
185 static JSPropertySpec JS_Class_Properties[]; \ | 185 static JSPropertySpec JS_Class_Properties[]; \ |
186 static JSMethodSpec JS_Class_Methods[]; \ | 186 static JSMethodSpec JS_Class_Methods[]; \ |
187 static const wchar_t* m_pClassName | 187 static const wchar_t* m_pClassName |
188 | 188 |
189 #define IMPLEMENT_JS_CLASS_RICH(js_class_name, class_alternate, class_name) \ | 189 #define IMPLEMENT_JS_CLASS_RICH(js_class_name, class_alternate, class_name) \ |
190 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name); \ | 190 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name); \ |
191 void js_class_name::JSConstructor(IFXJS_Context* cc, JSFXObject obj, \ | 191 void js_class_name::JSConstructor(IFXJS_Context* cc, JSFXObject obj, \ |
192 JSFXObject global) { \ | 192 JSFXObject global) { \ |
193 CJS_Object* pObj = new js_class_name(obj); \ | 193 CJS_Object* pObj = new js_class_name(obj); \ |
194 pObj->SetEmbedObject(new class_alternate(pObj)); \ | 194 pObj->SetEmbedObject(new class_alternate(pObj)); \ |
195 JS_SetPrivate(NULL, obj, (void*)pObj); \ | 195 JS_SetPrivate(NULL, obj, (void*)pObj); \ |
196 pObj->InitInstance(cc); \ | 196 pObj->InitInstance(cc); \ |
197 } \ | 197 } \ |
198 \ | 198 \ |
199 void js_class_name::JSDestructor(JSFXObject obj) { \ | 199 void js_class_name::JSDestructor(JSFXObject obj) { \ |
200 js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL, obj); \ | 200 js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL, obj); \ |
201 ASSERT(pObj != NULL); \ | 201 ASSERT(pObj != NULL); \ |
202 pObj->ExitInstance(); \ | 202 pObj->ExitInstance(); \ |
203 delete pObj; \ | 203 delete pObj; \ |
204 } \ | 204 } \ |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 const v8::PropertyCallbackInfo<v8::Value>& info) { \ | 391 const v8::PropertyCallbackInfo<v8::Value>& info) { \ |
392 JSSpecialPropPut<class_alternate>(#class_name, property, value, info); \ | 392 JSSpecialPropPut<class_alternate>(#class_name, property, value, info); \ |
393 } \ | 393 } \ |
394 void js_class_name::delprop_##js_class_name##_static( \ | 394 void js_class_name::delprop_##js_class_name##_static( \ |
395 v8::Local<v8::String> property, \ | 395 v8::Local<v8::String> property, \ |
396 const v8::PropertyCallbackInfo<v8::Boolean>& info) { \ | 396 const v8::PropertyCallbackInfo<v8::Boolean>& info) { \ |
397 JSSpecialPropDel<class_alternate>(#class_name, property, info); \ | 397 JSSpecialPropDel<class_alternate>(#class_name, property, info); \ |
398 } \ | 398 } \ |
399 void js_class_name::JSConstructor(IFXJS_Context* cc, JSFXObject obj, \ | 399 void js_class_name::JSConstructor(IFXJS_Context* cc, JSFXObject obj, \ |
400 JSFXObject global) { \ | 400 JSFXObject global) { \ |
401 CJS_Object* pObj = new js_class_name(obj); \ | 401 CJS_Object* pObj = new js_class_name(obj); \ |
402 pObj->SetEmbedObject(new class_alternate(pObj)); \ | 402 pObj->SetEmbedObject(new class_alternate(pObj)); \ |
403 JS_SetPrivate(NULL, obj, (void*)pObj); \ | 403 JS_SetPrivate(NULL, obj, (void*)pObj); \ |
404 pObj->InitInstance(cc); \ | 404 pObj->InitInstance(cc); \ |
405 } \ | 405 } \ |
406 \ | 406 \ |
407 void js_class_name::JSDestructor(JSFXObject obj) { \ | 407 void js_class_name::JSDestructor(JSFXObject obj) { \ |
408 js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL, obj); \ | 408 js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL, obj); \ |
409 ASSERT(pObj != NULL); \ | 409 ASSERT(pObj != NULL); \ |
410 pObj->ExitInstance(); \ | 410 pObj->ExitInstance(); \ |
411 delete pObj; \ | 411 delete pObj; \ |
412 } \ | 412 } \ |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 #define VALUE_NAME_BOOLEAN L"boolean" | 533 #define VALUE_NAME_BOOLEAN L"boolean" |
534 #define VALUE_NAME_DATE L"date" | 534 #define VALUE_NAME_DATE L"date" |
535 #define VALUE_NAME_OBJECT L"object" | 535 #define VALUE_NAME_OBJECT L"object" |
536 #define VALUE_NAME_FXOBJ L"fxobj" | 536 #define VALUE_NAME_FXOBJ L"fxobj" |
537 #define VALUE_NAME_NULL L"null" | 537 #define VALUE_NAME_NULL L"null" |
538 #define VALUE_NAME_UNDEFINED L"undefined" | 538 #define VALUE_NAME_UNDEFINED L"undefined" |
539 | 539 |
540 FXJSVALUETYPE GET_VALUE_TYPE(v8::Local<v8::Value> p); | 540 FXJSVALUETYPE GET_VALUE_TYPE(v8::Local<v8::Value> p); |
541 | 541 |
542 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_DEFINE_H_ | 542 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_DEFINE_H_ |
OLD | NEW |