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

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

Issue 1334313002: Merge to XFA: Rename Init methods to more accurately describe purpose (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: 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; \
137 }
138
139 int CJS_GlobalConsts::DefineJSObjects(v8::Isolate* pIsolate) {
134 DEFINE_GLOBAL_CONST(pIsolate, IDS_GREATER_THAN, Invalid value 140 DEFINE_GLOBAL_CONST(pIsolate, IDS_GREATER_THAN, Invalid value
135 : must be greater than or equal to % s.); 141 : must be greater than or equal to % s.);
136 DEFINE_GLOBAL_CONST( 142 DEFINE_GLOBAL_CONST(
137 pIsolate, IDS_GT_AND_LT, Invalid value 143 pIsolate, IDS_GT_AND_LT, Invalid value
138 : must be greater than or equal to % s and less than or equal to % s.); 144 : 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 145 DEFINE_GLOBAL_CONST(pIsolate, IDS_LESS_THAN, Invalid value
140 : must be less than or equal to % s.); 146 : must be less than or equal to % s.);
141 DEFINE_GLOBAL_CONST(pIsolate, IDS_INVALID_MONTH, **Invalid**); 147 DEFINE_GLOBAL_CONST(pIsolate, IDS_INVALID_MONTH, **Invalid**);
142 DEFINE_GLOBAL_CONST(pIsolate, IDS_INVALID_DATE, Invalid date / time 148 DEFINE_GLOBAL_CONST(pIsolate, IDS_INVALID_DATE, Invalid date / time
143 : please ensure that the date / time exists.Field); 149 : please ensure that the date / time exists.Field);
144 DEFINE_GLOBAL_CONST(pIsolate, IDS_INVALID_VALUE, 150 DEFINE_GLOBAL_CONST(pIsolate, IDS_INVALID_VALUE,
145 The value entered does not match the format of the field); 151 The value entered does not match the format of the field);
146 DEFINE_GLOBAL_CONST(pIsolate, IDS_AM, am); 152 DEFINE_GLOBAL_CONST(pIsolate, IDS_AM, am);
147 DEFINE_GLOBAL_CONST(pIsolate, IDS_PM, pm); 153 DEFINE_GLOBAL_CONST(pIsolate, IDS_PM, pm);
148 DEFINE_GLOBAL_CONST( 154 DEFINE_GLOBAL_CONST(
149 pIsolate, IDS_MONTH_INFO, 155 pIsolate, IDS_MONTH_INFO,
150 January[1] February[2] March[3] April[4] May[5] June[6] July[7] August 156 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 157 [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 158 [1] Feb[2] Mar[3] Apr[4] Jun[6] Jul[7] Aug[8] Sep[9] Oct[10] Nov
153 [11] Dec[12]); 159 [11] Dec[12]);
154 DEFINE_GLOBAL_CONST(pIsolate, IDS_STARTUP_CONSOLE_MSG, ** ^ _ ^ **); 160 DEFINE_GLOBAL_CONST(pIsolate, IDS_STARTUP_CONSOLE_MSG, ** ^ _ ^ **);
155 161
156 return 0; 162 return 0;
157 } 163 }
158 164
159 /* ------------------------------ CJS_GlobalArrays 165 /* ------------------------------ CJS_GlobalArrays ------------------------ */
160 * ------------------------------ */
161 166
162 int CJS_GlobalArrays::Init(v8::Isolate* pIsolate) { 167 #define DEFINE_GLOBAL_ARRAY(pIsolate) \
168 int size = FX_ArraySize(ArrayContent); \
169 \
170 CJS_Array array(pIsolate); \
171 for (int i = 0; i < size; i++) \
172 array.SetElement(i, CJS_Value(pIsolate, ArrayContent[i])); \
173 \
174 CJS_PropValue prop(pIsolate); \
175 prop << array; \
176 if (JS_DefineGlobalConst(pIsolate, (const wchar_t*)ArrayName, \
177 prop.ToV8Value()) < 0) { \
178 return -1; \
179 }
180
181 int CJS_GlobalArrays::DefineJSObjects(v8::Isolate* pIsolate) {
163 { 182 {
164 const FX_WCHAR* ArrayName = L"RE_NUMBER_ENTRY_DOT_SEP"; 183 const FX_WCHAR* ArrayName = L"RE_NUMBER_ENTRY_DOT_SEP";
165 const FX_WCHAR* ArrayContent[] = {L"[+-]?\\d*\\.?\\d*"}; 184 const FX_WCHAR* ArrayContent[] = {L"[+-]?\\d*\\.?\\d*"};
166 DEFINE_GLOBAL_ARRAY(pIsolate); 185 DEFINE_GLOBAL_ARRAY(pIsolate);
167 } 186 }
168 187
169 { 188 {
170 const FX_WCHAR* ArrayName = L"RE_NUMBER_COMMIT_DOT_SEP"; 189 const FX_WCHAR* ArrayName = L"RE_NUMBER_COMMIT_DOT_SEP";
171 const FX_WCHAR* ArrayContent[] = { 190 const FX_WCHAR* ArrayContent[] = {
172 L"[+-]?\\d+(\\.\\d+)?", /* -1.0 or -1 */ 191 L"[+-]?\\d+(\\.\\d+)?", /* -1.0 or -1 */
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 274
256 { 275 {
257 const FX_WCHAR* ArrayName = L"RE_SSN_COMMIT"; 276 const FX_WCHAR* ArrayName = L"RE_SSN_COMMIT";
258 const FX_WCHAR* ArrayContent[] = { 277 const FX_WCHAR* ArrayContent[] = {
259 L"\\d{3}(\\.|[- ])?\\d{2}(\\.|[- ])?\\d{4}"}; 278 L"\\d{3}(\\.|[- ])?\\d{2}(\\.|[- ])?\\d{4}"};
260 DEFINE_GLOBAL_ARRAY(pIsolate); 279 DEFINE_GLOBAL_ARRAY(pIsolate);
261 } 280 }
262 281
263 return 0; 282 return 0;
264 } 283 }
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