gnustep-dev
[Top][All Lists]
Advanced

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

RFA: Reorganize GS extensions (was: RFC: en/decodeBase64 relocation)


From: David Ayers
Subject: RFA: Reorganize GS extensions (was: RFC: en/decodeBase64 relocation)
Date: Sat, 08 Dec 2007 11:43:19 +0100
User-agent: Mozilla Thunderbird 1.0.2 (X11/20070113)

Richard Frith-Macdonald schrieb:
> On 2007-12-06 15:12:30 +0000 David Ayers <address@hidden> wrote:
> 
>> I've also added the declarations to the NSData.h header because -base
>> avoids including GSCategories.h declarations when building itself and
>> relies on the extensions being declared in GNUstep's standard headers.
>>
>> I it was once explained to me that this was done to avoid having folks
>> who merely target GNUstep from having to include the special headers.
> 
> 
> I guess I'd forgotten this.
> 
>> But maybe we should reconsider this approach and remove the:
>>
>> /* The following ifndef prevents the categories declared in this file
>> being
>> * seen in GNUstep code.  This is necessary because those category
>> * declarations are also present in the header files for the corresponding
>> * classes in GNUstep.  The separate category declarations in this file
>> * are only needed for software using the GNUstep Additions library
>> * without the main GNUstep base library.
>> */
>> #ifndef GNUSTEP
>>
>> in GSCategories.h
> 
> 
> Well, I think so.  I don;t know who wrote that (it could well have been
> me),
> but my current feeling is that the best approacch is to try to move towards
> as completely compatible as we can with the main part of the base library,
> and isolate the extensions etc in the Additions subproject.

Agreed... but it seems like quite a task (read can of worms)...

- to consolidate all our NSObject.h/NSDebug.h/GC-related macros and
provide the definitions that work for GNUstep (with/without GC) and OS X
- find a solution for extensions like NSStringEncoding enum
- find solutions for the implications wrt generating documentation

I think this can only be done step by step and deal with the issues as
the show themselves.

My first proposal would be to start preparing the header files.  I think
seperate GSMacros.h file would be warrented.  This file should contain
at least all the macros currently defined in GSCategories.h.  Then we
need to decide which macros from NSObject.h and NSDebug.h should also be
transfered or whether we should take the opportunuty to remove them.

Attached is my first proposal:

Cheers,
David

PS: I cannot test on OS X so I'll need some help testing... maybe
someone can setup the autobuilder test for OS X.
Index: ChangeLog
===================================================================
--- ChangeLog   (Revision 25700)
+++ ChangeLog   (Arbeitskopie)
@@ -1,3 +1,15 @@
+2007-12-08  David Ayers  <address@hidden>
+
+       * Headers/Additions/GNUstepBase/GSMacros.h: Copied
+       from GSCategories.h and removed references to
+       categories.
+       * Headers/Additions/GNUstepBase/GSCategories.h:
+       Include new GSMacros.h file and remove all
+       macro definitions.  Move #ifndef GNUSTEP block
+       inside of other conditional block to allow extracting
+       definitions piece by piece.
+       * Source/GNUmakefile: Add new GSMacros.h file.
+       
 2007-12-07  Richard Frith-Macdonald <address@hidden>
 
        * Headers/Additions/GNUstepBase/GSConfig.h.in:
Index: Headers/Additions/GNUstepBase/GSMacros.h
===================================================================
--- Headers/Additions/GNUstepBase/GSMacros.h    (Revision 25700)
+++ Headers/Additions/GNUstepBase/GSMacros.h    (Arbeitskopie)
@@ -1,6 +1,6 @@
-/** Declaration of extension methods and functions for standard classes
+/** Declaration of extension macros
 
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2007 Free Software Foundation, Inc.
 
    Written by:  Richard Frith-Macdonald <address@hidden>
    and:         Adam Fedor <address@hidden>
@@ -22,23 +22,11 @@
    Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02111 USA.
 
-   AutogsdocSource: Additions/GSCategories.m
-
 */
 
-#ifndef        INCLUDED_GS_CATEGORIES_H
-#define        INCLUDED_GS_CATEGORIES_H
-#include "GNUstepBase/GSVersionMacros.h"
+#ifndef        INCLUDED_GS_MACROS_H
+#define        INCLUDED_GS_MACROS_H
 
-/* The following ifndef prevents the categories declared in this file being
- * seen in GNUstep code.  This is necessary because those category
- * declarations are also present in the header files for the corresponding
- * classes in GNUstep.  The separate category declarations in this file
- * are only needed for software using the GNUstep Additions library
- * without the main GNUstep base library.
- */
-#ifndef GNUSTEP
-
 #include <string.h>
 #include <Foundation/Foundation.h>
 
@@ -59,6 +47,15 @@
 @class NSMutableSet;
 
 
+/* The following ifndef prevents the declarations in this section from being
+ * seen in GNUstep code.  This is necessary because those 
+ * declarations are also present in the header files for the corresponding
+ * classes in GNUstep.  The separate declarations in this file
+ * are only needed for software using the GNUstep Additions library
+ * without the main GNUstep base library.
+ */
+#ifndef GNUSTEP
+
 /* ------------------------------------------------------------------------
  * Macros
  */
@@ -189,185 +186,15 @@
 #define GS_INITIALIZED_LOCK(IDENT,CLASSNAME) \
            (IDENT != nil ? IDENT : [CLASSNAME newLockAt: &IDENT])
 
-/* ------------------------------------------------------------------------
- * Class/Method Extensions
- */
+#endif /* GNUSTEP */
 
-/* 
-   GSCategory extensions are implemented in 
-   Source/Additions/GSCategory.m
-   for both gnustep-base and gnustep-baseadd.
-*/
 
address@hidden NSCalendarDate (GSCategories)
-- (int) weekOfYear;
address@hidden
-
address@hidden NSData (GSCategories)
-- (NSString*) hexadecimalRepresentation;
-- (id) initWithHexadecimalRepresentation: (NSString*)string;
-- (NSData*) md5Digest;
-- (BOOL) uudecodeInto: (NSMutableData*)decoded
-                name: (NSString**)namePtr
-                mode: (int*)modePtr;
-- (BOOL) uuencodeInto: (NSMutableData*)encoded
-                name: (NSString*)name
-                mode: (int)mode;
address@hidden
-
address@hidden NSString (GSCategories)
-+ (id) stringWithFormat: (NSString*)format
-             arguments: (va_list)argList;
-- (NSString*) stringByDeletingPrefix: (NSString*)prefix;
-- (NSString*) stringByDeletingSuffix: (NSString*)suffix;
-- (NSString*) stringByTrimmingLeadSpaces;
-- (NSString*) stringByTrimmingTailSpaces;
-- (NSString*) stringByTrimmingSpaces;
-- (NSString*) stringByReplacingString: (NSString*)replace
-                           withString: (NSString*)by;
address@hidden
-
address@hidden NSMutableString (GSCategories)
-- (void) deleteSuffix: (NSString*)suffix;
-- (void) deletePrefix: (NSString*)prefix;
-- (void) replaceString: (NSString*)replace
-            withString: (NSString*)by;
-- (void) trimLeadSpaces;
-- (void) trimTailSpaces;
-- (void) trimSpaces;
address@hidden
-
address@hidden NSNumber(GSCategories)
-+ (NSValue*) valueFromString: (NSString *)string;
address@hidden
-
address@hidden NSObject (GSCategories)
-- notImplemented:(SEL)aSel;
-- (id) subclassResponsibility: (SEL)aSel;
-- (id) shouldNotImplement: (SEL)aSel;
-/*
-  WARNING: The -compare: method for NSObject is deprecated
-           due to subclasses declaring the same selector with 
-          conflicting signatures.
-           Comparision of arbitrary objects is not just meaningless
-           but also dangerous as most concrete implementations
-           expect comparable objects as arguments often accessing
-          instance variables directly.
-          This method will be removed in a future release.
-*/
-- (NSComparisonResult) compare: (id)anObject;
address@hidden
-
-/* 
-   GSCompatibility methods are implemented in
-   Source/Additions/GSCompatibility.m
-   for gnustep-baseadd only.
-   The implementations for gnustep-base reside in the
-   corresponding source files of -base.
-*/
-
address@hidden NSArray (GSCompatibility)
-- (id) initWithArray: (NSArray*)array copyItems: (BOOL)shouldCopy;
-- (unsigned) insertionPosition: (id)item
-                usingFunction: (NSComparisonResult (*)(id, id, void *))sorter
-                      context: (void *)context;
-- (unsigned) insertionPosition: (id)item
-                usingSelector: (SEL)comp;
address@hidden
-
address@hidden      NSAttributedString (GSCategories)
-- (NSAttributedString*) attributedSubstringWithRange: (NSRange)aRange;
address@hidden
-
address@hidden NSBundle(GSCompatibility)
-+ (NSString *) pathForLibraryResource: (NSString *)name
-                               ofType: (NSString *)ext
-                          inDirectory: (NSString *)bundlePath;
address@hidden
-
address@hidden NSDistantObject (GSCompatibility)
-+ (void) setDebug: (int)val;
address@hidden
-
address@hidden NSFileHandle(GSCompatibility)
-+ (id) fileHandleAsServerAtAddress: (NSString*)address
-                           service: (NSString*)service
-                          protocol: (NSString*)protocol;
-- (NSString*) socketAddress;
address@hidden
-
-// Used only in EOFault.m, -[EOFault forward::], for Object compatibility
address@hidden NSInvocation(GSCompatibility)
-- (retval_t) returnFrame:(arglist_t)args;
-- (id) initWithArgframe:(arglist_t)args selector:(SEL)selector;
address@hidden
-
address@hidden NSObject (GSCompatibility)
-+ (id) notImplemented:(SEL)selector;
-- (BOOL) isInstance;
address@hidden
-
address@hidden NSString (GSCompatibility)
-- (BOOL) boolValue;
-- (NSString*) substringFromRange:(NSRange)range;
address@hidden
-
address@hidden NSProcessInfo(GSCompatibility)
-- (NSMutableSet *) debugSet;
address@hidden
-
address@hidden NSLock (GSCategories)
-+ (id) newLockAt: (id *)location;
address@hidden
-
address@hidden NSLock (GSCompatibility)
-- (void) gcFinalize;
address@hidden
-
address@hidden NSRecursiveLock (GSCategories)
-+ (id)newLockAt:(id *)location;
address@hidden
-
address@hidden NSRecursiveLock (GSCompatibility)
-- (void) gcFinalize;
address@hidden
-
-
-/* ------------------------------------------------------------------------
- * Functions
- */
-
-/* 
-   Similar to the GSCompatibility methods,
-   these functions are implemented in
-   Source/Additions/GSCompatibility.m
-   for gnustep-baseadd only.
-   The implementations for gnustep-base reside in the
-   corresponding source files of -base.
-*/
-GS_EXPORT NSArray *NSStandardLibraryPaths(void);
-GS_EXPORT void NSDecimalFromComponents(NSDecimal *result, 
-                                      unsigned long long mantissa,
-                                      short exponent, BOOL negative);
-
-GS_EXPORT BOOL GSDebugSet(NSString *level);
-
-GS_EXPORT NSThread *GSCurrentThread(void);
-GS_EXPORT NSMutableDictionary *GSCurrentThreadDictionary(void);
-
-GS_EXPORT NSString *GSDebugMethodMsg(id obj, SEL sel, const char *file, 
-                                    int line, NSString *fmt);
-GS_EXPORT NSString *GSDebugFunctionMsg(const char *func, const char *file,
-                                      int line, NSString *fmt);
-
 #endif /* OS_API_VERSION(GS_API_NONE,GS_API_NONE) */
 
 #if    defined(__cplusplus)
 }
 #endif
 
-#endif /* GNUSTEP */
+#endif /* INCLUDED_GS_MACROS_H */
 
-#endif /* INCLUDED_GS_CATEGORIES_H */
 
-
Index: Headers/Additions/GNUstepBase/GSCategories.h
===================================================================
--- Headers/Additions/GNUstepBase/GSCategories.h        (Revision 25700)
+++ Headers/Additions/GNUstepBase/GSCategories.h        (Arbeitskopie)
@@ -29,16 +29,8 @@
 #ifndef        INCLUDED_GS_CATEGORIES_H
 #define        INCLUDED_GS_CATEGORIES_H
 #include "GNUstepBase/GSVersionMacros.h"
+#include "GNUstepBase/GSMacros.h"
 
-/* The following ifndef prevents the categories declared in this file being
- * seen in GNUstep code.  This is necessary because those category
- * declarations are also present in the header files for the corresponding
- * classes in GNUstep.  The separate category declarations in this file
- * are only needed for software using the GNUstep Additions library
- * without the main GNUstep base library.
- */
-#ifndef GNUSTEP
-
 #include <string.h>
 #include <Foundation/Foundation.h>
 
@@ -59,136 +51,15 @@
 @class NSMutableSet;
 
 
-/* ------------------------------------------------------------------------
- * Macros
+/* The following ifndef prevents the declarations in this section from being
+ * seen in GNUstep code.  This is necessary because those 
+ * declarations are also present in the header files for the corresponding
+ * classes in GNUstep.  The separate declarations in this file
+ * are only needed for software using the GNUstep Additions library
+ * without the main GNUstep base library.
  */
+#ifndef GNUSTEP
 
-// Following are also defined in base/Headers/Foundation/NSObject.h
-#define IF_NO_GC(x)    \
-    x
-
-// Following are also defined in base/Headers/Foundation/NSDebug.h
-#ifdef DEBUG
-#define NSDebugLLog(level, format, args...) \
-    do { if (GSDebugSet(level) == YES) \
-        NSLog(format , ## args); } while (0)
-
-#define NSDebugLog(format, args...) \
-    do { if (GSDebugSet(@"dflt") == YES) \
-        NSLog(format , ## args); } while (0)
-
-#define NSDebugFLLog(level, format, args...) \
-    do { if (GSDebugSet(level) == YES) { \
-        NSString *fmt = GSDebugFunctionMsg( \
-        __PRETTY_FUNCTION__, __FILE__, __LINE__, format); \
-        NSLog(fmt , ## args); }} while (0)
-
-#define NSDebugFLog(format, args...) \
-    do { if (GSDebugSet(@"dflt") == YES) { \
-        NSString *fmt = GSDebugFunctionMsg( \
-        __PRETTY_FUNCTION__, __FILE__, __LINE__, format); \
-        NSLog(fmt , ## args); }} while (0)
-
-#define NSDebugMLLog(level, format, args...) \
-    do { if (GSDebugSet(level) == YES) { \
-        NSString *fmt = GSDebugMethodMsg( \
-        self, _cmd, __FILE__, __LINE__, format); \
-        NSLog(fmt , ## args); }} while (0)
-
-#define NSDebugMLog(format, args...) \
-    do { if (GSDebugSet(@"dflt") == YES) { \
-        NSString *fmt = GSDebugMethodMsg( \
-        self, _cmd, __FILE__, __LINE__, format); \
-        NSLog(fmt , ## args); }} while (0)
-
-#else
-#define NSDebugLLog(level, format, args...)
-#define NSDebugLog(format, args...)
-#define NSDebugFLLog(level, format, args...)
-#define NSDebugFLog(format, args...)
-#define NSDebugMLLog(level, format, args...)
-#define NSDebugMLog(format, args...)
-#endif /* DEBUG */
-
-#define GSOnceFLog(format, args...) \
-  do { static BOOL beenHere = NO; if (beenHere == NO) {\
-    NSString *fmt = GSDebugFunctionMsg( \
-        __PRETTY_FUNCTION__, __FILE__, __LINE__, format); \
-    beenHere = YES; \
-    NSLog(fmt , ## args); }} while (0)
-
-#define GSOnceMLog(format, args...) \
-  do { static BOOL beenHere = NO; if (beenHere == NO) {\
-    NSString *fmt = GSDebugMethodMsg( \
-        self, _cmd, __FILE__, __LINE__, format); \
-    beenHere = YES; \
-    NSLog(fmt , ## args); }} while (0)
-
-#ifdef GSWARN
-#define NSWarnLog(format, args...) \
-    do { if (GSDebugSet(@"NoWarn") == NO) { \
-        NSLog(format , ## args); }} while (0)
-
-#define NSWarnFLog(format, args...) \
-    do { if (GSDebugSet(@"NoWarn") == NO) { \
-        NSString *fmt = GSDebugFunctionMsg( \
-        __PRETTY_FUNCTION__, __FILE__, __LINE__, format); \
-        NSLog(fmt , ## args); }} while (0)
-
-#define NSWarnMLog(format, args...) \
-    do { if (GSDebugSet(@"NoWarn") == NO) { \
-        NSString *fmt = GSDebugMethodMsg( \
-        self, _cmd, __FILE__, __LINE__, format); \
-        NSLog(fmt , ## args); }} while (0)
-#else
-#define NSWarnLog(format, args...)
-#define NSWarnFLog(format, args...)
-#define NSWarnMLog(format, args...)
-#endif /* GSWARN */
-
-#define GS_RANGE_CHECK(RANGE, SIZE) \
-  if (RANGE.location > SIZE || RANGE.length > (SIZE - RANGE.location)) \
-    [NSException raise: NSRangeException \
-                format: @"in %s, range { %u, %u } extends beyond size (%u)", \
-                  GSNameFromSelector(_cmd), RANGE.location, RANGE.length, SIZE]
-
-/* Taken from base/Headers/Foundation/NSString.h */
-typedef enum _NSGNUstepStringEncoding
-{
-/* NB. Must not have an encoding with value zero - so we can use zero to
-   tell that a variable that should contain an encoding has not yet been
-   initialised */
-  GSUndefinedEncoding = 0,
-
-// GNUstep additions
-  NSKOI8RStringEncoding = 50,          // Russian/Cyrillic
-  NSISOLatin3StringEncoding = 51,      // ISO-8859-3; South European
-  NSISOLatin4StringEncoding = 52,      // ISO-8859-4; North European
-  NSISOCyrillicStringEncoding = 22,    // ISO-8859-5
-  NSISOArabicStringEncoding = 53,      // ISO-8859-6
-  NSISOGreekStringEncoding = 54,       // ISO-8859-7
-  NSISOHebrewStringEncoding = 55,      // ISO-8859-8
-  NSISOLatin5StringEncoding = 57,      // ISO-8859-9; Turkish
-  NSISOLatin6StringEncoding = 58,      // ISO-8859-10; Nordic
-  NSISOThaiStringEncoding = 59,                // ISO-8859-11
-/* Possible future ISO-8859 additions
-                                       // ISO-8859-12
-*/
-  NSISOLatin7StringEncoding = 61,      // ISO-8859-13
-  NSISOLatin8StringEncoding = 62,      // ISO-8859-14
-  NSISOLatin9StringEncoding = 63,      // ISO-8859-15; Replaces ISOLatin1
-  NSGB2312StringEncoding = 56,
-  NSUTF7StringEncoding = 64,           // RFC 2152
-  NSGSM0338StringEncoding,             // GSM (mobile phone) default alphabet
-  NSBIG5StringEncoding,                        // Traditional chinese
-  NSKoreanEUCStringEncoding
-} NSGNUstepStringEncoding;
-
-
-/* Taken from base/Headers/Foundation/NSLock.h */
-#define GS_INITIALIZED_LOCK(IDENT,CLASSNAME) \
-           (IDENT != nil ? IDENT : [CLASSNAME newLockAt: &IDENT])
-
 /* ------------------------------------------------------------------------
  * Class/Method Extensions
  */
@@ -360,14 +231,15 @@
 GS_EXPORT NSString *GSDebugFunctionMsg(const char *func, const char *file,
                                       int line, NSString *fmt);
 
+#endif /* GNUSTEP */
+
+
 #endif /* OS_API_VERSION(GS_API_NONE,GS_API_NONE) */
 
 #if    defined(__cplusplus)
 }
 #endif
 
-#endif /* GNUSTEP */
-
 #endif /* INCLUDED_GS_CATEGORIES_H */
 
 
Index: Source/GNUmakefile
===================================================================
--- Source/GNUmakefile  (Revision 25700)
+++ Source/GNUmakefile  (Arbeitskopie)
@@ -116,6 +116,7 @@
 
 ADD_HEADERS = \
 GSVersionMacros.h \
+GSMacros.h \
 GSObjCRuntime.h \
 GSCategories.h \
 GSFileHandle.h \

reply via email to

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