mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
use objc_getProtocol
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@29841 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
42e39c0df8
commit
b4c1a94377
2 changed files with 30 additions and 62 deletions
|
@ -994,6 +994,7 @@ objc_registerClassPair(Class cls)
|
|||
__objc_resolve_class_links();
|
||||
}
|
||||
|
||||
/*
|
||||
static id
|
||||
objectNew(id cls)
|
||||
{
|
||||
|
@ -1007,15 +1008,39 @@ objectNew(id cls)
|
|||
newIMP = (IMP) objc_msg_lookup((void *) cls, newSel);
|
||||
return newIMP((id) cls, newSel);
|
||||
}
|
||||
*/
|
||||
|
||||
Protocol *
|
||||
objc_getProtocol(const char *name)
|
||||
{
|
||||
// Protocols are not centrally registered in the GNU runtime.
|
||||
Protocol *protocol = (Protocol *) (objectNew(objc_getClass("Protocol")));
|
||||
Protocol *p = NULL;
|
||||
Class cls;
|
||||
void *iterator = NULL;
|
||||
|
||||
protocol->protocol_name = (char *) name;
|
||||
return protocol;
|
||||
/* Protocols are not centrally registered in the GNU runtime.
|
||||
* So we just find the first match we can.
|
||||
*/
|
||||
|
||||
while (p == NULL && (cls = objc_next_class(&iterator)))
|
||||
{
|
||||
struct objc_protocol_list *pcllist = cls->protocols;
|
||||
size_t i;
|
||||
|
||||
while (pcllist != NULL)
|
||||
{
|
||||
for (i = 0; i < pcllist->count; i++)
|
||||
{
|
||||
if (strcmp(pcllist->list[i]->protocol_name, name) == 0)
|
||||
{
|
||||
p = (Protocol*)pcllist->list[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
pcllist = pcllist->next;
|
||||
}
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
BOOL
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue