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

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

Issue 472563002: Remove try/catch block (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Tabify Created 6 years, 4 months 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/fxcodec/codec/fx_codec_jpx_opj.cpp ('k') | fpdfsdk/src/fpdf_progressive.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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\ 100 IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\
101 IFXJS_Context* cc = pRuntime->GetCurrentContext();\ 101 IFXJS_Context* cc = pRuntime->GetCurrentContext();\
102 CJS_PropValue value(isolate);\ 102 CJS_PropValue value(isolate);\
103 value.StartGetting();\ 103 value.StartGetting();\
104 CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\ 104 CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\
105 ASSERT(pJSObj != NULL);\ 105 ASSERT(pJSObj != NULL);\
106 class_name* pObj = (class_name*)pJSObj->GetEmbedObject();\ 106 class_name* pObj = (class_name*)pJSObj->GetEmbedObject();\
107 ASSERT(pObj != NULL);\ 107 ASSERT(pObj != NULL);\
108 JS_ErrorString sError;\ 108 JS_ErrorString sError;\
109 FX_BOOL bRet = FALSE;\ 109 FX_BOOL bRet = FALSE;\
110 » try\ 110 » MEMLEAKCHECK_1();\
111 » {\ 111 » bRet = pObj->prop_name(cc, value, sError);\
112 » » MEMLEAKCHECK_1();\ 112 » MEMLEAKCHECK_2(class_name, prop_name);\
113 » » bRet = pObj->prop_name(cc, value, sError);\
114 » » MEMLEAKCHECK_2(class_name, prop_name);\
115 » }\
116 » catch (...)\
117 » {\
118 » » CFX_ByteString cbName;\
119 » » cbName.Format("%s.%s", #class_name, #prop_name);\
120 » » JS_Error(NULL,CFX_WideString::FromLocal(cbName), L"Unknown error is catched!");\
121 » » return ;\
122 » }\
123 if (bRet)\ 113 if (bRet)\
124 {\ 114 {\
125 info.GetReturnValue().Set((v8::Handle<v8::Value>)value);\ 115 info.GetReturnValue().Set((v8::Handle<v8::Value>)value);\
126 return ;\ 116 return ;\
127 }\ 117 }\
128 else\ 118 else\
129 {\ 119 {\
130 CFX_ByteString cbName;\ 120 CFX_ByteString cbName;\
131 cbName.Format("%s.%s", #class_name, #prop_name);\ 121 cbName.Format("%s.%s", #class_name, #prop_name);\
132 JS_Error(NULL,CFX_WideString::FromLocal(cbName), sError);\ 122 JS_Error(NULL,CFX_WideString::FromLocal(cbName), sError);\
(...skipping 13 matching lines...) Expand all
146 IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\ 136 IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\
147 IFXJS_Context* cc = pRuntime->GetCurrentContext();\ 137 IFXJS_Context* cc = pRuntime->GetCurrentContext();\
148 CJS_PropValue propValue(CJS_Value(isolate,value,VT_unknown));\ 138 CJS_PropValue propValue(CJS_Value(isolate,value,VT_unknown));\
149 propValue.StartSetting();\ 139 propValue.StartSetting();\
150 CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\ 140 CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\
151 ASSERT(pJSObj != NULL);\ 141 ASSERT(pJSObj != NULL);\
152 class_name* pObj = (class_name*)pJSObj->GetEmbedObject();\ 142 class_name* pObj = (class_name*)pJSObj->GetEmbedObject();\
153 ASSERT(pObj != NULL);\ 143 ASSERT(pObj != NULL);\
154 JS_ErrorString sError;\ 144 JS_ErrorString sError;\
155 FX_BOOL bRet = FALSE;\ 145 FX_BOOL bRet = FALSE;\
156 » try\ 146 » MEMLEAKCHECK_1();\
157 » {\ 147 » bRet = pObj->prop_name(cc, propValue, sError);\
158 » » MEMLEAKCHECK_1();\ 148 » MEMLEAKCHECK_2(class_name, prop_name);\
159 » » bRet = pObj->prop_name(cc, propValue, sError);\
160 » » MEMLEAKCHECK_2(class_name, prop_name);\
161 » }\
162 » catch (...)\
163 » {\
164 » » CFX_ByteString cbName;\
165 » » cbName.Format("%s.%s", #class_name, #prop_name);\
166 » » JS_Error(NULL,CFX_WideString::FromLocal(cbName), L"Unknown error is catched!");\
167 » » return ;\
168 » }\
169 if (bRet)\ 149 if (bRet)\
170 {\ 150 {\
171 return ;\ 151 return ;\
172 }\ 152 }\
173 else\ 153 else\
174 {\ 154 {\
175 CFX_ByteString cbName;\ 155 CFX_ByteString cbName;\
176 cbName.Format("%s.%s", #class_name, #prop_name);\ 156 cbName.Format("%s.%s", #class_name, #prop_name);\
177 JS_Error(NULL,CFX_WideString::FromLocal(cbName), sError);\ 157 JS_Error(NULL,CFX_WideString::FromLocal(cbName), sError);\
178 return ;\ 158 return ;\
(...skipping 22 matching lines...) Expand all
201 {\ 181 {\
202 parameters.push_back(CJS_Value(isolate, info[i], VT_unknown));\ 182 parameters.push_back(CJS_Value(isolate, info[i], VT_unknown));\
203 }\ 183 }\
204 CJS_Value valueRes(isolate);\ 184 CJS_Value valueRes(isolate);\
205 CJS_Object* pJSObj = (CJS_Object *)JS_GetPrivate(isolate,info.Holder()); \ 185 CJS_Object* pJSObj = (CJS_Object *)JS_GetPrivate(isolate,info.Holder()); \
206 ASSERT(pJSObj != NULL);\ 186 ASSERT(pJSObj != NULL);\
207 class_name* pObj = (class_name*)pJSObj->GetEmbedObject();\ 187 class_name* pObj = (class_name*)pJSObj->GetEmbedObject();\
208 ASSERT(pObj != NULL);\ 188 ASSERT(pObj != NULL);\
209 JS_ErrorString sError;\ 189 JS_ErrorString sError;\
210 FX_BOOL bRet = FALSE;\ 190 FX_BOOL bRet = FALSE;\
211 » try\ 191 » MEMLEAKCHECK_1();\
212 » {\ 192 » bRet = pObj->method_name(cc, parameters, valueRes, sError);\
213 » » MEMLEAKCHECK_1();\ 193 » MEMLEAKCHECK_2(class_name, method_name);\
214 » » bRet = pObj->method_name(cc, parameters, valueRes, sError);\
215 » » MEMLEAKCHECK_2(class_name, method_name);\
216 » }\
217 » catch (...)\
218 » {\
219 » » CFX_ByteString cbName;\
220 » » cbName.Format("%s.%s", #class_name, #method_name);\
221 » » JS_Error(NULL, CFX_WideString::FromLocal(cbName), L"Unknown erro r is catched!");\
222 » » return ;\
223 » }\
224 if (bRet)\ 194 if (bRet)\
225 {\ 195 {\
226 info.GetReturnValue().Set(valueRes.ToJSValue());\ 196 info.GetReturnValue().Set(valueRes.ToJSValue());\
227 return ;\ 197 return ;\
228 }\ 198 }\
229 else\ 199 else\
230 {\ 200 {\
231 CFX_ByteString cbName;\ 201 CFX_ByteString cbName;\
232 cbName.Format("%s.%s", #class_name, #method_name);\ 202 cbName.Format("%s.%s", #class_name, #method_name);\
233 JS_Error(NULL, CFX_WideString::FromLocal(cbName), sError);\ 203 JS_Error(NULL, CFX_WideString::FromLocal(cbName), sError);\
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 void js_class_name::queryprop_##js_class_name##_static(JS_PROPQUERY_ARGS )\ 333 void js_class_name::queryprop_##js_class_name##_static(JS_PROPQUERY_ARGS )\
364 {\ 334 {\
365 v8::Isolate* isolate = info.GetIsolate();\ 335 v8::Isolate* isolate = info.GetIsolate();\
366 v8::String::Utf8Value utf8_value(property);\ 336 v8::String::Utf8Value utf8_value(property);\
367 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());\
368 CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\ 338 CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\
369 ASSERT(pJSObj != NULL);\ 339 ASSERT(pJSObj != NULL);\
370 class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\ 340 class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\
371 ASSERT(pObj != NULL);\ 341 ASSERT(pObj != NULL);\
372 FX_BOOL bRet = FALSE;\ 342 FX_BOOL bRet = FALSE;\
373 » try\ 343 » MEMLEAKCHECK_1();\
374 » {\ 344 » bRet = pObj->QueryProperty((FX_LPCWSTR)propname);\
375 » » MEMLEAKCHECK_1();\ 345 » MEMLEAKCHECK_2(class_name, (FX_LPCWSTR)prop_name);\
376 » » bRet = pObj->QueryProperty((FX_LPCWSTR)propname);\
377 » » MEMLEAKCHECK_2(class_name, (FX_LPCWSTR)prop_name);\
378 » }\
379 » catch (...)\
380 » {\
381 » » return ;\
382 » }\
383 if (bRet)\ 346 if (bRet)\
384 {\ 347 {\
385 info.GetReturnValue().Set(0x004);\ 348 info.GetReturnValue().Set(0x004);\
386 return ;\ 349 return ;\
387 }\ 350 }\
388 else\ 351 else\
389 {\ 352 {\
390 info.GetReturnValue().Set(0);\ 353 info.GetReturnValue().Set(0);\
391 return ;\ 354 return ;\
392 }\ 355 }\
(...skipping 12 matching lines...) Expand all
405 v8::String::Utf8Value utf8_value(property);\ 368 v8::String::Utf8Value utf8_value(property);\
406 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());\
407 CJS_PropValue value(isolate);\ 370 CJS_PropValue value(isolate);\
408 value.StartGetting();\ 371 value.StartGetting();\
409 CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\ 372 CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\
410 ASSERT(pJSObj != NULL);\ 373 ASSERT(pJSObj != NULL);\
411 class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\ 374 class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\
412 ASSERT(pObj != NULL);\ 375 ASSERT(pObj != NULL);\
413 JS_ErrorString sError;\ 376 JS_ErrorString sError;\
414 FX_BOOL bRet = FALSE;\ 377 FX_BOOL bRet = FALSE;\
415 » try\ 378 » MEMLEAKCHECK_1();\
416 » {\ 379 » bRet = pObj->DoProperty(cc, (FX_LPCWSTR)propname, value, sError);\
417 » » MEMLEAKCHECK_1();\ 380 » MEMLEAKCHECK_2(class_name, L"GetProperty");\
418 » » bRet = pObj->DoProperty(cc, (FX_LPCWSTR)propname, value, sError) ;\
419 » » MEMLEAKCHECK_2(class_name, L"GetProperty");\
420 » }\
421 » catch (...)\
422 » {\
423 » » CFX_ByteString cbName;\
424 » » cbName.Format("%s.%s", #class_name, L"GetProperty");\
425 » » JS_Error(NULL,CFX_WideString::FromLocal(cbName), L"Unknown error is catched!");\
426 » » return ;\
427 » }\
428 if (bRet)\ 381 if (bRet)\
429 {\ 382 {\
430 info.GetReturnValue().Set((v8::Handle<v8::Value>)value);\ 383 info.GetReturnValue().Set((v8::Handle<v8::Value>)value);\
431 return ;\ 384 return ;\
432 }\ 385 }\
433 else\ 386 else\
434 {\ 387 {\
435 CFX_ByteString cbName;\ 388 CFX_ByteString cbName;\
436 cbName.Format("%s.%s", #class_name, L"GetProperty");\ 389 cbName.Format("%s.%s", #class_name, L"GetProperty");\
437 JS_Error(NULL,CFX_WideString::FromLocal(cbName), sError);\ 390 JS_Error(NULL,CFX_WideString::FromLocal(cbName), sError);\
(...skipping 15 matching lines...) Expand all
453 v8::String::Utf8Value utf8_value(property);\ 406 v8::String::Utf8Value utf8_value(property);\
454 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());\
455 CJS_PropValue PropValue(CJS_Value(isolate,value,VT_unknown));\ 408 CJS_PropValue PropValue(CJS_Value(isolate,value,VT_unknown));\
456 PropValue.StartSetting();\ 409 PropValue.StartSetting();\
457 CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\ 410 CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\
458 if(!pJSObj) return;\ 411 if(!pJSObj) return;\
459 class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\ 412 class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\
460 ASSERT(pObj != NULL);\ 413 ASSERT(pObj != NULL);\
461 JS_ErrorString sError;\ 414 JS_ErrorString sError;\
462 FX_BOOL bRet = FALSE;\ 415 FX_BOOL bRet = FALSE;\
463 » try\ 416 » MEMLEAKCHECK_1();\
464 » {\ 417 » bRet = pObj->DoProperty(cc, (FX_LPCWSTR)propname, PropValue, sError);\
465 » » MEMLEAKCHECK_1();\ 418 » MEMLEAKCHECK_2(class_name,L"PutProperty");\
466 » » bRet = pObj->DoProperty(cc, (FX_LPCWSTR)propname, PropValue, sEr ror);\
467 » » MEMLEAKCHECK_2(class_name,L"PutProperty");\
468 » }\
469 » catch (...)\
470 » {\
471 » » CFX_ByteString cbName;\
472 » » cbName.Format("%s.%s", #class_name, "PutProperty");\
473 » » JS_Error(NULL,CFX_WideString::FromLocal(cbName), L"Unknown error is catched!");\
474 » » return ;\
475 » }\
476 if (bRet)\ 419 if (bRet)\
477 {\ 420 {\
478 return ;\ 421 return ;\
479 }\ 422 }\
480 else\ 423 else\
481 {\ 424 {\
482 CFX_ByteString cbName;\ 425 CFX_ByteString cbName;\
483 cbName.Format("%s.%s", #class_name, "PutProperty");\ 426 cbName.Format("%s.%s", #class_name, "PutProperty");\
484 JS_Error(NULL,CFX_WideString::FromLocal(cbName), sError);\ 427 JS_Error(NULL,CFX_WideString::FromLocal(cbName), sError);\
485 return ;\ 428 return ;\
(...skipping 12 matching lines...) Expand all
498 IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\ 441 IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\
499 IFXJS_Context* cc = pRuntime->GetCurrentContext();\ 442 IFXJS_Context* cc = pRuntime->GetCurrentContext();\
500 v8::String::Utf8Value utf8_value(property);\ 443 v8::String::Utf8Value utf8_value(property);\
501 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());\
502 CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\ 445 CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\
503 ASSERT(pJSObj != NULL);\ 446 ASSERT(pJSObj != NULL);\
504 class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\ 447 class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\
505 ASSERT(pObj != NULL);\ 448 ASSERT(pObj != NULL);\
506 JS_ErrorString sError;\ 449 JS_ErrorString sError;\
507 FX_BOOL bRet = FALSE;\ 450 FX_BOOL bRet = FALSE;\
508 » try\ 451 » MEMLEAKCHECK_1();\
509 » {\ 452 » bRet = pObj->DelProperty(cc, (FX_LPCWSTR)propname, sError);\
510 » » MEMLEAKCHECK_1();\ 453 » MEMLEAKCHECK_2(class_name,L"DelProperty");\
511 » » bRet = pObj->DelProperty(cc, (FX_LPCWSTR)propname, sError);\
512 » » MEMLEAKCHECK_2(class_name,L"DelProperty");\
513 » }\
514 » catch (...)\
515 » {\
516 » » CFX_ByteString cbName;\
517 » » cbName.Format("%s.%s", #class_name, "DelProperty");\
518 » » return ;\
519 » }\
520 if (bRet)\ 454 if (bRet)\
521 {\ 455 {\
522 return ;\ 456 return ;\
523 }\ 457 }\
524 else\ 458 else\
525 {\ 459 {\
526 CFX_ByteString cbName;\ 460 CFX_ByteString cbName;\
527 cbName.Format("%s.%s", #class_name, "DelProperty");\ 461 cbName.Format("%s.%s", #class_name, "DelProperty");\
528 return ;\ 462 return ;\
529 }\ 463 }\
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 {\ 536 {\
603 parameters.push_back(CJS_Value(isolate, info[i], VT_unknown));\ 537 parameters.push_back(CJS_Value(isolate, info[i], VT_unknown));\
604 }\ 538 }\
605 CJS_Value valueRes(isolate);\ 539 CJS_Value valueRes(isolate);\
606 CJS_Object* pJSObj = (CJS_Object *)JS_GetPrivate(isolate, info.Holder()) ;\ 540 CJS_Object* pJSObj = (CJS_Object *)JS_GetPrivate(isolate, info.Holder()) ;\
607 ASSERT(pJSObj != NULL);\ 541 ASSERT(pJSObj != NULL);\
608 class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\ 542 class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\
609 ASSERT(pObj != NULL);\ 543 ASSERT(pObj != NULL);\
610 JS_ErrorString sError;\ 544 JS_ErrorString sError;\
611 FX_BOOL bRet = FALSE;\ 545 FX_BOOL bRet = FALSE;\
612 » try\ 546 » MEMLEAKCHECK_1();\
613 » {\ 547 » bRet = pObj->method_name(cc, parameters, valueRes, sError);\
614 » » MEMLEAKCHECK_1();\ 548 » MEMLEAKCHECK_2(class_name, method_name);\
615 » » bRet = pObj->method_name(cc, parameters, valueRes, sError);\
616 » » MEMLEAKCHECK_2(class_name, method_name);\
617 » }\
618 » catch (...)\
619 » {\
620 » » CFX_ByteString cbName;\
621 » » cbName.Format("%s.%s", #class_name, #method_name);\
622 » » JS_Error(NULL, CFX_WideString::FromLocal(cbName), L"Unknown erro r is catched!");\
623 » » return ;\
624 » }\
625 if (bRet)\ 549 if (bRet)\
626 {\ 550 {\
627 info.GetReturnValue().Set(valueRes.ToJSValue());\ 551 info.GetReturnValue().Set(valueRes.ToJSValue());\
628 return ;\ 552 return ;\
629 }\ 553 }\
630 else\ 554 else\
631 {\ 555 {\
632 CFX_ByteString cbName;\ 556 CFX_ByteString cbName;\
633 cbName.Format("%s.%s", #class_name, #method_name);\ 557 cbName.Format("%s.%s", #class_name, #method_name);\
634 JS_Error(NULL, CFX_WideString::FromLocal(cbName), sError);\ 558 JS_Error(NULL, CFX_WideString::FromLocal(cbName), sError);\
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 else if (strcmp(sType,VALUE_NAME_NULL) == 0) 696 else if (strcmp(sType,VALUE_NAME_NULL) == 0)
773 return VT_null; 697 return VT_null;
774 else if (strcmp(sType,VALUE_NAME_UNDEFINED) == 0) 698 else if (strcmp(sType,VALUE_NAME_UNDEFINED) == 0)
775 return VT_undefined; 699 return VT_undefined;
776 */ 700 */
777 701
778 return VT_unknown; 702 return VT_unknown;
779 } 703 }
780 704
781 #endif //_JS_DEFINE_H_ 705 #endif //_JS_DEFINE_H_
OLDNEW
« no previous file with comments | « core/src/fxcodec/codec/fx_codec_jpx_opj.cpp ('k') | fpdfsdk/src/fpdf_progressive.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698