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 _JS_DEFINE_H_ | 7 #ifndef _JS_DEFINE_H_ |
8 #define _JS_DEFINE_H_ | 8 #define _JS_DEFINE_H_ |
9 | 9 |
10 #include "../jsapi/fxjs_v8.h" | 10 #include "../jsapi/fxjs_v8.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 static int Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType);\ | 162 static int Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType);\ |
163 static JSConstSpec JS_Class_Consts[];\ | 163 static JSConstSpec JS_Class_Consts[];\ |
164 static JSPropertySpec JS_Class_Properties[];\ | 164 static JSPropertySpec JS_Class_Properties[];\ |
165 static JSMethodSpec JS_Class_Methods[];\ | 165 static JSMethodSpec JS_Class_Methods[];\ |
166 static const wchar_t* m_pClassName | 166 static const wchar_t* m_pClassName |
167 | 167 |
168 #define IMPLEMENT_JS_CLASS_RICH(js_class_name, class_alternate, class_name) \ | 168 #define IMPLEMENT_JS_CLASS_RICH(js_class_name, class_alternate, class_name) \ |
169 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name);\ | 169 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name);\ |
170 void js_class_name::JSConstructor(IFXJS_Context* cc, JSFXObject obj, JSFXObject
global)\ | 170 void js_class_name::JSConstructor(IFXJS_Context* cc, JSFXObject obj, JSFXObject
global)\ |
171 {\ | 171 {\ |
172 » CJS_Object* pObj = FX_NEW js_class_name(obj);\ | 172 » CJS_Object* pObj = new js_class_name(obj);\ |
173 » pObj->SetEmbedObject(FX_NEW class_alternate(pObj));\ | 173 » pObj->SetEmbedObject(new class_alternate(pObj));\ |
174 JS_SetPrivate(NULL,obj,(void*)pObj); \ | 174 JS_SetPrivate(NULL,obj,(void*)pObj); \ |
175 pObj->InitInstance(cc);\ | 175 pObj->InitInstance(cc);\ |
176 }\ | 176 }\ |
177 \ | 177 \ |
178 void js_class_name::JSDestructor(JSFXObject obj) \ | 178 void js_class_name::JSDestructor(JSFXObject obj) \ |
179 {\ | 179 {\ |
180 js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL,obj);\ | 180 js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL,obj);\ |
181 ASSERT(pObj != NULL);\ | 181 ASSERT(pObj != NULL);\ |
182 pObj->ExitInstance();\ | 182 pObj->ExitInstance();\ |
183 delete pObj;\ | 183 delete pObj;\ |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 JSSpecialPropGet<class_alternate>(#class_name, property, info); \ | 337 JSSpecialPropGet<class_alternate>(#class_name, property, info); \ |
338 } \ | 338 } \ |
339 void js_class_name::putprop_##js_class_name##_static(v8::Local<v8::String> prope
rty,v8::Local<v8::Value> value,const v8::PropertyCallbackInfo<v8::Value>& info)
{\ | 339 void js_class_name::putprop_##js_class_name##_static(v8::Local<v8::String> prope
rty,v8::Local<v8::Value> value,const v8::PropertyCallbackInfo<v8::Value>& info)
{\ |
340 JSSpecialPropPut<class_alternate>(#class_name, property, value, info); \ | 340 JSSpecialPropPut<class_alternate>(#class_name, property, value, info); \ |
341 }\ | 341 }\ |
342 void js_class_name::delprop_##js_class_name##_static(v8::Local<v8::String> prope
rty,const v8::PropertyCallbackInfo<v8::Boolean>& info) { \ | 342 void js_class_name::delprop_##js_class_name##_static(v8::Local<v8::String> prope
rty,const v8::PropertyCallbackInfo<v8::Boolean>& info) { \ |
343 JSSpecialPropDel<class_alternate>(#class_name, property, info); \ | 343 JSSpecialPropDel<class_alternate>(#class_name, property, info); \ |
344 } \ | 344 } \ |
345 void js_class_name::JSConstructor(IFXJS_Context* cc, JSFXObject obj,JSFXObject
global)\ | 345 void js_class_name::JSConstructor(IFXJS_Context* cc, JSFXObject obj,JSFXObject
global)\ |
346 {\ | 346 {\ |
347 » CJS_Object* pObj = FX_NEW js_class_name(obj);\ | 347 » CJS_Object* pObj = new js_class_name(obj);\ |
348 » pObj->SetEmbedObject(FX_NEW class_alternate(pObj));\ | 348 » pObj->SetEmbedObject(new class_alternate(pObj));\ |
349 JS_SetPrivate(NULL,obj, (void*)pObj); \ | 349 JS_SetPrivate(NULL,obj, (void*)pObj); \ |
350 pObj->InitInstance(cc);\ | 350 pObj->InitInstance(cc);\ |
351 }\ | 351 }\ |
352 \ | 352 \ |
353 void js_class_name::JSDestructor(JSFXObject obj) \ | 353 void js_class_name::JSDestructor(JSFXObject obj) \ |
354 {\ | 354 {\ |
355 js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL,obj);\ | 355 js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL,obj);\ |
356 ASSERT(pObj != NULL);\ | 356 ASSERT(pObj != NULL);\ |
357 pObj->ExitInstance();\ | 357 pObj->ExitInstance();\ |
358 delete pObj;\ | 358 delete pObj;\ |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 #define VALUE_NAME_BOOLEAN L"boolean" | 462 #define VALUE_NAME_BOOLEAN L"boolean" |
463 #define VALUE_NAME_DATE L"date" | 463 #define VALUE_NAME_DATE L"date" |
464 #define VALUE_NAME_OBJECT L"object" | 464 #define VALUE_NAME_OBJECT L"object" |
465 #define VALUE_NAME_FXOBJ L"fxobj" | 465 #define VALUE_NAME_FXOBJ L"fxobj" |
466 #define VALUE_NAME_NULL L"null" | 466 #define VALUE_NAME_NULL L"null" |
467 #define VALUE_NAME_UNDEFINED L"undefined" | 467 #define VALUE_NAME_UNDEFINED L"undefined" |
468 | 468 |
469 FXJSVALUETYPE GET_VALUE_TYPE(v8::Handle<v8::Value> p); | 469 FXJSVALUETYPE GET_VALUE_TYPE(v8::Handle<v8::Value> p); |
470 | 470 |
471 #endif //_JS_DEFINE_H_ | 471 #endif //_JS_DEFINE_H_ |
OLD | NEW |