From 2da7bd4d78897bed52fe1304694f4e970db65e58 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 17 Feb 2015 13:21:34 -0800 Subject: Tidy up JS_Defines.h This is a purely mechanical change, no new functionality. - Expand some macros which were merely a short-cut to save typing but reduced transparency. - Put GET_VALUE_TYPE() implementation into a .cpp file. This is a portion of the patch from issue 908033002 at patchset 40001 (http://crrev.com/908033002#ps40001) R=brucedawson@chromium.org Review URL: https://codereview.chromium.org/927263003 --- fpdfsdk/include/javascript/JS_Define.h | 69 +++++----------------------------- 1 file changed, 9 insertions(+), 60 deletions(-) (limited to 'fpdfsdk/include/javascript/JS_Define.h') diff --git a/fpdfsdk/include/javascript/JS_Define.h b/fpdfsdk/include/javascript/JS_Define.h index 9a51f69c81..650bef0e0a 100644 --- a/fpdfsdk/include/javascript/JS_Define.h +++ b/fpdfsdk/include/javascript/JS_Define.h @@ -46,8 +46,6 @@ typedef CFX_WideString JS_ErrorString; /* ====================================== PUBLIC DEFINE SPEC ============================================== */ #define JS_WIDESTRING(widestring) L###widestring -#define OBJ_PROP_PARAMS IFXJS_Context* cc, CJS_PropValue& vp, JS_ErrorString& sError -#define OBJ_METHOD_PARAMS IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, JS_ErrorString& sError #define BEGIN_JS_STATIC_CONST(js_class_name) JSConstSpec js_class_name::JS_Class_Consts[] = { #define JS_STATIC_CONST_ENTRY_NUMBER(const_name, pValue) {JS_WIDESTRING(const_name), pValue, L"", 0}, #define JS_STATIC_CONST_ENTRY_STRING(const_name, pValue) {JS_WIDESTRING(const_name), 0, JS_WIDESTRING(pValue), 1}, @@ -89,7 +87,8 @@ typedef CFX_WideString JS_ErrorString; /* ======================================== PROP CALLBACK ============================================ */ #define JS_STATIC_PROP_GET(prop_name, class_name)\ - static void get_##prop_name##_static(JS_PROPGET_ARGS)\ + static void get_##prop_name##_static(v8::Local property, \ + const v8::PropertyCallbackInfo& info) \ {\ v8::Isolate* isolate = info.GetIsolate();\ v8::Local context = isolate->GetCurrentContext();\ @@ -125,7 +124,9 @@ typedef CFX_WideString JS_ErrorString; } #define JS_STATIC_PROP_SET(prop_name, class_name)\ - static void set_##prop_name##_static(JS_PROPPUT_ARGS)\ + static void set_##prop_name##_static(v8::Local property, \ + v8::Local value, \ + const v8::PropertyCallbackInfo& info) \ {\ v8::Isolate* isolate = info.GetIsolate();\ v8::Local context = isolate->GetCurrentContext();\ @@ -166,7 +167,7 @@ JS_STATIC_PROP_SET(prop_name, class_name) /* ========================================= METHOD CALLBACK =========================================== */ #define JS_STATIC_METHOD(method_name, class_name)\ - static void method_name##_static(JS_METHOD_ARGS)\ + static void method_name##_static(const v8::FunctionCallbackInfo& info) \ {\ v8::Isolate* isolate = info.GetIsolate();\ v8::Local context = isolate->GetCurrentContext();\ @@ -521,7 +522,7 @@ void js_class_name::GetMethods(JSMethodSpec*& pMethods, int& nSize)\ } #define JS_SPECIAL_STATIC_METHOD(method_name, class_alternate, class_name)\ - static void method_name##_static(JS_METHOD_ARGS)\ + static void method_name##_static(const v8::FunctionCallbackInfo& info)\ {\ v8::Isolate* isolate = info.GetIsolate();\ v8::Local context = isolate->GetCurrentContext();\ @@ -564,7 +565,7 @@ void js_class_name::GetMethods(JSMethodSpec*& pMethods, int& nSize)\ /* ======================================== GLOBAL METHODS ============================================ */ #define JS_STATIC_GLOBAL_FUN(fun_name) \ -static void fun_name##_static(JS_METHOD_ARGS)\ +static void fun_name##_static(const v8::FunctionCallbackInfo& info)\ {\ v8::Isolate* isolate = info.GetIsolate();\ v8::Local context = isolate->GetCurrentContext();\ @@ -648,58 +649,6 @@ if (JS_DefineGlobalConst(pRuntime, (const wchar_t*)ArrayName, prop.ToJSValue()) #define CLASSNAME_DATE L"Date" #define CLASSNAME_STRING L"v8::String" -extern const unsigned int JSCONST_nStringHash; -extern const unsigned int JSCONST_nNumberHash; -extern const unsigned int JSCONST_nBoolHash; -extern const unsigned int JSCONST_nDateHash; -extern const unsigned int JSCONST_nObjectHash; -extern const unsigned int JSCONST_nFXobjHash; -extern const unsigned int JSCONST_nNullHash; -extern const unsigned int JSCONST_nUndefHash; - -static FXJSVALUETYPE GET_VALUE_TYPE(v8::Handle p) -{ - - const unsigned int nHash = JS_CalcHash(JS_GetTypeof(p)); - - if (nHash == JSCONST_nUndefHash) - return VT_undefined; - else if (nHash == JSCONST_nNullHash) - return VT_null; - else if (nHash == JSCONST_nStringHash) - return VT_string; - else if (nHash == JSCONST_nNumberHash) - return VT_number; - else if (nHash == JSCONST_nBoolHash) - return VT_boolean; - else if (nHash == JSCONST_nDateHash) - return VT_date; - else if (nHash == JSCONST_nObjectHash) - return VT_object; - else if (nHash == JSCONST_nFXobjHash) - return VT_fxobject; - - /* - const char * sType = p->getTypeof()->toDchars(); - if (strcmp(sType,VALUE_NAME_STRING) == 0) - return VT_string; - else if (strcmp(sType,VALUE_NAME_NUMBER) == 0) - return VT_number; - else if (strcmp(sType,VALUE_NAME_BOOLEAN) == 0) - return VT_boolean; - else if (strcmp(sType,VALUE_NAME_DATE) == 0) - return VT_date; - else if (strcmp(sType,VALUE_NAME_OBJECT) == 0) - return VT_object; - else if (strcmp(sType,VALUE_NAME_FXOBJ) == 0) - return VT_object; - else if (strcmp(sType,VALUE_NAME_NULL) == 0) - return VT_null; - else if (strcmp(sType,VALUE_NAME_UNDEFINED) == 0) - return VT_undefined; - */ - - return VT_unknown; -} +FXJSVALUETYPE GET_VALUE_TYPE(v8::Handle p); #endif //_JS_DEFINE_H_ -- cgit v1.2.3