[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFA/base] GSObjCRuntime (Part 1: whitespace)
From: |
David Ayers |
Subject: |
[RFA/base] GSObjCRuntime (Part 1: whitespace) |
Date: |
Thu, 05 Jun 2003 18:37:14 +0200 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4b) Gecko/20030507 |
Hello Richard,
I've got a couple of unfinished patches from base over gdl2 to gsweb
that are starting to have lots of dependencies and they are hampering my
reviewal (or rather the testing) of reported bugs and thier fixes. So I
wish to start committing them iteratively. (is that a real word?)
Here is the plan I have for GSObjCRuntime...
I have the following goals:
- better conformance to GNU coding standards.
- grouping of depricateded functions and wrapping them in a #ifndef
NO_DEPRECATED macro
- additional functions / typedefs for runtime manipulations of methods:
typedef struct objc_method *GSMethod;
(Needed because GNU and NeXT/Apple runtime define Method(_t)
differently and using the the struct is rather clumsy.)
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)
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);
- 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:
void GSAddClassBehavior (Class receiver, Class behavior)
(well actually it would be renaming this one and keeping a
depricated inline GSObjCAddClassBehavior pointing at it for a release.)
void GSMakeClass(const char *name, const char *superName, const char
**ivarNames, const char **ivarTypes,
Class **, unsigned *cnt);
void GSAddClasses(Class *, unsigned cnt);
and potentially
NSArray *GSObjCInstanceMethodNames(class cls)
void GSInstanceMethodNames(class cls, const char ***, unsigned cnt*)
(instead of requiring an instantiated object as currently
GSObjCMethodNames() does)
NSArray *GSObjCInstanceMethodNamesInClass(class cls)
void GSInstanceMethodNamesInClass(class cls, const char ***,
unsigned cnt*)
(only the methods defined by the class and not its superclass)
NSArray *GSObjCClassMethodNames(class cls)
void GSClassMethodNames(class cls, const char ***, unsigned cnt*)
NSArray *GSObjCClassMethodNamesInClass(class cls)
void GSClassMethodNamesInClass(class cls, const char ***, unsigned cnt*)
(I'm not really satisfied with the interface of the GS* variants and I'm
not sure whether they are that useful anyway.)
I'll also try to supply documentation for everything I touch, that
doesn't have documentation yet. I generally have no personal preference
of whether documentation is in the header or the source file. But I
don't really like it, if it's not used consistently in one or the other
for a source/header pair. In the case of GSObjCRuntime, many functions
are static inlined in the header, so I would also like to move the
documtation of all functions to the header, if you don't mind.
Please let me know what you think of all of this. (That goes for anyone
interested.) I'm especially open to any suggestions for a better naming
scheme.
To start things off, I've attached a pure whitespace patch (GNU coding
standards and readability) for the first step. OK to commit?
Cheers,
David
Index: Headers/gnustep/base/GSObjCRuntime.h
===================================================================
RCS file:
/cvsroot/gnustep/gnustep/core/base/Headers/gnustep/base/GSObjCRuntime.h,v
retrieving revision 1.14
diff -u -r1.14 GSObjCRuntime.h
--- Headers/gnustep/base/GSObjCRuntime.h 20 May 2003 14:44:57 -0000
1.14
+++ Headers/gnustep/base/GSObjCRuntime.h 5 Jun 2003 15:11:14 -0000
@@ -73,44 +73,64 @@
* Get the type encoding for a named ivar,
* and copy a value into an ivar.
*/
-GS_EXPORT BOOL GSObjCFindVariable(id obj, const char *name,
- const char **type, unsigned int *size, int *offset);
-GS_EXPORT void GSObjCGetVariable(id obj, int offset, unsigned int size,
- void *data);
-GS_EXPORT void GSObjCSetVariable(id obj, int offset, unsigned int size,
- const void *data);
-GS_EXPORT NSArray* GSObjCMethodNames(id obj);
-GS_EXPORT NSArray* GSObjCVariableNames(id obj);
+GS_EXPORT BOOL
+GSObjCFindVariable(id obj, const char *name,
+ const char **type, unsigned int *size, int *offset);
-GS_EXPORT void GSObjCAddClassBehavior(Class receiver, Class behavior);
+GS_EXPORT void
+GSObjCGetVariable(id obj, int offset, unsigned int size, void *data);
-GS_EXPORT NSValue*
+GS_EXPORT void
+GSObjCSetVariable(id obj, int offset, unsigned int size, const void *data);
+
+GS_EXPORT NSArray *
+GSObjCMethodNames(id obj);
+
+GS_EXPORT NSArray *
+GSObjCVariableNames(id obj);
+
+GS_EXPORT void
+GSObjCAddClassBehavior(Class receiver, Class behavior);
+
+GS_EXPORT NSValue *
GSObjCMakeClass(NSString *name, NSString *superName, NSDictionary *iVars);
-GS_EXPORT void GSObjCAddClasses(NSArray *classes);
+
+GS_EXPORT void
+GSObjCAddClasses(NSArray *classes);
/*
* Functions for key-value encoding ... they access values in an object
* either by selector or directly, but do so using NSNumber for the
* scalar types of data.
*/
-GS_EXPORT id GSObjCGetValue(NSObject *self, NSString *key, SEL sel,
- const char *type, unsigned size, int offset);
-GS_EXPORT void GSObjCSetValue(NSObject *self, NSString *key, id val, SEL sel,
- const char *type, unsigned size, int offset);
+GS_EXPORT id
+GSObjCGetValue(NSObject *self, NSString *key, SEL sel,
+ const char *type, unsigned size, int offset);
+
+GS_EXPORT void
+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);
+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>
@@ -197,7 +217,7 @@
* Return the name of the supplied class, or a nul pointer if no class
* was supplied.
*/
-GS_STATIC_INLINE const char*
+GS_STATIC_INLINE const char *
GSNameFromClass(Class this)
{
if (this == 0)
@@ -209,7 +229,7 @@
* Return the name of the supplied selector, or a nul pointer if no selector
* was supplied.
*/
-GS_STATIC_INLINE const char*
+GS_STATIC_INLINE const char *
GSNameFromSelector(SEL this)
{
if (this == 0)
@@ -250,7 +270,7 @@
}
else
{
- SEL s;
+ SEL s;
if (types == 0)
{
@@ -281,7 +301,7 @@
* May return a nul pointer if the selector was a nul pointer or if it
* was not typed.
*/
-GS_STATIC_INLINE const char*
+GS_STATIC_INLINE const char *
GSTypesFromSelector(SEL this)
{
if (this == 0)
@@ -311,15 +331,18 @@
#include <Foundation/Foundation.h>
#endif
-GS_EXPORT NSZone *GSObjCZone(NSObject *obj);
+GS_EXPORT NSZone *
+GSObjCZone(NSObject *obj);
/**
* Quickly return autoreleased data storage area.
*/
-GS_EXPORT void *GSAutoreleasedBuffer(unsigned size);
+GS_EXPORT void *
+GSAutoreleasedBuffer(unsigned size);
/* Getting a system error message on a variety of systems */
-GS_EXPORT const char *GSLastErrorStr(long error_id);
+GS_EXPORT const char *
+GSLastErrorStr(long error_id);
Index: Source/Additions/GSObjCRuntime.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/Additions/GSObjCRuntime.m,v
retrieving revision 1.17
diff -u -r1.17 GSObjCRuntime.m
--- Source/Additions/GSObjCRuntime.m 22 May 2003 17:00:03 -0000 1.17
+++ Source/Additions/GSObjCRuntime.m 5 Jun 2003 15:11:16 -0000
@@ -53,7 +53,7 @@
/** Deprecated ... use GSObjCFindVariable() */
BOOL
GSFindInstanceVariable(id obj, const char *name,
- const char **type, unsigned int *size, int *offset)
+ const char **type, unsigned int *size, int *offset)
{
return GSObjCFindVariable(obj, name, type, size, offset);
}
@@ -67,7 +67,7 @@
*/
BOOL
GSObjCFindVariable(id obj, const char *name,
- const char **type, unsigned int *size, int *offset)
+ const char **type, unsigned int *size, int *offset)
{
Class class;
struct objc_ivar_list *ivars;
@@ -114,7 +114,7 @@
* If obj is a class, this returns the class methods.<br />
* Returns nil if obj is nil.
*/
-NSArray*
+NSArray *
GSObjCMethodNames(id obj)
{
NSMutableSet *set;
@@ -190,7 +190,7 @@
* belong to the class of obj or one of its superclasses.<br />
* Returns nil if obj is nil.
*/
-NSArray*
+NSArray *
GSObjCVariableNames(id obj)
{
NSMutableArray *array;
@@ -283,7 +283,7 @@
* <p>The iVars dictionary lists the instance variable names and their types.
* </p>
*/
-NSValue*
+NSValue *
GSObjCMakeClass(NSString *name, NSString *superName, NSDictionary *iVars)
{
Class newClass;
@@ -838,7 +838,7 @@
/** Deprecated ... use GSObjCGetValue() */
id
GSGetValue(NSObject *self, NSString *key, SEL sel,
- const char *type, unsigned size, int offset)
+ const char *type, unsigned size, int offset)
{
return GSObjCGetValue(self, key, sel, type, size, offset);
}
@@ -854,7 +854,7 @@
*/
id
GSObjCGetValue(NSObject *self, NSString *key, SEL sel,
- const char *type, unsigned size, int offset)
+ const char *type, unsigned size, int offset)
{
if (sel != 0)
{
@@ -1155,7 +1155,7 @@
/** Deprecated ... use GSObjCSetValue() */
void
GSSetValue(NSObject *self, NSString *key, id val, SEL sel,
- const char *type, unsigned size, int offset)
+ const char *type, unsigned size, int offset)
{
GSObjCSetValue(self, key, val, sel, type, size, offset);
}
@@ -1171,7 +1171,7 @@
*/
void
GSObjCSetValue(NSObject *self, NSString *key, id val, SEL sel,
- const char *type, unsigned size, int offset)
+ const char *type, unsigned size, int offset)
{
static NSNull *null = nil;
@@ -1535,10 +1535,10 @@
}
#else
#ifndef HAVE_STRERROR
-const char*
+const char *
strerror(int eno)
{
- extern char* sys_errlist[];
+ extern char *sys_errlist[];
extern int sys_nerr;
if (eno < 0 || eno >= sys_nerr)
- [RFA/base] GSObjCRuntime (Part 1: whitespace),
David Ayers <=
- Re: [RFA/base] GSObjCRuntime (Part 1: whitespace), Richard Frith-Macdonald, 2003/06/07
- Re: [RFA/base] GSObjCRuntime (Part 2: NO_DEPRECATED macro), David Ayers, 2003/06/07
- Re: [RFA/base] GSObjCRuntime (Part 2: NO_DEPRECATED macro), Richard Frith-Macdonald, 2003/06/11
- Re: [RFA/base] GSObjCRuntime (Part 2: NO_DEPRECATED macro), David Ayers, 2003/06/11
- Re: [RFA/base] GSObjCRuntime (Part 3: Access functions to Method structures), David Ayers, 2003/06/11
- Re: [RFA/base] GSObjCRuntime (Part 3: Access functions to Method structures), David Ayers, 2003/06/19
- Re: [RFA/base] GSObjCRuntime (Part 3: Access functions to Method structures), David Ayers, 2003/06/22
- Re: [RFA/base] GSObjCRuntime (Part 4: Access IVar definition structures), David Ayers, 2003/06/30