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

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

Issue 2453683011: Remove FX_BOOL from fpdfsdk. (Closed)
Patch Set: Regenerate patch after rebase. Created 4 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/javascript/Icon.cpp ('k') | fpdfsdk/javascript/JS_EventHandler.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_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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 JSMethodSpec js_class_name::JS_Class_Methods[] = { 63 JSMethodSpec js_class_name::JS_Class_Methods[] = {
64 #define JS_STATIC_METHOD_ENTRY(method_name) \ 64 #define JS_STATIC_METHOD_ENTRY(method_name) \
65 { JS_WIDESTRING(method_name), method_name##_static } \ 65 { JS_WIDESTRING(method_name), method_name##_static } \
66 , 66 ,
67 67
68 #define END_JS_STATIC_METHOD() \ 68 #define END_JS_STATIC_METHOD() \
69 { 0, 0 } \ 69 { 0, 0 } \
70 } \ 70 } \
71 ; // NOLINT 71 ; // NOLINT
72 72
73 template <class C, 73 template <class C, bool (C::*M)(IJS_Context*, CJS_PropValue&, CFX_WideString&)>
74 FX_BOOL (C::*M)(IJS_Context*, CJS_PropValue&, CFX_WideString&)>
75 void JSPropGetter(const char* prop_name_string, 74 void JSPropGetter(const char* prop_name_string,
76 const char* class_name_string, 75 const char* class_name_string,
77 v8::Local<v8::String> property, 76 v8::Local<v8::String> property,
78 const v8::PropertyCallbackInfo<v8::Value>& info) { 77 const v8::PropertyCallbackInfo<v8::Value>& info) {
79 CJS_Runtime* pRuntime = 78 CJS_Runtime* pRuntime =
80 CJS_Runtime::CurrentRuntimeFromIsolate(info.GetIsolate()); 79 CJS_Runtime::CurrentRuntimeFromIsolate(info.GetIsolate());
81 if (!pRuntime) 80 if (!pRuntime)
82 return; 81 return;
83 CJS_Object* pJSObj = 82 CJS_Object* pJSObj =
84 static_cast<CJS_Object*>(pRuntime->GetObjectPrivate(info.Holder())); 83 static_cast<CJS_Object*>(pRuntime->GetObjectPrivate(info.Holder()));
85 C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); 84 C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
86 CFX_WideString sError; 85 CFX_WideString sError;
87 CJS_PropValue value(pRuntime); 86 CJS_PropValue value(pRuntime);
88 value.StartGetting(); 87 value.StartGetting();
89 if (!(pObj->*M)(pRuntime->GetCurrentContext(), value, sError)) { 88 if (!(pObj->*M)(pRuntime->GetCurrentContext(), value, sError)) {
90 pRuntime->Error( 89 pRuntime->Error(
91 JSFormatErrorString(class_name_string, prop_name_string, sError)); 90 JSFormatErrorString(class_name_string, prop_name_string, sError));
92 return; 91 return;
93 } 92 }
94 info.GetReturnValue().Set(value.GetJSValue()->ToV8Value(pRuntime)); 93 info.GetReturnValue().Set(value.GetJSValue()->ToV8Value(pRuntime));
95 } 94 }
96 95
97 template <class C, 96 template <class C, bool (C::*M)(IJS_Context*, CJS_PropValue&, CFX_WideString&)>
98 FX_BOOL (C::*M)(IJS_Context*, CJS_PropValue&, CFX_WideString&)>
99 void JSPropSetter(const char* prop_name_string, 97 void JSPropSetter(const char* prop_name_string,
100 const char* class_name_string, 98 const char* class_name_string,
101 v8::Local<v8::String> property, 99 v8::Local<v8::String> property,
102 v8::Local<v8::Value> value, 100 v8::Local<v8::Value> value,
103 const v8::PropertyCallbackInfo<void>& info) { 101 const v8::PropertyCallbackInfo<void>& info) {
104 CJS_Runtime* pRuntime = 102 CJS_Runtime* pRuntime =
105 CJS_Runtime::CurrentRuntimeFromIsolate(info.GetIsolate()); 103 CJS_Runtime::CurrentRuntimeFromIsolate(info.GetIsolate());
106 if (!pRuntime) 104 if (!pRuntime)
107 return; 105 return;
108 CJS_Object* pJSObj = 106 CJS_Object* pJSObj =
(...skipping 16 matching lines...) Expand all
125 property, info); \ 123 property, info); \
126 } \ 124 } \
127 static void set_##prop_name##_static( \ 125 static void set_##prop_name##_static( \
128 v8::Local<v8::String> property, v8::Local<v8::Value> value, \ 126 v8::Local<v8::String> property, v8::Local<v8::Value> value, \
129 const v8::PropertyCallbackInfo<void>& info) { \ 127 const v8::PropertyCallbackInfo<void>& info) { \
130 JSPropSetter<class_name, &class_name::prop_name>(#prop_name, #class_name, \ 128 JSPropSetter<class_name, &class_name::prop_name>(#prop_name, #class_name, \
131 property, value, info); \ 129 property, value, info); \
132 } 130 }
133 131
134 template <class C, 132 template <class C,
135 FX_BOOL (C::*M)(IJS_Context*, 133 bool (C::*M)(IJS_Context*,
136 const std::vector<CJS_Value>&, 134 const std::vector<CJS_Value>&,
137 CJS_Value&, 135 CJS_Value&,
138 CFX_WideString&)> 136 CFX_WideString&)>
139 void JSMethod(const char* method_name_string, 137 void JSMethod(const char* method_name_string,
140 const char* class_name_string, 138 const char* class_name_string,
141 const v8::FunctionCallbackInfo<v8::Value>& info) { 139 const v8::FunctionCallbackInfo<v8::Value>& info) {
142 CJS_Runtime* pRuntime = 140 CJS_Runtime* pRuntime =
143 CJS_Runtime::CurrentRuntimeFromIsolate(info.GetIsolate()); 141 CJS_Runtime::CurrentRuntimeFromIsolate(info.GetIsolate());
144 if (!pRuntime) 142 if (!pRuntime)
145 return; 143 return;
146 std::vector<CJS_Value> parameters; 144 std::vector<CJS_Value> parameters;
147 for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) { 145 for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) {
148 parameters.push_back(CJS_Value(pRuntime, info[i])); 146 parameters.push_back(CJS_Value(pRuntime, info[i]));
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 v8::Local<v8::String> property, 348 v8::Local<v8::String> property,
351 const v8::PropertyCallbackInfo<v8::Integer>& info) { 349 const v8::PropertyCallbackInfo<v8::Integer>& info) {
352 CJS_Runtime* pRuntime = 350 CJS_Runtime* pRuntime =
353 CJS_Runtime::CurrentRuntimeFromIsolate(info.GetIsolate()); 351 CJS_Runtime::CurrentRuntimeFromIsolate(info.GetIsolate());
354 v8::String::Utf8Value utf8_value(property); 352 v8::String::Utf8Value utf8_value(property);
355 CFX_WideString propname = CFX_WideString::FromUTF8( 353 CFX_WideString propname = CFX_WideString::FromUTF8(
356 CFX_ByteStringC(*utf8_value, utf8_value.length())); 354 CFX_ByteStringC(*utf8_value, utf8_value.length()));
357 CJS_Object* pJSObj = 355 CJS_Object* pJSObj =
358 static_cast<CJS_Object*>(pRuntime->GetObjectPrivate(info.Holder())); 356 static_cast<CJS_Object*>(pRuntime->GetObjectPrivate(info.Holder()));
359 Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject()); 357 Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
360 FX_BOOL bRet = pObj->QueryProperty(propname.c_str()); 358 bool bRet = pObj->QueryProperty(propname.c_str());
361 info.GetReturnValue().Set(bRet ? 4 : 0); 359 info.GetReturnValue().Set(bRet ? 4 : 0);
362 } 360 }
363 361
364 template <class Alt> 362 template <class Alt>
365 void JSSpecialPropGet(const char* class_name, 363 void JSSpecialPropGet(const char* class_name,
366 v8::Local<v8::String> property, 364 v8::Local<v8::String> property,
367 const v8::PropertyCallbackInfo<v8::Value>& info) { 365 const v8::PropertyCallbackInfo<v8::Value>& info) {
368 CJS_Runtime* pRuntime = 366 CJS_Runtime* pRuntime =
369 CJS_Runtime::CurrentRuntimeFromIsolate(info.GetIsolate()); 367 CJS_Runtime::CurrentRuntimeFromIsolate(info.GetIsolate());
370 if (!pRuntime) 368 if (!pRuntime)
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 CFX_ByteStringC(*utf8_value, utf8_value.length())); 424 CFX_ByteStringC(*utf8_value, utf8_value.length()));
427 CFX_WideString sError; 425 CFX_WideString sError;
428 if (!pObj->DelProperty(pRuntime->GetCurrentContext(), propname.c_str(), 426 if (!pObj->DelProperty(pRuntime->GetCurrentContext(), propname.c_str(),
429 sError)) { 427 sError)) {
430 CFX_ByteString cbName; 428 CFX_ByteString cbName;
431 cbName.Format("%s.%s", class_name, "DelProperty"); 429 cbName.Format("%s.%s", class_name, "DelProperty");
432 // Probably a missing call to JSFX_Error(). 430 // Probably a missing call to JSFX_Error().
433 } 431 }
434 } 432 }
435 433
436 template <FX_BOOL (*F)(IJS_Context*, 434 template <bool (*F)(IJS_Context*,
437 const std::vector<CJS_Value>&, 435 const std::vector<CJS_Value>&,
438 CJS_Value&, 436 CJS_Value&,
439 CFX_WideString&)> 437 CFX_WideString&)>
440 void JSGlobalFunc(const char* func_name_string, 438 void JSGlobalFunc(const char* func_name_string,
441 const v8::FunctionCallbackInfo<v8::Value>& info) { 439 const v8::FunctionCallbackInfo<v8::Value>& info) {
442 CJS_Runtime* pRuntime = 440 CJS_Runtime* pRuntime =
443 CJS_Runtime::CurrentRuntimeFromIsolate(info.GetIsolate()); 441 CJS_Runtime::CurrentRuntimeFromIsolate(info.GetIsolate());
444 if (!pRuntime) 442 if (!pRuntime)
445 return; 443 return;
446 std::vector<CJS_Value> parameters; 444 std::vector<CJS_Value> parameters;
447 for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) { 445 for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) {
448 parameters.push_back(CJS_Value(pRuntime, info[i])); 446 parameters.push_back(CJS_Value(pRuntime, info[i]));
449 } 447 }
(...skipping 26 matching lines...) Expand all
476 #define IMPLEMENT_JS_STATIC_GLOBAL_FUN(js_class_name) \ 474 #define IMPLEMENT_JS_STATIC_GLOBAL_FUN(js_class_name) \
477 void js_class_name::DefineJSObjects(CFXJS_Engine* pEngine) { \ 475 void js_class_name::DefineJSObjects(CFXJS_Engine* pEngine) { \
478 for (size_t i = 0; i < FX_ArraySize(global_methods) - 1; ++i) { \ 476 for (size_t i = 0; i < FX_ArraySize(global_methods) - 1; ++i) { \
479 pEngine->DefineGlobalMethod( \ 477 pEngine->DefineGlobalMethod( \
480 js_class_name::global_methods[i].pName, \ 478 js_class_name::global_methods[i].pName, \
481 js_class_name::global_methods[i].pMethodCall); \ 479 js_class_name::global_methods[i].pMethodCall); \
482 } \ 480 } \
483 } 481 }
484 482
485 #endif // FPDFSDK_JAVASCRIPT_JS_DEFINE_H_ 483 #endif // FPDFSDK_JAVASCRIPT_JS_DEFINE_H_
OLDNEW
« no previous file with comments | « fpdfsdk/javascript/Icon.cpp ('k') | fpdfsdk/javascript/JS_EventHandler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698