From a6cb961a4121bd8ff929a9e468dac35f2e4e9c42 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sat, 9 Jan 2016 07:30:44 -0800 Subject: [PATCH] Move number's typeid set to FromFFI from Type_new. --- Execute.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Execute.cpp b/Execute.cpp index 3399c86..c19dc76 100644 --- a/Execute.cpp +++ b/Execute.cpp @@ -854,10 +854,12 @@ void Function::PoolFFI(CYPool *pool, JSContextRef context, ffi_type *ffi, void * #define CYFromFFI_(Type_) \ template <> \ JSValueRef Primitive::FromFFI(JSContextRef context, ffi_type *ffi, void *data, bool initialize, JSObjectRef owner) const { \ - return CYCastJSValue(context, *reinterpret_cast(data)); \ + JSValueRef value(CYCastJSValue(context, *reinterpret_cast(data))); \ + JSObjectRef typed(_jsccall(JSObjectCallAsConstructor, context, CYGetCachedObject(context, CYJSString("Number")), 1, &value)); \ + CYSetProperty(context, typed, cyt_s, CYMakeType(context, *this), kJSPropertyAttributeDontEnum); \ + return typed; \ } -CYFromFFI_(bool) CYFromFFI_(wchar_t) CYFromFFI_(float) CYFromFFI_(double) @@ -880,6 +882,11 @@ CYFromFFI_(signed __int128) CYFromFFI_(unsigned __int128) #endif +template <> +JSValueRef Primitive::FromFFI(JSContextRef context, ffi_type *ffi, void *data, bool initialize, JSObjectRef owner) const { + return CYCastJSValue(context, *reinterpret_cast(data)); +} + template <> JSValueRef Primitive::FromFFI(JSContextRef context, ffi_type *ffi, void *data, bool initialize, JSObjectRef owner) const { uint16_t string(uint8_t(*reinterpret_cast(data))); @@ -1706,13 +1713,6 @@ static JSValueRef Type_callAsFunction(JSContextRef context, JSObjectRef object, type->PoolFFI(buffer, context, ffi, data, arguments[0]); JSValueRef value(type->FromFFI(context, ffi, data, false, buffer)); - - if (JSValueGetType(context, value) == kJSTypeNumber) { - JSObjectRef typed(_jsccall(JSObjectCallAsConstructor, context, CYGetCachedObject(context, CYJSString("Number")), 1, &value)); - CYSetProperty(context, typed, cyt_s, object, kJSPropertyAttributeDontEnum); - value = typed; - } - return value; } CYCatch(NULL) } -- 2.45.2