From 079cab1b73aea2d0a569e9880596e27b21144e73 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Mon, 13 Oct 2014 04:09:26 -0700 Subject: [PATCH 1/1] Directly create types for Objective-C field types. --- Internal.hpp | 1 - JavaScript.hpp | 1 - ObjectiveC/Library.mm | 15 +++++---------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/Internal.hpp b/Internal.hpp index 9bd4012..e0f732a 100644 --- a/Internal.hpp +++ b/Internal.hpp @@ -35,7 +35,6 @@ JSGlobalContextRef CYGetJSContext(JSContextRef context); void Structor_(CYPool &pool, sig::Type *&type); -JSObjectRef CYMakeType(JSContextRef context, const char *type); JSObjectRef CYMakeType(JSContextRef context, sig::Type *type); extern JSClassRef Functor_; diff --git a/JavaScript.hpp b/JavaScript.hpp index 80599e6..9408c78 100644 --- a/JavaScript.hpp +++ b/JavaScript.hpp @@ -134,7 +134,6 @@ struct CYRegisterHook { JSObjectRef CYMakePointer(JSContextRef context, void *pointer, size_t length, sig::Type *type, ffi_type *ffi, JSObjectRef owner); -JSObjectRef CYMakeType(JSContextRef context, const char *encoding); JSObjectRef CYMakeType(JSContextRef context, sig::Type *type); JSObjectRef CYMakeType(JSContextRef context, sig::Signature *signature); diff --git a/ObjectiveC/Library.mm b/ObjectiveC/Library.mm index dce14d7..32426a5 100644 --- a/ObjectiveC/Library.mm +++ b/ObjectiveC/Library.mm @@ -2732,16 +2732,11 @@ static JSValueRef Class_callAsFunction_pointerTo(JSContextRef context, JSObjectR if (!CYIsClass(value)) CYThrow("non-Class object cannot be used as Type"); - // XXX: this is a very silly implementation - - std::ostringstream type; - type << "@\""; - type << class_getName(value); - type << "\""; - - CYPoolTry { - return CYMakeType(context, type.str().c_str()); - } CYPoolCatch(NULL) + sig::Type type; + memset(&type, 0, sizeof(type)); + type.primitive = sig::object_P; + type.name = class_getName(value); + return CYMakeType(context, &type); } CYCatch(NULL) return /*XXX*/ NULL; } static JSValueRef Selector_callAsFunction_toString(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry { -- 2.45.2