Patchwork libobjc - another small header update

login
register
mail settings
Submitter Nicola Pero
Date Oct. 9, 2010, 8:12 p.m.
Message ID <1286655162.61319927@192.168.2.227>
Download mbox | patch
Permalink /patch/67330/
State New
Headers show

Comments

Nicola Pero - Oct. 9, 2010, 8:12 p.m.
This patch moved the declaration of messaging functions and types into objc/message.h (all mechanical with the exception of updates to comments).  

Committed to trunk.

Thanks

Patch

Index: ChangeLog
===================================================================
--- ChangeLog   (revision 165234)
+++ ChangeLog   (working copy)
@@ -1,3 +1,11 @@ 
+2010-10-09  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       * objc/objc-api.h (struct objc_super, Super, Super_t,
+       objc_msg_lookup_super, objc_msg_sendv, objc_msg_forward,
+       objc_msg_forward2): Declarations moved to objc/message.h.  Include
+       message.h here.
+       * objc/message.h: Added such declarations; updated comments.
+
 2010-10-06  Nicola Pero  <nicola.pero@meta-innovation.com>

        Implemented fast enumeration for Objective-C.
Index: objc/objc-api.h
===================================================================
--- objc/objc-api.h     (revision 165234)
+++ objc/objc-api.h     (working copy)
@@ -289,27 +289,13 @@  typedef struct objc_category {
                                                 conformed to */
 } Category, *Category_t;

-/*
-** 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_super.
-*/
-typedef struct objc_super {
-  id      self;                           /* Id of the object sending
-                                                the message. */
-#ifdef __cplusplus
-  Class super_class;
-#else
-  Class class;                              /* Object's super class. */
-#endif
-} Super, *Super_t;
+/* We include message.h for compatibility with the old objc-api.h
+   which included the declarations currently in message.h.  The
+   Apple/NeXT runtime does not do this and only include message.h in
+   objc-runtime.h.  It does not matter that much since most of the
+   definitions in message.h are runtime-specific.  */
+#include "message.h"

-objc_EXPORT IMP objc_msg_lookup_super(Super_t super, SEL sel);
-
-objc_EXPORT retval_t objc_msg_sendv(id, SEL, arglist_t);
-
-
-
 /*
 ** This is a hook which is called by objc_lookup_class and
 ** objc_get_class if the runtime is not able to find the class.
@@ -359,16 +345,6 @@  objc_free(void *mem);
 #include "deprecated/objc_valloc.h"
 #include "deprecated/objc_malloc.h"

-/*
-**  Hooks for method forwarding. This makes it easy to substitute a
-**  library, such as ffcall, that implements closures, thereby avoiding
-**  gcc's __builtin_apply problems.  __objc_msg_forward2's result will
-**  be preferred over that of __objc_msg_forward if both are set and
-**  return non-NULL.
-*/
-objc_EXPORT IMP (*__objc_msg_forward)(SEL);
-objc_EXPORT IMP (*__objc_msg_forward2)(id, SEL);
-
 #include "deprecated/objc_unexpected_exception.h"

 objc_EXPORT Method_t class_get_class_method(MetaClass _class, SEL aSel);
Index: objc/message.h
===================================================================
--- objc/message.h      (revision 165234)
+++ objc/message.h      (working copy)
@@ -33,8 +33,17 @@  extern "C" {
 #include "objc.h"
 #include "objc-decls.h"

-/* This file includes declarations of the messaging functions and types.  */
+/* This file includes declarations of the messaging functions and
+   types.
+*/

+/* Compatibility note: the messaging function is one area where the
+   GNU runtime and the Apple/NeXT runtime differ significantly.  If
+   you can, it is recommended that you use higher-level facilities
+   (provided by a Foundation library such as GNUstep Base) to perform
+   forwarding or other advanced messaging tricks.
+*/
+
 typedef void* retval_t;                /* return value */
 typedef void(*apply_t)(void);  /* function pointer */
 typedef union arglist {
@@ -44,8 +53,38 @@  typedef union arglist {

 objc_EXPORT IMP objc_msg_lookup(id receiver, SEL op);

-/* TODO: Add the remaining messaging declarations from objc-api.h.  */
+/*
+ * 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.
+ */
+typedef struct objc_super {
+  id      self;       /* Id of the object sending the message. */
+#ifdef __cplusplus
+  /* The new version of the API will always use 'super_class'.  */
+  Class super_class;
+#else
+  Class class;        /* Object's super class. */
+#endif
+} Super, *Super_t;

+objc_EXPORT IMP objc_msg_lookup_super(Super_t super, SEL sel);
+
+objc_EXPORT retval_t objc_msg_sendv(id, SEL, arglist_t);
+
+/*
+ * Hooks for method forwarding. This makes it easy to substitute a
+ * library, such as ffcall, that implements closures, thereby avoiding
+ * gcc's __builtin_apply problems.  __objc_msg_forward2's result will
+ * be preferred over that of __objc_msg_forward if both are set and
+ * return non-NULL.
+ *
+ * TODO: The API should define objc_set_msg_forward_handler () or
+ * similar instead of these hooks.
+ */
+objc_EXPORT IMP (*__objc_msg_forward)(SEL);
+objc_EXPORT IMP (*__objc_msg_forward2)(id, SEL);
+
 #ifdef __cplusplus
 }
 #endif