--- gcc/objc/selector.c 2018/04/24 18:20:06 1.1.1.2 +++ gcc/objc/selector.c 2018/04/24 18:26:39 1.1.1.3 @@ -1,22 +1,21 @@ /* GNU Objective C Runtime selector related functions - Copyright (C) 1993 Free Software Foundation, Inc. - -Author: Kresten Krab Thorup + Copyright (C) 1993, 1995 Free Software Foundation, Inc. + Contributed by Kresten Krab Thorup This file is part of GNU CC. GNU CC is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 2, or (at your option) any later version. +terms of the GNU General Public License as published by the Free Software +Foundation; either version 2, or (at your option) any later version. GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - details. +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +details. You should have received a copy of the GNU General Public License along with - GNU CC; see the file COPYING. If not, write to the Free Software - Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ +GNU CC; see the file COPYING. If not, write to the Free Software +Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* As a special exception, if you link this library with files compiled with GCC to produce an executable, this does not cause the resulting executable @@ -28,7 +27,7 @@ You should have received a copy of the G #include "objc/sarray.h" #include "encoding.h" -/* Initial selector hash table size. Value doesnt matter much */ +/* Initial selector hash table size. Value doesn't matter much */ #define SELECTOR_HASH_SIZE 128 /* Tables mapping selector names to uid and opposite */ @@ -54,7 +53,7 @@ void __objc_init_selector_tables() /* This routine is given a class and records all of the methods in its class structure in the record table. */ void -__objc_register_selectors_from_class (Class* class) +__objc_register_selectors_from_class (Class class) { MethodList_t method_list; @@ -147,6 +146,29 @@ sel_get_typed_uid (const char *name, con return 0; } +/* Return selector representing name; prefer a selector with non-NULL type */ +SEL +sel_get_any_typed_uid (const char *name) +{ + struct objc_list *l; + sidx i; + SEL s; + + i = (sidx) hash_value_for_key (__objc_selector_hash, name); + if (i == 0) + return 0; + + for (l = (struct objc_list*)sarray_get (__objc_selector_array, i); + l; l = l->tail) + { + s = (SEL) l->head; + if (s->sel_types) + return s; + } + + return s; +} + /* return selector representing name */ SEL sel_get_any_uid (const char *name)