bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFA/base] GSObjCRuntime (Part 2: NO_DEPRECATED macro)


From: David Ayers
Subject: Re: [RFA/base] GSObjCRuntime (Part 2: NO_DEPRECATED macro)
Date: Sat, 07 Jun 2003 12:28:19 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4b) Gecko/20030507

Richard Frith-Macdonald wrote:


On Thursday, June 5, 2003, at 05:37  pm, David Ayers wrote:


   GSMethod GSGetInstanceMethod(Class class, SEL sel);
   GSMethod GSGetClassMethod(Class class, SEL sel);
      (These functions search up the class hierarchy)
   GSMethod GSGetInstanceMethodInClass(Class class, SEL sel);
   GSMethod GSGetClassMethodInClass(Class class, SEL sel);
(These functions only search the given class an not its superclasses)


Sounds OK, but the distinction between the two types does not seem clear from the names. Perhaps something like 'NotInherited' rather than 'InClass' ? ... I'm not sure whether that's any better though. Also, they break the convention that all runtime manipulation functions begin with GSObjC

To me the names don't really matter that much, but I was aiming at having all GS* functions being usable during +load (i.e. no instances and no messages), while GSObjC* may use/receive/return full fledged objects and send messages.

This is what I need for the following patches on gdl2. I would later propose to follow up with:
- similar functions for accessing runtime instance variable information:
   typedef struct objc_ivar *GSIVar

   GSIVar *GSGetInstanceDefinition(Class class, const char *name);
   GSIVar *GSObjCGetInstanceDefinition(Class class, NSString *name);
GSIVar *GSGetInstanceDefinitionInClass(Class class, const char *name); GSIVar *GSObjCGetInstanceDefinitionInClass(Class class, NSString *name);

Getting an ivar definition in a struct is nice.
I'm not sure about the need for the distinction between an ivar defined in the class and one defined in a superclass. I don't think there is ever any reason to treat the two separately. Is the idea simply to parallel the instance method functions? If so, I think I'd prefer just to omit the 'InClass' version.

Yes, your right. Instance variables can't be overriden of course. I'll remove those versions.

- splitting some GSObjC* and GS* functions, where the GSObjC* functions are convience functions using full fledged objects and messaging and thier GS* counterparts are the actual implementations interfaceing the runtime structures/functions so that they can be "safely" used during +load. Candidates are:

I don't think this is worthwhile (not for use during +load anyway ... as the use of any of these is likely to at least require you to pass a Class as an argument, and to obtain a class you almost always have to do something like [foo class] ... which will usually cause trouble in +load), or desirable.

Well this is one of my main objectives. In +load we can obtain a class via: GSClassFromName() (if the class was already loaded of course.)

We should stick with the current convention that *ALL* the ObjC runtime manipulation functions should have the GSObjC prefix rather than attempting to drop the 'ObjC' part from some. Also, I prefer to keep the API small rather than adding a lot of convenience functions. I think the challenge is to pick the best compromise of convenience and efficiency in the arguments passed to the functions.

As long as we're dealing with single structs and pointers, I agree, we don't need convinience methods. That's why I wasn't suggesting GSObjC*Method* functions. I would like to have some indication of whether a function is unsafe for +load or not. I don't care whether this is done through ObjC or some other prefix/suffix. I also would like most functionality (that seems sensible) available during +load. But for "standard usage", when dealing with arrays and dictionaries (like the GSObjCMakeClass and GSObjCAddClasses) c-arrays can get very clumsy. Personally I think that justifies moving the existing implementation to being "load safe" while providing the convience functions for standard usage. Right now, we just don't have safe counterparts to be used during +load. This is where I want to fill the gap without losing ease of use.

To start things off, I've attached a pure whitespace patch (GNU coding standards and readability) for the first step. OK to commit?

Looks fine to me.

Commited:
   * Headers/gnustep/base/GSObjCRuntime.h
   * Source/Additions/GSObjCRuntime.m : White space patch to better
   conform with GNU coding standards and improve readability.

So here's part 2, also rather trivial:

  * Wrap deprecated API in NO_DEPRICATED macro.

If no one objects, I'll commit this (very) soon.

Thanks,
David

? SSL/SSL.bundle
? SSL/config.log
? SSL/config.mak
? SSL/config.status
? SSL/ix86
? SSL/shared_debug_obj
? Source/Additions/shared_debug_obj
? Tools/make_strings/shared_debug_obj
Index: ChangeLog
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/ChangeLog,v
retrieving revision 1.1864
diff -u -r1.1864 ChangeLog
--- ChangeLog   7 Jun 2003 09:45:51 -0000       1.1864
+++ ChangeLog   7 Jun 2003 09:59:41 -0000
@@ -3,6 +3,7 @@
        * Headers/gnustep/base/GSObjCRuntime.h
        * Source/Additions/GSObjCRuntime.m : White space patch to better
        conform with GNU coding standards and improve readability.
+       Wrap deprecated API in NO_DEPRICATED macro.
 
 2003-06-06  David Ayers  <d.ayers@inode.at>
 
Index: Headers/gnustep/base/GSObjCRuntime.h
===================================================================
RCS file: 
/cvsroot/gnustep/gnustep/core/base/Headers/gnustep/base/GSObjCRuntime.h,v
retrieving revision 1.15
diff -u -r1.15 GSObjCRuntime.h
--- Headers/gnustep/base/GSObjCRuntime.h        7 Jun 2003 09:45:51 -0000       
1.15
+++ Headers/gnustep/base/GSObjCRuntime.h        7 Jun 2003 09:59:42 -0000
@@ -111,27 +111,6 @@
 GSObjCSetValue(NSObject *self, NSString *key, id val, SEL sel,
               const char *type, unsigned size, int offset);
 
-/*
- * The next five are old (deprecated) names for the same thing.
- */
-GS_EXPORT BOOL
-GSFindInstanceVariable(id obj, const char *name,
-                      const char **type, unsigned int *size, int *offset);
-
-GS_EXPORT void
-GSGetVariable(id obj, int offset, unsigned int size, void *data);
-
-GS_EXPORT void
-GSSetVariable(id obj, int offset, unsigned int size, const void *data);
-
-GS_EXPORT id
-GSGetValue(NSObject *self, NSString *key, SEL sel,
-          const char *type, unsigned size, int offset);
-
-GS_EXPORT void
-GSSetValue(NSObject *self, NSString *key, id val, SEL sel,
-          const char *type, unsigned size, int offset);
-
 #include <gnustep/base/objc-gnu2next.h>
 
 #define GS_STATIC_INLINE static inline
@@ -174,32 +153,6 @@
   return NO;
 }
 
-/** ## deprecated ##
- */
-GS_STATIC_INLINE const char*
-GSObjCName(Class this)
-{
-  return class_get_class_name(this);
-}
-
-/** ## deprecated ##
- */
-GS_STATIC_INLINE const char*
-GSObjCSelectorName(SEL this)
-{
-  if (this == 0)
-    return 0;
-  return sel_get_name(this);
-}
-
-/** ## deprecated ##
- */
-GS_STATIC_INLINE const char*
-GSObjCSelectorTypes(SEL this)
-{
-  return sel_get_type(this);
-}
-
 /**
  * Given a class name, return the corresponding class or
  * a nul pointer if the class cannot be found. <br />
@@ -346,6 +299,58 @@
 
 
 
+#ifndef NO_DEPRECATED
+/*
+ * The next five are old (deprecated) names for the same thing.
+ */
+GS_EXPORT BOOL
+GSFindInstanceVariable(id obj, const char *name,
+                      const char **type, unsigned int *size, int *offset);
+
+GS_EXPORT void
+GSGetVariable(id obj, int offset, unsigned int size, void *data);
+
+GS_EXPORT void
+GSSetVariable(id obj, int offset, unsigned int size, const void *data);
+
+GS_EXPORT id
+GSGetValue(NSObject *self, NSString *key, SEL sel,
+          const char *type, unsigned size, int offset);
+
+GS_EXPORT void
+GSSetValue(NSObject *self, NSString *key, id val, SEL sel,
+          const char *type, unsigned size, int offset);
+
+/** ## deprecated ##
+ */
+GS_STATIC_INLINE const char*
+GSObjCName(Class this)
+{
+  return class_get_class_name(this);
+}
+
+/** ## deprecated ##
+ */
+GS_STATIC_INLINE const char*
+GSObjCSelectorName(SEL this)
+{
+  if (this == 0)
+    return 0;
+  return sel_get_name(this);
+}
+
+/** ## deprecated ##
+ */
+GS_STATIC_INLINE const char*
+GSObjCSelectorTypes(SEL this)
+{
+  return sel_get_type(this);
+}
+
+#endif  /* NO_DEPRECATED */
+
+
+
 #ifndef        GS_MAX_OBJECTS_FROM_STACK
 /**
  * The number of objects to try to get from varargs into an array on
@@ -492,6 +497,6 @@
 })
 
 
-#endif
+#endif /* NO_GNUSTEP */
 
 #endif /* __GSObjCRuntime_h_GNUSTEP_BASE_INCLUDE */

reply via email to

[Prev in Thread] Current Thread [Next in Thread]