From 2b06ef4c58a060d00b739932b47b56795cd347c3 Mon Sep 17 00:00:00 2001 From: netc Date: Sat, 13 Sep 1997 17:52:31 +0000 Subject: [PATCH] Merge in changes from NET-Community. Add DLL support on Windows platforms. Numerous minor bug fixes related to Windows platforms. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2420 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 107 ++++ Headers/gnustep/base/NSDate.h | 1 + Headers/gnustep/base/NSHashTable.h | 7 + Headers/gnustep/base/NSMapTable.h | 34 ++ Headers/gnustep/base/NSObject.h | 13 + Headers/gnustep/base/StdioStream.h | 2 + Headers/gnustep/base/UdpPort.h | 2 +- Headers/gnustep/base/fake-main.h | 2 + Headers/gnustep/base/preface.h.in | 5 + Source/Connection.m | 14 - Source/Makefile.in | 107 +++- Source/NSArchiver.m | 4 - Source/NSBundle.m | 11 +- Source/NSCalendarDate.m | 57 +- Source/NSCharacterSet.m | 8 +- Source/NSDate.m | 2 +- Source/NSDictionary.m | 8 +- Source/NSException.m | 20 +- Source/NSFileManager.m | 175 +++++-- Source/NSHashTable.m | 65 --- Source/NSMapTable.m | 127 ----- Source/NSObject.m | 50 ++ Source/NSProcessInfo.m | 34 +- Source/NSString.m | 163 +++--- Source/NSThread.m | 10 +- Source/NSUser.m | 6 +- Source/NSUserDefaults.m | 28 - Source/RunLoop.m | 268 +++++++++- Source/StdioStream.m | 12 + Source/Stream.m | 2 - Source/TcpPort.m | 15 - Source/Time.m | 6 +- Source/externs.m | 390 ++++++++++++++ Source/find_exec.c | 70 ++- Source/libgnustep-base.def | 811 +++++++++++++++++++++++++++++ Source/o_cbs_char_p.m | 18 - Source/o_cbs_id.m | 18 - Source/o_cbs_int.m | 18 - Source/o_cbs_int_p.m | 18 - Source/o_cbs_void_p.m | 27 - Source/win32-entry.c | 94 ---- Source/win32-entry.m | 182 +++++++ Testing/Makefile.in | 2 +- Testing/NSData-test.m | 8 +- Testing/diningPhilosophers.m | 5 - Testing/nsattributedstring.m | 11 +- Testing/nsbundle.m | 2 + configure.in | 67 ++- 48 files changed, 2409 insertions(+), 697 deletions(-) create mode 100644 Source/externs.m create mode 100644 Source/libgnustep-base.def delete mode 100644 Source/win32-entry.c create mode 100644 Source/win32-entry.m diff --git a/ChangeLog b/ChangeLog index 01175869a..9b9bb629e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,110 @@ +Sat Sep 13 10:05:57 1997 Scott Christley + + * The GNU tools for building a DLL on Windows only allow functions + and not data to be exported; therefore, all global variables were + moved into a separate file, externs.m, and added to the import + library for the DLL so that those variables would be accessible + outside of the DLL. + * configure.in (PIPE): Make the -pipe a configure option. + (DLLTOOL): Add support for building DLLs. + (disable-static): New configure option to disable the building + of the static library when building a shared library. + (pcthread, pthread, m): Add checks for pcthread and math libraries. + (sys/stat.h, sys/vfs.h, sys/statfs.h, statvfs): Add checks + for filesystem related headers and functions. + (getcwd): Remove duplicate check. + * src/win32-entry.c: Rename to win32-entry.m + * src/externs.m: New file. + * src/libgnustep-base.def: New file. + * src/Connection.m: Move all global variables to externs.m. + * src/NSArchive.m: Likewise. + * src/NSBundle.m: Likewise. + Comment out code that would not compile on WIN32. + * src/NSException.m: Likewise. + (dealloc): Release instance variables. + * src/NSFileManager.m: Likewise. + Add WIN32 specific code. + * src/NSHashTable.m: Likewise. + * src/NSMapTable.m: Likewise. + * src/NSThread.m: Likewise. + (-init): Set the thread data first. + * src/NSUserDefaults.m: Likewise. + * src/Stream.m: Likewise. + * src/TcpPort.m: Likewise. + * src/o_cbs_char_p.m: Likewise. + * src/o_cbs_id.m: Likewise. + * src/o_cbs_int.m: Likewise. + * src/o_cbs_int_p.m: Likewise. + * src/o_cbs_void_p.m: Likewise. + + * checks/Makefile.in: Do not link with math library. + * checks/NSData-test.m: Correct directory for include files. + * checks/diningPhilosophers.m (WIN32): Check different macro. + * checks/nsattributedstring.m (main): New function. + * checks/nsbundle.m: Do not include for MINGW32. + + * src/Makefile.in: Add support for building a DLL. Break + out the single install target into multiple targets. + + * src/NSCalendarDate.m (-descriptionWithCalendarFormat:locale:): + Add character string month names. + (short_month, long_month): New static arrays. + * src/NSDate.m (+timeIntervalSinceReferenceDate): Also test _WIN32. + + * src/NSCharacterSet.m (NSCharacterSet_PATH): Don't specify + full path, just bundle directory. + + * src/NSDictionary.m (-initWithContentsOfFile:): Make sure + the returned object is an NSDictionary. + + * src/NSObject.m (initialize): Create global lock. + (-performSelector:, -performSelector:WithObject:) + (-performSelector:withObject:withObject:): New methods. + * src/include/NSObject.h: Add prototype for global lock. + (-performSelector:, -performSelector:WithObject:) + (-performSelector:withObject:withObject:): New methods. + + * src/NSProcessInfo.m (_gnu_process_args): Check if NULL. + For MINGW32, have NSProcessInfo access the global variables directly. + + * src/NSString.m: Add support for different path components + that are supported on WIN32. + (rangeOfCharacterFromSet:options:mask:): Correct assert. + (-componentsSeparatedByString:): Correct calculation of search range. + + * src/NSUser.m: Check _WIN32 macro as well. + * src/Time.m: Likewise. + + * src/RunLoop.m (_AIX): Include header file. + UNIX is vastly different from WIN32 so separate the functionality + into different methods. Move all global variables to externs.m. + (-acceptWIN32InputForMode:beforeDate:): New method. + (-acceptUNIXInputForMode:beforeDate:): New method. + (-acceptInputForMode:beforeDate:): Call the appropriate method + depending upon whether a UNIX or WIN32 system. + + * src/StdioStream.m: Comment out code that would not compile on WIN32. + * src/include/StdioStream.h (-rewindStream): Add prototype. + + * src/find_exec.c: Handle the different path separator in the + PATH environment variable and the different path component + which is supported on WIN32. Also add common WIN32 extensions to + the filename when searching for the executed file. + + * src/include/NSDate.h (-initWithTimeIntervalSince1970:): ADd + missing method prototype. + + * src/include/NSHashTable.h: Move typedefs that were in NSHashTable.m + to here so that externs.m has access to them. + * src/include/NSMapTable.h: Move typedefs that were in NSMapTable.m + to here so that externs.m has access to them. + + * src/include/UdpPort.h (WIN32): Use __WIN32__ macro instead. + + * src/include/fake-main.h: Do not redefine main on MINGW32. + + * src/include/preface.h.in: Add WIN32 specific definition. + Fri Sep 12 12:27:00 1997 Richard Frith-Macdonald * src/NSString.m: Added [-classForPortCoder:]) method for diff --git a/Headers/gnustep/base/NSDate.h b/Headers/gnustep/base/NSDate.h index 079fd3606..101d7712b 100644 --- a/Headers/gnustep/base/NSDate.h +++ b/Headers/gnustep/base/NSDate.h @@ -56,6 +56,7 @@ typedef double NSTimeInterval; - (NSDate*) initWithTimeInterval: (NSTimeInterval)secsToBeAdded sinceDate: (NSDate*)anotherDate; - (NSDate*) initWithTimeIntervalSinceNow: (NSTimeInterval)secsToBeAdded; +- (NSDate*) initWithTimeIntervalSince1970: (NSTimeInterval)seconds; - (id) initWithTimeIntervalSinceReferenceDate: (NSTimeInterval)secs; // Converting to NSCalendar diff --git a/Headers/gnustep/base/NSHashTable.h b/Headers/gnustep/base/NSHashTable.h index 8ebeddd8e..03709cb46 100644 --- a/Headers/gnustep/base/NSHashTable.h +++ b/Headers/gnustep/base/NSHashTable.h @@ -81,6 +81,13 @@ extern const NSHashTableCallBacks NSOwnedPointerHashCallBacks; * struct is the size of an int. */ extern const NSHashTableCallBacks NSPointerToStructHashCallBacks; +/* These are to increase readabilty locally. */ +typedef unsigned int (*NSHT_hash_func_t)(NSHashTable *, const void *); +typedef BOOL (*NSHT_isEqual_func_t)(NSHashTable *, const void *, const void *); +typedef void (*NSHT_retain_func_t)(NSHashTable *, const void *); +typedef void (*NSHT_release_func_t)(NSHashTable *, void *); +typedef NSString *(*NSHT_describe_func_t)(NSHashTable *, const void *); + /**** Function Prototypes ****************************************************/ /** Creating an NSHashTable... **/ diff --git a/Headers/gnustep/base/NSMapTable.h b/Headers/gnustep/base/NSMapTable.h index ec4e85355..ee44838b6 100644 --- a/Headers/gnustep/base/NSMapTable.h +++ b/Headers/gnustep/base/NSMapTable.h @@ -114,6 +114,40 @@ extern const NSMapTableValueCallBacks NSObjectMapValueCallBacks; /* For values that are pointers with transfer of ownership upon insertion. */ extern const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks; +/* This is for keeping track of information... */ +typedef struct _NSMT_extra _NSMT_extra_t; + +struct _NSMT_extra +{ + NSMapTableKeyCallBacks keyCallBacks; + NSMapTableValueCallBacks valueCallBacks; +}; + +/* These are to increase readabilty locally. */ +typedef unsigned int (*NSMT_hash_func_t)(NSMapTable *, const void *); +typedef BOOL (*NSMT_is_equal_func_t)(NSMapTable *, const void *, + const void *); +typedef void (*NSMT_retain_func_t)(NSMapTable *, const void *); +typedef void (*NSMT_release_func_t)(NSMapTable *, void *); +typedef NSString *(*NSMT_describe_func_t)(NSMapTable *, const void *); + +/** Macros... **/ + +#define NSMT_EXTRA(T) \ + ((_NSMT_extra_t *)(o_map_extra((o_map_t *)(T)))) + +#define NSMT_KEY_CALLBACKS(T) \ + ((NSMT_EXTRA((T)))->keyCallBacks) + +#define NSMT_VALUE_CALLBACKS(T) \ + ((NSMT_EXTRA((T)))->valueCallBacks) + +#define NSMT_DESCRIBE_KEY(T, P) \ + NSMT_KEY_CALLBACKS((T)).describe((T), (P)) + +#define NSMT_DESCRIBE_VALUE(T, P) \ + NSMT_VALUE_CALLBACKS((T)).describe((T), (P)) + /**** Function Prototypes ****************************************************/ /** Creating an NSMapTable... **/ diff --git a/Headers/gnustep/base/NSObject.h b/Headers/gnustep/base/NSObject.h index 7823ee5f1..1ff1a8a83 100644 --- a/Headers/gnustep/base/NSObject.h +++ b/Headers/gnustep/base/NSObject.h @@ -27,11 +27,13 @@ #include #include #include +#include @class NSArchiver; @class NSCoder; @class NSPortCoder; @class NSMethodSignature; +@class NSRecursiveLock; @class NSString; @class NSInvocation; @class Protocol; @@ -116,6 +118,11 @@ - (id) replacementObjectForPortCoder: (NSPortCoder*)anEncoder; @end +/* Global lock to be used by classes when operating on any global + data that invoke other methods which also access global; thus, + creating the potential for deadlock. */ +extern NSRecursiveLock *gnustep_global_lock; + NSObject *NSAllocateObject(Class aClass, unsigned extraBytes, NSZone *zone); void NSDeallocateObject(NSObject *anObject); NSObject *NSCopyObject(NSObject *anObject, unsigned extraBytes, NSZone *zone); @@ -151,4 +158,10 @@ enum {NSNotFound = 0x7fffffff}; - write: (TypedStream*)aStream; @end +@interface NSObject (OPENSTEP) +- performSelector: (SEL)aSelector; +- performSelector: (SEL)aSelector withObject: anObject; +- performSelector: (SEL)aSelector withObject: object1 withObject: object2; +@end + #endif /* __NSObject_h_GNUSTEP_BASE_INCLUDE */ diff --git a/Headers/gnustep/base/StdioStream.h b/Headers/gnustep/base/StdioStream.h index 70ca10c3b..0df7016ec 100644 --- a/Headers/gnustep/base/StdioStream.h +++ b/Headers/gnustep/base/StdioStream.h @@ -48,6 +48,8 @@ - initWithPipeTo: (NSString*)systemCommand; - initWithPipeFrom: (NSString*)systemCommand; +- (void) rewindStream; + @end #endif /* __StdioStream_h__GNUSTEP_BASE_INCLUDE */ diff --git a/Headers/gnustep/base/UdpPort.h b/Headers/gnustep/base/UdpPort.h index 970835873..32425ca5e 100644 --- a/Headers/gnustep/base/UdpPort.h +++ b/Headers/gnustep/base/UdpPort.h @@ -27,7 +27,7 @@ #include #include #include -#ifndef WIN32 +#ifndef __WIN32__ # include # include #endif /* !WIN32 */ diff --git a/Headers/gnustep/base/fake-main.h b/Headers/gnustep/base/fake-main.h index 9e5d70a0a..a91a8727a 100644 --- a/Headers/gnustep/base/fake-main.h +++ b/Headers/gnustep/base/fake-main.h @@ -45,8 +45,10 @@ */ #if !defined(__ELF__) && !defined(SYS_AUTOLOAD) +#ifndef __MINGW32__ #define main gnustep_base_user_main extern int gnustep_base_user_main (/* int argc, char *argv[] */); +#endif #endif /* __ELF__ */ /* diff --git a/Headers/gnustep/base/preface.h.in b/Headers/gnustep/base/preface.h.in index 0420a395e..a70df0569 100644 --- a/Headers/gnustep/base/preface.h.in +++ b/Headers/gnustep/base/preface.h.in @@ -30,6 +30,11 @@ #include #include +#if defined(__WIN32__) || defined(_WIN32) +#include +#define GNUSTEP_BASE_SOCKET_MESSAGE (WM_USER + 1) +#endif + #if NeXT_runtime #include #include diff --git a/Source/Connection.m b/Source/Connection.m index efdceb492..cd60cb3cd 100644 --- a/Source/Connection.m +++ b/Source/Connection.m @@ -1476,17 +1476,3 @@ static int messages_received_count; } @end - - -/* Notification Strings. */ - -NSString *ConnectionBecameInvalidNotification -= @"ConnectionBecameInvalidNotification"; - -NSString *ConnectionWasCreatedNotification -= @"ConnectionWasCreatedNotification"; - - -/* RunLoop modes */ -NSString *RunLoopConnectionReplyMode -= @"RunLoopConnectionReplyMode"; diff --git a/Source/Makefile.in b/Source/Makefile.in index 79f97ec63..ac8b5cf78 100644 --- a/Source/Makefile.in +++ b/Source/Makefile.in @@ -31,12 +31,12 @@ VPATH = @srcdir@ # Installation locations prefix = @prefix@ exec_prefix = @exec_prefix@ -bindir = $(exec_prefix)/bin +bindir = @bindir@ libdir = @libdir@ gnustep_libdir = $(libdir)/gnustep includedir = @includedir@ -CC = @CC@ -pipe +CC = @CC@ @PIPE@ LIBS = @LIBS@ RANLIB = @RANLIB@ INSTALL = @INSTALL@ @@ -51,6 +51,7 @@ TEXI2DVI = texi2dvi LEX = flex LEXFLAGS = YACC = bison +DLLTOOL = @DLLTOOL@ # GNUSTEP_INSTALL_PREFIX must be defined here and not in config.h because # the installing person may set it on the `make' command line. @@ -223,8 +224,9 @@ proplist.y \ stringsfile.l \ stringsfile.tab.h \ stringsfile.y \ -win32-entry.c \ -win32-def.top +win32-entry.m \ +win32-def.top \ +libgnustep-base.def GNU_OBJS = \ $(GNU_MFILES:.m=${OEXT}) \ @@ -426,7 +428,8 @@ NSTimeZone.m \ NSUser.m \ NSUserDefaults.m \ NSValue.m \ -NSZone.m +NSZone.m \ +externs.m NSVALUE_MFILES = \ NSValue0.m NSValue1.m NSValue2.m NSValue3.m \ @@ -554,12 +557,13 @@ DIST_FILES = \ $(GNUSTEP_OTHER_SRCFILES) \ $(UNICODE_HEADERS) +IMPORT_LIBRARY=@IMPORT_LIBRARY@ # Targets all: \ gnustep/base Foundation \ -lib$(LIBRARY_NAME)$(LIBEXT) \ +@STATIC_LIBRARY@ \ @SHARED_LIBRARY@ \ gdomap @@ -577,6 +581,42 @@ lib$(LIBRARY_NAME)$(LIBEXT): $(HEADERS_INSTALL) $(OBJS_INSTALL) $(AR) $(ARFLAGS) $(AROUT)lib$(LIBRARY_NAME)$(LIBEXT) $(OBJS_INSTALL) $(RANLIB) lib$(LIBRARY_NAME)$(LIBEXT) +lib$(LIBRARY_NAME)_s$(LIBEXT): $(HEADERS_INSTALL) $(OBJS_INSTALL) + $(AR) $(ARFLAGS) $(AROUT)lib$(LIBRARY_NAME)_s$(LIBEXT) $(OBJS_INSTALL) + $(RANLIB) lib$(LIBRARY_NAME)_s$(LIBEXT) + +lib$(LIBRARY_NAME).def: FORCE + nm @STATIC_LIBRARY@ \ + | grep '^........ [T] _' \ + | sed 's/[^_]*_//' >> lib$(LIBRARY_NAME).lst + cat win32-def.top lib$(LIBRARY_NAME).lst > lib$(LIBRARY_NAME).def + rm lib$(LIBRARY_NAME).lst + +lib$(LIBRARY_NAME).dll: @STATIC_LIBRARY@ win32-entry$(OEXT) + # Link DLL. + $(CC) -dll -Wl,--base-file -Wl,lib$(LIBRARY_NAME).base \ + -o lib$(LIBRARY_NAME).dll win32-entry.o @STATIC_LIBRARY@ \ + -lmoldname -lobjc -lkernel32 -lwsock32 -ladvapi32 -luser32 + $(DLLTOOL) --dllname lib$(LIBRARY_NAME).dll \ + --def lib$(LIBRARY_NAME).def --base-file \ + lib$(LIBRARY_NAME).base --output-exp lib$(LIBRARY_NAME).exp + $(CC) -dll -Wl,--base-file -Wl,lib$(LIBRARY_NAME).base \ + lib$(LIBRARY_NAME).exp \ + -o lib$(LIBRARY_NAME).dll win32-entry.o @STATIC_LIBRARY@ \ + -lmoldname -lobjc -lkernel32 -lwsock32 -ladvapi32 -luser32 + $(DLLTOOL) --dllname lib$(LIBRARY_NAME).dll \ + --def lib$(LIBRARY_NAME).def \ + --base-file lib$(LIBRARY_NAME).base \ + --output-exp lib$(LIBRARY_NAME).exp + $(CC) -dll lib$(LIBRARY_NAME).exp \ + -o lib$(LIBRARY_NAME).dll win32-entry.o @STATIC_LIBRARY@ \ + -lmoldname -lobjc -lkernel32 -lwsock32 -ladvapi32 -luser32 + # Build the import library to link to: + $(DLLTOOL) --dllname lib$(LIBRARY_NAME).dll \ + --def lib$(LIBRARY_NAME).def \ + --output-lib $(IMPORT_LIBRARY) + ar r lib$(LIBRARY_NAME)$(LIBEXT) externs$(OEXT) + # Local links to the include files gnustep/base: $(HEADERS_INSTALL) rm -rf gnustep @@ -597,21 +637,16 @@ Foundation: ../configure $(HEADERS_INSTALL) rm -rf Foundation $(LN_S) $(srcdir)/include Foundation -install: installdirs all - # Install the Distributed Objects name server - $(INSTALL_PROGRAM) -o root -m 04755 gdomap $(bindir) - # Install the library - $(INSTALL_DATA) lib$(LIBRARY_NAME)$(LIBEXT) $(libdir) - $(RANLIB) $(libdir)/lib$(LIBRARY_NAME)$(LIBEXT); \ - if [ -n "@SHARED_LIBRARY@" ]; then \ - $(INSTALL_DATA) lib$(LIBRARY_NAME).so.$(VERSION) $(libdir) ; \ - rm -f $(libdir)/lib$(LIBRARY_NAME).so.$(MAJOR_VERSION) ; \ - rm -f $(libdir)/lib$(LIBRARY_NAME).so ; \ - $(LN_S) $(libdir)/lib$(LIBRARY_NAME).so.$(VERSION) \ - $(libdir)/lib$(LIBRARY_NAME).so.$(MAJOR_VERSION) ; \ - $(LN_S) $(libdir)/lib$(LIBRARY_NAME).so.$(MAJOR_VERSION) \ - $(libdir)/lib$(LIBRARY_NAME).so ; \ - fi +install: all installdirs install-headers install-lib install-apps + +installdirs: + $(srcdir)/../mkinstalldirs \ + $(bindir) \ + $(libdir) \ + $(includedir)/gnustep/base \ + $(includedir)/objc + +install-headers: all # Install the headers for file in $(HEADERS_INSTALL); do \ $(INSTALL_DATA) $(srcdir)/$$file \ @@ -623,11 +658,29 @@ install: installdirs all $(includedir)/objc/`basename $$file` ; \ done -installdirs: - $(srcdir)/../mkinstalldirs \ - $(libdir) \ - $(includedir)/gnustep/base \ - $(includedir)/objc +install-lib: all + # Install the library + $(INSTALL_DATA) lib$(LIBRARY_NAME)$(LIBEXT) $(libdir) + $(RANLIB) $(libdir)/lib$(LIBRARY_NAME)$(LIBEXT); \ + if [ -n "@SHARED_LIBRARY@" ]; then \ + if [ -e lib$(LIBRARY_NAME).so.$(VERSION) ] ; then \ + $(INSTALL_DATA) lib$(LIBRARY_NAME).so.$(VERSION) $(libdir) ; \ + rm -f $(libdir)/lib$(LIBRARY_NAME).so.$(MAJOR_VERSION) ; \ + rm -f $(libdir)/lib$(LIBRARY_NAME).so ; \ + $(LN_S) $(libdir)/lib$(LIBRARY_NAME).so.$(VERSION) \ + $(libdir)/lib$(LIBRARY_NAME).so.$(MAJOR_VERSION) ; \ + $(LN_S) $(libdir)/lib$(LIBRARY_NAME).so.$(MAJOR_VERSION) \ + $(libdir)/lib$(LIBRARY_NAME).so ; \ + fi \ + fi + # Install the DLL if it exists + if [ -e lib$(LIBRARY_NAME).dll ]; then \ + $(INSTALL_DATA) lib$(LIBRARY_NAME).dll $(bindir) ; \ + fi + +install-apps: gdomap + # Install the Distributed Objects name server + -$(INSTALL_PROGRAM) -o root -m 04755 gdomap $(bindir) uninstall: rm -f $(libdir)/lib$(LIBRARY_NAME)$(LIBEXT) @@ -748,6 +801,8 @@ mostlyclean: objc/*~ clean: mostlyclean rm -f lib$(LIBRARY_NAME)$(LIBEXT) *${OEXT} + rm -f lib$(LIBRARY_NAME)_s$(LIBEXT) + rm -f lib$(LIBRARY_NAME).dll rm -f $(NSVALUE_MFILES) $(NSNUMBER_MFILES) rm -f gdomap distclean: clean diff --git a/Source/NSArchiver.m b/Source/NSArchiver.m index 7b831c7d9..f4bc6d11b 100644 --- a/Source/NSArchiver.m +++ b/Source/NSArchiver.m @@ -230,10 +230,6 @@ static Class NSUnarchiver_concrete_class; @end - -/* Exceptions */ -NSString *NSInconsistentArchiveException = @"NSInconsistentArchiveException"; - /* NSObject extensions for archiving */ diff --git a/Source/NSBundle.m b/Source/NSBundle.m index 573983e91..a3dabe1b6 100644 --- a/Source/NSBundle.m +++ b/Source/NSBundle.m @@ -103,9 +103,6 @@ static NSBundle* _loadingBundle = nil; static NSLock* load_lock = nil; static BOOL _strip_after_loading = NO; -NSString* NSBundleDidLoadNotification = @"NSBundleDidLoadNotification"; -NSString* NSShowNonLocalizedStrings = @"NSShowNonLocalizedStrings"; -NSString* NSLoadedClasses = @"NSLoadedClasses"; static NSString* platform = #ifdef PLATFORM_OS @PLATFORM_OS; @@ -156,6 +153,9 @@ _bundle_resource_path(NSString *primary, NSString* bundlePath, NSString *lang) static NSString * _bundle_path_for_name(NSString* path, NSString* name) { +#ifdef __WIN32__ + return nil; +#else DIR *thedir; struct dirent *entry; NSString *fullname; @@ -179,6 +179,7 @@ _bundle_path_for_name(NSString* path, NSString* name) return nil; return [path stringByAppendingPathComponent: fullname]; +#endif } @interface NSBundle (Private) @@ -643,6 +644,8 @@ _bundle_load_callback(Class theClass, Category *theCategory) subPath: bundlePath]; enumerate = [paths objectEnumerator]; resources = [NSMutableArray arrayWithCapacity: 2]; +#ifdef __WIN32__ +#else while((path = [enumerate nextObject])) { DIR *thedir; @@ -667,7 +670,7 @@ _bundle_load_callback(Class theClass, Category *theCategory) closedir(thedir); } } - +#endif return resources; } diff --git a/Source/NSCalendarDate.m b/Source/NSCalendarDate.m index 22810068c..7dcb13933 100644 --- a/Source/NSCalendarDate.m +++ b/Source/NSCalendarDate.m @@ -46,6 +46,35 @@ #define GREGORIAN_REFERENCE 730486 +// +// Short and long month names +// TODO: These should be localized for the language. +// +static id short_month[12] = {@"Jan", + @"Feb", + @"Mar", + @"Apr", + @"May", + @"Jun", + @"Jul", + @"Aug", + @"Sep", + @"Oct", + @"Nov", + @"Dec"}; +static id long_month[12] = {@"January", + @"February", + @"March", + @"April", + @"May", + @"June", + @"July", + @"August", + @"September", + @"October", + @"November", + @"December"}; + @implementation NSCalendarDate @@ -526,7 +555,9 @@ const char *f = [format cString]; int lf = strlen(f); BOOL mtag = NO, dtag = NO, ycent = NO; + BOOL mname = NO; int yd = 0, md = 0, dd = 0, hd = 0, mnd = 0, sd = 0; + int nhd; int i, j, k; // If the format is nil then return an empty string @@ -534,6 +565,7 @@ return @""; [self getYear: &yd month: &md day: &dd hour: &hd minute: &mnd second: &sd]; + nhd = hd; // The strftime specifiers // %a abbreviated weekday name according to locale @@ -588,6 +620,7 @@ // is it the month case 'b': + mname = YES; case 'B': mtag = YES; // Month is character string case 'm': @@ -595,9 +628,10 @@ if (mtag) { // +++ Translate to locale character string - /* was: k = sprintf(&(buf[j]), ""); */ - buf[j] = '\0'; - k = 0; + if (mname) + k = sprintf(&(buf[j]), "%s", [short_month[md-1] cString]); + else + k = sprintf(&(buf[j]), "%s", [long_month[md-1] cString]); } else k = sprintf(&(buf[j]), "%02d", md); @@ -625,10 +659,13 @@ break; // is it the hour - case 'H': case 'I': + nhd = hd % 12; // 12 hour clock + if (hd == 12) + nhd = 12; // 12pm not 0pm + case 'H': ++i; - k = sprintf(&(buf[j]), "%02d", hd); + k = sprintf(&(buf[j]), "%02d", nhd); j += k; break; @@ -646,6 +683,16 @@ j += k; break; + // Is it the am/pm indicator + case 'p': + ++i; + if (hd >= 12) + k = sprintf(&(buf[j]), "PM"); + else + k = sprintf(&(buf[j]), "AM"); + j += k; + break; + // is it the zone name case 'Z': ++i; diff --git a/Source/NSCharacterSet.m b/Source/NSCharacterSet.m index 4849c4e3d..4f8762690 100644 --- a/Source/NSCharacterSet.m +++ b/Source/NSCharacterSet.m @@ -27,9 +27,7 @@ #include #include -static NSString* NSCharacterSet_PATH = -OBJC_STRINGIFY(GNUSTEP_INSTALL_PREFIX) @"/share/NSCharacterSets"; - +static NSString* NSCharacterSet_PATH = @"NSCharacterSets"; static NSString* gnustep_libdir = #ifdef GNUSTEP_INSTALL_LIBDIR @GNUSTEP_INSTALL_LIBDIR; @@ -79,9 +77,6 @@ static NSLock* cache_lock = nil; if (cache_set[number] == nil) { NS_DURING -#if 0 - path = nil; -#else path = [gstep_base_bundle pathForResource:setname ofType:@"dat" inDirectory:NSCharacterSet_PATH]; @@ -92,7 +87,6 @@ static NSLock* cache_lock = nil; ofType:@"dat" inDirectory:@"../NSCharacterSets"]; } -#endif if (path == nil || [path length] == 0) { diff --git a/Source/NSDate.m b/Source/NSDate.m index d26c2da91..56b638836 100644 --- a/Source/NSDate.m +++ b/Source/NSDate.m @@ -63,7 +63,7 @@ + (NSTimeInterval) timeIntervalSinceReferenceDate { -#ifndef __WIN32__ +#if !defined(__WIN32__) && !defined(_WIN32) volatile NSTimeInterval interval; struct timeval tp; diff --git a/Source/NSDictionary.m b/Source/NSDictionary.m index aa0cf68ef..d9a3a02aa 100644 --- a/Source/NSDictionary.m +++ b/Source/NSDictionary.m @@ -186,8 +186,12 @@ static Class NSMutableDictionary_concrete_class; myString = [[NSString alloc] initWithContentsOfFile:path]; if (myString) { - [self initWithDictionary: (NSDictionary*) [myString propertyList]]; - return self; + id result = [myString propertyList]; + if ( [result isKindOfClass: [NSDictionary class]] ) + { + [self initWithDictionary: result]; + return self; + } } [self autorelease]; return nil; diff --git a/Source/NSException.m b/Source/NSException.m index 09ae44976..5ed855b86 100644 --- a/Source/NSException.m +++ b/Source/NSException.m @@ -29,15 +29,6 @@ #include #include -NSString *NSGenericException = @"NSGenericException"; -NSString *NSInternalInconsistencyException - = @"NSInternalInconsistencyException"; -NSString *NSInvalidArgumentException = @"NSInvalidArgumentException"; -NSString *NSMallocException = @"NSMallocException"; -NSString *NSRangeException = @"NSRangeException"; - -NSUncaughtExceptionHandler *_NSUncaughtExceptionHandler; - static volatile void _NSFoundationUncaughtExceptionHandler(NSException *exception) { @@ -97,6 +88,17 @@ _NSFoundationUncaughtExceptionHandler(NSException *exception) return self; } +- (void)dealloc +{ + [e_name release]; + e_name = nil; + [e_reason release]; + e_reason = nil; + [e_info release]; + e_info = nil; + [super dealloc]; +} + - (volatile void)raise { NSThread *thread; diff --git a/Source/NSFileManager.m b/Source/NSFileManager.m index e6ab14d8d..d1eaba39d 100644 --- a/Source/NSFileManager.m +++ b/Source/NSFileManager.m @@ -26,6 +26,8 @@ #include #include +#include +#include /* determine directory reading files */ @@ -59,8 +61,10 @@ # include /* for PATH_MAX */ # include #else +#ifndef __WIN32__ # include /* for MAXPATHLEN */ #endif +#endif #ifndef PATH_MAX # ifdef _POSIX_VERSION @@ -85,7 +89,10 @@ #endif #include + +#ifdef HAVE_SYS_STAT_H #include +#endif /* include usual headers */ @@ -110,11 +117,23 @@ static NSFileManager* defaultManager = nil; + (NSFileManager*)defaultManager { - if (!defaultManager) { - // THREAD - defaultManager = [[self alloc] init]; + if (!defaultManager) + { + NS_DURING + { + [gnustep_global_lock lock]; + defaultManager = [[self alloc] init]; + [gnustep_global_lock unlock]; + } + NS_HANDLER + { + // unlock then re-raise the exception + [gnustep_global_lock unlock]; + [localException raise]; + } + NS_ENDHANDLER } - return defaultManager; + return defaultManager; } // Directory operations @@ -123,12 +142,19 @@ static NSFileManager* defaultManager = nil; { const char* cpath = [self fileSystemRepresentationWithPath:path]; +#if defined(__WIN32__) || defined(_WIN32) + return SetCurrentDirectory(cpath); +#else return (chdir(cpath) == 0); +#endif } - (BOOL)createDirectoryAtPath:(NSString*)path attributes:(NSDictionary*)attributes { +#if defined(__WIN32__) || defined(_WIN32) + return CreateDirectory([path cString], NULL); +#else const char* cpath; char dirpath[PATH_MAX+1]; struct stat statbuf; @@ -168,7 +194,7 @@ static NSFileManager* defaultManager = nil; else { // make new directory if (mkdir(dirpath, 0777) != 0) - return NO; // could not create component + return NO; // could not create component // if last directory and attributes then change if (cur == len && attributes) return [self changeFileAttributes:attributes @@ -178,21 +204,27 @@ static NSFileManager* defaultManager = nil; dirpath[cur] = '/'; cur++; } while (cur < len); - + return YES; +#endif /* WIN32 */ } - (NSString*)currentDirectoryPath { char path[PATH_MAX]; - + +#if defined(__WIN32__) || defined(_WIN32) + if (GetCurrentDirectory(PATH_MAX, path) > PATH_MAX) + return nil; +#else #ifdef HAVE_GETCWD if (getcwd(path, PATH_MAX-1) == NULL) return nil; #else if (getwd(path) == NULL) return nil; -#endif +#endif /* HAVE_GETCWD */ +#endif /* WIN32 */ return [self stringWithFileSystemRepresentation:path length:strlen(path)]; } @@ -280,6 +312,20 @@ static NSFileManager* defaultManager = nil; - (BOOL)fileExistsAtPath:(NSString*)path isDirectory:(BOOL*)isDirectory { +#if defined(__WIN32__) || defined(_WIN32) + DWORD res = GetFileAttributes([path cString]); + if (res == -1) + return NO; + + if (isDirectory) + { + if (res & FILE_ATTRIBUTE_DIRECTORY) + *isDirectory = YES; + else + *isDirectory = NO; + } + return YES; +#else struct stat statbuf; const char* cpath = [self fileSystemRepresentationWithPath:path]; @@ -291,6 +337,7 @@ static NSFileManager* defaultManager = nil; } return YES; +#endif /* WIN32 */ } - (BOOL)isReadableFileAtPath:(NSString*)path @@ -349,7 +396,7 @@ static NSFileManager* defaultManager = nil; NSFilePosixPermissions, NSFileType }; - + if (stat(cpath, &statbuf) != 0) return nil; @@ -380,14 +427,47 @@ static NSFileManager* defaultManager = nil; values[8] = NSFileTypeSocket; else values[8] = NSFileTypeUnknown; - + return [[[NSDictionary alloc] - initWithObjects:values forKeys:keys count:9] + initWithObjects:values forKeys:keys count:5] autorelease]; } - (NSDictionary*)fileSystemAttributesAtPath:(NSString*)path { +#if defined(__WIN32__) || defined(_WIN32) + long long totalsize, freesize; + id values[5]; + id keys[5] = { + NSFileSystemSize, + NSFileSystemFreeSize, + NSFileSystemNodes, + NSFileSystemFreeNodes, + NSFileSystemNumber + }; + DWORD SectorsPerCluster, BytesPerSector, NumberFreeClusters; + DWORD TotalNumberClusters; + const char *cpath = [self fileSystemRepresentationWithPath: path]; + + if (!GetDiskFreeSpace(cpath, &SectorsPerCluster, + &BytesPerSector, &NumberFreeClusters, + &TotalNumberClusters)) + return nil; + + totalsize = TotalNumberClusters * SectorsPerCluster * BytesPerSector; + freesize = NumberFreeClusters * SectorsPerCluster * BytesPerSector; + + values[0] = [NSNumber numberWithLongLong: totalsize]; + values[1] = [NSNumber numberWithLongLong: freesize]; + values[2] = [NSNumber numberWithLong: LONG_MAX]; + values[3] = [NSNumber numberWithLong: LONG_MAX]; + values[4] = [NSNumber numberWithUnsignedInt: 0]; + + return [[[NSDictionary alloc] + initWithObjects:values forKeys:keys count:5] + autorelease]; + +#else #if HAVE_SYS_VFS_H || HAVE_SYS_STATFS_H struct stat statbuf; #if HAVE_STATVFS @@ -433,6 +513,7 @@ static NSFileManager* defaultManager = nil; #else return nil; #endif +#endif /* WIN32 */ } - (BOOL)changeFileAttributes:(NSDictionary*)attributes atPath:(NSString*)path @@ -441,7 +522,8 @@ static NSFileManager* defaultManager = nil; NSNumber* num; NSDate* date; BOOL allOk = YES; - + +#ifndef __WIN32__ num = [attributes objectForKey:NSFileOwnerAccountNumber]; if (num) { allOk &= (chown(cpath, [num intValue], -1) == 0); @@ -451,6 +533,7 @@ static NSFileManager* defaultManager = nil; if (num) { allOk &= (chown(cpath, -1, [num intValue]) == 0); } +#endif num = [attributes objectForKey:NSFilePosixPermissions]; if (num) { @@ -551,7 +634,11 @@ static NSFileManager* defaultManager = nil; const char* lpath = [self fileSystemRepresentationWithPath:path]; const char* npath = [self fileSystemRepresentationWithPath:otherPath]; +#ifdef __WIN32__ + return NO; +#else return (symlink(lpath, npath) == 0); +#endif } - (NSString*)pathContentOfSymbolicLinkAtPath:(NSString*)path @@ -570,7 +657,27 @@ static NSFileManager* defaultManager = nil; - (const char*)fileSystemRepresentationWithPath:(NSString*)path { +#if defined(__WIN32__) || defined(_WIN32) + char cpath[4]; + char *fspath = [path cString]; + + // Check if path specifies drive number or is current drive + if (fspath[0] && (fspath[1] == ':')) + { + cpath[0] = fspath[0]; + cpath[1] = fspath[1]; + cpath[2] = '\\'; + cpath[3] = '\0'; + } + else + { + cpath[0] = '\\'; + cpath[1] = '\0'; + } + return [[NSString stringWithCString: cpath] cString]; +#else return [[[path copy] autorelease] cString]; +#endif } - (NSString*)stringWithFileSystemRepresentation:(const char*)string @@ -596,6 +703,8 @@ static NSFileManager* defaultManager = nil; */ - (void)recurseIntoDirectory:(NSString*)path relativeName:(NSString*)name { +#ifdef __WIN32__ +#else const char* cpath; DIR* dir; @@ -608,6 +717,7 @@ static NSFileManager* defaultManager = nil; [pathStack addObject:name]; [enumStack addObject:[NSValue valueWithPointer:dir]]; } +#endif } /* @@ -618,7 +728,10 @@ static NSFileManager* defaultManager = nil; */ - (void)backtrack { +#ifdef __WIN32__ +#else closedir((DIR*)[[enumStack lastObject] pointerValue]); +#endif [enumStack removeLastObject]; [pathStack removeLastObject]; [currentFileName release]; @@ -639,6 +752,8 @@ static NSFileManager* defaultManager = nil; */ - (void)findNextFile { +#ifdef __WIN32__ +#else NSFileManager* manager = [NSFileManager defaultManager]; DIR_enum_state* dir; DIR_enum_item* dirbuf; @@ -688,6 +803,7 @@ static NSFileManager* defaultManager = nil; else [self backtrack]; } +#endif } // Initializing @@ -772,38 +888,3 @@ static NSFileManager* defaultManager = nil; - (NSNumber*)filePosixPermissions; {return [self objectForKey:NSFilePosixPermissions];} @end - -/* - * File attributes names - */ - -/* File Attributes */ - -NSString* NSFileSize = @"NSFileSize"; -NSString* NSFileModificationDate = @"NSFileModificationDate"; -NSString* NSFileOwnerAccountNumber = @"NSFileOwnerAccountNumber"; -NSString* NSFileGroupOwnerAccountNumber = @"NSFileGroupOwnerAccountNumber"; -NSString* NSFileReferenceCount = @"NSFileReferenceCount"; -NSString* NSFileIdentifier = @"NSFileIdentifier"; -NSString* NSFileDeviceIdentifier = @"NSFileDeviceIdentifier"; -NSString* NSFilePosixPermissions = @"NSFilePosixPermissions"; -NSString* NSFileType = @"NSFileType"; - -/* File Types */ - -NSString* NSFileTypeDirectory = @"NSFileTypeDirectory"; -NSString* NSFileTypeRegular = @"NSFileTypeRegular"; -NSString* NSFileTypeSymbolicLink = @"NSFileTypeSymbolicLink"; -NSString* NSFileTypeSocket = @"NSFileTypeSocket"; -NSString* NSFileTypeFifo = @"NSFileTypeFifo"; -NSString* NSFileTypeCharacterSpecial = @"NSFileTypeCharacterSpecial"; -NSString* NSFileTypeBlockSpecial = @"NSFileTypeBlockSpecial"; -NSString* NSFileTypeUnknown = @"NSFileTypeUnknown"; - -/* FileSystem Attributes */ - -NSString* NSFileSystemSize = @"NSFileSystemSize"; -NSString* NSFileSystemFreeSize = @"NSFileSystemFreeSize"; -NSString* NSFileSystemNodes = @"NSFileSystemNodes"; -NSString* NSFileSystemFreeNodes = @"NSFileSystemFreeNodes"; -NSString* NSFileSystemNumber = @"NSFileSystemNumber"; diff --git a/Source/NSHashTable.m b/Source/NSHashTable.m index 87357f554..5139c72ad 100644 --- a/Source/NSHashTable.m +++ b/Source/NSHashTable.m @@ -32,71 +32,6 @@ #include #include "NSCallBacks.h" -/**** Type, Constant, and Macro Definitions **********************************/ - -/* These are to increase readabilty locally. */ -typedef unsigned int (*NSHT_hash_func_t)(NSHashTable *, const void *); -typedef BOOL (*NSHT_isEqual_func_t)(NSHashTable *, const void *, const void *); -typedef void (*NSHT_retain_func_t)(NSHashTable *, const void *); -typedef void (*NSHT_release_func_t)(NSHashTable *, void *); -typedef NSString *(*NSHT_describe_func_t)(NSHashTable *, const void *); - -/** Standard NSHashTable callbacks... **/ - -const NSHashTableCallBacks NSIntHashCallBacks = -{ - (NSHT_hash_func_t) _NS_int_hash, - (NSHT_isEqual_func_t) _NS_int_is_equal, - (NSHT_retain_func_t) _NS_int_retain, - (NSHT_release_func_t) _NS_int_release, - (NSHT_describe_func_t) _NS_int_describe -}; - -const NSHashTableCallBacks NSNonOwnedPointerHashCallBacks = -{ - (NSHT_hash_func_t) _NS_owned_void_p_hash, - (NSHT_isEqual_func_t) _NS_owned_void_p_is_equal, - (NSHT_retain_func_t) _NS_owned_void_p_retain, - (NSHT_release_func_t) _NS_owned_void_p_release, - (NSHT_describe_func_t) _NS_owned_void_p_describe -}; - -const NSHashTableCallBacks NSNonRetainedObjectHashCallBacks = -{ - (NSHT_hash_func_t) _NS_non_retained_id_hash, - (NSHT_isEqual_func_t) _NS_non_retained_id_is_equal, - (NSHT_retain_func_t) _NS_non_retained_id_retain, - (NSHT_release_func_t) _NS_non_retained_id_release, - (NSHT_describe_func_t) _NS_non_retained_id_describe -}; - -const NSHashTableCallBacks NSObjectsHashCallBacks = -{ - (NSHT_hash_func_t) _NS_id_hash, - (NSHT_isEqual_func_t) _NS_id_is_equal, - (NSHT_retain_func_t) _NS_id_retain, - (NSHT_release_func_t) _NS_id_release, - (NSHT_describe_func_t) _NS_id_describe -}; - -const NSHashTableCallBacks NSOwnedPointerHashCallBacks = -{ - (NSHT_hash_func_t) _NS_owned_void_p_hash, - (NSHT_isEqual_func_t) _NS_owned_void_p_is_equal, - (NSHT_retain_func_t) _NS_owned_void_p_retain, - (NSHT_release_func_t) _NS_owned_void_p_release, - (NSHT_describe_func_t) _NS_owned_void_p_describe -}; - -const NSHashTableCallBacks NSPointerToStructHashCallBacks = -{ - (NSHT_hash_func_t) _NS_int_p_hash, - (NSHT_isEqual_func_t) _NS_int_p_is_equal, - (NSHT_retain_func_t) _NS_int_p_retain, - (NSHT_release_func_t) _NS_int_p_release, - (NSHT_describe_func_t) _NS_int_p_describe -}; - /** Macros... **/ #define NSHT_CALLBACKS(T) \ diff --git a/Source/NSMapTable.m b/Source/NSMapTable.m index d6be56669..f4606e722 100644 --- a/Source/NSMapTable.m +++ b/Source/NSMapTable.m @@ -33,133 +33,6 @@ #include #include "NSCallBacks.h" -/**** Type, Constant, and Macro Definitions **********************************/ - -/* This is for keeping track of information... */ -typedef struct _NSMT_extra _NSMT_extra_t; - -struct _NSMT_extra -{ - NSMapTableKeyCallBacks keyCallBacks; - NSMapTableValueCallBacks valueCallBacks; -}; - -/* These are to increase readabilty locally. */ -typedef unsigned int (*NSMT_hash_func_t)(NSMapTable *, const void *); -typedef BOOL (*NSMT_is_equal_func_t)(NSMapTable *, const void *, - const void *); -typedef void (*NSMT_retain_func_t)(NSMapTable *, const void *); -typedef void (*NSMT_release_func_t)(NSMapTable *, void *); -typedef NSString *(*NSMT_describe_func_t)(NSMapTable *, const void *); - -const NSMapTableKeyCallBacks NSIntMapKeyCallBacks = -{ - (NSMT_hash_func_t) _NS_int_hash, - (NSMT_is_equal_func_t) _NS_int_is_equal, - (NSMT_retain_func_t) _NS_int_retain, - (NSMT_release_func_t) _NS_int_release, - (NSMT_describe_func_t) _NS_int_describe, - 0 -}; - -const NSMapTableKeyCallBacks NSNonOwnedPointerMapKeyCallBacks = -{ - (NSMT_hash_func_t) _NS_non_owned_void_p_hash, - (NSMT_is_equal_func_t) _NS_non_owned_void_p_is_equal, - (NSMT_retain_func_t) _NS_non_owned_void_p_retain, - (NSMT_release_func_t) _NS_non_owned_void_p_release, - (NSMT_describe_func_t) _NS_non_owned_void_p_describe, - 0 -}; - -const NSMapTableKeyCallBacks NSNonOwnedPointerOrNullMapKeyCallBacks = -{ - (NSMT_hash_func_t) _NS_non_owned_void_p_hash, - (NSMT_is_equal_func_t) _NS_non_owned_void_p_is_equal, - (NSMT_retain_func_t) _NS_non_owned_void_p_retain, - (NSMT_release_func_t) _NS_non_owned_void_p_release, - (NSMT_describe_func_t) _NS_non_owned_void_p_describe, - /* FIXME: Oh my. Is this really ok? I did it in a moment of - * weakness. A fit of madness, I say! And if this is wrong, what - * *should* it be?!? */ - (const void *)-1 -}; - -const NSMapTableKeyCallBacks NSNonRetainedObjectMapKeyCallBacks = -{ - (NSMT_hash_func_t) _NS_non_retained_id_hash, - (NSMT_is_equal_func_t) _NS_non_retained_id_is_equal, - (NSMT_retain_func_t) _NS_non_retained_id_retain, - (NSMT_release_func_t) _NS_non_retained_id_release, - (NSMT_describe_func_t) _NS_non_retained_id_describe, - 0 -}; - -const NSMapTableKeyCallBacks NSObjectMapKeyCallBacks = -{ - (NSMT_hash_func_t) _NS_id_hash, - (NSMT_is_equal_func_t) _NS_id_is_equal, - (NSMT_retain_func_t) _NS_id_retain, - (NSMT_release_func_t) _NS_id_release, - (NSMT_describe_func_t) _NS_id_describe, - 0 -}; - -const NSMapTableKeyCallBacks NSOwnedPointerMapKeyCallBacks = -{ - (NSMT_hash_func_t) _NS_owned_void_p_hash, - (NSMT_is_equal_func_t) _NS_owned_void_p_is_equal, - (NSMT_retain_func_t) _NS_owned_void_p_retain, - (NSMT_release_func_t) _NS_owned_void_p_release, - (NSMT_describe_func_t) _NS_owned_void_p_describe, - 0 -}; - -const NSMapTableValueCallBacks NSIntMapValueCallBacks = -{ - (NSMT_retain_func_t) _NS_int_retain, - (NSMT_release_func_t) _NS_int_release, - (NSMT_describe_func_t) _NS_int_describe -}; - -const NSMapTableValueCallBacks NSNonOwnedPointerMapValueCallBacks = -{ - (NSMT_retain_func_t) _NS_non_owned_void_p_retain, - (NSMT_release_func_t) _NS_non_owned_void_p_release, - (NSMT_describe_func_t) _NS_non_owned_void_p_describe -}; - -const NSMapTableValueCallBacks NSObjectMapValueCallBacks = -{ - (NSMT_retain_func_t) _NS_id_retain, - (NSMT_release_func_t) _NS_id_release, - (NSMT_describe_func_t) _NS_id_describe -}; - -const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks = -{ - (NSMT_retain_func_t) _NS_owned_void_p_retain, - (NSMT_release_func_t) _NS_owned_void_p_release, - (NSMT_describe_func_t) _NS_owned_void_p_describe -}; - -/** Macros... **/ - -#define NSMT_EXTRA(T) \ - ((_NSMT_extra_t *)(o_map_extra((o_map_t *)(T)))) - -#define NSMT_KEY_CALLBACKS(T) \ - ((NSMT_EXTRA((T)))->keyCallBacks) - -#define NSMT_VALUE_CALLBACKS(T) \ - ((NSMT_EXTRA((T)))->valueCallBacks) - -#define NSMT_DESCRIBE_KEY(T, P) \ - NSMT_KEY_CALLBACKS((T)).describe((T), (P)) - -#define NSMT_DESCRIBE_VALUE(T, P) \ - NSMT_VALUE_CALLBACKS((T)).describe((T), (P)) - /** Dummy callbacks... **/ size_t diff --git a/Source/NSObject.m b/Source/NSObject.m index a8a25e13d..daa332f96 100644 --- a/Source/NSObject.m +++ b/Source/NSObject.m @@ -122,6 +122,9 @@ extraRefCount (id anObject) { if (self == [NSObject class]) { + // Create the global lock + gnustep_global_lock = [[NSRecursiveLock alloc] init]; + retain_counts = o_map_with_callbacks (o_callbacks_for_non_owned_void_p, o_callbacks_for_int); retain_counts_gate = objc_mutex_allocate (); @@ -746,3 +749,50 @@ extraRefCount (id anObject) } @end + + +@implementation NSObject (OPENSTEP) + +/* OPENSTEP Object class extensions + as distinquished from the OpenStep specification. */ + +- performSelector: (SEL)aSelector +{ + IMP msg = objc_msg_lookup(self, aSelector); + if (!msg) + { + [NSException + raise: NSGenericException + format: @"invalid selector passed to %s", sel_get_name(_cmd)]; + return nil; + } + return (*msg)(self, aSelector); +} + +- performSelector: (SEL)aSelector withObject: anObject +{ + IMP msg = objc_msg_lookup(self, aSelector); + if (!msg) + { + [NSException + raise: NSGenericException + format: @"invalid selector passed to %s", sel_get_name(_cmd)]; + return nil; + } + return (*msg)(self, aSelector, anObject); +} + +- performSelector: (SEL)aSelector withObject: object1 withObject: object2 +{ + IMP msg = objc_msg_lookup(self, aSelector); + if (!msg) + { + [NSException + raise: NSGenericException + format: @"invalid selector passed to %s", sel_get_name(_cmd)]; + return nil; + } + return (*msg)(self, aSelector, object1, object2); +} + +@end diff --git a/Source/NSProcessInfo.m b/Source/NSProcessInfo.m index da9c49880..7ccaa250a 100644 --- a/Source/NSProcessInfo.m +++ b/Source/NSProcessInfo.m @@ -152,12 +152,15 @@ _gnu_process_args(int argc, char *argv[], char *env[]) while (env[i]) { cp = strchr(env[i],'='); - /* Temporary set *cp to \0 for copying purposes */ - *cp = '\0'; - [keys addObject: [NSString stringWithCString:env[i]]]; - [values addObject: [NSString stringWithCString:cp+1]]; - /* Return the original value of environ[i] */ - *cp = '='; + if (cp != NULL) + { + /* Temporary set *cp to \0 for copying purposes */ + *cp = '\0'; + [keys addObject: [NSString stringWithCString:env[i]]]; + [values addObject: [NSString stringWithCString:cp+1]]; + /* Return the original value of environ[i] */ + *cp = '='; + } i++; } _gnu_environment = [[NSDictionary alloc] initWithObjects:values @@ -260,7 +263,21 @@ __attribute__ ((section ("__libc_subinit"))) = &(_gnu_process_noobjc_args); #else static void * __gnustep_base_subinit_args__ __attribute__ ((section ("_libc_subinit"))) = &(_gnu_process_args); -#endif +#endif /* linux */ + +#else +#ifdef __MINGW32__ +/* For Windows32API Library, we know the global variables */ +extern int __argc; +extern char** __argv; +extern char** _environ; + ++ (void)initialize +{ + if (self == [NSProcessInfo class]) + _gnu_process_args(__argc, __argv, _environ); +} + #else #undef main int main(int argc, char *argv[], char *env[]) @@ -285,7 +302,8 @@ int main(int argc, char *argv[], char *env[]) /* Call the user defined main function */ return gnustep_base_user_main (argc, argv, env); } -#endif +#endif /* __MINGW32__ */ +#endif /* __ELF__ */ /************************************************************************* *** Getting an NSProcessInfo Object diff --git a/Source/NSString.m b/Source/NSString.m index 711a359f5..334089295 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -71,6 +71,19 @@ // #define DEFAULT_ENCODING NSISOLatin1StringEncoding // #define DEFAULT_ENCODING NSCyrillicStringEncoding +#if defined(__WIN32__) || defined(_WIN32) + +#define PATH_COMPONENT @"\\" +#define PATH_COMPONENT_LEN 1 +#define PATH_COMPONENT2 @"/" +#define PATH_COMPONENT_LEN2 1 + +#else + +#define PATH_COMPONENT @"/" +#define PATH_COMPONENT_LEN 1 + +#endif /* Path components */ @implementation NSString @@ -496,13 +509,15 @@ handle_printf_atsign (FILE *stream, - (id) initWithContentsOfFile: (NSString*)path { /* xxx Maybe this should use StdioStream? */ -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(_WIN32) NSMutableString *s = [NSMutableString stringWithCString:""]; DWORD dwread; char bytes[1024]; BOOL res, done = NO; HANDLE fd = CreateFile([path cString], GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL); + if (fd == -1) + return nil; while (!done) { @@ -606,22 +621,23 @@ handle_printf_atsign (FILE *stream, - (NSArray*) componentsSeparatedByString: (NSString*)separator { - NSRange search; + NSRange search, complete; NSRange found; NSMutableArray *array = [NSMutableArray array]; search = NSMakeRange (0, [self length]); + complete = search; found = [self rangeOfString: separator]; while (found.length) { NSRange current; + current = NSMakeRange (search.location, found.location - search.location); [array addObject: [self substringFromRange: current]]; + search = NSMakeRange (found.location + found.length, - search.length - (found.location + - found.length - - search.location) ); + complete.length - found.location - found.length); found = [self rangeOfString: separator options: 0 range: search]; @@ -677,7 +693,7 @@ handle_printf_atsign (FILE *stream, NSRange range; /* xxx check to make sure aRange is within self; raise NSStringBoundsError */ - assert(NSMaxRange(aRange) < [self length]); + assert(NSMaxRange(aRange) <= [self length]); if ((mask & NSBackwardsSearch) == NSBackwardsSearch) { @@ -1615,79 +1631,6 @@ else - (NSString*) description { return self; -#if 0 - const char *src = [self cString]; - char *dest; - char *src_ptr,*dest_ptr; - int len,quote; - unsigned char ch; - NSString *ret; - - /* xxx Really should make this work with unichars. */ - -#define inrange(ch,min,max) ((ch)>=(min) && (ch)<=(max)) -#define noquote(ch) (inrange(ch,'a','z') || inrange(ch,'A','Z') || inrange(ch,'0','9') || ((ch)=='_') || ((ch)=='.') || ((ch)=='$')) -#define charesc(ch) (inrange(ch,07,014) || ((ch)=='\"') || ((ch)=='\\')) -#define numesc(ch) (((ch)<=06) || inrange(ch,015,037) || ((ch)>0176)) - - for (src_ptr = (char*)src, len=0,quote=0; - (ch=*src_ptr); - src_ptr++, len++) - { - if (!noquote(ch)) - { - quote=1; - if (charesc(ch)) - len++; - else if (numesc(ch)) - len+=3; - } - } - if (quote) - len+=2; - - dest = (char*) objc_malloc (len+1); - - src_ptr = (char*) src; - dest_ptr = dest; - if (quote) - *(dest_ptr++) = '\"'; - for (; (ch=*src_ptr); src_ptr++,dest_ptr++) - { - if (charesc(ch)) - { - *(dest_ptr++) = '\\'; - switch (ch) - { - case '\a': *dest_ptr = 'a'; break; - case '\b': *dest_ptr = 'b'; break; - case '\t': *dest_ptr = 't'; break; - case '\n': *dest_ptr = 'n'; break; - case '\v': *dest_ptr = 'v'; break; - case '\f': *dest_ptr = 'f'; break; - default: *dest_ptr = ch; /* " or \ */ - } - } - else if (numesc(ch)) - { - *(dest_ptr++) = '\\'; - *(dest_ptr++) = '0' + ((ch>>6)&07); - *(dest_ptr++) = '0' + ((ch>>3)&07); - *dest_ptr = '0' + (ch&07); - } - else - { /* copy literally */ - *dest_ptr = ch; - } - } - if (quote) - *(dest_ptr++) = '\"'; - *dest_ptr = '\0'; - - ret = [NSString stringWithCString:dest]; - objc_free (dest); - return ret; -#endif } @@ -1887,22 +1830,44 @@ else NSRange range; NSString *substring = nil; - range = [self rangeOfString:@"/" options:NSBackwardsSearch]; + range = [self rangeOfString: PATH_COMPONENT options:NSBackwardsSearch]; if (range.length == 0) - substring = [[self copy] autorelease]; - else if (range.location == [self length] - 1) + substring = [[self copy] autorelease]; + else if (range.location == ([self length] - PATH_COMPONENT_LEN)) { if (range.location == 0) - substring = [[NSString new] autorelease]; + substring = [[NSString new] autorelease]; else - substring = [[self substringToIndex:range.location] - lastPathComponent]; + substring = [[self substringToIndex:range.location] + lastPathComponent]; } else - substring = [self substringFromIndex:range.location+1]; + substring = [self substringFromIndex:range.location + PATH_COMPONENT_LEN]; + +#ifdef PATH_COMPONENT2 + if (substring == self) + { + NSRange range2 = [self rangeOfString: PATH_COMPONENT2 + options:NSBackwardsSearch]; + if (range2.length == 0) + substring = [[self copy] autorelease]; + else if (range2.location == ([self length] - PATH_COMPONENT_LEN2)) + { + if (range2.location == 0) + substring = [[NSString new] autorelease]; + else + substring = [[self substringToIndex:range2.location] + lastPathComponent]; + } + else + substring = [self substringFromIndex: + range2.location + PATH_COMPONENT_LEN2]; + } +#endif /* PATH_COMPONENT2 */ return substring; } + /* Returns a new string containing the path extension of the receiver. The path extension is a suffix on the last path component which starts with a '.' (for example .tiff is the pathExtension for /foo/bar.tiff). Returns @@ -1914,11 +1879,27 @@ else range = [self rangeOfString:@"." options:NSBackwardsSearch]; if (range.length == 0 - || range.location - < ([self rangeOfString:@"/" options:NSBackwardsSearch]).location) - substring = [[NSString new] autorelease]; + || range.location < ([self rangeOfString: PATH_COMPONENT + options:NSBackwardsSearch]).location) + substring = nil; else - substring = [self substringFromIndex:range.location+1]; + substring = [self substringFromIndex:range.location + PATH_COMPONENT_LEN]; + +#ifdef PATH_COMPONENT2 + if (!substring) + { + if (range.length == 0 + || range.location < ([self rangeOfString: PATH_COMPONENT2 + options:NSBackwardsSearch]).location) + substring = nil; + else + substring = [self substringFromIndex: + range.location + PATH_COMPONENT_LEN2]; + } +#endif + + if (!substring) + substring = [[NSString new] autorelease]; return substring; } @@ -1992,7 +1973,7 @@ else else if (range.location > 1) substring = [self substringToIndex:range.location-1]; else - substring = @"/"; + substring = PATH_COMPONENT; return substring; } diff --git a/Source/NSThread.m b/Source/NSThread.m index 0305213d9..cc22995c6 100644 --- a/Source/NSThread.m +++ b/Source/NSThread.m @@ -28,10 +28,6 @@ #include #include -// Notifications -NSString *NSBecomingMultiThreaded = @"NSBecomingMultiThreadedNotification"; -NSString *NSThreadExiting = @"NSThreadExitingNotification"; - // Class variables #define USING_THREAD_COLLECTION 0 @@ -78,14 +74,14 @@ static BOOL entered_multi_threaded_state; { [super init]; + /* Make it easy and fast to get this NSThread object from the thread. */ + objc_thread_set_data (self); + /* initialize our ivars. */ _thread_dictionary = nil; // Initialize this later only when needed _exception_handler = NULL; init_autorelease_thread_vars (&_autorelease_vars); - /* Make it easy and fast to get this NSThread object from the thread. */ - objc_thread_set_data (self); - #if USING_THREAD_COLLECTION /* Register ourselves in the maptable of all threads. */ // Lock the thread list so it doesn't change on us diff --git a/Source/NSUser.m b/Source/NSUser.m index 40fd6a842..fbcecca9d 100644 --- a/Source/NSUser.m +++ b/Source/NSUser.m @@ -25,7 +25,7 @@ #include #include #include // for getenv() -#ifndef __WIN32__ +#if !defined(__WIN32__) && !defined(_WIN32) #include // for getlogin() #include // for getpwnam() #endif @@ -35,7 +35,7 @@ NSString * NSUserName () { -#if __WIN32__ +#if defined(__WIN32__) || defined(_WIN32) /* The GetUserName function returns the current user name */ char buf[1024]; DWORD n = 1024; @@ -78,7 +78,7 @@ NSHomeDirectory () NSString * NSHomeDirectoryForUser (NSString *login_name) { -#ifndef __WIN32__ +#if !defined(__WIN32__) && !defined(_WIN32) struct passwd *pw; pw = getpwnam ([login_name cStringNoCopy]); return [NSString stringWithCString: pw->pw_dir]; diff --git a/Source/NSUserDefaults.m b/Source/NSUserDefaults.m index 052429841..1d4e4e728 100644 --- a/Source/NSUserDefaults.m +++ b/Source/NSUserDefaults.m @@ -55,34 +55,6 @@ static NSString* GNU_UserDefaultsDatabese = @"./GNUStep/.GNUstepDefaults"; static NSString* GNU_UserDefaultsDatabeseLock = @"./GNUStep/.GNUstepUDLock"; -/************************************************************************* - *** C O N S T A N T S - *************************************************************************/ -/* Standard domains */ -NSString* NSArgumentDomain = @"NSArgumentDomain"; -NSString* NSGlobalDomain = @"NSGlobalDomain"; -NSString* NSRegistrationDomain = @"NSRegistrationDomain"; - -/* Public notification */ -NSString *NSUserDefaultsChanged = @"NSUserDefaultsChanged"; - -/* Keys for language-dependent information */ -NSString *NSWeekDayNameArray = @"NSWeekDayNameArray"; -NSString *NSShortWeekDayNameArray = @"NSShortWeekDayNameArray"; -NSString *NSMonthNameArray = @"NSMonthNameArray"; -NSString *NSShortMonthNameArray = @"NSShortMonthNameArray"; -NSString *NSTimeFormatString = @"NSTimeFormatString"; -NSString *NSDateFormatString = @"NSDateFormatString"; -NSString *NSTimeDateFormatString = @"NSTimeDateFormatString"; -NSString *NSShortTimeDateFormatString = @"NSShortTimeDateFormatString"; -NSString *NSCurrencySymbol = @"NSCurrencySymbol"; -NSString *NSDecimalSeparator = @"NSDecimalSeparator"; -NSString *NSThousandsSeparator = @"NSThousandsSeparator"; -NSString *NSInternationalCurrencyString = @"NSInternationalCurrencyString"; -NSString *NSCurrencyString = @"NSCurrencyString"; -NSString *NSDecimalDigits = @"NSDecimalDigits"; -NSString *NSAMPMDesignation = @"NSAMPMDesignation"; - /************************************************************************* *** Local method definitions *************************************************************************/ diff --git a/Source/RunLoop.m b/Source/RunLoop.m index 273565910..cba791801 100644 --- a/Source/RunLoop.m +++ b/Source/RunLoop.m @@ -63,9 +63,15 @@ #include #include #include + +#ifdef _AIX +#include +#endif /* AIX */ + #ifndef __WIN32__ #include #endif /* !__WIN32__ */ + #include #include /* for memset() */ @@ -335,10 +341,6 @@ static RunLoop *current_run_loop; { /* Linux doesn't always return double from methods, even though I'm using -lieee. */ -#if 0 - assert (mode); - return nil; -#else Heap *timers; NSTimer *min_timer = nil; id saved_mode; @@ -387,15 +389,242 @@ static RunLoop *current_run_loop; [[min_timer fireDate] timeIntervalSinceReferenceDate]); return [min_timer fireDate]; -#endif } -/* Listen to input sources. - If LIMIT_DATE is nil, then don't wait; i.e. call select() with 0 timeout */ -- (void) acceptInputForMode: (NSString*)mode - beforeDate: limit_date +/* + Because WIN32 is so vastly different from UNIX in the way it + waits on file descriptors, sockets, and the event queue, I have + separated them out into complete separate methods. This will make + it much easier to maintain and read versus if it was all jumbled + together into a single method. + + Note that only one of the two methods will actually be compiled. + */ + +#if defined(__WIN32__) || (_WIN32) + +/* Private method + Perform WIN32 style mechanism to wait on multiple inputs */ +- (void) acceptWIN32InputForMode: (NSString*)mode + beforeDate: limit_date +{ + DWORD wait_count = 0; + HANDLE handle_list[MAXIMUM_WAIT_OBJECTS - 1]; + DWORD wait_timeout; + struct timeval timeout; + void *select_timeout; + fd_set fds; /* The file descriptors we will listen to. */ + fd_set read_fds; /* Copy for listening to read-ready fds. */ + fd_set exception_fds; /* Copy for listening to exception fds. */ + fd_set write_fds; /* Copy for listening for write-ready fds. */ + int select_return; + int fd_index; + NSMapTable *fd_2_object; + NSTimeInterval ti; + id saved_mode; + DWORD wait_return; + id ports; + int num_of_ports; + int port_fd_count = 128; // xxx #define this constant + int port_fd_array[port_fd_count]; + + assert (mode); + saved_mode = _current_mode; + _current_mode = mode; + + /* Find out how much time we should wait, and set SELECT_TIMEOUT. */ + if (!limit_date) + { + /* Don't wait at all. */ + timeout.tv_sec = 0; + timeout.tv_usec = 0; + select_timeout = &timeout; + wait_timeout = 0; + } + else if ((ti = [limit_date timeIntervalSinceNow]) < LONG_MAX + && ti > 0.0) + { + /* Wait until the LIMIT_DATE. */ + if (debug_run_loop) + printf ("\tRunLoop accept input before %f (seconds from now %f)\n", + [limit_date timeIntervalSinceReferenceDate], ti); + /* If LIMIT_DATE has already past, return immediately. */ + if (ti < 0) + { + if (debug_run_loop) + printf ("\tRunLoop limit date past, returning\n"); + _current_mode = saved_mode; + return; + } + timeout.tv_sec = ti; + timeout.tv_usec = (ti - timeout.tv_sec) * 1000000.0; + select_timeout = &timeout; + wait_timeout = ti * 1000; + } + else if (ti <= 0.0) + { + /* The LIMIT_DATE has already past; return immediately without + polling any inputs. */ + _current_mode = saved_mode; + return; + } + else + { + /* Wait forever. */ + if (debug_run_loop) + printf ("\tRunLoop accept input waiting forever\n"); + select_timeout = NULL; + wait_timeout = INFINITE; + } + +#if 1 + /* Get ready to listen to file descriptors. + Initialize the set of FDS we'll pass to select(), and create + an empty map for keeping track of which object is associated + with which file descriptor. */ + FD_ZERO (&fds); + FD_ZERO (&write_fds); + fd_2_object = NSCreateMapTable (NSIntMapKeyCallBacks, + NSObjectMapValueCallBacks, 0); + + /* If a port is invalid, remove it from this mode. */ + ports = NSMapGet (_mode_2_in_ports, mode); + { + id port; + int i; + for (i = [ports count]-1; i >= 0; i--) + { + port = [ports objectAtIndex: i]; + if (![port isValid]) + [ports removeObjectAtIndex: i]; + } + } + num_of_ports = 0; + + /* Do the pre-listening set-up for the ports of this mode. */ + { + if (ports) + { + id port; + int i; + int fd_count = port_fd_count; + int fd_array[port_fd_count]; + + /* Ask our ports for the list of file descriptors they + want us to listen to; add these to FD_LISTEN_SET. + Save the list of ports for later use. */ + for (i = [ports count]-1; i >= 0; i--) + { + port = [ports objectAtIndex: i]; + if ([port respondsTo: @selector(getFds:count:)]) + [port getFds: fd_array count: &fd_count]; + else + fd_count = 0; + if (debug_run_loop) + printf("\tRunLoop listening to %d sockets\n", fd_count); + num_of_ports += fd_count; + if (num_of_ports > port_fd_count) + { + /* xxx Uh oh our array isn't big enough */ + perror ("RunLoop attempt to listen to too many ports\n"); + abort (); + } + while (fd_count--) + { + int j = num_of_ports - fd_count - 1; + port_fd_array[j] = fd_array[fd_count]; + FD_SET (port_fd_array[j], &fds); + NSMapInsert (fd_2_object, + (void*)port_fd_array[j], + port); + } + } + } + } + if (debug_run_loop) + printf("\tRunLoop listening to %d total ports\n", num_of_ports); + + /* Wait for incoming data, listening to the file descriptors in _FDS. */ + read_fds = fds; + exception_fds = fds; + select_return = select (FD_SETSIZE, &read_fds, &write_fds, &exception_fds, + select_timeout); + + if (select_return < 0) + { + /* Some exceptional condition happened. */ + /* xxx We can do something with exception_fds, instead of + aborting here. */ + perror ("[TcpInPort receivePacketWithTimeout:] select()"); + abort (); + } + else if (select_return == 0) + { + NSFreeMapTable (fd_2_object); + _current_mode = saved_mode; + return; + } + + /* Look at all the file descriptors select() says are ready for reading; + notify the corresponding object for each of the ready fd's. */ + if (ports) + { + int i; + + for (i = num_of_ports - 1; i >= 0; i--) + { + if (FD_ISSET (port_fd_array[i], &read_fds)) + { + id fd_object = (id) NSMapGet (fd_2_object, + (void*)port_fd_array[i]); + assert (fd_object); + [fd_object readyForReadingOnFileDescriptor: + port_fd_array[i]]; + } + } + } + + /* Clean up before returning. */ + NSFreeMapTable (fd_2_object); + +#else + + /* Wait for incoming data */ + wait_return = MsgWaitForMultipleObjects(wait_count, handle_list, FALSE, + wait_timeout, QS_ALLINPUT); + + if (debug_run_loop) + printf ("\tRunLoop MsgWaitForMultipleObjects returned %ld\n", wait_return); + + if (wait_return == 0xFFFFFFFF) + { + /* Some exceptional condition happened. */ + NSLog(@"RunLoop error, MsgWaitForMultipleObjects returned %d\n", + GetLastError()); + } + else if (wait_return == (WAIT_OBJECT_0 + wait_count)) + { + /* Event in the event queue */ + if (_event_queue) + [_event_queue readyForReadingOnEventQueue]; + } + else + { + /* We handle the other wait objects here */ + } +#endif + + _current_mode = saved_mode; +} + +#else + +/* Private method + Perform UNIX style mechanism to wait on multiple inputs */ +- (void) acceptUNIXInputForMode: (NSString*)mode + beforeDate: limit_date { NSTimeInterval ti; struct timeval timeout; @@ -606,6 +835,22 @@ static RunLoop *current_run_loop; _current_mode = saved_mode; } +#endif /* WIN32 */ + +/* Listen to input sources. + If LIMIT_DATE is nil, then don't wait; i.e. call select() with 0 timeout */ + +- (void) acceptInputForMode: (NSString*)mode + beforeDate: limit_date +{ +#if defined(__WIN32__) || defined(_WIN32) + [self acceptWIN32InputForMode: mode beforeDate: limit_date]; +#else + [self acceptUNIXInputForMode: mode beforeDate: limit_date]; +#endif /* WIN32 */ +} + + /* Running the run loop once through for timers and input listening. */ @@ -712,11 +957,6 @@ static RunLoop *current_run_loop; @end - -/* RunLoop mode strings. */ - -id RunLoopDefaultMode = @"RunLoopDefaultMode"; - /* NSObject method additions. */ diff --git a/Source/StdioStream.m b/Source/StdioStream.m index 8b882a310..e9a149c93 100644 --- a/Source/StdioStream.m +++ b/Source/StdioStream.m @@ -31,6 +31,10 @@ #include #include /* SEEK_* on SunOS 4 */ +#ifdef __WIN32__ +#define fdopen _fdopen +#endif + enum { STREAM_READONLY = 0, STREAM_READWRITE, @@ -138,16 +142,24 @@ o_vscanf (void *stream, - initWithPipeTo: (NSString*) systemCommand { +#ifdef __WIN32__ + return nil; +#else return [self initWithFilePointer: popen([systemCommand cStringNoCopy], "w") fmode:"w"]; +#endif } - initWithPipeFrom: (NSString*) systemCommand { +#ifdef __WIN32__ + return nil; +#else return [self initWithFilePointer: popen([systemCommand cStringNoCopy], "r") fmode:"r"]; +#endif } - init diff --git a/Source/Stream.m b/Source/Stream.m index 7821fbeba..b8eb6c2c8 100644 --- a/Source/Stream.m +++ b/Source/Stream.m @@ -27,8 +27,6 @@ #include #include -NSString* StreamException = @"StreamException"; - @implementation Stream /* This is the designated initializer. */ diff --git a/Source/TcpPort.m b/Source/TcpPort.m index 80a41d19a..b49b14a92 100644 --- a/Source/TcpPort.m +++ b/Source/TcpPort.m @@ -1913,18 +1913,3 @@ static NSMapTable *out_port_bag = NULL; } @end - - - -/* Notification Strings. */ - -NSString * -InPortClientBecameInvalidNotification = -@"InPortClientBecameInvalidNotification"; - -NSString * -InPortAcceptedClientNotification = -@"InPortAcceptedClientNotification"; - - - diff --git a/Source/Time.m b/Source/Time.m index d126d984b..023d85728 100644 --- a/Source/Time.m +++ b/Source/Time.m @@ -189,7 +189,7 @@ id monthNames; #endif return ((long)((end_tms.tms_utime - start_tms.tms_utime + end_tms.tms_stime - start_tms.tms_stime) * 1000) / CLK_TCK); -#elif __WIN32__ +#elif defined(__WIN32__) || defined(_WIN32) DWORD start_tick, end_tick; start_tick = GetTickCount(); @@ -214,7 +214,7 @@ id monthNames; { #if HAVE_TIMES struct tms start_tms, end_tms; -#elif __WIN32__ +#elif defined(__WIN32__) || defined(_WIN32) DWORD start_tick, end_tick; #else struct rusage start_ru, end_ru; @@ -225,7 +225,7 @@ id monthNames; times(&start_tms); (*aFunc)(); times(&end_tms); -#elif __WIN32__ +#elif defined(__WIN32__) || defined(_WIN32) #else getrusage(RUSAGE_SELF, &start_ru); (*aFunc)(); diff --git a/Source/externs.m b/Source/externs.m new file mode 100644 index 000000000..60d6b9273 --- /dev/null +++ b/Source/externs.m @@ -0,0 +1,390 @@ +/* All of the external data + Copyright (C) 1997 Free Software Foundation, Inc. + + Written by: Scott Christley + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include "NSCallBacks.h" +#include +#include + +/* Global lock to be used by classes when operating on any global + data that invoke other methods which also access global; thus, + creating the potential for deadlock. */ +NSRecursiveLock *gnustep_global_lock = nil; + +/* Connection Notification Strings. */ + +NSString *ConnectionBecameInvalidNotification = +@"ConnectionBecameInvalidNotification"; + +NSString *ConnectionWasCreatedNotification = +@"ConnectionWasCreatedNotification"; + +/* NSThread Notifications */ +NSString *NSBecomingMultiThreaded = @"NSBecomingMultiThreadedNotification"; +NSString *NSThreadExiting = @"NSThreadExitingNotification"; + +/* Port Notifications */ +NSString *PortBecameInvalidNotification = @"PortBecameInvalidNotification"; + +NSString *InPortClientBecameInvalidNotification = +@"InPortClientBecameInvalidNotification"; + +NSString *InPortAcceptedClientNotification = +@"InPortAcceptedClientNotification"; + +/* RunLoop modes */ +NSString *RunLoopConnectionReplyMode = @"RunLoopConnectionReplyMode"; + +/* RunLoop mode strings. */ +id RunLoopDefaultMode = @"RunLoopDefaultMode"; + +/* Exceptions */ +NSString *NSInconsistentArchiveException = @"NSInconsistentArchiveException"; +NSString *NSGenericException = @"NSGenericException"; +NSString *NSInternalInconsistencyException = +@"NSInternalInconsistencyException"; +NSString *NSInvalidArgumentException = @"NSInvalidArgumentException"; +NSString *NSMallocException = @"NSMallocException"; +NSString *NSRangeException = @"NSRangeException"; + +/* Exception handler */ +NSUncaughtExceptionHandler *_NSUncaughtExceptionHandler; + +/* NSBundle */ +NSString* NSBundleDidLoadNotification = @"NSBundleDidLoadNotification"; +NSString* NSShowNonLocalizedStrings = @"NSShowNonLocalizedStrings"; +NSString* NSLoadedClasses = @"NSLoadedClasses"; + +/* Stream */ +NSString* StreamException = @"StreamException"; + +/* + * File attributes names + */ + +/* File Attributes */ + +NSString* NSFileSize = @"NSFileSize"; +NSString* NSFileModificationDate = @"NSFileModificationDate"; +NSString* NSFileOwnerAccountNumber = @"NSFileOwnerAccountNumber"; +NSString* NSFileGroupOwnerAccountNumber = @"NSFileGroupOwnerAccountNumber"; +NSString* NSFileReferenceCount = @"NSFileReferenceCount"; +NSString* NSFileIdentifier = @"NSFileIdentifier"; +NSString* NSFileDeviceIdentifier = @"NSFileDeviceIdentifier"; +NSString* NSFilePosixPermissions = @"NSFilePosixPermissions"; +NSString* NSFileType = @"NSFileType"; + +/* File Types */ + +NSString* NSFileTypeDirectory = @"NSFileTypeDirectory"; +NSString* NSFileTypeRegular = @"NSFileTypeRegular"; +NSString* NSFileTypeSymbolicLink = @"NSFileTypeSymbolicLink"; +NSString* NSFileTypeSocket = @"NSFileTypeSocket"; +NSString* NSFileTypeFifo = @"NSFileTypeFifo"; +NSString* NSFileTypeCharacterSpecial = @"NSFileTypeCharacterSpecial"; +NSString* NSFileTypeBlockSpecial = @"NSFileTypeBlockSpecial"; +NSString* NSFileTypeUnknown = @"NSFileTypeUnknown"; + +/* FileSystem Attributes */ + +NSString* NSFileSystemSize = @"NSFileSystemSize"; +NSString* NSFileSystemFreeSize = @"NSFileSystemFreeSize"; +NSString* NSFileSystemNodes = @"NSFileSystemNodes"; +NSString* NSFileSystemFreeNodes = @"NSFileSystemFreeNodes"; +NSString* NSFileSystemNumber = @"NSFileSystemNumber"; + +/* Standard domains */ +NSString* NSArgumentDomain = @"NSArgumentDomain"; +NSString* NSGlobalDomain = @"NSGlobalDomain"; +NSString* NSRegistrationDomain = @"NSRegistrationDomain"; + +/* Public notification */ +NSString *NSUserDefaultsChanged = @"NSUserDefaultsChanged"; + +/* Keys for language-dependent information */ +NSString *NSWeekDayNameArray = @"NSWeekDayNameArray"; +NSString *NSShortWeekDayNameArray = @"NSShortWeekDayNameArray"; +NSString *NSMonthNameArray = @"NSMonthNameArray"; +NSString *NSShortMonthNameArray = @"NSShortMonthNameArray"; +NSString *NSTimeFormatString = @"NSTimeFormatString"; +NSString *NSDateFormatString = @"NSDateFormatString"; +NSString *NSTimeDateFormatString = @"NSTimeDateFormatString"; +NSString *NSShortTimeDateFormatString = @"NSShortTimeDateFormatString"; +NSString *NSCurrencySymbol = @"NSCurrencySymbol"; +NSString *NSDecimalSeparator = @"NSDecimalSeparator"; +NSString *NSThousandsSeparator = @"NSThousandsSeparator"; +NSString *NSInternationalCurrencyString = @"NSInternationalCurrencyString"; +NSString *NSCurrencyString = @"NSCurrencyString"; +NSString *NSDecimalDigits = @"NSDecimalDigits"; +NSString *NSAMPMDesignation = @"NSAMPMDesignation"; + +/* Standard MapTable callbacks */ + +const NSMapTableKeyCallBacks NSIntMapKeyCallBacks = +{ + (NSMT_hash_func_t) _NS_int_hash, + (NSMT_is_equal_func_t) _NS_int_is_equal, + (NSMT_retain_func_t) _NS_int_retain, + (NSMT_release_func_t) _NS_int_release, + (NSMT_describe_func_t) _NS_int_describe, + 0 +}; + +const NSMapTableKeyCallBacks NSNonOwnedPointerMapKeyCallBacks = +{ + (NSMT_hash_func_t) _NS_non_owned_void_p_hash, + (NSMT_is_equal_func_t) _NS_non_owned_void_p_is_equal, + (NSMT_retain_func_t) _NS_non_owned_void_p_retain, + (NSMT_release_func_t) _NS_non_owned_void_p_release, + (NSMT_describe_func_t) _NS_non_owned_void_p_describe, + 0 +}; + +const NSMapTableKeyCallBacks NSNonOwnedPointerOrNullMapKeyCallBacks = +{ + (NSMT_hash_func_t) _NS_non_owned_void_p_hash, + (NSMT_is_equal_func_t) _NS_non_owned_void_p_is_equal, + (NSMT_retain_func_t) _NS_non_owned_void_p_retain, + (NSMT_release_func_t) _NS_non_owned_void_p_release, + (NSMT_describe_func_t) _NS_non_owned_void_p_describe, + /* FIXME: Oh my. Is this really ok? I did it in a moment of + * weakness. A fit of madness, I say! And if this is wrong, what + * *should* it be?!? */ + (const void *)-1 +}; + +const NSMapTableKeyCallBacks NSNonRetainedObjectMapKeyCallBacks = +{ + (NSMT_hash_func_t) _NS_non_retained_id_hash, + (NSMT_is_equal_func_t) _NS_non_retained_id_is_equal, + (NSMT_retain_func_t) _NS_non_retained_id_retain, + (NSMT_release_func_t) _NS_non_retained_id_release, + (NSMT_describe_func_t) _NS_non_retained_id_describe, + 0 +}; + +const NSMapTableKeyCallBacks NSObjectMapKeyCallBacks = +{ + (NSMT_hash_func_t) _NS_id_hash, + (NSMT_is_equal_func_t) _NS_id_is_equal, + (NSMT_retain_func_t) _NS_id_retain, + (NSMT_release_func_t) _NS_id_release, + (NSMT_describe_func_t) _NS_id_describe, + 0 +}; + +const NSMapTableKeyCallBacks NSOwnedPointerMapKeyCallBacks = +{ + (NSMT_hash_func_t) _NS_owned_void_p_hash, + (NSMT_is_equal_func_t) _NS_owned_void_p_is_equal, + (NSMT_retain_func_t) _NS_owned_void_p_retain, + (NSMT_release_func_t) _NS_owned_void_p_release, + (NSMT_describe_func_t) _NS_owned_void_p_describe, + 0 +}; + +const NSMapTableValueCallBacks NSIntMapValueCallBacks = +{ + (NSMT_retain_func_t) _NS_int_retain, + (NSMT_release_func_t) _NS_int_release, + (NSMT_describe_func_t) _NS_int_describe +}; + +const NSMapTableValueCallBacks NSNonOwnedPointerMapValueCallBacks = +{ + (NSMT_retain_func_t) _NS_non_owned_void_p_retain, + (NSMT_release_func_t) _NS_non_owned_void_p_release, + (NSMT_describe_func_t) _NS_non_owned_void_p_describe +}; + +const NSMapTableValueCallBacks NSObjectMapValueCallBacks = +{ + (NSMT_retain_func_t) _NS_id_retain, + (NSMT_release_func_t) _NS_id_release, + (NSMT_describe_func_t) _NS_id_describe +}; + +const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks = +{ + (NSMT_retain_func_t) _NS_owned_void_p_retain, + (NSMT_release_func_t) _NS_owned_void_p_release, + (NSMT_describe_func_t) _NS_owned_void_p_describe +}; + +/** Standard NSHashTable callbacks... **/ + +const NSHashTableCallBacks NSIntHashCallBacks = +{ + (NSHT_hash_func_t) _NS_int_hash, + (NSHT_isEqual_func_t) _NS_int_is_equal, + (NSHT_retain_func_t) _NS_int_retain, + (NSHT_release_func_t) _NS_int_release, + (NSHT_describe_func_t) _NS_int_describe +}; + +const NSHashTableCallBacks NSNonOwnedPointerHashCallBacks = +{ + (NSHT_hash_func_t) _NS_owned_void_p_hash, + (NSHT_isEqual_func_t) _NS_owned_void_p_is_equal, + (NSHT_retain_func_t) _NS_owned_void_p_retain, + (NSHT_release_func_t) _NS_owned_void_p_release, + (NSHT_describe_func_t) _NS_owned_void_p_describe +}; + +const NSHashTableCallBacks NSNonRetainedObjectsHashCallBacks = +{ + (NSHT_hash_func_t) _NS_non_retained_id_hash, + (NSHT_isEqual_func_t) _NS_non_retained_id_is_equal, + (NSHT_retain_func_t) _NS_non_retained_id_retain, + (NSHT_release_func_t) _NS_non_retained_id_release, + (NSHT_describe_func_t) _NS_non_retained_id_describe +}; + +const NSHashTableCallBacks NSObjectsHashCallBacks = +{ + (NSHT_hash_func_t) _NS_id_hash, + (NSHT_isEqual_func_t) _NS_id_is_equal, + (NSHT_retain_func_t) _NS_id_retain, + (NSHT_release_func_t) _NS_id_release, + (NSHT_describe_func_t) _NS_id_describe +}; + +const NSHashTableCallBacks NSOwnedPointerHashCallBacks = +{ + (NSHT_hash_func_t) _NS_owned_void_p_hash, + (NSHT_isEqual_func_t) _NS_owned_void_p_is_equal, + (NSHT_retain_func_t) _NS_owned_void_p_retain, + (NSHT_release_func_t) _NS_owned_void_p_release, + (NSHT_describe_func_t) _NS_owned_void_p_describe +}; + +const NSHashTableCallBacks NSPointerToStructHashCallBacks = +{ + (NSHT_hash_func_t) _NS_int_p_hash, + (NSHT_isEqual_func_t) _NS_int_p_is_equal, + (NSHT_retain_func_t) _NS_int_p_retain, + (NSHT_release_func_t) _NS_int_p_release, + (NSHT_describe_func_t) _NS_int_p_describe +}; + +/* Callbacks for (NUL-terminated) arrays of `char'. */ + +/* FIXME: Is this right?!? */ +#define _OBJECTS_NOT_A_CHAR_P_MARKER (const void *)(-1) + +const void *o_not_a_char_p_marker = _OBJECTS_NOT_A_CHAR_P_MARKER; + +o_callbacks_t o_callbacks_for_char_p = +{ + (o_hash_func_t) o_char_p_hash, + (o_compare_func_t) o_char_p_compare, + (o_is_equal_func_t) o_char_p_is_equal, + (o_retain_func_t) o_char_p_retain, + (o_release_func_t) o_char_p_release, + (o_describe_func_t) o_char_p_describe, + _OBJECTS_NOT_A_CHAR_P_MARKER +}; + +/* Callbacks for `int' (and smaller) things. */ + +/* FIXME: This isn't right. Fix it. */ +#define _OBJECTS_NOT_AN_INT_MARKER (const void *)(-1) + +const void *o_not_an_int_marker = _OBJECTS_NOT_AN_INT_MARKER; + +o_callbacks_t o_callbacks_for_int = +{ + (o_hash_func_t) o_int_hash, + (o_compare_func_t) o_int_compare, + (o_is_equal_func_t) o_int_is_equal, + (o_retain_func_t) o_int_retain, + (o_release_func_t) o_int_release, + (o_describe_func_t) o_int_describe, + _OBJECTS_NOT_AN_INT_MARKER +}; + +/* Callbacks for the Objective-C object type. */ + +/* FIXME: Is this right?!? */ +#define _OBJECTS_NOT_AN_ID_MARKER (const void *)(-1) + +const void *o_not_an_id_marker = _OBJECTS_NOT_AN_ID_MARKER; + +o_callbacks_t o_callbacks_for_id = +{ + (o_hash_func_t) o_id_hash, + (o_compare_func_t) o_id_compare, + (o_is_equal_func_t) o_id_is_equal, + (o_retain_func_t) o_id_retain, + (o_release_func_t) o_id_release, + (o_describe_func_t) o_id_describe, + _OBJECTS_NOT_AN_ID_MARKER +}; + +/* Callbacks for pointers to `int'. */ + +/* FIXME: Is this right?!? */ +#define _OBJECTS_NOT_AN_INT_P_MARKER (const void *)(-1) + +const void *o_not_an_int_p_marker = _OBJECTS_NOT_AN_INT_P_MARKER; + +o_callbacks_t o_callbacks_for_int_p = +{ + (o_hash_func_t) o_int_p_hash, + (o_compare_func_t) o_int_p_compare, + (o_is_equal_func_t) o_int_p_is_equal, + (o_retain_func_t) o_int_p_retain, + (o_release_func_t) o_int_p_release, + (o_describe_func_t) o_int_p_describe, + _OBJECTS_NOT_AN_INT_P_MARKER +}; + +/* Callbacks for pointers to `void'. */ + +/* FIXME: Is this right?!? */ +#define _OBJECTS_NOT_A_VOID_P_MARKER (const void *)(-1) + +const void *o_not_a_void_p_marker = _OBJECTS_NOT_A_VOID_P_MARKER; + +o_callbacks_t o_callbacks_for_non_owned_void_p = +{ + (o_hash_func_t) o_non_owned_void_p_hash, + (o_compare_func_t) o_non_owned_void_p_compare, + (o_is_equal_func_t) o_non_owned_void_p_is_equal, + (o_retain_func_t) o_non_owned_void_p_retain, + (o_release_func_t) o_non_owned_void_p_release, + _OBJECTS_NOT_A_VOID_P_MARKER +}; + +o_callbacks_t o_callbacks_for_owned_void_p = +{ + (o_hash_func_t) o_owned_void_p_hash, + (o_compare_func_t) o_owned_void_p_compare, + (o_is_equal_func_t) o_owned_void_p_is_equal, + (o_retain_func_t) o_owned_void_p_retain, + (o_release_func_t) o_owned_void_p_release, + _OBJECTS_NOT_A_VOID_P_MARKER +}; + diff --git a/Source/find_exec.c b/Source/find_exec.c index f0a6e3fbb..226cae92f 100644 --- a/Source/find_exec.c +++ b/Source/find_exec.c @@ -51,8 +51,16 @@ int lstat(char *path, struct stat *buf) { return (-1); } #define DEFAULT_PATH ".:~/bin::/usr/local/bin:/usr/new:/usr/ucb:/usr/bin:/bin:/usr/hosts" +#if defined(__WIN32__) || defined(_WIN32) +#define PATH_SEPARATOR ';' +#define PATH_COMPONENT "\\" +#else +#define PATH_SEPARATOR ':' +#define PATH_COMPONENT "/" +#endif + /* ABSOLUTE_FILENAME_P (fname): True if fname is an absolute filename */ -#ifdef atarist +#if defined(atarist) || defined(__WIN32__) || defined(_WIN32) #define ABSOLUTE_FILENAME_P(fname) ((fname[0] == '/') || \ (fname[0] && (fname[1] == ':'))) #else @@ -131,7 +139,7 @@ objc_find_executable (const char *file) next = name; /* copy directory name into [name] */ - while (*p && *p != ':') *next++ = *p++; + while (*p && *p != PATH_SEPARATOR) *next++ = *p++; *next = 0; if (*p) p++; @@ -144,7 +152,7 @@ objc_find_executable (const char *file) cwd_in_path = 1; } - strcat (name, "/"); + strcat (name, PATH_COMPONENT); strcat (name, file); /* @@ -152,6 +160,33 @@ objc_find_executable (const char *file) */ if (find_full_path (name) == 0) return copy_of (name); + + /* Also add common executable extensions on windows */ +#if defined(__WIN32__) || defined(_WIN32) + { + int fl = strlen(name); + + strcat (name, ".com"); + if (find_full_path (name) == 0) + return copy_of (name); + name[fl] = '\0'; + + strcat (name, ".exe"); + if (find_full_path (name) == 0) + return copy_of (name); + name[fl] = '\0'; + + strcat (name, ".bat"); + if (find_full_path (name) == 0) + return copy_of (name); + name[fl] = '\0'; + + strcat (name, ".cmd"); + if (find_full_path (name) == 0) + return copy_of (name); + name[fl] = '\0'; + } +#endif } /* @@ -165,7 +200,7 @@ objc_find_executable (const char *file) #else getwd (name); #endif - strcat (name, "/"); + strcat (name, PATH_COMPONENT); strcat (name, file); /* @@ -173,6 +208,33 @@ objc_find_executable (const char *file) */ if (find_full_path (name) == 0) return copy_of (name); + + /* Also add common executable extensions on windows */ +#if defined(__WIN32__) || defined(_WIN32) + { + int fl = strlen(name); + + strcat (name, ".com"); + if (find_full_path (name) == 0) + return copy_of (name); + name[fl] = '\0'; + + strcat (name, ".exe"); + if (find_full_path (name) == 0) + return copy_of (name); + name[fl] = '\0'; + + strcat (name, ".bat"); + if (find_full_path (name) == 0) + return copy_of (name); + name[fl] = '\0'; + + strcat (name, ".cmd"); + if (find_full_path (name) == 0) + return copy_of (name); + name[fl] = '\0'; + } +#endif } return 0; diff --git a/Source/libgnustep-base.def b/Source/libgnustep-base.def new file mode 100644 index 000000000..7c9839530 --- /dev/null +++ b/Source/libgnustep-base.def @@ -0,0 +1,811 @@ +; +; libgnustep-base.def +; +; Exports for libgnustep-base DLL +; Specific to WIN32 operating systems +; +; Copyright (C) 1996 Free Software Foundation, Inc. +; +; Author: Scott Christley +; Date: 1996 +; +; 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. +; +; If you are interested in a warranty or support for this source code, +; contact Scott Christley for more information. +; +; 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., 675 Mass Ave, Cambridge, MA 02139, USA. +; + +LIBRARY libgstep +EXPORTS +__objc_class_name_Archiver +__objc_class_name_Unarchiver +__objc_class_name_Array +__objc_class_name_ConstantArray +__objc_class_name_Bag +__objc_class_name_BinaryCStream +__objc_class_name_BinaryTree +__objc_class_name_BinaryTreeNode +__objc_class_name_CircularArray +__objc_category_name_ConstantCollection_ArchivingHelpers +__objc_category_name_ConstantCollection_DeallocationHelpers +__objc_class_name_Collection +__objc_class_name_ConstantCollection +__objc_class_name_Enumerator +__objc_category_name_NSObject_ConnectedCoderCallbacks +__objc_class_name_ConnectedDecoder +__objc_class_name_ConnectedEncoder +__objc_category_name_Coder_NSArchiverCompatibility +__objc_category_name_Coder_NSCoderCompatibility +__objc_class_name_Coder +__objc_class_name_Connection +__objc_class_name_CStream +__objc_class_name_Decoder +__objc_class_name_DelegatePool +__objc_class_name_Dictionary +__objc_class_name_Encoder +__objc_class_name_GapArray +__objc_class_name_Heap +__objc_class_name_ConstantIndexedCollection +__objc_class_name_IndexedCollection +__objc_class_name_ReverseEnumerator +__objc_class_name_ArgframeInvocation +__objc_class_name_Invocation +__objc_class_name_MethodInvocation +__objc_class_name_ObjectFunctionInvocation +__objc_class_name_ObjectMethodInvocation +__objc_class_name_VoidFunctionInvocation +__objc_class_name_ConstantKeyedCollection +__objc_class_name_KeyEnumerator +__objc_class_name_KeyedCollection +__objc_class_name_LinkedList +__objc_class_name_LinkedListNode +__objc_class_name_Lock +__objc_class_name_Magnitude +__objc_class_name_MallocAddress +__objc_class_name_MappedCollector +__objc_class_name_MemoryStream +inchar_func +outchar_func +unchar_func +__objc_class_name_Notification +__objc_category_name_NotificationDispatcher_OpenStepCompat +__objc_class_name_NotificationDispatcher +__objc_class_name_NotificationInvocation +__objc_class_name_NotificationPerformer +__objc_class_name_NotificationRequest +__objc_class_name_OrderedCollection +__objc_class_name_InPacket +__objc_class_name_InPort +__objc_class_name_OutPacket +__objc_class_name_OutPort +__objc_class_name_Port +__objc_category_name_NSObject_ForProxy +__objc_category_name_Protocol_RemoteSelfCoding +__objc_class_name_Proxy +__objc_class_name_Queue +__objc_class_name_Random +__objc_class_name_RawCStream +__objc_class_name_RBTree +__objc_class_name_RBTreeNode +__objc_class_name_RNGAdditiveCongruential +__objc_class_name_RNGBerkeley +__objc_category_name_NSObject_PerformingAfterDelay +__objc_category_name_RunLoop_GNUstepExtensions +__objc_class_name_FdInfo +__objc_class_name_RunLoop +__objc_class_name_Set +__objc_class_name_SplayTree +__objc_class_name_Stack +__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_TextCStream +__objc_class_name_Time +gettimeofday +times +__objc_class_name_UdpInPacket +__objc_class_name_UdpInPort +__objc_class_name_UdpOutPort +behavior_class_add_category +behavior_class_add_class +behavior_class_add_methods +behavior_set_debug +class_add_behavior +pl_create_buffer +pl_delete_buffer +pl_flush_buffer +pl_init_buffer +pl_load_buffer_state +pl_scan_buffer +pl_scan_bytes +pl_scan_string +pl_switch_to_buffer +pllex +plrestart +plwrap +str2data +strdup +unescstr +sf_create_buffer +sf_delete_buffer +sf_flush_buffer +sf_init_buffer +sf_load_buffer_state +sf_scan_buffer +sf_scan_bytes +sf_scan_string +sf_switch_to_buffer +sflex +sfrestart +sfwrap +ostream_at_eos +ostream_close +ostream_close_memory +ostream_flush +ostream_get_memory_buffer +ostream_getc +ostream_gets +ostream_map_file +ostream_open_descriptor +ostream_open_memory +ostream_printf +ostream_putc +ostream_read +ostream_save_to_file +ostream_scanf +ostream_seek +ostream_tell +ostream_ungetc +ostream_vprintf +ostream_vscanf +ostream_write +o_array_all_elements +o_array_all_elements_ascending +o_array_all_elements_descending +o_array_alloc +o_array_alloc_with_zone +o_array_ascending_enumerator +o_array_at_index_put_element +o_array_capacity +o_array_check +o_array_contains_element +o_array_count +o_array_dealloc +o_array_descending_enumerator +o_array_element_at_index +o_array_empty +o_array_enumerator +o_array_enumerator_next_element +o_array_enumerator_next_index +o_array_enumerator_next_index_and_element +o_array_index_of_element +o_array_init +o_array_init_from_array +o_array_init_with_callbacks +o_array_is_empty +o_array_is_equal_to_array +o_array_map_elements +o_array_of_char_p +o_array_of_id +o_array_of_int +o_array_of_non_owned_void_p +o_array_of_owned_void_p +o_array_remove_element +o_array_remove_element_at_index +o_array_remove_element_known_present +o_array_with_callbacks +o_array_with_zone +o_array_with_zone_with_callbacks +o_hash_init_from_array +_o_array_alloc_with_zone +_o_array_copy_with_zone +_o_array_dealloc +_o_array_description +_o_array_set_serial_number +o_array_extra +o_array_extra_callbacks +o_array_magic_number +o_array_name +o_array_serial_number +o_array_set_extra +o_array_set_extra_callbacks +o_array_set_name +o_array_unset_extra +o_array_unset_name +o_array_zone +o_array_element_callbacks +o_array_not_an_element_marker +o_callbacks_standard +o_callbacks_standardize +o_compare +o_describe +o_hash +o_is_equal +o_release +o_retain +o_char_p_compare +o_char_p_describe +o_char_p_hash +o_char_p_is_equal +o_char_p_release +o_char_p_retain +o_id_compare +o_id_describe +o_id_hash +o_id_is_equal +o_id_release +o_id_retain +o_int_compare +o_int_describe +o_int_hash +o_int_is_equal +o_int_release +o_int_retain +o_int_p_compare +o_int_p_describe +o_int_p_hash +o_int_p_is_equal +o_int_p_release +o_int_p_retain +o_non_owned_void_p_compare +o_non_owned_void_p_describe +o_non_owned_void_p_hash +o_non_owned_void_p_is_equal +o_non_owned_void_p_release +o_non_owned_void_p_retain +o_owned_void_p_compare +o_owned_void_p_describe +o_owned_void_p_hash +o_owned_void_p_is_equal +o_owned_void_p_release +o_owned_void_p_retain +_o_hash_hash +_o_hash_retain +o_callbacks_for_hash +o_hash_add_element +o_hash_add_element_if_absent +o_hash_add_element_known_absent +o_hash_all_elements +o_hash_alloc +o_hash_alloc_with_zone +o_hash_capacity +o_hash_check +o_hash_contains_element +o_hash_contains_hash +o_hash_copy +o_hash_copy_with_zone +o_hash_count +o_hash_dealloc +o_hash_description +o_hash_element +o_hash_empty +o_hash_enumerator_for_hash +o_hash_enumerator_next_element +o_hash_init +o_hash_init_from_hash +o_hash_init_with_callbacks +o_hash_intersect_hash +o_hash_intersects_hash +o_hash_is_empty +o_hash_is_equal_to_hash +o_hash_map_elements +o_hash_minus_hash +o_hash_of_char_p +o_hash_of_id +o_hash_of_int +o_hash_of_int_p +o_hash_of_non_owned_void_p +o_hash_of_owned_void_p +o_hash_remove_element +o_hash_replace_element +o_hash_resize +o_hash_rightsize +o_hash_union_hash +o_hash_with_callbacks +o_hash_with_zone +o_hash_with_zone_with_callbacks +_o_hash_alloc_with_zone +_o_hash_copy_with_zone +_o_hash_dealloc +_o_hash_description +_o_hash_set_serial_number +o_hash_extra +o_hash_extra_callbacks +o_hash_magic_number +o_hash_name +o_hash_serial_number +o_hash_set_extra +o_hash_set_extra_callbacks +o_hash_set_name +o_hash_unset_extra +o_hash_unset_name +o_hash_zone +o_hash_element_callbacks +o_hash_not_an_element_marker +_o_list_free_node +o_hash_init_from_list +o_list +o_list_all_elements +o_list_alloc +o_list_alloc_with_zone +o_list_append_element +o_list_append_element_if_absent +o_list_append_list +o_list_at_index_insert_element +o_list_at_index_insert_element_if_absent +o_list_at_index_insert_list +o_list_capacity +o_list_check +o_list_contains_element +o_list_copy +o_list_copy_with_zone +o_list_count +o_list_dealloc +o_list_element +o_list_empty +o_list_enumerator +o_list_enumerator_next_element +o_list_first_element +o_list_forward_enumerator +o_list_init +o_list_init_from_list +o_list_init_with_callbacks +o_list_is_empty +o_list_is_equal_to_list +o_list_last_element +o_list_map_elements +o_list_nth_element +o_list_of_char_p +o_list_of_id +o_list_of_int +o_list_of_non_owned_void_p +o_list_of_owned_void_p +o_list_prepend_element +o_list_prepend_element_if_absent +o_list_prepend_list +o_list_remove_element +o_list_remove_first_element +o_list_remove_last_element +o_list_remove_nth_element +o_list_remove_nth_occurrance_of_element +o_list_replace_element +o_list_replace_first_element +o_list_replace_last_element +o_list_replace_nth_element +o_list_replace_nth_occurrance_of_element +o_list_reverse_enumerator +o_list_with_callbacks +o_list_with_zone +o_list_with_zone_with_callbacks +_o_list_alloc_with_zone +_o_list_copy_with_zone +_o_list_dealloc +_o_list_description +_o_list_set_serial_number +o_list_extra +o_list_extra_callbacks +o_list_magic_number +o_list_name +o_list_serial_number +o_list_set_extra +o_list_set_extra_callbacks +o_list_set_name +o_list_unset_extra +o_list_unset_name +o_list_zone +o_list_element_callbacks +o_list_not_an_element_marker +_o_map_enumerator_next_node +_o_map_hash +_o_map_retain +o_callbacks_for_map +o_map_all_keys +o_map_all_keys_and_values +o_map_all_values +o_map_alloc +o_map_alloc_with_zone +o_map_at_key_put_value +o_map_at_key_put_value_if_absent +o_map_at_key_put_value_known_absent +o_map_capacity +o_map_check +o_map_contains_key +o_map_contains_map +o_map_contains_value +o_map_copy +o_map_copy_with_zone +o_map_count +o_map_dealloc +o_map_description +o_map_empty +o_map_enumerator_for_map +o_map_enumerator_next_key +o_map_enumerator_next_key_and_value +o_map_enumerator_next_value +o_map_init +o_map_init_from_map +o_map_init_with_callbacks +o_map_intersect_map +o_map_intersects_map +o_map_is_empty +o_map_is_equal_to_map +o_map_key_and_value_at_key +o_map_key_at_key +o_map_keys_contain_keys_of_map +o_map_keys_intersect_keys_of_map +o_map_map_keys +o_map_map_values +o_map_minus_map +o_map_node_for_key +o_map_of_char_p +o_map_of_char_p_to_id +o_map_of_char_p_to_int +o_map_of_char_p_to_non_owned_void_p +o_map_of_id +o_map_of_id_to_char_p +o_map_of_id_to_int +o_map_of_id_to_non_owned_void_p +o_map_of_int +o_map_of_int_to_char_p +o_map_of_int_to_id +o_map_of_int_to_non_owned_void_p +o_map_of_non_owned_void_p +o_map_remove_key +o_map_remove_node +o_map_replace_key +o_map_resize +o_map_rightsize +o_map_union_map +o_map_value_at_key +o_map_with_callbacks +o_map_with_zone +o_map_with_zone_with_callbacks +_o_map_alloc_with_zone +_o_map_copy_with_zone +_o_map_dealloc +_o_map_description +_o_map_set_serial_number +o_map_extra +o_map_extra_callbacks +o_map_magic_number +o_map_name +o_map_serial_number +o_map_set_extra +o_map_set_extra_callbacks +o_map_set_name +o_map_unset_extra +o_map_unset_name +o_map_zone +o_map_key_callbacks +o_map_not_a_key_marker +o_map_not_a_value_marker +o_map_value_callbacks +gnustep_base_version +o_gcc_version +plerror +plparse +sfSetDict +sferror +sfparse +method_types_get_next_argument +method_types_get_number_of_arguments +method_types_get_size_of_register_arguments +method_types_get_size_of_stack_arguments +mframe_build_return +mframe_dissect_call +mframe_do_call +md5_buffer +md5_init_ctx +md5_process_block +md5_read_ctx +md5_stream +_o_next_power_of_two +_o_number_allocated +_o_number_deallocated +_o_number_serialized +o_vscanf +__objc_class_name_HashTable +__objc_class_name_List +CopyStringBuffer +__objc_class_name_NXStringTable +__objc_class_name_Storage +NXlex__create_buffer +NXlex__delete_buffer +NXlex__flush_buffer +NXlex__init_buffer +NXlex__load_buffer_state +NXlex__scan_buffer +NXlex__scan_bytes +NXlex__scan_string +NXlex__switch_to_buffer +NXlex_lex +NXlex_restart +NXlex_wrap +NSAllocateObject +__objc_category_name_NSObject_NSArchiver +__objc_class_name_NSArchiver +__objc_class_name_NSUnarchiver +__objc_class_name_NSArray +__objc_class_name_NSArrayEnumerator +__objc_class_name_NSArrayEnumeratorReverse +__objc_class_name_NSArrayNonCore +__objc_class_name_NSMutableArray +__objc_class_name_NSMutableArrayNonCore +__objc_class_name_NSAssertionHandler +__objc_class_name_NSAutoreleasePool +__objc_class_name_NSBitmapCharSet +__objc_class_name_NSMutableBitmapCharSet +__objc_category_name_NSBundle_Private +__objc_class_name_NSBundle +_bundle_load_callback +objc_executable_location +__objc_category_name_NSCalendarDate_GregorianDate +__objc_class_name_NSCalendarDate +_NS_id_describe +_NS_id_hash +_NS_id_is_equal +_NS_id_release +_NS_id_retain +_NS_int_describe +_NS_int_hash +_NS_int_is_equal +_NS_int_p_describe +_NS_int_p_hash +_NS_int_p_is_equal +_NS_int_p_release +_NS_int_p_retain +_NS_int_release +_NS_int_retain +_NS_non_owned_void_p_describe +_NS_non_owned_void_p_hash +_NS_non_owned_void_p_is_equal +_NS_non_owned_void_p_release +_NS_non_owned_void_p_retain +_NS_non_retained_id_describe +_NS_non_retained_id_hash +_NS_non_retained_id_is_equal +_NS_non_retained_id_release +_NS_non_retained_id_retain +_NS_owned_void_p_describe +_NS_owned_void_p_hash +_NS_owned_void_p_is_equal +_NS_owned_void_p_release +_NS_owned_void_p_retain +__objc_class_name_NSCharacterSet +__objc_class_name_NSMutableCharacterSet +__objc_class_name_NSCoder +__objc_class_name_NSCoderNonCore +NSCopyObject +__objc_class_name_NSConcreteValue +__objc_class_name_NSCountedSet +__objc_class_name_NSData +__objc_class_name_NSMutableData +__objc_class_name_NSDate +NSDeallocateObject +__objc_class_name_NSDictionary +__objc_class_name_NSMutableDictionary +__objc_class_name_NSEnumerator +_NSAddHandler +_NSRemoveHandler +__objc_class_name_NSException +__objc_category_name_NSDictionary_NSFileAttributes +__objc_class_name_NSDirectoryEnumerator +__objc_class_name_NSFileManager +NSContainsRect +NSDivideRect +NSEqualPoints +NSEqualRects +NSEqualSizes +NSHeight +NSInsetRect +NSIntegralRect +NSIntersectionRect +NSIntersectsRect +NSIsEmptyRect +NSMakePoint +NSMakeRect +NSMakeSize +NSMaxX +NSMaxY +NSMidX +NSMidY +NSMinX +NSMinY +NSMouseInRect +NSOffsetRect +NSPointInRect +NSStringFromPoint +NSStringFromRect +NSStringFromSize +NSUnionRect +NSWidth +__objc_class_name_NSGArchiver +__objc_class_name_NSGArchiverNullCStream +__objc_class_name_NSGUnarchiver +__objc_class_name_NSGArray +__objc_class_name_NSGMutableArray +__objc_class_name_NSGCountedSet +__objc_class_name_NSGCountedSetEnumerator +__objc_class_name_NSGCString +__objc_class_name_NSGMutableCString +__objc_class_name_NSGData +__objc_class_name_NSGMutableData +__objc_class_name_NSGDictionary +__objc_class_name_NSGDictionaryKeyEnumerator +__objc_class_name_NSGDictionaryObjectEnumerator +__objc_class_name_NSGMutableDictionary +__objc_class_name_NSGMutableSet +__objc_class_name_NSGSet +__objc_class_name_NSGSetEnumerator +NSAllHashTableObjects +NSCompareHashTables +NSCopyHashTableWithZone +NSCountHashTable +NSCreateHashTable +NSCreateHashTableWithZone +NSEnumerateHashTable +NSFreeHashTable +NSHashGet +NSHashInsert +NSHashInsertIfAbsent +NSHashInsertKnownAbsent +NSHashRemove +NSNextHashEnumeratorItem +NSResetHashTable +NSStringFromHashTable +_NSHT_compare +_NSHT_describe +_NSHT_extra_describe +_NSHT_extra_release +_NSHT_extra_retain +_NSHT_hash +_NSHT_is_equal +_NSHT_release +_NSHT_retain +__objc_class_name_NSInvocation +__objc_class_name_NSConditionLock +__objc_class_name_NSLock +__objc_class_name_NSRecursiveLock +NSLog +NSLogv +NSAllMapTableKeys +NSAllMapTableValues +NSCompareMapTables +NSCopyMapTableWithZone +NSCountMapTable +NSCreateMapTable +NSCreateMapTableWithZone +NSEnumerateMapTable +NSFreeMapTable +NSMapGet +NSMapInsert +NSMapInsertIfAbsent +NSMapInsertKnownAbsent +NSMapMember +NSMapRemove +NSNextMapEnumeratorPair +NSResetMapTable +NSStringFromMapTable +_NSMT_extra_describe +_NSMT_extra_release +_NSMT_extra_retain +_NSMT_key_compare +_NSMT_key_describe +_NSMT_key_hash +_NSMT_key_is_equal +_NSMT_key_release +_NSMT_key_retain +_NSMT_value_describe +_NSMT_value_release +_NSMT_value_retain +__objc_class_name_NSMethodSignature +__objc_class_name_NSNotification +__objc_class_name_NSNotificationCenter +__objc_class_name_NSNumber +NSClassFromString +NSSelectorFromString +NSStringFromClass +NSStringFromSelector +NSDecrementExtraRefCountWasZero +NSIncrementExtraRefCount +NSShouldRetainWithZone +__objc_category_name_NSObject_GNU +__objc_category_name_NSObject_NEXTSTEP +__objc_class_name_NSObject +NSAllocateMemoryPages +NSCopyMemoryPages +NSDeallocateMemoryPages +NSLogPageSize +NSPageSize +NSRealMemoryAvailable +NSRoundDownToMultipleOfPageSize +NSRoundUpToMultipleOfPageSize +__objc_class_name_NSProcessInfo +__objc_class_name__NSConcreteProcessInfo +NSEqualRanges +NSIntersectionRange +NSMakeRange +NSStringFromRange +NSUnionRange +__objc_class_name_NSRunLoop +__objc_class_name_NSScanner +__objc_class_name_NSMutableSet +__objc_class_name_NSSet +__objc_class_name_NSMutableString +__objc_class_name_NSString +__objc_class_name_NXConstantString +__objc_class_name_NSThread +__objc_class_name_NSTimer +__objc_category_name_NSConcreteTimeZoneDetail_NSCoding +__objc_category_name_NSConcreteTimeZoneDetail_NSCopying +__objc_category_name_NSTimeZone_Archiving +__objc_category_name_NSTimeZone_NSCopying +__objc_class_name_NSConcreteTimeZoneDetail +__objc_class_name_NSTimeZone +__objc_class_name_NSTimeZoneDetail +NSHomeDirectory +NSHomeDirectoryForUser +NSUserName +__objc_class_name_NSUserDefaults +__objc_class_name_NSValue +__objc_class_name_NSValueDecoder +NSCreateChildZone +NSCreateZone +NSDefaultMallocZone +NSDestroyZone +NSMallocCheck +NSMergeZone +NSNameZone +NSSetZoneName +NSZoneCalloc +NSZoneFree +NSZoneFromPointer +NSZoneMalloc +NSZoneName +NSZonePtrInfo +NSZoneRealloc +addtolist +delfromlist +searchheap +lstat +objc_find_executable +readlink +objc_load_module +objc_load_modules +objc_unload_module +objc_unload_modules +__objc_class_name_NSNonretainedObjectValue +__objc_class_name_NSPointValue +__objc_class_name_NSPointerValue +__objc_class_name_NSRectValue +__objc_class_name_NSSizeValue +__objc_class_name_NSBoolNumber +__objc_class_name_NSUCharNumber +__objc_class_name_NSCharNumber +__objc_class_name_NSUShortNumber +__objc_class_name_NSShortNumber +__objc_class_name_NSUIntNumber +__objc_class_name_NSIntNumber +__objc_class_name_NSULongNumber +__objc_class_name_NSLongNumber +__objc_class_name_NSULongLongNumber +__objc_class_name_NSLongLongNumber +__objc_class_name_NSFloatNumber +__objc_class_name_NSDoubleNumber diff --git a/Source/o_cbs_char_p.m b/Source/o_cbs_char_p.m index 642df795d..926ad7220 100644 --- a/Source/o_cbs_char_p.m +++ b/Source/o_cbs_char_p.m @@ -28,24 +28,6 @@ #include #include -/**** Type, Constant, and Macro Definitions **********************************/ - -/* FIXME: Is this right?!? */ -#define _OBJECTS_NOT_A_CHAR_P_MARKER (const void *)(-1) - -const void *o_not_a_char_p_marker = _OBJECTS_NOT_A_CHAR_P_MARKER; - -o_callbacks_t o_callbacks_for_char_p = -{ - (o_hash_func_t) o_char_p_hash, - (o_compare_func_t) o_char_p_compare, - (o_is_equal_func_t) o_char_p_is_equal, - (o_retain_func_t) o_char_p_retain, - (o_release_func_t) o_char_p_release, - (o_describe_func_t) o_char_p_describe, - _OBJECTS_NOT_A_CHAR_P_MARKER -}; - /**** Function Implementations ***********************************************/ size_t diff --git a/Source/o_cbs_id.m b/Source/o_cbs_id.m index bc92f3217..f7d87e540 100644 --- a/Source/o_cbs_id.m +++ b/Source/o_cbs_id.m @@ -29,24 +29,6 @@ #include #include -/**** Type, Constant, and Macro Definitions **********************************/ - -/* FIXME: Is this right?!? */ -#define _OBJECTS_NOT_AN_ID_MARKER (const void *)(-1) - -const void *o_not_an_id_marker = _OBJECTS_NOT_AN_ID_MARKER; - -o_callbacks_t o_callbacks_for_id = -{ - (o_hash_func_t) o_id_hash, - (o_compare_func_t) o_id_compare, - (o_is_equal_func_t) o_id_is_equal, - (o_retain_func_t) o_id_retain, - (o_release_func_t) o_id_release, - (o_describe_func_t) o_id_describe, - _OBJECTS_NOT_AN_ID_MARKER -}; - /**** Function Implementations ***********************************************/ /* FIXME: It sure would be nice if we had a way of checking whether diff --git a/Source/o_cbs_int.m b/Source/o_cbs_int.m index db3fcbbdf..41f5fd17b 100644 --- a/Source/o_cbs_int.m +++ b/Source/o_cbs_int.m @@ -28,24 +28,6 @@ #include #include -/**** Type, Constant, and Macro Definitions **********************************/ - -/* FIXME: This isn't right. Fix it. */ -#define _OBJECTS_NOT_AN_INT_MARKER (const void *)(-1) - -const void *o_not_an_int_marker = _OBJECTS_NOT_AN_INT_MARKER; - -o_callbacks_t o_callbacks_for_int = -{ - (o_hash_func_t) o_int_hash, - (o_compare_func_t) o_int_compare, - (o_is_equal_func_t) o_int_is_equal, - (o_retain_func_t) o_int_retain, - (o_release_func_t) o_int_release, - (o_describe_func_t) o_int_describe, - _OBJECTS_NOT_AN_INT_MARKER -}; - /**** Function Implementations ***********************************************/ /* FIXME: We (like OpenStep) make the big assumption here that diff --git a/Source/o_cbs_int_p.m b/Source/o_cbs_int_p.m index 6edbcb315..451f7d2d1 100644 --- a/Source/o_cbs_int_p.m +++ b/Source/o_cbs_int_p.m @@ -28,24 +28,6 @@ #include #include -/**** Type, Constant, and Macro Definitions **********************************/ - -/* FIXME: Is this right?!? */ -#define _OBJECTS_NOT_AN_INT_P_MARKER (const void *)(-1) - -const void *o_not_an_int_p_marker = _OBJECTS_NOT_AN_INT_P_MARKER; - -o_callbacks_t o_callbacks_for_int_p = -{ - (o_hash_func_t) o_int_p_hash, - (o_compare_func_t) o_int_p_compare, - (o_is_equal_func_t) o_int_p_is_equal, - (o_retain_func_t) o_int_p_retain, - (o_release_func_t) o_int_p_release, - (o_describe_func_t) o_int_p_describe, - _OBJECTS_NOT_AN_INT_P_MARKER -}; - /**** Function Implementations ***********************************************/ size_t diff --git a/Source/o_cbs_void_p.m b/Source/o_cbs_void_p.m index 2e76bd16a..6a286ad2b 100644 --- a/Source/o_cbs_void_p.m +++ b/Source/o_cbs_void_p.m @@ -28,33 +28,6 @@ #include #include -/**** Type, Constant, and Macro Definitions **********************************/ - -/* FIXME: Is this right?!? */ -#define _OBJECTS_NOT_A_VOID_P_MARKER (const void *)(-1) - -const void *o_not_a_void_p_marker = _OBJECTS_NOT_A_VOID_P_MARKER; - -o_callbacks_t o_callbacks_for_non_owned_void_p = -{ - (o_hash_func_t) o_non_owned_void_p_hash, - (o_compare_func_t) o_non_owned_void_p_compare, - (o_is_equal_func_t) o_non_owned_void_p_is_equal, - (o_retain_func_t) o_non_owned_void_p_retain, - (o_release_func_t) o_non_owned_void_p_release, - _OBJECTS_NOT_A_VOID_P_MARKER -}; - -o_callbacks_t o_callbacks_for_owned_void_p = -{ - (o_hash_func_t) o_owned_void_p_hash, - (o_compare_func_t) o_owned_void_p_compare, - (o_is_equal_func_t) o_owned_void_p_is_equal, - (o_retain_func_t) o_owned_void_p_retain, - (o_release_func_t) o_owned_void_p_release, - _OBJECTS_NOT_A_VOID_P_MARKER -}; - /**** Function Implementations ***********************************************/ size_t diff --git a/Source/win32-entry.c b/Source/win32-entry.c deleted file mode 100644 index 2e9e05db0..000000000 --- a/Source/win32-entry.c +++ /dev/null @@ -1,94 +0,0 @@ -/* DLL entry routine - Copyright (C) 1996 Free Software Foundation, Inc. - - Original Author: Scott Christley - Created: 1996 - - 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., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include - -/* Only if using Microsoft's tools and libraries */ -#ifdef __MS_WIN32__ -#include -WINBOOL WINAPI _CRT_INIT( HINSTANCE hinstDLL, DWORD fdwReason, - LPVOID lpReserved ); - -// Global errno isn't defined in Microsoft's thread safe C library -void errno() -{} - -int _MB_init_runtime() -{ - return 0; -} -#endif /* __MS_WIN32__ */ - -int gnustep_base_user_main(int argc, char *argv[], char *env[]) -{ - return 0; -} - -// -// DLL entry function for GNUstep Base Library -// This function gets called everytime a process/thread attaches to DLL -// -WINBOOL WINAPI DLLMain(HANDLE hInst, ULONG ul_reason_for_call, - LPVOID lpReserved) -{ - if (ul_reason_for_call == DLL_PROCESS_ATTACH) - { -#ifdef __MS_WIN32__ - /* Initialize C stdio DLL */ - _CRT_INIT(hInst, ul_reason_for_call, lpReserved); -#endif /* __MS_WIN32__ */ - - printf("GNUstep Base Library: process attach\n"); - - /* Initialize the GNUstep Base Library runtime structures */ - gnustep_base_init_runtime(); - } - - if (ul_reason_for_call == DLL_PROCESS_DETACH) - { - printf("GNUstep Base Library: process detach\n"); - } - - if (ul_reason_for_call == DLL_THREAD_ATTACH) - { -#ifdef __MS_WIN32__ - /* Initialize C stdio DLL */ - _CRT_INIT(hInst, ul_reason_for_call, lpReserved); -#endif /* __MS_WIN32__ */ - - printf("GNUstep Base Library: thread attach\n"); - - /* Initialize the Library? -not for threads? */ - gnustep_base_init_runtime(); - } - - if (ul_reason_for_call == DLL_THREAD_DETACH) - { - printf("GNUstep Base Library: thread detach\n"); - } - - return TRUE; -} - - - diff --git a/Source/win32-entry.m b/Source/win32-entry.m new file mode 100644 index 000000000..0034a7be0 --- /dev/null +++ b/Source/win32-entry.m @@ -0,0 +1,182 @@ +/* DLL entry routine + Copyright (C) 1996, 1997 Free Software Foundation, Inc. + + Original Author: Scott Christley + Created: 1996 + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include + +/* Only if using Microsoft's tools and libraries */ +#ifdef __MS_WIN32__ +#include +WINBOOL WINAPI _CRT_INIT( HINSTANCE hinstDLL, DWORD fdwReason, + LPVOID lpReserved ); + +// Global errno isn't defined in Microsoft's thread safe C library +void errno() +{} + +int _MB_init_runtime() +{ + return 0; +} +#endif /* __MS_WIN32__ */ + +int gnustep_base_user_main(int argc, char *argv[], char *env[]) +{ + return 0; +} + +LONG APIENTRY +gnustep_base_socket_handler(HWND hWnd, UINT message, + UINT wParam, LONG lParam); + +// +// Global variables for socket handler +// +HWND gnustep_base_wnd; + +// +// DLL entry function for GNUstep Base Library +// This function gets called everytime a process/thread attaches to DLL +// +WINBOOL WINAPI +DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) +{ + switch(ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + { + WNDCLASS wc; + WSADATA lpWSAData; + +#ifdef __MS_WIN32__ + /* Initialize the Microsoft C stdio DLL */ + _CRT_INIT(hInst, ul_reason_for_call, lpReserved); + + /* Initialize the GNUstep Base Library runtime structures */ + gnustep_base_init_runtime(); +#endif /* __MS_WIN32__ */ + + // Initialize Windows Sockets + if (WSAStartup(MAKEWORD(1,1), &lpWSAData)) + NSLog(@"Error: Could not startup Windows Sockets.\n"); + + // Register a window class for the socket handler + wc.lpszClassName = "GnustepBaseSocketHandler"; + wc.lpfnWndProc = gnustep_base_socket_handler; + wc.hInstance = hInst; + wc.hCursor = NULL; + wc.hIcon = NULL; + wc.hbrBackground = NULL; + wc.lpszMenuName = NULL; + wc.style = 0; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + + if (!RegisterClass(&wc)) + NSLog(@"Error: Could not register WIN32 socket handler class.\n"); + + // Create a window which will recieve the socket handling events + gnustep_base_wnd = CreateWindow("GNUstepBaseSocketHandler", + "", WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, CW_USEDEFAULT, + CW_USEDEFAULT, CW_USEDEFAULT, + NULL, NULL, hInst, NULL); + if (!gnustep_base_wnd) + NSLog(@"Error: Could not create WIN32 socket handler window.\n"); + + break; + } + + case DLL_PROCESS_DETACH: + { + DestroyWindow(gnustep_base_wnd); + break; + } + + case DLL_THREAD_ATTACH: + { +#ifdef __MS_WIN32__ + /* Initialize C stdio DLL */ + _CRT_INIT(hInst, ul_reason_for_call, lpReserved); +#endif /* __MS_WIN32__ */ + + break; + } + + case DLL_THREAD_DETACH: + { + break; + } + } + + return TRUE; +} + +// +// The window procedure for handling sockets +// +LONG APIENTRY +gnustep_base_socket_handler(HWND hWnd, UINT message, + UINT wParam, LONG lParam) +{ + WORD wEvent, wError; + + // If not a socket message then call the default window procedure + if (message != GNUSTEP_BASE_SOCKET_MESSAGE) + return DefWindowProc(hWnd, message, wParam, lParam); + + // Check for an error code + wError = WSAGETSELECTERROR(lParam); + if (wError != 0) + { + NSLog(@"Error: received socket error code %d\n", wError); + return 0; + } + + // Get the event + wEvent = WSAGETSELECTEVENT(lParam); + switch (wEvent) + { + case FD_READ: + NSLog(@"Got an FD_READ\n"); + break; + case FD_WRITE: + NSLog(@"Got an FD_WRITE\n"); + break; + case FD_OOB: + NSLog(@"Got an FD_OOB\n"); + break; + case FD_ACCEPT: + NSLog(@"Got an FD_ACCEPT\n"); + break; + case FD_CONNECT: + NSLog(@"Got an FD_CONNECT\n"); + break; + case FD_CLOSE: + NSLog(@"Got an FD_CLOSE\n"); + break; + default: + } + + return 0; +} + diff --git a/Testing/Makefile.in b/Testing/Makefile.in index 34792318c..ba469b63c 100644 --- a/Testing/Makefile.in +++ b/Testing/Makefile.in @@ -39,7 +39,7 @@ DYNAMIC_LDFLAGS=@DYNAMIC_LDFLAGS@ DYNAMIC_CFLAGS=@DYNAMIC_CFLAGS@ DEFS = @DEFS@ LIBS = -L../src @whole_archive@ -l$(LIBRARY_NAME) @no_whole_archive@ \ - @LIBOBJC@ @LIBS@ -lm + @LIBOBJC@ @LIBS@ EXEEXT = OEXT = .o diff --git a/Testing/NSData-test.m b/Testing/NSData-test.m index ae1b178b6..9c38b9ad0 100644 --- a/Testing/NSData-test.m +++ b/Testing/NSData-test.m @@ -11,10 +11,10 @@ ******************************************************************************/ #include -#include -#include -#include -#include +#include +#include +#include +#include /* Data for stuffing into *Data objects. I like printable data, as it * gives a quick visual check mechanism, but it has the disadvantage diff --git a/Testing/diningPhilosophers.m b/Testing/diningPhilosophers.m index f486673cb..bc7b49556 100644 --- a/Testing/diningPhilosophers.m +++ b/Testing/diningPhilosophers.m @@ -114,11 +114,6 @@ int main() int i; id p[5]; -#ifdef WIN32 - // Initialize ourselves in Obj-C runtime - init_diningPhilosophers(); -#endif - // Create the locks for (i = 0;i < 5; ++i) { diff --git a/Testing/nsattributedstring.m b/Testing/nsattributedstring.m index e59ebe6e1..f5f512078 100644 --- a/Testing/nsattributedstring.m +++ b/Testing/nsattributedstring.m @@ -31,7 +31,7 @@ #include #include #include -#include "NSAttributedString.h" +#include #include void printAttrString(NSAttributedString *attrStr) @@ -112,4 +112,11 @@ void testAttributedString(void) printAttrString(muAttrString2); printAttrString([muAttrString2 attributedSubstringFromRange:NSMakeRange(10,7)]); -} \ No newline at end of file +} + +/* xxx umm this file needs a main */ +int +main() +{ + exit(0); +} diff --git a/Testing/nsbundle.m b/Testing/nsbundle.m index 13e09422b..49000e457 100644 --- a/Testing/nsbundle.m +++ b/Testing/nsbundle.m @@ -7,7 +7,9 @@ This file is part of the GNUstep Base Library. */ +#ifndef __MINGW32__ #include +#endif #include "Foundation/NSBundle.h" #include "Foundation/NSException.h" #include "Foundation/NSString.h" diff --git a/configure.in b/configure.in index 5c1700589..dbc0b83bd 100644 --- a/configure.in +++ b/configure.in @@ -40,6 +40,20 @@ AC_CANONICAL_SYSTEM AC_PROG_CC AC_PROG_CPP +#-------------------------------------------------------------------- +# -pipe option for compiler +#-------------------------------------------------------------------- +PIPE='-pipe' +AC_SUBST(PIPE) + +#-------------------------------------------------------------------- +# Check for the pthreads and math library +#-------------------------------------------------------------------- +AC_CHECK_LIB(pcthread, pthread_create, + , + AC_CHECK_LIB(pthread, pthread_create)) +AC_CHECK_LIB(m, sqrt) + #-------------------------------------------------------------------- # Find out if we\'re using NeXT\'s compiler. # if yes: @@ -219,6 +233,12 @@ AC_CHECK_HEADERS(string.h memory.h) #-------------------------------------------------------------------- AC_CHECK_HEADERS(values.h) +#-------------------------------------------------------------------- +# Header files and functions for files and filesystems +#-------------------------------------------------------------------- +AC_CHECK_HEADERS(sys/stat.h sys/vfs.h sys/statfs.h) +AC_CHECK_FUNCS(statvfs) + #-------------------------------------------------------------------- # These two headers (functions) needed by Time.m #-------------------------------------------------------------------- @@ -265,11 +285,6 @@ AC_CHECK_FUNCS(getcwd) #-------------------------------------------------------------------- AC_HEADER_DIRENT -#-------------------------------------------------------------------- -# This function is needed by NSFileManager.m -#-------------------------------------------------------------------- -AC_CHECK_FUNCS(getcwd) - #-------------------------------------------------------------------- # This function needed by NSPage.m #-------------------------------------------------------------------- @@ -313,6 +328,29 @@ AC_CHECK_FUNCS(register_printf_function) AC_CHECK_LIB(socket, main) AC_CHECK_LIB(nsl, main) +#-------------------------------------------------------------------- +# Tools for making a DLL. +#-------------------------------------------------------------------- +DLLTOOL='dlltool' +AC_SUBST(DLLTOOL) + +#-------------------------------------------------------------------- +# Make a static library? +# Import library is the library for linking with a DLL. +#-------------------------------------------------------------------- +AC_ARG_ENABLE(static, +[ --disable-static Do not build the static library], +echo $enable_static +if [[ x$enable_static = xno ]]; then + STATIC_LIBRARY='' +else + STATIC_LIBRARY='lib$(LIBRARY_NAME)$(LIBEXT)' +fi, +STATIC_LIBRARY='lib$(LIBRARY_NAME)$(LIBEXT)') +IMPORT_LIBRARY=$STATIC_LIBRARY +AC_SUBST(STATIC_LIBRARY) +AC_SUBST(IMPORT_LIBRARY) + #-------------------------------------------------------------------- # Make a shared library? #-------------------------------------------------------------------- @@ -352,6 +390,25 @@ case "${target}" in i[[345]]86-*-cygwin32) whole_archive='-Wl,--whole-archive' no_whole_archive='-Wl,--no-whole-archive' + LIBS="$LIBS -ladvapi32" + # -pipe not supported + PIPE='' + ;; + i[[345]]86-*-mingw32) + whole_archive='-Wl,--whole-archive' + no_whole_archive='-Wl,--no-whole-archive' + LIBS="$LIBS -lwsock32 -ladvapi32 -luser32" + # Shared library is a DLL + if [[ x$SHARED_LIBRARY != x ]]; then + SHARED_LIBRARY='lib$(LIBRARY_NAME).dll' + # Rename static library if also building a shared library + if [[ x$STATIC_LIBRARY != x ]]; then + STATIC_LIBRARY='lib$(LIBRARY_NAME)_s$(LIBEXT)' + IMPORT_LIBRARY='lib$(LIBRARY_NAME)$(LIBEXT)' + fi + fi + # -pipe not supported + PIPE='' ;; esac