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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/src/javascript/Consts.cpp
diff --git a/fpdfsdk/src/javascript/Consts.cpp b/fpdfsdk/src/javascript/Consts.cpp
index 77cf445d77d9e2f6c6d9f4baa098af8760cfa74f..b534d2b393408e592a93566030732db63a74ed28 100644
--- a/fpdfsdk/src/javascript/Consts.cpp
+++ b/fpdfsdk/src/javascript/Consts.cpp
@@ -127,10 +127,16 @@ END_JS_STATIC_CONST()
IMPLEMENT_JS_CLASS_CONST(CJS_Zoomtype, zoomtype)
-/* ------------------------------ CJS_GlobalConsts
- * ------------------------------ */
+/* ------------------------------ CJS_GlobalConsts ------------------------- */
-int CJS_GlobalConsts::Init(v8::Isolate* pIsolate) {
+#define DEFINE_GLOBAL_CONST(pIsolate, const_name, const_value) \
+ if (JS_DefineGlobalConst( \
+ pIsolate, JS_WIDESTRING(const_name), \
+ JS_NewString(pIsolate, JS_WIDESTRING(const_value)))) { \
+ return -1; \
+ }
+
+int CJS_GlobalConsts::DefineJSObjects(v8::Isolate* pIsolate) {
DEFINE_GLOBAL_CONST(pIsolate, IDS_GREATER_THAN, Invalid value
: must be greater than or equal to % s.);
DEFINE_GLOBAL_CONST(
@@ -156,10 +162,23 @@ int CJS_GlobalConsts::Init(v8::Isolate* pIsolate) {
return 0;
}
-/* ------------------------------ CJS_GlobalArrays
- * ------------------------------ */
+/* ------------------------------ CJS_GlobalArrays ------------------------ */
+
+#define DEFINE_GLOBAL_ARRAY(pIsolate) \
+ int size = FX_ArraySize(ArrayContent); \
+ \
+ CJS_Array array(pIsolate); \
+ for (int i = 0; i < size; i++) \
+ array.SetElement(i, CJS_Value(pIsolate, ArrayContent[i])); \
+ \
+ CJS_PropValue prop(pIsolate); \
+ prop << array; \
+ if (JS_DefineGlobalConst(pIsolate, (const wchar_t*)ArrayName, \
+ prop.ToV8Value()) < 0) { \
+ return -1; \
+ }
-int CJS_GlobalArrays::Init(v8::Isolate* pIsolate) {
+int CJS_GlobalArrays::DefineJSObjects(v8::Isolate* pIsolate) {
{
const FX_WCHAR* ArrayName = L"RE_NUMBER_ENTRY_DOT_SEP";
const FX_WCHAR* ArrayContent[] = {L"[+-]?\\d*\\.?\\d*"};
« 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