From patchwork Thu Jun 2 23:15:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Pero X-Patchwork-Id: 98496 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 86AFBB6FB6 for ; Fri, 3 Jun 2011 09:16:21 +1000 (EST) Received: (qmail 2322 invoked by alias); 2 Jun 2011 23:16:19 -0000 Received: (qmail 2308 invoked by uid 22791); 2 Jun 2011 23:16:16 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL, BAYES_00, SARE_SUB_ENC_UTF8, TW_BJ, TW_VF, 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; Thu, 02 Jun 2011 23:15:58 +0000 Received: from eggs.gnu.org ([140.186.70.92]:56390) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1QSH7N-0002wr-Cj for gcc-patches@gnu.org; Thu, 02 Jun 2011 19:15:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QSH7L-0008Ar-2d for gcc-patches@gnu.org; Thu, 02 Jun 2011 19:15:57 -0400 Received: from smtp131.iad.emailsrvr.com ([207.97.245.131]:58894) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QSH7K-0008An-Sw for gcc-patches@gnu.org; Thu, 02 Jun 2011 19:15:55 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp53.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id 3C72F5863F for ; Thu, 2 Jun 2011 19:15:54 -0400 (EDT) Received: from dynamic8.wm-web.iad.mlsrvr.com (dynamic8.wm-web.iad1a.rsapps.net [192.168.2.149]) by smtp53.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id 27B5D5863A for ; Thu, 2 Jun 2011 19:15:54 -0400 (EDT) Received: from meta-innovation.com (localhost [127.0.0.1]) by dynamic8.wm-web.iad.mlsrvr.com (Postfix) with ESMTP id 13F33305006C for ; Thu, 2 Jun 2011 19:15:54 -0400 (EDT) Received: by www2.webmail.us (Authenticated sender: nicola.pero@meta-innovation.com, from: nicola.pero@meta-innovation.com) with HTTP; Fri, 3 Jun 2011 01:15:54 +0200 (CEST) Date: Fri, 3 Jun 2011 01:15:54 +0200 (CEST) Subject: =?utf-8?Q?libobjc=3A_remove_deprecated_API_=28patch_1=29?= From: "Nicola Pero" To: "gcc-patches@gnu.org" MIME-Version: 1.0 X-Type: plain Message-ID: <1307056554.080415079@www2.webmail.us> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 207.97.245.131 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 removes a number of deprecated libobjc functions and methods, which are part of the "Traditional" Objective-C API that was deprecated in GCC 4.6.x and are to be removed in GCC 4.7.0. It's the first of a long sequence of patches that does this removal one bit at a time. This one removes the deprecated objc_error(), objc_verror() and objc_set_error_handler() functions, and all the deprecated Object methods whose implementation used to use these functions. Unfortunately, all of our testcases use the "Traditional" Objective-C API when testing the GNU runtime and they will need to be updated to use the "Modern" Objective-C API because the Traditional Objective-C API is simply going away. I'll update the relevant testcases with each patch. This first patch requires only a tiny update of a single testcase. Committed to trunk. Thanks Index: libobjc/sendmsg.c =================================================================== --- libobjc/sendmsg.c (revision 174585) +++ libobjc/sendmsg.c (working copy) @@ -977,16 +977,8 @@ __objc_forward (id object, SEL sel, arglist_t args : "instance" ), object->class_pointer->name, sel_getName (sel)); - /* TODO: support for error: is surely deprecated ? */ - err_sel = sel_get_any_uid ("error:"); - if (__objc_responds_to (object, err_sel)) - { - imp = get_implementation (object, object->class_pointer, err_sel); - return (*imp) (object, sel_get_any_uid ("error:"), msg); - } - - /* The object doesn't respond to doesNotRecognize: or error:; - Therefore, a default action is taken. */ + /* The object doesn't respond to doesNotRecognize:. Therefore, a + default action is taken. */ _objc_abort ("%s\n", msg); return 0; Index: libobjc/Makefile.in =================================================================== --- libobjc/Makefile.in (revision 174585) +++ libobjc/Makefile.in (working copy) @@ -139,7 +139,6 @@ OBJC_DEPRECATED_H = \ STR.h \ hash.h \ objc-list.h \ - objc_error.h \ objc_get_uninstalled_dtable.h \ objc_malloc.h \ objc_msg_sendv.h \ Index: libobjc/libobjc.def =================================================================== --- libobjc/libobjc.def (revision 174585) +++ libobjc/libobjc.def (working copy) @@ -25,7 +25,6 @@ search_for_method_in_list objc_get_uninstalled_dtable objc_hash_is_key_in_hash hash_is_key_in_hash -objc_verror _objc_load_callback objc_malloc objc_atomic_malloc @@ -53,7 +52,6 @@ objc_thread_remove __objc_class_name_Object __objc_class_name_Protocol __objc_class_name_NXConstantString -objc_error __objc_object_alloc __objc_object_copy __objc_object_dispose Index: libobjc/error.c =================================================================== --- libobjc/error.c (revision 174585) +++ libobjc/error.c (working copy) @@ -45,53 +45,3 @@ _objc_abort (const char *fmt, ...) abort (); va_end (ap); } - -/* The rest of the file is deprecated. */ -#include "objc/objc-api.h" /* For objc_error_handler. */ - -/* -** Error handler function -** NULL so that default is to just print to stderr -*/ -static objc_error_handler _objc_error_handler = NULL; - -/* Trigger an objc error */ -void -objc_error (id object, int code, const char *fmt, ...) -{ - va_list ap; - - va_start (ap, fmt); - objc_verror (object, code, fmt, ap); - va_end (ap); -} - -/* Trigger an objc error */ -void -objc_verror (id object, int code, const char *fmt, va_list ap) -{ - BOOL result = NO; - - /* Call the error handler if its there - Otherwise print to stderr */ - if (_objc_error_handler) - result = (*_objc_error_handler) (object, code, fmt, ap); - else - vfprintf (stderr, fmt, ap); - - /* Continue if the error handler says its ok - Otherwise abort the program */ - if (result) - return; - else - abort (); -} - -/* Set the error handler */ -objc_error_handler -objc_set_error_handler (objc_error_handler func) -{ - objc_error_handler temp = _objc_error_handler; - _objc_error_handler = func; - return temp; -} Index: libobjc/ChangeLog =================================================================== --- libobjc/ChangeLog (revision 174585) +++ libobjc/ChangeLog (working copy) @@ -1,3 +1,19 @@ +2011-06-02 Nicola Pero + + * Makefile.in (OBJC_DEPRECATED_H): Removed objc_error.h. + * objc/deprecated/objc_error.h: Removed. + * objc/objc-api.h: Do not include deprecated/objc_error.h. + * libobjc.def (objc_error, objc_verror): Removed. + * error.c (_objc_error_handler, objc_error, objc_verror, + objc_set_error_handler): Removed. + * Object.m ([-error:], [-perform:], [-perform:with:], + [-perform:with:with], [-subclassResponsibility:], + [-notImplemented:], [-shouldNotImplement:], [-doesNotRecognize:]): + Removed. + * objc/deprecated/Object.h: Removed the same methods. + * sendmsg.c (__objc_forward): Do not try to invoke the "error:" + method after trying to invoke the "doesNotRecognize:" method. + 2011-05-26 Nicola Pero * sendmsg.c: Reindented part of the file. No non-trivial changes Index: libobjc/Object.m =================================================================== --- libobjc/Object.m (revision 174585) +++ libobjc/Object.m (working copy) @@ -248,30 +248,6 @@ see the files COPYING3 and COPYING.RUNTIME respect :class_get_class_method(self->isa, aSel))); } -- perform:(SEL)aSel -{ - IMP msg = objc_msg_lookup(self, aSel); - if (!msg) - return [self error:"invalid selector passed to %s", sel_get_name(_cmd)]; - return (*msg)(self, aSel); -} - -- perform:(SEL)aSel with:anObject -{ - IMP msg = objc_msg_lookup(self, aSel); - if (!msg) - return [self error:"invalid selector passed to %s", sel_get_name(_cmd)]; - return (*msg)(self, aSel, anObject); -} - -- perform:(SEL)aSel with:anObject1 with:anObject2 -{ - IMP msg = objc_msg_lookup(self, aSel); - if (!msg) - return [self error:"invalid selector passed to %s", sel_get_name(_cmd)]; - return (*msg)(self, aSel, anObject1, anObject2); -} - - (retval_t)forward:(SEL)aSel :(arglist_t)argFrame { (void) argFrame; /* UNUSED */ @@ -302,45 +278,6 @@ see the files COPYING3 and COPYING.RUNTIME respect return nil; } -- subclassResponsibility:(SEL)aSel -{ - return [self error:"subclass should override %s", sel_get_name(aSel)]; -} - -- notImplemented:(SEL)aSel -{ - return [self error:"method %s not implemented", sel_get_name(aSel)]; -} - -- shouldNotImplement:(SEL)aSel -{ - return [self error:"%s should not implement %s", - object_get_class_name(self), sel_get_name(aSel)]; -} - -- doesNotRecognize:(SEL)aSel -{ - return [self error:"%s does not recognize %s", - object_get_class_name(self), sel_get_name(aSel)]; -} - -- error:(const char *)aString, ... -{ -#define FMT "error: %s (%s)\n%s\n" - char fmt[(strlen((char*)FMT)+strlen((char*)object_get_class_name(self)) - +((aString!=NULL)?strlen((char*)aString):0)+8)]; - va_list ap; - - sprintf(fmt, FMT, object_get_class_name(self), - object_is_instance(self)?"instance":"class", - (aString!=NULL)?aString:""); - va_start(ap, aString); - objc_verror(self, OBJC_ERR_UNKNOWN, fmt, ap); - va_end(ap); - return nil; -#undef FMT -} - + (int)version { return class_get_version(self); Index: libobjc/objc/deprecated/Object.h =================================================================== --- libobjc/objc/deprecated/Object.h (revision 174585) +++ libobjc/objc/deprecated/Object.h (working copy) @@ -48,11 +48,6 @@ + (struct objc_method_description *)descriptionForInstanceMethod:(SEL)aSel; - (struct objc_method_description *)descriptionForMethod:(SEL)aSel; -/* Sending messages determined at run time */ -- perform:(SEL)aSel; -- perform:(SEL)aSel with:anObject; -- perform:(SEL)aSel with:anObject1 with:anObject2; - /* Forwarding */ - (retval_t)forward:(SEL)aSel :(arglist_t)argFrame; - (retval_t)performv:(SEL)aSel :(arglist_t)argFrame; @@ -61,15 +56,6 @@ + poseAs:(Class)aClassObject; - (Class)transmuteClassTo:(Class)aClassObject; -/* Enforcing intentions */ -- subclassResponsibility:(SEL)aSel; -- notImplemented:(SEL)aSel; -- shouldNotImplement:(SEL)aSel; - -/* Error handling */ -- doesNotRecognize:(SEL)aSel; -- error:(const char *)aString, ...; - /* Archiving */ + (int)version; + setVersion:(int)aVersion; Index: libobjc/objc/deprecated/objc_error.h =================================================================== --- libobjc/objc/deprecated/objc_error.h (revision 174585) +++ libobjc/objc/deprecated/objc_error.h (working copy) @@ -1,56 +0,0 @@ -/* This API is incredibly limited and unsophisticated. objc_error() - generally causes the program to abort, so it should only be used - when something so dramatic happens that it could be pointless to - continue. Only two cases I can think of: failure to allocate new - memory or failure to load an Objective-C module. -*/ -/* Error handling - - Call objc_error() or objc_verror() to record an error; this error - routine will generally exit the program but not necessarily if the - user has installed his own error handler. - - Call objc_set_error_handler to assign your own function for - handling errors. The function should return YES if it is ok - to continue execution, or return NO or just abort if the - program should be stopped. The default error handler is just to - print a message on stderr. - - The error handler function should be of type objc_error_handler - The first parameter is an object instance of relevance. - The second parameter is an error code. - The third parameter is a format string in the printf style. - The fourth parameter is a variable list of arguments. */ -void objc_error(id object, int code, const char* fmt, ...); -void objc_verror(id object, int code, const char* fmt, va_list ap); -typedef BOOL (*objc_error_handler)(id, int code, const char *fmt, va_list ap); -objc_error_handler objc_set_error_handler(objc_error_handler func); - -/* Error codes - These are used by the runtime library, and your - error handling may use them to determine if the error is - hard or soft thus whether execution can continue or abort. */ -#define OBJC_ERR_UNKNOWN 0 /* Generic error */ - -#define OBJC_ERR_OBJC_VERSION 1 /* Incorrect runtime version */ -#define OBJC_ERR_GCC_VERSION 2 /* Incorrect compiler version */ -#define OBJC_ERR_MODULE_SIZE 3 /* Bad module size */ -#define OBJC_ERR_PROTOCOL_VERSION 4 /* Incorrect protocol version */ - -#define OBJC_ERR_MEMORY 10 /* Out of memory */ - -#define OBJC_ERR_RECURSE_ROOT 20 /* Attempt to archive the root - object more than once. */ -#define OBJC_ERR_BAD_DATA 21 /* Didn't read expected data */ -#define OBJC_ERR_BAD_KEY 22 /* Bad key for object */ -#define OBJC_ERR_BAD_CLASS 23 /* Unknown class */ -#define OBJC_ERR_BAD_TYPE 24 /* Bad type specification */ -#define OBJC_ERR_NO_READ 25 /* Cannot read stream */ -#define OBJC_ERR_NO_WRITE 26 /* Cannot write stream */ -#define OBJC_ERR_STREAM_VERSION 27 /* Incorrect stream version */ -#define OBJC_ERR_BAD_OPCODE 28 /* Bad opcode */ - -#define OBJC_ERR_UNIMPLEMENTED 30 /* Method is not implemented */ - -#define OBJC_ERR_BAD_STATE 40 /* Bad thread state */ - Index: libobjc/objc/objc-api.h =================================================================== --- libobjc/objc/objc-api.h (revision 174585) +++ libobjc/objc/objc-api.h (working copy) @@ -109,8 +109,6 @@ struct objc_method_description equivalent to "*". */ #define _C_ATOM '%' -#include "deprecated/objc_error.h" - #include "deprecated/struct_objc_static_instances.h" #include "deprecated/struct_objc_symtab.h" #include "deprecated/struct_objc_module.h" Index: gcc/testsuite/ChangeLog =================================================================== --- gcc/testsuite/ChangeLog (revision 174585) +++ gcc/testsuite/ChangeLog (working copy) @@ -1,3 +1,7 @@ +2011-06-02 Nicola Pero + + * objc.dg/torture/forward-1.m (main): Updated testcase. + 2011-06-02 Asher Langton PR fortran/49268 Index: gcc/testsuite/objc.dg/torture/forward-1.m =================================================================== --- gcc/testsuite/objc.dg/torture/forward-1.m (revision 174585) +++ gcc/testsuite/objc.dg/torture/forward-1.m (working copy) @@ -71,7 +71,9 @@ id forwarder, receiver; /* If we have a reciever try to perform on that object */ if (receiver) return [receiver performv: theSel: theArgFrame]; - return [self doesNotRecognize:theSel]; + + /* Normally you'd emit an error here. */ + printf ("Unrecognized selector\n"); } @end int main()