From f6ca07b3fda40f0c5d5690caad8ac931cb46ccf6 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 1 Jun 2017 09:17:18 -0700 Subject: Replace some repeated code with existing CFXJS_Engine::NewString() helper. In turn, fix type information for New*() return values. In turn, resolve some ambiguity in a ? operator expression. Change-Id: I45c31d81f815b11590b46dacc8060d8e489dde5c Reviewed-on: https://pdfium-review.googlesource.com/6131 Commit-Queue: Tom Sepez Reviewed-by: dsinclair --- fpdfsdk/javascript/JS_Define.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'fpdfsdk/javascript') diff --git a/fpdfsdk/javascript/JS_Define.h b/fpdfsdk/javascript/JS_Define.h index fb901dc714..f360e8f6b9 100644 --- a/fpdfsdk/javascript/JS_Define.h +++ b/fpdfsdk/javascript/JS_Define.h @@ -173,14 +173,15 @@ void JSMethod(const char* method_name_string, static JSConstSpec ConstSpecs[]; \ static void DefineConsts(CFXJS_Engine* pEngine); -#define IMPLEMENT_JS_CLASS_CONST_PART(js_class_name, class_name) \ - void js_class_name::DefineConsts(CFXJS_Engine* pEngine) { \ - for (size_t i = 0; i < FX_ArraySize(ConstSpecs) - 1; ++i) { \ - pEngine->DefineObjConst(g_nObjDefnID, ConstSpecs[i].pName, \ - ConstSpecs[i].eType == JSConstSpec::Number \ - ? pEngine->NewNumber(ConstSpecs[i].number) \ - : pEngine->NewString(ConstSpecs[i].pStr)); \ - } \ +#define IMPLEMENT_JS_CLASS_CONST_PART(js_class_name, class_name) \ + void js_class_name::DefineConsts(CFXJS_Engine* pEngine) { \ + for (size_t i = 0; i < FX_ArraySize(ConstSpecs) - 1; ++i) { \ + pEngine->DefineObjConst( \ + g_nObjDefnID, ConstSpecs[i].pName, \ + ConstSpecs[i].eType == JSConstSpec::Number \ + ? pEngine->NewNumber(ConstSpecs[i].number).As() \ + : pEngine->NewString(ConstSpecs[i].pStr).As()); \ + } \ } // Convenience macros for declaring classes without an alternate. -- cgit v1.2.3