mirror of
https://github.com/darlinghq/darling-libobjc2.git
synced 2024-11-30 07:30:32 +00:00
Implemented objc_copyProtocolList().
This commit is contained in:
parent
79b67ad044
commit
c6f0651609
@ -600,6 +600,15 @@ objc_property_t *protocol_copyPropertyList(Protocol *p, unsigned int *count);
|
||||
*/
|
||||
Protocol **protocol_copyProtocolList(Protocol *p, unsigned int *count);
|
||||
|
||||
/**
|
||||
* Returns all of the protocols that the runtime is aware of. Note that
|
||||
* protocols compiled by GCC and not attacked to classes may not have been
|
||||
* registered with the runtime. The number of protocols returned is stored at
|
||||
* the address indicated by the pointer argument.
|
||||
*
|
||||
* The caller is responsible for freeing the returned array.
|
||||
*/
|
||||
Protocol **objc_copyProtocolList(unsigned int *outCount);
|
||||
/**
|
||||
* Returns the method description for the specified method within a given
|
||||
* protocol.
|
||||
|
20
protocol.c
20
protocol.c
@ -474,3 +474,23 @@ BOOL protocol_isEqual(Protocol *p, Protocol *other)
|
||||
return NO;
|
||||
}
|
||||
|
||||
Protocol **objc_copyProtocolList(unsigned int *outCount)
|
||||
{
|
||||
unsigned int total = known_protocol_table->table_used;
|
||||
Protocol **p = calloc(sizeof(Protocol*), known_protocol_table->table_used);
|
||||
|
||||
struct protocol_table_enumerator *e = NULL;
|
||||
Protocol *next;
|
||||
|
||||
unsigned int count = 0;
|
||||
while ((count < total) && (next = protocol_next(known_protocol_table, &e)))
|
||||
{
|
||||
p[count++] = next;
|
||||
}
|
||||
if (NULL != outCount)
|
||||
{
|
||||
*outCount = total;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user