Index: fpdfsdk/include/javascript/JS_Define.h |
diff --git a/fpdfsdk/include/javascript/JS_Define.h b/fpdfsdk/include/javascript/JS_Define.h |
index 9a51f69c8170f15ffbc6d283d64b88f904171ae4..819a4d0cb7413aa2abd993b343c90fafaf219821 100644 |
--- a/fpdfsdk/include/javascript/JS_Define.h |
+++ b/fpdfsdk/include/javascript/JS_Define.h |
@@ -12,6 +12,9 @@ typedef v8::Handle<v8::Object> JSObject; |
typedef v8::Handle<v8::Object> JSFXObject; |
typedef unsigned JSBool; |
+#include "JS_Object.h" |
+#include "JS_Value.h" |
+ |
struct JSConstSpec |
{ |
const wchar_t* pName; |
@@ -46,8 +49,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}, |
@@ -60,151 +61,125 @@ typedef CFX_WideString JS_ErrorString; |
#define BEGIN_JS_STATIC_METHOD(js_class_name) JSMethodSpec js_class_name::JS_Class_Methods[] = { |
#define JS_STATIC_METHOD_ENTRY(method_name, nargs) {JS_WIDESTRING(method_name), method_name##_static, nargs}, |
#define END_JS_STATIC_METHOD() {0, 0, 0}}; |
-#define MEMLEAKCHECK_1() ((void)0) |
-#define MEMLEAKCHECK_2(main_name, sub_name) ((void)0) |
- |
- |
-/* |
-#ifdef _DEBUG |
-#define MEMLEAKCHECK_1() \ |
- _CrtMemState state1;\ |
- _CrtMemCheckpoint(&state1); |
- |
-#define MEMLEAKCHECK_2(main_name,sub_name) \ |
- _CrtMemState state2;\ |
- _CrtMemCheckpoint(&state2);\ |
- _CrtMemState diff;\ |
- _CrtMemDifference(&diff,&state1,&state2);\ |
- if (diff.lSizes[_NORMAL_BLOCK] > 0)\ |
- {\ |
- TRACE("Detected normal block memory leaks in JS Module! [%s.%s]\n",#main_name,#sub_name);\ |
- _CrtMemDumpStatistics(&diff);\ |
- } |
-#else |
- #define MEMLEAKCHECK_1() ((void)0) |
- #define MEMLEAKCHECK_2(main_name,sub_name) ((void)0) |
-#endif |
-*/ |
/* ======================================== PROP CALLBACK ============================================ */ |
-#define JS_STATIC_PROP_GET(prop_name, class_name)\ |
- static void get_##prop_name##_static(JS_PROPGET_ARGS)\ |
-{\ |
- v8::Isolate* isolate = info.GetIsolate();\ |
- v8::Local<v8::Context> context = isolate->GetCurrentContext();\ |
- v8::Local<v8::Value> v = context->GetEmbedderData(1);\ |
- ASSERT(!v.IsEmpty());\ |
- if(v.IsEmpty()) return;\ |
- v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v);\ |
- IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\ |
- IFXJS_Context* cc = pRuntime->GetCurrentContext();\ |
- CJS_PropValue value(isolate);\ |
- value.StartGetting();\ |
- CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\ |
- ASSERT(pJSObj != NULL);\ |
- class_name* pObj = (class_name*)pJSObj->GetEmbedObject();\ |
- ASSERT(pObj != NULL);\ |
- JS_ErrorString sError;\ |
- FX_BOOL bRet = FALSE;\ |
- MEMLEAKCHECK_1();\ |
- bRet = pObj->prop_name(cc, value, sError);\ |
- MEMLEAKCHECK_2(class_name, prop_name);\ |
- if (bRet)\ |
- {\ |
- info.GetReturnValue().Set((v8::Handle<v8::Value>)value);\ |
- return ;\ |
- }\ |
- else\ |
- {\ |
- CFX_ByteString cbName;\ |
- cbName.Format("%s.%s", #class_name, #prop_name);\ |
- JS_Error(NULL,CFX_WideString::FromLocal(cbName), sError);\ |
- return ;\ |
- }\ |
+template <class C, FX_BOOL (C::*M)(IFXJS_Context* cc, CJS_PropValue& vp, JS_ErrorString& sError)> |
+void JSPropGetter(const char* prop_name_string, |
+ const char* class_name_string, |
+ v8::Local<v8::String> property, |
+ const v8::PropertyCallbackInfo<v8::Value>& info) { |
+ v8::Isolate* isolate = info.GetIsolate(); |
+ v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
+ v8::Local<v8::Value> v = context->GetEmbedderData(1); |
+ if (v.IsEmpty()) { |
brucedawson
2015/02/16 20:42:00
The assert/return was ambiguous in that it made it
|
+ return; |
+ } |
+ v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v); |
+ IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); |
+ IFXJS_Context* pContext = pRuntime->GetCurrentContext(); |
+ CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder()); |
+ C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); |
+ JS_ErrorString sError; |
+ CJS_PropValue value(isolate); |
+ value.StartGetting(); |
+ if (!(pObj->*M)(pContext, value, sError)) { |
+ CFX_ByteString cbName; |
+ cbName.Format("%s.%s", class_name_string, prop_name_string); |
+ JS_Error(NULL, CFX_WideString::FromLocal(cbName), sError); |
+ return; |
+ } |
+ info.GetReturnValue().Set((v8::Handle<v8::Value>)value); |
} |
-#define JS_STATIC_PROP_SET(prop_name, class_name)\ |
- static void set_##prop_name##_static(JS_PROPPUT_ARGS)\ |
-{\ |
- v8::Isolate* isolate = info.GetIsolate();\ |
- v8::Local<v8::Context> context = isolate->GetCurrentContext();\ |
- v8::Local<v8::Value> v = context->GetEmbedderData(1);\ |
- ASSERT(!v.IsEmpty());\ |
- if(v.IsEmpty()) return;\ |
- v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v);\ |
- IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\ |
- IFXJS_Context* cc = pRuntime->GetCurrentContext();\ |
- CJS_PropValue propValue(CJS_Value(isolate,value,VT_unknown));\ |
- propValue.StartSetting();\ |
- CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\ |
- ASSERT(pJSObj != NULL);\ |
- class_name* pObj = (class_name*)pJSObj->GetEmbedObject();\ |
- ASSERT(pObj != NULL);\ |
- JS_ErrorString sError;\ |
- FX_BOOL bRet = FALSE;\ |
- MEMLEAKCHECK_1();\ |
- bRet = pObj->prop_name(cc, propValue, sError);\ |
- MEMLEAKCHECK_2(class_name, prop_name);\ |
- if (bRet)\ |
- {\ |
- return ;\ |
- }\ |
- else\ |
- {\ |
- CFX_ByteString cbName;\ |
- cbName.Format("%s.%s", #class_name, #prop_name);\ |
- JS_Error(NULL,CFX_WideString::FromLocal(cbName), sError);\ |
- return ;\ |
- }\ |
+template <class C, FX_BOOL (C::*M)(IFXJS_Context* cc, CJS_PropValue& vp, JS_ErrorString& sError)> |
+void JSPropSetter(const char* prop_name_string, |
+ const char* class_name_string, |
+ v8::Local<v8::String> property, |
+ v8::Local<v8::Value> value, |
+ const v8::PropertyCallbackInfo<void>& info) { |
+ v8::Isolate* isolate = info.GetIsolate(); |
+ v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
+ v8::Local<v8::Value> v = context->GetEmbedderData(1); |
+ if (v.IsEmpty()) { |
+ return; |
+ } |
+ v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v); |
+ IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); |
+ IFXJS_Context* pContext = pRuntime->GetCurrentContext(); |
+ CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder()); |
+ C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); |
+ JS_ErrorString sError; |
+ CJS_PropValue propValue(CJS_Value(isolate, value, VT_unknown)); |
+ propValue.StartSetting(); |
+ if (!(pObj->*M)(pContext, propValue, sError)) { |
+ CFX_ByteString cbName; |
+ cbName.Format("%s.%s", class_name_string, prop_name_string); |
+ JS_Error(NULL, CFX_WideString::FromLocal(cbName), sError); |
+ } |
} |
-#define JS_STATIC_PROP(prop_name, class_name)\ |
-JS_STATIC_PROP_GET(prop_name, class_name);\ |
-JS_STATIC_PROP_SET(prop_name, class_name) |
+#define JS_STATIC_PROP(prop_name, class_name) \ |
+ static void get_##prop_name##_static( \ |
+ v8::Local<v8::String> property, \ |
+ const v8::PropertyCallbackInfo<v8::Value>& info) { \ |
+ JSPropGetter<class_name, &class_name::prop_name>( \ |
+ #prop_name, #class_name, property, info); \ |
+ } \ |
+ static void set_##prop_name##_static( \ |
+ v8::Local<v8::String> property, \ |
+ v8::Local<v8::Value> value, \ |
+ const v8::PropertyCallbackInfo<void>& info) { \ |
+ JSPropSetter<class_name, &class_name::prop_name>( \ |
+ #prop_name, #class_name, property, value, info); \ |
+ } |
/* ========================================= METHOD CALLBACK =========================================== */ |
-#define JS_STATIC_METHOD(method_name, class_name)\ |
- static void method_name##_static(JS_METHOD_ARGS)\ |
-{\ |
- v8::Isolate* isolate = info.GetIsolate();\ |
- v8::Local<v8::Context> context = isolate->GetCurrentContext();\ |
- v8::Local<v8::Value> v = context->GetEmbedderData(1);\ |
- ASSERT(!v.IsEmpty());\ |
- if(v.IsEmpty()) return;\ |
- v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v);\ |
- IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\ |
- IFXJS_Context* cc = pRuntime->GetCurrentContext();\ |
- CJS_Parameters parameters;\ |
- for (unsigned int i = 0; i<(unsigned int)info.Length(); i++)\ |
- {\ |
- parameters.push_back(CJS_Value(isolate, info[i], VT_unknown));\ |
- }\ |
- CJS_Value valueRes(isolate);\ |
- CJS_Object* pJSObj = (CJS_Object *)JS_GetPrivate(isolate,info.Holder());\ |
- ASSERT(pJSObj != NULL);\ |
- class_name* pObj = (class_name*)pJSObj->GetEmbedObject();\ |
- ASSERT(pObj != NULL);\ |
- JS_ErrorString sError;\ |
- FX_BOOL bRet = FALSE;\ |
- MEMLEAKCHECK_1();\ |
- bRet = pObj->method_name(cc, parameters, valueRes, sError);\ |
- MEMLEAKCHECK_2(class_name, method_name);\ |
- if (bRet)\ |
- {\ |
- info.GetReturnValue().Set(valueRes.ToJSValue());\ |
- return ;\ |
- }\ |
- else\ |
- {\ |
- CFX_ByteString cbName;\ |
- cbName.Format("%s.%s", #class_name, #method_name);\ |
- JS_Error(NULL, CFX_WideString::FromLocal(cbName), sError);\ |
- return ;\ |
- }\ |
+template <class C, FX_BOOL (C::*M)(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, JS_ErrorString& sError)> |
+void JSMethod(const char* method_name_string, |
+ const char* class_name_string, |
+ const v8::FunctionCallbackInfo<v8::Value>& info) { |
+ v8::Isolate* isolate = info.GetIsolate(); |
+ v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
+ v8::Local<v8::Value> v = context->GetEmbedderData(1); |
+ if (v.IsEmpty()) { |
+ return; |
+ } |
+ v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v); |
+ IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); |
+ IFXJS_Context* cc = pRuntime->GetCurrentContext(); |
+ CJS_Parameters parameters; |
+ for (unsigned int i = 0; i<(unsigned int)info.Length(); i++) { |
+ parameters.push_back(CJS_Value(isolate, info[i], VT_unknown)); |
+ } |
+ CJS_Value valueRes(isolate); |
+ CJS_Object* pJSObj = (CJS_Object *)JS_GetPrivate(isolate,info.Holder()); |
+ C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); |
+ JS_ErrorString sError; |
+ if (!(pObj->*M)(cc, parameters, valueRes, sError)) { |
+ CFX_ByteString cbName; |
+ cbName.Format("%s.%s", class_name_string, method_name_string); |
+ JS_Error(NULL, CFX_WideString::FromLocal(cbName), sError); |
+ return; |
+ } |
+ info.GetReturnValue().Set(valueRes.ToJSValue()); |
} |
+#define JS_STATIC_METHOD(method_name, class_name) \ |
+ static void method_name##_static( \ |
+ const v8::FunctionCallbackInfo<v8::Value>& info) { \ |
+ JSMethod<class_name, &class_name::method_name>( \ |
+ #class_name, #method_name, info); \ |
+ } |
+ |
+#define JS_SPECIAL_STATIC_METHOD(method_name, class_alternate, class_name) \ |
+ static void method_name##_static( \ |
+ const v8::FunctionCallbackInfo<v8::Value>& info) { \ |
+ JSMethod<class_alternate, &class_alternate::method_name>( \ |
+ #class_name, #method_name, info); \ |
+ } |
+ |
/* ===================================== JS CLASS =============================================== */ |
#define DECLARE_JS_CLASS(js_class_name) \ |
@@ -340,9 +315,7 @@ const wchar_t * js_class_name::m_pClassName = JS_WIDESTRING(class_name);\ |
class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\ |
ASSERT(pObj != NULL);\ |
FX_BOOL bRet = FALSE;\ |
- MEMLEAKCHECK_1();\ |
bRet = pObj->QueryProperty(propname.c_str());\ |
- MEMLEAKCHECK_2(class_name, prop_name.c_str());\ |
if (bRet)\ |
{\ |
info.GetReturnValue().Set(0x004);\ |
@@ -375,9 +348,7 @@ const wchar_t * js_class_name::m_pClassName = JS_WIDESTRING(class_name);\ |
ASSERT(pObj != NULL);\ |
JS_ErrorString sError;\ |
FX_BOOL bRet = FALSE;\ |
- MEMLEAKCHECK_1();\ |
bRet = pObj->DoProperty(cc, propname.c_str(), value, sError);\ |
- MEMLEAKCHECK_2(class_name, L"GetProperty");\ |
if (bRet)\ |
{\ |
info.GetReturnValue().Set((v8::Handle<v8::Value>)value);\ |
@@ -413,9 +384,7 @@ const wchar_t * js_class_name::m_pClassName = JS_WIDESTRING(class_name);\ |
ASSERT(pObj != NULL);\ |
JS_ErrorString sError;\ |
FX_BOOL bRet = FALSE;\ |
- MEMLEAKCHECK_1();\ |
bRet = pObj->DoProperty(cc, propname.c_str(), PropValue, sError);\ |
- MEMLEAKCHECK_2(class_name,L"PutProperty");\ |
if (bRet)\ |
{\ |
return ;\ |
@@ -448,9 +417,7 @@ const wchar_t * js_class_name::m_pClassName = JS_WIDESTRING(class_name);\ |
ASSERT(pObj != NULL);\ |
JS_ErrorString sError;\ |
FX_BOOL bRet = FALSE;\ |
- MEMLEAKCHECK_1();\ |
bRet = pObj->DelProperty(cc, propname.c_str(), sError);\ |
- MEMLEAKCHECK_2(class_name,L"DelProperty");\ |
if (bRet)\ |
{\ |
return ;\ |
@@ -520,75 +487,38 @@ void js_class_name::GetMethods(JSMethodSpec*& pMethods, int& nSize)\ |
nSize = sizeof(JS_Class_Methods)/sizeof(JSMethodSpec)-1;\ |
} |
-#define JS_SPECIAL_STATIC_METHOD(method_name, class_alternate, class_name)\ |
- static void method_name##_static(JS_METHOD_ARGS)\ |
-{\ |
- v8::Isolate* isolate = info.GetIsolate();\ |
- v8::Local<v8::Context> context = isolate->GetCurrentContext();\ |
- v8::Local<v8::Value> v = context->GetEmbedderData(1);\ |
- ASSERT(!v.IsEmpty());\ |
- if(v.IsEmpty()) return;\ |
- v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v);\ |
- IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\ |
- IFXJS_Context* cc = pRuntime->GetCurrentContext();\ |
- CJS_Parameters parameters;\ |
- for (unsigned int i = 0; i<(unsigned int)info.Length(); i++)\ |
- {\ |
- parameters.push_back(CJS_Value(isolate, info[i], VT_unknown));\ |
- }\ |
- CJS_Value valueRes(isolate);\ |
- CJS_Object* pJSObj = (CJS_Object *)JS_GetPrivate(isolate, info.Holder());\ |
- ASSERT(pJSObj != NULL);\ |
- class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\ |
- ASSERT(pObj != NULL);\ |
- JS_ErrorString sError;\ |
- FX_BOOL bRet = FALSE;\ |
- MEMLEAKCHECK_1();\ |
- bRet = pObj->method_name(cc, parameters, valueRes, sError);\ |
- MEMLEAKCHECK_2(class_name, method_name);\ |
- if (bRet)\ |
- {\ |
- info.GetReturnValue().Set(valueRes.ToJSValue());\ |
- return ;\ |
- }\ |
- else\ |
- {\ |
- CFX_ByteString cbName;\ |
- cbName.Format("%s.%s", #class_name, #method_name);\ |
- JS_Error(NULL, CFX_WideString::FromLocal(cbName), sError);\ |
- return ;\ |
- }\ |
- JS_Error(NULL, JS_WIDESTRING(method_name), L"Embeded object not found!");\ |
- return ;\ |
+/* ======================================== GLOBAL METHODS ============================================ */ |
+ |
+template <FX_BOOL (*F)(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, JS_ErrorString& sError)> |
+void JSGlobalFunc(const char *func_name_string, |
+ const v8::FunctionCallbackInfo<v8::Value>& info) { |
+ v8::Isolate* isolate = info.GetIsolate(); |
+ v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
+ v8::Local<v8::Value> v = context->GetEmbedderData(1); |
+ if (v.IsEmpty()) { |
Lei Zhang
2015/02/14 00:00:15
Can we ever hit this? If we were to hit this case,
|
+ return; |
+ } |
+ v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v); |
+ IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); |
+ IFXJS_Context* cc = pRuntime->GetCurrentContext(); |
+ CJS_Parameters parameters; |
+ for (unsigned int i = 0; i<(unsigned int)info.Length(); i++) { |
+ parameters.push_back(CJS_Value(isolate, info[i], VT_unknown)); |
+ } |
+ CJS_Value valueRes(isolate); |
+ JS_ErrorString sError; |
+ if (!(*F)(cc, parameters, valueRes, sError)) |
+ { |
+ JS_Error(NULL, JS_WIDESTRING(fun_name), sError); |
+ return; |
+ } |
+ info.GetReturnValue().Set(valueRes.ToJSValue()); |
} |
-/* ======================================== GLOBAL METHODS ============================================ */ |
#define JS_STATIC_GLOBAL_FUN(fun_name) \ |
-static void fun_name##_static(JS_METHOD_ARGS)\ |
-{\ |
- v8::Isolate* isolate = info.GetIsolate();\ |
- v8::Local<v8::Context> context = isolate->GetCurrentContext();\ |
- v8::Local<v8::Value> v = context->GetEmbedderData(1);\ |
- ASSERT(!v.IsEmpty());\ |
- if(v.IsEmpty()) return;\ |
- v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v);\ |
- IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\ |
- IFXJS_Context* cc = pRuntime->GetCurrentContext();\ |
- CJS_Parameters parameters;\ |
- for (unsigned int i = 0; i<(unsigned int)info.Length(); i++)\ |
- {\ |
- parameters.push_back(CJS_Value(isolate, info[i], VT_unknown));\ |
- }\ |
- CJS_Value valueRes(isolate);\ |
- JS_ErrorString sError;\ |
- if (!fun_name(cc, parameters, valueRes, sError))\ |
- {\ |
- JS_Error(NULL, JS_WIDESTRING(fun_name), sError);\ |
- return ;\ |
- }\ |
- info.GetReturnValue().Set(valueRes.ToJSValue());\ |
- return ;\ |
-} |
+ static void fun_name##_static(const v8::FunctionCallbackInfo<v8::Value>& info) { \ |
+ JSGlobalFunc<fun_name>(#fun_name, info); \ |
+ } |
#define JS_STATIC_DECLARE_GLOBAL_FUN() \ |
static JSMethodSpec global_methods[]; \ |
@@ -648,58 +578,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<v8::Value> 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<v8::Value> p); |
#endif //_JS_DEFINE_H_ |