| 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 typedef v8::Value JSValue; | 10 typedef v8::Value JSValue; |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 {\ | 334 {\ |
| 335 v8::Isolate* isolate = info.GetIsolate();\ | 335 v8::Isolate* isolate = info.GetIsolate();\ |
| 336 v8::String::Utf8Value utf8_value(property);\ | 336 v8::String::Utf8Value utf8_value(property);\ |
| 337 CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_val
ue.length());\ | 337 CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_val
ue.length());\ |
| 338 CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\ | 338 CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\ |
| 339 ASSERT(pJSObj != NULL);\ | 339 ASSERT(pJSObj != NULL);\ |
| 340 class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\ | 340 class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\ |
| 341 ASSERT(pObj != NULL);\ | 341 ASSERT(pObj != NULL);\ |
| 342 FX_BOOL bRet = FALSE;\ | 342 FX_BOOL bRet = FALSE;\ |
| 343 MEMLEAKCHECK_1();\ | 343 MEMLEAKCHECK_1();\ |
| 344 » bRet = pObj->QueryProperty((FX_LPCWSTR)propname);\ | 344 » bRet = pObj->QueryProperty(propname.c_str());\ |
| 345 » MEMLEAKCHECK_2(class_name, (FX_LPCWSTR)prop_name);\ | 345 » MEMLEAKCHECK_2(class_name, prop_name.c_str());\ |
| 346 if (bRet)\ | 346 if (bRet)\ |
| 347 {\ | 347 {\ |
| 348 info.GetReturnValue().Set(0x004);\ | 348 info.GetReturnValue().Set(0x004);\ |
| 349 return ;\ | 349 return ;\ |
| 350 }\ | 350 }\ |
| 351 else\ | 351 else\ |
| 352 {\ | 352 {\ |
| 353 info.GetReturnValue().Set(0);\ | 353 info.GetReturnValue().Set(0);\ |
| 354 return ;\ | 354 return ;\ |
| 355 }\ | 355 }\ |
| (...skipping 13 matching lines...) Expand all Loading... |
| 369 CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_val
ue.length());\ | 369 CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_val
ue.length());\ |
| 370 CJS_PropValue value(isolate);\ | 370 CJS_PropValue value(isolate);\ |
| 371 value.StartGetting();\ | 371 value.StartGetting();\ |
| 372 CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\ | 372 CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\ |
| 373 ASSERT(pJSObj != NULL);\ | 373 ASSERT(pJSObj != NULL);\ |
| 374 class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\ | 374 class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\ |
| 375 ASSERT(pObj != NULL);\ | 375 ASSERT(pObj != NULL);\ |
| 376 JS_ErrorString sError;\ | 376 JS_ErrorString sError;\ |
| 377 FX_BOOL bRet = FALSE;\ | 377 FX_BOOL bRet = FALSE;\ |
| 378 MEMLEAKCHECK_1();\ | 378 MEMLEAKCHECK_1();\ |
| 379 » bRet = pObj->DoProperty(cc, (FX_LPCWSTR)propname, value, sError);\ | 379 » bRet = pObj->DoProperty(cc, propname.c_str(), value, sError);\ |
| 380 MEMLEAKCHECK_2(class_name, L"GetProperty");\ | 380 MEMLEAKCHECK_2(class_name, L"GetProperty");\ |
| 381 if (bRet)\ | 381 if (bRet)\ |
| 382 {\ | 382 {\ |
| 383 info.GetReturnValue().Set((v8::Handle<v8::Value>)value);\ | 383 info.GetReturnValue().Set((v8::Handle<v8::Value>)value);\ |
| 384 return ;\ | 384 return ;\ |
| 385 }\ | 385 }\ |
| 386 else\ | 386 else\ |
| 387 {\ | 387 {\ |
| 388 CFX_ByteString cbName;\ | 388 CFX_ByteString cbName;\ |
| 389 cbName.Format("%s.%s", #class_name, L"GetProperty");\ | 389 cbName.Format("%s.%s", #class_name, L"GetProperty");\ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 407 CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_val
ue.length());\ | 407 CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_val
ue.length());\ |
| 408 CJS_PropValue PropValue(CJS_Value(isolate,value,VT_unknown));\ | 408 CJS_PropValue PropValue(CJS_Value(isolate,value,VT_unknown));\ |
| 409 PropValue.StartSetting();\ | 409 PropValue.StartSetting();\ |
| 410 CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\ | 410 CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\ |
| 411 if(!pJSObj) return;\ | 411 if(!pJSObj) return;\ |
| 412 class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\ | 412 class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\ |
| 413 ASSERT(pObj != NULL);\ | 413 ASSERT(pObj != NULL);\ |
| 414 JS_ErrorString sError;\ | 414 JS_ErrorString sError;\ |
| 415 FX_BOOL bRet = FALSE;\ | 415 FX_BOOL bRet = FALSE;\ |
| 416 MEMLEAKCHECK_1();\ | 416 MEMLEAKCHECK_1();\ |
| 417 » bRet = pObj->DoProperty(cc, (FX_LPCWSTR)propname, PropValue, sError);\ | 417 » bRet = pObj->DoProperty(cc, propname.c_str(), PropValue, sError);\ |
| 418 MEMLEAKCHECK_2(class_name,L"PutProperty");\ | 418 MEMLEAKCHECK_2(class_name,L"PutProperty");\ |
| 419 if (bRet)\ | 419 if (bRet)\ |
| 420 {\ | 420 {\ |
| 421 return ;\ | 421 return ;\ |
| 422 }\ | 422 }\ |
| 423 else\ | 423 else\ |
| 424 {\ | 424 {\ |
| 425 CFX_ByteString cbName;\ | 425 CFX_ByteString cbName;\ |
| 426 cbName.Format("%s.%s", #class_name, "PutProperty");\ | 426 cbName.Format("%s.%s", #class_name, "PutProperty");\ |
| 427 JS_Error(NULL,CFX_WideString::FromLocal(cbName), sError);\ | 427 JS_Error(NULL,CFX_WideString::FromLocal(cbName), sError);\ |
| (...skipping 14 matching lines...) Expand all Loading... |
| 442 IFXJS_Context* cc = pRuntime->GetCurrentContext();\ | 442 IFXJS_Context* cc = pRuntime->GetCurrentContext();\ |
| 443 v8::String::Utf8Value utf8_value(property);\ | 443 v8::String::Utf8Value utf8_value(property);\ |
| 444 CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_val
ue.length());\ | 444 CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_val
ue.length());\ |
| 445 CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\ | 445 CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\ |
| 446 ASSERT(pJSObj != NULL);\ | 446 ASSERT(pJSObj != NULL);\ |
| 447 class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\ | 447 class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\ |
| 448 ASSERT(pObj != NULL);\ | 448 ASSERT(pObj != NULL);\ |
| 449 JS_ErrorString sError;\ | 449 JS_ErrorString sError;\ |
| 450 FX_BOOL bRet = FALSE;\ | 450 FX_BOOL bRet = FALSE;\ |
| 451 MEMLEAKCHECK_1();\ | 451 MEMLEAKCHECK_1();\ |
| 452 » bRet = pObj->DelProperty(cc, (FX_LPCWSTR)propname, sError);\ | 452 » bRet = pObj->DelProperty(cc, propname.c_str(), sError);\ |
| 453 MEMLEAKCHECK_2(class_name,L"DelProperty");\ | 453 MEMLEAKCHECK_2(class_name,L"DelProperty");\ |
| 454 if (bRet)\ | 454 if (bRet)\ |
| 455 {\ | 455 {\ |
| 456 return ;\ | 456 return ;\ |
| 457 }\ | 457 }\ |
| 458 else\ | 458 else\ |
| 459 {\ | 459 {\ |
| 460 CFX_ByteString cbName;\ | 460 CFX_ByteString cbName;\ |
| 461 cbName.Format("%s.%s", #class_name, "DelProperty");\ | 461 cbName.Format("%s.%s", #class_name, "DelProperty");\ |
| 462 return ;\ | 462 return ;\ |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 /* ======================================== GLOBAL CONSTS ======================
====================== */ | 619 /* ======================================== GLOBAL CONSTS ======================
====================== */ |
| 620 #define DEFINE_GLOBAL_CONST(pRuntime, const_name , const_value)\ | 620 #define DEFINE_GLOBAL_CONST(pRuntime, const_name , const_value)\ |
| 621 if (JS_DefineGlobalConst(pRuntime,JS_WIDESTRING(const_name),JS_NewString(pRuntim
e,JS_WIDESTRING(const_value)))) return -1 | 621 if (JS_DefineGlobalConst(pRuntime,JS_WIDESTRING(const_name),JS_NewString(pRuntim
e,JS_WIDESTRING(const_value)))) return -1 |
| 622 | 622 |
| 623 /* ======================================== GLOBAL ARRAYS ======================
====================== */ | 623 /* ======================================== GLOBAL ARRAYS ======================
====================== */ |
| 624 | 624 |
| 625 #define DEFINE_GLOBAL_ARRAY(pRuntime)\ | 625 #define DEFINE_GLOBAL_ARRAY(pRuntime)\ |
| 626 int size = sizeof(ArrayContent) / sizeof(FX_LPCWSTR);\ | 626 int size = sizeof(ArrayContent) / sizeof(FX_LPCWSTR);\ |
| 627 \ | 627 \ |
| 628 CJS_Array array(pRuntime);\ | 628 CJS_Array array(pRuntime);\ |
| 629 for (int i=0; i<size; i++) array.SetElement(i,CJS_Value(pRuntime,(FX_LPCWSTR)Arr
ayContent[i]));\ | 629 for (int i=0; i<size; i++) array.SetElement(i,CJS_Value(pRuntime,ArrayContent[i]
));\ |
| 630 \ | 630 \ |
| 631 CJS_PropValue prop(pRuntime);\ | 631 CJS_PropValue prop(pRuntime);\ |
| 632 prop << array;\ | 632 prop << array;\ |
| 633 if (JS_DefineGlobalConst(pRuntime, (const wchar_t*)ArrayName, prop.ToJSValue())
< 0)\ | 633 if (JS_DefineGlobalConst(pRuntime, (const wchar_t*)ArrayName, prop.ToJSValue())
< 0)\ |
| 634 return -1 | 634 return -1 |
| 635 | 635 |
| 636 /* ============================================================ */ | 636 /* ============================================================ */ |
| 637 | 637 |
| 638 #define VALUE_NAME_STRING L"string" | 638 #define VALUE_NAME_STRING L"string" |
| 639 #define VALUE_NAME_NUMBER L"number" | 639 #define VALUE_NAME_NUMBER L"number" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 else if (strcmp(sType,VALUE_NAME_NULL) == 0) | 696 else if (strcmp(sType,VALUE_NAME_NULL) == 0) |
| 697 return VT_null; | 697 return VT_null; |
| 698 else if (strcmp(sType,VALUE_NAME_UNDEFINED) == 0) | 698 else if (strcmp(sType,VALUE_NAME_UNDEFINED) == 0) |
| 699 return VT_undefined; | 699 return VT_undefined; |
| 700 */ | 700 */ |
| 701 | 701 |
| 702 return VT_unknown; | 702 return VT_unknown; |
| 703 } | 703 } |
| 704 | 704 |
| 705 #endif //_JS_DEFINE_H_ | 705 #endif //_JS_DEFINE_H_ |
| OLD | NEW |