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

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

Issue 2172813002: Tidy up JS_Value.h (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebse Created 4 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 | « no previous file | fpdfsdk/javascript/JS_Value.h » ('j') | fpdfsdk/javascript/JS_Value.h » ('J')
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 FPDFSDK_JAVASCRIPT_JS_DEFINE_H_ 7 #ifndef FPDFSDK_JAVASCRIPT_JS_DEFINE_H_
8 #define FPDFSDK_JAVASCRIPT_JS_DEFINE_H_ 8 #define FPDFSDK_JAVASCRIPT_JS_DEFINE_H_
9 9
10 #include <vector> 10 #include <vector>
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder()); 85 CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder());
86 C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); 86 C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
87 CFX_WideString sError; 87 CFX_WideString sError;
88 CJS_PropValue value(pRuntime); 88 CJS_PropValue value(pRuntime);
89 value.StartGetting(); 89 value.StartGetting();
90 if (!(pObj->*M)(pContext, value, sError)) { 90 if (!(pObj->*M)(pContext, value, sError)) {
91 FXJS_Error(isolate, JSFormatErrorString(class_name_string, prop_name_string, 91 FXJS_Error(isolate, JSFormatErrorString(class_name_string, prop_name_string,
92 sError)); 92 sError));
93 return; 93 return;
94 } 94 }
95 info.GetReturnValue().Set((v8::Local<v8::Value>)value); 95 info.GetReturnValue().Set(value.ToV8Value());
96 } 96 }
97 97
98 template <class C, 98 template <class C,
99 FX_BOOL (C::*M)(IJS_Context*, CJS_PropValue&, CFX_WideString&)> 99 FX_BOOL (C::*M)(IJS_Context*, CJS_PropValue&, CFX_WideString&)>
100 void JSPropSetter(const char* prop_name_string, 100 void JSPropSetter(const char* prop_name_string,
101 const char* class_name_string, 101 const char* class_name_string,
102 v8::Local<v8::String> property, 102 v8::Local<v8::String> property,
103 v8::Local<v8::Value> value, 103 v8::Local<v8::Value> value,
104 const v8::PropertyCallbackInfo<void>& info) { 104 const v8::PropertyCallbackInfo<void>& info) {
105 v8::Isolate* isolate = info.GetIsolate(); 105 v8::Isolate* isolate = info.GetIsolate();
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 v8::String::Utf8Value utf8_value(property); 376 v8::String::Utf8Value utf8_value(property);
377 CFX_WideString propname = CFX_WideString::FromUTF8( 377 CFX_WideString propname = CFX_WideString::FromUTF8(
378 CFX_ByteStringC(*utf8_value, utf8_value.length())); 378 CFX_ByteStringC(*utf8_value, utf8_value.length()));
379 CFX_WideString sError; 379 CFX_WideString sError;
380 CJS_PropValue value(pRuntime); 380 CJS_PropValue value(pRuntime);
381 value.StartGetting(); 381 value.StartGetting();
382 if (!pObj->DoProperty(pContext, propname.c_str(), value, sError)) { 382 if (!pObj->DoProperty(pContext, propname.c_str(), value, sError)) {
383 FXJS_Error(isolate, JSFormatErrorString(class_name, "GetProperty", sError)); 383 FXJS_Error(isolate, JSFormatErrorString(class_name, "GetProperty", sError));
384 return; 384 return;
385 } 385 }
386 info.GetReturnValue().Set((v8::Local<v8::Value>)value); 386 info.GetReturnValue().Set(value.ToV8Value());
387 } 387 }
388 388
389 template <class Alt> 389 template <class Alt>
390 void JSSpecialPropPut(const char* class_name, 390 void JSSpecialPropPut(const char* class_name,
391 v8::Local<v8::String> property, 391 v8::Local<v8::String> property,
392 v8::Local<v8::Value> value, 392 v8::Local<v8::Value> value,
393 const v8::PropertyCallbackInfo<v8::Value>& info) { 393 const v8::PropertyCallbackInfo<v8::Value>& info) {
394 v8::Isolate* isolate = info.GetIsolate(); 394 v8::Isolate* isolate = info.GetIsolate();
395 CJS_Runtime* pRuntime = 395 CJS_Runtime* pRuntime =
396 static_cast<CJS_Runtime*>(FXJS_GetRuntimeFromIsolate(isolate)); 396 static_cast<CJS_Runtime*>(FXJS_GetRuntimeFromIsolate(isolate));
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 #define IMPLEMENT_JS_STATIC_GLOBAL_FUN(js_class_name) \ 479 #define IMPLEMENT_JS_STATIC_GLOBAL_FUN(js_class_name) \
480 void js_class_name::DefineJSObjects(v8::Isolate* pIsolate) { \ 480 void js_class_name::DefineJSObjects(v8::Isolate* pIsolate) { \
481 for (size_t i = 0; i < FX_ArraySize(global_methods) - 1; ++i) { \ 481 for (size_t i = 0; i < FX_ArraySize(global_methods) - 1; ++i) { \
482 FXJS_DefineGlobalMethod(pIsolate, \ 482 FXJS_DefineGlobalMethod(pIsolate, \
483 js_class_name::global_methods[i].pName, \ 483 js_class_name::global_methods[i].pName, \
484 js_class_name::global_methods[i].pMethodCall); \ 484 js_class_name::global_methods[i].pMethodCall); \
485 } \ 485 } \
486 } 486 }
487 487
488 #endif // FPDFSDK_JAVASCRIPT_JS_DEFINE_H_ 488 #endif // FPDFSDK_JAVASCRIPT_JS_DEFINE_H_
OLDNEW
« no previous file with comments | « no previous file | fpdfsdk/javascript/JS_Value.h » ('j') | fpdfsdk/javascript/JS_Value.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698