From patchwork Tue Dec 14 21:58:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Pero X-Patchwork-Id: 75572 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 E7222B6EED for ; Wed, 15 Dec 2010 08:59:09 +1100 (EST) Received: (qmail 12792 invoked by alias); 14 Dec 2010 21:59:07 -0000 Received: (qmail 12776 invoked by uid 22791); 14 Dec 2010 21:59:04 -0000 X-SWARE-Spam-Status: No, hits=-0.0 required=5.0 tests=AWL, BAYES_50, 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; Tue, 14 Dec 2010 21:58:56 +0000 Received: from eggs.gnu.org ([140.186.70.92]:47263) by fencepost.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1PSctX-0003wb-I6 for gcc-patches@gnu.org; Tue, 14 Dec 2010 16:58:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PSctZ-00042y-3n for gcc-patches@gnu.org; Tue, 14 Dec 2010 16:58:54 -0500 Received: from smtp151.iad.emailsrvr.com ([207.97.245.151]:47969) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PSctZ-00042e-0o for gcc-patches@gnu.org; Tue, 14 Dec 2010 16:58:53 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp35.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id 662C72C8715 for ; Tue, 14 Dec 2010 16:58:52 -0500 (EST) Received: from dynamic4.wm-web.iad.mlsrvr.com (dynamic4.wm-web.iad1a.rsapps.net [192.168.2.153]) by smtp35.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id 1AABF2C8663 for ; Tue, 14 Dec 2010 16:58:52 -0500 (EST) Received: from meta-innovation.com (localhost [127.0.0.1]) by dynamic4.wm-web.iad.mlsrvr.com (Postfix) with ESMTP id 76D511D4A2B0 for ; Tue, 14 Dec 2010 16:58:51 -0500 (EST) Received: by www2.webmail.us (Authenticated sender: nicola.pero@meta-innovation.com, from: nicola.pero@meta-innovation.com) with HTTP; Tue, 14 Dec 2010 22:58:51 +0100 (CET) Date: Tue, 14 Dec 2010 22:58:51 +0100 (CET) Subject: libobjc: have selectors.c use objc/runtime.h instead of objc/objc-api.h From: "Nicola Pero" To: "gcc-patches@gnu.org" MIME-Version: 1.0 X-Type: plain Message-ID: <1292363931.48464505@192.168.2.229> 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 migrates selectors.c to use the new Objective-C runtime API, and removes a now obsolete #undef in objects.c. It's part of a process of tidying up a few lose ends remained in libobjc after migrating to the new API. Committed to trunk. Thanks 2010-12-14 Nicola Pero * objects.c (object_copy): Do not #undef as we are no longer including objc/objc-api.h. * selector.c: Include objc/runtime.h and objc-private/module-abi-8.h. Do not include objc/objc-api.h and objc/encoding.h. Updated (__objc_register_selectors_from_class): Use struct objc_method_list * instead of MethodList_t. (__objc_register_selectors_from_list): Use Method instead of Method_t. (struct objc_method_description_list): Do not define here. (__objc_register_instance_methods_to_class): Use struct objc_method_list * instead of MethodList_t and Method instead of Method_t. Index: selector.c =================================================================== --- selector.c (revision 167817) +++ selector.c (working copy) @@ -23,13 +23,13 @@ see the files COPYING3 and COPYING.RUNTIME respect . */ #include "objc-private/common.h" -#include "objc/objc-api.h" +#include "objc/runtime.h" #include "objc/thr.h" #include "objc-private/hash.h" -#include "objc-private/objc-list.h" +#include "objc-private/objc-list.h" +#include "objc-private/module-abi-8.h" #include "objc-private/runtime.h" #include "objc-private/sarray.h" -#include "objc/encoding.h" /* Initial selector hash table size. Value doesn't matter much. */ #define SELECTOR_HASH_SIZE 128 @@ -57,7 +57,7 @@ void __objc_init_selector_tables (void) void __objc_register_selectors_from_class (Class class) { - MethodList_t method_list; + struct objc_method_list * method_list; method_list = class->methods; while (method_list) @@ -75,14 +75,14 @@ __objc_register_selectors_from_class (Class class) The name and type pointers in the method list must be permanent and immutable. */ void -__objc_register_selectors_from_list (MethodList_t method_list) +__objc_register_selectors_from_list (struct objc_method_list *method_list) { int i = 0; objc_mutex_lock (__objc_runtime_mutex); while (i < method_list->method_count) { - Method_t method = &method_list->method_list[i]; + Method method = &method_list->method_list[i]; if (method->method_name) { method->method_name @@ -94,15 +94,6 @@ void objc_mutex_unlock (__objc_runtime_mutex); } -/* Temporary definition while we include objc/objc-api.h instead of - objc-private/module-abi-8.h. It should go away once we include - module-abi-8.h. */ -struct objc_method_description_list -{ - int count; - struct objc_method_description list[1]; -}; - /* The same as __objc_register_selectors_from_list, but works on a struct objc_method_description_list* instead of a struct objc_method_list*. This is only used for protocols, which have @@ -131,11 +122,11 @@ __objc_register_selectors_from_description_list /* Register instance methods as class methods for root classes. */ void __objc_register_instance_methods_to_class (Class class) { - MethodList_t method_list; - MethodList_t class_method_list; + struct objc_method_list *method_list; + struct objc_method_list *class_method_list; int max_methods_no = 16; - MethodList_t new_list; - Method_t curr_method; + struct objc_method_list *new_list; + Method curr_method; /* Only if a root class. */ if (class->super_class) @@ -156,7 +147,7 @@ void __objc_register_instance_methods_to_class (Cl /* Iterate through the methods from this method list. */ for (i = 0; i < method_list->method_count; i++) { - Method_t mth = &method_list->method_list[i]; + Method mth = &method_list->method_list[i]; if (mth->method_name && ! search_for_method_in_list (class_method_list, mth->method_name)) Index: objects.c =================================================================== --- objects.c (revision 167817) +++ objects.c (working copy) @@ -72,9 +72,6 @@ class_create_instance (Class class) return class_createInstance (class, 0); } -/* Temporary, while we are including objc-api.h instead of runtime.h. */ -#undef object_copy - id object_copy (id object, size_t extraBytes) { Index: ChangeLog =================================================================== --- ChangeLog (revision 167817) +++ ChangeLog (working copy) @@ -1,5 +1,21 @@ 2010-12-14 Nicola Pero + * objects.c (object_copy): Do not #undef as we are no longer + including objc/objc-api.h. + * selector.c: Include objc/runtime.h and + objc-private/module-abi-8.h. Do not include objc/objc-api.h and + objc/encoding.h. Updated + (__objc_register_selectors_from_class): Use struct + objc_method_list * instead of MethodList_t. + (__objc_register_selectors_from_list): Use Method instead of + Method_t. + (struct objc_method_description_list): Do not define here. + (__objc_register_instance_methods_to_class): Use struct + objc_method_list * instead of MethodList_t and Method instead of + Method_t. + +2010-12-14 Nicola Pero + * selector.c: Reindented some code and tidied up comments. No actual code changes.