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

Side by Side Diff: fpdfsdk/src/javascript/Consts.cpp

Issue 1335763002: Rename Init methods to more accurately describe purpose (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Also move some macros out of header. Created 5 years, 3 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 | « fpdfsdk/include/javascript/JS_Runtime.h ('k') | fpdfsdk/src/javascript/JS_Runtime.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 #include "../../include/javascript/JavaScript.h" 7 #include "../../include/javascript/JavaScript.h"
8 #include "../../include/javascript/IJavaScript.h" 8 #include "../../include/javascript/IJavaScript.h"
9 #include "../../include/javascript/JS_Define.h" 9 #include "../../include/javascript/JS_Define.h"
10 #include "../../include/javascript/JS_Object.h" 10 #include "../../include/javascript/JS_Object.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 JS_STATIC_CONST_ENTRY_STRING(L"fitP", L"FitPage") 120 JS_STATIC_CONST_ENTRY_STRING(L"fitP", L"FitPage")
121 JS_STATIC_CONST_ENTRY_STRING(L"fitW", L"FitWidth") 121 JS_STATIC_CONST_ENTRY_STRING(L"fitW", L"FitWidth")
122 JS_STATIC_CONST_ENTRY_STRING(L"fitH", L"FitHeight") 122 JS_STATIC_CONST_ENTRY_STRING(L"fitH", L"FitHeight")
123 JS_STATIC_CONST_ENTRY_STRING(L"fitV", L"FitVisibleWidth") 123 JS_STATIC_CONST_ENTRY_STRING(L"fitV", L"FitVisibleWidth")
124 JS_STATIC_CONST_ENTRY_STRING(L"pref", L"Preferred") 124 JS_STATIC_CONST_ENTRY_STRING(L"pref", L"Preferred")
125 JS_STATIC_CONST_ENTRY_STRING(L"refW", L"ReflowWidth") 125 JS_STATIC_CONST_ENTRY_STRING(L"refW", L"ReflowWidth")
126 END_JS_STATIC_CONST() 126 END_JS_STATIC_CONST()
127 127
128 IMPLEMENT_JS_CLASS_CONST(CJS_Zoomtype, zoomtype) 128 IMPLEMENT_JS_CLASS_CONST(CJS_Zoomtype, zoomtype)
129 129
130 /* ------------------------------ CJS_GlobalConsts 130 /* ------------------------------ CJS_GlobalConsts ------------------------- */
131 * ------------------------------ */
132 131
133 int CJS_GlobalConsts::Init(v8::Isolate* pIsolate) { 132 #define DEFINE_GLOBAL_CONST(pIsolate, const_name, const_value) \
133 if (JS_DefineGlobalConst( \
134 pIsolate, JS_WIDESTRING(const_name), \
135 JS_NewString(pIsolate, JS_WIDESTRING(const_value)))) \
136 return -1
Lei Zhang 2015/09/10 23:15:38 indent the returns if clang-format is willing?
Tom Sepez 2015/09/10 23:29:20 Grrrr. Not-willing. Lemme see what { } do.
137
138 int CJS_GlobalConsts::DefineJSObjects(v8::Isolate* pIsolate) {
134 DEFINE_GLOBAL_CONST(pIsolate, IDS_GREATER_THAN, Invalid value 139 DEFINE_GLOBAL_CONST(pIsolate, IDS_GREATER_THAN, Invalid value
135 : must be greater than or equal to % s.); 140 : must be greater than or equal to % s.);
136 DEFINE_GLOBAL_CONST( 141 DEFINE_GLOBAL_CONST(
137 pIsolate, IDS_GT_AND_LT, Invalid value 142 pIsolate, IDS_GT_AND_LT, Invalid value
138 : must be greater than or equal to % s and less than or equal to % s.); 143 : must be greater than or equal to % s and less than or equal to % s.);
139 DEFINE_GLOBAL_CONST(pIsolate, IDS_LESS_THAN, Invalid value 144 DEFINE_GLOBAL_CONST(pIsolate, IDS_LESS_THAN, Invalid value
140 : must be less than or equal to % s.); 145 : must be less than or equal to % s.);
141 DEFINE_GLOBAL_CONST(pIsolate, IDS_INVALID_MONTH, **Invalid**); 146 DEFINE_GLOBAL_CONST(pIsolate, IDS_INVALID_MONTH, **Invalid**);
142 DEFINE_GLOBAL_CONST(pIsolate, IDS_INVALID_DATE, Invalid date / time 147 DEFINE_GLOBAL_CONST(pIsolate, IDS_INVALID_DATE, Invalid date / time
143 : please ensure that the date / time exists.Field); 148 : please ensure that the date / time exists.Field);
144 DEFINE_GLOBAL_CONST(pIsolate, IDS_INVALID_VALUE, 149 DEFINE_GLOBAL_CONST(pIsolate, IDS_INVALID_VALUE,
145 The value entered does not match the format of the field); 150 The value entered does not match the format of the field);
146 DEFINE_GLOBAL_CONST(pIsolate, IDS_AM, am); 151 DEFINE_GLOBAL_CONST(pIsolate, IDS_AM, am);
147 DEFINE_GLOBAL_CONST(pIsolate, IDS_PM, pm); 152 DEFINE_GLOBAL_CONST(pIsolate, IDS_PM, pm);
148 DEFINE_GLOBAL_CONST( 153 DEFINE_GLOBAL_CONST(
149 pIsolate, IDS_MONTH_INFO, 154 pIsolate, IDS_MONTH_INFO,
150 January[1] February[2] March[3] April[4] May[5] June[6] July[7] August 155 January[1] February[2] March[3] April[4] May[5] June[6] July[7] August
151 [8] September[9] October[10] November[11] December[12] Sept[9] Jan 156 [8] September[9] October[10] November[11] December[12] Sept[9] Jan
152 [1] Feb[2] Mar[3] Apr[4] Jun[6] Jul[7] Aug[8] Sep[9] Oct[10] Nov 157 [1] Feb[2] Mar[3] Apr[4] Jun[6] Jul[7] Aug[8] Sep[9] Oct[10] Nov
153 [11] Dec[12]); 158 [11] Dec[12]);
154 DEFINE_GLOBAL_CONST(pIsolate, IDS_STARTUP_CONSOLE_MSG, ** ^ _ ^ **); 159 DEFINE_GLOBAL_CONST(pIsolate, IDS_STARTUP_CONSOLE_MSG, ** ^ _ ^ **);
155 160
156 return 0; 161 return 0;
157 } 162 }
158 163
159 /* ------------------------------ CJS_GlobalArrays 164 /* ------------------------------ CJS_GlobalArrays ------------------------ */
160 * ------------------------------ */
161 165
162 int CJS_GlobalArrays::Init(v8::Isolate* pIsolate) { 166 #define DEFINE_GLOBAL_ARRAY(pIsolate) \
167 int size = FX_ArraySize(ArrayContent); \
168 \
169 CJS_Array array(pIsolate); \
170 for (int i = 0; i < size; i++) \
171 array.SetElement(i, CJS_Value(pIsolate, ArrayContent[i])); \
172 \
173 CJS_PropValue prop(pIsolate); \
174 prop << array; \
175 if (JS_DefineGlobalConst(pIsolate, (const wchar_t*)ArrayName, \
176 prop.ToV8Value()) < 0) \
177 return -1
178
179 int CJS_GlobalArrays::DefineJSObjects(v8::Isolate* pIsolate) {
163 { 180 {
164 const FX_WCHAR* ArrayName = L"RE_NUMBER_ENTRY_DOT_SEP"; 181 const FX_WCHAR* ArrayName = L"RE_NUMBER_ENTRY_DOT_SEP";
165 const FX_WCHAR* ArrayContent[] = {L"[+-]?\\d*\\.?\\d*"}; 182 const FX_WCHAR* ArrayContent[] = {L"[+-]?\\d*\\.?\\d*"};
166 DEFINE_GLOBAL_ARRAY(pIsolate); 183 DEFINE_GLOBAL_ARRAY(pIsolate);
167 } 184 }
168 185
169 { 186 {
170 const FX_WCHAR* ArrayName = L"RE_NUMBER_COMMIT_DOT_SEP"; 187 const FX_WCHAR* ArrayName = L"RE_NUMBER_COMMIT_DOT_SEP";
171 const FX_WCHAR* ArrayContent[] = { 188 const FX_WCHAR* ArrayContent[] = {
172 L"[+-]?\\d+(\\.\\d+)?", /* -1.0 or -1 */ 189 L"[+-]?\\d+(\\.\\d+)?", /* -1.0 or -1 */
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 272
256 { 273 {
257 const FX_WCHAR* ArrayName = L"RE_SSN_COMMIT"; 274 const FX_WCHAR* ArrayName = L"RE_SSN_COMMIT";
258 const FX_WCHAR* ArrayContent[] = { 275 const FX_WCHAR* ArrayContent[] = {
259 L"\\d{3}(\\.|[- ])?\\d{2}(\\.|[- ])?\\d{4}"}; 276 L"\\d{3}(\\.|[- ])?\\d{2}(\\.|[- ])?\\d{4}"};
260 DEFINE_GLOBAL_ARRAY(pIsolate); 277 DEFINE_GLOBAL_ARRAY(pIsolate);
261 } 278 }
262 279
263 return 0; 280 return 0;
264 } 281 }
OLDNEW
« no previous file with comments | « fpdfsdk/include/javascript/JS_Runtime.h ('k') | fpdfsdk/src/javascript/JS_Runtime.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698