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

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

Issue 1437863005: Merge to XFA: Replace CJS_Parameters with std::vector<CJS_Value>. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 1 month 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 | « fpdfsdk/src/javascript/Field.cpp ('k') | fpdfsdk/src/javascript/JS_Value.h » ('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 FPDFSDK_SRC_JAVASCRIPT_JS_DEFINE_H_ 7 #ifndef FPDFSDK_SRC_JAVASCRIPT_JS_DEFINE_H_
8 #define FPDFSDK_SRC_JAVASCRIPT_JS_DEFINE_H_ 8 #define FPDFSDK_SRC_JAVASCRIPT_JS_DEFINE_H_
9 9
10 #include "../../include/jsapi/fxjs_v8.h" 10 #include "../../include/jsapi/fxjs_v8.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } \ 129 } \
130 static void set_##prop_name##_static( \ 130 static void set_##prop_name##_static( \
131 v8::Local<v8::String> property, v8::Local<v8::Value> value, \ 131 v8::Local<v8::String> property, v8::Local<v8::Value> value, \
132 const v8::PropertyCallbackInfo<void>& info) { \ 132 const v8::PropertyCallbackInfo<void>& info) { \
133 JSPropSetter<class_name, &class_name::prop_name>(#prop_name, #class_name, \ 133 JSPropSetter<class_name, &class_name::prop_name>(#prop_name, #class_name, \
134 property, value, info); \ 134 property, value, info); \
135 } 135 }
136 136
137 template <class C, 137 template <class C,
138 FX_BOOL (C::*M)(IJS_Context*, 138 FX_BOOL (C::*M)(IJS_Context*,
139 const CJS_Parameters&, 139 const std::vector<CJS_Value>&,
140 CJS_Value&, 140 CJS_Value&,
141 CFX_WideString&)> 141 CFX_WideString&)>
142 void JSMethod(const char* method_name_string, 142 void JSMethod(const char* method_name_string,
143 const char* class_name_string, 143 const char* class_name_string,
144 const v8::FunctionCallbackInfo<v8::Value>& info) { 144 const v8::FunctionCallbackInfo<v8::Value>& info) {
145 v8::Isolate* isolate = info.GetIsolate(); 145 v8::Isolate* isolate = info.GetIsolate();
146 CJS_Runtime* pRuntime = static_cast<CJS_Runtime*>( 146 CJS_Runtime* pRuntime = static_cast<CJS_Runtime*>(
147 FXJS_GetRuntimeFromV8Context(isolate->GetCurrentContext())); 147 FXJS_GetRuntimeFromV8Context(isolate->GetCurrentContext()));
148 if (!pRuntime) 148 if (!pRuntime)
149 return; 149 return;
150 IJS_Context* pContext = pRuntime->GetCurrentContext(); 150 IJS_Context* pContext = pRuntime->GetCurrentContext();
151 CJS_Parameters parameters; 151 std::vector<CJS_Value> parameters;
152 for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) { 152 for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) {
153 parameters.push_back(CJS_Value(pRuntime, info[i], CJS_Value::VT_unknown)); 153 parameters.push_back(CJS_Value(pRuntime, info[i], CJS_Value::VT_unknown));
154 } 154 }
155 CJS_Value valueRes(pRuntime); 155 CJS_Value valueRes(pRuntime);
156 CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder()); 156 CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder());
157 C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); 157 C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
158 CFX_WideString sError; 158 CFX_WideString sError;
159 if (!(pObj->*M)(pContext, parameters, valueRes, sError)) { 159 if (!(pObj->*M)(pContext, parameters, valueRes, sError)) {
160 FXJS_Error(isolate, JSFormatErrorString(class_name_string, 160 FXJS_Error(isolate, JSFormatErrorString(class_name_string,
161 method_name_string, sError)); 161 method_name_string, sError));
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 CFX_WideString propname = 429 CFX_WideString propname =
430 CFX_WideString::FromUTF8(*utf8_value, utf8_value.length()); 430 CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());
431 CFX_WideString sError; 431 CFX_WideString sError;
432 if (!pObj->DelProperty(pContext, propname.c_str(), sError)) { 432 if (!pObj->DelProperty(pContext, propname.c_str(), sError)) {
433 CFX_ByteString cbName; 433 CFX_ByteString cbName;
434 cbName.Format("%s.%s", class_name, "DelProperty"); 434 cbName.Format("%s.%s", class_name, "DelProperty");
435 // Probably a missing call to JSFX_Error(). 435 // Probably a missing call to JSFX_Error().
436 } 436 }
437 } 437 }
438 438
439 template <FX_BOOL ( 439 template <FX_BOOL (*F)(IJS_Context*,
440 *F)(IJS_Context*, const CJS_Parameters&, CJS_Value&, CFX_WideString&)> 440 const std::vector<CJS_Value>&,
441 CJS_Value&,
442 CFX_WideString&)>
441 void JSGlobalFunc(const char* func_name_string, 443 void JSGlobalFunc(const char* func_name_string,
442 const v8::FunctionCallbackInfo<v8::Value>& info) { 444 const v8::FunctionCallbackInfo<v8::Value>& info) {
443 CJS_Runtime* pRuntime = static_cast<CJS_Runtime*>( 445 CJS_Runtime* pRuntime = static_cast<CJS_Runtime*>(
444 FXJS_GetRuntimeFromV8Context(info.GetIsolate()->GetCurrentContext())); 446 FXJS_GetRuntimeFromV8Context(info.GetIsolate()->GetCurrentContext()));
445 if (!pRuntime) 447 if (!pRuntime)
446 return; 448 return;
447 IJS_Context* pContext = pRuntime->GetCurrentContext(); 449 IJS_Context* pContext = pRuntime->GetCurrentContext();
448 CJS_Parameters parameters; 450 std::vector<CJS_Value> parameters;
449 for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) { 451 for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) {
450 parameters.push_back(CJS_Value(pRuntime, info[i], CJS_Value::VT_unknown)); 452 parameters.push_back(CJS_Value(pRuntime, info[i], CJS_Value::VT_unknown));
451 } 453 }
452 CJS_Value valueRes(pRuntime); 454 CJS_Value valueRes(pRuntime);
453 CFX_WideString sError; 455 CFX_WideString sError;
454 if (!(*F)(pContext, parameters, valueRes, sError)) { 456 if (!(*F)(pContext, parameters, valueRes, sError)) {
455 FXJS_Error(pRuntime->GetIsolate(), 457 FXJS_Error(pRuntime->GetIsolate(),
456 JSFormatErrorString(func_name_string, nullptr, sError)); 458 JSFormatErrorString(func_name_string, nullptr, sError));
457 return; 459 return;
458 } 460 }
(...skipping 22 matching lines...) Expand all
481 for (size_t i = 0; i < FX_ArraySize(global_methods) - 1; ++i) { \ 483 for (size_t i = 0; i < FX_ArraySize(global_methods) - 1; ++i) { \
482 FXJS_DefineGlobalMethod(pIsolate, \ 484 FXJS_DefineGlobalMethod(pIsolate, \
483 js_class_name::global_methods[i].pName, \ 485 js_class_name::global_methods[i].pName, \
484 js_class_name::global_methods[i].pMethodCall); \ 486 js_class_name::global_methods[i].pMethodCall); \
485 } \ 487 } \
486 } 488 }
487 489
488 CJS_Value::Type GET_VALUE_TYPE(v8::Local<v8::Value> p); 490 CJS_Value::Type GET_VALUE_TYPE(v8::Local<v8::Value> p);
489 491
490 #endif // FPDFSDK_SRC_JAVASCRIPT_JS_DEFINE_H_ 492 #endif // FPDFSDK_SRC_JAVASCRIPT_JS_DEFINE_H_
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/Field.cpp ('k') | fpdfsdk/src/javascript/JS_Value.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698