Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Side by Side Diff: fpdfsdk/include/javascript/JS_Define.h

Issue 733693003: Getting rid of more (FX_LPCWSTR) casts and fixing two bugs revealed by this. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Simplified GetAttrValue to just assign *pValue and to share code. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fxcrt/fxcrt_platforms.cpp ('k') | fpdfsdk/src/fsdk_baseform.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_
OLDNEW
« no previous file with comments | « core/src/fxcrt/fxcrt_platforms.cpp ('k') | fpdfsdk/src/fsdk_baseform.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698