Skip to content

Commit 6c2a61d

Browse files
committed
Improve protocol reference loading.
Now all @protocol references will refer to precisely the same instance, even across shared libraries.
1 parent bc726e7 commit 6c2a61d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

loader.c

+11
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,17 @@ PUBLIC void __objc_load(struct objc_init *init)
228228
}
229229
registerProtocol((struct objc_protocol*)proto);
230230
}
231+
for (struct objc_protocol **proto = init->proto_ref_begin ; proto < init->proto_ref_end ;
232+
proto++)
233+
{
234+
if (*proto == NULL)
235+
{
236+
continue;
237+
}
238+
struct objc_protocol *p = objc_getProtocol((*proto)->name);
239+
assert(p);
240+
*proto = p;
241+
}
231242
for (Class *cls = init->cls_begin ; cls < init->cls_end ; cls++)
232243
{
233244
if (*cls == NULL)

0 commit comments

Comments
 (0)