libobjc - fixed initializing protocols and tests for modern Objective-C API

Nicola Pero nicola.pero@meta-innovation.com
Fri Oct 15 10:41:00 GMT 2010


This patch includes two testcases, one testing all the new protocol_xxx API functions, and the other one testing all the new sel_xxx API functions.  I have about 8 testcases which will test all the functions in the new API in alphabetical order.  This batch commits the first two.  :-)

The testcases were very useful because they found a number of bugs.  First of all, I had to fix a typo in a function declaration (for sel_xxx functions) but then I also had to revamp how protocol static instances are initialied (for the protocol_xxx functions).

The initialization of static protocol instances was really unfinished in the GNU Objective-C runtime and the only reason nobody reported it is (IMO) because in my experience nobody actually inspects the list of methods implemented by a protocol at runtime (but we need it to properly and completely support the new API and it could actually be very useful; I'm happy to have fixed it). :-)

Committed to trunk.

Thanks

In gcc/testsuite/:
2010-10-15  Nicola Pero  <nicola.pero@meta-innovation.com>

        * objc.dg/gnu-api-2-protocol.m: New.
        * objc.dg/gnu-api-2-sel.m: New.

In libobjc/:
2010-10-15  Nicola Pero  <nicola.pero@meta-innovation.com>

        * init.c (__objc_init_protocol): New function which fixes up a
        protocol's class pointer, registers it with the runtime, register
        all protocol selectors and registers associated protocols too.
        (objc_init_statics): Detect if we are initializing protocols, and
        if so, use __objc_init_protocol instead of only fixing up the
        class pointer.
        (__objc_init_protocls): Use __objc_init_protocol.
        * objc-private/module-abi-8.h: Updated comments.
        * objc-private/runtime.h
        (__objc_register_selectors_from_description_list): New.
        * selector.c (__objc_register_selectors_from_description_list):
        New.  (struct objc_method_description_list): Declare.
        * Protocol.m ([-descriptionForInstanceMethod:]): Use sel_get_name
        when accessing the name of a method, which is now correctly a SEL.
        ([-descriptionForClassMethod:]): Same change.
        * protocols.c (protocol_getMethodDescription): Same change.
        * objc/runtime.h: Updated comments.
        (sel_registerTypedName): Fixed typo in function name.
        

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20101015/2879069a/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: testcase.patch.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20101015/2879069a/attachment-0001.txt>


More information about the Gcc-patches mailing list