move a bit more stuff into additions

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@29666 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2010-02-18 16:18:54 +00:00
parent dc0c550db8
commit 85760d2563
17 changed files with 671 additions and 327 deletions

View file

@ -1,3 +1,22 @@
2010-02-18 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/Additions/GNUstepBase/NSDebug+GNUstepBase.h:
* Headers/Additions/GNUstepBase/NSThread+GNUstepBase.h:
* Source/Additions/NSDebug+GNUstepBase.m:
* Source/Additions/NSThread+GNUstepBase.m:
* Headers/Additions/GNUstepBase/Additions.h:
* Headers/Foundation/Foundation.h:
* Headers/Foundation/NSDebug.h:
* Headers/Foundation/NSThread.h:
* Source/Additions/GNUmakefile:
* Source/DocMakefile:
* Source/GNUmakefile:
* Source/NSDebug.m:
* Source/NSOperation.m:
Move some gnustep specific extensions into additions library so they
can be used to port apps to OSX in future (when the additions library
builds on OSX again).
2010-02-18 Richard Frith-Macdonald <rfm@gnu.org>
* SSL/configure.ac: Check for latest thread ID callback

View file

@ -43,6 +43,7 @@
#import <GNUstepBase/NSBundle+GNUstepBase.h>
#import <GNUstepBase/NSCalendarDate+GNUstepBase.h>
#import <GNUstepBase/NSData+GNUstepBase.h>
#import <GNUstepBase/NSDebug+GNUstepBase.h>
#import <GNUstepBase/NSFileHandle+GNUstepBase.h>
#import <GNUstepBase/NSLock+GNUstepBase.h>
#import <GNUstepBase/NSMutableString+GNUstepBase.h>
@ -51,6 +52,7 @@
#import <GNUstepBase/NSProcessInfo+GNUstepBase.h>
#import <GNUstepBase/NSString+GNUstepBase.h>
#import <GNUstepBase/NSTask+GNUstepBase.h>
#import <GNUstepBase/NSThread+GNUstepBase.h>
#import <GNUstepBase/NSURL+GNUstepBase.h>
#endif /* __Additions_h_GNUSTEP_BASE_INCLUDE */

View file

@ -0,0 +1,311 @@
/** Declaration of extension methods for base additions
Copyright (C) 2003-2010 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald <rfm@gnu.org>
and: Adam Fedor <fedor@gnu.org>
This file is part of the GNUstep Base Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02111 USA.
*/
#ifndef INCLUDED_NSDebug_GNUstepBase_h
#define INCLUDED_NSDebug_GNUstepBase_h
#import <GNUstepBase/GSVersionMacros.h>
#if defined(GNUSTEP_BASE_INTERNAL)
# import "Foundation/NSDebug.h"
# import "Foundation/NSProcessInfo.h"
#else
# import <Foundation/NSDebug.h>
# import <Foundation/NSProcessInfo.h>
#endif
#if defined(__cplusplus)
extern "C" {
#endif
#if OS_API_VERSION(GS_API_NONE,GS_API_LATEST)
GS_EXPORT BOOL GSDebugSet(NSString *level);
/**
* Used to produce a format string for logging a message with function
* location details.
*/
GS_EXPORT NSString* GSDebugFunctionMsg(const char *func, const char *file,
int line, NSString *fmt);
/**
* Used to produce a format string for logging a message with method
* location details.
*/
GS_EXPORT NSString* GSDebugMethodMsg(id obj, SEL sel, const char *file,
int line, NSString *fmt);
#ifdef GSDIAGNOSE
/**
<p>NSDebugLLog() is the basic debug logging macro used to display
log messages using NSLog(), if debug logging was enabled at compile
time and the appropriate logging level was set at runtime.
</p>
<p>Debug logging which can be enabled/disabled by defining GSDIAGNOSE
when compiling and also setting values in the mutable set which
is set up by NSProcessInfo. GSDIAGNOSE is defined automatically
unless diagnose=no is specified in the make arguments.
</p>
<p>NSProcess initialises a set of strings that are the names of active
debug levels using the '--GNU-Debug=...' command line argument.
Each command-line argument of that form is removed from
<code>NSProcessInfo</code>'s list of arguments and the variable part
(...) is added to the set.
This means that as far as the program proper is concerned, it is
running with the same arguments as if debugging had not been enabled.
</p>
<p>For instance, to debug the NSBundle class, run your program with
'--GNU-Debug=NSBundle'
You can of course supply multiple '--GNU-Debug=...' arguments to
output debug information on more than one thing.
</p>
<p>NSUserDefaults also adds debug levels from the array given by the
GNU-Debug key ... but these values will not take effect until the
+standardUserDefaults method is called ... so they are useless for
debugging NSUserDefaults itself or for debugging any code executed
before the defaults system is used.
</p>
<p>To embed debug logging in your code you use the NSDebugLLog() or
NSDebugLog() macro. NSDebugLog() is just NSDebugLLog() with the debug
level set to 'dflt'. So, to activate debug statements that use
NSDebugLog(), you supply the '--GNU-Debug=dflt' argument to your program.
</p>
<p>You can also change the active debug levels under your programs control -
NSProcessInfo has a [-debugSet] method that returns the mutable set that
contains the active debug levels - your program can modify this set.
</p>
<p>Two debug levels have a special effect - 'dflt' is the level used for
debug logs statements where no debug level is specified, and 'NoWarn'
is used to *disable* warning messages.
</p>
<p>As a convenience, there are four more logging macros you can use -
NSDebugFLog(), NSDebugFLLog(), NSDebugMLog() and NSDebugMLLog().
These are the same as the other macros, but are specifically for use in
either functions or methods and prepend information about the file, line
and either function or class/method in which the message was generated.
</p>
*/
#define NSDebugLLog(level, format, args...) \
do { if (GSDebugSet(level) == YES) \
NSLog(format , ## args); } while (0)
/**
* This macro is a shorthand for NSDebugLLog() using then default debug
* level ... 'dflt'
*/
#define NSDebugLog(format, args...) \
do { if (GSDebugSet(@"dflt") == YES) \
NSLog(format , ## args); } while (0)
/**
* This macro is like NSDebugLLog() but includes the name and location
* of the function in which the macro is used as part of the log output.
*/
#define NSDebugFLLog(level, format, args...) \
do { if (GSDebugSet(level) == YES) { \
NSString *s = GSDebugFunctionMsg( \
__PRETTY_FUNCTION__, __FILE__, __LINE__, \
[NSString stringWithFormat: format, ##args]); \
NSLog(@"%@", s); }} while (0)
/**
* This macro is a shorthand for NSDebugFLLog() using then default debug
* level ... 'dflt'
*/
#define NSDebugFLog(format, args...) \
do { if (GSDebugSet(@"dflt") == YES) { \
NSString *s = GSDebugFunctionMsg( \
__PRETTY_FUNCTION__, __FILE__, __LINE__, \
[NSString stringWithFormat: format, ##args]); \
NSLog(@"%@", s); }} while (0)
/**
* This macro is like NSDebugLLog() but includes the name and location
* of the <em>method</em> in which the macro is used as part of the log output.
*/
#define NSDebugMLLog(level, format, args...) \
do { if (GSDebugSet(level) == YES) { \
NSString *s = GSDebugFunctionMsg( \
__PRETTY_FUNCTION__, __FILE__, __LINE__, \
[NSString stringWithFormat: format, ##args]); \
NSLog(@"%@", s); }} while (0)
/**
* This macro is a shorthand for NSDebugMLLog() using then default debug
* level ... 'dflt'
*/
#define NSDebugMLog(format, args...) \
do { if (GSDebugSet(@"dflt") == YES) { \
NSString *s = GSDebugFunctionMsg( \
__PRETTY_FUNCTION__, __FILE__, __LINE__, \
[NSString stringWithFormat: format, ##args]); \
NSLog(@"%@", s); }} while (0)
/**
* This macro saves the name and location of the function in
* which the macro is used, along with a short string msg as
* the tag associated with a recorded object.
*/
#define NSDebugFRLog(object, msg) \
do { \
NSString *tag = GSDebugFunctionMsg( \
__PRETTY_FUNCTION__, __FILE__, __LINE__, msg); \
GSDebugAllocationTagRecordedObject(object, tag); } while (0)
/**
* This macro saves the name and location of the method in
* which the macro is used, along with a short string msg as
* the tag associated with a recorded object.
*/
#define NSDebugMRLog(object, msg) \
do { \
NSString *tag = GSDebugMethodMsg( \
self, _cmd, __FILE__, __LINE__, msg); \
GSDebugAllocationTagRecordedObject(object, tag); } 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...)
#define NSDebugFRLog(object, msg)
#define NSDebugMRLog(object, msg)
#endif
/**
* Macro to log a message only the first time it is encountered.<br />
* Not entirely thread safe ... but that's not really important,
* it just means that it's possible for the message to be logged
* more than once if two threads call it simultaneously when it
* has not already been called.<br />
* Use this from inside a function. Pass an NSString as a format,
* followed by zero or more arguments for the format string.
* Example: GSOnceMLog(@"This function is deprecated, use another");
*/
#define GSOnceFLog(format, args...) \
do { static BOOL beenHere = NO; if (beenHere == NO) {\
NSString *s = GSDebugFunctionMsg( \
__PRETTY_FUNCTION__, __FILE__, __LINE__, \
[NSString stringWithFormat: format, ##args]); \
beenHere = YES; \
NSLog(@"%@", s); }} while (0)
/**
* Macro to log a message only the first time it is encountered.<br />
* Not entirely thread safe ... but that's not really important,
* it just means that it's possible for the message to be logged
* more than once if two threads call it simultaneously when it
* has not already been called.<br />
* Use this from inside a method. Pass an NSString as a format
* followed by zero or more arguments for the format string.<br />
* Example: GSOnceMLog(@"This method is deprecated, use another");
*/
#define GSOnceMLog(format, args...) \
do { static BOOL beenHere = NO; if (beenHere == NO) {\
NSString *s = GSDebugFunctionMsg( \
__PRETTY_FUNCTION__, __FILE__, __LINE__, \
[NSString stringWithFormat: format, ##args]); \
beenHere = YES; \
NSLog(@"%@", s); }} while (0)
#ifdef GSWARN
/**
<p>NSWarnLog() is the basic debug logging macro used to display
warning messages using NSLog(), if warn logging was not disabled at compile
time and the disabling logging level was not set at runtime.
</p>
<p>Warning messages which can be enabled/disabled by defining GSWARN
when compiling.
</p>
<p>You can also disable these messages at runtime by supplying a
'--GNU-Debug=NoWarn' argument to the program, or by adding 'NoWarn'
to the user default array named 'GNU-Debug'.
</p>
<p>These logging macros are intended to be used when the software detects
something that it not necessarily fatal or illegal, but looks like it
might be a programming error. eg. attempting to remove 'nil' from an
NSArray, which the Spec/documentation does not prohibit, but which a
well written program should not be attempting (since an NSArray object
cannot contain a 'nil').
</p>
<p>NB. The 'warn=yes' option is understood by the GNUstep make package
to mean that GSWARN should be defined, and the 'warn=no' means that
GSWARN should be undefined. Default is to define it.
</p>
<p>To embed debug logging in your code you use the NSWarnLog() macro.
</p>
<p>As a convenience, there are two more logging macros you can use -
NSWarnFLog(), and NSWarnMLog().
These are specifically for use in either functions or methods and
prepend information about the file, line and either function or
class/method in which the message was generated.
</p>
*/
#define NSWarnLog(format, args...) \
do { if (GSDebugSet(@"NoWarn") == NO) { \
NSLog(format , ## args); }} while (0)
/**
* This macro is like NSWarnLog() but includes the name and location of the
* <em>function</em> in which the macro is used as part of the log output.
*/
#define NSWarnFLog(format, args...) \
do { if (GSDebugSet(@"NoWarn") == NO) { \
NSString *s = GSDebugFunctionMsg( \
__PRETTY_FUNCTION__, __FILE__, __LINE__, \
[NSString stringWithFormat: format, ##args]); \
NSLog(@"%@", s); }} while (0)
/**
* This macro is like NSWarnLog() but includes the name and location of the
* <em>method</em> in which the macro is used as part of the log output.
*/
#define NSWarnMLog(format, args...) \
do { if (GSDebugSet(@"NoWarn") == NO) { \
NSString *s = GSDebugFunctionMsg( \
__PRETTY_FUNCTION__, __FILE__, __LINE__, \
[NSString stringWithFormat: format, ##args]); \
NSLog(@"%@", s); }} while (0)
#else
#define NSWarnLog(format, args...)
#define NSWarnFLog(format, args...)
#define NSWarnMLog(format, args...)
#endif
#endif /* OS_API_VERSION */
#if defined(__cplusplus)
}
#endif
#endif /* INCLUDED_NSDebug_GNUstepBase_h */

View file

@ -0,0 +1,53 @@
/** Declaration of extension methods for base additions
Copyright (C) 2003-2010 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald <rfm@gnu.org>
and: Adam Fedor <fedor@gnu.org>
This file is part of the GNUstep Base Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02111 USA.
*/
#ifndef INCLUDED_NSThread_GNUstepBase_h
#define INCLUDED_NSThread_GNUstepBase_h
#import <GNUstepBase/GSVersionMacros.h>
#import <Foundation/NSThread.h>
#if defined(__cplusplus)
extern "C" {
#endif
#if OS_API_VERSION(GS_API_NONE,GS_API_LATEST)
@interface NSThread (GNUstepBase)
@end
GS_EXPORT NSThread *GSCurrentThread(void);
GS_EXPORT NSMutableDictionary *GSCurrentThreadDictionary(void);
#endif /* OS_API_VERSION */
#if defined(__cplusplus)
}
#endif
#endif /* INCLUDED_NSThread_GNUstepBase_h */

View file

@ -1 +1,139 @@
#warning Do NOT include Foundation.h within GNUstep-base
/*
Global include file for the GNUstep Base Library.
Copyright (C) 1997 Free Software Foundation, Inc.
Written by: Scott Christley <scottc@net-community.com>
Date: Sep 1997
This file is part of the GNUstep Base Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02111 USA.
*/
#ifndef __Foundation_h_GNUSTEP_BASE_INCLUDE
#define __Foundation_h_GNUSTEP_BASE_INCLUDE
#import <GNUstepBase/GSVersionMacros.h>
#import <objc/objc.h>
#import <Foundation/FoundationErrors.h>
#import <Foundation/NSObjCRuntime.h>
#import <GNUstepBase/GSConfig.h>
#import <Foundation/NSDebug.h>
#import <Foundation/NSObject.h>
#import <Foundation/NSAffineTransform.h>
#import <Foundation/NSArchiver.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSAttributedString.h>
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSBundle.h>
#import <Foundation/NSByteOrder.h>
#import <Foundation/NSCache.h>
#import <Foundation/NSCalendarDate.h>
#import <Foundation/NSCharacterSet.h>
#import <Foundation/NSClassDescription.h>
#import <Foundation/NSCoder.h>
#import <Foundation/NSComparisonPredicate.h>
#import <Foundation/NSCompoundPredicate.h>
#import <Foundation/NSConnection.h>
#import <Foundation/NSData.h>
#import <Foundation/NSDateFormatter.h>
#import <Foundation/NSDate.h>
#import <Foundation/NSDecimalNumber.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSDistantObject.h>
#import <Foundation/NSDistributedLock.h>
#import <Foundation/NSDistributedNotificationCenter.h>
#import <Foundation/NSEnumerator.h>
#import <Foundation/NSError.h>
#import <Foundation/NSException.h>
#import <Foundation/NSExpression.h>
#import <Foundation/NSFileHandle.h>
#import <Foundation/NSFileManager.h>
#import <Foundation/NSFormatter.h>
#import <Foundation/NSGarbageCollector.h>
#import <Foundation/NSGeometry.h>
#import <Foundation/NSHashTable.h>
#import <Foundation/NSHost.h>
#import <Foundation/NSHTTPCookie.h>
#import <Foundation/NSHTTPCookieStorage.h>
#import <Foundation/NSIndexPath.h>
#import <Foundation/NSIndexSet.h>
#import <Foundation/NSInvocation.h>
#import <Foundation/NSKeyedArchiver.h>
#import <Foundation/NSKeyValueCoding.h>
#import <Foundation/NSKeyValueObserving.h>
#import <Foundation/NSLock.h>
#import <Foundation/NSMapTable.h>
#import <Foundation/NSMethodSignature.h>
#import <Foundation/NSNotification.h>
#import <Foundation/NSNotificationQueue.h>
#import <Foundation/NSNetServices.h>
#import <Foundation/NSNull.h>
#import <Foundation/NSNumberFormatter.h>
#import <Foundation/NSOperation.h>
#import <Foundation/NSPathUtilities.h>
#import <Foundation/NSPointerArray.h>
#import <Foundation/NSPointerFunctions.h>
#import <Foundation/NSPortCoder.h>
#import <Foundation/NSPortMessage.h>
#import <Foundation/NSPortNameServer.h>
#import <Foundation/NSPredicate.h>
#import <Foundation/NSProcessInfo.h>
#import <Foundation/NSProtocolChecker.h>
#import <Foundation/NSProxy.h>
#import <Foundation/NSRange.h>
#import <Foundation/NSRunLoop.h>
#import <Foundation/NSScanner.h>
#import <Foundation/NSSerialization.h>
#import <Foundation/NSSet.h>
#import <Foundation/NSSortDescriptor.h>
#import <Foundation/NSSpellServer.h>
#import <Foundation/NSStream.h>
#import <Foundation/NSString.h>
#import <Foundation/NSTask.h>
#import <Foundation/NSThread.h>
#import <Foundation/NSTimer.h>
#import <Foundation/NSTimeZone.h>
#import <Foundation/NSUndoManager.h>
#import <Foundation/NSURLAuthenticationChallenge.h>
#import <Foundation/NSURLCache.h>
#import <Foundation/NSURLConnection.h>
#import <Foundation/NSURLCredential.h>
#import <Foundation/NSURLCredentialStorage.h>
#import <Foundation/NSURLDownload.h>
#import <Foundation/NSURLError.h>
#import <Foundation/NSURL.h>
#import <Foundation/NSURLHandle.h>
#import <Foundation/NSURLProtectionSpace.h>
#import <Foundation/NSURLProtocol.h>
#import <Foundation/NSURLRequest.h>
#import <Foundation/NSURLResponse.h>
#import <Foundation/NSUserDefaults.h>
#import <Foundation/NSValue.h>
#import <Foundation/NSValueTransformer.h>
#import <Foundation/NSXMLDocument.h>
#import <Foundation/NSXMLDTD.h>
#import <Foundation/NSXMLDTDNode.h>
#import <Foundation/NSXMLElement.h>
#import <Foundation/NSXMLNode.h>
#import <Foundation/NSXMLNodeOptions.h>
#import <Foundation/NSXMLParser.h>
#import <Foundation/NSZone.h>
#endif /* __Foundation_h_GNUSTEP_BASE_INCLUDE */

View file

@ -29,8 +29,16 @@
#import <GNUstepBase/GSVersionMacros.h>
#include <errno.h>
#import <Foundation/NSObject.h>
#if !defined(NO_GNUSTEP)
# if defined(GNUSTEP_BASE_INTERNAL)
# import "Foundation/NSObject.h"
# import "GNUstepBase/NSDebug+GNUstepBase.h"
# else
# import <Foundation/NSObject.h>
# import <GNUstepBase/NSDebug+GNUstepBase.h>
# endif
#endif
#if defined(__cplusplus)
extern "C" {
@ -149,19 +157,6 @@ GS_EXPORT NSArray *GSDebugAllocationListRecordedObjects(Class c);
*/
GS_EXPORT id GSDebugAllocationTagRecordedObject(id object, id tag);
/**
* Used to produce a format string for logging a message with function
* location details.
*/
GS_EXPORT NSString* GSDebugFunctionMsg(const char *func, const char *file,
int line, NSString *fmt);
/**
* Used to produce a format string for logging a message with method
* location details.
*/
GS_EXPORT NSString* GSDebugMethodMsg(id obj, SEL sel, const char *file,
int line, NSString *fmt);
/**
* This functions allows to set own function callbacks for debugging allocation
* of objects. Useful if you intend to write your own object allocation code.
@ -211,253 +206,6 @@ GS_EXPORT BOOL NSDeallocateZombies;
#ifdef GSDIAGNOSE
#import <Foundation/NSObjCRuntime.h>
#import <Foundation/NSProcessInfo.h>
/**
<p>NSDebugLLog() is the basic debug logging macro used to display
log messages using NSLog(), if debug logging was enabled at compile
time and the appropriate logging level was set at runtime.
</p>
<p>Debug logging which can be enabled/disabled by defining GSDIAGNOSE
when compiling and also setting values in the mutable set which
is set up by NSProcessInfo. GSDIAGNOSE is defined automatically
unless diagnose=no is specified in the make arguments.
</p>
<p>NSProcess initialises a set of strings that are the names of active
debug levels using the '--GNU-Debug=...' command line argument.
Each command-line argument of that form is removed from
<code>NSProcessInfo</code>'s list of arguments and the variable part
(...) is added to the set.
This means that as far as the program proper is concerned, it is
running with the same arguments as if debugging had not been enabled.
</p>
<p>For instance, to debug the NSBundle class, run your program with
'--GNU-Debug=NSBundle'
You can of course supply multiple '--GNU-Debug=...' arguments to
output debug information on more than one thing.
</p>
<p>NSUserDefaults also adds debug levels from the array given by the
GNU-Debug key ... but these values will not take effect until the
+standardUserDefaults method is called ... so they are useless for
debugging NSUserDefaults itself or for debugging any code executed
before the defaults system is used.
</p>
<p>To embed debug logging in your code you use the NSDebugLLog() or
NSDebugLog() macro. NSDebugLog() is just NSDebugLLog() with the debug
level set to 'dflt'. So, to activate debug statements that use
NSDebugLog(), you supply the '--GNU-Debug=dflt' argument to your program.
</p>
<p>You can also change the active debug levels under your programs control -
NSProcessInfo has a [-debugSet] method that returns the mutable set that
contains the active debug levels - your program can modify this set.
</p>
<p>Two debug levels have a special effect - 'dflt' is the level used for
debug logs statements where no debug level is specified, and 'NoWarn'
is used to *disable* warning messages.
</p>
<p>As a convenience, there are four more logging macros you can use -
NSDebugFLog(), NSDebugFLLog(), NSDebugMLog() and NSDebugMLLog().
These are the same as the other macros, but are specifically for use in
either functions or methods and prepend information about the file, line
and either function or class/method in which the message was generated.
</p>
*/
#define NSDebugLLog(level, format, args...) \
do { if (GSDebugSet(level) == YES) \
NSLog(format , ## args); } while (0)
/**
* This macro is a shorthand for NSDebugLLog() using then default debug
* level ... 'dflt'
*/
#define NSDebugLog(format, args...) \
do { if (GSDebugSet(@"dflt") == YES) \
NSLog(format , ## args); } while (0)
/**
* This macro is like NSDebugLLog() but includes the name and location
* of the function in which the macro is used as part of the log output.
*/
#define NSDebugFLLog(level, format, args...) \
do { if (GSDebugSet(level) == YES) { \
NSString *s = GSDebugFunctionMsg( \
__PRETTY_FUNCTION__, __FILE__, __LINE__, \
[NSString stringWithFormat: format, ##args]); \
NSLog(@"%@", s); }} while (0)
/**
* This macro is a shorthand for NSDebugFLLog() using then default debug
* level ... 'dflt'
*/
#define NSDebugFLog(format, args...) \
do { if (GSDebugSet(@"dflt") == YES) { \
NSString *s = GSDebugFunctionMsg( \
__PRETTY_FUNCTION__, __FILE__, __LINE__, \
[NSString stringWithFormat: format, ##args]); \
NSLog(@"%@", s); }} while (0)
/**
* This macro is like NSDebugLLog() but includes the name and location
* of the <em>method</em> in which the macro is used as part of the log output.
*/
#define NSDebugMLLog(level, format, args...) \
do { if (GSDebugSet(level) == YES) { \
NSString *s = GSDebugFunctionMsg( \
__PRETTY_FUNCTION__, __FILE__, __LINE__, \
[NSString stringWithFormat: format, ##args]); \
NSLog(@"%@", s); }} while (0)
/**
* This macro is a shorthand for NSDebugMLLog() using then default debug
* level ... 'dflt'
*/
#define NSDebugMLog(format, args...) \
do { if (GSDebugSet(@"dflt") == YES) { \
NSString *s = GSDebugFunctionMsg( \
__PRETTY_FUNCTION__, __FILE__, __LINE__, \
[NSString stringWithFormat: format, ##args]); \
NSLog(@"%@", s); }} while (0)
/**
* This macro saves the name and location of the function in
* which the macro is used, along with a short string msg as
* the tag associated with a recorded object.
*/
#define NSDebugFRLog(object, msg) \
do { \
NSString *tag = GSDebugFunctionMsg( \
__PRETTY_FUNCTION__, __FILE__, __LINE__, msg); \
GSDebugAllocationTagRecordedObject(object, tag); } while (0)
/**
* This macro saves the name and location of the method in
* which the macro is used, along with a short string msg as
* the tag associated with a recorded object.
*/
#define NSDebugMRLog(object, msg) \
do { \
NSString *tag = GSDebugMethodMsg( \
self, _cmd, __FILE__, __LINE__, msg); \
GSDebugAllocationTagRecordedObject(object, tag); } 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...)
#define NSDebugFRLog(object, msg)
#define NSDebugMRLog(object, msg)
#endif
/**
* Macro to log a message only the first time it is encountered.<br />
* Not entirely thread safe ... but that's not really important,
* it just means that it's possible for the message to be logged
* more than once if two threads call it simultaneously when it
* has not already been called.<br />
* Use this from inside a function. Pass an NSString as a format,
* followed by zero or more arguments for the format string.
* Example: GSOnceMLog(@"This function is deprecated, use another");
*/
#define GSOnceFLog(format, args...) \
do { static BOOL beenHere = NO; if (beenHere == NO) {\
NSString *s = GSDebugFunctionMsg( \
__PRETTY_FUNCTION__, __FILE__, __LINE__, \
[NSString stringWithFormat: format, ##args]); \
beenHere = YES; \
NSLog(@"%@", s); }} while (0)
/**
* Macro to log a message only the first time it is encountered.<br />
* Not entirely thread safe ... but that's not really important,
* it just means that it's possible for the message to be logged
* more than once if two threads call it simultaneously when it
* has not already been called.<br />
* Use this from inside a method. Pass an NSString as a format
* followed by zero or more arguments for the format string.<br />
* Example: GSOnceMLog(@"This method is deprecated, use another");
*/
#define GSOnceMLog(format, args...) \
do { static BOOL beenHere = NO; if (beenHere == NO) {\
NSString *s = GSDebugFunctionMsg( \
__PRETTY_FUNCTION__, __FILE__, __LINE__, \
[NSString stringWithFormat: format, ##args]); \
beenHere = YES; \
NSLog(@"%@", s); }} while (0)
#ifdef GSWARN
#import <Foundation/NSObjCRuntime.h>
/**
<p>NSWarnLog() is the basic debug logging macro used to display
warning messages using NSLog(), if warn logging was not disabled at compile
time and the disabling logging level was not set at runtime.
</p>
<p>Warning messages which can be enabled/disabled by defining GSWARN
when compiling.
</p>
<p>You can also disable these messages at runtime by supplying a
'--GNU-Debug=NoWarn' argument to the program, or by adding 'NoWarn'
to the user default array named 'GNU-Debug'.
</p>
<p>These logging macros are intended to be used when the software detects
something that it not necessarily fatal or illegal, but looks like it
might be a programming error. eg. attempting to remove 'nil' from an
NSArray, which the Spec/documentation does not prohibit, but which a
well written program should not be attempting (since an NSArray object
cannot contain a 'nil').
</p>
<p>NB. The 'warn=yes' option is understood by the GNUstep make package
to mean that GSWARN should be defined, and the 'warn=no' means that
GSWARN should be undefined. Default is to define it.
</p>
<p>To embed debug logging in your code you use the NSWarnLog() macro.
</p>
<p>As a convenience, there are two more logging macros you can use -
NSWarnFLog(), and NSWarnMLog().
These are specifically for use in either functions or methods and
prepend information about the file, line and either function or
class/method in which the message was generated.
</p>
*/
#define NSWarnLog(format, args...) \
do { if (GSDebugSet(@"NoWarn") == NO) { \
NSLog(format , ## args); }} while (0)
/**
* This macro is like NSWarnLog() but includes the name and location of the
* <em>function</em> in which the macro is used as part of the log output.
*/
#define NSWarnFLog(format, args...) \
do { if (GSDebugSet(@"NoWarn") == NO) { \
NSString *s = GSDebugFunctionMsg( \
__PRETTY_FUNCTION__, __FILE__, __LINE__, \
[NSString stringWithFormat: format, ##args]); \
NSLog(@"%@", s); }} while (0)
/**
* This macro is like NSWarnLog() but includes the name and location of the
* <em>method</em> in which the macro is used as part of the log output.
*/
#define NSWarnMLog(format, args...) \
do { if (GSDebugSet(@"NoWarn") == NO) { \
NSString *s = GSDebugFunctionMsg( \
__PRETTY_FUNCTION__, __FILE__, __LINE__, \
[NSString stringWithFormat: format, ##args]); \
NSLog(@"%@", s); }} while (0)
#else
#define NSWarnLog(format, args...)
#define NSWarnFLog(format, args...)
#define NSWarnMLog(format, args...)
#endif
/**
* Retrieve stack information. Use caution: uses built-in gcc functions
* and currently only works up to 100 frames.

View file

@ -27,12 +27,17 @@
#define __NSThread_h_GNUSTEP_BASE_INCLUDE
#import <GNUstepBase/GSVersionMacros.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSDate.h>
#if defined(GNUSTEP_BASE_INTERNAL)
#import "Foundation/NSAutoreleasePool.h" // for struct autorelease_thread_vars
#import "Foundation/NSException.h" // for NSHandler
#else
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSException.h>
#import <Foundation/NSAutoreleasePool.h> // for struct autorelease_thread_vars
#endif
@class NSArray;
@class NSDate;
@class NSMutableDictionary;
#if defined(__cplusplus)
extern "C" {
@ -372,11 +377,14 @@ GS_EXPORT NSString* const NSThreadWillExitNotification;
*/
GS_EXPORT NSString* const NSThreadDidStartNotification;
/*
* Get current thread and it's dictionary.
*/
GS_EXPORT NSThread *GSCurrentThread(void);
GS_EXPORT NSMutableDictionary *GSCurrentThreadDictionary(void);
#endif
#if !defined(NO_GNUSTEP)
# if defined(GNUSTEP_BASE_INTERNAL)
# import "GNUstepBase/NSThread+GNUstepBase.h"
# else
# import <GNUstepBase/NSThread+GNUstepBase.h>
# endif
#endif
#if defined(__cplusplus)

View file

@ -357,25 +357,6 @@ extern "C" {
+ (Class) valueClassWithObjCType: (const char*)type;
@end
/**
* Cache info for internal use by NSNumber concrete subclasses.
* DO NOT USE.
*/
typedef struct {
int typeLevel;
void (*getValue)(NSNumber*, SEL, void*);
} GSNumberInfo;
/** Internal method for caching. DO NOT USE. */
GSNumberInfo *GSNumberInfoFromObject(NSNumber *o);
#define GS_SMALL 16
/**
* Internal method: get cached values for integers in the range
* - GS_SMALL to + GS_SMALL
* <br />DO NOT USE
*/
unsigned GSSmallHash(int n);
#endif
#if defined(__cplusplus)

View file

@ -46,6 +46,7 @@ Additions_OBJC_FILES =\
NSBundle+GNUstepBase.m \
NSCalendarDate+GNUstepBase.m \
NSData+GNUstepBase.m \
NSDebug+GNUstepBase.m \
NSError+GNUstepBase.m \
NSFileHandle+GNUstepBase.m \
NSLock+GNUstepBase.m \
@ -55,6 +56,7 @@ Additions_OBJC_FILES =\
NSProcessInfo+GNUstepBase.m \
NSString+GNUstepBase.m \
NSTask+GNUstepBase.m \
NSThread+GNUstepBase.m \
NSURL+GNUstepBase.m \
behavior.m

View file

@ -0,0 +1,60 @@
/** Debugging utilities for GNUStep and OpenStep
Copyright (C) 1997,1999,2000,2001 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
Date: August 1997
Extended by: Nicola Pero <n.pero@mi.flashnet.it>
Date: December 2000, April 2001
This file is part of the GNUstep Base Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02111 USA.
$Date: 2010-02-17 11:47:06 +0000 (Wed, 17 Feb 2010) $ $Revision: 29657 $
*/
#import "config.h"
#import "Foundation/NSDebug.h"
#import "Foundation/NSString.h"
#import "GNUstepBase/NSDebug+GNUstepBase.h"
NSString*
GSDebugFunctionMsg(const char *func, const char *file, int line, NSString *fmt)
{
NSString *message;
message = [NSString stringWithFormat: @"File %s: %d. In %s %@",
file, line, func, fmt];
return message;
}
NSString*
GSDebugMethodMsg(id obj, SEL sel, const char *file, int line, NSString *fmt)
{
NSString *message;
Class cls = (Class)obj;
char c = '+';
if ([obj isInstance] == YES)
{
c = '-';
cls = [obj class];
}
message = [NSString stringWithFormat: @"File %s: %d. In [%@ %c%@] %@",
file, line, NSStringFromClass(cls), c, NSStringFromSelector(sel), fmt];
return message;
}

View file

@ -0,0 +1,45 @@
/** Control of executable units within a shared virtual memory space
Copyright (C) 2010 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
This file is part of the GNUstep Objective-C Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02111 USA.
$Date: 2010-02-17 11:47:06 +0000 (Wed, 17 Feb 2010) $ $Revision: 29657 $
*/
#import "config.h"
#if defined(__APPLE__)
/* These functions are in NSThread.m in the base library.
*/
NSThread*
GSCurrentThread(void)
{
return [NSThread currentThread];
}
NSMutableDictionary*
GSCurrentThreadDictionary(void)
{
return [GSCurrentThread() threadDictionary];
}
#endif

View file

@ -155,6 +155,7 @@ NSAttributedString+GNUstepBase.h \
NSBundle+GNUstepBase.h \
NSCalendarDate+GNUstepBase.h \
NSData+GNUstepBase.h \
NSDebug+GNUstepBase.h \
NSFileHandle+GNUstepBase.h \
NSLock+GNUstepBase.h \
NSMutableString+GNUstepBase.h \
@ -163,6 +164,7 @@ NSObject+GNUstepBase.h \
NSProcessInfo+GNUstepBase.h \
NSString+GNUstepBase.h \
NSTask+GNUstepBase.h \
NSThread+GNUstepBase.h \
NSURL+GNUstepBase.h \
behavior.h \
Unicode.h \

View file

@ -120,6 +120,7 @@ NSAttributedString+GNUstepBase.h \
NSBundle+GNUstepBase.h \
NSCalendarDate+GNUstepBase.h \
NSData+GNUstepBase.h \
NSDebug+GNUstepBase.h \
NSFileHandle+GNUstepBase.h \
NSLock+GNUstepBase.h \
NSMutableString+GNUstepBase.h \
@ -128,6 +129,7 @@ NSObject+GNUstepBase.h \
NSProcessInfo+GNUstepBase.h \
NSString+GNUstepBase.h \
NSTask+GNUstepBase.h \
NSThread+GNUstepBase.h \
NSURL+GNUstepBase.h \
Unicode.h \
GNUstep.h \

View file

@ -834,34 +834,6 @@ GSDebugAllocationListRecordedObjects(Class c)
}
NSString*
GSDebugFunctionMsg(const char *func, const char *file, int line, NSString *fmt)
{
NSString *message;
message = [NSString stringWithFormat: @"File %s: %d. In %s %@",
file, line, func, fmt];
return message;
}
NSString*
GSDebugMethodMsg(id obj, SEL sel, const char *file, int line, NSString *fmt)
{
NSString *message;
Class cls = (Class)obj;
char c = '+';
if ([obj isInstance] == YES)
{
c = '-';
cls = [obj class];
}
message = [NSString stringWithFormat: @"File %s: %d. In [%@ %c%@] %@",
file, line, NSStringFromClass(cls), c, NSStringFromSelector(sel), fmt];
return message;
}
#define _NS_FRAME_HACK(a) \
case a: env->addr = __builtin_frame_address(a + 1); break;
#define _NS_RETURN_HACK(a) \

View file

@ -651,7 +651,7 @@
roundedNumber = [roundedNumber decimalNumberByMultiplyingBy:
(NSDecimalNumber*)[NSDecimalNumber numberWithInt: -1]];
intPart = (NSDecimalNumber*)
[NSDecimalNumber numberWithInt: [roundedNumber intValue]];
[NSDecimalNumber numberWithInt: (int)[roundedNumber doubleValue]];
fracPart = [roundedNumber decimalNumberBySubtracting: intPart];
intPartString
= AUTORELEASE([[intPart descriptionWithLocale: locale] mutableCopy]);

View file

@ -1,21 +1,21 @@
#define INTEGER_MACRO(type, name, ignored) \
- (type) name ## Value\
{\
return (type)VALUE;\
return (type)VALUE;\
}
#include "GSNumberTypes.h"
- (const char *)objCType
- (const char *) objCType
{
return @encode(typeof(VALUE));
return @encode(typeof(VALUE));
}
- (NSString*)descriptionWithLocale: (id)aLocale
- (NSString*) descriptionWithLocale: (id)aLocale
{
return [[[NSString alloc] initWithFormat: FORMAT
locale: aLocale, VALUE] autorelease];
return [[[NSString alloc] initWithFormat: FORMAT
locale: aLocale, VALUE] autorelease];
}
- (void)getValue: (void*)buffer
- (void) getValue: (void*)buffer
{
typeof(VALUE) *ptr = buffer;
*ptr = VALUE;
typeof(VALUE) *ptr = buffer;
*ptr = VALUE;
}
#undef FORMAT

View file

@ -32,6 +32,7 @@
#import "Foundation/NSOperation.h"
#import "Foundation/NSArray.h"
#import "Foundation/NSAutoreleasePool.h"
#import "Foundation/NSDictionary.h"
#import "Foundation/NSEnumerator.h"
#import "Foundation/NSException.h"
#import "Foundation/NSLock.h"