This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: objc-improvements-branch merge -- Part 2


Next, we do mods to libobjc headers so that they are ObjC++-friendly. Bootstrapped on
i686-pc-linux-gnu.


[libobjc/ChangeLog]
2004-08-12  Ziemowit Laski  <zlaski@apple.com>

* objc/NXConstStr.h: Update copyright date; bracket with
'extern "C"' for C++ use; make include syntax consistent
by using <...> instead of "..."; hoist <objc/...> includes
above the 'extern "C"' block.
* objc/Object.h: Likewise.
* objc/Protocol.h: Likewise.
* objc/encoding.h: Likewise.
* objc/hash.h: Likewise.
* objc/runtime.h: Likewise.
* objc/sarray.h: Likewise.
* objc/thr.h: Likewise.
* objc/typedstream.h: Likewise.
* objc/objc-api.h: Add 'extern "C"' block for C++ use.
(objc_static_instances): For C++ case, do away with
zero-sized array.
(objc_method): Hoist definition to file scope.
(_objc_load_callback, _objc_object_alloc, class_get_class_method,
class_get_instance_method, class_create_instance,
class_get_class_name, class_get_instance_size,
class_get_meta_class, class_get_super_class, class_get_version,
class_is_class, class_is_meta_class, class_set_version,
class_get_gc_object_type, class_ivar_set_gcinvisible,
get_imp): Rename 'class' parameter to '_class'.
* objc/objc-list.h: Add 'extern "C"' block for C++ use.
* objc/objc.h: Update copyright date.
(arglist_t): Provide a union tag.


Index: libobjc/objc/NXConstStr.h
===================================================================
RCS file: /cvs/gcc/gcc/libobjc/objc/NXConstStr.h,v
retrieving revision 1.3
diff -u -3 -p -r1.3 NXConstStr.h
--- libobjc/objc/NXConstStr.h   23 May 2003 20:04:58 -0000      1.3
+++ libobjc/objc/NXConstStr.h   13 Aug 2004 01:49:46 -0000
@@ -1,5 +1,5 @@
 /* Interface for the NXConstantString class for Objective-C.
-   Copyright (C) 1995 Free Software Foundation, Inc.
+   Copyright (C) 1995, 2004 Free Software Foundation, Inc.
    Contributed by Pieter J. Schoenmakers <tiggr@es.ele.tue.nl>

 This file is part of GCC.
@@ -28,7 +28,11 @@ Boston, MA 02111-1307, USA.  */
 #ifndef __nxconstantstring_INCLUDE_GNU
 #define __nxconstantstring_INCLUDE_GNU

-#include "objc/Object.h"
+#include <objc/Object.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif

 @interface NXConstantString: Object
 {
@@ -41,4 +45,8 @@ Boston, MA 02111-1307, USA.  */

@end

+#ifdef __cplusplus
+}
+#endif
+
 #endif
Index: libobjc/objc/Object.h
===================================================================
RCS file: /cvs/gcc/gcc/libobjc/objc/Object.h,v
retrieving revision 1.3
diff -u -3 -p -r1.3 Object.h
--- libobjc/objc/Object.h       23 May 2003 20:04:58 -0000      1.3
+++ libobjc/objc/Object.h       13 Aug 2004 01:49:46 -0000
@@ -27,6 +27,10 @@ Boston, MA 02111-1307, USA.  */
 #ifndef __object_INCLUDE_GNU
 #define __object_INCLUDE_GNU

+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <objc/objc.h>
 #include <objc/typedstream.h>

@@ -121,4 +125,8 @@ Boston, MA 02111-1307, USA. */

@end

+#ifdef __cplusplus
+}
+#endif
+
 #endif
Index: libobjc/objc/Protocol.h
===================================================================
RCS file: /cvs/gcc/gcc/libobjc/objc/Protocol.h,v
retrieving revision 1.4
diff -u -3 -p -r1.4 Protocol.h
--- libobjc/objc/Protocol.h     23 May 2003 20:04:58 -0000      1.4
+++ libobjc/objc/Protocol.h     13 Aug 2004 01:49:46 -0000
@@ -1,5 +1,5 @@
 /* Declare the class Protocol for Objective C programs.
-   Copyright (C) 1993 Free Software Foundation, Inc.
+   Copyright (C) 1993, 2004 Free Software Foundation, Inc.

This file is part of GCC.

@@ -27,7 +27,11 @@ Boston, MA 02111-1307, USA.  */
 #ifndef __Protocol_INCLUDE_GNU
 #define __Protocol_INCLUDE_GNU

-#include "objc/Object.h"
+#include <objc/Object.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif

 @interface Protocol : Object
 {
@@ -52,7 +56,8 @@ Boston, MA 02111-1307, USA.  */

@end

-
-
+#ifdef __cplusplus
+}
+#endif

 #endif /* not __Protocol_INCLUDE_GNU */
Index: libobjc/objc/encoding.h
===================================================================
RCS file: /cvs/gcc/gcc/libobjc/objc/encoding.h,v
retrieving revision 1.5
diff -u -3 -p -r1.5 encoding.h
--- libobjc/objc/encoding.h     25 Jun 2004 04:31:51 -0000      1.5
+++ libobjc/objc/encoding.h     13 Aug 2004 01:49:46 -0000
@@ -1,5 +1,5 @@
 /* Encoding of types for Objective C.
-   Copyright (C) 1993, 1997, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1997, 2002, 2004 Free Software Foundation, Inc.

Author: Kresten Krab Thorup

@@ -29,13 +29,14 @@ Boston, MA 02111-1307, USA.  */
 #ifndef __encoding_INCLUDE_GNU
 #define __encoding_INCLUDE_GNU

-#include <ctype.h>
-#include "objc/objc-api.h"
+#include <objc/objc-api.h>

 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */

+#include <ctype.h>
+
 #define _C_CONST       'r'
 #define _C_IN          'n'
 #define _C_INOUT       'N'
Index: libobjc/objc/hash.h
===================================================================
RCS file: /cvs/gcc/gcc/libobjc/objc/hash.h,v
retrieving revision 1.9
diff -u -3 -p -r1.9 hash.h
--- libobjc/objc/hash.h 25 Jun 2004 04:31:51 -0000      1.9
+++ libobjc/objc/hash.h 13 Aug 2004 01:49:46 -0000
@@ -1,5 +1,5 @@
 /* Hash tables for Objective C method dispatch.
-   Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1995, 1996, 2004 Free Software Foundation, Inc.

This file is part of GCC.

@@ -28,14 +28,14 @@ Boston, MA 02111-1307, USA.  */
 #ifndef __hash_INCLUDE_GNU
 #define __hash_INCLUDE_GNU

-#include <stddef.h>
-#include <string.h>
 #include <objc/objc.h>

 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */

+#include <stddef.h>
+#include <string.h>

 /*
  * This data structure is used to hold items
Index: libobjc/objc/objc-api.h
===================================================================
RCS file: /cvs/gcc/gcc/libobjc/objc/objc-api.h,v
retrieving revision 1.10
diff -u -3 -p -r1.10 objc-api.h
--- libobjc/objc/objc-api.h     25 Jun 2004 04:31:51 -0000      1.10
+++ libobjc/objc/objc-api.h     13 Aug 2004 01:49:46 -0000
@@ -27,17 +27,17 @@ Boston, MA 02111-1307, USA.  */
 #ifndef __objc_api_INCLUDE_GNU
 #define __objc_api_INCLUDE_GNU

-#include "objc/objc.h"
-#include "objc/hash.h"
-#include "objc/thr.h"
-#include "objc/objc-decls.h"
-#include <stdio.h>
-#include <stdarg.h>
+#include <objc/objc.h>
+#include <objc/hash.h>
+#include <objc/thr.h>
+#include <objc/objc-decls.h>

 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */

+#include <stdio.h>
+#include <stdarg.h>

 /* For functions which return Method_t */
 #define METHOD_NULL    (Method_t)0
@@ -152,7 +152,11 @@ extern BOOL objc_trace;
 struct objc_static_instances
 {
   char *class_name;
+#ifdef __cplusplus
+  id instances[1];
+#else
   id instances[0];
+#endif
 };

/*
@@ -241,28 +245,28 @@ typedef struct objc_ivar_list {
** and categories can break them across modules. To handle this problem is a
** singly linked list of methods.
*/
-typedef struct objc_method Method;
-typedef Method* Method_t;
+typedef struct objc_method {
+ SEL method_name; /* This variable is the method's
+ name. It is a char*.
+ The unique integer passed to
+ objc_msg_send is a char* too.
+ It is compared against
+ method_name using strcmp. */
+ const char* method_types; /* Description of the method's
+ parameter list. Useful for
+ debuggers. */
+ IMP method_imp; /* Address of the method in the
+ executable. */
+} Method, *Method_t;
+
typedef struct objc_method_list {
- struct objc_method_list* method_next; /* This variable is used to link
- a method list to another. It
- is a singly linked list. */
- int method_count; /* Number of methods defined in
- this structure. */
- struct objc_method {
- SEL method_name; /* This variable is the method's
- name. It is a char*.
- The unique integer passed to
- objc_msg_send is a char* too.
- It is compared against
- method_name using strcmp. */
- const char* method_types; /* Description of the method's
- parameter list. Useful for
- debuggers. */
- IMP method_imp; /* Address of the method in the
- executable. */
- } method_list[1]; /* Variable length
- structure. */
+ struct objc_method_list* method_next; /* This variable is used to link
+ a method list to another. It
+ is a singly linked list. */
+ int method_count; /* Number of methods defined in
+ this structure. */
+ Method method_list[1]; /* Variable length
+ structure. */
} MethodList, *MethodList_t;


struct objc_protocol_list {
@@ -375,12 +379,12 @@ objc_EXPORT Class (*_objc_lookup_class)(
** dynamic loader determine the classes that have been loaded when
** an object file is dynamically linked in.
*/
-objc_EXPORT void (*_objc_load_callback)(Class class, Category* category);
+objc_EXPORT void (*_objc_load_callback)(Class _class, Category* category);


 /*
 ** Hook functions for allocating, copying and disposing of instances
 */
-objc_EXPORT id (*_objc_object_alloc)(Class class);
+objc_EXPORT id (*_objc_object_alloc)(Class _class);
 objc_EXPORT id (*_objc_object_copy)(id object);
 objc_EXPORT id (*_objc_object_dispose)(id object);

@@ -432,9 +436,9 @@ objc_EXPORT void (*_objc_free)(void *);
 */
 objc_EXPORT IMP (*__objc_msg_forward)(SEL);

-Method_t class_get_class_method(MetaClass class, SEL aSel);
+Method_t class_get_class_method(MetaClass _class, SEL aSel);

-Method_t class_get_instance_method(Class class, SEL aSel);
+Method_t class_get_instance_method(Class _class, SEL aSel);

Class class_pose_as(Class impostor, Class superclass);

@@ -463,66 +467,66 @@ SEL sel_register_typed_name(const char *

BOOL sel_is_mapped (SEL aSel);

-extern id class_create_instance(Class class);
+extern id class_create_instance(Class _class);

 static inline const char *
-class_get_class_name(Class class)
+class_get_class_name(Class _class)
 {
-  return CLS_ISCLASS(class)?class->name:((class==Nil)?"Nil":0);
+  return CLS_ISCLASS(_class)?_class->name:((_class==Nil)?"Nil":0);
 }

 static inline long
-class_get_instance_size(Class class)
+class_get_instance_size(Class _class)
 {
-  return CLS_ISCLASS(class)?class->instance_size:0;
+  return CLS_ISCLASS(_class)?_class->instance_size:0;
 }

 static inline MetaClass
-class_get_meta_class(Class class)
+class_get_meta_class(Class _class)
 {
-  return CLS_ISCLASS(class)?class->class_pointer:Nil;
+  return CLS_ISCLASS(_class)?_class->class_pointer:Nil;
 }

 static inline Class
-class_get_super_class(Class class)
+class_get_super_class(Class _class)
 {
-  return CLS_ISCLASS(class)?class->super_class:Nil;
+  return CLS_ISCLASS(_class)?_class->super_class:Nil;
 }

 static inline int
-class_get_version(Class class)
+class_get_version(Class _class)
 {
-  return CLS_ISCLASS(class)?class->version:-1;
+  return CLS_ISCLASS(_class)?_class->version:-1;
 }

 static inline BOOL
-class_is_class(Class class)
+class_is_class(Class _class)
 {
-  return CLS_ISCLASS(class);
+  return CLS_ISCLASS(_class);
 }

 static inline BOOL
-class_is_meta_class(Class class)
+class_is_meta_class(Class _class)
 {
-  return CLS_ISMETA(class);
+  return CLS_ISMETA(_class);
 }


static inline void -class_set_version(Class class, long version) +class_set_version(Class _class, long version) { - if (CLS_ISCLASS(class)) - class->version = version; + if (CLS_ISCLASS(_class)) + _class->version = version; }

 static inline void *
-class_get_gc_object_type (Class class)
+class_get_gc_object_type (Class _class)
 {
-  return CLS_ISCLASS(class) ? class->gc_object_type : NULL;
+  return CLS_ISCLASS(_class) ? _class->gc_object_type : NULL;
 }

/* Mark the instance variable as innaccessible to the garbage collector */
-extern void class_ivar_set_gcinvisible (Class class,
+extern void class_ivar_set_gcinvisible (Class _class,
const char* ivarname,
BOOL gcInvisible);


@@ -532,7 +536,7 @@ method_get_imp(Method_t method)
   return (method!=METHOD_NULL)?method->method_imp:(IMP)0;
 }

-IMP get_imp (Class class, SEL sel);
+IMP get_imp (Class _class, SEL sel);

 /* Redefine on NeXTSTEP so as not to conflict with system function */
 #ifdef __NeXT__
@@ -615,7 +619,6 @@ objc_get_uninstalled_dtable(void);
 }
 #endif /* __cplusplus */

-
 #endif /* not __objc_api_INCLUDE_GNU */


Index: libobjc/objc/objc-list.h =================================================================== RCS file: /cvs/gcc/gcc/libobjc/objc/objc-list.h,v retrieving revision 1.6 diff -u -3 -p -r1.6 objc-list.h --- libobjc/objc/objc-list.h 25 Jun 2004 04:31:51 -0000 1.6 +++ libobjc/objc/objc-list.h 13 Aug 2004 01:49:46 -0000 @@ -32,7 +32,6 @@ Boston, MA 02111-1307, USA. */ extern "C" { #endif /* __cplusplus */

-
 struct objc_list {
   void *head;
   struct objc_list *tail;
@@ -154,5 +153,4 @@ list_free(struct objc_list* list)
 }
 #endif /* __cplusplus */

-
 #endif /* not __GNU_OBJC_LIST_H */
Index: libobjc/objc/objc.h
===================================================================
RCS file: /cvs/gcc/gcc/libobjc/objc/objc.h,v
retrieving revision 1.4
diff -u -3 -p -r1.4 objc.h
--- libobjc/objc/objc.h 23 May 2003 20:04:58 -0000      1.4
+++ libobjc/objc/objc.h 13 Aug 2004 01:49:46 -0000
@@ -1,5 +1,5 @@
 /* Basic data types for Objective C.
-   Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1995, 1996, 2004 Free Software Foundation, Inc.

This file is part of GCC.

@@ -150,7 +150,7 @@ typedef struct objc_protocol {

 typedef void* retval_t;                /* return value */
 typedef void(*apply_t)(void);  /* function pointer */
-typedef union {
+typedef union arglist {
   char *arg_ptr;
   char arg_regs[sizeof (char*)];
 } *arglist_t;                  /* argument frame */
Index: libobjc/objc/runtime.h
===================================================================
RCS file: /cvs/gcc/gcc/libobjc/objc/runtime.h,v
retrieving revision 1.6
diff -u -3 -p -r1.6 runtime.h
--- libobjc/objc/runtime.h      25 Jun 2004 04:31:51 -0000      1.6
+++ libobjc/objc/runtime.h      13 Aug 2004 01:49:46 -0000
@@ -26,26 +26,25 @@ Foundation, 59 Temple Place - Suite 330,
 #ifndef __objc_runtime_INCLUDE_GNU
 #define __objc_runtime_INCLUDE_GNU

-#include <stdarg.h>            /* for varargs and va_list's */
-
-#include <stdio.h>
-#include <ctype.h>
+#include <objc/objc.h>         /* core data types */
+#include <objc/objc-api.h>     /* runtime api functions */

-#include <stddef.h> /* so noone else will get system versions */
-#include "assert.h"
-
-#include "objc/objc.h" /* core data types */
-#include "objc/objc-api.h" /* runtime api functions */
+#include <objc/thr.h> /* thread and mutex support */


-#include "objc/thr.h"          /* thread and mutex support */
-
-#include "objc/hash.h"         /* hash structures */
-#include "objc/objc-list.h"    /* linear lists */
+#include <objc/hash.h>         /* hash structures */
+#include <objc/objc-list.h>    /* linear lists */

 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */

+#include <stdarg.h> /* for varargs and va_list's */
+
+#include <stdio.h>
+#include <ctype.h>
+
+#include <stddef.h> /* so noone else will get system versions */
+#include <assert.h>


 extern void __objc_add_class_to_hash(Class);   /* (objc-class.c) */
 extern void __objc_init_selector_tables(void); /* (objc-sel.c) */
@@ -94,7 +93,4 @@ extern void __objc_generate_gc_type_desc
 }
 #endif /* __cplusplus */

-
 #endif /* not __objc_runtime_INCLUDE_GNU */
-
-
Index: libobjc/objc/sarray.h
===================================================================
RCS file: /cvs/gcc/gcc/libobjc/objc/sarray.h,v
retrieving revision 1.5
diff -u -3 -p -r1.5 sarray.h
--- libobjc/objc/sarray.h       25 Jun 2004 04:31:51 -0000      1.5
+++ libobjc/objc/sarray.h       13 Aug 2004 01:49:46 -0000
@@ -1,5 +1,5 @@
 /* Sparse Arrays for Objective C dispatch tables
-   Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1995, 1996, 2004 Free Software Foundation, Inc.
    Contributed by Kresten Krab Thorup.

 This file is part of GCC.
@@ -28,6 +28,12 @@ Boston, MA 02111-1307, USA.  */
 #ifndef __sarray_INCLUDE_GNU
 #define __sarray_INCLUDE_GNU

+#include <objc/thr.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
 #define OBJC_SPARSE2           /* 2-level sparse array */
 /* #define OBJC_SPARSE3 */      /* 3-level sparse array */

@@ -41,22 +47,11 @@ extern const char* __objc_sparse3_id;

#include <stddef.h>

-#include "objc/thr.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
 extern int nbuckets;           /* for stats */
 extern int nindices;
 extern int narrays;
 extern int idxsize;

-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
 #include <assert.h>

 /* An unsigned integer of same size as a pointer */
@@ -151,10 +146,6 @@ struct sarray {
   size_t capacity;
 };

-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
 struct sarray* sarray_new(int, void* default_element);
 void sarray_free(struct sarray*);
 struct sarray* sarray_lazy_copy(struct sarray*);
@@ -251,5 +242,4 @@ static inline void* sarray_get_safe(stru
 }
 #endif /* __cplusplus */

-
 #endif /* __sarray_INCLUDE_GNU */
Index: libobjc/objc/thr.h
===================================================================
RCS file: /cvs/gcc/gcc/libobjc/objc/thr.h,v
retrieving revision 1.7
diff -u -3 -p -r1.7 thr.h
--- libobjc/objc/thr.h  25 Jun 2004 04:31:51 -0000      1.7
+++ libobjc/objc/thr.h  13 Aug 2004 01:49:46 -0000
@@ -1,5 +1,5 @@
 /* Thread and mutex controls for Objective C.
-   Copyright (C) 1996, 1997, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 2002, 2004 Free Software Foundation, Inc.
    Contributed by Galen C. Hunt (gchunt@cs.rochester.edu)

 This file is part of GCC.
@@ -38,7 +38,7 @@ Boston, MA 02111-1307, USA.  */
 #ifndef __thread_INCLUDE_GNU
 #define __thread_INCLUDE_GNU

-#include "objc/objc.h"
+#include <objc/objc.h>

 #ifdef __cplusplus
 extern "C" {
@@ -150,5 +150,4 @@ void * __objc_thread_get_data (void);
 }
 #endif /* __cplusplus */

-
 #endif /* not __thread_INCLUDE_GNU */
Index: libobjc/objc/typedstream.h
===================================================================
RCS file: /cvs/gcc/gcc/libobjc/objc/typedstream.h,v
retrieving revision 1.5
diff -u -3 -p -r1.5 typedstream.h
--- libobjc/objc/typedstream.h  25 Jun 2004 04:31:51 -0000      1.5
+++ libobjc/objc/typedstream.h  13 Aug 2004 01:49:46 -0000
@@ -1,5 +1,5 @@
 /* GNU Objective-C Typed Streams interface.
-   Copyright (C) 1993, 1995 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1995, 2004 Free Software Foundation, Inc.

This file is part of GCC.

@@ -27,14 +27,14 @@ Boston, MA 02111-1307, USA.  */
 #ifndef __typedstream_INCLUDE_GNU
 #define __typedstream_INCLUDE_GNU

-#include "objc/objc.h"
-#include "objc/hash.h"
-#include <stdio.h>
+#include <objc/objc.h>
+#include <objc/hash.h>

 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */

+#include <stdio.h>

 typedef int (*objc_typed_read_func)(void*, char*, int);
 typedef int (*objc_typed_write_func)(void*, const char*, int);
@@ -138,5 +138,4 @@ void objc_flush_typed_stream (TypedStrea
 }
 #endif /* __cplusplus */

-
 #endif /* not __typedstream_INCLUDE_GNU */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]