summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/javascript/Consts.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-09-11 08:35:03 -0700
committerTom Sepez <tsepez@chromium.org>2015-09-11 08:35:03 -0700
commit570875c067ab1b4c81fac2cfe908f867d3979d3a (patch)
tree0f238dc0696073dbb2899e593879861b814fd408 /fpdfsdk/src/javascript/Consts.cpp
parent87d76b5453e9de46dc0469fe3597eae7d888c411 (diff)
downloadpdfium-570875c067ab1b4c81fac2cfe908f867d3979d3a.tar.xz
Merge to XFA: Rename Init methods to more accurately describe purpose
(cherry picked from commit df4de98c06075b0e491ac645f2d118a6813cedc9) Trivial manual merges in fpdfsdk/include/javascript/JS_Runtime.h fpdfsdk/src/javascript/JS_Runtime.cpp Original Review URL: https://codereview.chromium.org/1335763002 . TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1334313002 .
Diffstat (limited to 'fpdfsdk/src/javascript/Consts.cpp')
-rw-r--r--fpdfsdk/src/javascript/Consts.cpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/fpdfsdk/src/javascript/Consts.cpp b/fpdfsdk/src/javascript/Consts.cpp
index 77cf445d77..b534d2b393 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*"};