diff --git a/ANNOUNCE b/ANNOUNCE index d65b538bd..5b9b63e26 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,7 +1,7 @@ Announcement ************ -The GNUstep Base Library, version 0.6.5, is now available. +The GNUstep Base Library, version 0.6.6, is now available. What is the GNUstep Base Library? ================================= @@ -22,8 +22,8 @@ portion of the OpenStep standard (the Foundation library). Where can you get it? How can you compile it? ============================================== - The gstepbase-0.6.5.tar.gz distribution file has been placed on -`ftp.gnu.org' in `pub/gnu/gstep'. + The gstepbase-0.6.6.tar.gz distribution file has been placed on +`ftp.gnustep.org' in `pub/gnustep/core'. The library requires gcc 2.8.0 or higher. Significant sections of the library do not work with the NeXT runtime, so we recommend using @@ -40,44 +40,3 @@ two `quit'. The most recent (not necessarily tested) snapshots of the library will be placed on `alpha.gnu.org'. - - -[ Most GNU software is packed using the GNU `gzip' compression program. - Source code is available on most sites distributing GNU software. - - For information on how to order GNU software on tape, floppy or cd-rom, or - printed GNU manuals, check the file etc/ORDERS in the GNU Emacs distribution - or in GNUinfo/ORDERS on prep, or e-mail a request to: gnu@prep.ai.mit.edu - - By ordering your GNU software from the FSF, you help us continue to - develop more free software. Media revenues are our primary source of - support. Donations to FSF are deductible on US tax returns. - - The above software will soon be at these ftp sites as well. - Please try them before prep.ai.mit.edu as prep is very busy! - - thanx -gnu@prep.ai.mit.edu - - ASIA: ftp.cs.titech.ac.jp, utsun.s.u-tokyo.ac.jp:/ftpsync/prep, - cair.kaist.ac.kr:/pub/gnu, ftp.nectec.or.th:/pub/mirrors/gnu - AUSTRALIA: archie.au:/gnu (archie.oz or archie.oz.au for ACSnet) - AFRICA: ftp.sun.ac.za:/pub/gnu - MIDDLE-EAST: ftp.technion.ac.il:/pub/unsupported/gnu - EUROPE: irisa.irisa.fr:/pub/gnu, ftp.univ-lyon1.fr:pub/gnu, - ftp.mcc.ac.uk, unix.hensa.ac.uk:/pub/uunet/systems/gnu, - src.doc.ic.ac.uk:/gnu, ftp.ieunet.ie:pub/gnu, ftp.eunet.ch, - nic.switch.ch:/mirror/gnu, ftp.informatik.rwth-aachen.de:/pub/gnu, - ftp.informatik.tu-muenchen.de, ftp.win.tue.nl:/pub/gnu, - ftp.funet.fi:/pub/gnu, ftp.denet.dk, ftp.stacken.kth.se, isy.liu.se, - ftp.luth.se:/pub/unix/gnu, ftp.sunet.se:/pub/gnu, archive.eu.net - SOUTH AMERICA: ftp.unicamp.br:/pub/gnu - WESTERN CANADA: ftp.cs.ubc.ca:/mirror2/gnu - USA: wuarchive.wustl.edu:/systems/gnu, labrea.stanford.edu, - ftp.digex.net:/pub/gnu, ftp.kpc.com:/pub/mirror/gnu, f.ms.uky.edu:/pub3/gnu, - jaguar.utah.edu:/gnustuff, ftp.hawaii.edu:/mirrors/gnu, - vixen.cso.uiuc.edu:/gnu, mrcnext.cso.uiuc.edu:/pub/gnu, - ftp.cs.columbia.edu:/archives/gnu/prep, col.hp.com:/mirrors/gnu, - gatekeeper.dec.com:/pub/GNU, ftp.uu.net:/systems/gnu - -] - diff --git a/BUGS b/BUGS index 1b1c1ef05..25aa50060 100644 --- a/BUGS +++ b/BUGS @@ -1,15 +1,16 @@ TODO **** - * NSZone memory allocation may not work correctly. If you encounter - a problem with NSZones, switch to using the default zone instead - of creating one. + * Some people have reported NSZone memory allocation problems. If + you encounter a problem with NSZones, switch to using the default + zone instead of creating one. Or better yet, fix the problem and + submit a patch. - * Invocations (and by extension, Distributed Objects) work well only - on ix86 platforms. In particular, they don't work well on PPC and - Sparc platforms. + * Invocations (and by extension, Distributed Objects) have been well + tested only on ix86 platforms. In particular, there are still + minor problems on PPC and Sparc platforms. - * Distributed Objects aren't thread safe. Don't use DO between - threads in a multi-theaded app. + * Distributed Objects is now thread safe, but it hasn't been well + tested. diff --git a/ChangeLog b/ChangeLog index a40fb1654..d423b050a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2000-08-07 Adam Fedor + + * Merge 0.6.6 branch into main. + 2000-07-24 Richard Frith-Macdonald * Tools/gdomap.c: Permit dumping of internal table of known peer @@ -27,6 +31,191 @@ * Source/GNUMakefile: Add NSDecimal and NSDecimalNumber +2000-08-06 Adam Fedor + + * Version 0.6.6 released. + + * Source/NSTimer.m (-compare:): Add return to quiet warning. + +2000-08-04 Richard Frith-Macdonald + + * Source/NSPortNameServer.m: include netinet/in.h as needed on + FreeBSD to define values used in arpa/inet.h + +2000-08-03 Richard Frith-Macdonald + + * Source/NSHost: ([_initWithHostEntry:key:]) workaround for buggy + host entries with missing h_aliases + +2000-08-03 Richard Frith-Macdonald + + * NSTimeZones/NSTimeZones.tar: Updated to latest (July 31st) info + +2000-08-02 Adam Fedor + + * Version: Update version number + * Documentation/announce.tmpl.texi: Update + * Documentation/readme.tmpl.texi: Likewise. + * Documentation/news.tmpl.texi: Likewise. + * Documentation/todo.tmpl.texi: Likewise. + * ANNOUNCE, BUGS, NEWS, README: Regenerate + +2000-08-02 Adam Fedor + + * Testing/nsconnection_client.m: Rewrite, organize. + * Testing/nsconnection_server.m: Likewise. + +2000-08-02 Richard Frith-Macdonald + + * Source/GSTcpPort.m: ([-removeHandle:]) corrected logic for releasing + self when port was created and retained by an incoming connection. + +2000-08-01 Adam Fedor + + * Source/NSConcreteNumber.m (-compare:): Add return at end to quiet + compiler warning. + + * Source/NSFileHandle.m: Change +fileHandle... methods to use + abstracts class's allocWithZone. + + * Source/libgnustep-base.def: Update for new/removed classes. + +2000-08-01 Richard Frith-Macdonald + + * Source/NSCalendarDate.m: Correct order of args to + lastDayOfGregorianMonth() + * Source/NSPortCoder.m: Handle classes encoded as objects specially. + * Source/NSArchiver.m: ditto. + * Source/NNSUnarchiver.m: ditto. + +2000-07-31 Richard Frith-Macdonald + + * Source/Foundation/NSDebug.h: removed GS_IMPORT + * Source/Foundation/NSObjCRuntime.h: ditto + * Source/Foundation/GSConfig.h.in: ditto + +2000-07-31 Richard Frith-Macdonald + + * Source/NSString.m: implement -cStringLength correctly in terms of + other methods of the abstract class, rather than making the subclass + do it. Cache [-characterAtIndex:] implementation for speed + throughout. + * Source/Unicode.m: Remove uslen() function - unused and unsafe. + Tidied code and optimised a little. + * Source/Foundation/Unicode.h: Remove uslen() + * Source/NSNumber.m: Check for nul argument to [-compare:] + * Source/NSDate.m: ditto + * Source/NSObject.m: ditto + * Source/NSConcreteNumber.m: ditto + * Source/NSTimer.m: ditto + +2000-07-30 Richard Frith-Macdonald + + * Tools/nconnection.m: Trivial test of basic inter-thread use of + DO taken from example code in Applde documentation. + +2000-07-29 Richard Frith-Macdonald + + Varous cluster classes - Bugfix to let allocWithZone work for + new concrete subclasses in the cluster. + * Source/NSPortCoder.m: Accept classes when asked to decode object. + * Source/NSUnarchiver.m: ditto. + +2000-07-28 Richard Frith-Macdonald + + * Source/NSConnection.m: Don't create/use locks until the app + goes multi-threaded. + * Source/GSTcpPort.m: ditto. + +2000-07-27 Richard Frith-Macdonald + + * Source/GSTcpPort.m: Fix stupid error in last bugfix + * Source/Foundation/GSConfig.h.in: define GS_SIZEOF_VOIDP + * configure.in: provide GS_SIZEOF_VOIDP + +2000-07-27 Richard Frith-Macdonald + + * Source/NSThread.m: clarify code for getting current thread. + +2000-07-27 Richard Frith-Macdonald + + * Source/Foundation/NSDebug.h: Bugfix reported by Frederic.De.Jaeger + to prevent incorrect processor handling of cases where logging format + string has no arguments. + +2000-07-26 Richard Frith-Macdonald + + * Source/GSTcpPort.m: When given bad data on a socket, log a message + and invalidate the socket handle rather than raising an exception + and crashing. Should make system more robust in the face of attacks. + +2000-07-24 Adam Fedor + + * Source/GSTcpPort.m + (-sendBeforeDate:msgid:components:from:reserved:]): Correct typo. + +2000-07-24 Richard Frith-Macdonald + + Testing directory tidied to reflect removal of old classes. + * Source/NSTimer.m: Tidied a little. + +2000-07-23 Richard Frith-Macdonald + + Old DO code removed along with associated libObjects classes that it + required - library slimmed down. + +2000-07-21 Richard Frith-Macdonald + + * Source/NSGCString.m: implement methods to get numeric values. + * Source/NSGString.m: implement methods to get numeric values. + +2000-07-19 Adam Fedor + + * Documentation/news.tmpl.texi: Update. + * Documentation/todo.tmpl.texi: Update. + +2000-07-18 Richard Frith-Macdonald + + * Tools/Makefile.postamble: Improve warning messages for gdomap install + * Source/NSProcessInfo.m: Change __MINGW32__ to __MINGW__ + * Source/GSTcpPort.m: improve encoding of local port for send over wire + +2000-07-17 Adam Fedor + + * Source/NSZone.m: Remove duplicate function definitions (when + GS_WITH_GC is 1) already defined in NSZone.h. + +2000-07-17 Richard Frith-Macdonald + + * Source/externs.m: Some evil casts to avoid compiler warnings about + assigning to constant variables when we initiallise them. + * Source/NSGSet.m: implemented [-anyObject] and [-allObjects] + * Source/NSSet.m: Fix to encode subclasses as abstract class. + Remove unused methods for set/get concrete class + * Source/NSCountedSet.m: ditto + * Source/NSNumber.m: Use explicitly signed types for portability - + particularly for systems (eg PPC) where char is not signed by default. + * Source/NSConcrete.m: ditto. + * Source/NSConcreteNumber.m: ditto. + * Source/Foundation/NSValue.h: ditto + * Source/Foundation/NSConcreteNumber.h: ditto + * Source/NSArray.m: Remove unused methods for set/get concrete class + * Source/NSDictionary.m: ditto. + * Source/NSString.m: ditto. + * Source/NSAttributedString.m: ditto. + * Source/NSHost.m: store names and addresses in sets for improved + performance (comparisons). + Encode host as an address other than loopback if possible. + Add code for a new '+localHost' method to try to get ALL + names/addresses of current host. + * Source/NSPortNameServer.m: Use new localHost method. + * Source/GSTcpPort.m: Use new localHost method. + +2000-07-16 Adam Fedor + + * Tools/GNUmakefile (gdomap): Make as a C-tool rather than an + Objective-C program (no need for libobjc). + 2000-07-07 Jonathan Gapen * Source/NSString.m: (-initWithFormat:), (-initWithFormat:locale:), diff --git a/Documentation/announce.tmpl.texi b/Documentation/announce.tmpl.texi index bb59045d9..9b43eed5e 100644 --- a/Documentation/announce.tmpl.texi +++ b/Documentation/announce.tmpl.texi @@ -54,45 +54,3 @@ with line one @samp{help} and line two @samp{quit}. The most recent (not necessarily tested) snapshots of the library will be placed on @samp{@value{GNUSTEP-BASE-SNAP-FTP-MACHINE}}. -@format - - -[ Most GNU software is packed using the GNU `gzip' compression program. - Source code is available on most sites distributing GNU software. - - For information on how to order GNU software on tape, floppy or cd-rom, or - printed GNU manuals, check the file etc/ORDERS in the GNU Emacs distribution - or in GNUinfo/ORDERS on prep, or e-mail a request to: gnu@@prep.ai.mit.edu - - By ordering your GNU software from the FSF, you help us continue to - develop more free software. Media revenues are our primary source of - support. Donations to FSF are deductible on US tax returns. - - The above software will soon be at these ftp sites as well. - Please try them before prep.ai.mit.edu as prep is very busy! - - thanx -gnu@@prep.ai.mit.edu - - ASIA: ftp.cs.titech.ac.jp, utsun.s.u-tokyo.ac.jp:/ftpsync/prep, - cair.kaist.ac.kr:/pub/gnu, ftp.nectec.or.th:/pub/mirrors/gnu - AUSTRALIA: archie.au:/gnu (archie.oz or archie.oz.au for ACSnet) - AFRICA: ftp.sun.ac.za:/pub/gnu - MIDDLE-EAST: ftp.technion.ac.il:/pub/unsupported/gnu - EUROPE: irisa.irisa.fr:/pub/gnu, ftp.univ-lyon1.fr:pub/gnu, - ftp.mcc.ac.uk, unix.hensa.ac.uk:/pub/uunet/systems/gnu, - src.doc.ic.ac.uk:/gnu, ftp.ieunet.ie:pub/gnu, ftp.eunet.ch, - nic.switch.ch:/mirror/gnu, ftp.informatik.rwth-aachen.de:/pub/gnu, - ftp.informatik.tu-muenchen.de, ftp.win.tue.nl:/pub/gnu, - ftp.funet.fi:/pub/gnu, ftp.denet.dk, ftp.stacken.kth.se, isy.liu.se, - ftp.luth.se:/pub/unix/gnu, ftp.sunet.se:/pub/gnu, archive.eu.net - SOUTH AMERICA: ftp.unicamp.br:/pub/gnu - WESTERN CANADA: ftp.cs.ubc.ca:/mirror2/gnu - USA: wuarchive.wustl.edu:/systems/gnu, labrea.stanford.edu, - ftp.digex.net:/pub/gnu, ftp.kpc.com:/pub/mirror/gnu, f.ms.uky.edu:/pub3/gnu, - jaguar.utah.edu:/gnustuff, ftp.hawaii.edu:/mirrors/gnu, - vixen.cso.uiuc.edu:/gnu, mrcnext.cso.uiuc.edu:/pub/gnu, - ftp.cs.columbia.edu:/archives/gnu/prep, col.hp.com:/mirrors/gnu, - gatekeeper.dec.com:/pub/GNU, ftp.uu.net:/systems/gnu - -] -@end format diff --git a/Documentation/coding-standards.tmpl.texi b/Documentation/coding-standards.tmpl.texi index b129e59dc..64ee26620 100644 --- a/Documentation/coding-standards.tmpl.texi +++ b/Documentation/coding-standards.tmpl.texi @@ -62,6 +62,7 @@ into another language, under the above conditions for modified versions. * Coding Style:: * Memory Management:: * Error Handling:: +* Contributing:: @end menu @c ****************************************************************** @@ -248,7 +249,7 @@ of code is involved @end example @c ****************************************************************** -@node Memory Management, Error Handling , Coding Style, Top +@node Memory Management, Error Handling, Coding Style, Top @section Memory Management In anticipation of the day when we can make the use of a Garbage Collector @@ -281,7 +282,7 @@ in use. @end itemize @c ****************************************************************** -@node Error Handling, , Memory Management, Top +@node Error Handling, Contributing, Memory Management, Top @section Error Handling Initialization methods (e.g. -init) should, upon failure to @@ -320,4 +321,40 @@ Java has the "finally" block which is specifically designed for this task. A similar mechanism exists in libFoundation with the CLEANUP and FINALLY blocks. +@node Contributing, , Error Handling, Top +@section Contributing + +Contributing code is not difficult. Here are +some general guidelines: + +@itemize @bullet + +@item +FSF must maintain the right to accept or reject potential contributions. +Generally, the only reasons for rejecting contributions are cases where +they duplicate existing or nearly-released code, contain unremovable +specific machine dependencies, or are somehow incompatible with the +rest of the library. + +@item +Acceptance of contributions means that the code is accepted for adaptation +into libgnustep-base. FSF must reserve the right to make various editorial changes +in code. Very often, this merely entails formatting, maintenance of various +conventions, etc. Contributors are always given authorship credit and shown +the final version for approval. + +@item +Contributors must assign their copyright to FSF via a form sent out +upon acceptance. Assigning copyright to FSF ensures that the code +may be freely distributed. + +@item +Assistance in providing documentation, test files, and debugging +support is strongly encouraged. + +@end itemize + +Extensions, comments, and suggested modifications of existing libgnustep-base +features are also very welcome. + @bye diff --git a/Documentation/gnustep-base.tmpl.texi b/Documentation/gnustep-base.tmpl.texi index c03e9beb1..b35e090a5 100644 --- a/Documentation/gnustep-base.tmpl.texi +++ b/Documentation/gnustep-base.tmpl.texi @@ -98,20 +98,21 @@ and the MacOS-X Foundation implementation. * Tools:: * Installation:: * Implementation:: -* Coding Standards:: -* Contributing:: * Concept Index:: @end menu @node Overview, Configuration, Top, Top @chapter Overview -The GNUstep Base Library (gstep-base) requires the GNUstep Makefile +*The GNUstep Base Library (gstep-base) requires the GNUstep Makefile Package (gstep-make) to compile. A recent GCC compiler may also be needed as well as other libraries. You should consult the @file{GNUstep-HOWTO} document that comes with the GNUstep Core Libraries package (gstep-core) or information on supported machines on the web -site @url{http://www.gnustep.org/information} +site @url{http://www.gnustep.org/information}. + +Documentation for individual classes is included in gsdoc (and html) format +in the gsdoc directory. @node Configuration, Classes, Overview, Top @chapter Configuration @@ -124,15 +125,21 @@ for a list of these. It is not likely that you will need to use the the directory specified by the @code{GNUSTEP_SYSTEM_ROOT} environment variable (specified when you installed gstep-make). -The only feature you may want to use is the @code{--enable-fake-main} -option. Normally, the configure script will determine if a program can -read process information directly from the system (for use by the class -NSProcessInfo) and enable or disable the fake-main hack automatically, -but if you find that configure is not doing this correctly, you can -force the fake-main hack to be used, which will always work. Note that -if the fake-main hack is enabled, you need to include the header file -GSConfig.h in you main program -- this is done by default if you include -NSObject.h or Foundation.h. +The only feature you may want to use is the +@code{--enable-pass-arguments} or the @code{--enable-fake-main} +option(s). Normally, the configure script will determine if a program +can read process information directly from the system (for use by the +class NSProcessInfo) and enable or disable the fake-main hack +automatically, but if you find that configure is not doing this +correctly, you can force the fake-main hack to be used, which will +always work. Note that if the fake-main hack is enabled, you need to +include the header file GSConfig.h in you main program -- this is done +by default if you include NSObject.h or Foundation.h. If you want to +avoid the whole idea of the fake-main hack, you can use the +pass-arguments option. In this case you will be forced to call the +NSProcessInfo initializeWithArguments method to pass the program +arguments to NSProcessInfo (This would be done automatically if you use +the NSApplicationMain function in a gui application). Most other important configuration options are already set when you configure the gstep-make package. @@ -148,7 +155,7 @@ configure the gstep-make package. Type @code{make install} to install the libraries and programs -@node Implementation, Coding Standards, Installation, Top +@node Implementation, Concept Index, Installation, Top @chapter Implementation Details @menu @@ -166,12 +173,6 @@ The OpenStep standard defines an reference-count based memory management scheme using the Boehm conservative garbage collecting library, though this is currently (October 1999) in a pre-alpha state. -@menu -* Memory Allocation:: -* Reference Counting:: -* Garbage Collection:: -@end menu - @node Memory Allocation, Reference Counting, Memory Management, Implementation @section Memory Allocation @@ -269,94 +270,9 @@ implement, and also that time zone names may vary wildly between OSes (this could be a big problem when archiving is used between different systems). -@c ****************************************************************** -@node Coding Standards, Contributing, Implementation, Top -@chapter Coding Standards -This chapter explains the official coding standards which developers -for GNUstep base should follow. Note that these standards are in addition -to GNU coding standards, not a replacement of them. -@menu -* Error Handling:: -@end menu - -@node Error Handling, , Coding Standards, Coding Standards -@section Error Handling - -Initialization methods (e.g. -init) should, upon failure to -initialize the class, deallocate itself and return nil. This may mean -in certain cases, that it should catch exceptions, since the calling -method will be expecting a nil object rather than an exception on -failure. However, init methods should endeavor to provide some -information, via NSLog, on the failure. - -All other methods should cause an exception on failure*, unless -returning nil is a valid response (e.g. [dictionary -objectForKey: nil]) or if documented otherwise. - -Failure here is a relative term. I'd interpret failure to occur when -either system resources have been exceeded, an operation was performed -on invalid data, or a required precondition was not met. -On the other hand, passing a nil object as a parameter (as in -[(NSMutableData *)data appendData: nil]), or other "unusual" -requests should succeed in a reasonable manner (or return nil, if -appropriate) and/or reasonable default values could be used. - -If an error is recoverable or it does not damage the internal state of -an object, it's ok not to raise an error. At the very least, though, a message -should be printed through NSLog. - -Special care should be taken in methods that create resources like -allocate memory or open files or obtain general system resources (locks, -shared memory etc.) from the kernel. If an exception is generated -between the allocation of the resource and its disposal, the resource -will be simply lost without any possibility to release. The code should -check for exceptions and if something bad occurs it should release all -the allocated resources and reraise the exception. - -Unfortunately there is no nice way to do this automatically in OpenStep. -Java has the "finally" block which is specifically designed for this task. A -similar mechanism exists in libFoundation with the CLEANUP and FINALLY -blocks. - -@node Contributing, Concept Index, Coding Standards, Top -@chapter Contributing - -Contributing code is not difficult. Here are -some general guidelines: - -@itemize @bullet - -@item -FSF must maintain the right to accept or reject potential contributions. -Generally, the only reasons for rejecting contributions are cases where -they duplicate existing or nearly-released code, contain unremovable -specific machine dependencies, or are somehow incompatible with the -rest of the library. - -@item -Acceptance of contributions means that the code is accepted for adaptation -into libgnustep-base. FSF must reserve the right to make various editorial changes -in code. Very often, this merely entails formatting, maintenance of various -conventions, etc. Contributors are always given authorship credit and shown -the final version for approval. - -@item -Contributors must assign their copyright to FSF via a form sent out -upon acceptance. Assigning copyright to FSF ensures that the code -may be freely distributed. - -@item -Assistance in providing documentation, test files, and debugging -support is strongly encouraged. - -@end itemize - -Extensions, comments, and suggested modifications of existing libgnustep-base -features are also very welcome. - -@node Concept Index, , Contributing, Top +@node Concept Index, , Implementation, Top @unnumbered Concept Index @printindex cp diff --git a/Documentation/news.tmpl.texi b/Documentation/news.tmpl.texi index 59e023e5c..fca5ffca5 100644 --- a/Documentation/news.tmpl.texi +++ b/Documentation/news.tmpl.texi @@ -7,6 +7,22 @@ The currently released version of the library is @samp{@value{GNUSTEP-BASE-VERSION}}. +@section Noteworthy changes in version @samp{0.6.6} + +@itemize @bullet +@item Lots of new documentation. +@item Completely rewritten Distributed Object to be much more compatible with +the MacOS-X API (and incidentally, closer to the original OpenStep standard). +@item Support to compile library as a DLL on Windows (still cygwin only). +@item Removed lots of obsolete classes. +@item New tools for handling property lists. +@item More optimization of classes. +@end itemize + +@c ==================================================================== +@c Keep the next line just below the list of changes in most recent version. +@ifclear ANNOUNCE-ONLY + @section Noteworthy changes in version @samp{0.6.5} @itemize @bullet @@ -228,10 +244,6 @@ NSAllocateMemoryPages, NSDeallocateMemoryPages, NSCopyMemoryPages. @end itemize -@c ==================================================================== -@c Keep the next line just below the list of changes in most recent version. -@ifclear ANNOUNCE-ONLY - @section Noteworthy changes since version @samp{0.1.14} @itemize @bullet diff --git a/Documentation/todo.tmpl.texi b/Documentation/todo.tmpl.texi index 371dd4e8e..ded942cb4 100644 --- a/Documentation/todo.tmpl.texi +++ b/Documentation/todo.tmpl.texi @@ -10,15 +10,16 @@ @itemize @bullet -@item NSZone memory allocation may not work correctly. If you -encounter a problem with NSZones, switch to using the -default zone instead of creating one. +@item Some people have reported NSZone memory allocation problems. +If you encounter a problem with NSZones, switch to using the +default zone instead of creating one. Or better yet, fix the problem and +submit a patch. -@item Invocations (and by extension, Distributed Objects) work well only -on ix86 platforms. In particular, they don't work well on PPC and Sparc +@item Invocations (and by extension, Distributed Objects) have been well tested only +on ix86 platforms. In particular, there are still minor problems on PPC and Sparc platforms. -@item Distributed Objects aren't thread safe. Don't use DO -between threads in a multi-theaded app. +@item Distributed Objects is now thread safe, but it hasn't been well +tested. @end itemize diff --git a/Headers/gnustep/base/GSConfig.h.in b/Headers/gnustep/base/GSConfig.h.in index f8d4e764a..e41849627 100644 --- a/Headers/gnustep/base/GSConfig.h.in +++ b/Headers/gnustep/base/GSConfig.h.in @@ -77,7 +77,7 @@ */ #define main gnustep_base_user_main -GS_IMPORT int gnustep_base_user_main (/* int argc, char *argv[] */); +extern int gnustep_base_user_main (/* int argc, char *argv[] */); #endif /* GS_FAKE_MAIN */ @@ -97,6 +97,7 @@ GS_IMPORT int gnustep_base_user_main (/* int argc, char *argv[] */); #define GS_SIZEOF_LONG_LONG @ac_cv_sizeof_long_long@ #define GS_SIZEOF_FLOAT @ac_cv_sizeof_float@ #define GS_SIZEOF_DOUBLE @ac_cv_sizeof_double@ +#define GS_SIZEOF_VOIDP @ac_cv_sizeof_voidp@ /* * Size information to be places in bits 5 and 6 of type encoding bytes diff --git a/Headers/gnustep/base/NSArray.h b/Headers/gnustep/base/NSArray.h index 1f058ef4f..cb2572f10 100644 --- a/Headers/gnustep/base/NSArray.h +++ b/Headers/gnustep/base/NSArray.h @@ -135,4 +135,26 @@ @end +@interface NSArray (GNUstep) +/* + * Extension methods for working with sorted arrays - use a binary chop + * to determine the insertion location for an nobject. If equal objects + * already exist in the array, they will be located immediately before + * the insertion position. + * + * The comparator function takes two items as arguments, the first is the + * item to be added, the second is the item already in the array. + * The function should return NSOrderedAscending if the item to be + * added is 'less than' the item in the array, NSOrderedDescending + * if it is greater, and NSOrderedSame if it is equal. + * + * The selector version works the same - returning NSOrderedAscending if + * the reciever is 'less than' the item in the array. + */ +- (unsigned) insertionPosition: (id)item + usingFunction: (NSComparisonResult (*)(id, id))sorter; +- (unsigned) insertionPosition: (id)item + usingSelector: (SEL)comp; +@end + #endif /* __NSArray_h_GNUSTEP_BASE_INCLUDE */ diff --git a/Headers/gnustep/base/NSConcreteNumber.h b/Headers/gnustep/base/NSConcreteNumber.h index b5bd1cd0b..59163c03d 100644 --- a/Headers/gnustep/base/NSConcreteNumber.h +++ b/Headers/gnustep/base/NSConcreteNumber.h @@ -26,79 +26,79 @@ @interface NSBoolNumber : NSNumber { - BOOL data; + BOOL data; } @end @interface NSUCharNumber : NSNumber { - unsigned char data; + unsigned char data; } @end @interface NSCharNumber : NSNumber { - char data; + signed char data; } @end @interface NSUShortNumber : NSNumber { - unsigned short data; + unsigned short data; } @end @interface NSShortNumber : NSNumber { - short data; + signed short data; } @end @interface NSUIntNumber : NSNumber { - unsigned int data; + unsigned int data; } @end @interface NSIntNumber : NSNumber { - int data; + signed int data; } @end @interface NSULongNumber : NSNumber { - unsigned long data; + unsigned long data; } @end @interface NSLongNumber : NSNumber { - long data; + signed long data; } @end @interface NSULongLongNumber : NSNumber { - unsigned long long data; + unsigned long long data; } @end @interface NSLongLongNumber : NSNumber { - long long data; + signed long long data; } @end @interface NSFloatNumber : NSNumber { - float data; + float data; } @end @interface NSDoubleNumber : NSNumber { - double data; + double data; } @end diff --git a/Headers/gnustep/base/NSConnection.h b/Headers/gnustep/base/NSConnection.h index 479feb45e..db6efb240 100644 --- a/Headers/gnustep/base/NSConnection.h +++ b/Headers/gnustep/base/NSConnection.h @@ -1,4 +1,3 @@ -#if GS_NEW_DO /* Interface for GNU Objective-C version of NSConnection Copyright (C) 1997,2000 Free Software Foundation, Inc. @@ -241,318 +240,3 @@ GS_EXPORT NSString *NSConnectionDidInitializeNotification; /* OPENSTEP */ GS_EXPORT NSString *NSFailedAuthenticationException; /* MacOS-X */ #endif /* __NSConnection_h_GNUSTEP_BASE_INCLUDE */ -#else -/* Interface for GNU Objective-C version of NSConnection - Copyright (C) 1997 Free Software Foundation, Inc. - - Original by: Andrew Kachites McCallum - Version for OPENSTEP by: Richard Frith-Macdonald - Created: August 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 Library 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 Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. - */ - -#ifndef __NSConnection_h_GNUSTEP_BASE_INCLUDE -#define __NSConnection_h_GNUSTEP_BASE_INCLUDE - -#include -#include -#include -#include -#include -#include - -@class NSDistantObject; -@class NSPort; -@class NSData; - -/* - * Keys for the NSDictionary returned by [NSConnection -statistics] - */ -/* These in OPENSTEP 4.2 */ -GS_EXPORT NSString *NSConnectionRepliesReceived; -GS_EXPORT NSString *NSConnectionRepliesSent; -GS_EXPORT NSString *NSConnectionRequestsReceived; -GS_EXPORT NSString *NSConnectionRequestsSent; -/* These Are GNUstep extras */ -GS_EXPORT NSString *NSConnectionLocalCount; /* Objects sent out */ -GS_EXPORT NSString *NSConnectionProxyCount; /* Objects received */ - - -/* - * NSConnection class interface. - * - * A few methods are in the specification but not yet implemented. - */ -@interface NSConnection : NSObject -{ -@private - BOOL is_valid; - BOOL independent_queueing; - unsigned request_depth; - NSPort *receive_port; - NSPort *send_port; - unsigned message_count; - unsigned req_out_count; - unsigned req_in_count; - unsigned rep_out_count; - unsigned rep_in_count; - NSMapTable *local_objects; - NSMapTable *local_targets; - NSMapTable *remote_proxies; - NSTimeInterval reply_timeout; - NSTimeInterval request_timeout; - Class receive_port_class; - Class send_port_class; - Class encoding_class; - id delegate; - NSMutableArray *request_modes; -} - -+ (NSArray*) allConnections; -+ (NSConnection*) connectionWithRegisteredName: (NSString*)n - host: (NSString*)h; -+ (id)currentConversation; -+ (NSConnection*) defaultConnection; -+ (NSDistantObject*) rootProxyForConnectionWithRegisteredName: (NSString*)name - host: (NSString*)host; - -- (void) addRequestMode: (NSString*)mode; -- (void) addRunLoop: (NSRunLoop *)runloop; -- (id) delegate; -- (void) enableMultipleThreads; -- (BOOL) multipleThreadsEnabled; -- (BOOL) independentConversationQueueing; -- (void) invalidate; -- (BOOL) isValid; -- (BOOL) registerName: (NSString*)name; -- (NSArray *) remoteObjects; -- (void) removeRequestMode: (NSString*)mode; -- (void) removeRunLoop: (NSRunLoop *)runloop; -- (NSTimeInterval) replyTimeout; -- (NSArray*) requestModes; -- (NSTimeInterval) requestTimeout; -- (id) rootObject; -- (NSDistantObject*) rootProxy; -- (void) setDelegate: anObj; -- (void) setIndependentConversationQueueing: (BOOL)flag; -- (void) setReplyTimeout: (NSTimeInterval)seconds; -- (void) setRequestMode: (NSString*)mode; -- (void) setRequestTimeout: (NSTimeInterval)seconds; -- (void) setRootObject: anObj; -- (NSDictionary*) statistics; -@end - - -/* - * This catagory contains methods which were not in the original - * OpenStep specification, but which are in OPENSTEP. - * Some methods are not yet implemented. - */ -@interface NSConnection (OPENSTEP) -+ (NSConnection*) connectionWithReceivePort: (NSPort*)r - sendPort: (NSPort*)s; -- initWithReceivePort: (NSPort*)r - sendPort: (NSPort*)s; -- (NSPort*) receivePort; -- (void) runInNewThread; -- (NSPort*) sendPort; -@end - - -/* - * This catagory contains legacy methods from the original GNU 'Connection' - * class, and useful extensions to NSConnection. - */ -@interface NSConnection (GNUstepExtensions) - -- (void) gcFinalize; - -/* Setting and getting class configuration */ -+ (Class) defaultReceivePortClass; -+ (void) setDefaultReceivePortClass: (Class) aPortClass; -+ (Class) defaultSendPortClass; -+ (void) setDefaultSendPortClass: (Class) aPortClass; -+ (Class) defaultProxyClass; -+ (void) setDefaultProxyClass: (Class) aClass; -+ (int) defaultOutTimeout; -+ (void) setDefaultOutTimeout: (int)to; -+ (int) defaultInTimeout; -+ (void) setDefaultInTimeout: (int)to; - -/* Querying the state of all the connections */ -+ (int) messagesReceived; -+ (unsigned) connectionsCount; -+ (unsigned) connectionsCountWithInPort: (NSPort*)aPort; - -/* Registering your server object on the network. - These methods create a new connection object that must be "run" in order - to start handling requests from clients. - These method names may change when we get the capability to register - ports with names after the ports have been created. */ -/* I want the second method name to clearly indicate that we're not - connecting to a pre-existing registration name, we're registering a - new name, and this method will fail if that name has already been - registered. This is why I don't like "newWithRegisteredName:" --- - it's unclear if we're connecting to another NSConnection that already - registered with that name. */ -+ (NSConnection*) newWithRootObject: anObj; -+ (NSConnection*) newRegisteringAtName: (NSString*)n - withRootObject: anObj; -+ (NSConnection*) newRegisteringAtName: (NSString*)n - atPort: (int)portn - withRootObject: anObj; - -+ (NSConnection*) connectionByOutPort: (NSPort*)aPort; -/* Get a proxy to a remote server object. - A new connection is created if necessary. */ -+ (NSDistantObject*) rootProxyAtName: (NSString*)name onHost: (NSString*)host; -+ (NSDistantObject*) rootProxyAtName: (NSString*)name; -+ (NSDistantObject*) rootProxyAtPort: (NSPort*)anOutPort; -+ (NSDistantObject*) rootProxyAtPort: (NSPort*)anOutPort withInPort: (NSPort*)anInPort; - -/* This is the designated initializer for the NSConnection class. - You don't need to call it yourself. */ -+ (NSConnection*) newForInPort: (NSPort*)anInPort outPort: (NSPort*)anOutPort - ancestorConnection: (NSConnection*)ancestor; - -/* Make a connection object start listening for incoming requests. After - after DATE. */ -- (void) runConnectionUntilDate: date; - -/* Same as above, but never time out. */ -- (void) runConnection; - -/* When you get an invalidation notification from a connection, use - this method in order to find out if any of the proxy objects you're - using are going away. */ -- (id) proxies; - - -/* For getting the root object of a connection or port */ -+ rootObjectForInPort: (NSPort*)aPort; - -/* Used for setting the root object of a connection that we - created without one, or changing the root object of a connection - that already has one. */ -+ (void) setRootObject: anObj forInPort: (NSPort*)aPort; - -/* Querying and setting some instance variables */ -- (Class) receivePortClass; -- (Class) sendPortClass; -- (void) setReceivePortClass: (Class)aPortClass; -- (void) setSendPortClass: (Class)aPortClass; -- (Class) proxyClass; -- (Class) encodingClass; -- (Class) decodingClass; - - -/* Only subclassers and power-users need worry about these */ -- (void) addProxy: (NSDistantObject*)aProxy; -- (id) includesProxyForTarget: (gsu32)target; -- (void) removeProxy: (NSDistantObject*)aProxy; - -// It seems to be a non pure-OPENSTEP definition... -// -// new def : -- (NSArray*)localObjects; -- (void) addLocalObject: anObj; -- (id) includesLocalObject: anObj; -- (void) removeLocalObject: anObj; -- (retval_t) forwardForProxy: (NSDistantObject*)object - selector: (SEL)sel - argFrame: (arglist_t)frame; -- (const char *) typeForSelector: (SEL)sel remoteTarget: (unsigned)target; - -@end - -GS_EXPORT NSString *ConnectionBecameInvalidNotification; - -@interface Object (NSConnectionDelegate) -- (BOOL) connection: (NSConnection*)parent - shouldMakeNewConnection: (NSConnection*)newConnection; -/* - * This method may be used to ask a delegates permission to create - * a new connection from the old one. - * This method should be implemented in preference to the - * [makeNewConnection:sender:] which is obsolete. - */ -- (BOOL) makeNewConnection: (NSConnection*)newConnection - sender: (NSConnection*)parent; -/* - * This is the old way of doing the same thing as - * [connection:shouldMakeNewConnection:] - * It is obsolete - don't use it. - */ -- (NSConnection*) connection: ancestorConn didConnect: newConn; -/* - * If the delegate responds to this method, it will be used to ask the - * delegate's permission to establish a new connection from the old one. - * Often this is used so that the delegate can register for invalidation - * notification on new child connections. - * This is a GNUstep extension - * Normally return newConn. - */ -@end - -@interface Object (NSPortCoder) -- (Class) classForPortCoder; -/* - * Must return the class that will be created on the remote side - * of the connection. If the class to be created is not the same - * as that of the object returned by replacementObjectForPortCoder: - * then the class must be capable of recognising the object it - * actually gets in its initWithCoder: method. - * The default operation is to return NSDistantObject unless the - * object is being sent bycopy, in which case the objects actual - * class is returned. To force bycopy operation the object should - * return its own class. - */ -- (id) replacementObjectForPortCoder: (NSPortCoder*)aCoder; -/* - * This message is sent to an object about to be encoded for sending - * over the wire. The default action is to return an NSDistantObject - * which is a local proxy for the object unless the object is being - * sent bycopy, in which case the actual object is returned. - * To force bycopy, an object should return itsself. - */ - - -- (BOOL)authenticateComponents: (NSArray *)components - withData: (NSData *)authenticationData; -- (NSData *)authenticationDataForComponents: (NSArray *)components; - -@end - -#define CONNECTION_DEFAULT_TIMEOUT 15.0 /* in seconds */ - -/* - * NSRunLoop mode, NSNotification name and NSException strings. - */ -GS_EXPORT NSString *NSConnectionReplyMode; -GS_EXPORT NSString *NSConnectionDidDieNotification; -GS_EXPORT NSString *NSConnectionDidInitializeNotification; /* OPENSTEP */ - -/* - * For compatibility with old GNU DO code - - */ -#define RunLoopConnectionReplyMode NSConnectionReplyMode -#define ConnectionBecameInvalidNotification NSConnectionDidDieNotification -#define ConnectionWasCreatedNotification NSConnectionDidInitializeNotification - -#endif /* __NSConnection_h_GNUSTEP_BASE_INCLUDE */ -#endif diff --git a/Headers/gnustep/base/NSData.h b/Headers/gnustep/base/NSData.h index b92d052c8..400c4082a 100644 --- a/Headers/gnustep/base/NSData.h +++ b/Headers/gnustep/base/NSData.h @@ -160,6 +160,7 @@ #define _GSC_CHARPTR 0x14 #define _GSC_ARY_B 0x15 #define _GSC_STRUCT_B 0x16 +#define _GSC_CID 0x17 /* Class encoded as id */ @interface NSData (GNUstepExtensions) + (id) dataWithShmID: (int)anID length: (unsigned) length; diff --git a/Headers/gnustep/base/NSDebug.h b/Headers/gnustep/base/NSDebug.h index 27008ecfa..8a2d49307 100644 --- a/Headers/gnustep/base/NSDebug.h +++ b/Headers/gnustep/base/NSDebug.h @@ -27,7 +27,7 @@ #include #include -GS_IMPORT int errno; +extern int errno; /* @@ -115,30 +115,30 @@ GS_EXPORT NSString* GSDebugMethodMsg(id obj, SEL sel, const char *file, #define NSDebugLLog(level, format, args...) \ do { if (GSDebugSet(level) == YES) \ - NSLog(format, ## args); } while (0) + NSLog(format , ## args); } while (0) #define NSDebugLog(format, args...) \ do { if (GSDebugSet(@"dflt") == YES) \ - NSLog(format, ## args); } while (0) + 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) + 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) + 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) + 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) + NSLog(fmt , ## args); }} while (0) #else #define NSDebugLLog(level, format, args...) #define NSDebugLog(format, args...) @@ -178,17 +178,17 @@ GS_EXPORT NSString* GSDebugMethodMsg(id obj, SEL sel, const char *file, #define NSWarnLog(format, args...) \ do { \ - NSLog(format, ## args); } while (0) + NSLog(format , ## args); } while (0) #define NSWarnFLog(format, args...) \ do { \ NSString *fmt = GSDebugFunctionMsg( \ __PRETTY_FUNCTION__, __FILE__, __LINE__, format); \ - NSLog(fmt, ## args); } while (0) + NSLog(fmt , ## args); } while (0) #define NSWarnMLog(format, args...) \ do { \ NSString *fmt = GSDebugMethodMsg( \ self, _cmd, __FILE__, __LINE__, format); \ - NSLog(fmt, ## args); } while (0) + NSLog(fmt , ## args); } while (0) #else #define NSWarnLog(format, args...) #define NSWarnFLog(format, args...) diff --git a/Headers/gnustep/base/NSHost.h b/Headers/gnustep/base/NSHost.h index 860055a4c..71ada8602 100644 --- a/Headers/gnustep/base/NSHost.h +++ b/Headers/gnustep/base/NSHost.h @@ -25,13 +25,13 @@ #include -@class NSString, NSArray, NSMutableArray; +@class NSString, NSArray, NSSet; @interface NSHost : NSObject { @private - NSMutableArray *_names; - NSMutableArray *_addresses; + NSSet *_names; + NSSet *_addresses; } /* @@ -78,5 +78,9 @@ @end +@interface NSHost (GNUstep) ++ (NSHost*) localHost; /* All local IP addresses */ +@end + #endif diff --git a/Headers/gnustep/base/NSObjCRuntime.h b/Headers/gnustep/base/NSObjCRuntime.h index f730d2eac..eaf51cce8 100644 --- a/Headers/gnustep/base/NSObjCRuntime.h +++ b/Headers/gnustep/base/NSObjCRuntime.h @@ -34,7 +34,6 @@ #else # define GS_EXPORT extern #endif -#define GS_IMPORT extern #define GS_DECLARE @class NSString; diff --git a/Headers/gnustep/base/NSPortCoder.h b/Headers/gnustep/base/NSPortCoder.h index e2947c2f2..64ff9255c 100644 --- a/Headers/gnustep/base/NSPortCoder.h +++ b/Headers/gnustep/base/NSPortCoder.h @@ -1,4 +1,3 @@ -#if GS_NEW_DO /* Interface for NSPortCoder object for distributed objects Copyright (C) 2000 Free Software Foundation, Inc. @@ -100,50 +99,3 @@ #endif /* __NSPortCoder_h */ -#else -/* Interface for NSPortCoder object for distributed objects - Copyright (C) 1997 Free Software Foundation, Inc. - - Written by: Richard Frith-Macdonald - Date: August 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 Library 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 Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. - */ - -#ifndef __NSPortCoder_h -#define __NSPortCoder_h - -#include - -@class NSConnection; -@class NSPort; - -@interface NSPortCoder : NSCoder -{ -} - -- (NSConnection*) connection; -- (NSPort*) decodePortObject; -- (void) encodePortObject: (NSPort*)aPort; -- (BOOL) isBycopy; -- (BOOL) isByref; - -@end - - -#endif /* __NSPortCoder_h */ -#endif diff --git a/Headers/gnustep/base/NSValue.h b/Headers/gnustep/base/NSValue.h index 6c5762dcd..5d7383f84 100644 --- a/Headers/gnustep/base/NSValue.h +++ b/Headers/gnustep/base/NSValue.h @@ -65,13 +65,13 @@ // Allocating and Initializing + (NSNumber*) numberWithBool: (BOOL)value; -+ (NSNumber*) numberWithChar: (char)value; ++ (NSNumber*) numberWithChar: (signed char)value; + (NSNumber*) numberWithDouble: (double)value; + (NSNumber*) numberWithFloat: (float)value; -+ (NSNumber*) numberWithInt: (int)value; -+ (NSNumber*) numberWithLong: (long)value; -+ (NSNumber*) numberWithLongLong: (long long)value; -+ (NSNumber*) numberWithShort: (short)value; ++ (NSNumber*) numberWithInt: (signed int)value; ++ (NSNumber*) numberWithLong: (signed long)value; ++ (NSNumber*) numberWithLongLong: (signed long long)value; ++ (NSNumber*) numberWithShort: (signed short)value; + (NSNumber*) numberWithUnsignedChar: (unsigned char)value; + (NSNumber*) numberWithUnsignedInt: (unsigned int)value; + (NSNumber*) numberWithUnsignedLong: (unsigned long)value; @@ -79,13 +79,13 @@ + (NSNumber*) numberWithUnsignedShort: (unsigned short)value; - (id) initWithBool: (BOOL)value; -- (id) initWithChar: (char)value; +- (id) initWithChar: (signed char)value; - (id) initWithDouble: (double)value; - (id) initWithFloat: (float)value; -- (id) initWithInt: (int)value; -- (id) initWithLong: (long)value; -- (id) initWithLongLong: (long long)value; -- (id) initWithShort: (short)value; +- (id) initWithInt: (signed int)value; +- (id) initWithLong: (signed long)value; +- (id) initWithLongLong: (signed long long)value; +- (id) initWithShort: (signed short)value; - (id) initWithUnsignedChar: (unsigned char)value; - (id) initWithUnsignedInt: (unsigned int)value; - (id) initWithUnsignedLong: (unsigned long)value; @@ -95,13 +95,13 @@ // Accessing Data - (BOOL) boolValue; -- (char) charValue; +- (signed char) charValue; - (double) doubleValue; - (float) floatValue; -- (int) intValue; -- (long long) longLongValue; -- (long) longValue; -- (short) shortValue; +- (signed int) intValue; +- (signed long long) longLongValue; +- (signed long) longValue; +- (signed short) shortValue; - (NSString*) stringValue; - (unsigned char) unsignedCharValue; - (unsigned int) unsignedIntValue; diff --git a/Headers/gnustep/base/Unicode.h b/Headers/gnustep/base/Unicode.h index 6999fc224..3f5fb47a3 100644 --- a/Headers/gnustep/base/Unicode.h +++ b/Headers/gnustep/base/Unicode.h @@ -32,7 +32,6 @@ unichar chartouni(char c); char unitochar(unichar u); int strtoustr(unichar * u1,const char *s1,int size); int ustrtostr(char *s2,unichar *u1,int size); -int uslen (unichar *u); unichar uni_tolower(unichar ch); unichar uni_toupper(unichar ch); unsigned char uni_cop(unichar u); diff --git a/NEWS b/NEWS index 9d6dc2307..188f7f606 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,24 @@ News **** -The currently released version of the library is `0.6.5'. +The currently released version of the library is `0.6.6'. + +Noteworthy changes in version `0.6.6' +===================================== + + * Lots of new documentation. + + * Completely rewritten Distributed Object to be much more compatible + with the MacOS-X API (and incidentally, closer to the original + OpenStep standard). + + * Support to compile library as a DLL on Windows (still cygwin only). + + * Removed lots of obsolete classes. + + * New tools for handling property lists. + + * More optimization of classes. Noteworthy changes in version `0.6.5' ===================================== diff --git a/NSTimeZones/NSTimeZones.tar b/NSTimeZones/NSTimeZones.tar index 4011640a5..13794426a 100644 Binary files a/NSTimeZones/NSTimeZones.tar and b/NSTimeZones/NSTimeZones.tar differ diff --git a/Source/GNUmakefile b/Source/GNUmakefile index 5332dd884..f42f1aaf0 100644 --- a/Source/GNUmakefile +++ b/Source/GNUmakefile @@ -69,25 +69,10 @@ FILE_AUTHORS = \ # The GNU source files GNU_MFILES = \ -BinaryCStream.m \ -Coder.m \ -CStream.m \ -Decoder.m \ -Encoder.m \ GetDefEncoding.m \ -MachPort.m \ -MemoryStream.m \ -Port.m \ -RawCStream.m \ -StdioStream.m \ -Stream.m \ -TcpPort.m \ -TextCStream.m \ -UdpPort.m \ Unicode.m \ UnixFileHandle.m \ behavior.m \ -ostream.m \ o_array.m \ o_array_bas.m \ o_array_cbs.m \ @@ -132,33 +117,11 @@ fast.x \ GSUnion.h \ GSIArray.h \ GSIMap.h \ -BinaryCStream.h \ -Coder.h \ -CoderPrivate.h \ -Coding.h \ -CStream.h \ -CStreaming.h \ -Enumerating.h \ GetDefEncoding.h \ -Locking.h \ -MachPort.h \ -MemoryStream.h \ -Ordering.h \ -Port.h \ -RawCStream.h \ -Retaining.h \ -StdioStream.h \ -Stream.h \ -Streaming.h \ -TcpPort.h \ -TextCStream.h \ -UdpPort.h \ Unicode.h \ UnixFileHandle.h \ -ValueHolding.h \ behavior.h \ numbers.h \ -ostream.h \ o_array.h \ o_array_bas.h \ o_array_cbs.h \ diff --git a/Source/GSTcpPort.m b/Source/GSTcpPort.m index 874b57c79..4ce75daba 100644 --- a/Source/GSTcpPort.m +++ b/Source/GSTcpPort.m @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -51,6 +52,13 @@ extern int errno; +static BOOL multi_threaded = NO; + +/* + * Largest chunk of data possible in DO + */ +static gsu32 maxDataLength = 10 * 1024 * 1024; + #if 0 #define DO_LOCK(X) {NSDebugMLLog(@"GSTcpHandle",@"lock %@",X); [X lock];} #define DO_UNLOCK(X) {NSDebugMLLog(@"GSTcpHandle",@"unlock %@",X); [X unlock];} @@ -151,7 +159,6 @@ typedef enum { @interface GSTcpHandle : NSObject { - NSLock *myLock; /* Lock for this handle. */ int desc; /* File descriptor for I/O. */ unsigned wItem; /* Index of item being written. */ NSMutableData *wData; /* Data object being written. */ @@ -167,10 +174,12 @@ typedef enum { GSHandleState state; /* State of the handle. */ int addrNum; /* Address number within host. */ @public + NSLock *myLock; /* Lock for this handle. */ BOOL caller; /* Did we connect to other end? */ BOOL valid; GSTcpPort *recvPort; GSTcpPort *sendPort; + struct sockaddr_in clientname; /* Far end of connection. */ } + (GSTcpHandle*) handleWithDescriptor: (int)d; @@ -292,6 +301,10 @@ newDataWithEncodedPort(GSTcpPort *port) } } } + if (addr == nil) + { + addr = @"127.0.0.1"; /* resign ourselves to this */ + } } plen = [addr cStringLength] + 3; data = [[NSMutableData alloc] initWithLength: sizeof(GSPortItemHeader)+plen]; @@ -350,7 +363,10 @@ static Class runLoopClass; handle = (GSTcpHandle*)NSAllocateObject(self,0,NSDefaultMallocZone()); handle->desc = d; handle->wMsgs = [NSMutableArray new]; - handle->myLock = [NSRecursiveLock new]; + if (multi_threaded == YES) + { + handle->myLock = [NSRecursiveLock new]; + } handle->valid = YES; return AUTORELEASE(handle); } @@ -404,7 +420,8 @@ static Class runLoopClass; if (addrNum >= [addrs count]) { - NSLog(@"run out of addresses to try (tried %d)", addrNum); + NSLog(@"run out of addresses to try (tried %d) for port %@", + addrNum, aPort); return NO; } addr = [[addrs objectAtIndex: addrNum++] cString]; @@ -498,6 +515,12 @@ static Class runLoopClass; [super dealloc]; } +- (NSString*) description +{ + return [NSString stringWithFormat: @"Handle (%d) to %s:%d", + desc, inet_ntoa(clientname.sin_addr), ntohs(clientname.sin_port)]; +} + - (int) descriptor { return desc; @@ -669,37 +692,75 @@ static Class runLoopClass; l = GSSwapBigI32ToHost(h->length); if (rType == GSP_PORT) { + if (l > 32) + { + NSLog(@"%@ - unreasonable length (%u) for port", + self, l); + [self invalidate]; + return; + } /* * For a port, we leave the item header in the data * so that our decode function can check length info. */ rWant += l; } - else if (rType == GSP_DATA && l == 0) + else if (rType == GSP_DATA) { - NSData *d; + if (l == 0) + { + NSData *d; - /* - * For a zero-length data chunk, we create an empty - * data object and add it to the current message. - */ - rType = GSP_NONE; /* ready for a new item */ - rLength -= rWant; - if (rLength > 0) - { - memcpy(bytes, bytes + rWant, rLength); + /* + * For a zero-length data chunk, we create an empty + * data object and add it to the current message. + */ + rType = GSP_NONE; /* ready for a new item */ + rLength -= rWant; + if (rLength > 0) + { + memcpy(bytes, bytes + rWant, rLength); + } + rWant = sizeof(GSPortItemHeader); + d = [mutableDataClass new]; + [rItems addObject: d]; + RELEASE(d); + if (nItems == [rItems count]) + { + [self dispatch]; + } } - rWant = sizeof(GSPortItemHeader); - d = [mutableDataClass new]; - [rItems addObject: d]; - RELEASE(d); - if (nItems == [rItems count]) + else { - [self dispatch]; + if (l > maxDataLength) + { + NSLog(@"%@ - unreasonable length (%u) for data", + self, l); + [self invalidate]; + return; + } + /* + * If not a port or zero length data, + * we discard the data read so far and fill the + * data object with the data item from the msg. + */ + rLength -= rWant; + if (rLength > 0) + { + memcpy(bytes, bytes + rWant, rLength); + } + rWant = l; } } - else + else if (rType == GSP_HEAD) { + if (l > maxDataLength) + { + NSLog(@"%@ - unreasonable length (%u) for data", + self, l); + [self invalidate]; + return; + } /* * If not a port or zero length data, * we discard the data read so far and fill the @@ -712,6 +773,12 @@ static Class runLoopClass; } rWant = l; } + else + { + NSLog(@"%@ - bad data received on port handle", self); + [self invalidate]; + return; + } } break; @@ -1020,14 +1087,79 @@ static NSRecursiveLock *tcpPortLock = nil; static NSMapTable *tcpPortMap = 0; static Class tcpPortClass; +/* + * When the system becomes multithreaded, we set a flag to say so and + * make sure that port and handle locking is enabled. + */ ++ (void) _becomeThreaded: (NSNotification*)notification +{ + if (multi_threaded == NO) + { + NSMapEnumerator pEnum; + NSMapTable *m; + void *dummy; + + multi_threaded = YES; + if (tcpPortLock == nil) + { + tcpPortLock = [NSRecursiveLock new]; + } + pEnum = NSEnumerateMapTable(tcpPortMap); + while (NSNextMapEnumeratorPair(&pEnum, &dummy, (void**)&m)) + { + NSMapEnumerator mEnum; + GSTcpPort *p; + + mEnum = NSEnumerateMapTable(m); + while (NSNextMapEnumeratorPair(&mEnum, &dummy, (void**)&p)) + { + if ([p isValid] == YES) + { + NSMapEnumerator hEnum; + GSTcpHandle *h; + + if (p->myLock == nil) + { + p->myLock = [NSRecursiveLock new]; + } + hEnum = NSEnumerateMapTable(p->handles); + while (NSNextMapEnumeratorPair(&hEnum, &dummy, (void**)&h)) + { + if ([h isValid] == YES && h->myLock == nil) + { + h->myLock = [NSRecursiveLock new]; + } + } + } + } + } + } + [[NSNotificationCenter defaultCenter] + removeObserver: self + name: NSWillBecomeMultiThreadedNotification + object: nil]; +} + + (void) initialize { if (self == [GSTcpPort class]) { tcpPortClass = self; - tcpPortLock = [NSRecursiveLock new]; tcpPortMap = NSCreateMapTable(NSIntMapKeyCallBacks, - NSNonOwnedPointerMapValueCallBacks, 0); + NSNonOwnedPointerMapValueCallBacks, 0); + + if ([NSThread isMultiThreaded]) + { + [self _becomeThreaded: nil]; + } + else + { + [[NSNotificationCenter defaultCenter] + addObserver: self + selector: @selector(_becomeThreaded:) + name: NSWillBecomeMultiThreadedNotification + object: nil]; + } } } @@ -1080,7 +1212,7 @@ static Class tcpPortClass; { unsigned i; GSTcpPort *port = nil; - NSHost *thisHost = [NSHost currentHost]; + NSHost *thisHost = [NSHost localHost]; NSMapTable *thePorts; if (thisHost == nil) @@ -1122,10 +1254,13 @@ static Class tcpPortClass; port->address = [addr copy]; port->handles = NSCreateMapTable(NSIntMapKeyCallBacks, NSObjectMapValueCallBacks, 0); - port->myLock = [NSRecursiveLock new]; + if (multi_threaded == YES) + { + port->myLock = [NSRecursiveLock new]; + } port->_is_valid = YES; - if (shouldListen == YES && [thisHost isEqual: aHost] == YES) + if (shouldListen == YES && [thisHost isEqual: aHost]) { int reuse = 1; /* Should we re-use ports? */ int desc; @@ -1206,12 +1341,11 @@ static Class tcpPortClass; */ port->listener = desc; port->portNum = GSSwapBigI16ToHost(sockaddr.sin_port); - /* * Make sure we have the map table for this port. */ thePorts = (NSMapTable*)NSMapGet(tcpPortMap, - (void*)(gsaddr)port->portNum); + (void*)(gsaddr)port->portNum); if (thePorts == 0) { /* @@ -1527,6 +1661,7 @@ static Class tcpPortClass; * the other end. */ handle = [GSTcpHandle handleWithDescriptor: desc]; + memcpy(&handle->clientname, &clientname, sizeof(clientname)); [handle setState: GS_H_ACCEPT]; [self addHandle: handle forSend: NO]; } @@ -1557,8 +1692,15 @@ static Class tcpPortClass; DO_LOCK(myLock); if ([handle sendPort] == self) { - if (handle->caller == YES) + if (handle->caller != YES) { + /* + * This is a handle for a send port, and the handle was not formed + * by calling the remote process, so this port object must have + * been created to deal with an incoming connection and will have + * been retained - we must therefore release this port since the + * handle no longer uses it. + */ AUTORELEASE(self); } handle->sendPort = nil; @@ -1696,7 +1838,7 @@ static Class tcpPortClass; * word boundary, so we work with an aligned buffer * and use memcmpy() */ - if ((*hLength % __alignof__(gsu32)) != 0) + if ((hLength % __alignof__(gsu32)) != 0) { GSPortItemHeader itemHeader; diff --git a/Source/Makefile.preamble b/Source/Makefile.preamble index 61ea3a988..3e1f29a85 100644 --- a/Source/Makefile.preamble +++ b/Source/Makefile.preamble @@ -39,7 +39,7 @@ # # Additional flags to pass to the preprocessor -ADDITIONAL_CPPFLAGS = $(DEFS) -Wall -DGS_NEW_DO=1 +ADDITIONAL_CPPFLAGS = $(DEFS) -Wall # Additional flags to pass to the Objective-C compiler ADDITIONAL_OBJCFLAGS = diff --git a/Source/NSArchiver.m b/Source/NSArchiver.m index c1e3589ae..8f1d84abe 100644 --- a/Source/NSArchiver.m +++ b/Source/NSArchiver.m @@ -712,14 +712,6 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:); (*_tagImp)(_dst, tagSel, _GSC_ID | _GSC_XREF, _GSC_X_0); } } - else if (fastIsInstance(anObject) == NO) - { - /* - * If the object we have been given is actually a class, - * we encode it as a class instead. - */ - (*_eValImp)(self, eValSel, @encode(Class), &anObject); - } else { GSIMapNode node; @@ -769,22 +761,33 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:); } obj = [anObject replacementObjectForArchiver: self]; - cls = [obj classForArchiver]; - - (*_xRefImp)(_dst, xRefSel, _GSC_ID, node->value.uint); - if (_namMap->nodeCount) + if (fastIsInstance(obj) == NO) { - GSIMapNode node; - - node = GSIMapNodeForKey(_namMap, (GSIMapKey)cls); - - if (node) - { - cls = (Class)node->value.ptr; - } + /* + * If the object we have been given is actually a class, + * we encode it as a special case. + */ + (*_xRefImp)(_dst, xRefSel, _GSC_CID, node->value.uint); + (*_eValImp)(self, eValSel, @encode(Class), &obj); + } + else + { + cls = [obj classForArchiver]; + if (_namMap->nodeCount) + { + GSIMapNode n; + + n = GSIMapNodeForKey(_namMap, (GSIMapKey)cls); + + if (n) + { + cls = (Class)n->value.ptr; + } + } + (*_xRefImp)(_dst, xRefSel, _GSC_ID, node->value.uint); + (*_eValImp)(self, eValSel, @encode(Class), &cls); + [obj encodeWithCoder: self]; } - (*_eValImp)(self, eValSel, @encode(Class), &cls); - [obj encodeWithCoder: self]; } else { diff --git a/Source/NSArray.m b/Source/NSArray.m index 3cba8bda5..7d9485827 100644 --- a/Source/NSArray.m +++ b/Source/NSArray.m @@ -80,31 +80,16 @@ static SEL rlSel = @selector(removeLastObject); } } -+ (void) _setConcreteClass: (Class)c -{ - NSArray_concrete_class = c; -} - -+ (void) _setMutableConcreteClass: (Class)c -{ - NSMutableArray_concrete_class = c; -} - -+ (Class) _concreteClass -{ - return NSArray_concrete_class; -} - -+ (Class) _mutableConcreteClass -{ - return NSMutableArray_concrete_class; -} - + (id) allocWithZone: (NSZone*)z { if (self == NSArray_abstract_class) - return NSAllocateObject(NSArray_concrete_class, 0, z); - return [super allocWithZone: z]; + { + return NSAllocateObject(NSArray_concrete_class, 0, z); + } + else + { + return NSAllocateObject(self, 0, z); + } } + (id) array @@ -799,8 +784,13 @@ static NSString *indentStrings[] = { + (id) allocWithZone: (NSZone*)z { if (self == NSMutableArray_abstract_class) - return NSAllocateObject(NSMutableArray_concrete_class, 0, z); - return [super allocWithZone: z]; + { + return NSAllocateObject(NSMutableArray_concrete_class, 0, z); + } + else + { + return NSAllocateObject(self, 0, z); + } } /* The NSCopying Protocol */ @@ -1347,3 +1337,130 @@ static NSString *indentStrings[] = { return (*get)(array, oaiSel, --pos); } @end + + +@implementation NSArray (GNUstep) + +/* + * The comparator function takes two items as arguments, the first is the + * item to be added, the second is the item already in the array. + * The function should return NSOrderedAscending if the item to be + * added is 'less than' the item in the array, NSOrderedDescending + * if it is greater, and NSOrderedSame if it is equal. + */ +- (unsigned) insertionPosition: (id)item + usingFunction: (NSComparisonResult (*)(id, id))sorter +{ + unsigned count = [self count]; + unsigned upper = count; + unsigned lower = 0; + unsigned index; + IMP oai; + + if (item == nil) + { + [NSException raise: NSGenericException + format: @"Attempt to find position for nil object in array"]; + } + if (sorter == 0) + { + [NSException raise: NSGenericException + format: @"Attempt to find position with null comparator"]; + } + + oai = [self methodForSelector: oaiSel]; + /* + * Binary search for an item equal to the one to be inserted. + */ + for (index = upper/2; upper != lower; index = lower+(upper-lower)/2) + { + NSComparisonResult comparison; + + comparison = (*sorter)(item, (*oai)(self, oaiSel, index)); + if (comparison == NSOrderedAscending) + { + upper = index; + } + else if (comparison == NSOrderedDescending) + { + lower = index + 1; + } + else + { + break; + } + } + /* + * Now skip past any equal items so the insertion point is AFTER any + * items that are equal to the new one. + */ + while (index < count + && (*sorter)(item, (*oai)(self, oaiSel, index)) != NSOrderedAscending) + { + index++; + } + return index; +} + +- (unsigned) insertionPosition: (id)item + usingSelector: (SEL)comp +{ + unsigned count = [self count]; + unsigned upper = count; + unsigned lower = 0; + unsigned index; + NSComparisonResult (*imp)(id, SEL, id); + IMP oai; + + if (item == nil) + { + [NSException raise: NSGenericException + format: @"Attempt to find position for nil object in array"]; + } + if (comp == 0) + { + [NSException raise: NSGenericException + format: @"Attempt to find position with null comparator"]; + } + imp = (NSComparisonResult (*)(id, SEL, id))[item methodForSelector: comp]; + if (imp == 0) + { + [NSException raise: NSGenericException + format: @"Attempt to find position with unknown method"]; + } + + oai = [self methodForSelector: oaiSel]; + /* + * Binary search for an item equal to the one to be inserted. + */ + for (index = upper/2; upper != lower; index = lower+(upper-lower)/2) + { + NSComparisonResult comparison; + + comparison = (*imp)(item, comp, (*oai)(self, oaiSel, index)); + if (comparison == NSOrderedAscending) + { + upper = index; + } + else if (comparison == NSOrderedDescending) + { + lower = index + 1; + } + else + { + break; + } + } + /* + * Now skip past any equal items so the insertion point is AFTER any + * items that are equal to the new one. + */ + while (index < count + && (*imp)(item, comp, (*oai)(self, oaiSel, index)) != NSOrderedAscending) + { + index++; + } + return index; +} +@end + diff --git a/Source/NSAttributedString.m b/Source/NSAttributedString.m index fbd00ef04..e91aafa59 100644 --- a/Source/NSAttributedString.m +++ b/Source/NSAttributedString.m @@ -89,27 +89,6 @@ static Class NSAttributedString_concrete_class; static Class NSMutableAttributedString_abstract_class; static Class NSMutableAttributedString_concrete_class; -//Internal methods -+ (void) _setConcreteClass: (Class)c -{ - NSAttributedString_concrete_class = c; -} - -+ (void) _setMutableConcreteClass: (Class)c -{ - NSMutableAttributedString_concrete_class = c; -} - -+ (Class) _concreteClass -{ - return NSAttributedString_concrete_class; -} - -+ (Class) _mutableConcreteClass -{ - return NSMutableAttributedString_concrete_class; -} - + (void) initialize { if (self == [NSAttributedString class]) @@ -133,7 +112,7 @@ static Class NSMutableAttributedString_concrete_class; + (id) allocWithZone: (NSZone*)z { if (self == NSAttributedString_abstract_class) - return NSAllocateObject([self _concreteClass], 0, z); + return NSAllocateObject(NSAttributedString_concrete_class, 0, z); else return NSAllocateObject(self, 0, z); } @@ -166,7 +145,7 @@ static Class NSMutableAttributedString_concrete_class; { if ([self isKindOfClass: [NSMutableAttributedString class]] || NSShouldRetainWithZone(self, zone) == NO) - return [[[[self class] _concreteClass] allocWithZone: zone] + return [[NSAttributedString_concrete_class allocWithZone: zone] initWithAttributedString: self]; else return RETAIN(self); @@ -175,7 +154,7 @@ static Class NSMutableAttributedString_concrete_class; //NSMutableCopying protocol - (id) mutableCopyWithZone: (NSZone*)zone { - return [[[[self class] _mutableConcreteClass] allocWithZone: zone] + return [[NSMutableAttributedString_concrete_class allocWithZone: zone] initWithAttributedString: self]; } @@ -498,7 +477,7 @@ static Class NSMutableAttributedString_concrete_class; + allocWithZone: (NSZone*)z { if (self == NSMutableAttributedString_abstract_class) - return NSAllocateObject([self _mutableConcreteClass], 0, z); + return NSAllocateObject(NSMutableAttributedString_concrete_class, 0, z); else return NSAllocateObject(self, 0, z); } diff --git a/Source/NSCalendarDate.m b/Source/NSCalendarDate.m index b41b19161..afe6a9a68 100644 --- a/Source/NSCalendarDate.m +++ b/Source/NSCalendarDate.m @@ -48,7 +48,7 @@ #define GREGORIAN_REFERENCE 730486 static inline int -lastDayOfGregorianMonth(int year, int month) +lastDayOfGregorianMonth(int month, int year) { switch (month) { diff --git a/Source/NSConcreteNumber.m b/Source/NSConcreteNumber.m index 2cfc2624a..34815766a 100644 --- a/Source/NSConcreteNumber.m +++ b/Source/NSConcreteNumber.m @@ -45,7 +45,7 @@ #elif TYPE_ORDER == 1 # define NumberTemplate NSCharNumber # define TYPE_FORMAT @"%c" -# define TYPE_TYPE char +# define TYPE_TYPE signed char #elif TYPE_ORDER == 2 # define NumberTemplate NSUCharNumber # define TYPE_FORMAT @"%c" @@ -53,7 +53,7 @@ #elif TYPE_ORDER == 3 # define NumberTemplate NSShortNumber # define TYPE_FORMAT @"%hd" -# define TYPE_TYPE short +# define TYPE_TYPE signed short #elif TYPE_ORDER == 4 # define NumberTemplate NSUShortNumber # define TYPE_FORMAT @"%hu" @@ -61,7 +61,7 @@ #elif TYPE_ORDER == 5 # define NumberTemplate NSIntNumber # define TYPE_FORMAT @"%d" -# define TYPE_TYPE int +# define TYPE_TYPE signed int #elif TYPE_ORDER == 6 # define NumberTemplate NSUIntNumber # define TYPE_FORMAT @"%u" @@ -69,7 +69,7 @@ #elif TYPE_ORDER == 7 # define NumberTemplate NSLongNumber # define TYPE_FORMAT @"%ld" -# define TYPE_TYPE long +# define TYPE_TYPE signed long #elif TYPE_ORDER == 8 # define NumberTemplate NSULongNumber # define TYPE_FORMAT @"%lu" @@ -77,7 +77,7 @@ #elif TYPE_ORDER == 9 # define NumberTemplate NSLongLongNumber # define TYPE_FORMAT @"%lld" -# define TYPE_TYPE long long +# define TYPE_TYPE signed long long #elif TYPE_ORDER == 10 # define NumberTemplate NSULongLongNumber # define TYPE_FORMAT @"%llu" @@ -144,9 +144,9 @@ return (BOOL)data; } -- (char) charValue +- (signed char) charValue { - return (char)data; + return (signed char)data; } - (double) doubleValue @@ -159,24 +159,24 @@ return (float)data; } -- (int) intValue +- (signed int) intValue { - return (int)data; + return (signed int)data; } -- (long long) longLongValue +- (signed long long) longLongValue { - return (long long)data; + return (signed long long)data; } -- (long) longValue +- (signed long) longValue { - return (long)data; + return (signed long)data; } -- (short) shortValue +- (signed short) shortValue { - return (short)data; + return (signed short)data; } - (unsigned char) unsignedCharValue @@ -206,177 +206,184 @@ - (NSComparisonResult) compare: (NSNumber*)other { - GSNumberInfo *info; - if (other == self) { return NSOrderedSame; } - info = GSNumberInfoFromObject(other); - - switch (info->typeLevel) + else if (other == nil) { - case 0: - { - BOOL oData; - - (*(info->getValue))(other, @selector(getValue:), (void*)&oData); - if (data == oData) - return NSOrderedSame; - else if (data < oData) - return NSOrderedAscending; - else - return NSOrderedDescending; - } - case 1: - { - char oData; - - (*(info->getValue))(other, @selector(getValue:), (void*)&oData); - if (data == oData) - return NSOrderedSame; - else if (data < oData) - return NSOrderedAscending; - else - return NSOrderedDescending; - } - case 2: - { - unsigned char oData; - - (*(info->getValue))(other, @selector(getValue:), (void*)&oData); - if (data == oData) - return NSOrderedSame; - else if (data < oData) - return NSOrderedAscending; - else - return NSOrderedDescending; - } - case 3: - { - short oData; - - (*(info->getValue))(other, @selector(getValue:), (void*)&oData); - if (data == oData) - return NSOrderedSame; - else if (data < oData) - return NSOrderedAscending; - else - return NSOrderedDescending; - } - case 4: - { - unsigned short oData; - - (*(info->getValue))(other, @selector(getValue:), (void*)&oData); - if (data == oData) - return NSOrderedSame; - else if (data < oData) - return NSOrderedAscending; - else - return NSOrderedDescending; - } - case 5: - { - int oData; - - (*(info->getValue))(other, @selector(getValue:), (void*)&oData); - if (data == oData) - return NSOrderedSame; - else if (data < oData) - return NSOrderedAscending; - else - return NSOrderedDescending; - } - case 6: - { - unsigned int oData; - - (*(info->getValue))(other, @selector(getValue:), (void*)&oData); - if (data == oData) - return NSOrderedSame; - else if (data < oData) - return NSOrderedAscending; - else - return NSOrderedDescending; - } - case 7: - { - long oData; - - (*(info->getValue))(other, @selector(getValue:), (void*)&oData); - if (data == oData) - return NSOrderedSame; - else if (data < oData) - return NSOrderedAscending; - else - return NSOrderedDescending; - } - case 8: - { - unsigned long oData; - - (*(info->getValue))(other, @selector(getValue:), (void*)&oData); - if (data == oData) - return NSOrderedSame; - else if (data < oData) - return NSOrderedAscending; - else - return NSOrderedDescending; - } - case 9: - { - long long oData; - - (*(info->getValue))(other, @selector(getValue:), (void*)&oData); - if (data == oData) - return NSOrderedSame; - else if (data < oData) - return NSOrderedAscending; - else - return NSOrderedDescending; - } - case 10: - { - unsigned long long oData; - - (*(info->getValue))(other, @selector(getValue:), (void*)&oData); - if (data == oData) - return NSOrderedSame; - else if (data < oData) - return NSOrderedAscending; - else - return NSOrderedDescending; - } - case 11: - { - float oData; - - (*(info->getValue))(other, @selector(getValue:), (void*)&oData); - if (data == oData) - return NSOrderedSame; - else if (data < oData) - return NSOrderedAscending; - else - return NSOrderedDescending; - } - case 12: - { - double oData; - - (*(info->getValue))(other, @selector(getValue:), (void*)&oData); - if (data == oData) - return NSOrderedSame; - else if (data < oData) - return NSOrderedAscending; - else - return NSOrderedDescending; - } - default: - [NSException raise: NSInvalidArgumentException - format: @"number type value for comparison"]; - return NSOrderedSame; + [NSException raise: NSInvalidArgumentException + format: @"nil argument for compare:"]; } + else + { + GSNumberInfo *info = GSNumberInfoFromObject(other); + + switch (info->typeLevel) + { + case 0: + { + BOOL oData; + + (*(info->getValue))(other, @selector(getValue:), (void*)&oData); + if (data == oData) + return NSOrderedSame; + else if (data < oData) + return NSOrderedAscending; + else + return NSOrderedDescending; + } + case 1: + { + signed char oData; + + (*(info->getValue))(other, @selector(getValue:), (void*)&oData); + if (data == oData) + return NSOrderedSame; + else if (data < oData) + return NSOrderedAscending; + else + return NSOrderedDescending; + } + case 2: + { + unsigned char oData; + + (*(info->getValue))(other, @selector(getValue:), (void*)&oData); + if (data == oData) + return NSOrderedSame; + else if (data < oData) + return NSOrderedAscending; + else + return NSOrderedDescending; + } + case 3: + { + signed short oData; + + (*(info->getValue))(other, @selector(getValue:), (void*)&oData); + if (data == oData) + return NSOrderedSame; + else if (data < oData) + return NSOrderedAscending; + else + return NSOrderedDescending; + } + case 4: + { + unsigned short oData; + + (*(info->getValue))(other, @selector(getValue:), (void*)&oData); + if (data == oData) + return NSOrderedSame; + else if (data < oData) + return NSOrderedAscending; + else + return NSOrderedDescending; + } + case 5: + { + signed int oData; + + (*(info->getValue))(other, @selector(getValue:), (void*)&oData); + if (data == oData) + return NSOrderedSame; + else if (data < oData) + return NSOrderedAscending; + else + return NSOrderedDescending; + } + case 6: + { + unsigned int oData; + + (*(info->getValue))(other, @selector(getValue:), (void*)&oData); + if (data == oData) + return NSOrderedSame; + else if (data < oData) + return NSOrderedAscending; + else + return NSOrderedDescending; + } + case 7: + { + signed long oData; + + (*(info->getValue))(other, @selector(getValue:), (void*)&oData); + if (data == oData) + return NSOrderedSame; + else if (data < oData) + return NSOrderedAscending; + else + return NSOrderedDescending; + } + case 8: + { + unsigned long oData; + + (*(info->getValue))(other, @selector(getValue:), (void*)&oData); + if (data == oData) + return NSOrderedSame; + else if (data < oData) + return NSOrderedAscending; + else + return NSOrderedDescending; + } + case 9: + { + signed long long oData; + + (*(info->getValue))(other, @selector(getValue:), (void*)&oData); + if (data == oData) + return NSOrderedSame; + else if (data < oData) + return NSOrderedAscending; + else + return NSOrderedDescending; + } + case 10: + { + unsigned long long oData; + + (*(info->getValue))(other, @selector(getValue:), (void*)&oData); + if (data == oData) + return NSOrderedSame; + else if (data < oData) + return NSOrderedAscending; + else + return NSOrderedDescending; + } + case 11: + { + float oData; + + (*(info->getValue))(other, @selector(getValue:), (void*)&oData); + if (data == oData) + return NSOrderedSame; + else if (data < oData) + return NSOrderedAscending; + else + return NSOrderedDescending; + } + case 12: + { + double oData; + + (*(info->getValue))(other, @selector(getValue:), (void*)&oData); + if (data == oData) + return NSOrderedSame; + else if (data < oData) + return NSOrderedAscending; + else + return NSOrderedDescending; + } + default: + [NSException raise: NSInvalidArgumentException + format: @"number type value for comparison"]; + return NSOrderedSame; + } + } + return 0; /* Quiet warnings */ } - (NSString*) descriptionWithLocale: (NSDictionary*)locale diff --git a/Source/NSConnection.m b/Source/NSConnection.m index f464e82ba..1fd9bdb32 100644 --- a/Source/NSConnection.m +++ b/Source/NSConnection.m @@ -1,4 +1,3 @@ -#if GS_NEW_DO /* Implementation of connection object for remote object messaging Copyright (C) 1994, 1995, 1996, 1997, 2000 Free Software Foundation, Inc. @@ -244,7 +243,7 @@ static NSTimer *timer; static int debug_connection = 0; static NSHashTable *connection_table; -static NSLock *connection_table_gate; +static NSLock *connection_table_gate = nil; /* * Locate an existing connection with the specified send and receive ports. @@ -276,7 +275,7 @@ existingConnection(NSPort *receivePort, NSPort *sendPort) } static NSMapTable *root_object_map; -static NSLock *root_object_map_gate; +static NSLock *root_object_map_gate = nil; static id rootObjectForInPort(NSPort *aPort) @@ -315,13 +314,53 @@ setRootObjectForInPort(id anObj, NSPort *aPort) static NSMapTable *objectToCounter = NULL; static NSMapTable *targetToCounter = NULL; static NSMapTable *targetToCached = NULL; -static NSLock *global_proxies_gate; +static NSLock *global_proxies_gate = nil; +static BOOL multi_threaded = NO; @implementation NSConnection +/* + * When the system becomes multithreaded, we set a flag to say so and + * make sure that connection locking is enabled. + */ ++ (void) _becomeThreaded: (NSNotification*)notification +{ + if (multi_threaded == NO) + { + NSHashEnumerator enumerator; + NSConnection *c; + + multi_threaded = YES; + if (connection_table_gate == nil) + { + connection_table_gate = [NSLock new]; + } + if (global_proxies_gate == nil) + { + global_proxies_gate = [NSLock new]; + } + if (root_object_map_gate == nil) + { + root_object_map_gate = [NSLock new]; + } + enumerator = NSEnumerateHashTable(connection_table); + while ((c = (NSConnection*)NSNextHashEnumeratorItem(&enumerator)) != nil) + { + if (c->_refGate == nil) + { + c->_refGate = [NSRecursiveLock new]; + } + } + } + [[NSNotificationCenter defaultCenter] + removeObserver: self + name: NSWillBecomeMultiThreadedNotification + object: nil]; +} + + (NSArray*) allConnections { NSArray *a; @@ -443,7 +482,6 @@ static NSLock *global_proxies_gate; connection_table = NSCreateHashTable(NSNonRetainedObjectHashCallBacks, 0); - connection_table_gate = [NSLock new]; objectToCounter = NSCreateMapTable(NSNonOwnedPointerMapKeyCallBacks, @@ -454,11 +492,22 @@ static NSLock *global_proxies_gate; targetToCached = NSCreateMapTable(NSIntMapKeyCallBacks, NSObjectMapValueCallBacks, 0); - global_proxies_gate = [NSLock new]; + root_object_map = NSCreateMapTable(NSNonOwnedPointerMapKeyCallBacks, NSObjectMapValueCallBacks, 0); - root_object_map_gate = [NSLock new]; + if ([NSThread isMultiThreaded]) + { + [self _becomeThreaded: nil]; + } + else + { + [[NSNotificationCenter defaultCenter] + addObserver: self + selector: @selector(_becomeThreaded:) + name: NSWillBecomeMultiThreadedNotification + object: nil]; + } } } @@ -715,7 +764,10 @@ static NSLock *global_proxies_gate; _requestDepth = 0; _delegate = nil; - _refGate = [NSRecursiveLock new]; + if (multi_threaded == YES) + { + _refGate = [NSRecursiveLock new]; + } /* * Some attributes are inherited from the parent if possible. @@ -2690,2383 +2742,3 @@ static NSLock *global_proxies_gate; @end -#else -/* Implementation of connection object for remote object messaging - Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. - - Created by: Andrew Kachites McCallum - Date: July 1994 - Rewritten for OPENSTEP by: Richard Frith-Macdonald - Date: August 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 Library 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 Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. - */ - -/* To do: - Make it thread-safe. - */ - -/* RMC == Remote Method Coder, or Remote Method Call. - It's an instance of PortEncoder or PortDecoder. */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -@interface NSDistantObject (NSConnection) -- (id) localForProxy; -- (void) setProxyTarget: (unsigned)target; -- (unsigned) targetForProxy; -@end - -@implementation NSDistantObject (NSConnection) -- (id) localForProxy -{ - return _object; -} -- (void) setProxyTarget: (unsigned)target -{ - _handle = target; -} -- (unsigned) targetForProxy -{ - return _handle; -} -@end - -/* - * GSLocalCounter is a trivial class to keep track of how - * many different connections a particular local object is vended - * over. This is required so that we know when to remove an object - * from the global list when it is removed from the list of objects - * vended on a particular connection. - */ -@interface GSLocalCounter : NSObject -{ -@public - unsigned ref; - unsigned target; - id object; -} -+ (GSLocalCounter*) newWithObject: (id)ob; -@end - -@implementation GSLocalCounter - -static unsigned local_object_counter = 0; - -+ (GSLocalCounter*) newWithObject: (id)obj -{ - GSLocalCounter *counter; - - counter = (GSLocalCounter*)NSAllocateObject(self, 0, NSDefaultMallocZone()); - counter->ref = 1; - counter->object = RETAIN(obj); - counter->target = ++local_object_counter; - return counter; -} -- (void) dealloc -{ - [object release]; - [super dealloc]; -} -@end - - - -/* - * CachedLocalObject is a trivial class to keep track of how - * many different connections a particular local object is vended - * over. This is required so that we know when to remove an object - * from the global list when it is removed from the list of objects - * vended on a particular connection. - */ -@interface CachedLocalObject : NSObject -{ - id obj; - int time; -} -- (BOOL)countdown; -- (id) obj; -+ (CachedLocalObject*) itemWithObject: (id)o time: (int)t; -@end - -@implementation CachedLocalObject - -+ (CachedLocalObject*) itemWithObject: (id)o time: (int)t -{ - CachedLocalObject *item = [[self alloc] init]; - - item->obj = RETAIN(o); - item->time = t; - return [item autorelease]; -} - -- (void) dealloc -{ - [obj release]; - [super dealloc]; -} - -- (BOOL) countdown -{ - if (time-- > 0) - return YES; - return NO; -} - -- (id) obj -{ - return obj; -} - -@end - - -@interface NSConnection (GettingCoderInterface) -- (void) _handleRmc: rmc; -- (void) _handleQueuedRmcRequests; -- _getReceivedReplyRmcWithSequenceNumber: (int)n; -- newSendingRequestRmc; -- newSendingReplyRmcWithSequenceNumber: (int)n; -- (int) _newMsgNumber; -@end - -@interface NSConnection (Private) -- _superInit; -- (void) handlePortMessage: (NSPortMessage*)msg; -+ (void) setDebug: (int)val; -@end - -#define proxiesHashGate refGate -#define sequenceNumberGate refGate - -/* xxx Fix this! */ -#define refGate nil - -static inline BOOL -class_is_kind_of (Class self, Class aClassObject) -{ - Class class; - - for (class = self; class!=Nil; class = class_get_super_class(class)) - if (class==aClassObject) - return YES; - return NO; -} - -static inline unsigned int -hash_int (cache_ptr cache, const void *key) -{ - return (unsigned)key & cache->mask; -} - -static inline int -compare_ints (const void *k1, const void *k2) -{ - return !(k1 - k2); -} - -/* class defaults */ -static id default_receive_port_class; -static id default_send_port_class; -static id default_proxy_class; -static id default_encoding_class; -static id default_decoding_class; -static int default_reply_timeout; -static int default_request_timeout; -static NSTimer *timer; - -static int debug_connection = 0; - -static NSHashTable *connection_table; -static NSLock *connection_table_gate; - -static NSMutableDictionary *root_object_dictionary; -static NSLock *root_object_dictionary_gate; - -static NSMapTable *receive_port_2_ancestor; - -static NSMapTable *all_connections_local_objects = NULL; -static NSMapTable *all_connections_local_targets = NULL; -static NSMapTable *all_connections_local_cached = NULL; - -/* rmc handling */ -static NSMutableArray *received_request_rmc_queue; -static NSLock *received_request_rmc_queue_gate; -static NSMutableArray *received_reply_rmc_queue; -static NSLock *received_reply_rmc_queue_gate; - -static int messages_received_count; - - - - -@implementation NSConnection - -+ (NSArray*) allConnections -{ - return NSAllHashTableObjects(connection_table); -} - -+ (NSConnection*) connectionWithRegisteredName: (NSString*)n - host: (NSString*)h -{ - NSDistantObject *proxy; - - proxy = [self rootProxyForConnectionWithRegisteredName: n host: h]; - if (proxy != nil) - { - return [proxy connectionForProxy]; - } - return nil; -} - -/* - * Get the default connection for a thread. - * Possible problem - if the connection is invalidated, it won't be - * cleaned up until this thread calls this method again. The connection - * and it's ports could hang around for a very long time. - */ -+ (NSConnection*) defaultConnection -{ - static NSString *tkey = @"NSConnectionThreadKey"; - NSConnection *c; - NSMutableDictionary *d; - - d = GSCurrentThreadDictionary(); - c = (NSConnection*)[d objectForKey: tkey]; - if (c != nil && [c isValid] == NO) - { - /* - * If the default connection for this thread has been invalidated - - * release it and create a new one. - */ - [d removeObjectForKey: tkey]; - c = nil; - } - if (c == nil) - { - NSPort *newPort; - - c = [self alloc]; - newPort = [default_receive_port_class newForReceiving]; - c = [c initWithReceivePort: newPort sendPort: nil]; - RELEASE(newPort); - [d setObject: c forKey: tkey]; - RELEASE(c); - } - return c; -} - -+ (void) initialize -{ - connection_table = - NSCreateHashTable(NSNonRetainedObjectHashCallBacks, 0); - connection_table_gate = [NSLock new]; - /* xxx When NSHashTable's are working, change this. */ - all_connections_local_objects = - NSCreateMapTable(NSNonOwnedPointerMapKeyCallBacks, - NSObjectMapValueCallBacks, 0); - all_connections_local_targets = - NSCreateMapTable(NSIntMapKeyCallBacks, - NSNonOwnedPointerMapValueCallBacks, 0); - all_connections_local_cached = - NSCreateMapTable(NSIntMapKeyCallBacks, - NSObjectMapValueCallBacks, 0); - received_request_rmc_queue = [[NSMutableArray alloc] initWithCapacity: 32]; - received_request_rmc_queue_gate = [NSLock new]; - received_reply_rmc_queue = [[NSMutableArray alloc] initWithCapacity: 32]; - received_reply_rmc_queue_gate = [NSLock new]; - root_object_dictionary = [[NSMutableDictionary alloc] initWithCapacity: 8]; - root_object_dictionary_gate = [NSLock new]; - receive_port_2_ancestor = - NSCreateMapTable (NSNonOwnedPointerMapKeyCallBacks, - NSNonOwnedPointerMapValueCallBacks, 0); - messages_received_count = 0; - default_receive_port_class = [TcpInPort class]; - default_send_port_class = [TcpOutPort class]; - default_proxy_class = [NSDistantObject class]; - default_encoding_class = [NSPortCoder class]; - default_decoding_class = [NSPortCoder class]; - default_reply_timeout = CONNECTION_DEFAULT_TIMEOUT; - default_request_timeout = CONNECTION_DEFAULT_TIMEOUT; -} - -+ (id) new -{ - /* - * Undocumented feature of OPENSTEP/MacOS-X - * +new returns the default connection. - */ - return RETAIN([self defaultConnection]); -} - -+ (id) currentConversation -{ - [self notImplemented: _cmd]; - return self; -} - -+ (NSDistantObject*) rootProxyForConnectionWithRegisteredName: (NSString*)n - host: (NSString*)h -{ - id p = [default_send_port_class newForSendingToRegisteredName: n onHost: h]; - if (p == nil) - { - return nil; - } - return [self rootProxyAtPort: [p autorelease]]; -} - -+ (void) _timeout: (NSTimer*)t -{ - NSArray *cached_locals; - int i; - - cached_locals = NSAllMapTableValues(all_connections_local_cached); - for (i = [cached_locals count]; i > 0; i--) - { - CachedLocalObject *item = [cached_locals objectAtIndex: i-1]; - - if ([item countdown] == NO) - { - GSLocalCounter *counter = [item obj]; - NSMapRemove(all_connections_local_cached, (void*)counter->target); - } - } - if ([cached_locals count] == 0) - { - [t invalidate]; - timer = nil; - } -} - -- (void) addRequestMode: (NSString*)mode -{ - if ([request_modes containsObject: mode] == NO) - { - [request_modes addObject: mode]; - [[NSRunLoop currentRunLoop] addPort: receive_port forMode: mode]; - } -} - -- (void) addRunLoop: (NSRunLoop*)loop -{ - [self notImplemented: _cmd]; -} - -- (void) dealloc -{ - if (debug_connection) - NSLog(@"deallocating 0x%x\n", (gsaddr)self); - [super dealloc]; -} - -- (id) delegate -{ - return delegate; -} - -- (void) handlePortMessage: (NSPortMessage*)msg -{ - [self notImplemented: _cmd]; -} - -- (BOOL) independentConversationQueueing -{ - return independent_queueing; -} - -- (void) enableMultipleThreads -{ - [self notImplemented: _cmd]; -} - -- (BOOL) multipleThreadsEnabled -{ - [self notImplemented: _cmd]; - return NO; -} - - -- (id) init -{ - /* - * Undocumented feature of OPENSTEP/MacOS-X - * -init returns the default connection. - */ - RELEASE(self); - return [NSConnection defaultConnection]; -} - -/* xxx This needs locks */ -- (void) invalidate -{ - if (is_valid == NO) - return; - - is_valid = NO; - - NSHashRemove(connection_table, self); - - /* - * Don't need notifications any more - so remove self as observer. - */ - [[NSNotificationCenter defaultCenter] removeObserver: self]; - - /* - * We can't be the ancestor of anything if we are invalid. - */ - if (self == NSMapGet(receive_port_2_ancestor, receive_port)) - NSMapRemove(receive_port_2_ancestor, receive_port); - - /* - * If we have been invalidated, we don't need to retain proxies - * for local objects any more. In fact, we want to get rid of - * these proxies in case they are keeping us retained when we - * might otherwise de deallocated. - */ - { - NSArray *targets; - unsigned i; - - [proxiesHashGate lock]; - targets = NSAllMapTableValues(local_targets); - IF_NO_GC(RETAIN(targets)); - for (i = 0; i < [targets count]; i++) - { - id t = [[targets objectAtIndex: i] localForProxy]; - - [self removeLocalObject: t]; - } - [targets release]; - [proxiesHashGate unlock]; - } - - if (debug_connection) - NSLog(@"Invalidating connection 0x%x\n\t%@\n\t%@\n", (gsaddr)self, - [receive_port description], [send_port description]); - - /* - * We need to notify any watchers of our death - but if we are already - * in the deallocation process, we can't have a notification retaining - * and autoreleasing us later once we are deallocated - so we do the - * notification with a local autorelease pool to ensure that any release - * is done before the deallocation completes. - */ - { - CREATE_AUTORELEASE_POOL(arp); - - [[NSNotificationCenter defaultCenter] - postNotificationName: NSConnectionDidDieNotification - object: self]; - RELEASE(arp); - } -} - -- (BOOL) isValid -{ - return is_valid; -} - -- (BOOL) registerName: (NSString*)name -{ - NSPortNameServer *svr = [NSPortNameServer systemDefaultPortNameServer]; - NSArray *names = [svr namesForPort: receive_port]; - BOOL result = YES; - - if (name != nil) - { - result = [svr registerPort: receive_port forName: name]; - } - if (result == YES && [names count] > 0) - { - unsigned i; - - for (i = 0; i < [names count]; i++) - { - NSString *tmp = [names objectAtIndex: i]; - - if ([tmp isEqualToString: name] == NO) - { - [svr removePort: receive_port forName: name]; - } - } - } - return result; -} - -- (void) release -{ - /* - * If this would cause the connection to be deallocated then we - * must perform all necessary work (done in [-gcFinalize]). - * We bracket the code with a retain and release so that any - * retain/release pairs in the code won't cause recursion. - */ - if ([self retainCount] == 1) - { - [super retain]; - [self gcFinalize]; - [super release]; - } - [super release]; -} - -- (NSArray *) remoteObjects -{ - [self notImplemented: _cmd]; - return nil; -} - -- (void) removeRequestMode: (NSString*)mode -{ - if ([request_modes containsObject: mode]) - { - [request_modes removeObject: mode]; - [[NSRunLoop currentRunLoop] removePort: receive_port forMode: mode]; - } -} - -- (void) removeRunLoop: (NSRunLoop *)runloop -{ - [self notImplemented: _cmd]; -} - -- (NSTimeInterval) replyTimeout -{ - return reply_timeout; -} - -- (NSArray*) requestModes -{ - return [[request_modes copy] autorelease]; -} - -- (NSTimeInterval) requestTimeout -{ - return request_timeout; -} - -- (id) rootObject -{ - return [[self class] rootObjectForInPort: receive_port]; -} - -- (NSDistantObject*) rootProxy -{ - id op, ip; - NSDistantObject *newProxy = nil; - int seq_num = [self _newMsgNumber]; - - NSParameterAssert(receive_port); - NSParameterAssert (is_valid); - op = [[self encodingClass] - newForWritingWithConnection: self - sequenceNumber: seq_num - identifier: ROOTPROXY_REQUEST]; - [op dismiss]; - ip = [self _getReceivedReplyRmcWithSequenceNumber: seq_num]; - [ip decodeObjectAt: &newProxy withName: NULL]; - NSParameterAssert (class_is_kind_of (newProxy->isa, objc_get_class ("NSDistantObject"))); - [ip dismiss]; - return [newProxy autorelease]; -} - -- (void) setDelegate: anObj -{ - delegate = anObj; -} - -- (void) setIndependentConversationQueueing: (BOOL)flag -{ - independent_queueing = flag; -} - -- (void) setReplyTimeout: (NSTimeInterval)to -{ - reply_timeout = to; -} - -- (void) setRequestMode: (NSString*)mode -{ - while ([request_modes count] > 0 && [request_modes objectAtIndex: 0] != mode) - { - [self removeRequestMode: [request_modes objectAtIndex: 0]]; - } - while ([request_modes count] > 1) - { - [self removeRequestMode: [request_modes objectAtIndex: 1]]; - } - if (mode != nil && [request_modes count] == 0) - { - [self addRequestMode: mode]; - } -} - -- (void) setRequestTimeout: (NSTimeInterval)to -{ - request_timeout = to; -} - -- (void) setRootObject: anObj -{ - [[self class] setRootObject: anObj forInPort: receive_port]; -} - -- (NSDictionary*) statistics -{ - NSMutableDictionary *d; - id o; - - d = [NSMutableDictionary dictionaryWithCapacity: 8]; - - /* - * These are in OPENSTEP 4.2 - */ - o = [NSNumber numberWithUnsignedInt: rep_in_count]; - [d setObject: o forKey: NSConnectionRepliesReceived]; - o = [NSNumber numberWithUnsignedInt: rep_out_count]; - [d setObject: o forKey: NSConnectionRepliesSent]; - o = [NSNumber numberWithUnsignedInt: req_in_count]; - [d setObject: o forKey: NSConnectionRequestsReceived]; - o = [NSNumber numberWithUnsignedInt: req_out_count]; - [d setObject: o forKey: NSConnectionRequestsSent]; - - /* - * These are GNUstep extras - */ - o = [NSNumber numberWithUnsignedInt: NSCountMapTable(local_targets)]; - [d setObject: o forKey: NSConnectionLocalCount]; - o = [NSNumber numberWithUnsignedInt: NSCountMapTable(remote_proxies)]; - [d setObject: o forKey: NSConnectionProxyCount]; - [received_request_rmc_queue_gate lock]; - o = [NSNumber numberWithUnsignedInt: [received_request_rmc_queue count]]; - [received_request_rmc_queue_gate unlock]; - [d setObject: o forKey: @"Pending packets"]; - - return d; -} - -@end - - - -@implementation NSConnection (GNUstepExtensions) - -- (void) gcFinalize -{ - CREATE_AUTORELEASE_POOL(arp); - - if (debug_connection) - NSLog(@"finalising 0x%x\n", (gsaddr)self); - - [self invalidate]; - - /* Remove rootObject from root_object_dictionary - if this is last connection */ - if (receive_port != nil - && [NSConnection connectionsCountWithInPort: receive_port] == 0) - { - [NSConnection setRootObject: nil forInPort: receive_port]; - } - - /* Remove receive port from run loop. */ - [self setRequestMode: nil]; - if (receive_port != nil) - { - [[NSRunLoop currentRunLoop] removePort: receive_port - forMode: NSConnectionReplyMode]; - } - RELEASE(request_modes); - - /* Finished with ports - releasing them may generate a notification */ - RELEASE(receive_port); - RELEASE(send_port); - - [proxiesHashGate lock]; - if (remote_proxies != 0) - NSFreeMapTable(remote_proxies); - if (local_objects != 0) - NSFreeMapTable(local_objects); - if (local_targets != 0) - NSFreeMapTable(local_targets); - [proxiesHashGate unlock]; - - RELEASE(arp); -} - -/* Getting and setting class variables */ - -+ (Class) default_decoding_class -{ - return default_decoding_class; -} - -+ (int) defaultInTimeout -{ - return default_reply_timeout; -} - -+ (int) defaultOutTimeout -{ - return default_request_timeout; -} - -+ (Class) defaultProxyClass -{ - return default_proxy_class; -} - -+ (Class) defaultReceivePortClass -{ - return default_receive_port_class; -} - -+ (Class) defaultSendPortClass -{ - return default_send_port_class; -} - -+ (void) setDefaultDecodingClass: (Class) aClass -{ - default_decoding_class = aClass; -} - -+ (void) setDefaultInTimeout: (int)to -{ - default_reply_timeout = to; -} - -+ (void) setDefaultOutTimeout: (int)to -{ - default_request_timeout = to; -} - -+ (void) setDefaultProxyClass: (Class)aClass -{ - default_proxy_class = aClass; -} - -+ (void) setDefaultReceivePortClass: (Class)aClass -{ - default_receive_port_class = aClass; -} - -+ (void) setDefaultSendPortClass: (Class)aClass -{ - default_send_port_class = aClass; -} - -/* Class-wide stats and collections. */ - -+ (int) messagesReceived -{ - return messages_received_count; -} - -+ (unsigned) connectionsCount -{ - return NSCountHashTable(connection_table); -} - -+ (unsigned) connectionsCountWithInPort: (NSPort*)aPort -{ - unsigned count = 0; - NSHashEnumerator enumerator; - NSConnection *o; - - [connection_table_gate lock]; - enumerator = NSEnumerateHashTable(connection_table); - while ((o = (NSConnection*)NSNextHashEnumeratorItem(&enumerator)) != nil) - { - if ([aPort isEqual: [o receivePort]]) - { - count++; - } - } - [connection_table_gate unlock]; - - return count; -} - - -/* Creating and initializing connections. */ - -+ (NSConnection*) newWithRootObject: anObj; -{ - id newPort; - id newConn; - - newPort = [[default_receive_port_class newForReceiving] autorelease]; - newConn = [self newForInPort: newPort outPort: nil - ancestorConnection: nil]; - [[self class] setRootObject: anObj forInPort: newPort]; - return newConn; -} - -/* I want this method name to clearly indicate that we're not connecting - to a pre-existing registration name, we're registering a new name, - and this method will fail if that name has already been registered. - This is why I don't like "newWithRegisteredName: " --- it's unclear - if we're connecting to another NSConnection that already registered - with that name. */ - -+ (NSConnection*) newRegisteringAtName: (NSString*)n withRootObject: anObj -{ - return [self newRegisteringAtName: n - atPort: 0 - withRootObject: anObj]; -} - -+ (NSConnection*) newRegisteringAtName: (NSString*)n - atPort: (int)p - withRootObject: anObj -{ - id newPort; - id newConn; - - newPort = [default_receive_port_class newForReceiving]; - newConn = [self alloc]; - newConn = [newConn initWithReceivePort: newPort sendPort: nil]; - RELEASE(newPort); - [newConn setRootObject: anObj]; - if ([newConn registerName: n] == NO) - { - DESTROY(newConn); - } - return newConn; -} - -+ (NSDistantObject*) rootProxyAtName: (NSString*)n -{ - return [self rootProxyAtName: n onHost: @""]; -} - -+ (NSDistantObject*) rootProxyAtName: (NSString*)n onHost: (NSString*)h -{ - return [self rootProxyForConnectionWithRegisteredName: n host: h]; -} - -+ (NSDistantObject*) rootProxyAtPort: (NSPort*)anOutPort -{ - NSConnection *c = [self connectionByOutPort: anOutPort]; - - if (c) - return [c rootProxy]; - else - { - id newInPort = [default_receive_port_class newForReceiving]; - return [self rootProxyAtPort: anOutPort - withInPort: [newInPort autorelease]]; - } -} - -+ (NSDistantObject*) rootProxyAtPort: (NSPort*)anOutPort - withInPort: (NSPort *)anInPort -{ - NSConnection *newConn = [self newForInPort: anInPort - outPort: anOutPort - ancestorConnection: nil]; - NSDistantObject *newRemote; - - newRemote = [newConn rootProxy]; - [newConn autorelease]; - return newRemote; -} - - -+ (NSConnection*) newForInPort: (NSPort*)ip - outPort: (NSPort*)op - ancestorConnection: (NSConnection*)ancestor -{ - NSConnection *conn; - - conn = [self alloc]; - conn = [conn initWithReceivePort: ip sendPort: op]; - return conn; -} - -+ (NSConnection*) connectionByInPort: (NSPort*)ip - outPort: (NSPort*)op -{ - NSHashEnumerator enumerator; - NSConnection *o; - - NSParameterAssert (ip); - - [connection_table_gate lock]; - - enumerator = NSEnumerateHashTable(connection_table); - while ((o = (NSConnection*)NSNextHashEnumeratorItem(&enumerator)) != nil) - { - id newConnInPort; - id newConnOutPort; - - newConnInPort = [o receivePort]; - newConnOutPort = [o sendPort]; - if ([newConnInPort isEqual: ip] - && [newConnOutPort isEqual: op]) - { - [connection_table_gate unlock]; - return o; - } - } - [connection_table_gate unlock]; - return nil; -} - -+ (NSConnection*) connectionByOutPort: (NSPort*)op -{ - NSHashEnumerator enumerator; - NSConnection *o; - - NSParameterAssert (op); - - [connection_table_gate lock]; - - enumerator = NSEnumerateHashTable(connection_table); - while ((o = (NSConnection*)NSNextHashEnumeratorItem(&enumerator)) != nil) - { - id newConnOutPort; - - newConnOutPort = [o sendPort]; - if ([newConnOutPort isEqual: op]) - { - [connection_table_gate unlock]; - return o; - } - } - [connection_table_gate unlock]; - return nil; -} - -- _superInit -{ - [super init]; - return self; -} - -+ (void) setDebug: (int)val -{ - debug_connection = val; -} - -/* Creating new rmc's for encoding requests and replies */ - -/* Create a new, empty rmc, which will be filled with a request. */ -- newSendingRequestRmc -{ - id rmc; - - NSParameterAssert(receive_port); - NSParameterAssert (is_valid); - rmc = [[self encodingClass] newForWritingWithConnection: self - sequenceNumber: [self _newMsgNumber] - identifier: METHOD_REQUEST]; - return rmc; -} - -/* Create a new, empty rmc, which will be filled with a reply to msg #n. */ -- newSendingReplyRmcWithSequenceNumber: (int)n -{ - id rmc = [[self encodingClass] newForWritingWithConnection: self - sequenceNumber: n - identifier: METHOD_REPLY]; - NSParameterAssert (is_valid); - return rmc; -} - - -/* Methods for handling client and server, requests and replies */ - -/* NSDistantObject's -forward: : method calls this to the the message over the wire. */ -- (retval_t) forwardForProxy: (NSDistantObject*)object - selector: (SEL)sel - argFrame: (arglist_t)argframe -{ - NSPortCoder *op; - - /* The callback for encoding the args of the method call. */ - void encoder (int argnum, void *datum, const char *type, int flags) - { -#define ENCODED_ARGNAME @"argument value" - switch (*type) - { - case _C_ID: - if (flags & _F_BYCOPY) - [op encodeBycopyObject: *(id*)datum withName: ENCODED_ARGNAME]; -#ifdef _F_BYREF - else if (flags & _F_BYREF) - [op encodeByrefObject: *(id*)datum withName: ENCODED_ARGNAME]; -#endif - else - [op encodeObject: *(id*)datum withName: ENCODED_ARGNAME]; - break; - default: - [op encodeValueOfObjCType: type at: datum withName: ENCODED_ARGNAME]; - } - } - - /* Encode the method on an RMC, and send it. */ - { - BOOL out_parameters; - const char *type; - retval_t retframe; - int seq_num; - - NSParameterAssert (is_valid); - - /* get the method types from the selector */ -#if NeXT_runtime - [NSException - raise: NSGenericException - format: @"Sorry, distributed objects does not work with NeXT runtime"]; - /* type = [object selectorTypeForProxy: sel]; */ -#else - type = sel_get_type(sel); -#endif - if (type == 0 || *type == '\0') { - type = [[object methodSignatureForSelector: sel] methodType]; - if (type) { - sel_register_typed_name(sel_get_name(sel), type); - } - } - NSParameterAssert(type); - NSParameterAssert(*type); - - op = [self newSendingRequestRmc]; - seq_num = [op sequenceNumber]; - if (debug_connection > 4) - NSLog(@"building packet seq %d\n", seq_num); - - /* Send the types that we're using, so that the performer knows - exactly what qualifiers we're using. - If all selectors included qualifiers, and if I could make - sel_types_match() work the way I wanted, we wouldn't need to do - this. */ - [op encodeValueOfCType: @encode(char*) - at: &type - withName: @"selector type"]; - - /* xxx This doesn't work with proxies and the NeXT runtime because - type may be a method_type from a remote machine with a - different architecture, and its argframe layout specifiers - won't be right for this machine! */ - out_parameters = mframe_dissect_call (argframe, type, encoder); - /* Send the rmc */ - [op dismiss]; - if (debug_connection > 1) - NSLog(@"Sent message to 0x%x\n", (gsaddr)self); - req_out_count++; /* Sent a request. */ - - /* Get the reply rmc, and decode it. */ - { - NSPortCoder *ip = nil; - BOOL is_exception = NO; - - void decoder(int argnum, void *datum, const char *type, int flags) - { - if (type == 0) { - if (ip) { - /* this must be here to avoid trashing alloca'ed retframe */ - [ip dismiss]; - ip = (id)-1; - } - return; - } - /* If we didn't get the reply packet yet, get it now. */ - if (!ip) - { - if (!is_valid) - { - [NSException raise: NSGenericException - format: @"connection waiting for request was shut down"]; - } - /* xxx Why do we get the reply packet in here, and not - just before calling dissect_method_return() below? */ - ip = [self _getReceivedReplyRmcWithSequenceNumber: seq_num]; - /* Find out if the server is returning an exception instead - of the return values. */ - [ip decodeValueOfCType: @encode(BOOL) - at: &is_exception - withName: NULL]; - if (is_exception) - { - /* Decode the exception object, and raise it. */ - id exc; - [ip decodeObjectAt: &exc - withName: NULL]; - [ip dismiss]; - ip = (id)-1; - /* xxx Is there anything else to clean up in - dissect_method_return()? */ - [exc raise]; - } - } - [ip decodeValueOfObjCType: type at: datum withName: NULL]; - /* -decodeValueOfCType: at: withName: malloc's new memory - for char*'s. We need to make sure it gets freed eventually - so we don't have a memory leak. Request here that it be - autorelease'ed. Also autorelease created objects. */ - if (*type == _C_CHARPTR) - [NSData dataWithBytesNoCopy: *(void**)datum length: 1]; - else if (*type == _C_ID) - [*(id*)datum autorelease]; - } - - retframe = mframe_build_return (argframe, type, out_parameters, - decoder); - /* Make sure we processed all arguments, and dismissed the IP. - IP is always set to -1 after being dismissed; the only places - this is done is in this function DECODER(). IP will be nil - if mframe_build_return() never called DECODER(), i.e. when - we are just returning (void).*/ - NSAssert(ip == (id)-1 || ip == nil, NSInternalInconsistencyException); - rep_in_count++; /* received a reply */ - return retframe; - } - } -} - -/* NSConnection calls this to service the incoming method request. */ -- (void) _service_forwardForProxy: aRmc -{ - char *forward_type = 0; - id op = nil; - int reply_sequence_number; - - void decoder (int argnum, void *datum, const char *type) - { - /* We need this "dismiss" to happen here and not later so that Coder - "-awake..." methods will get sent before the __builtin_apply! */ - if (argnum == -1 && datum == 0 && type == 0) - { - [aRmc dismiss]; - return; - } - - [aRmc decodeValueOfObjCType: type - at: datum - withName: NULL]; - /* -decodeValueOfCType: at: withName: malloc's new memory - for char*'s. We need to make sure it gets freed eventually - so we don't have a memory leak. Request here that it be - autorelease'ed. Also autorelease created objects. */ - if (*type == _C_CHARPTR) - [NSData dataWithBytesNoCopy: *(void**)datum length: 1]; - else if (*type == _C_ID) - [*(id*)datum autorelease]; - } - - void encoder (int argnum, void *datum, const char *type, int flags) - { -#define ENCODED_RETNAME @"return value" - if (op == nil) - { - BOOL is_exception = NO; - /* It is possible that our connection died while the method was - being called - in this case we mustn't try to send the result - back to the remote application! */ - if (!is_valid) - return; - op = [self newSendingReplyRmcWithSequenceNumber: - reply_sequence_number]; - [op encodeValueOfCType: @encode(BOOL) - at: &is_exception - withName: @"Exceptional reply flag"]; - } - switch (*type) - { - case _C_ID: - if (flags & _F_BYCOPY) - [op encodeBycopyObject: *(id*)datum withName: ENCODED_RETNAME]; -#ifdef _F_BYREF - else if (flags & _F_BYREF) - [op encodeByrefObject: *(id*)datum withName: ENCODED_ARGNAME]; -#endif - else - [op encodeObject: *(id*)datum withName: ENCODED_RETNAME]; - break; - default: - [op encodeValueOfObjCType: type at: datum withName: ENCODED_RETNAME]; - } - } - - /* Make sure don't let exceptions caused by servicing the client's - request cause us to crash. */ - NS_DURING - { - NSParameterAssert (is_valid); - - /* Save this for later */ - reply_sequence_number = [aRmc sequenceNumber]; - - /* Get the types that we're using, so that we know - exactly what qualifiers the forwarder used. - If all selectors included qualifiers and I could make - sel_types_match() work the way I wanted, we wouldn't need - to do this. */ - [aRmc decodeValueOfCType: @encode(char*) - at: &forward_type - withName: NULL]; - - if (debug_connection > 1) - NSLog(@"Handling message from 0x%x\n", (gsaddr)self); - req_in_count++; /* Handling an incoming request. */ - mframe_do_call (forward_type, decoder, encoder); - [op dismiss]; - rep_out_count++; /* Sent back a reply. */ - } - - /* Make sure we pass all exceptions back to the requestor. */ - NS_HANDLER - { - BOOL is_exception = YES; - - /* Try to clean up a little. */ - DESTROY(op); - - /* Send the exception back to the client. */ - if (is_valid) - { - NS_DURING - { - op = [self newSendingReplyRmcWithSequenceNumber: - reply_sequence_number]; - [op encodeValueOfCType: @encode(BOOL) - at: &is_exception - withName: @"Exceptional reply flag"]; - [op encodeBycopyObject: localException - withName: @"Exception object"]; - [op dismiss]; - } - NS_HANDLER - { - DESTROY(op); - NSLog(@"Exception when sending exception back to client - %@", - localException); - } - NS_ENDHANDLER; - } - } - NS_ENDHANDLER; - - if (forward_type) - objc_free (forward_type); -} - -- (void) _service_rootObject: rmc -{ - id rootObject = [NSConnection rootObjectForInPort: receive_port]; - NSPortCoder* op = [[self encodingClass] - newForWritingWithConnection: [rmc connection] - sequenceNumber: [rmc sequenceNumber] - identifier: ROOTPROXY_REPLY]; - NSParameterAssert (receive_port); - NSParameterAssert (is_valid); - /* Perhaps we should turn this into a class method. */ - NSParameterAssert([rmc connection] == self); - [op encodeObject: rootObject withName: @"root object"]; - [op dismiss]; - [rmc dismiss]; -} - -- (void) _service_release: rmc forConnection: receiving_connection -{ - unsigned int count; - unsigned int pos; - - NSParameterAssert (is_valid); - - if ([rmc connection] != self) - { - [rmc dismiss]; - [NSException raise: @"ProxyDecodedBadTarget" - format: @"request to release object on bad connection"]; - } - - [rmc decodeValueOfCType: @encode(typeof(count)) - at: &count - withName: NULL]; - - for (pos = 0; pos < count; pos++) - { - unsigned target; - NSDistantObject *prox; - - [rmc decodeValueOfCType: @encode(typeof(target)) - at: &target - withName: NULL]; - - prox = (NSDistantObject*)[self includesLocalTarget: target]; - if (prox != nil) - { - if (debug_connection > 3) - NSLog(@"releasing object with target (0x%x) on (0x%x)", - target, (gsaddr)self); - [self removeLocalObject: [prox localForProxy]]; - } - else if (debug_connection > 3) - NSLog(@"releasing object with target (0x%x) on (0x%x) - nothing to do", - target, (gsaddr)self); - } - - [rmc dismiss]; -} - -- (void) _service_retain: rmc forConnection: receiving_connection -{ - unsigned target; - NSPortCoder *op; - - NSParameterAssert (is_valid); - - if ([rmc connection] != self) - { - [rmc dismiss]; - [NSException raise: @"ProxyDecodedBadTarget" - format: @"request to retain object on bad connection"]; - } - - op = [[self encodingClass] newForWritingWithConnection: [rmc connection] - sequenceNumber: [rmc sequenceNumber] - identifier: RETAIN_REPLY]; - - [rmc decodeValueOfCType: @encode(typeof(target)) - at: &target - withName: NULL]; - - if (debug_connection > 3) - NSLog(@"looking to retain local object with target (0x%x) on (0x%x)", - target, (gsaddr)self); - - if ([self includesLocalTarget: target] == nil) - { - GSLocalCounter *counter; - - [proxiesHashGate lock]; - counter = NSMapGet (all_connections_local_targets, (void*)target); - if (counter == nil) - { - /* - * If the target doesn't exist for any connection, but still - * persists in the cache (ie it was recently released) then - * we move it back from the cache to the main maps so we can - * retain it on this connection. - */ - counter = NSMapGet (all_connections_local_cached, (void*)target); - if (counter) - { - unsigned t = counter->target; - id o = counter->object; - - NSMapInsert(all_connections_local_objects, (void*)o, counter); - NSMapInsert(all_connections_local_targets, (void*)t, counter); - NSMapRemove(all_connections_local_cached, (void*)t); - if (debug_connection > 3) - NSLog(@"target (0x%x) moved from cache", target); - } - } - [proxiesHashGate unlock]; - if (counter == nil) - { - [op encodeObject: @"target not found anywhere" - withName: @"retain failed"]; - if (debug_connection > 3) - NSLog(@"target (0x%x) not found anywhere for retain", target); - } - else - { - [NSDistantObject proxyWithLocal: counter->object - connection: self]; - [op encodeObject: nil withName: @"retain ok"]; - if (debug_connection > 3) - NSLog(@"retained object (0x%x) target (0x%x) on connection(0x%x)", - counter->object, counter->target, self); - } - } - else - { - [op encodeObject: nil withName: @"already retained"]; - if (debug_connection > 3) - NSLog(@"target (0x%x) already retained on connection (0x%x)", - target, self); - } - - [op dismiss]; - [rmc dismiss]; -} - -- (void) shutdown -{ - id op; - - NSParameterAssert(receive_port); - NSParameterAssert (is_valid); - op = [[self encodingClass] - newForWritingWithConnection: self - sequenceNumber: [self _newMsgNumber] - identifier: CONNECTION_SHUTDOWN]; - [op dismiss]; -} - -- (void) _service_shutdown: rmc forConnection: receiving_connection -{ - NSParameterAssert (is_valid); - [self invalidate]; - if (receiving_connection == self) - [NSException raise: NSGenericException - format: @"connection waiting for request was shut down"]; - [rmc dismiss]; -} - -- (const char *) typeForSelector: (SEL)sel remoteTarget: (unsigned)target -{ - id op, ip; - char *type = 0; - int seq_num; - - NSParameterAssert(receive_port); - NSParameterAssert (is_valid); - seq_num = [self _newMsgNumber]; - op = [[self encodingClass] - newForWritingWithConnection: self - sequenceNumber: seq_num - identifier: METHODTYPE_REQUEST]; - [op encodeValueOfObjCType: ": " - at: &sel - withName: NULL]; - [op encodeValueOfCType: @encode(unsigned) - at: &target - withName: NULL]; - [op dismiss]; - ip = [self _getReceivedReplyRmcWithSequenceNumber: seq_num]; - [ip decodeValueOfCType: @encode(char*) - at: &type - withName: NULL]; - [ip dismiss]; - return type; -} - -- (void) _service_typeForSelector: rmc -{ - NSPortCoder* op; - unsigned target; - NSDistantObject *p; - id o; - SEL sel; - const char *type; - struct objc_method* m; - - NSParameterAssert(receive_port); - NSParameterAssert (is_valid); - NSParameterAssert([rmc connection] == self); - op = [[self encodingClass] - newForWritingWithConnection: [rmc connection] - sequenceNumber: [rmc sequenceNumber] - identifier: METHODTYPE_REPLY]; - - [rmc decodeValueOfObjCType: ": " - at: &sel - withName: NULL]; - [rmc decodeValueOfCType: @encode(unsigned) - at: &target - withName: NULL]; - p = [self includesLocalTarget: target]; - o = [p localForProxy]; - - /* xxx We should make sure that TARGET is a valid object. */ - /* Not actually a Proxy, but we avoid the warnings "id" would have made. */ - m = class_get_instance_method(((NSDistantObject*)o)->isa, sel); - /* Perhaps I need to be more careful in the line above to get the - version of the method types that has the type qualifiers in it. - Search the protocols list. */ - if (m) - type = m->method_types; - else - type = ""; - [op encodeValueOfCType: @encode(char*) - at: &type - withName: @"Requested Method Type for Target"]; - [op dismiss]; - [rmc dismiss]; -} - - -/* Running the connection, getting/sending requests/replies. */ - -- (void) runConnectionUntilDate: date -{ - [NSRunLoop runUntilDate: date]; -} - -- (void) runConnection -{ - [self runConnectionUntilDate: [NSDate distantFuture]]; -} - -- (void) _handleRmc: rmc -{ - NSConnection *conn = [rmc connection]; - int ident = [rmc identifier]; - - if (debug_connection > 4) - NSLog(@"handling packet of type %d seq %d\n", ident, [rmc sequenceNumber]); - - switch (ident) - { - case ROOTPROXY_REQUEST: - /* It won't take much time to handle this, so go ahead and service - it, even if we are waiting for a reply. */ - [conn _service_rootObject: rmc]; - break; - case METHODTYPE_REQUEST: - /* It won't take much time to handle this, so go ahead and service - it, even if we are waiting for a reply. */ - [conn _service_typeForSelector: rmc]; - break; - case METHOD_REQUEST: - /* We just got a new request; we need to decide whether to queue - it or service it now. - If the REPLY_DEPTH is 0, then we aren't in the middle of waiting - for a reply, we are waiting for requests---so service it now. - If REPLY_DEPTH is non-zero, we may still want to service it now - if independent_queuing is NO. */ - if (request_depth == 0 || independent_queueing == NO) - { - request_depth++; - [conn _service_forwardForProxy: rmc]; - request_depth--; - /* Service any requests that were queued while we - were waiting for replies. - xxx Is this the right place for this check? */ - if (request_depth == 0) - [self _handleQueuedRmcRequests]; - } - else - { - [received_request_rmc_queue_gate lock]; - [received_request_rmc_queue addObject: rmc]; - [received_request_rmc_queue_gate unlock]; - } - break; - case ROOTPROXY_REPLY: - case METHOD_REPLY: - case METHODTYPE_REPLY: - case RETAIN_REPLY: - /* Remember multi-threaded callbacks will have to be handled specially */ - [received_reply_rmc_queue_gate lock]; - [received_reply_rmc_queue addObject: rmc]; - [received_reply_rmc_queue_gate unlock]; - break; - case CONNECTION_SHUTDOWN: - { - [conn _service_shutdown: rmc forConnection: self]; - break; - } - case PROXY_RELEASE: - { - [conn _service_release: rmc forConnection: self]; - break; - } - case PROXY_RETAIN: - { - [conn _service_retain: rmc forConnection: self]; - break; - } - default: - [rmc dismiss]; - [NSException raise: NSGenericException - format: @"unrecognized NSPortCoder identifier"]; - } -} - -- (void) _handleQueuedRmcRequests -{ - id rmc; - - [received_request_rmc_queue_gate lock]; - RETAIN(self); - while (is_valid && ([received_request_rmc_queue count] > 0)) - { - rmc = [received_request_rmc_queue objectAtIndex: 0]; - RETAIN(rmc); - [received_request_rmc_queue removeObjectAtIndex: 0]; - [received_request_rmc_queue_gate unlock]; - [self _handleRmc: rmc]; - [received_request_rmc_queue_gate lock]; - RELEASE(rmc); - } - RELEASE(self); - [received_request_rmc_queue_gate unlock]; -} - -/* Deal with an RMC, either by queuing it for later service, or - by servicing it right away. This method is called by the - receive_port's received-packet-invocation. */ - -/* Look for it on the queue, if it is not there, return nil. */ -- _getReceivedReplyRmcFromQueueWithSequenceNumber: (int)sn -{ - id the_rmc = nil; - unsigned count, i; - - [received_reply_rmc_queue_gate lock]; - - count = [received_reply_rmc_queue count]; - /* xxx There should be a per-thread queue of rmcs so we can do - callbacks when multi-threaded. */ - for (i = 0; i < count; i++) - { - id a_rmc = [received_reply_rmc_queue objectAtIndex: i]; - if ([a_rmc connection] == self - && [a_rmc sequenceNumber] == sn) - { - if (debug_connection) - NSLog(@"Getting received reply from queue\n"); - [received_reply_rmc_queue removeObjectAtIndex: i]; - the_rmc = a_rmc; - break; - } - /* xxx Make sure that there isn't a higher sequenceNumber, meaning - that we somehow dropped a packet. */ - } - [received_reply_rmc_queue_gate unlock]; - return the_rmc; -} - -/* Check the queue, then try to get it from the network by waiting - while we run the NSRunLoop. Raise exception if we don't get anything - before timing out. */ -- _getReceivedReplyRmcWithSequenceNumber: (int)sn -{ - id rmc; - id timeout_date = nil; - - while (!(rmc = [self _getReceivedReplyRmcFromQueueWithSequenceNumber: sn])) - { - if (!timeout_date) - timeout_date = [[NSDate alloc] - initWithTimeIntervalSinceNow: reply_timeout]; - if ([NSRunLoop runOnceBeforeDate: timeout_date - forMode: NSConnectionReplyMode] == NO) - break; - } - if (timeout_date) - [timeout_date release]; - if (rmc == nil) - [NSException raise: NSPortTimeoutException - format: @"timed out waiting for reply"]; - return rmc; -} - -/* Sneaky, sneaky. See "sneaky" comment in TcpPort.m. - This method is called by InPort when it receives a new packet. */ -+ (void) invokeWithObject: packet -{ - id rmc; - NSConnection *connection; - - if (debug_connection > 3) - NSLog(@"packet arrived on %@", [[packet receivingInPort] description]); - - connection = NSMapGet(receive_port_2_ancestor, [packet receivingInPort]); - if (connection && [connection isValid]) - { - rmc = [NSPortCoder newDecodingWithPacket: packet - connection: connection]; - [[rmc connection] _handleRmc: rmc]; - } - else - { - [packet release]; /* Discard data on invalid connection. */ - } -} - -- (int) _newMsgNumber -{ - int n; - - NSParameterAssert (is_valid); - [sequenceNumberGate lock]; - n = message_count++; - [sequenceNumberGate unlock]; - return n; -} - - - -/* Managing objects and proxies. */ -- (void) addLocalObject: anObj -{ - id object = [anObj localForProxy]; - unsigned target; - GSLocalCounter *counter; - - NSParameterAssert (is_valid); - [proxiesHashGate lock]; - /* xxx Do we need to check to make sure it's not already there? */ - /* This retains object. */ - NSMapInsert(local_objects, (void*)object, anObj); - - /* - * Keep track of local objects accross all connections. - */ - counter = NSMapGet(all_connections_local_objects, (void*)object); - if (counter) - { - counter->ref++; - target = counter->target; - } - else - { - counter = [GSLocalCounter newWithObject: object]; - target = counter->target; - NSMapInsert(all_connections_local_objects, (void*)object, counter); - NSMapInsert(all_connections_local_targets, (void*)target, counter); - [counter release]; - } - [anObj setProxyTarget: target]; - NSMapInsert(local_targets, (void*)target, anObj); - if (debug_connection > 2) - NSLog(@"add local object (0x%x) target (0x%x) " - @"to connection (0x%x) (ref %d)\n", - (gsaddr)object, target, (gsaddr) self, counter->ref); - [proxiesHashGate unlock]; -} - -- (NSDistantObject*) localForObject: (id)object -{ - NSDistantObject *p; - - /* Don't assert (is_valid); */ - [proxiesHashGate lock]; - p = NSMapGet (local_objects, (void*)object); - [proxiesHashGate unlock]; - NSParameterAssert(!p || [p connectionForProxy] == self); - return p; -} - -/* This should get called whenever an object free's itself */ -+ (void) removeLocalObject: (id)anObj -{ - NSHashEnumerator enumerator; - NSConnection *o; - - enumerator = NSEnumerateHashTable(connection_table); - while ((o = (NSConnection*)NSNextHashEnumeratorItem(&enumerator)) != nil) - { - [o removeLocalObject: anObj]; - } -} - -- (void) removeLocalObject: anObj -{ - NSDistantObject *prox; - unsigned target; - GSLocalCounter *counter; - unsigned val = 0; - - [proxiesHashGate lock]; - - prox = NSMapGet(local_objects, (void*)anObj); - target = [prox targetForProxy]; - - /* - * If all references to a local proxy have gone - remove the - * global reference as well. - */ - counter = NSMapGet(all_connections_local_objects, (void*)anObj); - if (counter) - { - counter->ref--; - if ((val = counter->ref) == 0) - { - /* - * If this proxy has been vended onwards by another process, we - * need to keep a reference to the local object around for a - * while in case that other process needs it. - */ - if (0) - { - id item; - if (timer == nil) - { - timer = [NSTimer scheduledTimerWithTimeInterval: 1.0 - target: [NSConnection class] - selector: @selector(_timeout:) - userInfo: nil - repeats: YES]; - } - item = [CachedLocalObject itemWithObject: counter time: 30]; - NSMapInsert(all_connections_local_cached, (void*)target, item); - if (debug_connection > 3) - NSLog(@"placed local object (0x%x) target (0x%x) in cache", - (gsaddr)anObj, target); - } - NSMapRemove(all_connections_local_objects, (void*)anObj); - NSMapRemove(all_connections_local_targets, (void*)target); - } - } - - NSMapRemove(local_objects, (void*)anObj); - NSMapRemove(local_targets, (void*)target); - - if (debug_connection > 2) - NSLog(@"remove local object (0x%x) target (0x%x) " - @"from connection (0x%x) (ref %d)\n", - (gsaddr)anObj, target, (gsaddr)self, val); - - [proxiesHashGate unlock]; -} - -- (void) _release_targets: (unsigned*)list count: (unsigned)number -{ - NS_DURING - { - /* - * Tell the remote app that it can release its local objects - * for the targets in the specified list since we don't have - * proxies for them any more. - */ - if (receive_port && is_valid && number > 0) { - id op; - unsigned i; - - op = [[self encodingClass] - newForWritingWithConnection: self - sequenceNumber: [self _newMsgNumber] - identifier: PROXY_RELEASE]; - - [op encodeValueOfCType: @encode(unsigned) - at: &number - withName: NULL]; - - for (i = 0; i < number; i++) - { - [op encodeValueOfCType: @encode(unsigned) - at: &list[i] - withName: NULL]; - if (debug_connection > 3) - NSLog(@"sending release for target (0x%x) on (0x%x)", - list[i], (gsaddr)self); - } - - [op dismiss]; - } - } - NS_HANDLER - { - if (debug_connection) - NSLog(@"failed to release targets - %@\n", [localException name]); - } - NS_ENDHANDLER -} - -- (void) retainTarget: (unsigned)target -{ - NS_DURING - { - /* - * Tell the remote app that it must retain the local object - * for the target on this connection. - */ - if (receive_port && is_valid) - { - id op; - id ip; - id result; - int seq_num = [self _newMsgNumber]; - - op = [[self encodingClass] - newForWritingWithConnection: self - sequenceNumber: seq_num - identifier: PROXY_RETAIN]; - - [op encodeValueOfCType: @encode(typeof(target)) - at: &target - withName: NULL]; - - [op dismiss]; - ip = [self _getReceivedReplyRmcWithSequenceNumber: seq_num]; - [ip decodeObjectAt: &result withName: NULL]; - if (result != nil) - NSLog(@"failed to retain target - %@\n", result); - [ip dismiss]; - } - } - NS_HANDLER - { - NSLog(@"failed to retain target - %@\n", [localException name]); - } - NS_ENDHANDLER -} - -- (void) removeProxy: (NSDistantObject*)aProxy -{ - unsigned target = [aProxy targetForProxy]; - - /* Don't assert (is_valid); */ - [proxiesHashGate lock]; - /* This also releases aProxy */ - NSMapRemove (remote_proxies, (void*)target); - [proxiesHashGate unlock]; - - /* - * Tell the remote application that we have removed our proxy and - * it can release it's local object. - */ - [self _release_targets: &target count: 1]; -} - -- (NSArray*) localObjects -{ - NSArray *c; - - /* Don't assert (is_valid); */ - [proxiesHashGate lock]; - c = NSAllMapTableValues(local_objects); - [proxiesHashGate unlock]; - return c; -} - -- (NSArray*) proxies -{ - NSArray *c; - - /* Don't assert (is_valid); */ - [proxiesHashGate lock]; - c = NSAllMapTableValues(remote_proxies); - [proxiesHashGate unlock]; - return c; -} - -- (NSDistantObject*) proxyForTarget: (unsigned)target -{ - NSDistantObject *p; - - /* Don't assert (is_valid); */ - [proxiesHashGate lock]; - p = NSMapGet (remote_proxies, (void*)target); - [proxiesHashGate unlock]; - NSParameterAssert(!p || [p connectionForProxy] == self); - return p; -} - -- (void) addProxy: (NSDistantObject*) aProxy -{ - unsigned target = (unsigned int)[aProxy targetForProxy]; - - NSParameterAssert (is_valid); - NSParameterAssert(aProxy->isa == [NSDistantObject class]); - NSParameterAssert([aProxy connectionForProxy] == self); - [proxiesHashGate lock]; - if (NSMapGet (remote_proxies, (void*)target)) - { - [proxiesHashGate unlock]; - [NSException raise: NSGenericException - format: @"Trying to add the same proxy twice"]; - } - NSMapInsert (remote_proxies, (void*)target, aProxy); - [proxiesHashGate unlock]; -} - -- (id) includesProxyForTarget: (unsigned)target -{ - NSDistantObject *ret; - - /* Don't assert (is_valid); */ - [proxiesHashGate lock]; - ret = NSMapGet (remote_proxies, (void*)target); - [proxiesHashGate unlock]; - return ret; -} - -- (id) includesLocalObject: (id)anObj -{ - NSDistantObject* ret; - - /* Don't assert (is_valid); */ - [proxiesHashGate lock]; - ret = NSMapGet(local_objects, (void*)anObj); - [proxiesHashGate unlock]; - return ret; -} - -- (id) includesLocalTarget: (unsigned)target -{ - NSDistantObject* ret; - - /* Don't assert (is_valid); */ - [proxiesHashGate lock]; - ret = NSMapGet(local_targets, (void*)target); - [proxiesHashGate unlock]; - return ret; -} - -/* Check all connections. - Proxy needs to use this when decoding a local object in order to - make sure the target address is a valid object. It is not enough - for the Proxy to check the Proxy's connection only (using - -includesLocalTarget), because the proxy may have come from a - triangle connection. */ -+ (id) includesLocalTarget: (unsigned)target -{ - id ret; - - /* Don't assert (is_valid); */ - NSParameterAssert (all_connections_local_targets); - [proxiesHashGate lock]; - ret = NSMapGet (all_connections_local_targets, (void*)target); - [proxiesHashGate unlock]; - return ret; -} - - -/* Pass nil to remove any reference keyed by aPort. */ -+ (void) setRootObject: anObj forInPort: (NSPort*)aPort -{ - id oldRootObject = [self rootObjectForInPort: aPort]; - - NSParameterAssert ([aPort isValid]); - /* xxx This retains aPort? How will aPort ever get dealloc'ed? */ - if (oldRootObject != anObj) - { - if (anObj) - { - [root_object_dictionary_gate lock]; - [root_object_dictionary setObject: anObj forKey: aPort]; - [root_object_dictionary_gate unlock]; - } - else /* anObj == nil && oldRootObject != nil */ - { - [root_object_dictionary_gate lock]; - [root_object_dictionary removeObjectForKey: aPort]; - [root_object_dictionary_gate unlock]; - } - } -} - -+ rootObjectForInPort: (NSPort*)aPort -{ - id ro; - - [root_object_dictionary_gate lock]; - ro = [root_object_dictionary objectForKey: aPort]; - [root_object_dictionary_gate unlock]; - return ro; -} - - -/* Accessing ivars */ - -- (Class) receivePortClass -{ - return receive_port_class; -} - -- (Class) sendPortClass -{ - return send_port_class; -} - -- (void) setReceivePortClass: (Class) aPortClass -{ - receive_port_class = aPortClass; -} - -- (void) setSendPortClass: (Class) aPortClass -{ - send_port_class = aPortClass; -} - -- (Class) proxyClass -{ - /* we might replace this with a per-Connection proxy class. */ - return default_proxy_class; -} - -- (Class) encodingClass -{ - return encoding_class; -} - -- (Class) decodingClass -{ - /* we might replace this with a per-Connection class. */ - return default_decoding_class; -} - - -/* Prevent trying to encode the connection itself */ - -- (void) encodeWithCoder: anEncoder -{ - [self shouldNotImplement: _cmd]; -} - -+ newWithCoder: aDecoder; -{ - [self shouldNotImplement: _cmd]; - return self; -} - - -/* Shutting down and deallocating. */ - -/* - * We register this method for a notification when a port dies. - * NB. It is possible that the death of a port could be notified - * to us after we are invalidated - in which case we must ignore it. - */ -- (void) portIsInvalid: notification -{ - if (is_valid) - { - id port = [notification object]; - - if (debug_connection) - { - NSLog(@"Received port invalidation notification for " - @"connection 0x%x\n\t%@\n", (gsaddr)self, port); - } - - /* We shouldn't be getting any port invalidation notifications, - except from our own ports; this is how we registered ourselves - with the NSNotificationCenter in - +newForInPort: outPort: ancestorConnection. */ - NSParameterAssert (port == receive_port || port == send_port); - - [self invalidate]; - } -} - -@end - - - -@implementation NSConnection (OPENSTEP) - -+ (NSConnection*) connectionWithReceivePort: (NSPort*)r - sendPort: (NSPort*)s -{ - NSConnection *c; - - c = [self alloc]; - c = [self initWithReceivePort: r sendPort: s]; - return AUTORELEASE(c); -} - -/* This is the designated initializer for NSConnection */ -- (id) initWithReceivePort: (NSPort*)r - sendPort: (NSPort*)s -{ - NSNotificationCenter *nCenter; - NSConnection *conn; - id del; - - NSParameterAssert(r); - - /* - * Find previously existing connection if there - */ - conn = [NSConnection connectionByInPort: r outPort: s]; - if (conn != nil) - { - if (debug_connection > 2) - { - NSLog(@"Found existing connection (0x%x) for \n\t%@\n\t%@\n", - (gsaddr)conn, r, s); - } - RELEASE(self); - return RETAIN(conn); - } - [connection_table_gate lock]; - - if (debug_connection) - { - NSLog(@"Initialised new connection 0x%x\n\t%@\n\t%@\n", - (gsaddr)self, r, s); - } - is_valid = YES; - receive_port = RETAIN(r); - send_port = RETAIN(s); - message_count = 0; - rep_out_count = 0; - req_out_count = 0; - rep_in_count = 0; - req_in_count = 0; - - /* - * This maps (void*)obj to (id)obj. The obj's are retained. - * We use this instead of an NSHashTable because we only care about - * the object's address, and don't want to send the -hash message to it. - */ - local_objects = - NSCreateMapTable(NSNonOwnedPointerMapKeyCallBacks, - NSObjectMapValueCallBacks, 0); - - /* - * This maps handles for local objects to their local proxies. - */ - local_targets = - NSCreateMapTable(NSIntMapKeyCallBacks, - NSNonOwnedPointerMapValueCallBacks, 0); - - /* - * This maps [proxy targetForProxy] to proxy. The proxy's are retained. - */ - remote_proxies = - NSCreateMapTable(NSIntMapKeyCallBacks, - NSNonOwnedPointerMapValueCallBacks, 0); - - reply_timeout = default_reply_timeout; - request_timeout = default_request_timeout; - encoding_class = default_encoding_class; - - /* xxx It this the correct behavior? */ - if ((conn = NSMapGet(receive_port_2_ancestor, r)) == nil) - { - NSMapInsert(receive_port_2_ancestor, r, self); - /* - * This will cause the connection with the registered name - * to receive the -invokeWithObject: from the IN_PORT. - * This ends up being the ancestor of future new NSConnections - * on this in port. - */ - /* xxx Could it happen that this connection was invalidated, but - the others would still be OK? That would cause problems. - No. I don't think that can happen. */ - [(InPort*)r setReceivedPacketInvocation: (id)[self class]]; - } - - if (conn != nil) - { - receive_port_class = [conn receivePortClass]; - send_port_class = [conn sendPortClass]; - } - else - { - receive_port_class = default_receive_port_class; - send_port_class = default_send_port_class; - } - independent_queueing = NO; - request_depth = 0; - delegate = nil; - /* - * Set up request modes array and make sure the receiving port is - * added to the run loop to get data. - */ - request_modes - = RETAIN([NSMutableArray arrayWithObject: NSDefaultRunLoopMode]); - [[NSRunLoop currentRunLoop] addPort: (NSPort*)r - forMode: NSDefaultRunLoopMode]; - [[NSRunLoop currentRunLoop] addPort: (NSPort*)r - forMode: NSConnectionReplyMode]; - - /* Ask the delegate for permission, (OpenStep-style and GNUstep-style). */ - - /* Preferred OpenStep version, which just allows the returning of BOOL */ - del = [conn delegate]; - if ([del respondsTo: @selector(connection:shouldMakeNewConnection:)]) - { - if ([del connection: conn shouldMakeNewConnection: self] == NO) - { - [connection_table_gate unlock]; - RELEASE(self); - return nil; - } - } - /* Deprecated OpenStep version, which just allows the returning of BOOL */ - if ([del respondsTo: @selector(makeNewConnection:sender:)]) - { - if (![del makeNewConnection: self sender: conn]) - { - [connection_table_gate unlock]; - RELEASE(self); - return nil; - } - } - /* Here is the GNUstep version, which allows the delegate to specify - a substitute. Note: The delegate is responsible for freeing - newConn if it returns something different. */ - if ([del respondsTo: @selector(connection:didConnect:)]) - self = [del connection: conn didConnect: self]; - - /* Register ourselves for invalidation notification when the - ports become invalid. */ - nCenter = [NSNotificationCenter defaultCenter]; - [nCenter addObserver: self - selector: @selector(portIsInvalid:) - name: NSPortDidBecomeInvalidNotification - object: r]; - if (s != nil) - [nCenter addObserver: self - selector: @selector(portIsInvalid:) - name: NSPortDidBecomeInvalidNotification - object: s]; - - /* In order that connections may be deallocated - there is an - implementation of [-release] to automatically remove the connection - from this array when it is the only thing retaining it. */ - NSHashInsert(connection_table, (void*)self); - [connection_table_gate unlock]; - - [[NSNotificationCenter defaultCenter] - postNotificationName: NSConnectionDidInitializeNotification - object: self]; - - return self; -} - -- (NSPort*) receivePort -{ - return receive_port; -} - -- (void) runInNewThread -{ - [self notImplemented: _cmd]; -} - -- (NSPort*) sendPort -{ - return send_port; -} - -@end -#endif diff --git a/Source/NSCountedSet.m b/Source/NSCountedSet.m index 23bfd3638..31a098c3f 100644 --- a/Source/NSCountedSet.m +++ b/Source/NSCountedSet.m @@ -23,8 +23,10 @@ #include #include +#include #include #include +#include #include #include #include @@ -77,21 +79,16 @@ static Class NSCountedSet_concrete_class; } } -+ (void) _setCountedSetConcreteClass: (Class)c -{ - NSCountedSet_concrete_class = c; -} - -+ (Class) _concreteClass -{ - return NSCountedSet_concrete_class; -} - + (id) allocWithZone: (NSZone*)z { if (self == NSCountedSet_abstract_class) - return NSAllocateObject(NSCountedSet_concrete_class, 0, z); - return [super allocWithZone: z]; + { + return NSAllocateObject(NSCountedSet_concrete_class, 0, z); + } + else + { + return NSAllocateObject(self, 0, z); + } } - (unsigned int) countForObject: (id)anObject @@ -112,13 +109,59 @@ static Class NSCountedSet_concrete_class; - (id) initWithCoder: (NSCoder*)aCoder { - [self subclassResponsibility: _cmd]; - return nil; + unsigned count; + Class c = fastClass(self); + + if (c == NSCountedSet_abstract_class) + { + RELEASE(self); + self = [NSCountedSet_concrete_class allocWithZone: NSDefaultMallocZone()]; + return [self initWithCoder: aCoder]; + } + [aCoder decodeValueOfObjCType: @encode(unsigned) at: &count]; + { + id objs[count]; + unsigned refs[count]; + unsigned i; + IMP addImp = [self methodForSelector: @selector(addObject:)]; + + for (i = 0; i < count; i++) + { + [aCoder decodeValueOfObjCType: @encode(id) at: &objs[i]]; + [aCoder decodeValueOfObjCType: @encode(unsigned) at: &refs[i]]; + } + self = [self initWithObjects: objs count: count]; + for (i = 0; i < count; i++) + { + unsigned j = refs[i]; + + while (j-- > 1) + { + (*addImp)(self, @selector(addObject:), objs[i]); + } + } + } + return self; +} + +- (Class) classForCoder +{ + return NSCountedSet_abstract_class; } - (void) encodeWithCoder: (NSCoder*)aCoder { - [self subclassResponsibility: _cmd]; + unsigned count = [self count]; + NSEnumerator *e = [self objectEnumerator]; + id o; + + [aCoder encodeValueOfObjCType: @encode(unsigned) at: &count]; + while ((o = [e nextObject]) != nil) + { + [aCoder encodeValueOfObjCType: @encode(id) at: &o]; + count = [self countForObject: o]; + [aCoder encodeValueOfObjCType: @encode(unsigned) at: &count]; + } } - (id) initWithSet: (NSSet*)other copyItems: (BOOL)flag @@ -147,14 +190,15 @@ static Class NSCountedSet_concrete_class; { unsigned extra = [(NSCountedSet*)other countForObject: os[j]]; - if (extra > 1) - while (--extra) - (*addImp)(self, @selector(addObject:), os[j]); + while (extra-- > 1) + (*addImp)(self, @selector(addObject:), os[j]); } } +#if !GS_WITH_GC if (flag) while (i--) [os[i] release]; +#endif return self; } diff --git a/Source/NSData.m b/Source/NSData.m index 9f9c5865c..bea9500e7 100644 --- a/Source/NSData.m +++ b/Source/NSData.m @@ -110,6 +110,8 @@ static SEL appendSel = @selector(appendBytes:length:); static Class dataStatic; static Class dataMalloc; static Class mutableDataMalloc; +static Class NSDataAbstract; +static Class NSMutableDataAbstract; static IMP appendImp; static BOOL @@ -326,6 +328,8 @@ failure: { if (self == [NSData class]) { + NSDataAbstract = self; + NSMutableDataAbstract = [NSMutableData class]; dataMalloc = [NSDataMalloc class]; dataStatic = [NSDataStatic class]; mutableDataMalloc = [NSMutableDataMalloc class]; @@ -335,7 +339,14 @@ failure: + (id) allocWithZone: (NSZone*)z { - return (NSData*)NSAllocateObject(dataMalloc, 0, z); + if (self == NSDataAbstract) + { + return NSAllocateObject(dataMalloc, 0, z); + } + else + { + return NSAllocateObject(self, 0, z); + } } + (id) data @@ -1269,7 +1280,14 @@ failure: @implementation NSMutableData + (id) allocWithZone: (NSZone*)z { - return (NSData*)NSAllocateObject(mutableDataMalloc, 0, z); + if (self == NSMutableDataAbstract) + { + return NSAllocateObject(mutableDataMalloc, 0, z); + } + else + { + return NSAllocateObject(self, 0, z); + } } + (id) data diff --git a/Source/NSDate.m b/Source/NSDate.m index 943165bb5..1b61a7747 100644 --- a/Source/NSDate.m +++ b/Source/NSDate.m @@ -877,7 +877,7 @@ GSTimeNow() return abstractClass; } -- replacementObjectForPortCoder: aRmc +- (id) replacementObjectForPortCoder: (NSPortCoder*)aRmc { return self; } @@ -928,13 +928,13 @@ GSTimeNow() { // Get the current time, add the secs and init thyself return [self initWithTimeIntervalSinceReferenceDate: - GSTimeNow() + secsToBeAdded]; + GSTimeNow() + secsToBeAdded]; } - (id)initWithTimeIntervalSince1970: (NSTimeInterval)seconds { return [self initWithTimeIntervalSinceReferenceDate: - UNIX_REFERENCE_INTERVAL + seconds]; + UNIX_REFERENCE_INTERVAL + seconds]; } - (id) initWithTimeIntervalSinceReferenceDate: (NSTimeInterval)secs @@ -1017,6 +1017,11 @@ GSTimeNow() - (NSTimeInterval) timeIntervalSinceDate: (NSDate*)otherDate { + if (otherDate == nil) + { + [NSException raise: NSInvalidArgumentException + format: @"nil argument for timeIntervalSinceDate:"]; + } return otherTime(self) - otherTime(otherDate); } @@ -1035,17 +1040,33 @@ GSTimeNow() - (NSComparisonResult) compare: (NSDate*)otherDate { + if (otherDate == self) + { + return NSOrderedSame; + } + if (otherDate == nil) + { + [NSException raise: NSInvalidArgumentException + format: @"nil argument for compare:"]; + } if (otherTime(self) > otherTime(otherDate)) - return NSOrderedDescending; - + { + return NSOrderedDescending; + } if (otherTime(self) < otherTime(otherDate)) - return NSOrderedAscending; - + { + return NSOrderedAscending; + } return NSOrderedSame; } - (NSDate*) earlierDate: (NSDate*)otherDate { + if (otherDate == nil) + { + [NSException raise: NSInvalidArgumentException + format: @"nil argument for earlierDate:"]; + } if (otherTime(self) > otherTime(otherDate)) return otherDate; return self; @@ -1053,6 +1074,8 @@ GSTimeNow() - (BOOL) isEqual: (id)other { + if (other == nil) + return NO; if ([other isKindOf: abstractClass] && 1.0 > ABS(otherTime(self) - otherTime(other))) return YES; @@ -1061,6 +1084,8 @@ GSTimeNow() - (BOOL) isEqualToDate: (NSDate*)other { + if (other == nil) + return NO; if (1.0 > ABS(otherTime(self) - otherTime(other))) return YES; return NO; @@ -1068,6 +1093,11 @@ GSTimeNow() - (NSDate*) laterDate: (NSDate*)otherDate { + if (otherDate == nil) + { + [NSException raise: NSInvalidArgumentException + format: @"nil argument for laterDate:"]; + } if (otherTime(self) < otherTime(otherDate)) return otherDate; @@ -1091,19 +1121,21 @@ GSTimeNow() return [self class]; } -- replacementObjectForPortCoder: aRmc +- (id) replacementObjectForPortCoder: (NSPortCoder*)aRmc { return self; } - (void) encodeWithCoder: (NSCoder*)coder { - [coder encodeValueOfObjCType: @encode(NSTimeInterval) at: &_seconds_since_ref]; + [coder encodeValueOfObjCType: @encode(NSTimeInterval) + at: &_seconds_since_ref]; } - (id) initWithCoder: (NSCoder*)coder { - [coder decodeValueOfObjCType: @encode(NSTimeInterval) at: &_seconds_since_ref]; + [coder decodeValueOfObjCType: @encode(NSTimeInterval) + at: &_seconds_since_ref]; return self; } @@ -1123,6 +1155,11 @@ GSTimeNow() - (NSTimeInterval) timeIntervalSinceDate: (NSDate*)otherDate { + if (otherDate == nil) + { + [NSException raise: NSInvalidArgumentException + format: @"nil argument for timeIntervalSinceDate:"]; + } return _seconds_since_ref - otherTime(otherDate); } @@ -1140,17 +1177,33 @@ GSTimeNow() - (NSComparisonResult) compare: (NSDate*)otherDate { + if (otherDate == self) + { + return NSOrderedSame; + } + if (otherDate == nil) + { + [NSException raise: NSInvalidArgumentException + format: @"nil argument for compare:"]; + } if (_seconds_since_ref > otherTime(otherDate)) - return NSOrderedDescending; - + { + return NSOrderedDescending; + } if (_seconds_since_ref < otherTime(otherDate)) - return NSOrderedAscending; - + { + return NSOrderedAscending; + } return NSOrderedSame; } - (NSDate*) earlierDate: (NSDate*)otherDate { + if (otherDate == nil) + { + [NSException raise: NSInvalidArgumentException + format: @"nil argument for earlierDate:"]; + } if (_seconds_since_ref > otherTime(otherDate)) return otherDate; return self; @@ -1158,6 +1211,8 @@ GSTimeNow() - (BOOL) isEqual: (id)other { + if (other == nil) + return NO; if ([other isKindOfClass: abstractClass] && 1.0 > ABS(_seconds_since_ref - otherTime(other))) return YES; @@ -1166,6 +1221,8 @@ GSTimeNow() - (BOOL) isEqualToDate: (NSDate*)other { + if (other == nil) + return NO; if (1.0 > ABS(_seconds_since_ref - otherTime(other))) return YES; return NO; @@ -1173,6 +1230,11 @@ GSTimeNow() - (NSDate*) laterDate: (NSDate*)otherDate { + if (otherDate == nil) + { + [NSException raise: NSInvalidArgumentException + format: @"nil argument for laterDate:"]; + } if (_seconds_since_ref < otherTime(otherDate)) return otherDate; return self; @@ -1202,7 +1264,7 @@ GSTimeNow() return [self class]; } -- replacementObjectForPortCoder: aRmc +- (id) replacementObjectForPortCoder: (NSPortCoder*)aRmc { return self; } diff --git a/Source/NSDictionary.m b/Source/NSDictionary.m index 1d9732c57..aee1bf371 100644 --- a/Source/NSDictionary.m +++ b/Source/NSDictionary.m @@ -59,26 +59,6 @@ static SEL remSel = @selector(removeObjectForKey:); static SEL setSel = @selector(setObject:forKey:); static SEL appSel = @selector(appendString:); -+ (void) _setConcreteClass: (Class)c -{ - NSDictionary_concrete_class = c; -} - -+ (void) _setMutableConcreteClass: (Class)c -{ - NSMutableDictionary_concrete_class = c; -} - -+ (Class) _concreteClass -{ - return NSDictionary_concrete_class; -} - -+ (Class) _mutableConcreteClass -{ - return NSMutableDictionary_concrete_class; -} - + (void) initialize { if (self == [NSDictionary class]) @@ -95,8 +75,13 @@ static SEL appSel = @selector(appendString:); + (id) allocWithZone: (NSZone*)z { if (self == NSDictionary_abstract_class) - return NSAllocateObject(NSDictionary_concrete_class, 0, z); - return [super allocWithZone: z]; + { + return NSAllocateObject(NSDictionary_concrete_class, 0, z); + } + else + { + return NSAllocateObject(self, 0, z); + } } /* This is the designated initializer */ @@ -863,8 +848,13 @@ static NSString *indentStrings[] = { + (id) allocWithZone: (NSZone*)z { if (self == NSMutableDictionary_abstract_class) - return NSAllocateObject(NSMutableDictionary_concrete_class, 0, z); - return [super allocWithZone: z]; + { + return NSAllocateObject(NSMutableDictionary_concrete_class, 0, z); + } + else + { + return NSAllocateObject(self, 0, z); + } } - (id) copyWithZone: (NSZone*)z diff --git a/Source/NSFileHandle.m b/Source/NSFileHandle.m index ddd9bfc56..e48551282 100644 --- a/Source/NSFileHandle.m +++ b/Source/NSFileHandle.m @@ -29,6 +29,7 @@ #include #include +static Class NSFileHandle_abstract_class = nil; static Class NSFileHandle_concrete_class = nil; @implementation NSFileHandle @@ -37,63 +38,72 @@ static Class NSFileHandle_concrete_class = nil; { if (self == [NSFileHandle class]) { + NSFileHandle_abstract_class = self; NSFileHandle_concrete_class = [UnixFileHandle class]; } } -+ (void)_setConcreteClass: (Class)c -{ - NSFileHandle_concrete_class = c; -} - -+ (Class)_concreteClass -{ - return NSFileHandle_concrete_class; -} - + (id) allocWithZone: (NSZone*)z { - return NSAllocateObject ([self _concreteClass], 0, z); + if (self == NSFileHandle_abstract_class) + { + return NSAllocateObject (NSFileHandle_concrete_class, 0, z); + } + else + { + return NSAllocateObject (self, 0, z); + } } // Allocating and Initializing a FileHandle Object + (id) fileHandleForReadingAtPath: (NSString*)path { - return AUTORELEASE([[[self _concreteClass] alloc] - initForReadingAtPath: path]); + id o = [self allocWithZone: NSDefaultMallocZone()]; + + return AUTORELEASE([o initForReadingAtPath: path]); } + (id) fileHandleForWritingAtPath: (NSString*)path { - return AUTORELEASE([[[self _concreteClass] alloc] - initForWritingAtPath: path]); + id o = [self allocWithZone: NSDefaultMallocZone()]; + + return AUTORELEASE([o initForWritingAtPath: path]); } + (id) fileHandleForUpdatingAtPath: (NSString*)path { - return AUTORELEASE([[[self _concreteClass] alloc] - initForUpdatingAtPath: path]); + id o = [self allocWithZone: NSDefaultMallocZone()]; + + return AUTORELEASE([o initForUpdatingAtPath: path]); } + (id) fileHandleWithStandardError { - return AUTORELEASE([[[self _concreteClass] alloc] initWithStandardError]); + id o = [self allocWithZone: NSDefaultMallocZone()]; + + return AUTORELEASE([o initWithStandardError]); } + (id) fileHandleWithStandardInput { - return AUTORELEASE([[[self _concreteClass] alloc] initWithStandardInput]); + id o = [self allocWithZone: NSDefaultMallocZone()]; + + return AUTORELEASE([o initWithStandardInput]); } + (id) fileHandleWithStandardOutput { - return AUTORELEASE([[[self _concreteClass] alloc] initWithStandardOutput]); + id o = [self allocWithZone: NSDefaultMallocZone()]; + + return AUTORELEASE([o initWithStandardOutput]); } + (id) fileHandleWithNullDevice { - return AUTORELEASE([[[self _concreteClass] alloc] initWithNullDevice]); + id o = [self allocWithZone: NSDefaultMallocZone()]; + + return AUTORELEASE([o initWithNullDevice]); } - (id) initWithFileDescriptor: (int)desc @@ -277,21 +287,23 @@ NSString* NSFileHandleOperationException = service: (NSString*)service protocol: (NSString*)protocol { - return AUTORELEASE([[[self _concreteClass] alloc] - initAsClientAtAddress: address - service: service - protocol: protocol]); + id o = [self allocWithZone: NSDefaultMallocZone()]; + + return AUTORELEASE([o initAsClientAtAddress: address + service: service + protocol: protocol]); } + (id) fileHandleAsClientInBackgroundAtAddress: (NSString*)address service: (NSString*)service protocol: (NSString*)protocol { - return AUTORELEASE([[[self _concreteClass] alloc] - initAsClientInBackgroundAtAddress: address - service: service - protocol: protocol - forModes: nil]); + id o = [self allocWithZone: NSDefaultMallocZone()]; + + return AUTORELEASE([o initAsClientInBackgroundAtAddress: address + service: service + protocol: protocol + forModes: nil]); } + (id) fileHandleAsClientInBackgroundAtAddress: (NSString*)address @@ -299,21 +311,23 @@ NSString* NSFileHandleOperationException = protocol: (NSString*)protocol forModes: (NSArray*)modes { - return AUTORELEASE([[[self _concreteClass] alloc] - initAsClientInBackgroundAtAddress: address - service: service - protocol: protocol - forModes: modes]); + id o = [self allocWithZone: NSDefaultMallocZone()]; + + return AUTORELEASE([o initAsClientInBackgroundAtAddress: address + service: service + protocol: protocol + forModes: modes]); } + (id) fileHandleAsServerAtAddress: (NSString*)address service: (NSString*)service protocol: (NSString*)protocol { - return AUTORELEASE([[[self _concreteClass] alloc] - initAsServerAtAddress: address - service: service - protocol: protocol]); + id o = [self allocWithZone: NSDefaultMallocZone()]; + + return AUTORELEASE([o initAsServerAtAddress: address + service: service + protocol: protocol]); } - (BOOL) readInProgress diff --git a/Source/NSGArray.m b/Source/NSGArray.m index 4b8229c47..ac11404d0 100644 --- a/Source/NSGArray.m +++ b/Source/NSGArray.m @@ -683,3 +683,122 @@ static SEL eqSel = @selector(isEqual:); return array->_contents_array[--pos]; } @end + +@implementation NSGArray (GNUstep) +/* + * The comparator function takes two items as arguments, the first is the + * item to be added, the second is the item already in the array. + * The function should return NSOrderedAscending if the item to be + * added is 'less than' the item in the array, NSOrderedDescending + * if it is greater, and NSOrderedSame if it is equal. + */ +- (unsigned) insertionPosition: (id)item + usingFunction: (NSComparisonResult (*)(id, id))sorter +{ + unsigned upper = _count; + unsigned lower = 0; + unsigned index; + + if (item == nil) + { + [NSException raise: NSGenericException + format: @"Attempt to find position for nil object in array"]; + } + if (sorter == 0) + { + [NSException raise: NSGenericException + format: @"Attempt to find position with null comparator"]; + } + + /* + * Binary search for an item equal to the one to be inserted. + */ + for (index = upper/2; upper != lower; index = lower+(upper-lower)/2) + { + NSComparisonResult comparison; + + comparison = (*sorter)(item, _contents_array[index]); + if (comparison == NSOrderedAscending) + { + upper = index; + } + else if (comparison == NSOrderedDescending) + { + lower = index + 1; + } + else + { + break; + } + } + /* + * Now skip past any equal items so the insertion point is AFTER any + * items that are equal to the new one. + */ + while (index < _count + && (*sorter)(item, _contents_array[index]) != NSOrderedAscending) + { + index++; + } + return index; +} + +- (unsigned) insertionPosition: (id)item + usingSelector: (SEL)comp +{ + unsigned upper = _count; + unsigned lower = 0; + unsigned index; + NSComparisonResult (*imp)(id, SEL, id); + + if (item == nil) + { + [NSException raise: NSGenericException + format: @"Attempt to find position for nil object in array"]; + } + if (comp == 0) + { + [NSException raise: NSGenericException + format: @"Attempt to find position with null comparator"]; + } + imp = (NSComparisonResult (*)(id, SEL, id))[item methodForSelector: comp]; + if (imp == 0) + { + [NSException raise: NSGenericException + format: @"Attempt to find position with unknown method"]; + } + + /* + * Binary search for an item equal to the one to be inserted. + */ + for (index = upper/2; upper != lower; index = lower+(upper-lower)/2) + { + NSComparisonResult comparison; + + comparison = (*imp)(item, comp, _contents_array[index]); + if (comparison == NSOrderedAscending) + { + upper = index; + } + else if (comparison == NSOrderedDescending) + { + lower = index + 1; + } + else + { + break; + } + } + /* + * Now skip past any equal items so the insertion point is AFTER any + * items that are equal to the new one. + */ + while (index < _count + && (*imp)(item, comp, _contents_array[index]) != NSOrderedAscending) + { + index++; + } + return index; +} +@end + diff --git a/Source/NSGCString.m b/Source/NSGCString.m index b004cb454..ebcb9fe39 100644 --- a/Source/NSGCString.m +++ b/Source/NSGCString.m @@ -800,6 +800,77 @@ static IMP msInitImp; /* designated initialiser for mutable */ return strRangeCsNs(self, aString, mask, aRange); } +- (BOOL) boolValue +{ + if (_count == 0) + { + return 0; + } + else if (_count == 3 + && (_contents_chars[0] == 'Y' || _contents_chars[0] == 'y') + && (_contents_chars[1] == 'E' || _contents_chars[1] == 'e') + && (_contents_chars[2] == 'S' || _contents_chars[2] == 's')) + { + return YES; + } + else + { + char buf[_count+1]; + + memcpy(buf, _contents_chars, _count); + buf[_count] = '\0'; + return atoi(buf); + } +} + +- (double) doubleValue +{ + if (_count == 0) + { + return 0; + } + else + { + char buf[_count+1]; + + memcpy(buf, _contents_chars, _count); + buf[_count] = '\0'; + return atof(buf); + } +} + +- (float) floatValue +{ + if (_count == 0) + { + return 0; + } + else + { + char buf[_count+1]; + + memcpy(buf, _contents_chars, _count); + buf[_count] = '\0'; + return (float) atof(buf); + } +} + +- (int) intValue +{ + if (_count == 0) + { + return 0; + } + else + { + char buf[_count+1]; + + memcpy(buf, _contents_chars, _count); + buf[_count] = '\0'; + return atoi(buf); + } +} + @end diff --git a/Source/NSGSet.m b/Source/NSGSet.m index e4b96156f..0905e084b 100644 --- a/Source/NSGSet.m +++ b/Source/NSGSet.m @@ -25,7 +25,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -65,9 +67,12 @@ - (id) initWithSet: (NSSet*)d { - [super init]; - set = (NSGSet*)RETAIN(d); - node = set->map.firstNode; + self = [super init]; + if (self != nil) + { + set = (NSGSet*)RETAIN(d); + node = set->map.firstNode; + } return self; } @@ -94,11 +99,18 @@ @implementation NSGSet +static Class arrayClass; +static Class setClass; +static Class mutableSetClass; + + (void) initialize { if (self == [NSGSet class]) { class_add_behavior(self, [NSSetNonCore class]); + arrayClass = [NSArray class]; + setClass = [NSGSet class]; + mutableSetClass = [NSGMutableSet class]; } } @@ -113,46 +125,6 @@ [super dealloc]; } -- (void) encodeWithCoder: (NSCoder*)aCoder -{ - unsigned count = map.nodeCount; - GSIMapNode node = map.firstNode; - SEL sel = @selector(encodeObject:); - IMP imp = [aCoder methodForSelector: sel]; - - [aCoder encodeValueOfObjCType: @encode(unsigned) at: &count]; - while (node != 0) - { - (*imp)(aCoder, sel, node->key.obj); - node = node->nextInMap; - } -} - -- (unsigned) hash -{ - return map.nodeCount; -} - -- (id) initWithCoder: (NSCoder*)aCoder -{ - unsigned count; - id value; - SEL sel = @selector(decodeValueOfObjCType:at:); - IMP imp = [aCoder methodForSelector: sel]; - const char *type = @encode(id); - - (*imp)(aCoder, sel, @encode(unsigned), &count); - - GSIMapInitWithZoneAndCapacity(&map, [self zone], count); - while (count-- > 0) - { - (*imp)(aCoder, sel, type, &value); - GSIMapAddKeyNoRetain(&map, (GSIMapKey)value); - } - - return self; -} - /* Designated initialiser */ - (id) initWithObjects: (id*)objs count: (unsigned)c { @@ -199,6 +171,247 @@ @end +@implementation NSGSet (NonCore) + +- (NSArray*) allObjects +{ + id objs[map.nodeCount]; + GSIMapNode node = map.firstNode; + unsigned i = 0; + + while (node != 0) + { + objs[i++] = node->key.obj; + node = node->nextInMap; + } + return AUTORELEASE([[arrayClass allocWithZone: NSDefaultMallocZone()] + initWithObjects: objs count: i]); +} + +- (id) anyObject +{ + if (map.nodeCount > 0) + return map.firstNode->key.obj; + else + return nil; +} + +- (void) encodeWithCoder: (NSCoder*)aCoder +{ + unsigned count = map.nodeCount; + GSIMapNode node = map.firstNode; + SEL sel = @selector(encodeObject:); + IMP imp = [aCoder methodForSelector: sel]; + + [aCoder encodeValueOfObjCType: @encode(unsigned) at: &count]; + while (node != 0) + { + (*imp)(aCoder, sel, node->key.obj); + node = node->nextInMap; + } +} + +- (unsigned) hash +{ + return map.nodeCount; +} + +- (id) initWithCoder: (NSCoder*)aCoder +{ + unsigned count; + id value; + SEL sel = @selector(decodeValueOfObjCType:at:); + IMP imp = [aCoder methodForSelector: sel]; + const char *type = @encode(id); + + (*imp)(aCoder, sel, @encode(unsigned), &count); + + GSIMapInitWithZoneAndCapacity(&map, [self zone], count); + while (count-- > 0) + { + (*imp)(aCoder, sel, type, &value); + GSIMapAddKeyNoRetain(&map, (GSIMapKey)value); + } + + return self; +} + +- (BOOL) intersectsSet: (NSSet*) otherSet +{ + Class c; + + /* + * If this set is empty, or the other is nil, this method should return NO. + */ + if (map.nodeCount == 0) + return NO; + if (otherSet == nil) + return NO; + + // Loop for all members in otherSet + c = fastClass(otherSet); + if (c == setClass || c == mutableSetClass) + { + GSIMapNode node = ((NSGSet*)otherSet)->map.firstNode; + + while (node != 0) + { + if (GSIMapNodeForKey(&map, node->key) != 0) + { + return YES; + } + node = node->nextInMap; + } + } + else + { + NSEnumerator *e; + id o; + + e = [otherSet objectEnumerator]; + while ((o = [e nextObject])) // 1. pick a member from otherSet. + { + if (GSIMapNodeForKey(&map, (GSIMapKey)o) != 0) + { + return YES; + } + } + } + return NO; +} + +- (BOOL) isSubsetOfSet: (NSSet*) otherSet +{ + GSIMapNode node = map.firstNode; + + // -1. members of this set(self) <= that of otherSet + if (map.nodeCount > [otherSet count]) + return NO; + + // 0. Loop for all members in this set(self). + while (node != 0) + { + // 1. check the member is in the otherSet. + if ([otherSet member: node->key.obj]) + { + // 1.1 if true -> continue, try to check the next member. + node = node->nextInMap; + } + else + { + // 1.2 if false -> return NO; + return NO; + } + } + // 2. return YES; all members in this set are also in the otherSet. + return YES; +} + +- (BOOL) isEqualToSet: (NSSet*)other +{ + if (other == nil) + { + return NO; + } + else if (other == self) + { + return YES; + } + else + { + Class c = fastClass(other); + + if (c == setClass || c == mutableSetClass) + { + if (map.nodeCount != ((NSGSet*)other)->map.nodeCount) + { + return NO; + } + else + { + GSIMapNode node = map.firstNode; + + while (node != 0) + { + if (GSIMapNodeForKey(&(((NSGSet*)other)->map), node->key) + == 0) + { + return NO; + } + node = node->nextInMap; + } + } + } + else + { + if (map.nodeCount != [other count]) + { + return NO; + } + else + { + GSIMapNode node = map.firstNode; + + while (node != 0) + { + if ([other member: node->key.obj] == nil) + { + return NO; + } + node = node->nextInMap; + } + } + } + return YES; + } +} + +- (void) makeObjectsPerform: (SEL)aSelector +{ + GSIMapNode node = map.firstNode; + + while (node != 0) + { + [node->key.obj performSelector: aSelector]; + node = node->nextInMap; + } +} + +- (void) makeObjectsPerformSelector: (SEL)aSelector +{ + GSIMapNode node = map.firstNode; + + while (node != 0) + { + [node->key.obj performSelector: aSelector]; + node = node->nextInMap; + } +} + +- (void) makeObjectsPerformSelector: (SEL)aSelector withObject: argument +{ + GSIMapNode node = map.firstNode; + + while (node != 0) + { + [node->key.obj performSelector: aSelector withObject: argument]; + node = node->nextInMap; + } +} + +- (void) makeObjectsPerform: (SEL)aSelector withObject: argument +{ + GSIMapNode node = map.firstNode; + + while (node != 0) + { + [node->key.obj performSelector: aSelector withObject: argument]; + node = node->nextInMap; + } +} + +@end + @implementation NSGMutableSet + (void) initialize @@ -217,6 +430,34 @@ return self; } +- (id) initWithObjects: (id*)objects + count: (unsigned)count +{ + self = [self initWithCapacity: count]; + + while (count--) + { + id anObject = objects[count]; + + if (anObject == nil) + { + NSLog(@"Tried to init a set with a nil object"); + continue; + } + else + { + GSIMapNode node; + + node = GSIMapNodeForKey(&map, (GSIMapKey)anObject); + if (node == 0) + { + GSIMapAddKey(&map, (GSIMapKey)anObject); + } + } + } + return self; +} + - (void) addObject: (NSObject*)anObject { GSIMapNode node; @@ -224,7 +465,7 @@ if (anObject == nil) { [NSException raise: NSInvalidArgumentException - format: @"Tried to add nil to set"]; + format: @"Tried to add nil to set"]; } node = GSIMapNodeForKey(&map, (GSIMapKey)anObject); if (node == 0) @@ -249,3 +490,95 @@ } @end + +@implementation NSGMutableSet (NonCore) + +- (void) addObjectsFromArray: (NSArray*)array +{ + unsigned count = [array count]; + + while (count--) + { + id anObject = [array objectAtIndex: count]; + + if (anObject == nil) + { + [NSException raise: NSInvalidArgumentException + format: @"Tried to add nil to set"]; + } + else + { + GSIMapNode node; + + node = GSIMapNodeForKey(&map, (GSIMapKey)anObject); + if (node == 0) + { + GSIMapAddKey(&map, (GSIMapKey)anObject); + } + } + } +} + +- (void) unionSet: (NSSet*) other +{ + if (other != self) + { + NSEnumerator *e = [other objectEnumerator]; + id anObject; + + while ((anObject = [e nextObject]) != nil) + { + GSIMapNode node; + + if (anObject == nil) + { + [NSException raise: NSInvalidArgumentException + format: @"Tried to add nil to set"]; + } + node = GSIMapNodeForKey(&map, (GSIMapKey)anObject); + if (node == 0) + { + GSIMapAddKey(&map, (GSIMapKey)anObject); + } + } + } +} + +- (void) intersectSet: (NSSet*) other +{ + if (other != self) + { + GSIMapNode node = map.firstNode; + + while (node != 0) + { + GSIMapNode next = node->nextInMap; + + if ([other containsObject: node->key.obj] == NO) + { + GSIMapRemoveKey(&map, node->key); + } + node = next; + } + } +} + +- (void) minusSet: (NSSet*) other +{ + if (other == self) + { + GSIMapCleanMap(&map); + } + else + { + NSEnumerator *e = [other objectEnumerator]; + id anObject; + + while ((anObject = [e nextObject]) != nil) + { + GSIMapRemoveKey(&map, (GSIMapKey)anObject); + } + } +} + +@end diff --git a/Source/NSGString.m b/Source/NSGString.m index dfef39f7c..ffa9cc236 100644 --- a/Source/NSGString.m +++ b/Source/NSGString.m @@ -306,7 +306,7 @@ char *r = (char*)_fastMallocBuffer(_count+1); if (_count > 0) - ustrtostr(r,_contents_chars, _count); + ustrtostr(r, _contents_chars, _count); r[_count] = '\0'; return r; } @@ -498,6 +498,81 @@ return strRangeUsNs(self, aString, mask, aRange); } + +- (BOOL) boolValue +{ + if (_count == 0) + { + return 0; + } + else + { + char buf[_count+1]; + + ustrtostr(buf, _contents_chars, _count); + buf[_count] = '\0'; + if (_count == 3 + && (_contents_chars[0] == 'Y' || _contents_chars[0] == 'y') + && (_contents_chars[1] == 'E' || _contents_chars[1] == 'e') + && (_contents_chars[2] == 'S' || _contents_chars[2] == 's')) + { + return YES; + } + else + { + return atoi(buf); + } + } +} + +- (double) doubleValue +{ + if (_count == 0) + { + return 0; + } + else + { + char buf[_count+1]; + + ustrtostr(buf, _contents_chars, _count); + buf[_count] = '\0'; + return atof(buf); + } +} + +- (float) floatValue +{ + if (_count == 0) + { + return 0; + } + else + { + char buf[_count+1]; + + ustrtostr(buf, _contents_chars, _count); + buf[_count] = '\0'; + return (float) atof(buf); + } +} + +- (int) intValue +{ + if (_count == 0) + { + return 0; + } + else + { + char buf[_count+1]; + + ustrtostr(buf, _contents_chars, _count); + buf[_count] = '\0'; + return atoi(buf); + } +} + @end diff --git a/Source/NSHost.m b/Source/NSHost.m index b588081cf..d0ac4a77f 100644 --- a/Source/NSHost.m +++ b/Source/NSHost.m @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -48,62 +49,153 @@ #define INADDR_NONE -1 #endif +static NSString *localHostName = @"GNUstep local host"; +static Class hostClass; static NSLock *_hostCacheLock = nil; static BOOL _hostCacheEnabled = YES; static NSMutableDictionary *_hostCache = nil; +static NSString *myHostName = nil; + @interface NSHost (Private) ++ (struct hostent*) _entryForAddress: (NSString*)address; - (id) _initWithHostEntry: (struct hostent*)entry key: (NSString*)key; ++ (NSMutableSet*) _localAddresses; @end @implementation NSHost (Private) ++ (struct hostent*) _entryForAddress: (NSString*)address +{ + struct hostent *h = 0; + struct in_addr hostaddr; + +#ifndef HAVE_INET_ATON + hostaddr.s_addr = inet_addr([address cString]); + if (hostaddr.s_addr == INADDR_NONE) + { + NSLog(@"Attempt to lookup host entry for bad IP address (%@)", address); + } +#else + if (inet_aton([address cString], (struct in_addr*)&hostaddr.s_addr) == 0) + { + NSLog(@"Attempt to lookup host entry for bad IP address (%@)", address); + } +#endif + else + { + h = gethostbyaddr((char*)&hostaddr, sizeof(hostaddr), AF_INET); + if (h == 0) + { + NSLog(@"Host '%@' not found using 'gethostbyaddr()' - perhaps " + @"the address is wrong or networking is not set up on your " + @"machine", address); + } + } + return h; +} + - (id) _initWithHostEntry: (struct hostent*)entry key: (NSString*)name { int i; char *ptr; struct in_addr in; NSString *h_name; + NSMutableSet *names; + NSMutableSet *addresses; + NSMutableSet *extra; if ((self = [super init]) == nil) { return nil; } - if (name == nil || [name isEqual: @""] == YES) - { - NSLog(@"Host init failed - empty name/address supplied"); - RELEASE(self); - return nil; - } - if (entry == (struct hostent*)NULL) + if (name != localHostName && entry == (struct hostent*)NULL) { NSLog(@"Host '%@' init failed - perhaps the name/address is wrong or " @"networking is not set up on your machine", name); RELEASE(self); return nil; } - - _names = [NSMutableArray new]; - _addresses = [NSMutableArray new]; - - h_name = [NSString stringWithCString: entry->h_name]; - [_names addObject: h_name]; - - i = 0; - while ((ptr = entry->h_aliases[i++]) != 0) + else if (localHostName == nil && entry != (struct hostent*)NULL) { - [_names addObject: [NSString stringWithCString: ptr]]; + NSLog(@"Nil hostname supplied but network database entry is not empty"); + RELEASE(self); + return nil; } - i = 0; - while ((ptr = entry->h_addr_list[i++]) != 0) - { - NSString *addr; + names = [NSMutableSet new]; + addresses = [NSMutableSet new]; - memcpy((void*)&in.s_addr, (const void*)ptr, entry->h_length); - addr = [NSString stringWithCString: (char*)inet_ntoa(in)]; - [_addresses addObject: addr]; + if (name == localHostName) + { + extra = [hostClass _localAddresses]; } + else + { + extra = nil; + } + + for (;;) + { + /* + * We remove all the IP addresses that we have added to the host so + * far from the set of extra addresses available on the current host. + * Then we try to find a new network database entry for one of the + * remaining extra addresses, and loop round to add all the names + * and addresses for that entry. + */ + [extra minusSet: addresses]; + while (entry == 0 && [extra count] > 0) + { + NSString *a = [extra anyObject]; + + entry = [hostClass _entryForAddress: a]; + if (entry == 0) + { + /* + * Can't find a database entry for this IP address, but since + * we know the address is valid, we add it to the list of + * addresses for this host anyway. + */ + [addresses addObject: a]; + [extra removeObject: a]; + } + } + if (entry == 0) + { + break; + } + + h_name = [NSString stringWithCString: entry->h_name]; + [names addObject: h_name]; + + if (entry->h_aliases != 0) + { + i = 0; + while ((ptr = entry->h_aliases[i++]) != 0) + { + [names addObject: [NSString stringWithCString: ptr]]; + } + } + if (entry->h_addr_list != 0) + { + i = 0; + while ((ptr = entry->h_addr_list[i++]) != 0) + { + NSString *addr; + + memcpy((void*)&in.s_addr, (const void*)ptr, entry->h_length); + addr = [NSString stringWithCString: (char*)inet_ntoa(in)]; + [addresses addObject: addr]; + } + } + entry = 0; + } + + _names = [names copy]; + RELEASE(names); + _addresses = [addresses copy]; + RELEASE(addresses); if (_hostCacheEnabled == YES) { @@ -113,6 +205,14 @@ static NSMutableDictionary *_hostCache = nil; return self; } ++ (NSMutableSet*) _localAddresses +{ + NSMutableSet *set; + + set = [[self currentHost]->_addresses mutableCopy]; + [set addObject: @"127.0.0.1"]; + return AUTORELEASE(set); +} @end @implementation NSHost @@ -122,8 +222,6 @@ static NSMutableDictionary *_hostCache = nil; */ #define GSMAXHOSTNAMELEN 255 -static NSString *myHost = nil; - + (void) initialize { if (self == [NSHost class]) @@ -131,24 +229,25 @@ static NSString *myHost = nil; char buf[GSMAXHOSTNAMELEN+1]; int res; + hostClass = self; res = gethostname(buf, GSMAXHOSTNAMELEN); - if (res < 0) + if (res < 0 || *buf == '\0') { NSLog(@"Unable to get name of current host - using 'localhost'"); - myHost = @"localhost"; + myHostName = @"localhost"; } else { - myHost = [[NSString alloc] initWithCString: buf]; + myHostName = [[NSString alloc] initWithCString: buf]; } - _hostCacheLock = [[NSLock alloc] init]; + _hostCacheLock = [[NSRecursiveLock alloc] init]; _hostCache = [NSMutableDictionary new]; } } + (NSHost*) currentHost { - return [self hostWithName: myHost]; + return [self hostWithName: myHostName]; } + (NSHost*) hostWithName: (NSString*)name @@ -160,6 +259,11 @@ static NSString *myHost = nil; NSLog(@"Nil host name sent to [NSHost +hostWithName:]"); return nil; } + if ([name isEqual: @""] == YES) + { + NSLog(@"Empty host name sent to [NSHost +hostWithName:]"); + return nil; + } [_hostCacheLock lock]; if (_hostCacheEnabled == YES) @@ -168,19 +272,31 @@ static NSString *myHost = nil; } if (host == nil) { - struct hostent *h; - - h = gethostbyname((char*)[name cString]); - if (h == 0) + if (name == localHostName) { - NSLog(@"Host '%@' not found using 'gethostbyname()' - perhaps " - @"the hostname is wrong or networking is not set up on your " - @"machine", name); + /* + * Special GNUstep extension host - we try to have a host entry + * with ALL the IP addresses of any interfaaces on the local machine + */ + host = [[self alloc] _initWithHostEntry: 0 key: name]; + AUTORELEASE(host); } else { - host = [[self alloc] _initWithHostEntry: h key: name]; - AUTORELEASE(host); + struct hostent *h = 0; + + h = gethostbyname((char*)[name cString]); + if (h == 0) + { + NSLog(@"Host '%@' not found using 'gethostbyname()' - perhaps " + @"the hostname is wrong or networking is not set up on your " + @"machine", name); + } + else + { + host = [[self alloc] _initWithHostEntry: h key: name]; + AUTORELEASE(host); + } } } [_hostCacheLock unlock]; @@ -196,6 +312,11 @@ static NSString *myHost = nil; NSLog(@"Nil host address sent to [NSHost +hostWithName:]"); return nil; } + if ([address isEqual: @""] == YES) + { + NSLog(@"Empty host address sent to [NSHost +hostWithName:]"); + return nil; + } [_hostCacheLock lock]; if (_hostCacheEnabled == YES) @@ -206,35 +327,12 @@ static NSString *myHost = nil; if (host == nil) { struct hostent *h; - struct in_addr hostaddr; - BOOL addrOk = YES; -#ifndef HAVE_INET_ATON - hostaddr.s_addr = inet_addr([address cString]); - if (hostaddr.s_addr == INADDR_NONE) + h = [self _entryForAddress: address]; + if (h != 0) { - addrOk = NO; - } -#else - if (inet_aton([address cString], (struct in_addr*)&hostaddr.s_addr) == 0) - { - addrOk = NO; - } -#endif - if (addrOk == YES) - { - h = gethostbyaddr((char*)&hostaddr, sizeof(hostaddr), AF_INET); - if (h == 0) - { - NSLog(@"Host '%@' not found using 'gethostbyaddr()' - perhaps " - @"the address is wrong or networking is not set up on your " - @"machine", address); - } - else - { - host = [[self alloc] _initWithHostEntry: h key: address]; - AUTORELEASE(host); - } + host = [[self alloc] _initWithHostEntry: h key: address]; + AUTORELEASE(host); } } [_hostCacheLock unlock]; @@ -250,13 +348,7 @@ static NSString *myHost = nil; + (BOOL) isHostCacheEnabled; { - BOOL res; - - [_hostCacheLock lock]; - res = _hostCacheEnabled; - [_hostCacheLock unlock]; - - return res; + return _hostCacheEnabled; } + (void) flushHostCache @@ -279,7 +371,21 @@ static NSString *myHost = nil; - (void) encodeWithCoder: (NSCoder*)aCoder { - [aCoder encodeObject: [self address]]; + NSString *address = [self address]; + + if ([address isEqual: @"127.0.0.1"] == YES) + { + NSEnumerator *e = [_addresses objectEnumerator]; + + while ((address = [e nextObject]) != nil) + { + if ([address isEqual: @"127.0.0.1"] == NO) + { + break; + } + } + } + [aCoder encodeObject: address]; } - (id) initWithCoder: (NSCoder*)aCoder @@ -288,7 +394,15 @@ static NSString *myHost = nil; NSHost *host; address = [aCoder decodeObject]; - host = RETAIN([NSHost hostWithAddress: address]); + if (address != nil) + { + host = [NSHost hostWithAddress: address]; + } + else + { + host = [NSHost currentHost]; + } + RETAIN(host); RELEASE(self); return host; } @@ -324,52 +438,68 @@ static NSString *myHost = nil; - (BOOL) isEqual: (id)other { if (other == self) - return YES; + { + return YES; + } if ([other isKindOfClass: [NSHost class]]) - return [self isEqualToHost: (NSHost*)other]; + { + return [self isEqualToHost: (NSHost*)other]; + } return NO; } - (BOOL) isEqualToHost: (NSHost*)aHost { - NSArray* a; - int i; + NSEnumerator *e; + NSString *a; if (aHost == self) - return YES; - - a = [aHost addresses]; - for (i = 0; i < [a count]; i++) - if ([_addresses containsObject: [a objectAtIndex: i]]) + { return YES; - + } + e = [aHost->_addresses objectEnumerator]; + while ((a = [e nextObject]) != nil) + { + if ([_addresses member: a] != nil) + { + return YES; + } + } return NO; } - (NSString*) name { - return [_names objectAtIndex: 0]; + return [_names anyObject]; } - (NSArray*) names { - return _names; + return [_names allObjects]; } - (NSString*) address { - return [_addresses objectAtIndex: 0]; + return [_addresses anyObject]; } - (NSArray*) addresses { - return _addresses; + return [_addresses allObjects]; } - (NSString*) description { return [NSString stringWithFormat: @"Host %@ (%@ %@)", - [self name], [self names], [self addresses]]; + [self name], _names, _addresses]; } @end + +@implementation NSHost (GNUstep) ++ (NSHost*) localHost +{ + return [self hostWithName: localHostName]; +} +@end + diff --git a/Source/NSNumber.m b/Source/NSNumber.m index 03ee95033..ce57c7c3f 100644 --- a/Source/NSNumber.m +++ b/Source/NSNumber.m @@ -302,7 +302,7 @@ static Class doubleNumberClass; } } -+ (NSNumber*) numberWithChar: (char)value ++ (NSNumber*) numberWithChar: (signed char)value { NSNumber *theObj; @@ -336,7 +336,7 @@ static Class doubleNumberClass; return AUTORELEASE(theObj); } -+ (NSNumber*) numberWithInt: (int)value ++ (NSNumber*) numberWithInt: (signed int)value { NSNumber *theObj; @@ -350,7 +350,7 @@ static Class doubleNumberClass; return AUTORELEASE(theObj); } -+ (NSNumber*) numberWithLong: (long)value ++ (NSNumber*) numberWithLong: (signed long)value { NSNumber *theObj; @@ -364,7 +364,7 @@ static Class doubleNumberClass; return AUTORELEASE(theObj); } -+ (NSNumber*) numberWithLongLong: (long long)value ++ (NSNumber*) numberWithLongLong: (signed long long)value { NSNumber *theObj; @@ -378,7 +378,7 @@ static Class doubleNumberClass; return AUTORELEASE(theObj); } -+ (NSNumber*) numberWithShort: (short)value ++ (NSNumber*) numberWithShort: (signed short)value { NSNumber *theObj; @@ -500,7 +500,7 @@ static Class doubleNumberClass; return RETAIN(self); } -- (id) initWithChar: (char)value +- (id) initWithChar: (signed char)value { NSDeallocateObject(self); if (value <= GS_SMALL && value >= -GS_SMALL) @@ -531,7 +531,7 @@ static Class doubleNumberClass; return self; } -- (id) initWithInt: (int)value +- (id) initWithInt: (signed int)value { NSDeallocateObject(self); if (value <= GS_SMALL && value >= -GS_SMALL) @@ -544,7 +544,7 @@ static Class doubleNumberClass; return self; } -- (id) initWithLong: (long)value +- (id) initWithLong: (signed long)value { NSDeallocateObject(self); if (value <= GS_SMALL && value >= -GS_SMALL) @@ -557,7 +557,7 @@ static Class doubleNumberClass; return self; } -- (id) initWithLongLong: (long long)value +- (id) initWithLongLong: (signed long long)value { NSDeallocateObject(self); if (value <= GS_SMALL && value >= -GS_SMALL) @@ -570,7 +570,7 @@ static Class doubleNumberClass; return self; } -- (id) initWithShort: (short)value +- (id) initWithShort: (signed short)value { NSDeallocateObject(self); if (value <= GS_SMALL && value >= -GS_SMALL) @@ -742,7 +742,7 @@ static Class doubleNumberClass; } case 1: { - char oData; + signed char oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -756,7 +756,7 @@ static Class doubleNumberClass; } case 3: { - short oData; + signed short oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -770,7 +770,7 @@ static Class doubleNumberClass; } case 5: { - int oData; + signed int oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -784,7 +784,7 @@ static Class doubleNumberClass; } case 7: { - long oData; + signed long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -798,7 +798,7 @@ static Class doubleNumberClass; } case 9: { - long long oData; + signed long long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -832,7 +832,7 @@ static Class doubleNumberClass; return 0; } -- (char) charValue +- (signed char) charValue { if (fastClass(self) == abstractClass) [NSException raise: NSInternalInconsistencyException @@ -852,7 +852,7 @@ static Class doubleNumberClass; } case 1: { - char oData; + signed char oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -866,7 +866,7 @@ static Class doubleNumberClass; } case 3: { - short oData; + signed short oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -880,7 +880,7 @@ static Class doubleNumberClass; } case 5: { - int oData; + signed int oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -894,7 +894,7 @@ static Class doubleNumberClass; } case 7: { - long oData; + signed long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -908,7 +908,7 @@ static Class doubleNumberClass; } case 9: { - long long oData; + signed long long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -962,7 +962,7 @@ static Class doubleNumberClass; } case 1: { - char oData; + signed char oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -976,7 +976,7 @@ static Class doubleNumberClass; } case 3: { - short oData; + signed short oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -990,7 +990,7 @@ static Class doubleNumberClass; } case 5: { - int oData; + signed int oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1004,7 +1004,7 @@ static Class doubleNumberClass; } case 7: { - long oData; + signed long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1018,7 +1018,7 @@ static Class doubleNumberClass; } case 9: { - long long oData; + signed long long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1072,7 +1072,7 @@ static Class doubleNumberClass; } case 1: { - char oData; + signed char oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1086,7 +1086,7 @@ static Class doubleNumberClass; } case 3: { - short oData; + signed short oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1100,7 +1100,7 @@ static Class doubleNumberClass; } case 5: { - int oData; + signed int oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1114,7 +1114,7 @@ static Class doubleNumberClass; } case 7: { - long oData; + signed long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1128,7 +1128,7 @@ static Class doubleNumberClass; } case 9: { - long long oData; + signed long long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1162,7 +1162,7 @@ static Class doubleNumberClass; return 0; } -- (int) intValue +- (signed int) intValue { if (fastClass(self) == abstractClass) [NSException raise: NSInternalInconsistencyException @@ -1182,7 +1182,7 @@ static Class doubleNumberClass; } case 1: { - char oData; + signed char oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1196,7 +1196,7 @@ static Class doubleNumberClass; } case 3: { - short oData; + signed short oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1210,7 +1210,7 @@ static Class doubleNumberClass; } case 5: { - int oData; + signed int oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1224,7 +1224,7 @@ static Class doubleNumberClass; } case 7: { - long oData; + signed long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1238,7 +1238,7 @@ static Class doubleNumberClass; } case 9: { - long long oData; + signed long long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1272,7 +1272,7 @@ static Class doubleNumberClass; return 0; } -- (long long) longLongValue +- (signed long long) longLongValue { if (fastClass(self) == abstractClass) [NSException raise: NSInternalInconsistencyException @@ -1292,7 +1292,7 @@ static Class doubleNumberClass; } case 1: { - char oData; + signed char oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1306,7 +1306,7 @@ static Class doubleNumberClass; } case 3: { - short oData; + signed short oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1320,7 +1320,7 @@ static Class doubleNumberClass; } case 5: { - int oData; + signed int oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1334,7 +1334,7 @@ static Class doubleNumberClass; } case 7: { - long oData; + signed long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1348,7 +1348,7 @@ static Class doubleNumberClass; } case 9: { - long long oData; + signed long long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1382,7 +1382,7 @@ static Class doubleNumberClass; return 0; } -- (long) longValue +- (signed long) longValue { if (fastClass(self) == abstractClass) [NSException raise: NSInternalInconsistencyException @@ -1402,7 +1402,7 @@ static Class doubleNumberClass; } case 1: { - char oData; + signed char oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1416,7 +1416,7 @@ static Class doubleNumberClass; } case 3: { - short oData; + signed short oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1430,7 +1430,7 @@ static Class doubleNumberClass; } case 5: { - int oData; + signed int oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1444,7 +1444,7 @@ static Class doubleNumberClass; } case 7: { - long oData; + signed long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1458,7 +1458,7 @@ static Class doubleNumberClass; } case 9: { - long long oData; + signed long long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1492,7 +1492,7 @@ static Class doubleNumberClass; return 0; } -- (short) shortValue +- (signed short) shortValue { if (fastClass(self) == abstractClass) [NSException raise: NSInternalInconsistencyException @@ -1512,7 +1512,7 @@ static Class doubleNumberClass; } case 1: { - char oData; + signed char oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1526,7 +1526,7 @@ static Class doubleNumberClass; } case 3: { - short oData; + signed short oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1540,7 +1540,7 @@ static Class doubleNumberClass; } case 5: { - int oData; + signed int oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1554,7 +1554,7 @@ static Class doubleNumberClass; } case 7: { - long oData; + signed long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1568,7 +1568,7 @@ static Class doubleNumberClass; } case 9: { - long long oData; + signed long long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1627,7 +1627,7 @@ static Class doubleNumberClass; } case 1: { - char oData; + signed char oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1641,7 +1641,7 @@ static Class doubleNumberClass; } case 3: { - short oData; + signed short oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1655,7 +1655,7 @@ static Class doubleNumberClass; } case 5: { - int oData; + signed int oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1669,7 +1669,7 @@ static Class doubleNumberClass; } case 7: { - long oData; + signed long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1683,7 +1683,7 @@ static Class doubleNumberClass; } case 9: { - long long oData; + signed long long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1737,7 +1737,7 @@ static Class doubleNumberClass; } case 1: { - char oData; + signed char oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1751,7 +1751,7 @@ static Class doubleNumberClass; } case 3: { - short oData; + signed short oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1765,7 +1765,7 @@ static Class doubleNumberClass; } case 5: { - int oData; + signed int oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1779,7 +1779,7 @@ static Class doubleNumberClass; } case 7: { - long oData; + signed long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1793,7 +1793,7 @@ static Class doubleNumberClass; } case 9: { - long long oData; + signed long long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1847,7 +1847,7 @@ static Class doubleNumberClass; } case 1: { - char oData; + signed char oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1861,7 +1861,7 @@ static Class doubleNumberClass; } case 3: { - short oData; + signed short oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1875,7 +1875,7 @@ static Class doubleNumberClass; } case 5: { - int oData; + signed int oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1889,7 +1889,7 @@ static Class doubleNumberClass; } case 7: { - long oData; + signed long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1903,7 +1903,7 @@ static Class doubleNumberClass; } case 9: { - long long oData; + signed long long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1957,7 +1957,7 @@ static Class doubleNumberClass; } case 1: { - char oData; + signed char oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1971,7 +1971,7 @@ static Class doubleNumberClass; } case 3: { - short oData; + signed short oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1985,7 +1985,7 @@ static Class doubleNumberClass; } case 5: { - int oData; + signed int oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -1999,7 +1999,7 @@ static Class doubleNumberClass; } case 7: { - long oData; + signed long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -2013,7 +2013,7 @@ static Class doubleNumberClass; } case 9: { - long long oData; + signed long long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -2067,7 +2067,7 @@ static Class doubleNumberClass; } case 1: { - char oData; + signed char oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -2081,7 +2081,7 @@ static Class doubleNumberClass; } case 3: { - short oData; + signed short oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -2095,7 +2095,7 @@ static Class doubleNumberClass; } case 5: { - int oData; + signed int oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -2109,7 +2109,7 @@ static Class doubleNumberClass; } case 7: { - long oData; + signed long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -2123,7 +2123,7 @@ static Class doubleNumberClass; } case 9: { - long long oData; + signed long long oData; (*(info->getValue))(self, @selector(getValue:), &oData); return oData; @@ -2159,23 +2159,35 @@ static Class doubleNumberClass; - (NSComparisonResult) compare: (NSNumber*)other { - double otherValue; - double myValue; - - myValue = [self doubleValue]; - otherValue = [other doubleValue]; - - if (myValue == otherValue) + if (other == self) { return NSOrderedSame; } - else if (myValue < otherValue) + else if (other == nil) { - return NSOrderedAscending; + [NSException raise: NSInvalidArgumentException + format: @"nil argument for compare:"]; } else { - return NSOrderedDescending; + double otherValue; + double myValue; + + myValue = [self doubleValue]; + otherValue = [other doubleValue]; + + if (myValue == otherValue) + { + return NSOrderedSame; + } + else if (myValue < otherValue) + { + return NSOrderedAscending; + } + else + { + return NSOrderedDescending; + } } } @@ -2203,18 +2215,24 @@ static Class doubleNumberClass; return hash; } -- (BOOL) isEqual: o +- (BOOL) isEqual: (id)o { if (o == self) { return YES; } - if (o != nil && fastIsInstance(o) - && fastInstanceIsKindOfClass(o, abstractClass)) + else if (o == nil) + { + return NO; + } + else if (fastIsInstance(o) && fastInstanceIsKindOfClass(o, abstractClass)) { return [self isEqualToNumber: (NSNumber*)o]; } - return [super isEqual: o]; + else + { + return [super isEqual: o]; + } } - (BOOL) isEqualToNumber: (NSNumber*)o @@ -2223,7 +2241,11 @@ static Class doubleNumberClass; { return YES; } - if ([self compare: o] == NSOrderedSame) + else if (o == nil) + { + return NO; + } + else if ([self compare: o] == NSOrderedSame) { return YES; } diff --git a/Source/NSObject.m b/Source/NSObject.m index 4bd5d426c..b82db2d61 100644 --- a/Source/NSObject.m +++ b/Source/NSObject.m @@ -1332,16 +1332,31 @@ static BOOL deallocNotifications = NO; double_release_check_enabled = enable; } -- (int) compare: (id)anotherObject; +- (int) compare: (id)anotherObject { - if ([self isEqual:anotherObject]) - return 0; + if (anotherObject == self) + { + return NSOrderedSame; + } + if (anotherObject == nil) + { + [NSException raise: NSInvalidArgumentException + format: @"nil argument for compare:"]; + } + if ([self isEqual: anotherObject]) + { + return NSOrderedSame; + } // Ordering objects by their address is pretty useless, // so subclasses should override this is some useful way. - else if (self > anotherObject) - return 1; + if (self > anotherObject) + { + return NSOrderedDescending; + } else - return -1; + { + return NSOrderedAscending; + } } - (BOOL) isMetaClass diff --git a/Source/NSPort.m b/Source/NSPort.m index 34639ace4..723b51cc0 100644 --- a/Source/NSPort.m +++ b/Source/NSPort.m @@ -35,29 +35,33 @@ @implementation NSPort -Class _abstractClass; -Class _concreteClass; +Class NSPort_abstract_class; +Class NSPort_concrete_class; + (id) allocWithZone: (NSZone*)aZone { - if (self == _abstractClass) - return NSAllocateObject(_concreteClass, 0, aZone); + if (self == NSPort_abstract_class) + { + return NSAllocateObject(NSPort_concrete_class, 0, aZone); + } else - return [super allocWithZone: aZone]; + { + return NSAllocateObject(self, 0, aZone); + } } + (void) initialize { if (self == [NSPort class]) { - _abstractClass = self; - _concreteClass = [GSTcpPort class]; + NSPort_abstract_class = self; + NSPort_concrete_class = [GSTcpPort class]; } } + (NSPort*) port { - return AUTORELEASE([_concreteClass new]); + return AUTORELEASE([NSPort_concrete_class new]); } + (NSPort*) portWithMachPort: (int)machPort @@ -110,11 +114,20 @@ Class _concreteClass; */ - (void) invalidate { + NSAutoreleasePool *arp; + [[NSPortNameServer systemDefaultPortNameServer] removePort: self]; _is_valid = NO; + /* + * Use a local autorelease pool when invalidating so that we know that + * anything refering to this port during the invalidation process is + * released immediately. + */ + arp = [NSAutoreleasePool new]; [[NSNotificationCenter defaultCenter] postNotificationName: NSPortDidBecomeInvalidNotification object: self]; + [arp release]; } - (BOOL) isValid @@ -128,23 +141,27 @@ Class _concreteClass; return 0; } +- (id) retain +{ + return [super retain]; +} + +- (id) autorelease +{ + return [super autorelease]; +} + - (void) release { if (_is_valid && [self retainCount] == 1) { - NSAutoreleasePool *arp; - /* - * If the port is about to have a final release deallocate it - * we must invalidate it. Use a local autorelease pool when - * invalidating so that we know that anything refering to this - * port during the invalidation process is released immediately. - * Also - bracket with retain/release pair to prevent recursion. + * If the port is about to have a final release deallocate it + * we must invalidate it. + * Bracket with retain/release pair to prevent recursion. */ [super retain]; - arp = [NSAutoreleasePool new]; [self invalidate]; - [arp release]; [super release]; } [super release]; diff --git a/Source/NSPortCoder.m b/Source/NSPortCoder.m index 0de61f458..019ec9b74 100644 --- a/Source/NSPortCoder.m +++ b/Source/NSPortCoder.m @@ -1,4 +1,3 @@ -#if GS_NEW_DO /* Implementation of NSPortCoder object for remote messaging Copyright (C) 1997,2000 Free Software Foundation, Inc. @@ -75,8 +74,6 @@ #include -static BOOL debug_port_coder = NO; - typedef unsigned char uchar; #define PREFIX "GNUstep DO archive" @@ -141,6 +138,7 @@ typeToName2(char type) { switch (type & _GSC_MASK) { + case _GSC_CID: return "class (encoded as id)"; case _GSC_CLASS: return "class"; case _GSC_ID: return "object"; case _GSC_SEL: return "selector"; @@ -427,9 +425,12 @@ static IMP _xRefImp; /* Serialize a crossref. */ (*_dTagImp)(_src, dTagSel, &ainfo, 0, &_cursor); if (info != (ainfo & _GSC_MASK)) { - [NSException raise: NSInternalInconsistencyException - format: @"expected %s and got %s", - typeToName2(info), typeToName2(ainfo)]; + if (info != _GSC_ID || (ainfo & _GSC_MASK) != _GSC_CID) + { + [NSException raise: NSInternalInconsistencyException + format: @"expected %s and got %s", + typeToName2(info), typeToName2(ainfo)]; + } } for (i = 0; i < count; i++) @@ -473,84 +474,6 @@ static IMP _xRefImp; /* Serialize a crossref. */ return [_comp objectAtIndex: pos]; } -/* - * The [-decodeObject] method is implemented purely for performance - - * It duplicates the code for handling objects in the - * [-decodeValueOfObjCType:at:] method above, but differs in that the - * resulting object is autoreleased when it comes from this method. - */ -- (id) decodeObject -{ - unsigned char info; - unsigned xref; - id obj; - - (*_dTagImp)(_src, dTagSel, &info, &xref, &_cursor); - if ((info & _GSC_MASK) != _GSC_ID) - { - [NSException raise: NSInternalInconsistencyException - format: @"expected object and got %s", typeToName2(info)]; - } - - /* - * Special case - a zero crossref value is a nil pointer. - */ - if ((info & _GSC_SIZE) == 0) - { - return nil; - } - - if (info & _GSC_XREF) - { - if (xref >= GSIArrayCount(_objAry)) - { - [NSException raise: NSInternalInconsistencyException - format: @"object crossref missing - %d", - xref]; - } - obj = GSIArrayItemAtIndex(_objAry, xref).obj; - /* - * If it's a cross-reference, we don't need to autorelease it - * since we didn't create it. - */ - return obj; - } - else - { - Class c; - id rep; - - if (xref != GSIArrayCount(_objAry)) - { - [NSException raise: NSInternalInconsistencyException - format: @"extra object crossref - %d", - xref]; - } - (*_dValImp)(self, dValSel, @encode(Class), &c); - - obj = [c allocWithZone: _zone]; - GSIArrayAddItem(_objAry, (GSIArrayItem)obj); - - rep = [obj initWithCoder: self]; - if (rep != obj) - { - obj = rep; - GSIArraySetItemAtIndex(_objAry, (GSIArrayItem)obj, xref); - } - - rep = [obj awakeAfterUsingCoder: self]; - if (rep != obj) - { - obj = rep; - GSIArraySetItemAtIndex(_objAry, (GSIArrayItem)obj, xref); - } - /* - * A newly allocated object needs to be autoreleased. - */ - return AUTORELEASE(obj); - } -} - - (void) decodeValueOfObjCType: (const char*)type at: (void*)address { @@ -635,13 +558,62 @@ static IMP _xRefImp; /* Serialize a crossref. */ return; } + case _GSC_CID: + { + id obj; + + typeCheck(*type, _GSC_ID); + /* + * Special case - a zero crossref value size is a nil pointer. + */ + if ((info & _GSC_SIZE) == 0) + { + obj = nil; + } + else + { + if (info & _GSC_XREF) + { + if (xref >= GSIArrayCount(_objAry)) + { + [NSException raise: NSInternalInconsistencyException + format: @"object crossref missing - %d", + xref]; + } + obj = GSIArrayItemAtIndex(_objAry, xref).obj; + /* + * If it's a cross-reference, we need to retain it in + * order to give the appearance that it's actually a + * new object. + */ + IF_NO_GC(RETAIN(obj)); + } + else + { + if (xref != GSIArrayCount(_objAry)) + { + [NSException raise: NSInternalInconsistencyException + format: @"extra object crossref - %d", + xref]; + } + (*_dValImp)(self, dValSel, @encode(Class), &obj); + GSIArrayAddItem(_objAry, (GSIArrayItem)obj); + } + } + *(id*)address = obj; + return; + } + case _GSC_CLASS: { Class c; GSClassInfo *classInfo; Class dummy; - typeCheck(*type, _GSC_CLASS); + if (*type != _C_ID) + { + typeCheck(*type, _GSC_CLASS); + } /* * Special case - a zero crossref value size is a nil pointer. */ @@ -1209,14 +1181,6 @@ static IMP _xRefImp; /* Serialize a crossref. */ (*_eTagImp)(_dst, eTagSel, _GSC_ID | _GSC_XREF, _GSC_X_0); } } - else if (fastIsInstance(anObject) == NO) - { - /* - * If the object we have been given is actually a class, - * we encode it as a class instead. - */ - (*_eValImp)(self, eValSel, @encode(Class), &anObject); - } else { GSIMapNode node; @@ -1257,11 +1221,22 @@ static IMP _xRefImp; /* Serialize a crossref. */ } obj = [anObject replacementObjectForPortCoder: self]; - cls = [obj classForPortCoder]; - - (*_xRefImp)(_dst, xRefSel, _GSC_ID, node->value.uint); - (*_eValImp)(self, eValSel, @encode(Class), &cls); - [obj encodeWithCoder: self]; + if (fastIsInstance(obj) == NO) + { + /* + * If the object we have been given is actually a class, + * we encode it as a special case. + */ + (*_xRefImp)(_dst, xRefSel, _GSC_CID, node->value.uint); + (*_eValImp)(self, eValSel, @encode(Class), &obj); + } + else + { + cls = [obj classForPortCoder]; + (*_xRefImp)(_dst, xRefSel, _GSC_ID, node->value.uint); + (*_eValImp)(self, eValSel, @encode(Class), &cls); + [obj encodeWithCoder: self]; + } } else { @@ -1949,491 +1924,3 @@ static IMP _xRefImp; /* Serialize a crossref. */ @end -#else -/* Implementation of NSPortCoder object for remote messaging - Copyright (C) 1997 Free Software Foundation, Inc. - - This implementation for OPENSTEP conformance written by - Richard Frith-Macdonald - Created: August 1997 - - based on original code - - - Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. - - Written by: Andrew Kachites McCallum - Created: July 1994 - - 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 Library 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 Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DEFAULT_SIZE 256 - -#define PORT_CODER_FORMAT_VERSION ((((GNUSTEP_BASE_MAJOR_VERSION * 100) + \ - GNUSTEP_BASE_MINOR_VERSION) * 100) + GNUSTEP_BASE_SUBMINOR_VERSION) - -static BOOL debug_connected_coder = NO; - -/* - * The PortEncoder class is essentially the old ConnectedEncoder class - * with a name change. - * It uses the OPENSTEP method [-classForPortCoder] to ask an object - * what class to encode. - */ -@interface PortEncoder : Encoder -{ - NSConnection *connection; - unsigned sequence_number; - int identifier; - BOOL _is_by_copy; - BOOL _is_by_ref; -} - -+ newForWritingWithConnection: (NSConnection*)c - sequenceNumber: (int)n - identifier: (int)i; -- (void) dismiss; -- (NSConnection*) connection; -- (unsigned) sequenceNumber; -- (int) identifier; -@end - -@implementation PortEncoder - -- _initForWritingWithConnection: (NSConnection*)c - sequenceNumber: (int)n - identifier: (int)i -{ - OutPacket* packet = [[[(OutPort*)[c sendPort] outPacketClass] alloc] - initForSendingWithCapacity: DEFAULT_SIZE - replyInPort: [c receivePort]]; - [super initForWritingToStream: packet]; - [packet release]; - connection = c; - sequence_number = n; - identifier = i; - [self encodeValueOfCType: @encode(typeof(sequence_number)) - at: &sequence_number - withName: @"PortCoder sequence number"]; - [self encodeValueOfCType: @encode(typeof(identifier)) - at: &identifier - withName: @"PortCoder identifier"]; - return self; -} - -+ newForWritingWithConnection: (NSConnection*)c - sequenceNumber: (int)n - identifier: (int)i -{ - /* Export this method and not the -init... method because eventually - we may do some caching of old PortEncoder's to speed things up. */ - return [[self alloc] _initForWritingWithConnection: c - sequenceNumber: n - identifier: i]; -} - -- (void) dismiss -{ - id packet = [cstream stream]; - NS_DURING - { - [(OutPort*)[connection sendPort] sendPacket: packet - timeout: [connection requestTimeout]]; - } - NS_HANDLER - { - if (debug_connected_coder) - fprintf(stderr, "dismiss 0x%x: #=%d i=%d write failed - %s\n", - (unsigned)self, sequence_number, identifier, - [[localException reason] cString]); - if ([[connection sendPort] isValid]) - [[connection sendPort] invalidate]; - } - NS_ENDHANDLER - if (debug_connected_coder) - fprintf(stderr, "dismiss 0x%x: #=%d i=%d %d\n", - (unsigned)self, sequence_number, identifier, - [packet streamEofPosition]); - [self release]; -} - - -/* Access to ivars. */ - -- (int) identifier -{ - return identifier; -} - -- (NSConnection*) connection -{ - return connection; -} - -- (BOOL) isBycopy -{ - return _is_by_copy; -} - -- (BOOL) isByref -{ - return _is_by_ref; -} - -- (unsigned) sequenceNumber -{ - return sequence_number; -} - - -/* - * These three methods are called by Coder's designated object encoder when - * an object is to be sent over the wire with/without bycopy/byref. - * We make sure that if the object asks us whether it is to be sent bycopy - * or byref it is told the right thing. - */ -- (void) _doEncodeObject: anObj -{ - id obj; - Class cls; - - obj = [anObj replacementObjectForPortCoder: (NSPortCoder*)self]; - cls = [obj classForPortCoder]; - [self encodeClass: cls]; - [obj encodeWithCoder: (NSCoder*)self]; -} - -- (void) _doEncodeBycopyObject: anObj -{ - BOOL oldBycopy = _is_by_copy; - BOOL oldByref = _is_by_ref; - id obj; - Class cls; - - _is_by_copy = YES; - _is_by_ref = NO; - obj = [anObj replacementObjectForPortCoder: (NSPortCoder*)self]; - cls = [obj classForPortCoder]; - [self encodeClass: cls]; - [obj encodeWithCoder: (NSCoder*)self]; - _is_by_copy = oldBycopy; - _is_by_ref = oldByref; -} - -- (void) _doEncodeByrefObject: anObj -{ - BOOL oldBycopy = _is_by_copy; - BOOL oldByref = _is_by_ref; - id obj; - Class cls; - - _is_by_copy = NO; - _is_by_ref = YES; - obj = [anObj replacementObjectForPortCoder: (NSPortCoder*)self]; - cls = [obj classForPortCoder]; - [self encodeClass: cls]; - [obj encodeWithCoder: (NSCoder*)self]; - _is_by_copy = oldBycopy; - _is_by_ref = oldByref; -} - -- (void) writeSignature -{ - return; -} - -- (void) encodeDataObject: (NSData*)anObject -{ - unsigned l = [anObject length]; - - [self encodeValueOfObjCType: @encode(unsigned) at: &l]; - if (l) - { - const void *b = [anObject bytes]; - - [self encodeArrayOfObjCType: @encode(unsigned char) - count: l - at: b]; - } -} -@end - - - -/* - * The PortDecoder class is essentially the old ConnectedDecoder class - * with a name change. - */ -@interface PortDecoder : Decoder -{ - NSConnection *connection; - unsigned sequence_number; - int identifier; -} - -+ newDecodingWithPacket: (InPacket*)packet - connection: (NSConnection*)c; -+ newDecodingWithConnection: (NSConnection*)c - timeout: (int) timeout; -- (void) dismiss; -- (NSConnection*) connection; -- (unsigned) sequenceNumber; -- (int) identifier; -- (NSPort*) replyPort; -@end - -@implementation PortDecoder - -+ (void) readSignatureFromCStream: (id ) cs - getClassname: (char *) name - formatVersion: (int*) version -{ - const char *classname = class_get_class_name (self); - strcpy (name, classname); - *version = PORT_CODER_FORMAT_VERSION; -} - -+ newDecodingWithConnection: (NSConnection*)c - timeout: (int) timeout -{ - PortDecoder *cd; - id in_port; - id packet; - id reply_port; - - /* Try to get a packet. */ - in_port = [c receivePort]; - packet = [in_port receivePacketWithTimeout: timeout]; - if (!packet) - return nil; /* timeout */ - - /* Create the new PortDecoder */ - cd = [self newReadingFromStream: packet]; - [packet release]; - reply_port = [packet replyPort]; - cd->connection = [NSConnection newForInPort: in_port - outPort: reply_port - ancestorConnection: c]; - - /* Decode the PortDecoder's ivars. */ - [cd decodeValueOfCType: @encode(typeof(cd->sequence_number)) - at: &(cd->sequence_number) - withName: NULL]; - [cd decodeValueOfCType: @encode(typeof(cd->identifier)) - at: &(cd->identifier) - withName: NULL]; - - if (debug_connected_coder) - fprintf(stderr, "newDecoding #=%d id=%d\n", - cd->sequence_number, cd->identifier); - return cd; -} - -+ newDecodingWithPacket: (InPacket*)packet - connection: (NSConnection*)c -{ - PortDecoder *cd; - id in_port; - id reply_port; - - in_port = [c receivePort]; - - /* Create the new PortDecoder */ - cd = [self newReadingFromStream: packet]; - [packet release]; - reply_port = [packet replyOutPort]; - cd->connection = [NSConnection newForInPort: in_port - outPort: reply_port - ancestorConnection: c]; - - /* Decode the PortDecoder's ivars. */ - [cd decodeValueOfCType: @encode(typeof(cd->sequence_number)) - at: &(cd->sequence_number) - withName: NULL]; - [cd decodeValueOfCType: @encode(typeof(cd->identifier)) - at: &(cd->identifier) - withName: NULL]; - - if (debug_connected_coder) - fprintf(stderr, "newDecoding #=%d id=%d\n", - cd->sequence_number, cd->identifier); - return cd; -} - - -/* Access to ivars. */ - -- (int) identifier -{ - return identifier; -} - -- (NSConnection*) connection -{ - return connection; -} - -- (NSPort*) replyPort -{ - return (NSPort*)[(id)[cstream stream] replyPort]; -} - -- (unsigned) sequenceNumber -{ - return sequence_number; -} - -- (void) dealloc -{ - [connection release]; - [super dealloc]; -} - -- (void) dismiss -{ - [self release]; -} - -- (NSData*) decodeDataObject -{ - unsigned l; - - [self decodeValueOfObjCType: @encode(unsigned) at: &l]; - if (l) - { - void *b; - NSData *d; - NSZone *z; - -#if GS_WITH_GC - z = GSAtomicMallocZone(); -#else - z = NSDefaultMallocZone(); -#endif - b = NSZoneMalloc(z, l); - [self decodeArrayOfObjCType: @encode(unsigned char) - count: l - at: b]; - d = [[NSData alloc] initWithBytesNoCopy: b length: l fromZone: z]; - IF_NO_GC(AUTORELEASE(d)); - return d; - } - return [NSData data]; -} - -@end - - - -/* - * The NSPortCoder class is an abstract class which is used to create - * instances of PortEncoder or PortDecoder depending on what factory - * method is used. - */ -@implementation NSPortCoder - -+ newDecodingWithConnection: (NSConnection*)c - timeout: (int) timeout -{ - return [PortDecoder newDecodingWithConnection:c timeout:timeout]; -} - -+ newDecodingWithPacket: (InPacket*)packet - connection: (NSConnection*)c -{ - return [PortDecoder newDecodingWithPacket:packet connection:c]; -} - -+ newForWritingWithConnection: (NSConnection*)c - sequenceNumber: (int)n - identifier: (int)i -{ - return [[PortEncoder alloc] _initForWritingWithConnection: c - sequenceNumber: n - identifier: i]; -} - -- allocWithZone: (NSZone*)z -{ - [self subclassResponsibility:_cmd]; - return nil; -} - -- (NSConnection*) connection -{ - [self subclassResponsibility:_cmd]; - return nil; -} - -- (NSPort*) decodePortObject -{ - [self subclassResponsibility:_cmd]; - return nil; -} - -- (void) dismiss -{ - [self subclassResponsibility:_cmd]; -} - -- (void) encodePortObject: (NSPort*)aPort -{ - [self subclassResponsibility:_cmd]; -} - -- (int) identifier -{ - [self subclassResponsibility:_cmd]; - return 0; -} - -- (BOOL) isBycopy -{ - [self subclassResponsibility:_cmd]; - return NO; -} - -- (BOOL) isByref -{ - [self subclassResponsibility:_cmd]; - return NO; -} - -- (NSPort*) replyPort -{ - [self subclassResponsibility:_cmd]; - return nil; -} - -- (unsigned) sequenceNumber -{ - [self subclassResponsibility:_cmd]; - return 0; -} - -@end -#endif diff --git a/Source/NSPortNameServer.m b/Source/NSPortNameServer.m index ae597f451..da392e94b 100644 --- a/Source/NSPortNameServer.m +++ b/Source/NSPortNameServer.m @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include /* @@ -60,16 +60,12 @@ * to suppress warnings about using private methods. */ @class GSTcpPort; -@class TcpOutPort; @interface NSPort (Hack) -+ newForSendingToSockaddr: (struct sockaddr_in*)sockaddr - withAcceptedSocket: (int)sock - pollingInPort: (id)ip; - + (GSTcpPort*) portWithNumber: (gsu16)number onHost: (NSHost*)host forceAddress: (NSString*)addr listener: (BOOL)shouldListen; +- (gsu16) portNumber; @end /* @@ -345,17 +341,26 @@ typedef enum { } else { - NSHost *current = [NSHost currentHost]; + NSHost *local = [NSHost localHost]; NSHost *host = [NSHost hostWithName: hostname]; if (host == nil) { host = [NSHost hostWithAddress: hostname]; } - if ([current isEqual: host]) + if ([local isEqual: host]) { state = GSPC_LOPEN; } + else + { + NSHost *loopback = [NSHost hostWithAddress: @"127.0.0.1"]; + + if ([loopback isEqual: host]) + { + state = GSPC_LOPEN; + } + } } } @@ -525,11 +530,7 @@ typedef enum { #endif launchCmd = [NSString stringWithCString: make_gdomap_cmd(GNUSTEP_INSTALL_PREFIX)]; -#if GS_NEW_DO portClass = [GSTcpPort class]; -#else - portClass = [TcpOutPort class]; -#endif } } @@ -774,34 +775,7 @@ typedef enum { if (portNum) { - if (portClass == [TcpOutPort class]) - { - struct sockaddr_in sin; - NSPort *p; - unsigned short n; - - memset(&sin, '\0', sizeof(sin)); - sin.sin_family = AF_INET; - - /* - * The returned port is an unsigned int - so we have to - * convert to a short in network byte order (big endian). - */ - n = (unsigned short)portNum; - sin.sin_port = NSSwapHostShortToBig(n); - - /* - * The host addresses are given to us in network byte order - * so we just copy the address into place. - */ - sin.sin_addr = singleServer; - - p = [TcpOutPort newForSendingToSockaddr: &sin - withAcceptedSocket: 0 - pollingInPort: nil]; - return AUTORELEASE(p); - } - else if (portClass == [GSTcpPort class]) + if (portClass == [GSTcpPort class]) { NSString *addr; NSHost *host; @@ -886,7 +860,7 @@ typedef enum { if ([known count] == 0) { com = [GSPortCom new]; - [com startPortUnregistration: [(TcpInPort*)port portNumber] + [com startPortUnregistration: [port portNumber] withName: nil]; while ([limit timeIntervalSinceNow] > 0 && [com isActive] == YES) { @@ -905,7 +879,7 @@ typedef enum { } com = [GSPortCom new]; - [com startPortRegistration: [(TcpInPort*)port portNumber] + [com startPortRegistration: [port portNumber] withName: name]; while ([limit timeIntervalSinceNow] > 0 && [com isActive] == YES) { diff --git a/Source/NSProcessInfo.m b/Source/NSProcessInfo.m index 85031edac..979d2972b 100644 --- a/Source/NSProcessInfo.m +++ b/Source/NSProcessInfo.m @@ -477,8 +477,8 @@ _gnu_noobjc_free_vars(void) } #else /* !HAVE_PROC_FS || !HAVE_LOAD_METHOD */ -#ifdef __MINGW32__ -/* For Windows32API Library, we know the global variables */ +#ifdef __MINGW__ +/* For WindowsAPI Library, we know the global variables */ extern int __argc; extern char** __argv; extern char** _environ; @@ -505,9 +505,9 @@ int main(int argc, char *argv[], char *env[]) } #endif /* __MINGW__ */ -#ifdef __MS_WIN32__ +#ifdef __MS_WIN__ _MB_init_runtime(); -#endif /* __MS_WIN32__ */ +#endif /* __MS_WIN__ */ _gnu_process_args(argc, argv, env); @@ -515,7 +515,7 @@ int main(int argc, char *argv[], char *env[]) return gnustep_base_user_main(argc, argv, env); } #endif /* !GS_PASS_ARGUMENTS */ -#endif /* __MINGW32__ */ +#endif /* __MINGW__ */ #endif /* HAS_LOAD_METHOD && HAS_PROC_FS */ diff --git a/Source/NSSet.m b/Source/NSSet.m index 032e71997..2f5244f72 100644 --- a/Source/NSSet.m +++ b/Source/NSSet.m @@ -23,8 +23,10 @@ #include #include +#include #include #include +#include #include #include #include @@ -54,26 +56,6 @@ static Class NSMutableSet_concrete_class; } } -+ (void) _setConcreteClass: (Class)c -{ - NSSet_concrete_class = c; -} - -+ (void) _setMutableConcreteClass: (Class)c -{ - NSMutableSet_concrete_class = c; -} - -+ (Class) _concreteClass -{ - return NSSet_concrete_class; -} - -+ (Class) _mutableConcreteClass -{ - return NSMutableSet_concrete_class; -} - + (id) set { return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()] init]); @@ -118,8 +100,13 @@ static Class NSMutableSet_concrete_class; + (id) allocWithZone: (NSZone*)z { if (self == NSSet_abstract_class) - return NSAllocateObject(NSSet_concrete_class, 0, z); - return [super allocWithZone: z]; + { + return NSAllocateObject(NSSet_concrete_class, 0, z); + } + else + { + return NSAllocateObject(self, 0, z); + } } /* This is the designated initializer */ @@ -132,13 +119,37 @@ static Class NSMutableSet_concrete_class; - (id) initWithCoder: (NSCoder*)aCoder { - [self subclassResponsibility: _cmd]; - return nil; + unsigned count; + Class c = fastClass(self); + + if (c == NSSet_abstract_class) + { + RELEASE(self); + self = [NSSet_concrete_class allocWithZone: NSDefaultMallocZone()]; + return [self initWithCoder: aCoder]; + } + else if (c == NSMutableSet_abstract_class) + { + RELEASE(self); + self = [NSMutableSet_concrete_class allocWithZone: NSDefaultMallocZone()]; + return [self initWithCoder: aCoder]; + } + [aCoder decodeValueOfObjCType: @encode(unsigned) at: &count]; + { + id objs[count]; + unsigned i; + + for (i = 0; i < count; i++) + { + [aCoder decodeValueOfObjCType: @encode(id) at: &objs[i]]; + } + return [self initWithObjects: objs count: count]; + } } -- (void) encodeWithCoder: (NSCoder*)aCoder +- (Class) classForCoder { - [self subclassResponsibility: _cmd]; + return NSSet_abstract_class; } - (unsigned) count @@ -147,7 +158,20 @@ static Class NSMutableSet_concrete_class; return 0; } -- (id) member: anObject +- (void) encodeWithCoder: (NSCoder*)aCoder +{ + unsigned count = [self count]; + NSEnumerator *e = [self objectEnumerator]; + id o; + + [aCoder encodeValueOfObjCType: @encode(unsigned) at: &count]; + while ((o = [e nextObject]) != nil) + { + [aCoder encodeValueOfObjCType: @encode(id) at: &o]; + } +} + +- (id) member: (id)anObject { return [self subclassResponsibility: _cmd]; return 0; @@ -165,8 +189,7 @@ static Class NSMutableSet_concrete_class; - (id) mutableCopyWithZone: (NSZone*)z { - return [[[[self class] _mutableConcreteClass] allocWithZone: z] - initWithSet: self]; + return [[NSMutableSet_concrete_class allocWithZone: z] initWithSet: self]; } @end @@ -307,7 +330,12 @@ static Class NSMutableSet_concrete_class; } } -- (BOOL) containsObject: anObject +- (Class) classForCoder +{ + return NSSet_abstract_class; +} + +- (BOOL) containsObject: (id)anObject { return (([self member: anObject]) ? YES : NO); } @@ -395,7 +423,7 @@ static Class NSMutableSet_concrete_class; return YES; } -- (BOOL) isEqual: other +- (BOOL) isEqual: (id)other { if ([other isKindOfClass: [NSSet class]]) return [self isEqualToSet: other]; @@ -450,13 +478,18 @@ static Class NSMutableSet_concrete_class; + (id) allocWithZone: (NSZone*)z { if (self == NSMutableSet_abstract_class) - return NSAllocateObject(NSMutableSet_concrete_class, 0, z); - return [super allocWithZone: z]; + { + return NSAllocateObject(NSMutableSet_concrete_class, 0, z); + } + else + { + return NSAllocateObject(self, 0, z); + } } - (id) copyWithZone: (NSZone*)z { - return [[[[self class] _concreteClass] allocWithZone: z] initWithSet: self]; + return [[NSSet_concrete_class allocWithZone: z] initWithSet: self]; } /* This is the designated initializer */ @@ -465,12 +498,12 @@ static Class NSMutableSet_concrete_class; return [self subclassResponsibility: _cmd]; } -- (void) addObject: anObject +- (void) addObject: (id)anObject { [self subclassResponsibility: _cmd]; } -- (void) removeObject: anObject +- (void) removeObject: (id)anObject { [self subclassResponsibility: _cmd]; } @@ -479,13 +512,14 @@ static Class NSMutableSet_concrete_class; @implementation NSMutableSetNonCore -/* Override superclass's designated initializer */ -- initWithObjects: (id*)objects - count: (unsigned)count +- (id) initWithObjects: (id*)objects + count: (unsigned)count { [self initWithCapacity: count]; while (count--) - [self addObject: objects[count]]; + { + [self addObject: objects[count]]; + } return self; } @@ -494,35 +528,58 @@ static Class NSMutableSet_concrete_class; unsigned i, c = [array count]; for (i = 0; i < c; i++) - [self addObject: [array objectAtIndex: i]]; + { + [self addObject: [array objectAtIndex: i]]; + } } - (void) unionSet: (NSSet*) other { - id keys = [other objectEnumerator]; - id key; + if (other != self) + { + id keys = [other objectEnumerator]; + id key; - while ((key = [keys nextObject])) - [self addObject: key]; + while ((key = [keys nextObject])) + { + [self addObject: key]; + } + } } - (void) intersectSet: (NSSet*) other { - id keys = [self objectEnumerator]; - id key; + if (other != self) + { + id keys = [self objectEnumerator]; + id key; - while ((key = [keys nextObject])) - if ([other containsObject: key] == NO) - [self removeObject: key]; + while ((key = [keys nextObject])) + { + if ([other containsObject: key] == NO) + { + [self removeObject: key]; + } + } + } } - (void) minusSet: (NSSet*) other { - id keys = [other objectEnumerator]; - id key; + if (other == self) + { + [self removeAllObjects]; + } + else + { + id keys = [other objectEnumerator]; + id key; - while ((key = [keys nextObject])) - [self removeObject: key]; + while ((key = [keys nextObject])) + { + [self removeObject: key]; + } + } } - (void) removeAllObjects diff --git a/Source/NSString.m b/Source/NSString.m index 8864c3203..952515ffd 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include @@ -99,7 +98,12 @@ static NSStringEncoding _availableEncodings[] = { 0 }; -static Class NSString_class; /* For speed */ +/* + * Cache classes for speed. + */ +static Class NSData_class; +static Class NSString_class; +static Class NSMutableString_class; /* * Include sequence handling code with instructions to generate search @@ -173,47 +177,6 @@ static Class NSMutableString_c_concrete_class; static NSStringEncoding _DefaultStringEncoding; - -+ (void) _setConcreteClass: (Class)c -{ - NSString_concrete_class = c; -} - -+ (void) _setConcreteCClass: (Class)c -{ - NSString_c_concrete_class = c; -} - -+ (void) _setMutableConcreteClass: (Class)c -{ - NSMutableString_concrete_class = c; -} - -+ (void) _setMutableConcreteCClass: (Class)c -{ - NSMutableString_c_concrete_class = c; -} - -+ (Class) _concreteClass -{ - return NSString_concrete_class; -} - -+ (Class) _concreteCClass -{ - return NSString_c_concrete_class; -} - -+ (Class) _mutableConcreteClass -{ - return NSMutableString_concrete_class; -} - -+ (Class) _mutableConcreteCClass -{ - return NSMutableString_c_concrete_class; -} - #if HAVE_REGISTER_PRINTF_FUNCTION #include #include @@ -279,6 +242,8 @@ handle_printf_atsign (FILE *stream, { _DefaultStringEncoding = GetDefEncoding(); NSString_class = self; + NSMutableString_class = [NSMutableString class]; + NSData_class = [NSData class]; NSString_concrete_class = [NSGString class]; NSString_c_concrete_class = [NSGCString class]; NSMutableString_concrete_class = [NSGMutableString class]; @@ -300,9 +265,14 @@ handle_printf_atsign (FILE *stream, + (id) allocWithZone: (NSZone*)z { - if ([self class] == [NSString class]) - return NSAllocateObject ([self _concreteClass], 0, z); - return [super allocWithZone: z]; + if (self == NSString_class) + { + return NSAllocateObject (NSString_concrete_class, 0, z); + } + else + { + return NSAllocateObject (self, 0, z); + } } // Creating Temporary Strings @@ -861,9 +831,9 @@ handle_printf_atsign (FILE *stream, - (id) initWithContentsOfFile: (NSString*)path { - NSStringEncoding enc; - id d = [NSData dataWithContentsOfFile: path]; - const unsigned char *test; + NSStringEncoding enc; + NSData *d = [NSData_class dataWithContentsOfFile: path]; + const unsigned char *test; if (d == nil) return nil; @@ -912,12 +882,14 @@ handle_printf_atsign (FILE *stream, { unsigned l = [self length]; unsigned i; + unichar (*caiImp)(NSString*, SEL, unsigned); GS_RANGE_CHECK(aRange, l); + caiImp = (unichar (*)())[self methodForSelector: caiSel]; for (i = 0; i < aRange.length; i++) { - buffer[i] = [self characterAtIndex: aRange.location+i]; + buffer[i] = (*caiImp)(self, caiSel, aRange.location + i); } } @@ -1124,15 +1096,17 @@ handle_printf_atsign (FILE *stream, unsigned start; unsigned end; unsigned length = [self length]; + unichar (*caiImp)(NSString*, SEL, unsigned); if (anIndex >= length) [NSException raise: NSRangeException format:@"Invalid location."]; + caiImp = (unichar (*)())[self methodForSelector: caiSel]; start = anIndex; - while (uni_isnonsp([self characterAtIndex: start]) && start > 0) + while (uni_isnonsp((*caiImp)(self, caiSel, start)) && start > 0) start--; end=start+1; if (end < length) - while ((end < length) && (uni_isnonsp([self characterAtIndex: end])) ) + while ((end < length) && (uni_isnonsp((*caiImp)(self, caiSel, end))) ) end++; return NSMakeRange(start, end-start); } @@ -1398,17 +1372,19 @@ handle_printf_atsign (FILE *stream, { unichar thischar; unsigned start, end, len; + unichar (*caiImp)(NSString*, SEL, unsigned); len = [self length]; GS_RANGE_CHECK(aRange, len); + caiImp = (unichar (*)())[self methodForSelector: caiSel]; start = aRange.location; if (startIndex) { - if (start==0) + if (start == 0) { - *startIndex=0; + *startIndex = 0; } else { @@ -1417,8 +1393,8 @@ handle_printf_atsign (FILE *stream, { BOOL done = NO; - thischar = [self characterAtIndex: start]; - switch(thischar) + thischar = (*caiImp)(self, caiSel, start); + switch (thischar) { case (unichar)0x000A: case (unichar)0x000D: @@ -1435,8 +1411,8 @@ handle_printf_atsign (FILE *stream, }; if (start == 0) { - thischar = [self characterAtIndex: start]; - switch(thischar) + thischar = (*caiImp)(self, caiSel, start); + switch (thischar) { case (unichar)0x000A: case (unichar)0x000D: @@ -1456,12 +1432,12 @@ handle_printf_atsign (FILE *stream, if (lineEndIndex || contentsEndIndex) { - end=aRange.location+aRange.length; - while (endlength = aRange.length - maxLength; } } + caiImp = (unichar (*)())[self methodForSelector: caiSel]; count = 0; while (count < len) { - buffer[count]=unitochar([self characterAtIndex: aRange.location + count]); + buffer[count]=unitochar((*caiImp)(self, caiSel, aRange.location + count)); count++; } buffer[len] = '\0'; @@ -1739,10 +1736,9 @@ handle_printf_atsign (FILE *stream, ourbundle = [NSBundle bundleWithPath: rootPath]; ourname = GetEncodingName(encoding); - return [ourbundle - localizedStringForKey: ourname - value: ourname - table: nil]; + return [ourbundle localizedStringForKey: ourname + value: ourname + table: nil]; } - (BOOL) canBeConvertedToEncoding: (NSStringEncoding)encoding @@ -1760,29 +1756,33 @@ handle_printf_atsign (FILE *stream, - (NSData*) dataUsingEncoding: (NSStringEncoding)encoding allowLossyConversion: (BOOL)flag { - int count=0; - int len = [self length]; + unsigned int count = 0; + unsigned int len = [self length]; + unichar (*caiImp)(NSString*, SEL, unsigned); if (len == 0) - return [NSData data]; - - if ((encoding==NSASCIIStringEncoding) - || (encoding==NSISOLatin1StringEncoding) - || (encoding==NSISOLatin2StringEncoding) - || (encoding==NSNEXTSTEPStringEncoding) - || (encoding==NSNonLossyASCIIStringEncoding) - || (encoding==NSSymbolStringEncoding) - || (encoding==NSCyrillicStringEncoding)) { - char t; - unsigned char *buff; + return [NSData_class data]; + } + + caiImp = (unichar (*)())[self methodForSelector: caiSel]; + if ((encoding == NSASCIIStringEncoding) + || (encoding == NSISOLatin1StringEncoding) + || (encoding == NSISOLatin2StringEncoding) + || (encoding == NSNEXTSTEPStringEncoding) + || (encoding == NSNonLossyASCIIStringEncoding) + || (encoding == NSSymbolStringEncoding) + || (encoding == NSCyrillicStringEncoding)) + { + char t; + unsigned char *buff; buff = (unsigned char*)NSZoneMalloc(NSDefaultMallocZone(), len+1); if (!flag) { for (count = 0; count < len; count++) { - t = encode_unitochar([self characterAtIndex: count], encoding); + t = encode_unitochar((*caiImp)(self, caiSel, count), encoding); if (t) { buff[count] = t; @@ -1798,7 +1798,7 @@ handle_printf_atsign (FILE *stream, { for (count = 0; count < len; count++) { - t = encode_unitochar([self characterAtIndex: count], encoding); + t = encode_unitochar((*caiImp)(self, caiSel, count), encoding); if (t) { buff[count] = t; @@ -1814,17 +1814,19 @@ handle_printf_atsign (FILE *stream, } } buff[count] = '\0'; - return [NSData dataWithBytesNoCopy: buff length: count]; + return [NSData_class dataWithBytesNoCopy: buff length: count]; } else if (encoding == NSUnicodeStringEncoding) { - unichar *buff; + unichar *buff; buff = (unichar*)NSZoneMalloc(NSDefaultMallocZone(), 2*len+2); - buff[0]=0xFEFF; + buff[0] = 0xFEFF; for (count = 0; count < len; count++) - buff[count+1] = [self characterAtIndex: count]; - return [NSData dataWithBytesNoCopy: buff length: 2*len+2]; + { + buff[count+1] = (*caiImp)(self, caiSel, count); + } + return [NSData_class dataWithBytesNoCopy: buff length: 2*len+2]; } else /* UTF8 or EUC */ { @@ -1962,7 +1964,7 @@ handle_printf_atsign (FILE *stream, else { NSRange range2 = [self rangeOfCharacterFromSet: pathSeps() - options: NSBackwardsSearch]; + options: NSBackwardsSearch]; if (range2.length > 0 && range.location < range2.location) substring = nil; else @@ -2019,7 +2021,7 @@ handle_printf_atsign (FILE *stream, aLength--; } } - return [NSString stringWithCharacters: buf length: length]; + return [NSString_class stringWithCharacters: buf length: length]; } /* Returns a new string with the path extension given in aString @@ -2071,8 +2073,8 @@ handle_printf_atsign (FILE *stream, - (NSString*) stringByExpandingTildeInPath { - NSString *homedir; - NSRange first_slash_range; + NSString *homedir; + NSRange first_slash_range; if ([self length] == 0) return AUTORELEASE([self copy]); @@ -2101,9 +2103,8 @@ handle_printf_atsign (FILE *stream, homedir = NSHomeDirectory (); } - return [NSString stringWithFormat: @"%@%@", - homedir, - [self substringFromIndex: first_slash_range.location]]; + return [NSString_class stringWithFormat: @"%@%@", homedir, + [self substringFromIndex: first_slash_range.location]]; } - (NSString*) stringByAbbreviatingWithTildeInPath @@ -2113,8 +2114,8 @@ handle_printf_atsign (FILE *stream, if (![self hasPrefix: homedir]) return AUTORELEASE([self copy]); - return [NSString stringWithFormat: @"~%c%@", (char)pathSepChar, - [self substringFromIndex: [homedir length] + 1]]; + return [NSString_class stringWithFormat: @"~%c%@", (char)pathSepChar, + [self substringFromIndex: [homedir length] + 1]]; } - (NSString*) stringByResolvingSymlinksInPath @@ -2275,9 +2276,11 @@ handle_printf_atsign (FILE *stream, { NSMutableString *s; NSRange r; + unichar (*caiImp)(NSString*, SEL, unsigned); /* Expand `~' in the path */ s = [[self stringByExpandingTildeInPath] mutableCopy]; + caiImp = (unichar (*)())[s methodForSelector: caiSel]; /* Remove `/private' */ if ([s hasPrefix: @"/private"]) @@ -2292,13 +2295,13 @@ handle_printf_atsign (FILE *stream, unsigned length = [s length]; if (r.location + r.length + 1 <= length - && pathSepMember([s characterAtIndex: r.location + 1]) == YES) + && pathSepMember((*caiImp)(s, caiSel, r.location + 1)) == YES) { [s deleteCharactersInRange: r]; } else if (r.location + r.length + 2 <= length - && [s characterAtIndex: r.location + 1] == (unichar)'.' - && pathSepMember([s characterAtIndex: r.location + 2]) == YES) + && (*caiImp)(s, caiSel, r.location + 1) == (unichar)'.' + && pathSepMember((*caiImp)(s, caiSel, r.location + 2)) == YES) { r.length++; [s deleteCharactersInRange: r]; @@ -2328,9 +2331,9 @@ handle_printf_atsign (FILE *stream, range: r]).length) { if (r.location + r.length + 3 <= [s length] - && [s characterAtIndex: r.location + 1] == (unichar)'.' - && [s characterAtIndex: r.location + 2] == (unichar)'.' - && pathSepMember([s characterAtIndex: r.location + 3]) == YES) + && (*caiImp)(s, caiSel, r.location + 1) == (unichar)'.' + && (*caiImp)(s, caiSel, r.location + 2) == (unichar)'.' + && pathSepMember((*caiImp)(s, caiSel, r.location + 3)) == YES) { if (r.location > 0) { @@ -2367,11 +2370,16 @@ handle_printf_atsign (FILE *stream, if (len > 0) { int count = 0; - unichar (*caiImp)() = (unichar (*)())[self methodForSelector: caiSel]; + unichar (*caiImp)(NSString*, SEL, unsigned); + caiImp = (unichar (*)())[self methodForSelector: caiSel]; while (count < len) - if (!uni_isnonsp((*caiImp)(self, caiSel, count++))) - blen++; + { + if (!uni_isnonsp((*caiImp)(self, caiSel, count++))) + { + blen++; + } + } } return blen; } @@ -2577,7 +2585,7 @@ handle_printf_atsign (FILE *stream, } *ptr++ = '"'; *ptr = '\0'; - [output appendString: [NSString stringWithCString: buf]]; + [output appendString: [NSString_class stringWithCString: buf]]; } } else @@ -2593,7 +2601,7 @@ handle_printf_atsign (FILE *stream, { if ([self isKindOfClass: [NSMutableString class]] || NSShouldRetainWithZone(self, zone) == NO) - return [[[[self class] _concreteClass] allocWithZone: zone] + return [[NSString_concrete_class allocWithZone: zone] initWithString: self]; else return RETAIN(self); @@ -2601,7 +2609,7 @@ handle_printf_atsign (FILE *stream, - (id) mutableCopyWithZone: (NSZone*)zone { - return [[[[self class] _mutableConcreteClass] allocWithZone: zone] + return [[NSMutableString_concrete_class allocWithZone: zone] initWithString: self]; } @@ -2700,9 +2708,14 @@ handle_printf_atsign (FILE *stream, + (id) allocWithZone: (NSZone*)z { - if ([self class] == [NSMutableString class]) - return NSAllocateObject([self _mutableConcreteClass], 0, z); - return [super allocWithZone: z]; + if (self == NSMutableString_class) + { + return NSAllocateObject(NSMutableString_concrete_class, 0, z); + } + else + { + return NSAllocateObject(self, 0, z); + } } // Creating Temporary Strings @@ -2893,29 +2906,41 @@ handle_printf_atsign (FILE *stream, { unsigned location = 0; unsigned length = [self length]; + unichar (*caiImp)(NSString*, SEL, unsigned); - while (location < length && isspace([self characterAtIndex: location])) - location++; - + caiImp = (unichar (*)())[self methodForSelector: caiSel]; + while (location < length && isspace((*caiImp)(self, caiSel, location))) + { + location++; + } if (location > 0) - [self deleteCharactersInRange: NSMakeRange(0,location)]; + { + [self deleteCharactersInRange: NSMakeRange(0,location)]; + } } - (void) trimTailSpaces { unsigned length = [self length]; - if (length) + if (length > 0) { unsigned location = length; + unichar (*caiImp)(NSString*, SEL, unsigned); + caiImp = (unichar (*)())[self methodForSelector: caiSel]; while (location > 0) - if (!isspace([self characterAtIndex: --location])) - break; - + { + if (!isspace((*caiImp)(self, caiSel, --location))) + { + break; + } + } if (location < length-1) - [self deleteCharactersInRange: NSMakeRange((location == 0) ? 0 - : location + 1, length - ((location == 0) ? 0 : location + 1))]; + { + [self deleteCharactersInRange: NSMakeRange((location == 0) ? 0 + : location + 1, length - ((location == 0) ? 0 : location + 1))]; + } } } diff --git a/Source/NSThread.m b/Source/NSThread.m index f89e7acdf..76f9d5b95 100644 --- a/Source/NSThread.m +++ b/Source/NSThread.m @@ -123,7 +123,18 @@ gnustep_base_thread_callback() */ + (NSThread*) currentThread { - return GSCurrentThread(); + if (entered_multi_threaded_state == NO) + { + /* + * The NSThread class has been initialized - so we will have a default + * thread set up. + */ + return defaultThread; + } + else + { + return (NSThread*)objc_thread_get_data(); + } } /* diff --git a/Source/NSTimer.m b/Source/NSTimer.m index 4facad861..bc467713f 100644 --- a/Source/NSTimer.m +++ b/Source/NSTimer.m @@ -49,7 +49,9 @@ static Class NSDate_class; repeats: (BOOL)f { if (seconds <= 0) - seconds = 0.001; + { + seconds = 0.001; + } _interval = seconds; _date = [[NSDate_class allocWithZone: [self zone]] initWithTimeIntervalSinceNow: seconds]; @@ -61,31 +63,31 @@ static Class NSDate_class; } + (NSTimer*) timerWithTimeInterval: (NSTimeInterval)ti - invocation: invocation + invocation: (NSInvocation*)invocation repeats: (BOOL)f { return AUTORELEASE([[self alloc] initWithTimeInterval: ti - targetOrInvocation: invocation - selector: NULL - userInfo: nil - repeats: f]); + targetOrInvocation: invocation + selector: NULL + userInfo: nil + repeats: f]); } + (NSTimer*) timerWithTimeInterval: (NSTimeInterval)ti - target: object + target: (id)object selector: (SEL)selector - userInfo: info + userInfo: (id)info repeats: (BOOL)f { return AUTORELEASE([[self alloc] initWithTimeInterval: ti - targetOrInvocation: object - selector: selector - userInfo: info - repeats: f]); + targetOrInvocation: object + selector: selector + userInfo: info + repeats: f]); } + (NSTimer*) scheduledTimerWithTimeInterval: (NSTimeInterval)ti - invocation: invocation + invocation: (NSInvocation*)invocation repeats: (BOOL)f { id t = [self timerWithTimeInterval: ti @@ -96,16 +98,16 @@ static Class NSDate_class; } + (NSTimer*) scheduledTimerWithTimeInterval: (NSTimeInterval)ti - target: object + target: (id)object selector: (SEL)selector - userInfo: info + userInfo: (id)info repeats: (BOOL)f { id t = [self timerWithTimeInterval: ti - target: object - selector: selector - userInfo: info - repeats: f]; + target: object + selector: selector + userInfo: info + repeats: f]; [[NSRunLoop currentRunLoop] addTimer: t forMode: NSDefaultRunLoopMode]; return t; } @@ -118,14 +120,20 @@ static Class NSDate_class; - (void) fire { - if (_selector) - [_target performSelector: _selector withObject: self]; + if (_selector == 0) + { + [(NSInvocation*)_target invoke]; + } else - [_target invoke]; + { + [_target performSelector: _selector withObject: self]; + } - if (!_repeats) - [self invalidate]; - else if (!_invalidated) + if (_repeats == NO) + { + [self invalidate]; + } + else if (_invalidated == NO) { NSTimeInterval now = GSTimeNow(); NSTimeInterval nxt = [_date timeIntervalSinceReferenceDate]; @@ -138,7 +146,9 @@ static Class NSDate_class; } #ifdef LOG_MISSED if (inc > 0) - NSLog(@"Missed %d timeouts at %f second intervals", inc, _interval); + { + NSLog(@"Missed %d timeouts at %f second intervals", inc, _interval); + } #endif RELEASE(_date); _date = [[NSDate_class allocWithZone: [self zone]] @@ -155,7 +165,10 @@ static Class NSDate_class; - (BOOL) isValid { - return !_invalidated; + if (_invalidated == NO) + return YES; + else + return NO; } - (NSDate*) fireDate @@ -175,7 +188,20 @@ static Class NSDate_class; - (NSComparisonResult) compare: (NSTimer*)anotherTimer { - return [_date compare: anotherTimer->_date]; + if (anotherTimer == self) + { + return NSOrderedSame; + } + else if (anotherTimer == nil) + { + [NSException raise: NSInvalidArgumentException + format: @"nil argument for compare:"]; + } + else + { + return [_date compare: anotherTimer->_date]; + } + return 0; } @end diff --git a/Source/NSUnarchiver.m b/Source/NSUnarchiver.m index f081fa799..3d5f4cac8 100644 --- a/Source/NSUnarchiver.m +++ b/Source/NSUnarchiver.m @@ -98,6 +98,7 @@ typeToName2(char type) { switch (type & _GSC_MASK) { + case _GSC_CID: return "class (encoded as id)"; case _GSC_CLASS: return "class"; case _GSC_ID: return "object"; case _GSC_SEL: return "selector"; @@ -455,9 +456,12 @@ mapClassName(NSUnarchiverObjectInfo *info) (*tagImp)(src, tagSel, &ainfo, 0, &cursor); if (info != (ainfo & _GSC_MASK)) { - [NSException raise: NSInternalInconsistencyException - format: @"expected %s and got %s", - typeToName2(info), typeToName2(ainfo)]; + if (info != _GSC_ID || (ainfo & _GSC_MASK) != _GSC_CID) + { + [NSException raise: NSInternalInconsistencyException + format: @"expected %s and got %s", + typeToName2(info), typeToName2(ainfo)]; + } } for (i = 0; i < count; i++) @@ -558,7 +562,10 @@ mapClassName(NSUnarchiverObjectInfo *info) NSUnarchiverObjectInfo *classInfo; Class dummy; - typeCheck(*type, _GSC_CLASS); + if (*type != _C_ID) + { + typeCheck(*type, _GSC_CLASS); + } /* * Special case - a zero crossref value size is a nil pointer. */ @@ -982,84 +989,6 @@ mapClassName(NSUnarchiverObjectInfo *info) return [NSData data]; } -/* - * The [-decodeObject] method is implemented purely for performance - - * It duplicates the code for handling objects in the - * [-decodeValueOfObjCType:at:] method above, but differs in that the - * resulting object is autoreleased when it comes from this method. - */ -- (id) decodeObject -{ - unsigned char info; - unsigned xref; - id obj; - - (*tagImp)(src, tagSel, &info, &xref, &cursor); - if ((info & _GSC_MASK) != _GSC_ID) - { - [NSException raise: NSInternalInconsistencyException - format: @"expected object and got %s", typeToName2(info)]; - } - - /* - * Special case - a zero crossref value is a nil pointer. - */ - if ((info & _GSC_SIZE) == 0) - { - return nil; - } - - if (info & _GSC_XREF) - { - if (xref >= GSIArrayCount(objMap)) - { - [NSException raise: NSInternalInconsistencyException - format: @"object crossref missing - %d", - xref]; - } - obj = GSIArrayItemAtIndex(objMap, xref).obj; - /* - * If it's a cross-reference, we don't need to autorelease it - * since we didn't create it. - */ - return obj; - } - else - { - Class c; - id rep; - - if (xref != GSIArrayCount(objMap)) - { - [NSException raise: NSInternalInconsistencyException - format: @"extra object crossref - %d", - xref]; - } - (*dValImp)(self, dValSel, @encode(Class), &c); - - obj = [c allocWithZone: zone]; - GSIArrayAddItem(objMap, (GSIArrayItem)obj); - - rep = [obj initWithCoder: self]; - if (rep != obj) - { - obj = rep; - GSIArraySetItemAtIndex(objMap, (GSIArrayItem)obj, xref); - } - - rep = [obj awakeAfterUsingCoder: self]; - if (rep != obj) - { - obj = rep; - GSIArraySetItemAtIndex(objMap, (GSIArrayItem)obj, xref); - } - /* - * A newly allocated object needs to be autoreleased. - */ - return AUTORELEASE(obj); - } -} - - (BOOL) isAtEnd { return (cursor >= [data length]); diff --git a/Source/NSValue.m b/Source/NSValue.m index 8987a1d21..9997db3f0 100644 --- a/Source/NSValue.m +++ b/Source/NSValue.m @@ -106,7 +106,7 @@ static Class sizeValueClass; // Allocating and Initializing -+ (NSValue *)value: (const void *)value ++ (NSValue*) value: (const void *)value withObjCType: (const char *)type { Class theClass = [self valueClassWithObjCType: type]; @@ -117,7 +117,7 @@ static Class sizeValueClass; return AUTORELEASE(theObj); } -+ (NSValue *)valueWithBytes: (const void *)value ++ (NSValue*) valueWithBytes: (const void *)value objCType: (const char *)type { Class theClass = [self valueClassWithObjCType: type]; @@ -128,7 +128,7 @@ static Class sizeValueClass; return AUTORELEASE(theObj); } -+ (NSValue *) valueWithNonretainedObject: (id)anObject ++ (NSValue*) valueWithNonretainedObject: (id)anObject { NSValue *theObj; @@ -137,7 +137,7 @@ static Class sizeValueClass; return AUTORELEASE(theObj); } -+ (NSValue *) valueWithPoint: (NSPoint)point ++ (NSValue*) valueWithPoint: (NSPoint)point { NSValue *theObj; @@ -146,7 +146,7 @@ static Class sizeValueClass; return AUTORELEASE(theObj); } -+ (NSValue *)valueWithPointer: (const void *)pointer ++ (NSValue*) valueWithPointer: (const void *)pointer { NSValue *theObj; @@ -155,7 +155,7 @@ static Class sizeValueClass; return AUTORELEASE(theObj); } -+ (NSValue *)valueWithRect: (NSRect)rect ++ (NSValue*) valueWithRect: (NSRect)rect { NSValue *theObj; @@ -164,7 +164,7 @@ static Class sizeValueClass; return AUTORELEASE(theObj); } -+ (NSValue *)valueWithSize: (NSSize)size ++ (NSValue*) valueWithSize: (NSSize)size { NSValue *theObj; @@ -173,7 +173,7 @@ static Class sizeValueClass; return AUTORELEASE(theObj); } -+ (NSValue*)valueFromString: (NSString *)string ++ (NSValue*) valueFromString: (NSString *)string { NSDictionary *dict = [string propertyList]; @@ -214,57 +214,57 @@ static Class sizeValueClass; // Accessing Data /* All the rest of these methods must be implemented by a subclass */ -- (void)getValue: (void *)value +- (void) getValue: (void *)value { [self subclassResponsibility: _cmd]; } -- (BOOL)isEqual: (id)other +- (BOOL) isEqual: (id)other { if ([other isKindOfClass: [self class]]) { - return [self isEqualToValue: other]; + return [self isEqualToValue: other]; } return NO; } -- (BOOL)isEqualToValue: (NSValue*)other +- (BOOL) isEqualToValue: (NSValue*)other { [self subclassResponsibility: _cmd]; return NO; } -- (const char *)objCType +- (const char *) objCType { [self subclassResponsibility: _cmd]; return 0; } -- (id)nonretainedObjectValue +- (id) nonretainedObjectValue { [self subclassResponsibility: _cmd]; return 0; } -- (void *)pointerValue +- (void *) pointerValue { [self subclassResponsibility: _cmd]; return 0; } -- (NSRect)rectValue +- (NSRect) rectValue { [self subclassResponsibility: _cmd]; return NSMakeRect(0,0,0,0); } -- (NSSize)sizeValue +- (NSSize) sizeValue { [self subclassResponsibility: _cmd]; return NSMakeSize(0,0); } -- (NSPoint)pointValue +- (NSPoint) pointValue { [self subclassResponsibility: _cmd]; return NSMakePoint(0,0); diff --git a/Source/NSZone.m b/Source/NSZone.m index 23a9f0fd3..6e3b974a8 100644 --- a/Source/NSZone.m +++ b/Source/NSZone.m @@ -1736,89 +1736,6 @@ static NSZone atomic_zone = }; NSZone* __nszone_private_hidden_atomic_zone = &atomic_zone; -NSZone* NSCreateZone (size_t start, size_t gran, BOOL canFree) -{ return __nszone_private_hidden_default_zone; } - -NSZone* NSDefaultMallocZone (void) -{ return __nszone_private_hidden_default_zone; } - -NSZone* GSAtomicMallocZone (void) -{ return __nszone_private_hidden_atomic_zone; } - -NSZone* NSZoneFromPointer (void *ptr) -{ return __nszone_private_hidden_default_zone; } - -void* NSZoneMalloc (NSZone *zone, size_t size) -{ - void *ptr; - - if (zone == GSAtomicMallocZone()) - ptr = (void*)GC_MALLOC_ATOMIC(size); - else - ptr = (void*)GC_MALLOC(size); - - if (ptr == 0) - ptr = GSOutOfMemory(size, YES); - return ptr; -} - -void* NSZoneCalloc (NSZone *zone, size_t elems, size_t bytes) -{ - size_t size = elems * bytes; - void *ptr; - - if (zone == __nszone_private_hidden_atomic_zone) - ptr = (void*)GC_MALLOC_ATOMIC(size); - else - ptr = (void*)GC_MALLOC(size); - - if (ptr == 0) - ptr = GSOutOfMemory(size, NO); - memset(ptr, '\0', size); - return ptr; -} - -void* NSZoneRealloc (NSZone *zone, void *ptr, size_t size) -{ - ptr = GC_REALLOC(ptr, size); - if (ptr == 0) - GSOutOfMemory(size, NO); - return ptr; -} - -void NSRecycleZone (NSZone *zone) -{ -} - -void NSZoneFree (NSZone *zone, void *ptr) -{ - GC_FREE(ptr); -} - -void NSSetZoneName (NSZone *zone, NSString *name) -{ -} - -NSString* NSZoneName (NSZone *zone) -{ - return nil; -} - -void* NSZoneMallocAtomic (NSZone *zone, size_t size) -{ - return NSZoneMalloc(GSAtomicMallocZone(), size); -} - -BOOL NSZoneCheck (NSZone *zone) -{ - return YES; -} - -struct NSZoneStats NSZoneStats (NSZone *zone) -{ - struct NSZoneStats stats = { 0 }; - return stats; -} #endif /* GS_WITH_GC */ diff --git a/Source/Unicode.m b/Source/Unicode.m index 32bf88d1f..8d3b39286 100644 --- a/Source/Unicode.m +++ b/Source/Unicode.m @@ -33,211 +33,203 @@ struct _ucc_ {unichar from; char to;}; #include "unicode/cop.h" #include "unicode/decomp.h" -#define FALSE 0 -#define TRUE 1 - typedef unsigned char unc; +static NSStringEncoding defEnc = GSUndefinedEncoding; unichar encode_chartouni(char c, NSStringEncoding enc) { /* All that I could find in Next documentation on NSNonLossyASCIIStringEncoding was << forthcoming >>. */ - if ((enc == NSNonLossyASCIIStringEncoding) - || (enc == NSASCIIStringEncoding) - || (enc == NSISOLatin1StringEncoding)) + switch (enc) { - return (unichar)((unc)c); - } - if ((enc == NSNEXTSTEPStringEncoding)) - { - if ((unc)c < Next_conv_base) + case NSNonLossyASCIIStringEncoding: + case NSASCIIStringEncoding: + case NSISOLatin1StringEncoding: return (unichar)((unc)c); - else - return(Next_char_to_uni_table[(unc)c - Next_conv_base]); - } - if ((enc == NSCyrillicStringEncoding)) - { - if ((unc)c < Cyrillic_conv_base) - return (unichar)((unc)c); - else - return(Cyrillic_char_to_uni_table[(unc)c - Cyrillic_conv_base]); - } - if ((enc == NSISOLatin2StringEncoding)) - { - if ((unc)c < Latin2_conv_base) - return (unichar)((unc)c); - else - return(Latin2_char_to_uni_table[(unc)c - Latin2_conv_base]); - } + + case NSNEXTSTEPStringEncoding: + if ((unc)c < Next_conv_base) + return (unichar)((unc)c); + else + return(Next_char_to_uni_table[(unc)c - Next_conv_base]); + + case NSCyrillicStringEncoding: + if ((unc)c < Cyrillic_conv_base) + return (unichar)((unc)c); + else + return(Cyrillic_char_to_uni_table[(unc)c - Cyrillic_conv_base]); + + case NSISOLatin2StringEncoding: + if ((unc)c < Latin2_conv_base) + return (unichar)((unc)c); + else + return(Latin2_char_to_uni_table[(unc)c - Latin2_conv_base]); #if 0 - if ((enc == NSSymbolStringEncoding)) - { - if ((unc)c < Symbol_conv_base) - return (unichar)((unc)c); - else - return(Symbol_char_to_uni_table[(unc)c - Symbol_conv_base]); - } + case NSSymbolStringEncoding: + if ((unc)c < Symbol_conv_base) + return (unichar)((unc)c); + else + return(Symbol_char_to_uni_table[(unc)c - Symbol_conv_base]); #endif - return 0; + default: + return 0; + } } char encode_unitochar(unichar u, NSStringEncoding enc) { - int res; - int i =0; + int res; + int i = 0; - if ((enc == NSNonLossyASCIIStringEncoding) - || (enc == NSASCIIStringEncoding)) + switch (enc) { - if (u <128) - return (char)u; - else - return 0; - } + case NSNonLossyASCIIStringEncoding: + case NSASCIIStringEncoding: + if (u < 128) + return (char)u; + else + return 0; - if ((enc == NSISOLatin1StringEncoding)) - { - if (u <256) - return (char)u; - else - return 0; - } + case NSISOLatin1StringEncoding: + if (u < 256) + return (char)u; + else + return 0; - if ((enc == NSNEXTSTEPStringEncoding)) - { - if (u <(unichar)Next_conv_base) - return (char)u; - else - { - while (((res = u-Next_uni_to_char_table[i++].from) > 0) - && (i < Next_uni_to_char_table_size)); - return res?0:Next_uni_to_char_table[--i].to; - } - } + case NSNEXTSTEPStringEncoding: + if (u < (unichar)Next_conv_base) + return (char)u; + else + { + while (((res = u - Next_uni_to_char_table[i++].from) > 0) + && (i < Next_uni_to_char_table_size)); + return res ? 0 : Next_uni_to_char_table[--i].to; + } - if ((enc == NSCyrillicStringEncoding)) - { - if (u <(unichar)Cyrillic_conv_base) - return (char)u; - else - { - while (((res = u-Cyrillic_uni_to_char_table[i++].from) > 0) - && (i < Cyrillic_uni_to_char_table_size)); - return res ? 0 : Cyrillic_uni_to_char_table[--i].to; - } - } + case NSCyrillicStringEncoding: + if (u < (unichar)Cyrillic_conv_base) + return (char)u; + else + { + while (((res = u - Cyrillic_uni_to_char_table[i++].from) > 0) + && (i < Cyrillic_uni_to_char_table_size)); + return res ? 0 : Cyrillic_uni_to_char_table[--i].to; + } - if ((enc == NSISOLatin2StringEncoding)) - { - if (u <(unichar)Latin2_conv_base) - return (char)u; - else - { - while (((res = u-Latin2_uni_to_char_table[i++].from) > 0) - && (i < Latin2_uni_to_char_table_size)); - return res ? 0 : Latin2_uni_to_char_table[--i].to; - } - } + case NSISOLatin2StringEncoding: + if (u < (unichar)Latin2_conv_base) + return (char)u; + else + { + while (((res = u - Latin2_uni_to_char_table[i++].from) > 0) + && (i < Latin2_uni_to_char_table_size)); + return res ? 0 : Latin2_uni_to_char_table[--i].to; + } #if 0 - if ((enc == NSSymbolStringEncoding)) - { - if (u <(unichar)Symbol_conv_base) - return (char)u; - else - { - while (((res = u-Symbol_uni_to_char_table[i++].from) > 0) - && (i < Symbol_uni_to_char_table_size)); - return res ? '*' : Symbol_uni_to_char_table[--i].to; - } - } + case NSSymbolStringEncoding: + if (u < (unichar)Symbol_conv_base) + return (char)u; + else + { + while (((res = u - Symbol_uni_to_char_table[i++].from) > 0) + && (i < Symbol_uni_to_char_table_size)); + return res ? '*' : Symbol_uni_to_char_table[--i].to; + } #endif - return 0; + default: + return 0; + } } unichar chartouni(char c) { - static NSStringEncoding enc = GSUndefinedEncoding; - - if (enc == 0) - enc = [NSString defaultCStringEncoding]; - return encode_chartouni(c, enc); + if (defEnc == GSUndefinedEncoding) + { + defEnc = [NSString defaultCStringEncoding]; + } + return encode_chartouni(c, defEnc); } char unitochar(unichar u) { - unc res; - static NSStringEncoding enc = GSUndefinedEncoding; + unc res; - if (enc == 0) - enc = [NSString defaultCStringEncoding]; - if ((res = encode_unitochar(u, enc))) - return res; - else - return '*'; -} - -int -strtoustr(unichar * u1,const char *s1,int size) -{ - int count; - - for (count = 0; (count < size) && (s1[count] != 0); count++) - u1[count] = chartouni(s1[count]); - return count; -} - -int -ustrtostr(char *s2,unichar *u1,int size) -{ - int count; - - for (count = 0; (count < size) && (u1[count] != (unichar)0); count++) - s2[count] = unitochar(u1[count]); - return(count); -} - -int -encode_strtoustr(unichar * u1,const char *s1,int size, NSStringEncoding enc) -{ - int count; - - for (count = 0; (count < size) && (s1[count] != 0); count++) - u1[count] = encode_chartouni(s1[count], enc); - return count; -} - -int -encode_ustrtostr(char *s2,unichar *u1,int size, NSStringEncoding enc) -{ - int count; - - for (count = 0; (count < size) && (u1[count] != (unichar)0); count++) - s2[count] = encode_unitochar(u1[count], enc); - return(count); -} - -/* Be carefull if you use this. Unicode arrays returned by - -getCharacters methods are not zero terminated */ -int -uslen (unichar *u) -{ - int len = 0; - - while (u[len] != 0) + if (defEnc == GSUndefinedEncoding) { - if (u[++len] == 0) - return len; - ++len; + defEnc = [NSString defaultCStringEncoding]; } - return len; + if ((res = encode_unitochar(u, defEnc))) + { + return res; + } + else + { + return '*'; + } +} + +int +strtoustr(unichar *u1, const char *s1, int size) +{ + int count; + + if (defEnc == GSUndefinedEncoding) + { + defEnc = [NSString defaultCStringEncoding]; + } + for (count = 0; (count < size) && (s1[count] != 0); count++) + { + u1[count] = encode_chartouni(s1[count], defEnc); + } + return count; +} + +int +ustrtostr(char *s2, unichar *u1, int size) +{ + int count; + + if (defEnc == GSUndefinedEncoding) + { + defEnc = [NSString defaultCStringEncoding]; + } + for (count = 0; (count < size) && (u1[count] != (unichar)0); count++) + { + s2[count] = encode_unitochar(u1[count], defEnc); + } + return count; +} + +int +encode_strtoustr(unichar *u1, const char *s1, int size, NSStringEncoding enc) +{ + int count; + + for (count = 0; (count < size) && (s1[count] != 0); count++) + { + u1[count] = encode_chartouni(s1[count], enc); + } + return count; +} + +int +encode_ustrtostr(char *s2, unichar *u1, int size, NSStringEncoding enc) +{ + int count; + + for (count = 0; (count < size) && (u1[count] != (unichar)0); count++) + { + s2[count] = encode_unitochar(u1[count], enc); + } + return count; } unichar @@ -263,29 +255,33 @@ uni_toupper(unichar ch) unsigned char uni_cop(unichar u) { - unichar count,first,last,comp; - BOOL notfound; + unichar count, first, last, comp; + BOOL notfound; first = 0; last = uni_cop_table_size; - notfound = TRUE; - count =0; + notfound = YES; + count = 0; if (u > (unichar)0x0080) // no nonspacing in ascii { while (notfound && (first <= last)) { - if (!(first == last)) + if (first != last) { count = (first + last) / 2; comp = uni_cop_table[count].code; if (comp < u) - first = count+1; + { + first = count+1; + } else - if (comp > u) - last = count-1; - else - notfound = FALSE; + { + if (comp > u) + last = count-1; + else + notfound = NO; + } } else /* first == last */ { @@ -303,25 +299,23 @@ uni_cop(unichar u) BOOL uni_isnonsp(unichar u) { -#define TRUE 1 -#define FALSE 0 // check is uni_cop good for this if (uni_cop(u)) - return TRUE; + return YES; else - return FALSE; + return NO; } unichar* uni_is_decomp(unichar u) { - unichar count,first,last,comp; - BOOL notfound; + unichar count, first, last, comp; + BOOL notfound; first = 0; last = uni_dec_table_size; - notfound = TRUE; - count =0; + notfound = YES; + count = 0; if (u > (unichar)0x0080) // no composites in ascii { @@ -334,10 +328,12 @@ uni_is_decomp(unichar u) if (comp < u) first = count+1; else - if (comp > u) - last = count-1; - else - notfound = FALSE; + { + if (comp > u) + last = count-1; + else + notfound = NO; + } } else /* first == last */ { diff --git a/Source/externs.m b/Source/externs.m index 0e15f1c7d..886b3328a 100644 --- a/Source/externs.m +++ b/Source/externs.m @@ -204,7 +204,7 @@ GSBuildStrings() = [[NSString alloc] initWithCString: "NSArgumentDomain"]; NSBundleDidLoadNotification = [[NSString alloc] initWithCString: "NSBundleDidLoadNotification"]; - NSCharacterConversionException + *(NSString**)&NSCharacterConversionException = [[NSString alloc] initWithCString: "NSCharacterConversionException"]; NSConnectionDidDieNotification = [[NSString alloc] initWithCString: "NSConnectionDidDieNotification"]; @@ -293,7 +293,7 @@ GSBuildStrings() = [[NSString alloc] initWithCString: "NSFileTypeUnknown"]; NSFormalName = [[NSString alloc] initWithCString: "NSFormalName"]; - NSGenericException + *(NSString**)&NSGenericException = [[NSString alloc] initWithCString: "NSGenericException"]; NSGlobalDomain = [[NSString alloc] initWithCString: "NSGlobalDomain"]; @@ -301,12 +301,12 @@ GSBuildStrings() = [[NSString alloc] initWithCString: "NSHourNameDesignations"]; NSInconsistentArchiveException = [[NSString alloc] initWithCString: "NSInconsistentArchiveException"]; - NSInternalInconsistencyException + *(NSString**)&NSInternalInconsistencyException = [[NSString alloc] initWithCString: "NSInternalInconsistencyException"]; NSInternationalCurrencyString = [[NSString alloc] initWithCString: "NSInternationalCurrencyString"]; - NSInvalidArgumentException + *(NSString**)&NSInvalidArgumentException = [[NSString alloc] initWithCString: "NSInvalidArgumentException"]; NSLanguageCode = [[NSString alloc] initWithCString: "NSLanguageCode"]; @@ -316,7 +316,7 @@ GSBuildStrings() = [[NSString alloc] initWithCString: "NSLaterTimeDesignations"]; NSLoadedClasses = [[NSString alloc] initWithCString: "NSLoadedClasses"]; - NSMallocException + *(NSString**)&NSMallocException = [[NSString alloc] initWithCString: "NSMallocException"]; NSMonthNameArray = [[NSString alloc] initWithCString: "NSMonthNameArray"]; @@ -335,7 +335,7 @@ GSBuildStrings() = [[NSString alloc] initWithCString: "NSPositiveCurrencyFormatString"]; NSPriorDayDesignations = [[NSString alloc] initWithCString: "NSPriorDayDesignations"]; - NSRangeException + *(NSString**)&NSRangeException = [[NSString alloc] initWithCString: "NSRangeException"]; NSRegistrationDomain = [[NSString alloc] initWithCString: "NSRegistrationDomain"]; diff --git a/Source/libgnustep-base.def b/Source/libgnustep-base.def index 2967a15dd..23c826ef5 100644 --- a/Source/libgnustep-base.def +++ b/Source/libgnustep-base.def @@ -27,16 +27,8 @@ ; LIBRARY libgnustep-base EXPORTS -__objc_class_name_BinaryCStream -__objc_class_name_CStream -__objc_class_name_Coder -__objc_class_name_Decoder -__objc_class_name_Encoder -__objc_class_name_GSClassInfo -__objc_class_name_GSPortCoder __objc_class_name_GSTcpHandle __objc_class_name_GSTcpPort -__objc_class_name_MemoryStream __objc_class_name_NSArchiver __objc_class_name_NSArray __objc_class_name_NSArrayEnumerator @@ -138,9 +130,8 @@ __objc_class_name_NSObject __objc_class_name__FastMallocBuffer __objc_class_name_NSPipe __objc_class_name_NSPort +__objc_class_name_GSClassInfo __objc_class_name_NSPortCoder -__objc_class_name_PortDecoder -__objc_class_name_PortEncoder __objc_class_name_NSPortMessage __objc_class_name_GSPortCom __objc_class_name_NSPortNameServer @@ -187,21 +178,4 @@ __objc_class_name_NSPointValue __objc_class_name_NSPointerValue __objc_class_name_NSRectValue __objc_class_name_NSSizeValue -__objc_class_name_InPacket -__objc_class_name_InPort -__objc_class_name_OutPacket -__objc_class_name_OutPort -__objc_class_name_Port -__objc_class_name_RawCStream -__objc_class_name_StdioStream -__objc_class_name_Stream -__objc_class_name_TcpInPacket -__objc_class_name_TcpInPort -__objc_class_name_TcpOutPacket -__objc_class_name_TcpOutPort -__objc_class_name_TcpPrefPacket -__objc_class_name_TextCStream -__objc_class_name_UdpInPacket -__objc_class_name_UdpInPort -__objc_class_name_UdpOutPort __objc_class_name_UnixFileHandle diff --git a/Testing/GNUmakefile b/Testing/GNUmakefile index 312562c92..aebbb5648 100644 --- a/Testing/GNUmakefile +++ b/Testing/GNUmakefile @@ -34,110 +34,87 @@ include ../config.mak # The tools to be compiled TEST_TOOL_NAME = \ -awake \ -basic \ -benchmark \ -containers \ -cstream \ -client \ -diningPhilosophers \ -fref \ -gstcpport-server \ -gstcpport-client \ -invocation \ -invocation_int \ -invocation_char \ -invocation_short \ -invocation_long \ -nsarray \ -nsarchiver \ -nsattributedstring \ -nsbundle \ -nscharacterset \ -nsdata \ -NSData-test \ -nsdate \ -nsdictionary \ -nsfilehandle \ -nshashtable \ -nshost \ -nsinvocation \ -nsmaptable \ -nsnotification \ -nsprocessinfo \ -nsscanner \ -nsset \ -nstask \ -nstimer \ -nstimezone \ -pipes \ -release \ -server \ -string \ -tcpport-server \ -tcpport-client \ -thread-except \ -values \ -create-abbrevs \ -create-regions + awake \ + basic \ + benchmark \ + containers \ + create-abbrevs \ + create-regions \ + diningPhilosophers \ + fref \ + gstcpport-client \ + gstcpport-server \ + nsarchiver \ + nsarray \ + nsattributedstring \ + nsbundle \ + nscharacterset \ + nsconnection \ + nsconnection_client \ + nsconnection_server \ + nsdata \ + nsdate \ + nsdictionary \ + nsfilehandle \ + nshashtable \ + nshost \ + nsinvocation \ + nsmaptable \ + nsnotification \ + nsprocessinfo \ + nsscanner \ + nsset \ + nstask \ + nstimer \ + nstimezone \ + release \ + string \ + thread-except \ + values \ + # The tool Objective-C source files to be compiled -testtool_OBJC_FILES = testtool.m -gstcpport-client_OBJC_FILES = gstcpport-client.m -gstcpport-server_OBJC_FILES = gstcpport-server.m +awake_OBJC_FILES = awake.m +basic_OBJC_FILES = basic.m benchmark_OBJC_FILES = benchmark.m containers_OBJC_FILES = containers.m -test01_OBJC_FILES = test01.m -test02_OBJC_FILES = test02.m -heap_OBJC_FILES = heap.m -randoms_OBJC_FILES = randoms.m -prepend_OBJC_FILES = prepend.m -pipes_OBJC_FILES = pipes.m -server_OBJC_FILES = server.m -client_OBJC_FILES = client.m -string_OBJC_FILES = string.m -values_OBJC_FILES = values.m +create-abbrevs_OBJC_FILES = create-abbrevs.m +create-regions_OBJC_FILES = create-regions.m +diningPhilosophers_OBJC_FILES = diningPhilosophers.m +fref_OBJC_FILES = fref.m +gstcpport-client_OBJC_FILES = gstcpport-client.m +gstcpport-server_OBJC_FILES = gstcpport-server.m +nsarchiver_OBJC_FILES = nsarchiver.m nsarray_OBJC_FILES = nsarray.m nsattributedstring_OBJC_FILES = nsattributedstring.m nsbundle_OBJC_FILES = nsbundle.m +nscharacterset_OBJC_FILES = nscharacterset.m +nsconnection_OBJC_FILES = nsconnection.m +nsconnection_client_OBJC_FILES = nsconnection_client.m +nsconnection_server_OBJC_FILES = nsconnection_server.m nsdata_OBJC_FILES = nsdata.m +nsdate_OBJC_FILES = nsdate.m nsdictionary_OBJC_FILES = nsdictionary.m nsfilehandle_OBJC_FILES = nsfilehandle.m +nshashtable_OBJC_FILES = nshashtable.m nshost_OBJC_FILES = nshost.m nsinvocation_OBJC_FILES = nsinvocation.m -nsset_OBJC_FILES = nsset.m -nsprocessinfo_OBJC_FILES = nsprocessinfo.m -nsarchiver_OBJC_FILES = nsarchiver.m -oldclient_OBJC_FILES = oldclient.m -oldserver_OBJC_FILES = oldserver.m -invocation_OBJC_FILES = invocation.m -invocation_int_OBJC_FILES = invocation_int.m -invocation_char_OBJC_FILES = invocation_char.m -invocation_short_OBJC_FILES = invocation_short.m -invocation_long_OBJC_FILES = invocation_long.m -invocation_float_OBJC_FILES = invocation_float.m -diningPhilosophers_OBJC_FILES = diningPhilosophers.m nsmaptable_OBJC_FILES = nsmaptable.m -nshashtable_OBJC_FILES = nshashtable.m -tcpport-server_OBJC_FILES = tcpport-server.m -tcpport-client_OBJC_FILES = tcpport-client.m nsnotification_OBJC_FILES = nsnotification.m +nsprocessinfo_OBJC_FILES = nsprocessinfo.m +nsscanner_OBJC_FILES = nsscanner.m +nsset_OBJC_FILES = nsset.m nstask_OBJC_FILES = nstask.m nstimer_OBJC_FILES = nstimer.m -coder_OBJC_FILES = coder.m -cstream_OBJC_FILES = cstream.m -fref_OBJC_FILES = fref.m -basic_OBJC_FILES = basic.m -release_OBJC_FILES = release.m -nsscanner_OBJC_FILES = nsscanner.m -nsdate_OBJC_FILES = nsdate.m -awake_OBJC_FILES = awake.m -thread-except_OBJC_FILES = thread-except.m -nscharacterset_OBJC_FILES = nscharacterset.m -NSData-test_OBJC_FILES = NSData-test.m nstimezone_OBJC_FILES = nstimezone.m -create-abbrevs_OBJC_FILES = create-abbrevs.m -create-regions_OBJC_FILES = create-regions.m +prepend_OBJC_FILES = prepend.m +release_OBJC_FILES = release.m +string_OBJC_FILES = string.m +test01_OBJC_FILES = test01.m +test02_OBJC_FILES = test02.m +testtool_OBJC_FILES = testtool.m +thread-except_OBJC_FILES = thread-except.m +values_OBJC_FILES = values.m # The bundles to be compiled BUNDLE_NAME=LoadMe diff --git a/Testing/fref.m b/Testing/fref.m index 7e700cf67..62c2704b8 100644 --- a/Testing/fref.m +++ b/Testing/fref.m @@ -1,52 +1,8 @@ /* Test NSArchiver on encoding of self-referential forward references. */ -/* This tests an obscure, but important feature of archiving. GNUstep - implements it correctly; NeXT does not. When running in - NeXT-compatibility mode, (i.e. setting TRY_GNU_ARCHIVING to 0, and - setting SELF_REF_DECODE_SUBSTITUTES to 1) libgnustep-base crashes - when trying to use this feature. When the identical test is - compiled on a NeXTSTEP machine, it also crashes! */ - -/* Beginning of some parameters to vary. */ -/* Both 1 works; both 0 works. 0 and 1 crash, as does NeXT's */ - -/* Use GNU Archiving features, if they are available. */ -#define TRY_GNU_ARCHIVING 0 - -/* In the forward self-reference test, -initWithCoder substitutes - another object for self. */ -#define SELF_REF_DECODE_SUBSTITUTES 0 - -/* End of some parameters to vary. */ - - -#define GNU_ARCHIVING \ -(TRY_GNU_ARCHIVING && defined(GNUSTEP_BASE_MAJOR_VERSION)) - -#if GNU_ARCHIVING -#include -#endif /* GNU_ARCHIVING */ - - -#ifdef NX_CURRENT_COMPILER_RELEASE -#include -#include -#include -#else #include #include #include -#endif - -/* Set to 1 to use text coding instead of binary coding */ -#define TEXTCSTREAM 1 -#if TEXTCSTREAM -#include -#include -#endif - -/* The -initWithCoder methods substitutes another object for self. */ -static int decode_substitutes; /* This object encodes an -encodeConditionalObject: reference to a Foo. */ @interface SubFoo : NSObject @@ -67,53 +23,39 @@ static int decode_substitutes; @implementation SubFoo -- initWithSuperFoo: o label: (int)l +- (void) dealloc { - [super init]; - super_foo = o; + RELEASE(super_foo); + [super dealloc]; +} + +- (id) initWithSuperFoo: (id)o label: (int)l +{ + self = [super init]; + super_foo = RETAIN(o); label = l; return self; } -- superFoo +- (id) superFoo { return super_foo; } -- (void) encodeWithCoder: coder +- (void) encodeWithCoder: (NSCoder*)coder { printf ("In [SubFoo encodeWithCoder:]\n"); - [super encodeWithCoder: coder]; -#if GNU_ARCHIVING - [coder encodeObjectReference: super_foo - withName: @"super foo"]; -#else [coder encodeConditionalObject: super_foo]; -#endif [coder encodeValueOfObjCType: @encode(int) at: &label]; } -- initWithCoder: coder +- (id) initWithCoder: (NSCoder*)coder { - if (decode_substitutes) - { - id o = self; - self = [[[self class] alloc] init]; - [o release]; - } - else - { - self = [super initWithCoder: coder]; - } -#if GNU_ARCHIVING - [coder decodeObjectAt: &super_foo - withName: NULL]; -#else - super_foo = [coder decodeObject]; -#endif + [coder decodeValueOfObjCType: @encode(id) + at: &super_foo]; [coder decodeValueOfObjCType: @encode(int) - at: &label]; + at: &label]; return self; } @@ -127,9 +69,15 @@ static int decode_substitutes; @implementation Foo -- init +- (void) dealloc { - [super init]; + RELEASE(sub_foo); + [super dealloc]; +} + +- (id) init +{ + self = [super init]; sub_foo = nil; label = 0; return self; @@ -137,38 +85,28 @@ static int decode_substitutes; - (void) setSubFoo: o { - sub_foo = o; + ASSIGN(sub_foo, o); } -- subFoo +- (id) subFoo { return sub_foo; } -- (void) encodeWithCoder: coder +- (void) encodeWithCoder: (NSCoder*)coder { printf ("In [Foo encodeWithCoder:]\n"); - [super encodeWithCoder: coder]; [coder encodeObject: sub_foo]; [coder encodeValueOfObjCType: @encode(int) at: &label]; } -- initWithCoder: coder +- (id) initWithCoder: (NSCoder*)coder { - if (decode_substitutes) - { - id o = self; - self = [[[self class] alloc] init]; - [o release]; - } - else - { - self = [super initWithCoder: coder]; - } - sub_foo = [coder decodeObject]; + [coder decodeValueOfObjCType: @encode(id) + at: &sub_foo]; [coder decodeValueOfObjCType: @encode(int) - at: &label]; + at: &label]; return self; } @@ -192,7 +130,6 @@ test_fref () id array; id foo, sub_foo; printf ("\nTest encoding of forward references\n"); - decode_substitutes = 0; array = [[NSMutableArray alloc] init]; foo = [[Foo alloc] init]; @@ -202,22 +139,14 @@ test_fref () [array addObject: foo]; [array insertObject: sub_foo atIndex: 0]; -#if GNU_ARCHIVING - [Archiver archiveRootObject: array toFile: @"fref.dat"]; -#else [NSArchiver archiveRootObject: array toFile: @"fref.dat"]; -#endif printf ("Encoded: "); [sub_foo print]; - [foo release]; - [sub_foo release]; - [array release]; + RELEASE(foo); + RELEASE(sub_foo); + RELEASE(array); -#if GNU_ARCHIVING - array = [Unarchiver unarchiveObjectWithFile: @"fref.dat"]; -#else array = [NSUnarchiver unarchiveObjectWithFile: @"fref.dat"]; -#endif foo = [array objectAtIndex: 1]; sub_foo = [foo subFoo]; printf ("Decoded: "); @@ -230,28 +159,19 @@ test_self_fref () { id foo, sub_foo; printf ("\nTest encoding of self-referential forward references\n"); - decode_substitutes = SELF_REF_DECODE_SUBSTITUTES; foo = [[Foo alloc] init]; [foo setLabel: 4]; sub_foo = [[SubFoo alloc] initWithSuperFoo: foo label: 3]; [foo setSubFoo: sub_foo]; -#if GNU_ARCHIVING - [Archiver archiveRootObject: foo toFile: @"fref.dat"]; -#else [NSArchiver archiveRootObject: foo toFile: @"fref.dat"]; -#endif printf ("Encoded: "); [sub_foo print]; - [foo release]; - [sub_foo release]; + RELEASE(foo); + RELEASE(sub_foo); -#if GNU_ARCHIVING - foo = [Unarchiver unarchiveObjectWithFile: @"fref.dat"]; -#else foo = [NSUnarchiver unarchiveObjectWithFile: @"fref.dat"]; -#endif sub_foo = [foo subFoo]; printf ("Decoded: "); [sub_foo print]; @@ -260,16 +180,12 @@ test_self_fref () int main () { - id arp = [NSAutoreleasePool new]; - -#if TEXTCSTREAM - [Archiver setDefaultCStreamClass: [TextCStream class]]; -#endif + CREATE_AUTORELEASE_POOL(arp); test_fref (); test_self_fref (); - [arp release]; + RELEASE(arp); exit (0); } diff --git a/Testing/nsconnection.m b/Testing/nsconnection.m new file mode 100644 index 000000000..092286985 --- /dev/null +++ b/Testing/nsconnection.m @@ -0,0 +1,83 @@ +#include + +id myServer; + +@interface Tester : NSObject +{ +} ++ (void) connectWithPorts: (NSArray*)portArray; ++ (void) setServer: (id)anObject; ++ (void) startup; +- (int) doIt; +@end + +@implementation Tester ++ (void) connectWithPorts: (NSArray*)portArray +{ + NSAutoreleasePool *pool; + NSConnection *serverConnection; + Tester *serverObject; + + pool = [[NSAutoreleasePool alloc] init]; + + serverConnection = [NSConnection + connectionWithReceivePort: [portArray objectAtIndex: 0] + sendPort: [portArray objectAtIndex: 1]]; + + serverObject = [[self alloc] init]; + [(id)[serverConnection rootProxy] setServer: serverObject]; + [serverObject release]; + + [[NSRunLoop currentRunLoop] run]; + [pool release]; + [NSThread exit]; + + return; +} + ++ (void) setServer: (id)anObject +{ + myServer = [anObject retain]; + NSLog(@"Got %d", [myServer doIt]); + exit(0); +} + ++ (void) startup +{ + NSPort *port1; + NSPort *port2; + NSArray *portArray; + NSConnection *conn; + + port1 = [NSPort port]; + port2 = [NSPort port]; + + conn = [[NSConnection alloc] initWithReceivePort: port1 sendPort: port2]; + [conn setRootObject: self]; + + /* Ports switched here. */ + portArray = [NSArray arrayWithObjects: port2, port1, nil]; + + [NSThread detachNewThreadSelector: @selector(connectWithPorts:) + toTarget: self + withObject: portArray]; + + return; +} + +- (int) doIt +{ + return 42; +} +@end + +int +main() +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + [Tester startup]; + [[NSRunLoop currentRunLoop] run]; + [pool release]; + return 0; +} diff --git a/Testing/nsconnection_client.m b/Testing/nsconnection_client.m new file mode 100644 index 000000000..2651f4819 --- /dev/null +++ b/Testing/nsconnection_client.m @@ -0,0 +1,451 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "server.h" + +@interface Auth : NSObject +@end + +@implementation Auth +- (BOOL) authenticateComponents: (NSMutableArray*)components + withData: (NSData*)authData +{ + unsigned count = [components count]; + + while (count-- > 0) + { + id obj = [components objectAtIndex: count]; + + if ([obj isKindOfClass: [NSData class]] == YES) + { + NSMutableData *d = [obj mutableCopy]; + unsigned l = [d length]; + char *p = (char*)[d mutableBytes]; + + while (l-- > 0) + p[l] ^= 42; + [components replaceObjectAtIndex: count withObject: d]; + RELEASE(d); + } + } + return YES; +} +@end + +int con_data (id prx) +{ + BOOL b, br; + unsigned char uc, ucr; + char c, cr; + short s, sr; + int i, ir; + long l, lr; + float flt, fltr; + double dbl, dblr; + char *str; + id obj; + small_struct small = {12}; + foo ffoo = {99, "cow", 9876543}; + int a3[3] = {66,77,88}; + struct myarray ma = {{55,66,77}}; + + printf("Testing data sending\n"); + + printf("Boolean:\n"); + b = YES; + printf(" sending %d", b); + br = [prx sendBoolean: b]; + printf(" got %d", br); + if (b == !br) + printf(" ...ok\n"); + else + printf(" *** ERROR ***\n"); + br = b = YES; + printf(" sending ptr to %d", br); + [prx getBoolean: &br]; + printf(" got %d", br); + if (b == !br) + printf(" ...ok\n"); + else + printf(" *** ERROR ***\n"); + printf(" (should get error returning ptr)\n"); + +#define TEST_CALL(test, send, got, sendp, var, varr, val, msg1, msg2) \ + printf(test); \ + var = val; \ + printf(send, var); \ + varr = [prx msg1 var]; \ + printf(got, varr); \ + if (varr != var+ADD_CONST) \ + printf(" *** ERROR ***\n"); \ + else \ + printf(" ...ok\n"); \ + varr = var = val+1; \ + printf(sendp, varr); \ + [prx msg2 &varr]; \ + printf(got, varr); \ + if (varr != var+ADD_CONST) \ + printf(" *** ERROR ***\n"); \ + else \ + printf(" ...ok\n"); + + TEST_CALL("UChar:\n", " sending %x", " got %x", " sending ptr to %x", + uc, ucr, 23, sendUChar:, getUChar:) + printf(" (should get error returning ptr)\n"); + + TEST_CALL("Char:\n", " sending %x", " got %x", " sending ptr to %x", + c, cr, 23, sendChar:, getChar:) + printf(" (should get error returning ptr)\n"); + + TEST_CALL("Short:\n", " sending %d", " got %d", " sending ptr to %d", + s, sr, 23, sendShort:, getShort:) + + TEST_CALL("Int:\n", " sending %d", " got %d", " sending ptr to %d", + i, ir, 23, sendInt:, getInt:) + + TEST_CALL("Long:\n", " sending %ld", " got %ld", " sending ptr to %ld", + l, lr, 23, sendLong:, getLong:) + + TEST_CALL("Float:\n", " sending %f", " got %f", " sending ptr to %f", + flt, fltr, 23.2, sendFloat:, getFloat:) + + TEST_CALL("Double:\n", " sending %g", " got %g", " sending ptr to %g", + dbl, dblr, 23.2, sendDouble:, getDouble:) + + flt = 2.718; + dbl = 3.14159265358979323846264338327; + printf(" sending double %f, float %f\n", dbl, flt); + [prx sendDouble:dbl andFloat:flt]; + + + printf("String:\n"); + str = "My String 1"; + printf(" sending (%s)", str); + str = [prx sendString: str]; + printf(" got (%s)\n", str); + str = "My String 3"; + printf(" sending ptr to (%s)", str); + [prx getString: &str]; + printf(" got (%s)\n", str); + + printf("Small Struct:\n"); + //printf(" sending %x", small.z); + //small = [prx sendSmallStruct: small]; + //printf(" got %x\n", small.z); + printf(" sending ptr to %x", small.z); + [prx getSmallStruct: &small]; + printf(" got %x\n", small.z); + + printf("Struct:\n"); + printf(" sending i=%d,s=%s,l=%ld", ffoo.i, ffoo.s, ffoo.l); + ffoo = [prx sendStruct: ffoo]; + printf(" got %d %s %ld\n", ffoo.i, ffoo.s, ffoo.l); + printf(" sending ptr to i=%d,s=%s,l=%ld", ffoo.i, ffoo.s, ffoo.l); + [prx getStruct: &ffoo]; + printf(" got i=%d,s=%s,l=%ld\n", ffoo.i, ffoo.s, ffoo.l); + + printf("Object:\n"); + obj = [NSObject new]; + [prx addObject: obj]; // FIXME: Why is this needed? + printf(" sending %s", [[obj description] cString]); + obj = [prx sendObject: obj]; + printf(" got %s\n", [[obj description] cString]); + printf(" sending ptr to %s", [[obj description] cString]); + [prx getObject: &obj]; + printf(" got %s\n", [[obj description] cString]); + + printf("Many Arguments:\n"); + [prx manyArgs:1 :2 :3 :4 :5 :6 :7 :8 :9 :10 :11 :12]; + + return 0; +} + +int +con_messages (id prx) +{ + id obj; + + obj = [NSObject new]; + + printf("Oneway Void message:\n"); + [prx shout]; + printf(" ok\n"); + + /* this next line doesn't actually test callbacks, it tests + sending the same object twice in the same message. */ + printf("Send same object twice in message\n"); + [prx sendObject: prx]; + printf(" ok\n"); + + printf("performSelector:\n"); + if (prx != [prx performSelector:sel_get_any_uid("self")]) + printf(" ERROR\n"); + else + printf(" ok\n"); + + printf("Testing bycopy/byref:\n"); + [prx sendBycopy: obj]; + +#ifdef _F_BYREF + [prx sendByref: obj]; + [prx sendByref:@"hello"]; + [prx sendByref:[NSDate date]]; +#endif + printf(" ok\n"); + return 0; +} + +int +con_benchmark (id prx) +{ + int i; + NSDate *d = [NSDate date]; + NSMutableData *sen = [NSMutableData data]; + id localObj; + id rep; + + printf("Benchmarking\n"); + [sen setLength: 100000]; + rep = [prx sendObject: sen]; + printf(" Sent: 0x%p, Reply: 0x%p, Length: %d\n", sen, rep, [rep length]); + + [NSConnection setDebug: 0]; + [NSDistantObject setDebug: 0]; + //[NSPort setDebug: 0]; + localObj = [[NSObject alloc] init]; + [prx addObject: localObj]; // FIXME: Why is this needed? + for (i = 0; i < 10000; i++) + { +#if 0 + k = [prx count]; + for (j = 0; j < k; j++) + { + id remote_peer_obj = [prx objectAt: j]; + } +#endif + [prx echoObject: localObj]; + } + + printf(" Delay is %f\n", [d timeIntervalSinceNow]); + return 0; +} + +int +con_statistics (id prx) +{ + int j; + id localObj, cobj, a, o; + + printf("------------------------------------------------------------\n"); + printf("Printing Statistics\n"); + localObj = [[NSObject alloc] init]; + [prx outputStats: localObj]; + printf(" >>list proxy's hash is 0x%d\n", [prx hash]); + printf(" >>list proxy's self is 0x%p = 0x%p\n", [prx self], prx); + printf(" >>proxy's name is (%s)\n", [prx name]); + + cobj = [prx connectionForProxy]; + o = [cobj statistics]; + a = [o allKeys]; + + for (j = 0; j < [a count]; j++) + { + id k = [a objectAtIndex:j]; + id v = [o objectForKey:k]; + + printf(" %s - %s\n", [k cString], [[v description] cString]); + } + printf("------------------------------------------------------------\n"); + + return 0; +} + +int +con_loop (id prx) +{ + NSAutoreleasePool *arp; + id cobj; + + arp = [NSAutoreleasePool new]; + cobj = [prx connectionForProxy]; + printf("%d\n", [cobj retainCount]); + printf("%s\n", [[[cobj statistics] description] cString]); + //printf("%s\n", GSDebugAllocationList(YES)); + + [NSRunLoop runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 2 * 60]]; + [cobj invalidate]; + [arp release]; + return 0; +} + +int +con_objects (id prx) +{ + int j, k; + id localObj; + + localObj = [NSObject new]; + [prx addObject:localObj]; + k = [prx count]; + for (j = 0; j < k; j++) + { + id remote_peer_obj = [prx objectAt:j]; + printf("triangle %d object proxy's hash is 0x%x\n", + j, (unsigned)[remote_peer_obj hash]); + +#if 0 + /* xxx look at this again after we use release/retain everywhere */ + if ([remote_peer_obj isProxy]) + [remote_peer_obj release]; +#endif + remote_peer_obj = [prx objectAt:j]; + printf("repeated triangle %d object proxy's hash is 0x%x\n", + j, (unsigned)[remote_peer_obj hash]); + } + return 0; +} + +void +usage(const char *program) +{ + printf("Usage: %s [-ds] [t|b|m|l|o] [host] [server]\n", program); + printf(" -d - Debug connection\n"); + printf(" -s - Print Statistics\n"); + printf(" -t - Data type test [default]\n"); + printf(" -b - Benchmark test\n"); + printf(" -m - Messaging test\n"); + printf(" -l - Loop test\n"); + printf(" -o - Objects test\n"); +} + +typedef enum { + NO_TEST, TYPE_TEST, BENCHMARK_TEST, MESSAGE_TEST, + LOOP_TEST, OBJECT_TEST +} test_t; + +int main (int argc, char *argv[], char **env) +{ + int c, debug, stats; + test_t type_test; + id cobj, prx; + NSAutoreleasePool *arp; + Auth *auth; + extern int optind; + extern char *optarg; + + [NSProcessInfo initializeWithArguments: argv count: argc environment: env]; + arp = [NSAutoreleasePool new]; + auth = [Auth new]; + GSDebugAllocationActive(YES); + + debug = 0; + type_test = 0; + stats = 0; + while ((c = getopt(argc, argv, "hdtbmslo")) != EOF) + switch (c) + { + case 'd': + debug = 1; + break; + case 't': + type_test = TYPE_TEST; + break; + case 'b': + type_test = BENCHMARK_TEST; + break; + case 'm': + type_test = MESSAGE_TEST; + break; + case 's': + stats = 1; + break; + case 'l': + type_test = LOOP_TEST; + break; + case 'o': + type_test = OBJECT_TEST; + break; + case 'h': + usage(argv[0]); + exit(0); + break; + default: + usage(argv[0]); + exit(1); + break; + } + if (type_test == NO_TEST) + type_test = TYPE_TEST; + + if (debug) + { + [NSConnection setDebug: 10]; + [NSDistantObject setDebug: 10]; + //[NSPort setDebug: 10]; + } + + if (optind < argc) + { + if (optind+1 < argc) + prx = [NSConnection rootProxyForConnectionWithRegisteredName: + [NSString stringWithCString: argv[optind+1]] + host: [NSString stringWithCString:argv[optind]]]; + else + prx = [NSConnection rootProxyForConnectionWithRegisteredName: + @"test2server" + host:[NSString stringWithCString:argv[optind]]]; + } + else + prx = [NSConnection rootProxyForConnectionWithRegisteredName:@"test2server" + host:nil]; + + if (prx == nil) + { + printf("ERROR: Failed to connect to server\n"); + return -1; + } + + cobj = [prx connectionForProxy]; + [cobj setDelegate:auth]; + [cobj setRequestTimeout:180.0]; + [cobj setReplyTimeout:180.0]; + + [prx print: "This is a message from the client. Starting Tests!"]; + + switch (type_test) + { + case TYPE_TEST: + con_data (prx); + break; + case BENCHMARK_TEST: + con_benchmark (prx); + break; + case MESSAGE_TEST: + con_messages (prx); + break; + case LOOP_TEST: + con_loop (prx); + break; + case OBJECT_TEST: + con_objects (prx); + break; + default: + break; + } + + if (stats) + con_statistics (prx); + + [arp release]; + return 0; +} diff --git a/Testing/nsconnection_server.m b/Testing/nsconnection_server.m new file mode 100644 index 000000000..d2fa8d721 --- /dev/null +++ b/Testing/nsconnection_server.m @@ -0,0 +1,468 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "server.h" + +@implementation Server + +- (NSData*) authenticationDataForComponents: (NSMutableArray*)components +{ + unsigned count = [components count]; + + while (count-- > 0) + { + id obj = [components objectAtIndex: count]; + + if ([obj isKindOfClass: [NSData class]] == YES) + { + NSMutableData *d = [obj mutableCopy]; + unsigned l = [d length]; + char *p = (char*)[d mutableBytes]; + + while (l-- > 0) + p[l] ^= 42; + [components replaceObjectAtIndex: count withObject: d]; + RELEASE(d); + } + } + return [NSData data]; +} + +- init +{ + the_array = [[NSMutableArray alloc] init]; + return self; +} + +- (unsigned) count +{ + return [the_array count]; +} + +- (void) addObject: o +{ + [the_array addObject:o]; +} + +- objectAt: (unsigned)i +{ + if (i < [the_array count]) + return [the_array objectAtIndex: i]; + else + return nil; +} + +- echoObject: obj +{ + return obj; +} + +- print: (const char *)msg +{ + printf(">>%s<<\n", msg); + fflush(stdout); + return self; +} + +- (BOOL) sendBoolean: (BOOL)b +{ + printf("(%s) got %d, returning %d\n", sel_get_name(_cmd), b, !b); + fflush(stdout); + return !b; +} + +/* This causes problems, because the runtime encodes this as "*", a string! */ +- (void) getBoolean: (BOOL*)bp +{ + printf("(%s) got %d, returning %d\n", sel_get_name(_cmd), *bp, !(*bp)); + fflush(stdout); + *bp = !(*bp); +} + +/* This causes problems, because the runtime encodes this as "*", a string! */ +- (unsigned char) sendUChar: (unsigned char)num +{ + unsigned char rnum = num + ADD_CONST; + printf("(%s) got %d, returning %d\n", sel_get_name(_cmd), num, rnum); + fflush(stdout); + return rnum; +} + +/* This causes problems, because the runtime encodes this as "*", a string! */ +- (void) getUChar: (unsigned char *)num +{ + unsigned char rnum = *num + ADD_CONST; + printf("(%s) got %d, returning %d\n", sel_get_name(_cmd), *num, rnum); + *num = rnum; + fflush(stdout); +} + +- (char) sendChar: (char)num +{ + char rnum = num + ADD_CONST; + printf("(%s) got %d, returning %d\n", sel_get_name(_cmd), num, rnum); + fflush(stdout); + return rnum; +} + +- (void) getChar: (char *)num +{ + char rnum = *num + ADD_CONST; + printf("(%s) got %d, returning %d\n", sel_get_name(_cmd), *num, rnum); + *num = rnum; + fflush(stdout); +} + +- (short) sendShort: (short)num +{ + short rnum = num + ADD_CONST; + printf("(%s) got %d, returning %d\n", sel_get_name(_cmd), num, rnum); + fflush(stdout); + return rnum; +} + +- (void) getShort: (short *)num +{ + short rnum = *num + ADD_CONST; + printf("(%s) got %d, returning %d\n", sel_get_name(_cmd), *num, rnum); + *num = rnum; + fflush(stdout); +} + +- (int) sendInt: (int)num +{ + int rnum = num + ADD_CONST; + printf("(%s) got %d, returning %d\n", sel_get_name(_cmd), num, rnum); + fflush(stdout); + return rnum; +} + +- (void) getInt: (int *)num +{ + int rnum = *num + ADD_CONST; + printf("(%s) got %d, returning %d\n", sel_get_name(_cmd), *num, rnum); + *num = rnum; + fflush(stdout); +} + +- (long) sendLong: (long)num +{ + long rnum = num + ADD_CONST; + printf("(%s) got %ld, returning %ld\n", sel_get_name(_cmd), num, rnum); + fflush(stdout); + return rnum; +} + +- (void) getLong: (long *)num +{ + long rnum = *num + ADD_CONST; + printf("(%s) got %ld, returning %ld\n", sel_get_name(_cmd), *num, rnum); + *num = rnum; + fflush(stdout); +} + +- (float) sendFloat: (float)num +{ + float rnum = num + ADD_CONST; + printf("(%s) got %f, returning %f\n", sel_get_name(_cmd), num, rnum); + fflush(stdout); + return rnum; +} + +- (void) getFloat: (float *)num +{ + float rnum = *num + ADD_CONST; + printf("(%s) got %f, returning %f\n", sel_get_name(_cmd), *num, rnum); + *num = rnum; + fflush(stdout); +} + +- (double) sendDouble: (double)num +{ + double rnum = num + ADD_CONST; + printf("(%s) got %g, returning %g\n", sel_get_name(_cmd), num, rnum); + fflush(stdout); + return rnum; +} + +- (void) getDouble: (double *)num +{ + double rnum = *num + ADD_CONST; + printf("(%s) got %g, returning %g\n", sel_get_name(_cmd), *num, rnum); + *num = rnum; + fflush(stdout); +} + +- (small_struct) sendSmallStruct: (small_struct)str +{ + char rnum = str.z + ADD_CONST; + printf("(%s) got %d, returning %d\n", sel_get_name(_cmd), str.z, rnum); + fflush(stdout); + str.z = rnum; + return str; +} + +- (void) getSmallStruct: (small_struct *)str +{ + char rnum = str->z + ADD_CONST; + printf("(%s) got %d, returning %d\n", sel_get_name(_cmd), str->z, rnum); + fflush(stdout); + str->z = rnum; +} + +- (foo) sendStruct: (foo)f +{ + foo f2 = {1, "horse", 987654}; + printf("(%s) got i=%d s=%s l=%lu", sel_get_name(_cmd), f.i, f.s, f.l); + fflush(stdout); + printf(" returning i=%d s=%s l=%lu\n", f2.i, f2.s, f2.l); + fflush(stdout); + return f2; +} + +- (void) getStruct: (foo *)f +{ + foo f2 = {1, "horse", 987654}; + printf("(%s) got i=%d s=%s l=%lu,", sel_get_name(_cmd), f->i, f->s, f->l); + fflush(stdout); + printf(" returning i=%d s=%s l=%lu\n", f2.i, f2.s, f2.l); + fflush(stdout); + *f = f2; +} + +- sendObject: (id)str +{ + printf ("(%s) got object (%s)\n", sel_get_name(_cmd), + object_get_class_name (str)); + fflush(stdout); + return str; +} + +- (void) getObject: (id *)str +{ + printf ("(%s) got object (%s)\n", sel_get_name(_cmd), + object_get_class_name (*str)); + fflush(stdout); +} + +- (char *) sendString: (char *)str +{ + printf ("(%s) got string (%s)", sel_get_name(_cmd), str); + str[0] = 'N'; + printf(" returning (%s)\n", str); + fflush(stdout); + return str; +} + +- (void) getString: (char **)str +{ + printf ("(%s) got string (%s)", sel_get_name(_cmd), *str); + (*str)[0] = 'N'; + printf(" returning (%s)\n", *str); + fflush(stdout); +} + +- (oneway void) shout +{ + printf ("(%s) got it\n", sel_get_name(_cmd)); + fflush(stdout); +} + +/* sender must also respond to 'bounce:count:' */ +- bounce: sender count: (int)c +{ + printf ("(%s) got message %d, bouncing back %d", sel_get_name(_cmd), c, c-1); + fflush(stdout); + if (--c) + [sender bounce:self count:c]; + return self; +} + +- (void) outputStats:obj +{ + id c = [obj connectionForProxy]; + id o = [c statistics]; + id a = [o allKeys]; + int j; + + printf("------------------------------------------------------------\n"); + printf("Printing Statistics\n"); + printf(" Number of connections - %d\n", [[NSConnection allConnections] count]); + printf(" This connection -\n"); + for (j = 0; j < [a count]; j++) + { + id k = [a objectAtIndex:j]; + id v = [o objectForKey:k]; + printf(" %s - %s\n", [k cString], [[v description] cString]); + } + printf("------------------------------------------------------------\n"); + fflush(stdout); +} + +/* Doesn't work because GCC generates the wrong encoding: "@0@+8:+12^i+16" */ +- sendArray: (int[3])a +{ + printf(" >> array %d %d %d\n", a[0], a[1], a[2]); + fflush(stdout); + return self; +} + +- sendStructArray: (struct myarray)ma +{ + printf(" >>struct array %d %d %d\n", ma.a[0], ma.a[1], ma.a[2]); + fflush(stdout); + return self; +} + +- sendDouble: (double)d andFloat: (float)f +{ + printf("(%s) got double %f, float %f\n", sel_get_name(_cmd), d, f); + fflush(stdout); + return self; +} + +- sendBycopy: (bycopy id)o +{ + printf(" >> bycopy class is %s\n", object_get_class_name (o)); + fflush(stdout); + return self; +} + +#ifdef _F_BYREF +- sendByref: (byref id)o +{ + printf(" >> byref class is %s\n", object_get_class_name (o)); + fflush(stdout); + return self; +} +#endif + +- manyArgs: (int)i1 : (int)i2 : (int)i3 : (int)i4 : (int)i5 : (int)i6 +: (int)i7 : (int)i8 : (int)i9 : (int)i10 : (int)i11 : (int)i12 +{ + printf("manyArgs: got %d %d %d %d %d %d %d %d %d %d %d %d\n", + i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12); + fflush(stdout); + return self; +} + +- connectionBecameInvalid: notification +{ + id anObj = [notification object]; + if ([anObj isKindOf:[NSConnection class]]) + { + int i, count = [the_array count]; + for (i = count-1; i >= 0; i--) + { + id o = [the_array objectAtIndex: i]; + if ([o isProxy] && [o connectionForProxy] == anObj) + [the_array removeObjectAtIndex: i]; + } + if (count != [the_array count]) + printf("$$$$$ connectionBecameInvalid: removed from the_array\n"); + } + else + { + [self error:"non Connection is invalid"]; + } + return self; +} + +- (NSConnection*) connection: ancestor didConnect: newConn +{ + printf("%s\n", sel_get_name(_cmd)); + [[NSNotificationCenter defaultCenter] + addObserver: self + selector: @selector(connectionBecameInvalid:) + name: NSConnectionDidDieNotification + object: newConn]; + [newConn setDelegate: self]; + return newConn; +} +@end + +void +usage(const char *program) +{ + printf("Usage: %s [-d -t#] [server_name]\n", program); + printf(" -d - Debug connection\n"); + printf(" -t - Timeout after # seconds\n"); +} + +int main(int argc, char *argv[], char **env) +{ + int i, debug, timeout; + id l = [[Server alloc] init]; + id o = [[NSObject alloc] init]; + NSConnection *c; + NSAutoreleasePool *arp = [NSAutoreleasePool new]; + extern int optind; + extern char *optarg; + + [NSProcessInfo initializeWithArguments: argv count: argc environment: env]; + debug = 0; + timeout = 0; + while ((i = getopt(argc, argv, "hdt:")) != EOF) + switch (i) + { + case 'd': + debug = 1; + break; + case 't': + timeout = atoi(optarg);; + break; + case 'h': + usage(argv[0]); + exit(0); + break; + default: + usage(argv[0]); + exit(1); + break; + } + +#if NeXT_runtime + [NSDistantObject setProtocolForProxies:@protocol(AllProxies)]; +#endif + + if (debug) + { + [NSConnection setDebug: 10]; + [NSDistantObject setDebug: 10]; + } + + c = [NSConnection defaultConnection]; + [c setRootObject: l]; + + if (optind < argc) + [c registerName: [NSString stringWithCString: argv[optind]]]; + else + [c registerName: @"test2server"]; + + [[NSNotificationCenter defaultCenter] + addObserver: l + selector: @selector(connectionBecameInvalid:) + name: NSConnectionDidDieNotification + object: c]; + [c setDelegate: l]; + + [l addObject: o]; + printf(" list's hash is 0x%x\n", (unsigned)[l hash]); + printf(" object's hash is 0x%x\n", (unsigned)[o hash]); + printf("Running...\n"); + + if (timeout) + [NSRunLoop runUntilDate: [NSDate dateWithTimeIntervalSinceNow: timeout]]; + else + [NSRunLoop run]; + printf("Finished\n"); + + [arp release]; + exit(0); +} diff --git a/Testing/nsdata.m b/Testing/nsdata.m index bc41b55b8..fecbd2545 100644 --- a/Testing/nsdata.m +++ b/Testing/nsdata.m @@ -1,8 +1,385 @@ +#include #include +#include +#include +#include #include #include #include +/****************************************************************************** +* Module : NSMutableData(NSData) --- Black Box test module for the +* *Data classes to make sure that methods that raise exceptions +* do so, and that the exceptions are raised properly. +* +* Author : John W. M. Stevens + +............................................................................... +15 April 1997 + +******************************************************************************/ + +/* Data for stuffing into *Data objects. I like printable data, as it +* gives a quick visual check mechanism, but it has the disadvantage +* of not checking for 8 bit cleanliness. +*/ +char *testString = "Test string for mutable data and archiver classes."; +char *subString = "Sub String"; + +/*----------------------------------------------------------------------------- +| Routine : TestNSMutableData() --- Create an instance of an NSMutableData +| class, initialize it with a C string (to have something +| printable for tests) and invoke the two methods that +| should raise NSRangeException exceptions using ranges that +| cross both edges of the buffer boundary. +| +| Notes : Please see work logs for discussion. +-----------------------------------------------------------------------------*/ + +void +TestNSMutableData(void) +{ + auto NSMutableData *nsMutData; + auto char *str; + auto NSRange range; + + /* Allocate and initialize an instance of an NSMutableData + * class. + */ + nsMutData = [NSMutableData dataWithLength: strlen( testString ) + 1]; + str = (char *) [nsMutData mutableBytes]; + strcpy(str, testString); + + /* Get contents, display. */ + str = NULL; + str = (char *) [nsMutData mutableBytes]; + printf("NSMutableData Test ---------------------------------------------" + "---------------\n" + "1) String: (%s)\n", str); + + /* Attempt to force Range exception by having range start before + * zero. + */ +NS_DURING + range = NSMakeRange(-2, strlen( subString )); + [nsMutData replaceBytesInRange: range + withBytes : subString ]; +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force another Range exception. */ +NS_DURING + range = NSMakeRange(41, strlen( subString )); + [nsMutData replaceBytesInRange: range + withBytes : subString ]; +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force another Range exception. */ +NS_DURING + range = NSMakeRange(42, strlen( subString )); + [nsMutData replaceBytesInRange: range + withBytes : subString ]; +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* How about a length that is less than zero? */ +NS_DURING + range = NSMakeRange(6, -3.0); + [nsMutData replaceBytesInRange: range + withBytes : subString ]; +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force Range exception by having range start before + * zero. + */ +NS_DURING + range = NSMakeRange(-2, strlen( subString )); + [nsMutData resetBytesInRange: range]; +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force another Range exception. */ +NS_DURING + range = NSMakeRange(41, strlen( subString )); + [nsMutData resetBytesInRange: range]; +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force another Range exception. */ +NS_DURING + range = NSMakeRange(42, strlen( subString )); + [nsMutData resetBytesInRange: range]; +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* How about a length less than zero? */ +NS_DURING + range = NSMakeRange(6.0, -3.0); + [nsMutData resetBytesInRange: range]; +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Get contents, display. */ + str = NULL; + str = (char *) [nsMutData mutableBytes]; + printf("2) String: (%s)\n", str); + + /* Attempt to force an out of memory exception. */ +#if 0 + for ( ; ; ) + { + /* Append. */ + [nsMutData appendBytes: testString + length : strlen( testString ) + 1]; + + /* Show current value. */ + printf("%9u\r", [nsMutData length]); + } +#endif +} + +/*----------------------------------------------------------------------------- +| Routine : TestNSData() --- Create an instance of an NSData +| class, initialize it with a C string (to have something +| printable for tests) and invoke the two methods that +| should raise NSRangeException exceptions using ranges that +| cross both edges of the buffer boundary. +| +| Notes : Please see work logs for discussion. +-----------------------------------------------------------------------------*/ + +void +TestNSData(void) +{ + auto NSData *nsData; + auto NSData *newNsData; + auto char *str; + auto char bfr[128]; + auto NSRange range; + + /* Allocate and initialize an instance of an NSData + * class. + */ + nsData = [NSData dataWithBytes: testString + length : (unsigned int) strlen( testString ) + 1]; + + /* Get contents, display. */ + str = (char *) [nsData bytes]; + printf("NSData Test ----------------------------------------------------" + "---------------\n" + "1) String: (%s)\n", str); + + /* Attempt to force Range exception by having range start before + * zero. + */ +NS_DURING + /* Get buffer piece. */ + range = NSMakeRange(-2.0, 6.0); + [nsData getBytes: bfr + range : range]; + + /* Print buffer piece. */ + bfr[6] = '\0'; + printf(" A) Buffer: (%s)\n", bfr); +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force another Range exception. */ +NS_DURING + /* Get piece. */ + range = NSMakeRange(41, strlen( subString )); + [nsData getBytes: bfr + range : range]; + + /* Print buffer piece. */ + bfr[strlen( subString )] = '\0'; + printf(" B) Buffer: (%s)\n", bfr); +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force another Range exception. */ +NS_DURING + range = NSMakeRange(42, strlen( subString )); + [nsData getBytes: bfr + range : range]; + + /* Print buffer piece. */ + bfr[strlen( subString )] = '\0'; + printf(" C) Buffer: (%s)\n", bfr); +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* How about less than zero length? */ +NS_DURING + range = NSMakeRange(5.0, -4.0); + [nsData getBytes: bfr + range : range]; + + /* Print buffer piece. */ + bfr[strlen( subString )] = '\0'; + printf(" C) Buffer: (%s)\n", bfr); +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + +/*=================== subDataWithRange ======================================*/ + /* Attempt to force Range exception by having range start before + * zero. + */ +NS_DURING + /* Get buffer piece. */ + range = NSMakeRange(-2.0, 6.0); + newNsData = [nsData subdataWithRange: range]; + + /* Print buffer piece. */ + [newNsData getBytes: bfr]; + bfr[6] = '\0'; + printf(" D) Buffer: (%s)\n", bfr); +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force another Range exception. */ +NS_DURING + /* Get buffer piece. */ + range = NSMakeRange(41, strlen( subString )); + newNsData = [nsData subdataWithRange: range]; + + /* Print buffer piece. */ + [newNsData getBytes: bfr]; + bfr[strlen( subString )] = '\0'; + printf(" E) Buffer: (%s)\n", bfr); +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Attempt to force another Range exception. */ +NS_DURING + /* Get buffer piece. */ + range = NSMakeRange(42, strlen( subString )); + newNsData = [nsData subdataWithRange: range]; + + /* Print buffer piece. */ + [newNsData getBytes: bfr]; + bfr[strlen( subString )] = '\0'; + printf(" F) Buffer: (%s)\n", bfr); +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* How about a length less than zero? */ +NS_DURING + /* Get buffer piece. */ + range = NSMakeRange(9.0, -6.0); + newNsData = [nsData subdataWithRange: range]; + + /* Print buffer piece. */ + [newNsData getBytes: bfr]; + bfr[strlen( subString )] = '\0'; + printf(" F) Buffer: (%s)\n", bfr); +NS_HANDLER + fprintf(stderr, + "%s %d : Exception %s - %s\n", + __FILE__, + __LINE__, + [[localException name] cString], + [[localException reason] cString]); +NS_ENDHANDLER + + /* Get contents, display. */ + str = NULL; + str = (char *) [nsData bytes]; + printf("2) String: (%s)\n", str); +} + int main() { @@ -86,6 +463,12 @@ main() [d setCapacity: 2000000]; printf("Set capacity of shared memory item to %d\n", [d capacity]); + /* Test NSMutableData. */ + TestNSMutableData(); + + /* Test NSData. */ + TestNSData(); + [pool release]; exit(0); diff --git a/Testing/nstimer.m b/Testing/nstimer.m index c7e939b41..4b77ae0d8 100644 --- a/Testing/nstimer.m +++ b/Testing/nstimer.m @@ -1,13 +1,18 @@ #include -#include #include -#include +#include +#include @interface TestDouble : NSObject + (double) testDouble; - (double) testDoubleInstance; @end @implementation TestDouble ++ (void) sayCount +{ + static int count = 0; + printf ("Timer fired %d times\n", ++count); +} + (double) testDouble { return 12345678912345.0; @@ -23,20 +28,20 @@ double test_double () return 92345678912345.0; } -void say_count () -{ - static int count = 0; - printf ("Timer fired %d times\n", ++count); -} int main() { NSAutoreleasePool *arp = [NSAutoreleasePool new]; volatile double foo, bar; - id inv = [[VoidFunctionInvocation alloc] initWithVoidFunction: say_count]; + id inv; id o; id d; + inv = [NSInvocation invocationWithMethodSignature: + [TestDouble methodSignatureForSelector: @selector(sayCount)]]; + [inv setSelector: @selector(sayCount)]; + [inv setTarget: [TestDouble class]]; + foo = [TestDouble testDouble]; printf ("TestDouble is %f\n", foo); foo = [TestDouble testDouble]; diff --git a/Testing/server.h b/Testing/server.h index 343d6ffe9..8de3c93da 100644 --- a/Testing/server.h +++ b/Testing/server.h @@ -17,51 +17,58 @@ typedef struct _foo { struct myarray { int a[3]; }; + +#define ADD_CONST 47 @protocol ServerProtocol -- (void) addObject: o; +- (BOOL) sendBoolean: (BOOL)b; +- (void) getBoolean: (BOOL*)bp; +- (unsigned char) sendUChar: (unsigned char)uc; +- (void) getUChar: (unsigned char *)ucp; +- (char) sendChar: (char)uc; +- (void) getChar: (char *)ucp; +- (short) sendShort: (short)num; +- (void) getShort: (short *)num; +- (int) sendInt: (int)num; +- (void) getInt: (int *)num; +- (long) sendLong: (long)num; +- (void) getLong: (long *)num; +- (float) sendFloat: (float)num; +- (void) getFloat: (float *)num; +- (double) sendDouble: (double)num; +- (void) getDouble: (double *)num; +- sendDouble: (double)dbl andFloat: (float)flt; + +- (small_struct) sendSmallStruct: (small_struct)str; +- (void) getSmallStruct: (small_struct *)str; +- (foo) sendStruct: (foo)str; +- (void) getStruct: (foo *)str; +- (id) sendObject: (id)str; +- (void) getObject: (id *)str; +- (char *) sendString: (char *)str; +- (void) getString: (char **)str; + +- print: (const char *)str; + - objectAt: (unsigned)i; - (unsigned) count; -- print: (const char *)msg; -- getLong: (out unsigned long*)i; +- echoObject: obj; + - (oneway void) shout; -- callbackNameOn: obj; - bounce: sender count: (int)c; -- (BOOL) doBoolean: (BOOL)b; -- getBoolean: (BOOL*)bp; -- getUCharPtr: (unsigned char *)ucp; - (oneway void) outputStats:obj; -- (foo*) sendStructPtr: (foo*)f; -- sendStruct: (foo)f; -- sendSmallStruct: (small_struct)small; -- (foo) returnStruct; -- (foo) returnSetStruct: (int)x; -- (small_struct) returnSmallStruct; -- (small_struct) returnSetSmallStruct: (int)x; + - sendArray: (int[3])a; - sendStructArray: (struct myarray)ma; -- sendDouble: (double)d andFloat: (float)f; -- (double*) doDoublePointer: (double*)d; -- sendCharPtrPtr: (char**)sp; + - sendBycopy: (bycopy id)o; #ifdef _F_BYREF - sendByref: (byref id)o; #endif - manyArgs: (int)i1 : (int)i2 : (int)i3 : (int)i4 : (int)i5 : (int)i6 : (int)i7 : (int)i8 : (int)i9 : (int)i10 : (int)i11 : (int)i12; -- (float) returnFloat; -- (double) returnDouble; -- (id) echoObject: (id)obj; @end -#if NeXT_runtime -@protocol AllProxies -- (const char *)name; -- (unsigned) hash; -- self; -@end -#endif - @interface Server : NSObject { id the_array; diff --git a/Testing/thread-except.m b/Testing/thread-except.m index 787d8693c..19c349329 100644 --- a/Testing/thread-except.m +++ b/Testing/thread-except.m @@ -1,6 +1,8 @@ /* Test whether each thread has their own exception handlers. */ +#ifndef _REENTRANT #define _REENTRANT +#endif #include #include diff --git a/Testing/values.m b/Testing/values.m index e8e477283..e526ff9b2 100644 --- a/Testing/values.m +++ b/Testing/values.m @@ -16,11 +16,15 @@ int main() NSPoint p; NSRect rect; NSValue *v1, *v2; - NSNumber *n1, *n2, *n3, *n4, *n5; + NSNumber *nc, *ns, *n1, *n2, *n3, *n4, *n5; NSArray *a1, *a2; NSAutoreleasePool *arp = [NSAutoreleasePool new]; // Numbers + nc = [NSNumber numberWithChar:-100]; + ns = [NSNumber numberWithShort:-100]; +printf("try %d, %d", [nc charValue], [ns shortValue]); +printf("nc compare:ns is %d\n", [nc compare:ns]); n1 = [NSNumber numberWithUnsignedShort:30]; n2 = [NSNumber numberWithDouble:2.7]; n3 = [NSNumber numberWithDouble:30]; diff --git a/Tools/GNUmakefile b/Tools/GNUmakefile index 6e8e5678c..1281da308 100644 --- a/Tools/GNUmakefile +++ b/Tools/GNUmakefile @@ -37,7 +37,7 @@ DTD_FILES = gsdoc-0_6_5.dtd gsdoc-0_6_6.dtd # The application to be compiled TOOL_NAME = gdnc gsdoc defaults plmerge \ plparse sfparse pldes plser -OBJC_PROGRAM_NAME = gdomap +CTOOL_NAME = gdomap # The source files to be compiled gdomap_C_FILES = gdomap.c @@ -64,7 +64,7 @@ include Makefile.preamble -include GNUmakefile.local -include $(GNUSTEP_MAKEFILES)/objc.make +include $(GNUSTEP_MAKEFILES)/ctool.make include $(GNUSTEP_MAKEFILES)/tool.make include Makefile.postamble diff --git a/Tools/Makefile.postamble b/Tools/Makefile.postamble index 27983c69b..9c2b15732 100644 --- a/Tools/Makefile.postamble +++ b/Tools/Makefile.postamble @@ -19,7 +19,7 @@ before-install:: # Things to do after installing after-install:: - if [ ! -f $(dtddir) ]; then \ + @if [ ! -f $(dtddir) ]; then \ $(MKDIRS) $(dtddir); \ fi; \ for file in $(DTD_FILES); do \ @@ -28,16 +28,17 @@ after-install:: if [ "`$(WHOAMI)`" != "root" ]; then \ echo ""; \ echo "************************************************************"; \ - echo "WARNING: gdomap MUST be installed owned by root and with"; \ + echo "FAILED gdomap installation - please re-run this as root ..."; \ + echo "NOTE: gdomap MUST be installed owned by root and with"; \ echo "the 's-bit' set unless you defined 'GDOMAP_PORT_OVERRIDE' in"; \ echo "gdomap.h before compiling gdomap.c and NSPortNameServer.m"; \ echo "in which case you should install it by hand."; \ + echo "If you have installed by hand, ignore this message."; \ echo "************************************************************"; \ echo ""; \ else \ - echo "Installing gdomap and gdnc in $(GNUSTEP_INSTALLATION_DIR)/Tools/$(GNUSTEP_TARGET_DIR)"; \ + echo "Making gdomap in $(GNUSTEP_INSTALLATION_DIR)/Tools/$(GNUSTEP_TARGET_DIR) setuid to root"; \ $(INSTALL) -m 05755 $(GNUSTEP_OBJ_DIR)/gdomap $(GNUSTEP_INSTALLATION_DIR)/Tools/$(GNUSTEP_TARGET_DIR); \ - $(INSTALL) -m 0755 $(GNUSTEP_OBJ_DIR)/gdnc $(GNUSTEP_INSTALLATION_DIR)/Tools/$(GNUSTEP_TARGET_DIR); \ fi; \ echo "************************************************************"; \ echo "WARNING: if gdomap is started automatically, it will probe"; \ diff --git a/Version b/Version index 8112d8bc7..cf5b82c2d 100644 --- a/Version +++ b/Version @@ -7,12 +7,12 @@ GCC_VERSION=2.8.0 # The version number of this release. MAJOR_VERSION=0 MINOR_VERSION=6 -SUBMINOR_VERSION=5 +SUBMINOR_VERSION=6 GNUSTEP_BASE_VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${SUBMINOR_VERSION} VERSION=${GNUSTEP_BASE_VERSION} -GNUSTEP_BASE_FTP_MACHINE=ftp.gnu.org -GNUSTEP_BASE_FTP_DIRECTORY=pub/gnu/gstep +GNUSTEP_BASE_FTP_MACHINE=ftp.gnustep.org +GNUSTEP_BASE_FTP_DIRECTORY=pub/gnustep/core GNUSTEP_BASE_SNAP_FTP_MACHINE=alpha.gnu.org GNUSTEP_BASE_SNAP_FTP_DIRECTORY=gnu/gnustep diff --git a/configure b/configure index 27f717ed0..827a905ad 100755 --- a/configure +++ b/configure @@ -1,7 +1,7 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.13 +# Generated automatically using autoconf version 2.13.1 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation @@ -337,7 +337,7 @@ EOF verbose=yes ;; -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.13" + echo "configure generated by autoconf version 2.13.1" exit 0 ;; -with-* | --with-*) @@ -497,7 +497,7 @@ done if test -r "$cache_file"; then echo "loading cache $cache_file" - . $cache_file + test -f "$cache_file" && . $cache_file else echo "creating cache $cache_file" > $cache_file @@ -573,9 +573,130 @@ done if test -z "$ac_aux_dir"; then { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } fi -ac_config_guess=$ac_aux_dir/config.guess -ac_config_sub=$ac_aux_dir/config.sub -ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" +ac_config_sub="$SHELL $ac_aux_dir/config.sub" +ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. + + +echo $ac_n "checking host system type""... $ac_c" 1>&6 +echo "configure:583: checking host system type" >&5 +if test "x$ac_cv_host" = "x" || (test "x$host" != "xNONE" && test "x$host" != "x$ac_cv_host_alias"); then + +# Make sure we can run config.sub. + if $ac_config_sub sun4 >/dev/null 2>&1; then : + else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } + fi + + ac_cv_host_alias=$host + case "$ac_cv_host_alias" in + NONE) + case $nonopt in + NONE) + if ac_cv_host_alias=`$ac_config_guess`; then : + else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } + fi ;; + *) ac_cv_host_alias=$nonopt ;; + esac ;; + esac + + ac_cv_host=`$ac_config_sub $ac_cv_host_alias` + ac_cv_host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` + ac_cv_host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` + ac_cv_host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +else + echo $ac_n "(cached) $ac_c" 1>&6 +fi + +echo "$ac_t""$ac_cv_host" 1>&6 + +host=$ac_cv_host +host_alias=$ac_cv_host_alias +host_cpu=$ac_cv_host_cpu +host_vendor=$ac_cv_host_vendor +host_os=$ac_cv_host_os + + + + + +echo $ac_n "checking target system type""... $ac_c" 1>&6 +echo "configure:624: checking target system type" >&5 +if test "x$ac_cv_target" = "x" || (test "x$target" != "xNONE" && test "x$target" != "x$ac_cv_target_alias"); then + +# Make sure we can run config.sub. + if $ac_config_sub sun4 >/dev/null 2>&1; then : + else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } + fi + + ac_cv_target_alias=$target + case "$ac_cv_target_alias" in + NONE) + case $nonopt in + NONE) + ac_cv_target_alias=$host_alias ;; + + *) ac_cv_target_alias=$nonopt ;; + esac ;; + esac + + ac_cv_target=`$ac_config_sub $ac_cv_target_alias` + ac_cv_target_cpu=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` + ac_cv_target_vendor=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` + ac_cv_target_os=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +else + echo $ac_n "(cached) $ac_c" 1>&6 +fi + +echo "$ac_t""$ac_cv_target" 1>&6 + +target=$ac_cv_target +target_alias=$ac_cv_target_alias +target_cpu=$ac_cv_target_cpu +target_vendor=$ac_cv_target_vendor +target_os=$ac_cv_target_os + + + + + +echo $ac_n "checking build system type""... $ac_c" 1>&6 +echo "configure:664: checking build system type" >&5 +if test "x$ac_cv_build" = "x" || (test "x$build" != "xNONE" && test "x$build" != "x$ac_cv_build_alias"); then + +# Make sure we can run config.sub. + if $ac_config_sub sun4 >/dev/null 2>&1; then : + else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } + fi + + ac_cv_build_alias=$build + case "$ac_cv_build_alias" in + NONE) + case $nonopt in + NONE) + ac_cv_build_alias=$host_alias ;; + + *) ac_cv_build_alias=$nonopt ;; + esac ;; + esac + + ac_cv_build=`$ac_config_sub $ac_cv_build_alias` + ac_cv_build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` + ac_cv_build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` + ac_cv_build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +else + echo $ac_n "(cached) $ac_c" 1>&6 +fi + +echo "$ac_t""$ac_cv_build" 1>&6 + +build=$ac_cv_build +build_alias=$ac_cv_build_alias +build_cpu=$ac_cv_build_cpu +build_vendor=$ac_cv_build_vendor +build_os=$ac_cv_build_os + + + # Do some error checking and defaulting for the host and target type. @@ -598,69 +719,6 @@ NONE---*---* | *---NONE---* | *---*---NONE) ;; *) { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } ;; esac - -# Make sure we can run config.sub. -if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : -else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } -fi - -echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:609: checking host system type" >&5 - -host_alias=$host -case "$host_alias" in -NONE) - case $nonopt in - NONE) - if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : - else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } - fi ;; - *) host_alias=$nonopt ;; - esac ;; -esac - -host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` -host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` -echo "$ac_t""$host" 1>&6 - -echo $ac_n "checking target system type""... $ac_c" 1>&6 -echo "configure:630: checking target system type" >&5 - -target_alias=$target -case "$target_alias" in -NONE) - case $nonopt in - NONE) target_alias=$host_alias ;; - *) target_alias=$nonopt ;; - esac ;; -esac - -target=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $target_alias` -target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` -echo "$ac_t""$target" 1>&6 - -echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:648: checking build system type" >&5 - -build_alias=$build -case "$build_alias" in -NONE) - case $nonopt in - NONE) build_alias=$host_alias ;; - *) build_alias=$nonopt ;; - esac ;; -esac - -build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias` -build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` -echo "$ac_t""$build" 1>&6 - test "$host_alias" != "$target_alias" && test "$program_prefix$program_suffix$program_transform_name" = \ NONENONEs,x,x, && @@ -673,8 +731,8 @@ test "$host_alias" != "$target_alias" && # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:677: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then +echo "configure:735: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then @@ -703,8 +761,8 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:707: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then +echo "configure:765: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then @@ -750,12 +808,12 @@ fi if test -z "$CC"; then case "`uname -s`" in - *win32* | *WIN32*) + *win32* | *WIN32* | *CYGWIN*) # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:758: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then +echo "configure:816: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then @@ -785,8 +843,8 @@ fi test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } fi -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:790: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:848: checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -797,12 +855,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 801 "configure" +#line 859 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:806: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:864: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -827,14 +885,14 @@ echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:832: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:890: checking whether the C compiler ($CC $CFLAGS $CPPFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:837: checking whether we are using GNU C" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then +echo "configure:895: checking whether we are using GNU C" >&5 +if eval "test \"\${ac_cv_prog_gcc+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:904: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -861,8 +919,8 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:865: checking whether ${CC-cc} accepts -g" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then +echo "configure:923: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"\${ac_cv_prog_cc_g+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else echo 'void f(){}' > conftest.c @@ -893,13 +951,13 @@ else fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:897: checking how to run the C preprocessor" >&5 +echo "configure:955: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then -if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then +if eval "test \"\${ac_cv_prog_CPP+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else # This must be in double quotes, not single quotes, because CPP may get @@ -908,13 +966,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:918: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:976: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -925,13 +983,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:935: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:993: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -942,13 +1000,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:952: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1010: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -976,8 +1034,8 @@ echo "$ac_t""$CPP" 1>&6 # Extract the first word of "whoami", so it can be a program name with args. set dummy whoami; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:980: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_WHOAMI'+set}'`\" = set"; then +echo "configure:1038: checking for $ac_word" >&5 +if eval "test \"\${ac_cv_path_WHOAMI+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else case "$WHOAMI" in @@ -1024,14 +1082,14 @@ PIPE='-pipe' # include implementations of List, HashTable etc. #-------------------------------------------------------------------- echo $ac_n "checking whether we are using NeXT's compiler""... $ac_c" 1>&6 -echo "configure:1028: checking whether we are using NeXT's compiler" >&5 +echo "configure:1086: checking whether we are using NeXT's compiler" >&5 cat > conftest.$ac_ext <&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1093: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1051,16 +1109,16 @@ if test $NeXTCC = 0; then # Find out if nested functions work on this machine #---------------------------------------------------------------- echo $ac_n "checking whether nested functions work""... $ac_c" 1>&6 -echo "configure:1055: checking whether nested functions work" >&5 +echo "configure:1113: checking whether nested functions work" >&5 if test "$cross_compiling" = yes; then gcc_nested=1 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1122: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then gcc_nested=1 else @@ -1092,16 +1150,16 @@ fi # Find out if we're on a NEXTSTEP machine #---------------------------------------------------------------- echo $ac_n "checking whether we are running under NEXTSTEP""... $ac_c" 1>&6 -echo "configure:1096: checking whether we are running under NEXTSTEP" >&5 +echo "configure:1154: checking whether we are running under NEXTSTEP" >&5 cat > conftest.$ac_ext <&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1163: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1129,16 +1187,16 @@ rm -f conftest* saved_ac_ext=$ac_ext ac_ext=m echo $ac_n "checking whether we are using GNU Objective C runtime""... $ac_c" 1>&6 -echo "configure:1133: checking whether we are using GNU Objective C runtime" >&5 +echo "configure:1191: checking whether we are using GNU Objective C runtime" >&5 cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1200: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* NeXT_runtime=1 else @@ -1184,16 +1242,16 @@ else # Find out if we have NEXTSTEP 3.2 or lower #---------------------------------------------------------------- echo "checking NEXTSTEP version" 1>&6 -echo "configure:1188: checking NEXTSTEP version" >&5 +echo "configure:1246: checking NEXTSTEP version" >&5 cat > conftest.$ac_ext <&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1255: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1254,8 +1312,8 @@ fi # Check if Objective-C is installed #-------------------------------------------------------------------- echo $ac_n "checking for alternate objc library""... $ac_c" 1>&6 -echo "configure:1258: checking for alternate objc library" >&5 -if eval "test \"`echo '$''{'gs_cv_objc_libdir'+set}'`\" = set"; then +echo "configure:1316: checking for alternate objc library" >&5 +if eval "test \"\${gs_cv_objc_libdir+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else gs_cv_objc_libdir=NONE @@ -1283,17 +1341,17 @@ for ac_hdr in objc/objc.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1287: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then +echo "configure:1345: checking for $ac_hdr" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1297: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1355: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1330,7 +1388,7 @@ fi # Check if libobjc was compiled with thread support. #-------------------------------------------------------------------- echo $ac_n "checking whether objc has thread support""... $ac_c" 1>&6 -echo "configure:1334: checking whether objc has thread support" >&5 +echo "configure:1392: checking whether objc has thread support" >&5 saved_LIBS="$LIBS" extra_LIBS="" case "${target_os}" in @@ -1345,11 +1403,11 @@ if test $host_os = linux-gnu; then objc_threaded="-lpthread" else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1411: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then objc_threaded="-lpthread" else @@ -1367,11 +1425,11 @@ fi objc_threaded="-lpcthread" else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1433: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then objc_threaded="-lpcthread" else @@ -1390,11 +1448,11 @@ elif test "`echo $host_os|sed 's/[0-9].*//'|sed s/elf//`" = freebsd; then objc_threaded="-pthread" else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1456: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then objc_threaded="-pthread" else @@ -1412,11 +1470,11 @@ fi objc_threaded="-lpthread" else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1478: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then objc_threaded="-lpthread" else @@ -1435,11 +1493,11 @@ fi objc_threaded="-lpcthread" else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1501: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then objc_threaded="-lpcthread" else @@ -1458,11 +1516,11 @@ else objc_threaded="-lthread" else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1524: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then objc_threaded="-lthread" else @@ -1489,14 +1547,14 @@ ac_cv_objc_threaded=$objc_threaded # Byte order information needed for foundation headers. #-------------------------------------------------------------------- echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6 -echo "configure:1493: checking whether byte ordering is bigendian" >&5 -if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then +echo "configure:1551: checking whether byte ordering is bigendian" >&5 +if eval "test \"\${ac_cv_c_bigendian+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_c_bigendian=unknown # See if sys/param.h defines the BYTE_ORDER macro. cat > conftest.$ac_ext < #include @@ -1507,11 +1565,11 @@ int main() { #endif ; return 0; } EOF -if { (eval echo configure:1511: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1569: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* # It does; now see whether it defined to BIG_ENDIAN or not. cat > conftest.$ac_ext < #include @@ -1522,7 +1580,7 @@ int main() { #endif ; return 0; } EOF -if { (eval echo configure:1526: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1584: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_bigendian=yes else @@ -1542,7 +1600,7 @@ if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1617: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_bigendian=no else @@ -1589,15 +1647,15 @@ fi # Type size information needed for foundation headers. #-------------------------------------------------------------------- echo $ac_n "checking size of void*""... $ac_c" 1>&6 -echo "configure:1593: checking size of void*" >&5 -if eval "test \"`echo '$''{'ac_cv_sizeof_voidp'+set}'`\" = set"; then +echo "configure:1651: checking size of void*" >&5 +if eval "test \"\${ac_cv_sizeof_voidp+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < main() @@ -1608,7 +1666,7 @@ main() exit(0); } EOF -if { (eval echo configure:1612: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1670: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_voidp=`cat conftestval` else @@ -1634,15 +1692,15 @@ GS_UINT8="unsigned char" echo $ac_n "checking size of short""... $ac_c" 1>&6 -echo "configure:1638: checking size of short" >&5 -if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then +echo "configure:1696: checking size of short" >&5 +if eval "test \"\${ac_cv_sizeof_short+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < main() @@ -1653,7 +1711,7 @@ main() exit(0); } EOF -if { (eval echo configure:1657: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1715: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_short=`cat conftestval` else @@ -1675,15 +1733,15 @@ EOF echo $ac_n "checking size of int""... $ac_c" 1>&6 -echo "configure:1679: checking size of int" >&5 -if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then +echo "configure:1737: checking size of int" >&5 +if eval "test \"\${ac_cv_sizeof_int+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < main() @@ -1694,7 +1752,7 @@ main() exit(0); } EOF -if { (eval echo configure:1698: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1756: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_int=`cat conftestval` else @@ -1716,15 +1774,15 @@ EOF echo $ac_n "checking size of long""... $ac_c" 1>&6 -echo "configure:1720: checking size of long" >&5 -if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then +echo "configure:1778: checking size of long" >&5 +if eval "test \"\${ac_cv_sizeof_long+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < main() @@ -1735,7 +1793,7 @@ main() exit(0); } EOF -if { (eval echo configure:1739: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1797: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_long=`cat conftestval` else @@ -1757,15 +1815,15 @@ EOF echo $ac_n "checking size of long long""... $ac_c" 1>&6 -echo "configure:1761: checking size of long long" >&5 -if eval "test \"`echo '$''{'ac_cv_sizeof_long_long'+set}'`\" = set"; then +echo "configure:1819: checking size of long long" >&5 +if eval "test \"\${ac_cv_sizeof_long_long+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < main() @@ -1776,7 +1834,7 @@ main() exit(0); } EOF -if { (eval echo configure:1780: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1838: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_long_long=`cat conftestval` else @@ -1798,15 +1856,15 @@ EOF echo $ac_n "checking size of float""... $ac_c" 1>&6 -echo "configure:1802: checking size of float" >&5 -if eval "test \"`echo '$''{'ac_cv_sizeof_float'+set}'`\" = set"; then +echo "configure:1860: checking size of float" >&5 +if eval "test \"\${ac_cv_sizeof_float+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < main() @@ -1817,7 +1875,7 @@ main() exit(0); } EOF -if { (eval echo configure:1821: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1879: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_float=`cat conftestval` else @@ -1839,15 +1897,15 @@ EOF echo $ac_n "checking size of double""... $ac_c" 1>&6 -echo "configure:1843: checking size of double" >&5 -if eval "test \"`echo '$''{'ac_cv_sizeof_double'+set}'`\" = set"; then +echo "configure:1901: checking size of double" >&5 +if eval "test \"\${ac_cv_sizeof_double+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < main() @@ -1858,7 +1916,7 @@ main() exit(0); } EOF -if { (eval echo configure:1862: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1920: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_double=`cat conftestval` else @@ -1879,6 +1937,7 @@ EOF + if test $ac_cv_sizeof_voidp = $ac_cv_sizeof_int; then GS_ADDR="unsigned int" else @@ -2061,8 +2120,8 @@ fi # Defines CON_AUTOLOAD (whether constructor functions are autoloaded) #-------------------------------------------------------------------- echo $ac_n "checking loading of constructor functions""... $ac_c" 1>&6 -echo "configure:2065: checking loading of constructor functions" >&5 -if eval "test \"`echo '$''{'objc_cv_con_autoload'+set}'`\" = set"; then +echo "configure:2124: checking loading of constructor functions" >&5 +if eval "test \"\${objc_cv_con_autoload+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.constructor.c <&6 -echo "configure:2106: checking for dlfcn.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then +echo "configure:2165: checking for dlfcn.h" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2116: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2175: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2136,17 +2195,17 @@ fi if test $DYNAMIC_LINKER = null; then ac_safe=`echo "dl.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for dl.h""... $ac_c" 1>&6 -echo "configure:2140: checking for dl.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then +echo "configure:2199: checking for dl.h" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2150: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2209: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2171,17 +2230,17 @@ fi if test $DYNAMIC_LINKER = null; then ac_safe=`echo "windows.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for windows.h""... $ac_c" 1>&6 -echo "configure:2175: checking for windows.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then +echo "configure:2234: checking for windows.h" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2185: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2244: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2206,17 +2265,17 @@ fi if test $DYNAMIC_LINKER = null; then ac_safe=`echo "dld/defs.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for dld/defs.h""... $ac_c" 1>&6 -echo "configure:2210: checking for dld/defs.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then +echo "configure:2269: checking for dld/defs.h" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2220: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2279: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2256,19 +2315,19 @@ if test x"$ac_cv_objc_threaded" != x""; then fi LIBS="$LIBS $extra_LIBS" echo $ac_n "checking if +load method is executed before main""... $ac_c" 1>&6 -echo "configure:2260: checking if +load method is executed before main" >&5 -if eval "test \"`echo '$''{'objc_load_method_worked'+set}'`\" = set"; then +echo "configure:2319: checking if +load method is executed before main" >&5 +if eval "test \"\${objc_load_method_worked+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then objc_load_method_worked=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2331: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then objc_load_method_worked=yes else @@ -2303,12 +2362,12 @@ CPPFLAGS="$saved_CPPFLAGS" for ac_func in objc_condition_timedwait do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2307: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then +echo "configure:2366: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2395: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2357,7 +2417,7 @@ done cat > conftest.$ac_ext < EOF @@ -2378,12 +2438,12 @@ LIBS="$saved_LIBS" # Generic settings needed by NSZone.m #-------------------------------------------------------------------- echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:2382: checking for ANSI C header files" >&5 -if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then +echo "configure:2442: checking for ANSI C header files" >&5 +if eval "test \"\${ac_cv_header_stdc+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -2391,7 +2451,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2395: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2455: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2408,7 +2468,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -2426,7 +2486,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -2447,7 +2507,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -2458,7 +2518,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:2462: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2522: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -2482,12 +2542,12 @@ EOF fi echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:2486: checking for size_t" >&5 -if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then +echo "configure:2546: checking for size_t" >&5 +if eval "test \"\${ac_cv_type_size_t+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -2498,38 +2558,40 @@ EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then rm -rf conftest* - ac_cv_type_size_t=yes + eval "ac_cv_type_size_t=yes" else rm -rf conftest* - ac_cv_type_size_t=no + eval "ac_cv_type_size_t=no" fi rm -f conftest* fi -echo "$ac_t""$ac_cv_type_size_t" 1>&6 -if test $ac_cv_type_size_t = no; then - cat >> confdefs.h <<\EOF +if eval "test \"`echo '$ac_cv_type_'size_t`\" = yes"; then + echo "$ac_t""yes" 1>&6 +else + echo "$ac_t""no" 1>&6 + cat >> confdefs.h <&6 -echo "configure:2519: checking for inline" >&5 -if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then +echo "configure:2581: checking for inline" >&5 +if eval "test \"\${ac_cv_c_inline+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2595: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_inline=$ac_kw; break else @@ -2559,12 +2621,12 @@ esac # Following header checks needed for bzero in Storage.m and other places #-------------------------------------------------------------------- echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:2563: checking for ANSI C header files" >&5 -if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then +echo "configure:2625: checking for ANSI C header files" >&5 +if eval "test \"\${ac_cv_header_stdc+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -2572,7 +2634,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2576: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2638: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2589,7 +2651,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -2607,7 +2669,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -2628,7 +2690,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -2639,7 +2701,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:2643: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2705: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -2666,17 +2728,17 @@ for ac_hdr in string.h memory.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2670: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then +echo "configure:2732: checking for $ac_hdr" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2680: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2742: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2710,17 +2772,17 @@ for ac_hdr in values.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2714: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then +echo "configure:2776: checking for $ac_hdr" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2724: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2786: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2754,17 +2816,17 @@ for ac_hdr in sys/stat.h sys/vfs.h sys/statfs.h sys/statvfs.h pwd.h grp.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2758: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then +echo "configure:2820: checking for $ac_hdr" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2768: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2830: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2794,17 +2856,17 @@ for ac_hdr in sys/mount.h sys/types.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2798: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then +echo "configure:2860: checking for $ac_hdr" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2808: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2870: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2833,12 +2895,12 @@ done for ac_func in statvfs do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2837: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then +echo "configure:2899: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2928: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2894,17 +2957,17 @@ for ac_hdr in sys/time.h sys/rusage.h ucbinclude/sys/resource.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2898: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then +echo "configure:2961: checking for $ac_hdr" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2908: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2971: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2938,17 +3001,17 @@ for ac_hdr in sys/socket.h netinet/in.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2942: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then +echo "configure:3005: checking for $ac_hdr" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2952: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3015: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2982,17 +3045,17 @@ for ac_hdr in syslog.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2986: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then +echo "configure:3049: checking for $ac_hdr" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2996: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3059: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -3021,12 +3084,12 @@ done for ac_func in syslog do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3025: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then +echo "configure:3088: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3117: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3080,12 +3144,12 @@ done for ac_func in vsprintf vasprintf do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3084: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then +echo "configure:3148: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3177: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3137,11 +3202,11 @@ if test $ac_cv_func_vsprintf = yes ; then VSPRINTF_RETURNS_LENGTH=1 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3210: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then VSPRINTF_RETURNS_LENGTH=1 else @@ -3163,11 +3228,11 @@ if test $ac_cv_func_vasprintf = yes ; then VASPRINTF_RETURNS_LENGTH=1 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3236: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then VASPRINTF_RETURNS_LENGTH=1 else @@ -3191,12 +3256,12 @@ fi for ac_func in getcwd do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3195: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then +echo "configure:3260: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3289: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3248,12 +3314,12 @@ for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6 -echo "configure:3252: checking for $ac_hdr that defines DIR" >&5 -if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then +echo "configure:3318: checking for $ac_hdr that defines DIR" >&5 +if eval "test \"\${ac_cv_header_dirent_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include <$ac_hdr> @@ -3261,7 +3327,7 @@ int main() { DIR *dirp = 0; ; return 0; } EOF -if { (eval echo configure:3265: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3331: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* eval "ac_cv_header_dirent_$ac_safe=yes" else @@ -3286,15 +3352,15 @@ done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6 -echo "configure:3290: checking for opendir in -ldir" >&5 -ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then +echo "configure:3356: checking for opendir in -ldir" >&5 +ac_lib_var=`echo dir'_'opendir | sed 'y%./+-:%__p__%'` +if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-ldir $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3375: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3327,15 +3393,15 @@ fi else echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6 -echo "configure:3331: checking for opendir in -lx" >&5 -ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then +echo "configure:3397: checking for opendir in -lx" >&5 +ac_lib_var=`echo x'_'opendir | sed 'y%./+-:%__p__%'` +if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lx $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3416: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3376,17 +3442,17 @@ for ac_hdr in getopt.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:3380: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then +echo "configure:3446: checking for $ac_hdr" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3390: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3456: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -3419,12 +3485,12 @@ done for ac_func in valloc do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3423: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then +echo "configure:3489: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3518: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3478,12 +3545,12 @@ done for ac_func in times do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3482: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then +echo "configure:3549: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3578: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3537,12 +3605,12 @@ done for ac_func in mkstemp do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3541: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then +echo "configure:3609: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3638: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3592,12 +3661,12 @@ done for ac_func in shmctl do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3596: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then +echo "configure:3665: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3694: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3647,12 +3717,12 @@ done for ac_func in mmap do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3651: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then +echo "configure:3721: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3750: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3706,12 +3777,12 @@ done for ac_func in inet_aton do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3710: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then +echo "configure:3781: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3810: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3765,12 +3837,12 @@ done for ac_func in killpg setpgrp setpgid do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3769: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then +echo "configure:3841: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3870: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3818,15 +3891,15 @@ fi done echo $ac_n "checking whether setpgrp takes no argument""... $ac_c" 1>&6 -echo "configure:3822: checking whether setpgrp takes no argument" >&5 -if eval "test \"`echo '$''{'ac_cv_func_setpgrp_void'+set}'`\" = set"; then +echo "configure:3895: checking whether setpgrp takes no argument" >&5 +if eval "test \"\${ac_cv_func_setpgrp_void+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then { echo "configure: error: cannot check setpgrp if cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3923: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_setpgrp_void=no else @@ -3876,12 +3949,12 @@ fi for ac_func in usleep do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3880: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then +echo "configure:3953: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3982: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3935,12 +4009,12 @@ done for ac_func in strerror do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3939: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then +echo "configure:4013: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4042: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3992,12 +4067,12 @@ done # This function needed by NSString for handling of %@ printf directive. #-------------------------------------------------------------------- echo $ac_n "checking for register_printf_function""... $ac_c" 1>&6 -echo "configure:3996: checking for register_printf_function" >&5 -if eval "test \"`echo '$''{'ac_cv_func_register_printf_function'+set}'`\" = set"; then +echo "configure:4071: checking for register_printf_function" >&5 +if eval "test \"\${ac_cv_func_register_printf_function+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4100: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_register_printf_function=yes" else @@ -4045,11 +4121,11 @@ if test $register_printf = 1; then working_register_printf=1 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4129: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then working_register_printf=1 else @@ -4075,12 +4151,12 @@ fi for ac_func in realpath do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4079: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then +echo "configure:4155: checking for $ac_func" >&5 +if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4184: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4133,15 +4210,15 @@ done # Used in critical cases by NSProcessInfo.m #-------------------------------------------------------------------- echo $ac_n "checking program_invocation_name in C Library""... $ac_c" 1>&6 -echo "configure:4137: checking program_invocation_name in C Library" >&5 -if eval "test \"`echo '$''{'program_invocation_name_worked'+set}'`\" = set"; then +echo "configure:4214: checking program_invocation_name in C Library" >&5 +if eval "test \"\${program_invocation_name_worked+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then program_invocation_name_worked=no else cat > conftest.$ac_ext < @@ -4153,7 +4230,7 @@ main (int argc, char *argv[]) } EOF -if { (eval echo configure:4157: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4234: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then program_invocation_name_worked=yes else @@ -4182,7 +4259,7 @@ fi # Needed by NSProcessInfo.m #-------------------------------------------------------------------- echo $ac_n "checking kernel support for /proc filesystem""... $ac_c" 1>&6 -echo "configure:4186: checking kernel support for /proc filesystem" >&5 +echo "configure:4263: checking kernel support for /proc filesystem" >&5 if (grep proc /etc/fstab >/dev/null 2>/dev/null); then sys_proc_fs=yes; cat >> confdefs.h <<\EOF @@ -4205,7 +4282,7 @@ fi sys_proc_fs_exe=no; if test $sys_proc_fs = yes; then echo $ac_n "checking link to executable in /proc""... $ac_c" 1>&6 -echo "configure:4209: checking link to executable in /proc" >&5 +echo "configure:4286: checking link to executable in /proc" >&5 if test -L /proc/self/exe; then sys_proc_fs_exe=yes; echo "$ac_t""yes" 1>&6 @@ -4218,16 +4295,16 @@ fi # Check if short and int values need to be word aligned #-------------------------------------------------------------------- echo $ac_n "checking short/int needs to be word aligned""... $ac_c" 1>&6 -echo "configure:4222: checking short/int needs to be word aligned" >&5 +echo "configure:4299: checking short/int needs to be word aligned" >&5 if test "$cross_compiling" = yes; then NEED_WORD_ALIGNMENT=1 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4308: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then NEED_WORD_ALIGNMENT=0 else @@ -4255,7 +4332,7 @@ fi # doesn't work. Allow NSProcessInfo initialization method also. #-------------------------------------------------------------------- echo $ac_n "checking "use of pass-through arguments"""... $ac_c" 1>&6 -echo "configure:4259: checking "use of pass-through arguments"" >&5 +echo "configure:4336: checking "use of pass-through arguments"" >&5 # Check whether --enable-pass-arguments or --disable-pass-arguments was given. if test "${enable_pass_arguments+set}" = set; then enableval="$enable_pass_arguments" @@ -4277,7 +4354,7 @@ fi echo "$ac_t""$enable_pass_arguments" 1>&6 echo $ac_n "checking "use of fake-main definition"""... $ac_c" 1>&6 -echo "configure:4281: checking "use of fake-main definition"" >&5 +echo "configure:4358: checking "use of fake-main definition"" >&5 # Check whether --enable-fake-main or --disable-fake-main was given. if test "${enable_fake_main+set}" = set; then enableval="$enable_fake_main" @@ -4324,17 +4401,17 @@ for ac_hdr in libxml/xmlversion.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4328: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then +echo "configure:4405: checking for $ac_hdr" >&5 +if eval "test \"\${ac_cv_header_$ac_safe+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4338: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4415: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -4367,7 +4444,7 @@ if test $ac_cv_header_libxml_xmlversion_h = no; then HAVE_LIBXML=0 else cat > conftest.$ac_ext <&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4456: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -4498,7 +4575,7 @@ do echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.13" + echo "$CONFIG_STATUS generated by autoconf version 2.13.1" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; @@ -4573,6 +4650,7 @@ s%@ac_cv_sizeof_long@%$ac_cv_sizeof_long%g s%@ac_cv_sizeof_long_long@%$ac_cv_sizeof_long_long%g s%@ac_cv_sizeof_float@%$ac_cv_sizeof_float%g s%@ac_cv_sizeof_double@%$ac_cv_sizeof_double%g +s%@ac_cv_sizeof_voidp@%$ac_cv_sizeof_voidp%g s%@GS_ADDR@%$GS_ADDR%g s%@GS_SINT16@%$GS_SINT16%g s%@GS_UINT16@%$GS_UINT16%g @@ -4809,7 +4887,7 @@ exit 0 EOF chmod +x $CONFIG_STATUS rm -fr confdefs* $ac_clean_files -test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 +test "$no_create" = yes || $SHELL $CONFIG_STATUS || exit 1 if test "$no_recursion" != yes; then @@ -4873,7 +4951,7 @@ if test "$no_recursion" != yes; then # Check for guested configure; otherwise get Cygnus style configure. if test -f $ac_sub_srcdir/configure; then - ac_sub_configure=$ac_sub_srcdir/configure + ac_sub_configure="$SHELL $ac_sub_srcdir/configure" elif test -f $ac_sub_srcdir/configure.in; then ac_sub_configure=$ac_configure else @@ -4891,9 +4969,9 @@ if test "$no_recursion" != yes; then ac_sub_cache_file="$ac_dots$cache_file" ;; esac - echo "running ${CONFIG_SHELL-/bin/sh} $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_sub_srcdir" + echo "running $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_sub_srcdir" # The eval makes quoting arguments work. - if eval ${CONFIG_SHELL-/bin/sh} $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_sub_srcdir + if eval $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_sub_srcdir then : else { echo "configure: error: $ac_sub_configure failed for $ac_config_dir" 1>&2; exit 1; } diff --git a/configure.in b/configure.in index ac4849c26..12fcc022e 100644 --- a/configure.in +++ b/configure.in @@ -306,6 +306,7 @@ AC_SUBST(ac_cv_sizeof_float) AC_CHECK_SIZEOF(double) AC_SUBST(ac_cv_sizeof_double) +AC_SUBST(ac_cv_sizeof_voidp) if test $ac_cv_sizeof_voidp = $ac_cv_sizeof_int; then GS_ADDR="unsigned int" else