mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +00:00
improve typed selector handling
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32642 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8df64eca07
commit
6042f80fe1
2 changed files with 6 additions and 45 deletions
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
* Source/Additions/GSObjCRuntime.m: Use old API to work around bug in
|
* Source/Additions/GSObjCRuntime.m: Use old API to work around bug in
|
||||||
current sel_registerTypedName().
|
current sel_registerTypedName().
|
||||||
|
* Source/GSFFIInvocation.m: Use sel_getTypedName() to safely get a
|
||||||
|
typed selector.
|
||||||
|
|
||||||
2011-03-17 Wolfgang Lux <wolfgang.lux@gmail.com>
|
2011-03-17 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||||
|
|
||||||
|
|
|
@ -103,51 +103,10 @@ gs_find_best_typed_sel (SEL sel)
|
||||||
}
|
}
|
||||||
#elif defined (__GNU_LIBOBJC__)
|
#elif defined (__GNU_LIBOBJC__)
|
||||||
{
|
{
|
||||||
/* Get the list of all selectors with this name. */
|
/* The sel_getTypedSelector() function returns a typed selector if there
|
||||||
const char *selName = sel_getName (sel);
|
* is only one, nul if there are zero or more tha one.
|
||||||
unsigned int numberOfReturnedSelectors;
|
*/
|
||||||
SEL *selectors;
|
return sel_getTypedSelector(sel_getName(sel));
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
#elif defined(NeXTRUNTIME)
|
#elif defined(NeXTRUNTIME)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue