From patchwork Wed Dec 15 19:47:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Pero X-Patchwork-Id: 75674 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id B3BECB6F1E for ; Thu, 16 Dec 2010 06:47:34 +1100 (EST) Received: (qmail 31304 invoked by alias); 15 Dec 2010 19:47:33 -0000 Received: (qmail 31289 invoked by uid 22791); 15 Dec 2010 19:47:32 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL, BAYES_00, SARE_SUB_ENC_UTF8, TW_BJ, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (140.186.70.10) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 15 Dec 2010 19:47:27 +0000 Received: from eggs.gnu.org ([140.186.70.92]:42643) by fencepost.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1PSxJq-0006Yr-U4 for gcc-patches@gnu.org; Wed, 15 Dec 2010 14:47:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PSxJs-0003LF-99 for gcc-patches@gnu.org; Wed, 15 Dec 2010 14:47:25 -0500 Received: from smtp161.iad.emailsrvr.com ([207.97.245.161]:41586) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PSxJs-0003KR-6M for gcc-patches@gnu.org; Wed, 15 Dec 2010 14:47:24 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp46.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id 148BEE844D for ; Wed, 15 Dec 2010 14:47:21 -0500 (EST) Received: from dynamic1.wm-web.iad.mlsrvr.com (dynamic1.wm-web.iad1a.rsapps.net [192.168.2.150]) by smtp46.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id F331DE8C78 for ; Wed, 15 Dec 2010 14:47:20 -0500 (EST) Received: from meta-innovation.com (localhost [127.0.0.1]) by dynamic1.wm-web.iad.mlsrvr.com (Postfix) with ESMTP id E3D18C98078 for ; Wed, 15 Dec 2010 14:47:20 -0500 (EST) Received: by www2.webmail.us (Authenticated sender: nicola.pero@meta-innovation.com, from: nicola.pero@meta-innovation.com) with HTTP; Wed, 15 Dec 2010 20:47:20 +0100 (CET) Date: Wed, 15 Dec 2010 20:47:20 +0100 (CET) Subject: =?UTF-8?Q?libobjc:=20Tidied=20up=20declaration=20of=20objc=5Fsuper=20for?= =?UTF-8?Q?=20modern=20API?= From: "Nicola Pero" To: "gcc-patches@gnu.org" MIME-Version: 1.0 X-Type: plain Message-ID: <1292442440.929718458@192.168.2.227> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This patch does some renaming of 'struct objc_super' related types and fields when using the "Modern API", making it identical to the Apple/NeXT definition and removing the annoyance of having a different field name in the struct for ObjC and ObjC++. It leaves the fields unchanged for the "Traditional API". Committed to trunk. Thanks In libobjc/: 2010-12-15 Nicola Pero * objc/message.h (objc_super): When using the modern API, do not define Super and Super_t, and always use 'super_class' for the super class field. (objc_msg_lookup_super): Updated prototype to use 'struct objc_super *' instead of 'Super_t'. * sendmsg.c (objc_msg_lookup_super): Updated prototype to use 'struct objc_super *' instead of 'Super_t'. Index: sendmsg.c =================================================================== --- sendmsg.c (revision 167865) +++ sendmsg.c (working copy) @@ -445,7 +445,7 @@ objc_msg_lookup (id receiver, SEL op) } IMP -objc_msg_lookup_super (Super_t super, SEL sel) +objc_msg_lookup_super (struct objc_super *super, SEL sel) { if (super->self) return get_imp (super->class, sel); Index: ChangeLog =================================================================== --- ChangeLog (revision 167865) +++ ChangeLog (working copy) @@ -1,5 +1,15 @@ 2010-12-15 Nicola Pero + * objc/message.h (objc_super): When using the modern API, do not + define Super and Super_t, and always use 'super_class' for the + super class field. + (objc_msg_lookup_super): Updated prototype to use 'struct + objc_super *' instead of 'Super_t'. + * sendmsg.c (objc_msg_lookup_super): Updated prototype to use + 'struct objc_super *' instead of 'Super_t'. + +2010-12-15 Nicola Pero + * objc/message.h: Update comments, reindented code and moved deprecated types and functions at the end of the file. No code changes. Index: objc/message.h =================================================================== --- objc/message.h (revision 167865) +++ objc/message.h (working copy) @@ -91,25 +91,40 @@ objc_EXPORT IMP objc_msg_lookup (id receiver, SEL /* Structure used when a message is send to a class's super class. The compiler generates one of these structures and passes it to objc_msg_lookup_super() when a [super method] call is compiled. */ + +/* In the traditional API, the super class field is called 'class' in + Objective-C and 'super_class' in Objective-C++. In the new API + (objc/runtime.h) it is always called 'super_class'. We detect the + "traditional API" by the fact that the objc/objc-api.h header + include guards are defined, which means objc/objc-api.h has been + included. This works because objc/message.h does not exist in the + Traditional API and is only read because objc-api.h itself includes + it. */ +#ifdef __objc_api_INCLUDE_GNU +/* Traditional API. */ typedef struct objc_super { id self; /* Id of the object sending the message. */ - - /* The new version of the API will always use 'super_class'. TODO: - Use class only if objc-api.h is included, otherwise always use - super_class. */ #ifdef __cplusplus Class super_class; #else Class class; /* Object's super class. */ #endif } Super, *Super_t; +#else +/* Modern API. */ +struct objc_super +{ + id self; /* The receiver of the message. */ + Class super_class; /* The superclass of the receiver. */ +}; +#endif /* This is used by the compiler instead of objc_msg_lookup () when compiling a call to 'super', such as [super method]. This requires sending a message to super->self, but looking up the method as if super->self was in class super->super_class. */ -objc_EXPORT IMP objc_msg_lookup_super (Super_t super, SEL sel); +objc_EXPORT IMP objc_msg_lookup_super (struct objc_super *super, SEL sel); /* Hooks for method forwarding. They make it easy to substitute the built-in forwarding with one based on a library, such as ffi, that