From 8f41509fd52c574f447fe0e40555530de3fda431 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Tue, 28 Jan 2014 17:49:03 -0800 Subject: [PATCH] Remove all Objective-C selector bridge definitions. --- Bridge.def | 43 ------------------------------------------- Bridge.sh | 1 - Exception.hpp | 5 +++++ ObjectiveC/Library.mm | 37 ++++++------------------------------- 4 files changed, 11 insertions(+), 75 deletions(-) diff --git a/Bridge.def b/Bridge.def index 947075f..35b1d58 100644 --- a/Bridge.def +++ b/Bridge.def @@ -2,8 +2,6 @@ C YES true C NO false C NULL null -: applicationDidFinishLaunching: v12@0:4@8 - T id @ T Class # T SEL : @@ -170,9 +168,6 @@ V UINavigationControllerHideShowBarDuration f # UINavigationControllerDelegate -: navigationController:willShowViewController:animated: v20@0:4@8@12B16 -: navigationController:didShowViewController:animated: v20@0:4@8@12B16 - # UIScrollView C UIScrollViewIndicatorStyleDefault 0 @@ -184,29 +179,10 @@ V UIScrollViewDecelerationRateFast f # UIScrollViewDelegate -: scrollViewDidScroll: v12@0:4@8 -: scrollViewWillBeginDragging: v12@0:4@8 -: scrollViewDidEndDragging:willDecelerate: v16@0:4@8B12 -: scrollViewShouldScrollToTop: B12@0:4@8 -: scrollViewDidScrollToTop: v12@0:4@8 -: scrollViewWillBeginDecelerating: v12@0:4@8 -: scrollViewDidEndDecelerating: v12@0:4@8 - -: viewForZoomingInScrollView: @12@0:4@8 -: scrollViewDidEndZooming:withView:atScale: v20@0:4@8@12f16 - -: scrollViewDidEndScrollingAnimation: v12@0:4@8 - # UITabBar # UITabBarDelegate -: tabBar:willBeginCustomizingItems: v16@0:4@8@12 -: tabBar:didBeginCustomizingItems: v16@0:4@8@12 -: tabBar:willBeginCustomizingItems:changed: v20@0:4@8@12B16 -: tabBar:didBeginCustomizingItems:changed: v20@0:4@8@12B16 -: tabBar:didSelectItem: v16@0:4@8@12 - # UITableView C UITableViewStylePlain 0 @@ -257,20 +233,6 @@ C UITableViewCellSeparatorStyleSingleLine 1 # UITableViewDataSource -: tableView:numberOfRowsInSection: i16@0:4@8i12 -: numberOfSectionsInTableView: i12@0:4@8 -: tableView:cellForRowAtIndexPath: @16@0:4@8@12 -: sectionIndexTitlesForTableView: @12@0:4@8 -: tableView:sectionForSectionIndexTitle:atIndex: i20@0:4@8@12i16 -: tableView:titleForHeaderInSection: @16@0:4@8i12 -: tableView:titleForFooterInSection: @16@0:4@8i12 - -: tableView:commitEditingStyle:forRowAtIndexPath: v20@0:4@8i12@16 -: tableView:canEditRowAtIndexPath: B16@0:4@8@12 - -: tableView:canMoveRowAtIndexPath: B16@0:4@8@12 -: tableView:moveRowAtIndexPath:toIndexPath: v20@0:4@8@12@16 - # UIToolbar # UIView @@ -325,11 +287,6 @@ C UIWebViewNavigationTypeOther 5 # UIWebViewDelegate -: webView:shouldStartLoadWithRequest:navigationType: B20@0:4@8@12I16 -: webViewDidStartLoad: v12@0:4@8 -: webViewDidFinishLoad: v12@0:4@8 -: webView:didFailLoadWithError: v16@0:4@8@12 - # UIWindow V UIWindowLevelNormal f diff --git a/Bridge.sh b/Bridge.sh index 3652043..c97d942 100755 --- a/Bridge.sh +++ b/Bridge.sh @@ -47,4 +47,3 @@ EOF grep '^[CFV]' "$1" | sed -e 's/^C/0/;s/^F/1/;s/^V/2/' | sed -e 's/"/\\"/g;s/^\([^ ]*\) \([^ ]*\) \(.*\)$/\1\2, "\3", NULL/'; grep '^[EST]' "$1" | sed -e 's/^S/3/;s/^T/4/;s/^E/5/' | sed -e 's/^5\(.*\)$/4\1 i/;s/"/\\"/g' | sed -e 's/^\([^ ]*\) \([^ ]*\) \(.*\)$/\1\2, "\3", NULL/'; -grep '^:' "$1" | sed -e 's/^: \([^ ]*\) \(.*\)/6\1, "\2", NULL/'; diff --git a/Exception.hpp b/Exception.hpp index 73287dd..d683369 100644 --- a/Exception.hpp +++ b/Exception.hpp @@ -70,6 +70,11 @@ while (false) #define _assert(test) \ _assert_("assert", (test), #test, "") +#define _require(expr) ({ \ + __typeof__(expr) _value = (expr); \ + _assert_("require", _value != NULL, #expr, ""); \ +_value; }) + #define _trace() do { \ fprintf(stderr, "_trace():%u\n", __LINE__); \ } while (false) diff --git a/ObjectiveC/Library.mm b/ObjectiveC/Library.mm index fe8933c..c50f5b7 100644 --- a/ObjectiveC/Library.mm +++ b/ObjectiveC/Library.mm @@ -1601,24 +1601,6 @@ static bool CYImplements(id object, Class _class, SEL selector, bool devoid = fa return false; } -static const char *CYPoolTypeEncoding(CYPool &pool, JSContextRef context, SEL sel, objc_method *method) { - if (method != NULL) - return method_getTypeEncoding(method); - - const char *name(sel_getName(sel)); - size_t length(strlen(name)); - - char keyed[length + 2]; - keyed[0] = '6'; - keyed[length + 1] = '\0'; - memcpy(keyed + 1, name, length); - - if (CYBridgeEntry *entry = CYBridgeHash(keyed, length + 1)) - return entry->value_; - - return NULL; -} - static JSValueRef MessageAdapter_(JSContextRef context, size_t count, JSValueRef values[], JSObjectRef function) { JSObjectRef _this(CYCastJSObject(context, values[0])); return CYCallAsFunction(context, function, _this, count - 2, values + 2); @@ -1686,11 +1668,10 @@ static bool Messages_setProperty(JSContextRef context, JSObjectRef object, JSStr Message_privateData *message(reinterpret_cast(JSObjectGetPrivate((JSObjectRef) value))); type = sig::Unparse(pool, &message->signature_); imp = reinterpret_cast(message->GetValue()); - } else { - objc_method *method(class_getInstanceMethod(_class, sel)); - type = CYPoolTypeEncoding(pool, context, sel, method); + } else if (objc_method *method = class_getInstanceMethod(_class, sel)) { + type = method_getTypeEncoding(method); imp = CYMakeMessage(context, value, type); - } + } else _assert(false); objc_method *method(NULL); #if OBJC_API_VERSION >= 2 @@ -2760,15 +2741,9 @@ static JSValueRef Selector_callAsFunction_type(JSContextRef context, JSObjectRef Selector_privateData *internal(reinterpret_cast(JSObjectGetPrivate(_this))); SEL sel(internal->GetValue()); - objc_method *method; - if (Class _class = CYCastClass(pool, context, arguments[0])) - method = class_getInstanceMethod(_class, sel); - else - method = NULL; - - const char *encoding(CYPoolTypeEncoding(pool, context, sel, method)); - if (encoding == NULL) - return CYJSNull(context); + Class _class(_require(CYCastClass(pool, context, arguments[0]))); + objc_method *method(_require(class_getInstanceMethod(_class, sel))); + const char *encoding(method_getTypeEncoding(method)); sig::Signature signature; sig::Parse(pool, &signature, encoding, &Structor_); -- 2.45.2