From 6042f80fe1bb8c3e311aa0acc87d72c7eebd6d81 Mon Sep 17 00:00:00 2001 From: rfm Date: Fri, 18 Mar 2011 06:32:47 +0000 Subject: [PATCH] improve typed selector handling git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32642 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 2 ++ Source/GSFFIInvocation.m | 49 ++++------------------------------------ 2 files changed, 6 insertions(+), 45 deletions(-) diff --git a/ChangeLog b/ChangeLog index 09281104a..f4be7a88a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ * Source/Additions/GSObjCRuntime.m: Use old API to work around bug in current sel_registerTypedName(). + * Source/GSFFIInvocation.m: Use sel_getTypedName() to safely get a + typed selector. 2011-03-17 Wolfgang Lux diff --git a/Source/GSFFIInvocation.m b/Source/GSFFIInvocation.m index c1fb11894..9954c296f 100644 --- a/Source/GSFFIInvocation.m +++ b/Source/GSFFIInvocation.m @@ -103,51 +103,10 @@ gs_find_best_typed_sel (SEL sel) } #elif defined (__GNU_LIBOBJC__) { - /* Get the list of all selectors with this name. */ - const char *selName = sel_getName (sel); - unsigned int numberOfReturnedSelectors; - SEL *selectors; - - selectors = sel_copyTypedSelectorList (selName, &numberOfReturnedSelectors); - /* If no selectors are returned, there is no selector. */ - if (selectors == NULL) - return NULL; - - /* If one selector is returned, check if it has a type or not. */ - if (numberOfReturnedSelectors == 1) - { - SEL selector = selectors[0]; - free (selectors); - - if (GSTypesFromSelector(selector)) - return selector; - else - return NULL; - } - - /* If two selectors are returned, check if one of them has a null - * type; if so, pick the other one. */ - if (numberOfReturnedSelectors == 2) - { - SEL first_selector = selectors[0]; - SEL second_selector = selectors[1]; - const char *first_selector_types = GSTypesFromSelector(first_selector); - const char *second_selector_types = GSTypesFromSelector(second_selector); - free (selectors); - - if (first_selector_types && !second_selector_types) - return first_selector; - - if (!first_selector_types && second_selector_types) - return second_selector; - - /* If both selectors have a type, there is a conflict. */ - return NULL; - } - - /* More than two selectors - there is a conflict. */ - free (selectors); - return NULL; +/* The sel_getTypedSelector() function returns a typed selector if there + * is only one, nul if there are zero or more tha one. + */ + return sel_getTypedSelector(sel_getName(sel)); } #elif defined(NeXTRUNTIME) {