Chromium Code Reviews| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 info); \ | 176 info); \ |
| 177 } | 177 } |
| 178 | 178 |
| 179 #define JS_SPECIAL_STATIC_METHOD(method_name, class_alternate, class_name) \ | 179 #define JS_SPECIAL_STATIC_METHOD(method_name, class_alternate, class_name) \ |
| 180 static void method_name##_static( \ | 180 static void method_name##_static( \ |
| 181 const v8::FunctionCallbackInfo<v8::Value>& info) { \ | 181 const v8::FunctionCallbackInfo<v8::Value>& info) { \ |
| 182 JSMethod<class_alternate, &class_alternate::method_name>( \ | 182 JSMethod<class_alternate, &class_alternate::method_name>( \ |
| 183 #method_name, #class_name, info); \ | 183 #method_name, #class_name, info); \ |
| 184 } | 184 } |
| 185 | 185 |
| 186 /* ===================================== JS CLASS | 186 /* ========================================= JS_CLASS |
| 187 * =============================================== */ | 187 * =========================================== */ |
| 188 | 188 |
| 189 #define DECLARE_JS_CLASS(js_class_name) \ | 189 // All JS classes have a name, an object defintion ID, and the ability to |
| 190 static void JSConstructor(IFXJS_Context* cc, v8::Local<v8::Object> obj, \ | 190 // register themselves with FXJS_V8. We never make a BASE class on its own |
| 191 v8::Local<v8::Object> global); \ | 191 // because it can't really do anything. |
| 192 static void JSDestructor(v8::Local<v8::Object> obj); \ | 192 #define DECLARE_JS_CLASS_BASE_PART() \ |
| 193 static void DefineJSObjects(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType); \ | 193 static const wchar_t* g_pClassName; \ |
| 194 static JSConstSpec JS_Class_Consts[]; \ | 194 static int g_nObjDefnID; \ |
|
Tom Sepez
2015/10/02 22:58:11
note: we make this array for regular classes, not
| |
| 195 static JSPropertySpec JS_Class_Properties[]; \ | 195 static void DefineJSObjects(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType); |
| 196 static JSMethodSpec JS_Class_Methods[]; \ | |
| 197 static const wchar_t* m_pClassName | |
| 198 | 196 |
| 199 #define IMPLEMENT_JS_CLASS_RICH(js_class_name, class_alternate, class_name) \ | 197 #define IMPLEMENT_JS_CLASS_BASE_PART(js_class_name, class_name) \ |
| 200 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name); \ | 198 const wchar_t* js_class_name::g_pClassName = JS_WIDESTRING(class_name); \ |
| 201 void js_class_name::JSConstructor(IFXJS_Context* cc, \ | 199 int js_class_name::g_nObjDefnID = -1; |
| 202 v8::Local<v8::Object> obj, \ | 200 |
| 203 v8::Local<v8::Object> global) { \ | 201 // CONST classes provide constants, but not constructors, methods, or props. |
| 204 CJS_Object* pObj = new js_class_name(obj); \ | 202 #define DECLARE_JS_CLASS_CONST() \ |
| 205 pObj->SetEmbedObject(new class_alternate(pObj)); \ | 203 DECLARE_JS_CLASS_BASE_PART() \ |
| 206 FXJS_SetPrivate(NULL, obj, (void*)pObj); \ | 204 DECLARE_JS_CLASS_CONST_PART() |
| 207 pObj->InitInstance(cc); \ | 205 |
| 208 } \ | 206 #define DECLARE_JS_CLASS_CONST_PART() \ |
| 209 \ | 207 static JSConstSpec JS_Class_Consts[]; \ |
| 210 void js_class_name::JSDestructor(v8::Local<v8::Object> obj) { \ | 208 static void DefineConsts(v8::Isolate* pIsolate); |
| 211 js_class_name* pObj = (js_class_name*)FXJS_GetPrivate(NULL, obj); \ | 209 |
| 212 pObj->ExitInstance(); \ | 210 #define IMPLEMENT_JS_CLASS_CONST(js_class_name, class_name) \ |
| 213 delete pObj; \ | 211 IMPLEMENT_JS_CLASS_BASE_PART(js_class_name, class_name) \ |
| 214 } \ | 212 IMPLEMENT_JS_CLASS_CONST_PART(js_class_name, class_name) \ |
| 215 \ | 213 void js_class_name::DefineJSObjects(v8::Isolate* pIsolate, \ |
| 216 void js_class_name::DefineJSObjects(v8::Isolate* pIsolate, \ | 214 FXJSOBJTYPE eObjType) { \ |
| 217 FXJSOBJTYPE eObjType) { \ | 215 g_nObjDefnID = FXJS_DefineObj(pIsolate, js_class_name::g_pClassName, \ |
| 218 int nObjDefnID = FXJS_DefineObj(pIsolate, js_class_name::m_pClassName, \ | 216 eObjType, NULL, NULL); \ |
| 219 eObjType, JSConstructor, JSDestructor); \ | 217 DefineConsts(pIsolate); \ |
| 220 for (int i = 0; i < FX_ArraySize(JS_Class_Properties) - 1; ++i) { \ | |
| 221 FXJS_DefineObjProperty( \ | |
| 222 pIsolate, nObjDefnID, JS_Class_Properties[i].pName, \ | |
| 223 JS_Class_Properties[i].pPropGet, JS_Class_Properties[i].pPropPut); \ | |
| 224 } \ | |
| 225 for (int i = 0; i < FX_ArraySize(JS_Class_Methods) - 1; ++i) { \ | |
| 226 FXJS_DefineObjMethod(pIsolate, nObjDefnID, JS_Class_Methods[i].pName, \ | |
| 227 JS_Class_Methods[i].pMethodCall); \ | |
| 228 } \ | |
| 229 } | 218 } |
| 230 | 219 |
| 220 #define IMPLEMENT_JS_CLASS_CONST_PART(js_class_name, class_name) \ | |
| 221 void js_class_name::DefineConsts(v8::Isolate* pIsolate) { \ | |
| 222 for (int i = 0; i < FX_ArraySize(JS_Class_Consts) - 1; ++i) { \ | |
| 223 FXJS_DefineObjConst( \ | |
| 224 pIsolate, g_nObjDefnID, JS_Class_Consts[i].pName, \ | |
| 225 JS_Class_Consts[i].t == 0 \ | |
| 226 ? FXJS_NewNumber(pIsolate, JS_Class_Consts[i].number) \ | |
| 227 : FXJS_NewString(pIsolate, JS_Class_Consts[i].string)); \ | |
| 228 } \ | |
| 229 } | |
| 230 | |
| 231 // Convenience macros for declaring classes without an alternate. | |
| 232 #define DECLARE_JS_CLASS() DECLARE_JS_CLASS_RICH() | |
| 231 #define IMPLEMENT_JS_CLASS(js_class_name, class_name) \ | 233 #define IMPLEMENT_JS_CLASS(js_class_name, class_name) \ |
| 232 IMPLEMENT_JS_CLASS_RICH(js_class_name, class_name, class_name) | 234 IMPLEMENT_JS_CLASS_RICH(js_class_name, class_name, class_name) |
| 233 | 235 |
| 234 /* ======================================== CONST CLASS | 236 // Rich JS classes provide constsants, methods, properties, and the ability |
| 235 * ============================================ */ | 237 // to construct native object state. |
| 238 #define DECLARE_JS_CLASS_RICH() \ | |
| 239 DECLARE_JS_CLASS_BASE_PART() \ | |
| 240 DECLARE_JS_CLASS_CONST_PART() \ | |
| 241 DECLARE_JS_CLASS_RICH_PART() | |
| 236 | 242 |
| 237 #define DECLARE_JS_CLASS_CONST() \ | 243 #define DECLARE_JS_CLASS_RICH_PART() \ |
| 238 static void DefineJSObjects(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType); \ | 244 static void JSConstructor(IFXJS_Context* cc, v8::Local<v8::Object> obj, \ |
| 239 static JSConstSpec JS_Class_Consts[]; \ | 245 v8::Local<v8::Object> global); \ |
| 240 static const wchar_t* m_pClassName | 246 static void JSDestructor(v8::Local<v8::Object> obj); \ |
| 247 static void DefineProps(v8::Isolate* pIsoalte); \ | |
| 248 static void DefineMethods(v8::Isolate* pIsoalte); \ | |
| 249 static JSPropertySpec JS_Class_Properties[]; \ | |
| 250 static JSMethodSpec JS_Class_Methods[]; | |
| 241 | 251 |
| 242 #define IMPLEMENT_JS_CLASS_CONST(js_class_name, class_name) \ | 252 #define IMPLEMENT_JS_CLASS_RICH(js_class_name, class_alternate, class_name) \ |
| 243 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name); \ | 253 IMPLEMENT_JS_CLASS_BASE_PART(js_class_name, class_name) \ |
| 244 void js_class_name::DefineJSObjects(v8::Isolate* pIsolate, \ | 254 IMPLEMENT_JS_CLASS_CONST_PART(js_class_name, class_name) \ |
| 245 FXJSOBJTYPE eObjType) { \ | 255 IMPLEMENT_JS_CLASS_RICH_PART(js_class_name, class_alternate, class_name) \ |
| 246 int nObjDefnID = FXJS_DefineObj(pIsolate, js_class_name::m_pClassName, \ | 256 void js_class_name::DefineJSObjects(v8::Isolate* pIsolate, \ |
| 247 eObjType, NULL, NULL); \ | 257 FXJSOBJTYPE eObjType) { \ |
| 248 for (int i = 0; i < FX_ArraySize(JS_Class_Consts) - 1; ++i) { \ | 258 g_nObjDefnID = FXJS_DefineObj(pIsolate, js_class_name::g_pClassName, \ |
| 249 FXJS_DefineObjConst( \ | 259 eObjType, JSConstructor, JSDestructor); \ |
| 250 pIsolate, nObjDefnID, JS_Class_Consts[i].pName, \ | 260 DefineConsts(pIsolate); \ |
| 251 JS_Class_Consts[i].t == 0 \ | 261 DefineProps(pIsolate); \ |
| 252 ? FXJS_NewNumber(pIsolate, JS_Class_Consts[i].number) \ | 262 DefineMethods(pIsolate); \ |
| 253 : FXJS_NewString(pIsolate, JS_Class_Consts[i].string)); \ | |
| 254 } \ | |
| 255 } | 263 } |
| 256 | 264 |
| 257 /* ===================================== SPECIAL JS CLASS | 265 #define IMPLEMENT_JS_CLASS_RICH_PART(js_class_name, class_alternate, \ |
| 258 * =============================================== */ | 266 class_name) \ |
| 267 void js_class_name::JSConstructor(IFXJS_Context* cc, \ | |
| 268 v8::Local<v8::Object> obj, \ | |
| 269 v8::Local<v8::Object> global) { \ | |
| 270 CJS_Object* pObj = new js_class_name(obj); \ | |
| 271 pObj->SetEmbedObject(new class_alternate(pObj)); \ | |
| 272 FXJS_SetPrivate(NULL, obj, (void*)pObj); \ | |
| 273 pObj->InitInstance(cc); \ | |
| 274 } \ | |
| 275 void js_class_name::JSDestructor(v8::Local<v8::Object> obj) { \ | |
| 276 js_class_name* pObj = (js_class_name*)FXJS_GetPrivate(NULL, obj); \ | |
| 277 pObj->ExitInstance(); \ | |
| 278 delete pObj; \ | |
| 279 } \ | |
| 280 void js_class_name::DefineProps(v8::Isolate* pIsolate) { \ | |
| 281 for (int i = 0; i < FX_ArraySize(JS_Class_Properties) - 1; ++i) { \ | |
| 282 FXJS_DefineObjProperty( \ | |
| 283 pIsolate, g_nObjDefnID, JS_Class_Properties[i].pName, \ | |
| 284 JS_Class_Properties[i].pPropGet, JS_Class_Properties[i].pPropPut); \ | |
| 285 } \ | |
| 286 } \ | |
| 287 void js_class_name::DefineMethods(v8::Isolate* pIsolate) { \ | |
| 288 for (int i = 0; i < FX_ArraySize(JS_Class_Methods) - 1; ++i) { \ | |
| 289 FXJS_DefineObjMethod(pIsolate, g_nObjDefnID, JS_Class_Methods[i].pName, \ | |
| 290 JS_Class_Methods[i].pMethodCall); \ | |
| 291 } \ | |
| 292 } | |
| 293 | |
| 294 // Special JS classes implement methods, props, and queries, but not consts. | |
| 295 #define DECLARE_SPECIAL_JS_CLASS() \ | |
| 296 DECLARE_JS_CLASS_BASE_PART() \ | |
| 297 DECLARE_JS_CLASS_CONST_PART() \ | |
| 298 DECLARE_JS_CLASS_RICH_PART() \ | |
| 299 DECLARE_SPECIAL_JS_CLASS_PART() | |
| 300 | |
| 301 #define DECLARE_SPECIAL_JS_CLASS_PART() \ | |
| 302 static void queryprop_static( \ | |
| 303 v8::Local<v8::String> property, \ | |
| 304 const v8::PropertyCallbackInfo<v8::Integer>& info); \ | |
| 305 static void getprop_static(v8::Local<v8::String> property, \ | |
| 306 const v8::PropertyCallbackInfo<v8::Value>& info); \ | |
| 307 static void putprop_static(v8::Local<v8::String> property, \ | |
| 308 v8::Local<v8::Value> value, \ | |
| 309 const v8::PropertyCallbackInfo<v8::Value>& info); \ | |
| 310 static void delprop_static( \ | |
| 311 v8::Local<v8::String> property, \ | |
| 312 const v8::PropertyCallbackInfo<v8::Boolean>& info); \ | |
| 313 static void DefineAllProperties(v8::Isolate* pIsolate); | |
| 314 | |
| 315 #define IMPLEMENT_SPECIAL_JS_CLASS(js_class_name, class_alternate, class_name) \ | |
| 316 IMPLEMENT_JS_CLASS_BASE_PART(js_class_name, class_name) \ | |
| 317 IMPLEMENT_JS_CLASS_CONST_PART(js_class_name, class_name) \ | |
| 318 IMPLEMENT_JS_CLASS_RICH_PART(js_class_name, class_alternate, class_name) \ | |
| 319 IMPLEMENT_SPECIAL_JS_CLASS_PART(js_class_name, class_alternate, class_name) \ | |
| 320 void js_class_name::DefineJSObjects(v8::Isolate* pIsolate, \ | |
| 321 FXJSOBJTYPE eObjType) { \ | |
| 322 g_nObjDefnID = FXJS_DefineObj(pIsolate, js_class_name::g_pClassName, \ | |
| 323 eObjType, JSConstructor, JSDestructor); \ | |
| 324 DefineConsts(pIsolate); \ | |
| 325 DefineProps(pIsolate); \ | |
| 326 DefineMethods(pIsolate); \ | |
| 327 DefineAllProperties(pIsolate); \ | |
| 328 } | |
| 329 | |
| 330 #define IMPLEMENT_SPECIAL_JS_CLASS_PART(js_class_name, class_alternate, \ | |
| 331 class_name) \ | |
| 332 void js_class_name::queryprop_static( \ | |
| 333 v8::Local<v8::String> property, \ | |
| 334 const v8::PropertyCallbackInfo<v8::Integer>& info) { \ | |
| 335 JSSpecialPropQuery<class_alternate>(#class_name, property, info); \ | |
| 336 } \ | |
| 337 void js_class_name::getprop_static( \ | |
| 338 v8::Local<v8::String> property, \ | |
| 339 const v8::PropertyCallbackInfo<v8::Value>& info) { \ | |
| 340 JSSpecialPropGet<class_alternate>(#class_name, property, info); \ | |
| 341 } \ | |
| 342 void js_class_name::putprop_static( \ | |
| 343 v8::Local<v8::String> property, v8::Local<v8::Value> value, \ | |
| 344 const v8::PropertyCallbackInfo<v8::Value>& info) { \ | |
| 345 JSSpecialPropPut<class_alternate>(#class_name, property, value, info); \ | |
| 346 } \ | |
| 347 void js_class_name::delprop_static( \ | |
| 348 v8::Local<v8::String> property, \ | |
| 349 const v8::PropertyCallbackInfo<v8::Boolean>& info) { \ | |
| 350 JSSpecialPropDel<class_alternate>(#class_name, property, info); \ | |
| 351 } \ | |
| 352 void js_class_name::DefineAllProperties(v8::Isolate* pIsolate) { \ | |
| 353 FXJS_DefineObjAllProperties( \ | |
| 354 pIsolate, g_nObjDefnID, js_class_name::queryprop_static, \ | |
| 355 js_class_name::getprop_static, js_class_name::putprop_static, \ | |
| 356 js_class_name::delprop_static); \ | |
| 357 } | |
| 259 | 358 |
| 260 template <class Alt> | 359 template <class Alt> |
| 261 void JSSpecialPropQuery(const char*, | 360 void JSSpecialPropQuery(const char*, |
| 262 v8::Local<v8::String> property, | 361 v8::Local<v8::String> property, |
| 263 const v8::PropertyCallbackInfo<v8::Integer>& info) { | 362 const v8::PropertyCallbackInfo<v8::Integer>& info) { |
| 264 v8::Isolate* isolate = info.GetIsolate(); | 363 v8::Isolate* isolate = info.GetIsolate(); |
| 265 v8::String::Utf8Value utf8_value(property); | 364 v8::String::Utf8Value utf8_value(property); |
| 266 CFX_WideString propname = | 365 CFX_WideString propname = |
| 267 CFX_WideString::FromUTF8(*utf8_value, utf8_value.length()); | 366 CFX_WideString::FromUTF8(*utf8_value, utf8_value.length()); |
| 268 CJS_Object* pJSObj = | 367 CJS_Object* pJSObj = |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 337 CFX_WideString propname = | 436 CFX_WideString propname = |
| 338 CFX_WideString::FromUTF8(*utf8_value, utf8_value.length()); | 437 CFX_WideString::FromUTF8(*utf8_value, utf8_value.length()); |
| 339 CFX_WideString sError; | 438 CFX_WideString sError; |
| 340 if (!pObj->DelProperty(pRuntimeContext, propname.c_str(), sError)) { | 439 if (!pObj->DelProperty(pRuntimeContext, propname.c_str(), sError)) { |
| 341 CFX_ByteString cbName; | 440 CFX_ByteString cbName; |
| 342 cbName.Format("%s.%s", class_name, "DelProperty"); | 441 cbName.Format("%s.%s", class_name, "DelProperty"); |
| 343 // Probably a missing call to JSFX_Error(). | 442 // Probably a missing call to JSFX_Error(). |
| 344 } | 443 } |
| 345 } | 444 } |
| 346 | 445 |
| 347 #define DECLARE_SPECIAL_JS_CLASS(js_class_name) \ | |
| 348 static void JSConstructor(IFXJS_Context* cc, v8::Local<v8::Object> obj, \ | |
| 349 v8::Local<v8::Object> global); \ | |
| 350 static void JSDestructor(v8::Local<v8::Object> obj); \ | |
| 351 static JSConstSpec JS_Class_Consts[]; \ | |
| 352 static JSPropertySpec JS_Class_Properties[]; \ | |
| 353 static JSMethodSpec JS_Class_Methods[]; \ | |
| 354 static void DefineJSObjects(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType); \ | |
| 355 static const wchar_t* m_pClassName; \ | |
| 356 static void queryprop_##js_class_name##_static( \ | |
| 357 v8::Local<v8::String> property, \ | |
| 358 const v8::PropertyCallbackInfo<v8::Integer>& info); \ | |
| 359 static void getprop_##js_class_name##_static( \ | |
| 360 v8::Local<v8::String> property, \ | |
| 361 const v8::PropertyCallbackInfo<v8::Value>& info); \ | |
| 362 static void putprop_##js_class_name##_static( \ | |
| 363 v8::Local<v8::String> property, v8::Local<v8::Value> value, \ | |
| 364 const v8::PropertyCallbackInfo<v8::Value>& info); \ | |
| 365 static void delprop_##js_class_name##_static( \ | |
| 366 v8::Local<v8::String> property, \ | |
| 367 const v8::PropertyCallbackInfo<v8::Boolean>& info) | |
| 368 | |
| 369 #define IMPLEMENT_SPECIAL_JS_CLASS(js_class_name, class_alternate, class_name) \ | |
| 370 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name); \ | |
| 371 void js_class_name::queryprop_##js_class_name##_static( \ | |
| 372 v8::Local<v8::String> property, \ | |
| 373 const v8::PropertyCallbackInfo<v8::Integer>& info) { \ | |
| 374 JSSpecialPropQuery<class_alternate>(#class_name, property, info); \ | |
| 375 } \ | |
| 376 void js_class_name::getprop_##js_class_name##_static( \ | |
| 377 v8::Local<v8::String> property, \ | |
| 378 const v8::PropertyCallbackInfo<v8::Value>& info) { \ | |
| 379 JSSpecialPropGet<class_alternate>(#class_name, property, info); \ | |
| 380 } \ | |
| 381 void js_class_name::putprop_##js_class_name##_static( \ | |
| 382 v8::Local<v8::String> property, v8::Local<v8::Value> value, \ | |
| 383 const v8::PropertyCallbackInfo<v8::Value>& info) { \ | |
| 384 JSSpecialPropPut<class_alternate>(#class_name, property, value, info); \ | |
| 385 } \ | |
| 386 void js_class_name::delprop_##js_class_name##_static( \ | |
| 387 v8::Local<v8::String> property, \ | |
| 388 const v8::PropertyCallbackInfo<v8::Boolean>& info) { \ | |
| 389 JSSpecialPropDel<class_alternate>(#class_name, property, info); \ | |
| 390 } \ | |
| 391 void js_class_name::JSConstructor(IFXJS_Context* cc, \ | |
| 392 v8::Local<v8::Object> obj, \ | |
| 393 v8::Local<v8::Object> global) { \ | |
| 394 CJS_Object* pObj = new js_class_name(obj); \ | |
| 395 pObj->SetEmbedObject(new class_alternate(pObj)); \ | |
| 396 FXJS_SetPrivate(NULL, obj, (void*)pObj); \ | |
| 397 pObj->InitInstance(cc); \ | |
| 398 } \ | |
| 399 \ | |
| 400 void js_class_name::JSDestructor(v8::Local<v8::Object> obj) { \ | |
| 401 js_class_name* pObj = (js_class_name*)FXJS_GetPrivate(NULL, obj); \ | |
| 402 ASSERT(pObj != NULL); \ | |
| 403 pObj->ExitInstance(); \ | |
| 404 delete pObj; \ | |
| 405 } \ | |
| 406 \ | |
| 407 void js_class_name::DefineJSObjects(v8::Isolate* pIsolate, \ | |
| 408 FXJSOBJTYPE eObjType) { \ | |
| 409 int nObjDefnID = FXJS_DefineObj(pIsolate, js_class_name::m_pClassName, \ | |
| 410 eObjType, JSConstructor, JSDestructor); \ | |
| 411 for (int i = 0; i < FX_ArraySize(JS_Class_Properties) - 1; ++i) { \ | |
| 412 FXJS_DefineObjProperty( \ | |
| 413 pIsolate, nObjDefnID, JS_Class_Properties[i].pName, \ | |
| 414 JS_Class_Properties[i].pPropGet, JS_Class_Properties[i].pPropPut); \ | |
| 415 } \ | |
| 416 \ | |
| 417 for (int i = 0; i < FX_ArraySize(JS_Class_Methods) - 1; ++i) { \ | |
| 418 FXJS_DefineObjMethod(pIsolate, nObjDefnID, JS_Class_Methods[i].pName, \ | |
| 419 JS_Class_Methods[i].pMethodCall); \ | |
| 420 } \ | |
| 421 FXJS_DefineObjAllProperties( \ | |
| 422 pIsolate, nObjDefnID, \ | |
| 423 js_class_name::queryprop_##js_class_name##_static, \ | |
| 424 js_class_name::getprop_##js_class_name##_static, \ | |
| 425 js_class_name::putprop_##js_class_name##_static, \ | |
| 426 js_class_name::delprop_##js_class_name##_static); \ | |
| 427 } | |
| 428 | |
| 429 /* ======================================== GLOBAL METHODS | 446 /* ======================================== GLOBAL METHODS |
| 430 * ============================================ */ | 447 * ============================================ */ |
| 431 | 448 |
| 432 template <FX_BOOL (*F)(IFXJS_Context* cc, | 449 template <FX_BOOL (*F)(IFXJS_Context* cc, |
| 433 const CJS_Parameters& params, | 450 const CJS_Parameters& params, |
| 434 CJS_Value& vRet, | 451 CJS_Value& vRet, |
| 435 CFX_WideString& sError)> | 452 CFX_WideString& sError)> |
| 436 void JSGlobalFunc(const char* func_name_string, | 453 void JSGlobalFunc(const char* func_name_string, |
| 437 const v8::FunctionCallbackInfo<v8::Value>& info) { | 454 const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 438 v8::Isolate* isolate = info.GetIsolate(); | 455 v8::Isolate* isolate = info.GetIsolate(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 475 for (int i = 0; i < FX_ArraySize(global_methods) - 1; ++i) { \ | 492 for (int i = 0; i < FX_ArraySize(global_methods) - 1; ++i) { \ |
| 476 FXJS_DefineGlobalMethod(pIsolate, \ | 493 FXJS_DefineGlobalMethod(pIsolate, \ |
| 477 js_class_name::global_methods[i].pName, \ | 494 js_class_name::global_methods[i].pName, \ |
| 478 js_class_name::global_methods[i].pMethodCall); \ | 495 js_class_name::global_methods[i].pMethodCall); \ |
| 479 } \ | 496 } \ |
| 480 } | 497 } |
| 481 | 498 |
| 482 CJS_Value::Type GET_VALUE_TYPE(v8::Local<v8::Value> p); | 499 CJS_Value::Type GET_VALUE_TYPE(v8::Local<v8::Value> p); |
| 483 | 500 |
| 484 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_DEFINE_H_ | 501 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_DEFINE_H_ |
| OLD | NEW |