substrate-commits Mailing List for Objective-C Substrate (Page 2)
Brought to you by:
landonf
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(27) |
Sep
(18) |
Oct
|
Nov
|
Dec
(1) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <la...@us...> - 2006-08-31 22:26:27
|
Revision: 281
http://svn.sourceforge.net/substrate/?rev=281&view=rev
Author: landonf
Date: 2006-08-31 15:26:13 -0700 (Thu, 31 Aug 2006)
Log Message:
-----------
r5712@zadder: landonf | 2006-08-31 14:44:59 -0700
Checkpoint commit of old-style exception stack handling
Modified Paths:
--------------
trunk/Foundation/LFObjCRuntime.h.in
trunk/Foundation/Makefile.in
trunk/Foundation/NSConcreteData.m
trunk/Foundation/NSException.h
trunk/Foundation/NSException.m
Added Paths:
-----------
trunk/Foundation/LFObjCExceptionStack.m
trunk/Foundation/LFObjCGNUException.m
Removed Paths:
-------------
trunk/Foundation/LFObjCAppleRuntime.m
trunk/Foundation/LFObjCGNURuntime.m
trunk/Foundation/NSClassicException.h
trunk/Foundation/NSFuncallException.h
Property Changed:
----------------
trunk/
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 11572a18-12fc-0310-9209-f8edcc8181a7:/local/substrate/trunk:5684
+ 11572a18-12fc-0310-9209-f8edcc8181a7:/local/substrate/trunk:5712
Deleted: trunk/Foundation/LFObjCAppleRuntime.m
===================================================================
--- trunk/Foundation/LFObjCAppleRuntime.m 2006-08-31 07:30:41 UTC (rev 280)
+++ trunk/Foundation/LFObjCAppleRuntime.m 2006-08-31 22:26:13 UTC (rev 281)
@@ -1,288 +0,0 @@
-/*
- * LFObjCAppleRuntime.m vi:ts=4:sw=4:expandtab:
- * Apple Objective-C Runtime Abstraction and Support Code
- *
- * Copyright (C) 2005 - 2006 Landon Fuller <la...@op...>
- * All rights reserved.
- *
- * Author: Landon Fuller <la...@op...>
- *
- * This file is part of libFoundation.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation.
- *
- * We disclaim all warranties with regard to this software, including all
- * implied warranties of merchantability and fitness, in no event shall
- * we be liable for any special, indirect or consequential damages or any
- * damages whatsoever resulting from loss of use, data or profits, whether in
- * an action of contract, negligence or other tortious action, arising out of
- * or in connection with the use or performance of this software.
- */
-
-/*!
- * @file
- * @internal
- * @brief LFObjCRuntime
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef APPLE_RUNTIME
-
-/******************************************************************************
- * Supporting exceptions on Apple's runtime requires maintaining a per-thread
- * stack of exception handlers. Handlers are pushed and popped off the stack
- * at the beginning and end of every try/catch block, via a runtime function
- * call. When an exception occurs, our LFObjC_ExceptionThrow() function is
- * called, and we need to longjmp to the current exception handler at the top
- * of the per-thread handler stack.
- *****************************************************************************/
-
-#include <Foundation/NSZone.h>
-#include <Foundation/NSException.h>
-#include <Foundation/LFObjCRuntime.h>
-#include <Foundation/spin.h>
-
-#include <sys/types.h>
-#include <unistd.h>
-#include <assert.h>
-#include <stdlib.h>
-#include <pthread.h>
-#include <setjmp.h>
-
-/* Number of exception handlers to store in each bucket.
- * Selected arbitrarily. */
-#define EHS_BUCKET_SIZE 16
-
-/* Forward declarations */
-static void LFObjC_ExceptionThrow (id);
-static void LFObjC_ExceptionTryEnter (void *);
-static void LFObjC_ExceptionTryExit (void *);
-static id LFObjC_ExceptionExtract (void *);
-static int LFObjC_ExceptionMatch (Class, id);
-static void free_exception_handler_stack_tls (void *);
-
-/* The compiler will pass this structure to LFObjC_ExceptionThrow() */
-typedef struct LFObjCLocalExceptionData {
- jmp_buf buf;
- id *pointers[4];
-} LFObjCLocalExceptionData;
-
-/* Per-thread stack of exception handler buckets, each bucket
- * holds EHS_BUCKET_SIZE handlers */
-typedef struct LFExceptionHandlerBucket {
- int count;
- LFObjCLocalExceptionData *excData[EHS_BUCKET_SIZE];
- struct LFExceptionHandlerBucket *next;
-} LFExceptionHandlerBucket;
-
-/* We modify the pointer in this structure so that we don't
- * have to call pthread_setspecific() repeatedly */
-typedef struct LFExceptionHandler_TLS {
- LFExceptionHandlerBucket *bucket;
-} LFExceptionHandler_TLS;
-
-/* Per-thread EH stack key */
-static pthread_key_t LFExceptionHandlerStack_key;
-
-/*!
- * Exception handling functions for the Apple Objective-C runtime.
- * @internal
- */
-objc_exception_functions_t objc_exc_funcs = {
- 0,
- LFObjC_ExceptionThrow,
- LFObjC_ExceptionTryEnter,
- LFObjC_ExceptionTryExit,
- LFObjC_ExceptionExtract,
- LFObjC_ExceptionMatch
-};
-
-
-/* Uncaught exception handler */
-static LFUncaughtExceptionHandler *ueh_handler;
-static slock_t ueh_lock;
-
-/*!
- * Set Objective-C Uncaught Exception Handler.
- * @internal
- */
-LF_PRIVATE void LFObjCSetUncaughtExceptionHandler (LFUncaughtExceptionHandler *handler) {
- SpinLockAcquire(&ueh_lock);
- ueh_handler = handler;
- SpinLockRelease(&ueh_lock);
-}
-
-/*!
- * Get Objective-C Uncaught Exception Handler.
- * @internal
- */
-LF_PRIVATE LFUncaughtExceptionHandler *LFObjCGetUncaughtExceptionHandler (void) {
- LFUncaughtExceptionHandler *handler;
- SpinLockAcquire(&ueh_lock);
- handler = ueh_handler;
- SpinLockRelease(&ueh_lock);
-
- return handler;
-}
-
-/*!
- * Initialize the Objective-C Exception Handler.
- * @internal
- */
-LF_PRIVATE void LFObjCInitExceptionHandler (LFUncaughtExceptionHandler *handler) {
- /* Initialize the lock */
- SpinLockInit(&ueh_lock);
- ueh_handler = handler;
-
- /* Initialize our pthread key */
- pthread_key_create(&LFExceptionHandlerStack_key, free_exception_handler_stack_tls);
-
- /* Set up exception handling functions */
- objc_exception_set_functions((objc_exception_functions_t *) &objc_exc_funcs);
-}
-
-/*!
- * Throw an exception.
- * @internal
- */
-static void LFObjC_ExceptionThrow (id exception) {
- LFExceptionHandler_TLS *ehsTLS;
- LFObjCLocalExceptionData *lfexcData;
- LFExceptionHandlerBucket *bucket;
-
- /* Grab the stack */
- ehsTLS = (LFExceptionHandler_TLS *) pthread_getspecific(LFExceptionHandlerStack_key);
-
- /* If the stack is NULL or the bucket is empty, someone forgot to catch
- * the exception. Call the uncaught exception handler and fire SIGTRAP */
- if (!ehsTLS || !ehsTLS->bucket || ehsTLS->bucket->count == 0) {
- LFUncaughtExceptionHandler *handler;
-
- /* Acquire a lock and get the current ueh_handler */
- SpinLockAcquire(&ueh_lock);
- handler = ueh_handler;
- SpinLockRelease(&ueh_lock);
-
- /* Call and then fire SIGTRAP */
- handler(exception);
- kill(getpid(), SIGTRAP);
- }
-
- /* Pop our exception data */
- bucket = ehsTLS->bucket;
- assert(bucket);
- lfexcData = bucket->excData[bucket->count - 1];
- assert(lfexcData);
- bucket->count--;
-
- /* Store the exception in the first pointer */
- lfexcData->pointers[0] = (void *) exception;
-
- /* On my mark. */
- _longjmp(lfexcData->buf, 1);
-}
-
-/*!
- * Enter a @try/@catch block.
- * @internal
- */
-static void LFObjC_ExceptionTryEnter (void *excData) {
- LFExceptionHandler_TLS *ehsTLS;
- LFExceptionHandlerBucket *new, *bucket;
-
- /* Grab the stack */
- ehsTLS = (LFExceptionHandler_TLS *) pthread_getspecific(LFExceptionHandlerStack_key);
-
- /* Allocate and initialize the stack TLS holder if needed */
- if (!ehsTLS) {
- ehsTLS = NSZoneMalloc(NULL, sizeof(LFExceptionHandler_TLS));
- ehsTLS->bucket = NULL;
- pthread_setspecific(LFExceptionHandlerStack_key, ehsTLS);
- }
-
- /* Allocate and initialize a bucket if needed */
- if (!ehsTLS->bucket || ehsTLS->bucket->count == EHS_BUCKET_SIZE) {
- new = NSZoneMalloc(NULL, sizeof(LFExceptionHandlerBucket));
-
- /* Will either get set to NULL or the next bucket */
- new->next = ehsTLS->bucket;
- new->count = 0;
-
- ehsTLS->bucket = new;
- }
-
- /* Add our data to the bucket */
- bucket = ehsTLS->bucket;
- bucket->excData[bucket->count] = excData;
- bucket->count++;
-
- return;
-}
-
-/*!
- * Exit a @try/@catch block.
- * @internal
- */
-static void LFObjC_ExceptionTryExit (void *excData) {
- LFExceptionHandler_TLS *ehsTLS;
- LFExceptionHandlerBucket *bucket;
-
- /* Grab the stack */
- ehsTLS = (LFExceptionHandler_TLS *) pthread_getspecific(LFExceptionHandlerStack_key);
- assert(ehsTLS);
-
- /* Decrease the bucket count (ie, pop the excData) */
- bucket = ehsTLS->bucket;
- assert(bucket->excData[bucket->count - 1] == excData);
- bucket->count--;
-
- /* If the bucket is empty, and this isn't the last bucket available,
- * free the current bucket. */
- if (bucket->count == 0 && bucket->next != NULL) {
- ehsTLS->bucket = bucket->next;
- NSZoneFree(NULL, bucket);
- }
-
- return;
-}
-
-/*!
- * Extract the Objective-C object from the local exception data.
- * @internal
- */
-static id LFObjC_ExceptionExtract (void *excData) {
- LFObjCLocalExceptionData *lfexcData = (LFObjCLocalExceptionData *) excData;
- /* We stored the exception in the first pointer */
- return (id) lfexcData->pointers[0];
-}
-
-/*!
- * Match a given exception against the supplied class.
- * @internal
- */
-static int LFObjC_ExceptionMatch (Class excClass, id exception) {
- return [exception isKindOfClass: excClass];
-}
-
-/*!
- * Deallocate the exception stack TLS.
- * @internal
- */
-static void free_exception_handler_stack_tls (void *keyData) {
- LFExceptionHandler_TLS *ehsTLS = (LFExceptionHandler_TLS *) keyData;
-
- /* There will only ever be one bucket left behind by LFObjC_ExceptionTryExit() */
- if (ehsTLS->bucket)
- NSZoneFree(NULL, ehsTLS->bucket);
-
- NSZoneFree(NULL, ehsTLS);
-}
-
-#endif /* APPLE_RUNTIME */
Added: trunk/Foundation/LFObjCExceptionStack.m
===================================================================
--- trunk/Foundation/LFObjCExceptionStack.m (rev 0)
+++ trunk/Foundation/LFObjCExceptionStack.m 2006-08-31 22:26:13 UTC (rev 281)
@@ -0,0 +1,310 @@
+/*
+ * LFObjCExceptionStack.m vi:ts=4:sw=4:expandtab:
+ *
+ * Generic Exception Stack Implementation.
+ * Compatible with both new-style language exceptions as implemented by
+ * the Apple runtime, and old-style NS_DURING exceptions in both runtimes.
+ *
+ * Copyright (C) 2005 - 2006 Landon Fuller <la...@op...>
+ * All rights reserved.
+ *
+ * Author: Landon Fuller <la...@op...>
+ *
+ * This file is part of libFoundation.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation.
+ *
+ * We disclaim all warranties with regard to this software, including all
+ * implied warranties of merchantability and fitness, in no event shall
+ * we be liable for any special, indirect or consequential damages or any
+ * damages whatsoever resulting from loss of use, data or profits, whether in
+ * an action of contract, negligence or other tortious action, arising out of
+ * or in connection with the use or performance of this software.
+ */
+
+/*!
+ * @file
+ * @internal
+ * @brief LFObjCRuntime
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(APPLE_RUNTIME) || (defined(GNU_RUNTIME) && !defined(OBJC_EXCEPTIONS))
+
+/******************************************************************************
+ * This code implementions binary-compatible exception handling for both
+ * new and old-style exceptions in the Apple Objective-C runtime.
+ *
+ * It also implements non-binary compatible exception handling support for
+ * old-style exceptions in GNU's Objective-C runtime.
+ *
+ * We maintain a per-thread stack of exception handlers. Handlers are pushed
+ * and popped off the stack at the beginning and end of every try/catch block,
+ * via a runtime function call. When an exception occurs, our
+ * LFObjC_ExceptionThrow() function is called, and we need to longjmp to the
+ * current exception handler at the top of the per-thread handler stack.
+ *
+ * The push/pop runtime function calls are handled automatically by the
+ * new-style exception support in Apple's runtime. With old-style exceptions,
+ * we manually implement the equivalent using preprocessor macros.
+ *****************************************************************************/
+
+#include <Foundation/NSZone.h>
+#include <Foundation/NSException.h>
+#include <Foundation/LFObjCRuntime.h>
+#include <Foundation/spin.h>
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <setjmp.h>
+
+/* Number of exception handlers to store in each bucket.
+ * Selected arbitrarily. */
+#define EHS_BUCKET_SIZE 16
+
+/* Forward declarations */
+static void LFObjC_ExceptionThrow (id);
+static void LFObjC_ExceptionTryEnter (void *);
+static void LFObjC_ExceptionTryExit (void *);
+static id LFObjC_ExceptionExtract (void *);
+static int LFObjC_ExceptionMatch (Class, id);
+static void free_exception_handler_stack_tls (void *);
+
+/* Per-thread stack of exception handler buckets, each bucket
+ * holds EHS_BUCKET_SIZE handlers */
+typedef struct LFExceptionHandlerBucket {
+ int count;
+ LFObjCLocalExceptionData *excData[EHS_BUCKET_SIZE];
+ struct LFExceptionHandlerBucket *next;
+} LFExceptionHandlerBucket;
+
+/* We modify the pointer in this structure so that we don't
+ * have to call pthread_setspecific() repeatedly */
+typedef struct LFExceptionHandler_TLS {
+ LFExceptionHandlerBucket *bucket;
+} LFExceptionHandler_TLS;
+
+/* Per-thread EH stack key */
+static pthread_key_t LFExceptionHandlerStack_key;
+
+/* Uncaught exception handler */
+static LFUncaughtExceptionHandler *ueh_handler;
+static slock_t ueh_lock;
+
+/* Expose our exception stack functions */
+#if defined APPLE_RUNTIME
+/*!
+ * Exception handling functions for the Apple Objective-C runtime.
+ * @internal
+ */
+objc_exception_functions_t objc_exc_funcs = {
+ 0,
+ LFObjC_ExceptionThrow,
+ LFObjC_ExceptionTryEnter,
+ LFObjC_ExceptionTryExit,
+ LFObjC_ExceptionExtract,
+ LFObjC_ExceptionMatch
+};
+#endif /* APPLE_RUNTIME */
+
+void _NSAddHandler (LFObjCLocalExceptionData *excData) {
+ LFObjC_ExceptionTryEnter(excData);
+}
+
+void _NSRemoveHandler (LFObjCLocalExceptionData *excData) {
+ LFObjC_ExceptionTryExit(excData);
+}
+
+NSException *_NSExceptionFromHandler (LFObjCLocalExceptionData *excData) {
+ return LFObjC_ExceptionExtract(excData);
+}
+
+/*!
+ * Set Objective-C Uncaught Exception Handler.
+ * @internal
+ */
+LF_PRIVATE void LFObjCSetUncaughtExceptionHandler (LFUncaughtExceptionHandler *handler) {
+ SpinLockAcquire(&ueh_lock);
+ ueh_handler = handler;
+ SpinLockRelease(&ueh_lock);
+}
+
+/*!
+ * Get Objective-C Uncaught Exception Handler.
+ * @internal
+ */
+LF_PRIVATE LFUncaughtExceptionHandler *LFObjCGetUncaughtExceptionHandler (void) {
+ LFUncaughtExceptionHandler *handler;
+ SpinLockAcquire(&ueh_lock);
+ handler = ueh_handler;
+ SpinLockRelease(&ueh_lock);
+
+ return handler;
+}
+
+/*!
+ * Initialize the Objective-C Exception Handler.
+ * @internal
+ */
+LF_PRIVATE void LFObjCInitExceptionHandler (LFUncaughtExceptionHandler *handler) {
+ /* Initialize the lock */
+ SpinLockInit(&ueh_lock);
+ ueh_handler = handler;
+
+ /* Initialize our pthread key */
+ pthread_key_create(&LFExceptionHandlerStack_key, free_exception_handler_stack_tls);
+
+#if defined(APPLE_RUNTIME) && defined(OBJC_EXCEPTIONS)
+ /* Set up exception handling functions for the Apple runtime */
+ objc_exception_set_functions((objc_exception_functions_t *) &objc_exc_funcs);
+#endif
+}
+
+/*!
+ * Throw an exception.
+ * @internal
+ */
+LF_PRIVATE void LFObjC_ExceptionThrow (id exception) {
+ LFExceptionHandler_TLS *ehsTLS;
+ LFObjCLocalExceptionData *lfexcData;
+ LFExceptionHandlerBucket *bucket;
+
+ /* Grab the stack */
+ ehsTLS = (LFExceptionHandler_TLS *) pthread_getspecific(LFExceptionHandlerStack_key);
+
+ /* If the stack is NULL or the bucket is empty, someone forgot to catch
+ * the exception. Call the uncaught exception handler and fire SIGTRAP */
+ if (!ehsTLS || !ehsTLS->bucket || ehsTLS->bucket->count == 0) {
+ LFUncaughtExceptionHandler *handler;
+
+ /* Acquire a lock and get the current ueh_handler */
+ SpinLockAcquire(&ueh_lock);
+ handler = ueh_handler;
+ SpinLockRelease(&ueh_lock);
+
+ /* Call and then fire SIGTRAP */
+ handler(exception);
+ kill(getpid(), SIGTRAP);
+ }
+
+ /* Pop our exception data */
+ bucket = ehsTLS->bucket;
+ assert(bucket);
+ lfexcData = bucket->excData[bucket->count - 1];
+ assert(lfexcData);
+ bucket->count--;
+
+ /* Store the exception in the first pointer */
+ lfexcData->pointers[0] = (void *) exception;
+
+ /* On my mark. */
+ _longjmp(lfexcData->buf, 1);
+}
+
+/*!
+ * Enter a @try/@catch block.
+ * @internal
+ */
+static void LFObjC_ExceptionTryEnter (void *excData) {
+ LFExceptionHandler_TLS *ehsTLS;
+ LFExceptionHandlerBucket *new, *bucket;
+
+ /* Grab the stack */
+ ehsTLS = (LFExceptionHandler_TLS *) pthread_getspecific(LFExceptionHandlerStack_key);
+
+ /* Allocate and initialize the stack TLS holder if needed */
+ if (!ehsTLS) {
+ ehsTLS = NSZoneMalloc(NULL, sizeof(LFExceptionHandler_TLS));
+ ehsTLS->bucket = NULL;
+ pthread_setspecific(LFExceptionHandlerStack_key, ehsTLS);
+ }
+
+ /* Allocate and initialize a bucket if needed */
+ if (!ehsTLS->bucket || ehsTLS->bucket->count == EHS_BUCKET_SIZE) {
+ new = NSZoneMalloc(NULL, sizeof(LFExceptionHandlerBucket));
+
+ /* Will either get set to NULL or the next bucket */
+ new->next = ehsTLS->bucket;
+ new->count = 0;
+
+ ehsTLS->bucket = new;
+ }
+
+ /* Add our data to the bucket */
+ bucket = ehsTLS->bucket;
+ bucket->excData[bucket->count] = excData;
+ bucket->count++;
+
+ return;
+}
+
+/*!
+ * Exit a @try/@catch block.
+ * @internal
+ */
+static void LFObjC_ExceptionTryExit (void *excData) {
+ LFExceptionHandler_TLS *ehsTLS;
+ LFExceptionHandlerBucket *bucket;
+
+ /* Grab the stack */
+ ehsTLS = (LFExceptionHandler_TLS *) pthread_getspecific(LFExceptionHandlerStack_key);
+ assert(ehsTLS);
+
+ /* Decrease the bucket count (ie, pop the excData) */
+ bucket = ehsTLS->bucket;
+ assert(bucket->excData[bucket->count - 1] == excData);
+ bucket->count--;
+
+ /* If the bucket is empty, and this isn't the last bucket available,
+ * free the current bucket. */
+ if (bucket->count == 0 && bucket->next != NULL) {
+ ehsTLS->bucket = bucket->next;
+ NSZoneFree(NULL, bucket);
+ }
+
+ return;
+}
+
+/*!
+ * Extract the Objective-C object from the local exception data.
+ * @internal
+ */
+static id LFObjC_ExceptionExtract (void *excData) {
+ LFObjCLocalExceptionData *lfexcData = (LFObjCLocalExceptionData *) excData;
+ /* We stored the exception in the first pointer */
+ return (id) lfexcData->pointers[0];
+}
+
+/*!
+ * Match a given exception against the supplied class.
+ * @internal
+ */
+static int LFObjC_ExceptionMatch (Class excClass, id exception) {
+ return [exception isKindOfClass: excClass];
+}
+
+/*!
+ * Deallocate the exception stack TLS.
+ * @internal
+ */
+static void free_exception_handler_stack_tls (void *keyData) {
+ LFExceptionHandler_TLS *ehsTLS = (LFExceptionHandler_TLS *) keyData;
+
+ /* There will only ever be one bucket left behind by LFObjC_ExceptionTryExit() */
+ if (ehsTLS->bucket)
+ NSZoneFree(NULL, ehsTLS->bucket);
+
+ NSZoneFree(NULL, ehsTLS);
+}
+
+#endif /* APPLE_RUNTIME || (GNU_RUNTIME && !OBJC_EXCEPTIONS) */
Property changes on: trunk/Foundation/LFObjCExceptionStack.m
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/Foundation/LFObjCGNUException.m
===================================================================
--- trunk/Foundation/LFObjCGNUException.m (rev 0)
+++ trunk/Foundation/LFObjCGNUException.m 2006-08-31 22:26:13 UTC (rev 281)
@@ -0,0 +1,160 @@
+/*
+ * LFObjCGNUException.m vi:ts=4:sw=4:expandtab:
+ * New-style language exception handling for the GNU Objective-C runtime.
+ *
+ * Copyright (C) 2005 - 2006 Landon Fuller <la...@op...>
+ * All rights reserved.
+ *
+ * Author: Landon Fuller <la...@op...>
+ *
+ * This file is part of libFoundation.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation.
+ *
+ * We disclaim all warranties with regard to this software, including all
+ * implied warranties of merchantability and fitness, in no event shall
+ * we be liable for any special, indirect or consequential damages or any
+ * damages whatsoever resulting from loss of use, data or profits, whether in
+ * an action of contract, negligence or other tortious action, arising out of
+ * or in connection with the use or performance of this software.
+ */
+
+/*!
+ * @file
+ * @internal
+ * @brief LFObjCRuntime
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(GNU_RUNTIME) && defined(LF_OBJC_LANGUAGE_EXCEPTIONS)
+
+/* This is unfortunately required to use RTLD_NEXT on Linux systems */
+#define _GNU_SOURCE
+
+#include <Foundation/NSZone.h>
+#include <Foundation/NSException.h>
+#include <Foundation/LFObjCRuntime.h>
+#include <Foundation/spin.h>
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <signal.h>
+
+# include <dlfcn.h>
+/* GCC's exception handling and stack unwinding routines */
+# include <unwind.h>
+
+/* Uncaught exception handler */
+static LFUncaughtExceptionHandler *ueh_handler;
+static slock_t ueh_lock;
+
+/*! libgcc's _Unwind_RaiseException()
+ * @internal */
+static _Unwind_Reason_Code (*_real_Unwind_RaiseException)(struct _Unwind_Exception *e);
+
+/*!
+ * Set Objective-C Uncaught Exception Handler.
+ * @internal
+ */
+LF_PRIVATE void LFObjCSetUncaughtExceptionHandler (LFUncaughtExceptionHandler *handler) {
+ SpinLockAcquire(&ueh_lock);
+ ueh_handler = handler;
+ SpinLockRelease(&ueh_lock);
+}
+
+/*!
+ * Get Objective-C Uncaught Exception Handler.
+ * @internal
+ */
+LF_PRIVATE LFUncaughtExceptionHandler *LFObjCGetUncaughtExceptionHandler (void) {
+ LFUncaughtExceptionHandler *handler;
+ SpinLockAcquire(&ueh_lock);
+ handler = ueh_handler;
+ SpinLockRelease(&ueh_lock);
+
+ return handler;
+}
+
+/*!
+ * Initialize the Objective-C Exception Handler.
+ * @internal
+ */
+LF_PRIVATE void LFObjCInitExceptionHandler (LFUncaughtExceptionHandler *handler) {
+ /* Initialize the lock */
+ SpinLockInit(&ueh_lock);
+ ueh_handler = handler;
+
+#ifdef RTLD_NEXT
+ /* Locate the _Unwind_RaiseException symbol */
+ _real_Unwind_RaiseException = dlsym(RTLD_NEXT, "_Unwind_RaiseException");
+#endif /* RTLD_NEXT */
+
+}
+
+/*!
+ * Throw an exception.
+ * @internal
+ */
+LF_PRIVATE void LFObjC_ExceptionThrow (id exception) {
+ @throw exception;
+}
+
+/******************************************************************************
+ * XXX: Temporary Hack.
+ *
+ * When using the GNU Objective-C runtime, support for a default
+ * Objective-C exception handler is implemented by overriding gcc's
+ * _Unwind_RaiseException, calling the true _Unwind_RaiseException,
+ * and checking for _URC_END_OF_STACK, which signals that no exception
+ * handler was found.
+ *
+ * This is wrong, wrong, wrong, (really wrong!), but there is currently
+ * no other way to implement this functionality.
+ *
+ * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27466 for my libobjc
+ * enhancement request.
+ ******************************************************************************/
+
+/*! Our _Unwind_RaiseException()
+ * @internal */
+_Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *uwe) {
+ _Unwind_Reason_Code err;
+
+ err = _real_Unwind_RaiseException(uwe);
+ if (err == _URC_END_OF_STACK) {
+ LFUncaughtExceptionHandler *handler;
+
+ /* Acquire a lock and get the current ueh_handler */
+ SpinLockAcquire(&ueh_lock);
+ handler = ueh_handler;
+ SpinLockRelease(&ueh_lock);
+
+ /* If a handler is available, call it.
+ * We manually re-raise the _Unwind_Exception so that we can get
+ * access to the thrown Objective-C object without digging
+ * into the private libobjc structures */
+ @try {
+ _real_Unwind_RaiseException(uwe);
+ }
+ @catch (id exc) {
+ ueh_handler(exc);
+ }
+ }
+
+ /* Fire SIGTRAP */
+ kill(getpid(), SIGTRAP);
+
+ /* We're going to return objc_exception_throw(), where abort() will be
+ * called immediately. Unless someone caught SIGTRAP, this should
+ * be unreachable */
+ return err;
+}
+
+#endif /* GNU_RUNTIME && LF_OBJC_LANGUAGE_EXCEPTIONS */
Property changes on: trunk/Foundation/LFObjCGNUException.m
___________________________________________________________________
Name: svn:eol-style
+ native
Deleted: trunk/Foundation/LFObjCGNURuntime.m
===================================================================
--- trunk/Foundation/LFObjCGNURuntime.m 2006-08-31 07:30:41 UTC (rev 280)
+++ trunk/Foundation/LFObjCGNURuntime.m 2006-08-31 22:26:13 UTC (rev 281)
@@ -1,152 +0,0 @@
-/*
- * LFObjCGNURuntime.m vi:ts=4:sw=4:expandtab:
- * GNU Objective-C Runtime Abstraction and Support Code
- *
- * Copyright (C) 2005 - 2006 Landon Fuller <la...@op...>
- * All rights reserved.
- *
- * Author: Landon Fuller <la...@op...>
- *
- * This file is part of libFoundation.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation.
- *
- * We disclaim all warranties with regard to this software, including all
- * implied warranties of merchantability and fitness, in no event shall
- * we be liable for any special, indirect or consequential damages or any
- * damages whatsoever resulting from loss of use, data or profits, whether in
- * an action of contract, negligence or other tortious action, arising out of
- * or in connection with the use or performance of this software.
- */
-
-/*!
- * @file
- * @internal
- * @brief LFObjCRuntime
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef GNU_RUNTIME
-
-/* This is unfortunately required to use RTLD_NEXT on Linux systems */
-#define _GNU_SOURCE
-
-#include <Foundation/NSZone.h>
-#include <Foundation/NSException.h>
-#include <Foundation/LFObjCRuntime.h>
-#include <Foundation/spin.h>
-
-#include <sys/types.h>
-#include <unistd.h>
-#include <signal.h>
-
-# include <dlfcn.h>
-/* GCC's exception handling and stack unwinding routines */
-# include <unwind.h>
-
-/* Uncaught exception handler */
-static LFUncaughtExceptionHandler *ueh_handler;
-static slock_t ueh_lock;
-
-/*! libgcc's _Unwind_RaiseException()
- * @internal */
-static _Unwind_Reason_Code (*_real_Unwind_RaiseException)(struct _Unwind_Exception *e);
-
-/*!
- * Set Objective-C Uncaught Exception Handler.
- * @internal
- */
-LF_PRIVATE void LFObjCSetUncaughtExceptionHandler (LFUncaughtExceptionHandler *handler) {
- SpinLockAcquire(&ueh_lock);
- ueh_handler = handler;
- SpinLockRelease(&ueh_lock);
-}
-
-/*!
- * Get Objective-C Uncaught Exception Handler.
- * @internal
- */
-LF_PRIVATE LFUncaughtExceptionHandler *LFObjCGetUncaughtExceptionHandler (void) {
- LFUncaughtExceptionHandler *handler;
- SpinLockAcquire(&ueh_lock);
- handler = ueh_handler;
- SpinLockRelease(&ueh_lock);
-
- return handler;
-}
-
-/*!
- * Initialize the Objective-C Exception Handler.
- * @internal
- */
-LF_PRIVATE void LFObjCInitExceptionHandler (LFUncaughtExceptionHandler *handler) {
- /* Initialize the lock */
- SpinLockInit(&ueh_lock);
- ueh_handler = handler;
-
-#ifdef RTLD_NEXT
- /* Locate the _Unwind_RaiseException symbol */
- _real_Unwind_RaiseException = dlsym(RTLD_NEXT, "_Unwind_RaiseException");
-#endif /* RTLD_NEXT */
-
-}
-
-/******************************************************************************
- * XXX: Temporary Hack.
- *
- * When using the GNU Objective-C runtime, support for a default
- * Objective-C exception handler is implemented by overriding gcc's
- * _Unwind_RaiseException, calling the true _Unwind_RaiseException,
- * and checking for _URC_END_OF_STACK, which signals that no exception
- * handler was found.
- *
- * This is wrong, wrong, wrong, (really wrong!), but there is currently
- * no other way to implement this functionality.
- *
- * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27466 for my libobjc
- * enhancement request.
- ******************************************************************************/
-
-/*! Our _Unwind_RaiseException()
- * @internal */
-_Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *uwe) {
- _Unwind_Reason_Code err;
-
- err = _real_Unwind_RaiseException(uwe);
- if (err == _URC_END_OF_STACK) {
- LFUncaughtExceptionHandler *handler;
-
- /* Acquire a lock and get the current ueh_handler */
- SpinLockAcquire(&ueh_lock);
- handler = ueh_handler;
- SpinLockRelease(&ueh_lock);
-
- /* If a handler is available, call it.
- * We manually re-raise the _Unwind_Exception so that we can get
- * access to the thrown Objective-C object without digging
- * into the private libobjc structures */
- @try {
- _real_Unwind_RaiseException(uwe);
- }
- @catch (id exc) {
- ueh_handler(exc);
- }
- }
-
- /* Fire SIGTRAP */
- kill(getpid(), SIGTRAP);
-
- /* We're going to return objc_exception_throw(), where abort() will be
- * called immediately. Unless someone caught SIGTRAP, this should
- * be unreachable */
- return err;
-}
-
-#endif /* GNU_RUNTIME */
Modified: trunk/Foundation/LFObjCRuntime.h.in
===================================================================
--- trunk/Foundation/LFObjCRuntime.h.in 2006-08-31 07:30:41 UTC (rev 280)
+++ trunk/Foundation/LFObjCRuntime.h.in 2006-08-31 22:26:13 UTC (rev 281)
@@ -39,10 +39,14 @@
@class NSException;
+/* Apple or GNU Runtime */
#ifndef @OBJC_RUNTIME@
#define @OBJC_RUNTIME@ 1
#endif
+/* Exception Handling Implementation */
+@OBJC_EXCEPTIONS_DEFINE@
+
/* Include stdint.h if available */
@LF_STDINT_INC@
@@ -83,10 +87,6 @@
#define LFObjectGetSuperclass(obj) LFClassGetSuperclass(LFObjectGetClass(obj))
#define LFMethodGetIMP(method) (method != NULL ? method->method_imp : NULL)
-/*
- * Exception handling
- */
-
#ifdef LF_SPI
/*!
@@ -100,20 +100,26 @@
* Initialize the Apple or GNU Objective-C exception handler.
* @internal
*/
-void LFObjCInitExceptionHandler (LFUncaughtExceptionHandler *handler);
+LF_PRIVATE void LFObjCInitExceptionHandler (LFUncaughtExceptionHandler *handler);
/*!
* Set the uncaught exception handler.
* @internal
*/
-void LFObjCSetUncaughtExceptionHandler (LFUncaughtExceptionHandler *handler);
+LF_PRIVATE void LFObjCSetUncaughtExceptionHandler (LFUncaughtExceptionHandler *handler);
/*!
* Get the uncaught exception handler.
* @internal
*/
-LFUncaughtExceptionHandler *LFObjCGetUncaughtExceptionHandler (void);
+LF_PRIVATE LFUncaughtExceptionHandler *LFObjCGetUncaughtExceptionHandler (void);
+/*!
+ * Throw an exception.
+ * @internal
+ */
+LF_PRIVATE void LFObjC_ExceptionThrow (id exception);
+
#endif /* LF_SPI */
#if defined(GNU_RUNTIME)
Modified: trunk/Foundation/Makefile.in
===================================================================
--- trunk/Foundation/Makefile.in 2006-08-31 07:30:41 UTC (rev 280)
+++ trunk/Foundation/Makefile.in 2006-08-31 22:26:13 UTC (rev 281)
@@ -45,8 +45,8 @@
NSUnicodeString.m \
NSSimpleCString.m \
NSZone.m \
- LFObjCAppleRuntime.m \
- LFObjCGNURuntime.m \
+ LFObjCExceptionStack.m \
+ LFObjCGNUException.m \
LFHash.c \
s_lock.c \
$(TAS_SRC)
@@ -64,8 +64,8 @@
NSUnicodeString.o \
NSSimpleCString.o \
NSZone.o \
- LFObjCAppleRuntime.o \
- LFObjCGNURuntime.o \
+ LFObjCExceptionStack.o \
+ LFObjCGNUException.o \
LFHash.o \
s_lock.o \
$(TAS_OBJS)
@@ -96,7 +96,8 @@
# File Substitutions
EDIT= sed \
-e 's,@OBJC_RUNTIME\@,$(OBJC_RUNTIME),g' \
- -e 's,@LF_STDINT_INC\@,$(LF_STDINT_INC),g'
+ -e 's,@LF_STDINT_INC\@,$(LF_STDINT_INC),g' \
+ -e 's,@OBJC_EXCEPTIONS_DEFINE\@,$(OBJC_EXCEPTIONS_DEFINE),g'
# Generated File(s)
LFObjCRuntime.h: LFObjCRuntime.h.in
Deleted: trunk/Foundation/NSClassicException.h
===================================================================
--- trunk/Foundation/NSClassicException.h 2006-08-31 07:30:41 UTC (rev 280)
+++ trunk/Foundation/NSClassicException.h 2006-08-31 22:26:13 UTC (rev 281)
@@ -1,315 +0,0 @@
-/*
- NSClassicException.h
-
- Copyright (C) 1995, 1996 Ovidiu Predescu and Mircea Oancea.
- All rights reserved.
-
- Author: Ovidiu Predescu <ov...@bx...>
-
- This file is part of libFoundation.
-
- Permission to use, copy, modify, and distribute this software and its
- documentation for any purpose and without fee is hereby granted, provided
- that the above copyright notice appear in all copies and that both that
- copyright notice and this permission notice appear in supporting
- documentation.
-
- We disclaim all warranties with regard to this software, including all
- implied warranties of merchantability and fitness, in no event shall
- we be liable for any special, indirect or consequential damages or any
- damages whatsoever resulting from loss of use, data or profits, whether in
- an action of contract, negligence or other tortious action, arising out of
- or in connection with the use or performance of this software.
-*/
-
-#ifndef __NSException_h__
-#define __NSException_h__
-
-#include <setjmp.h>
-#include <stdarg.h>
-#include <Foundation/NSString.h>
-#include <Foundation/NSArray.h>
-
-@interface NSException : NSObject
-{
- NSString* name;
- NSString* reason;
- NSDictionary* userInfo;
-}
-
-/* Class initalization */
-+ (void)taskNowMultiThreaded:notification;
-
-/* Creating and Raising Exceptions */
-+ (NSException*)exceptionWithName:(NSString*)name
- reason:(NSString*)reason
- userInfo:(NSDictionary*)userInfo;
-+ (void)raise:(NSString *)name
- format:(NSString *)format,...;
-+ (void)raise:(NSString*)name
- format:(NSString*)format
- arguments:(va_list)argList;
-
-- (id)initWithName:(NSString*)name
- reason:(NSString*)reason
- userInfo:(NSDictionary*)userInfo;
-- (void)raise;
-
-/* Querying Exceptions */
-- (NSString*)name;
-- (NSString*)reason;
-- (NSDictionary*)userInfo;
-
-@end /* NSException */
-
-
-@interface NSException (Extensions)
-- (BOOL)exceptionIsKindOfClass:(Class)class;
- /* return [self isKindOfClass:class] */
-- (BOOL)exceptionIsIn:(NSArray*)exceptions;
-- (NSString*)errorString;
-- initWithFormat:(NSString*)format, ...;
-- setName:(NSString*)name;
-- setReason:(NSString*)reason;
-- setUserInfo:(NSDictionary*)userInfo;
-@end /* NSException (Extension) */
-
-
-typedef void NSUncaughtExceptionHandler(NSException *exception);
-
-NSUncaughtExceptionHandler *NSGetUncaughtExceptionHandler(void);
-void NSSetUncaughtExceptionHandler(NSUncaughtExceptionHandler *handler);
-
-/* Exception names */
-LF_EXPORT NSString *NSInconsistentArchiveException;
-LF_EXPORT NSString *NSGenericException;
-LF_EXPORT NSString *NSInternalInconsistencyException;
-LF_EXPORT NSString *NSInvalidArgumentException;
-LF_EXPORT NSString *NSMallocException;
-LF_EXPORT NSString *NSObjectInaccessibleException;
-LF_EXPORT NSString *NSObjectNotAvailableException;
-LF_EXPORT NSString *NSDestinationInvalidException;
-LF_EXPORT NSString *NSPortTimeoutException;
-LF_EXPORT NSString *NSInvalidSendPortException;
-LF_EXPORT NSString *NSInvalidReceivePortException;
-LF_EXPORT NSString *NSPortSendException;
-LF_EXPORT NSString *NSPortReceiveException;
-LF_EXPORT NSString *NSOldStyleException;
-LF_EXPORT NSString *NSRangeException;
-
-
-typedef struct _NSHandler
-{
- struct _NSHandler* previousHandler;
- jmp_buf jmpState;
- NSException* exception;
-} NSHandler;
-
-LF_EXPORT void _NSAddHandler(NSHandler *handler);
-LF_EXPORT void _NSRemoveHandler(NSHandler *handler);
-
-/* OpenStep macros for exception handling. */
-
-#define NS_DURING \
-({ \
- __label__ _quit; \
- NSHandler exceptionHandler; \
- if(!setjmp(exceptionHandler.jmpState)) { \
- _NSAddHandler(&exceptionHandler);
-
-#define NS_HANDLER \
- _NSRemoveHandler(&exceptionHandler); \
- goto _quit; /* to remove compiler warning about unused label*/ \
- } \
- else { \
- NSException* localException = exceptionHandler.exception; \
- _NSRemoveHandler(&exceptionHandler); \
-
-#define NS_ENDHANDLER \
- localException = nil; /* Avoid compiler warning */ \
- } \
-_quit: 0;\
-});
-
-#define NS_VALRETURN(value) \
- ({_NSRemoveHandler(&exceptionHandler); return (value);})
-
-#define NS_VOIDRETURN \
- ({_NSRemoveHandler(&exceptionHandler); return;})
-
-
-/*
- * The new macros for handling exceptions.
- */
-
-#define TRY \
-({ \
- __label__ _quit; \
- NSHandler exceptionHandler; \
- volatile int __setjmp_ret = setjmp(exceptionHandler.jmpState); \
- if(!__setjmp_ret) { \
- _NSAddHandler(&exceptionHandler);
-
-#define END_TRY \
- _NSRemoveHandler(&exceptionHandler); \
- goto _quit; /* to remove compiler warning about unused label */ \
- } \
-_quit: \
- { \
- void handler(NSException* localException) \
- { \
- BOOL _caught = NO; \
- if(localException) \
- _NSRemoveHandler(&exceptionHandler); \
- if(!localException) {
-
-#define CATCH(exception_class) \
- } else if([localException isKindOfClass:[exception_class class]]) { \
- _caught = YES;
-
-#ifndef PRECOMP
-# define MULTICATCH(exception_classes...) \
- } else if([localException exceptionIsIn: \
- [NSArray arrayWithObjects:##exception_classes, nil]]) { \
- _caught = YES;
-#endif /* PRECOMP */
-
-#define OTHERWISE \
- } else { \
- _caught = YES;
-
-#define CLEANUP \
- } \
- if(localException && !_caught) {
-
-#define FINALLY \
- } \
- if(1) {
-
-#define END_CATCH \
- } \
- if(!localException) return; \
- if(!_caught) \
- [localException raise]; \
- else RELEASE(localException); \
- } \
- handler(__setjmp_ret == 1 ? exceptionHandler.exception : nil); \
- } \
-});
-
- /* Use BREAK inside a TRY block to get out of it */
-#define BREAK ({_NSRemoveHandler(&exceptionHandler); goto _quit;})
-
-#ifndef PRECOMP
- /* If you want to generate an exception issue a THROW with the exception
- an object derived from the NSException class. */
-# define THROW(exception...) [##exception raise]
-#else
-# define THROW(exception) [exception raise]
-#endif /* PRECOMP */
-
- /* If you want to reraise an exception inside an exception handler
- just say RERAISE. */
-#define RERAISE THROW(localException)
-
-
-/*
- * Assertions.
- */
-
-#ifndef __FoundationException_definition__
-#define __FoundationException_definition__
-
-@interface FoundationException : NSException
-@end
-
-#endif /* __FoundationException_definition__ */
-
-@interface AssertException : FoundationException
-@end
-
-
-@interface NSAssertionHandler : NSObject
-
-/* Getting the Current Handler */
-+ (NSAssertionHandler*)currentHandler;
-
-/* Handling Failures */
-- (void)handleFailureInFunction:(NSString*)functionName
- file:(NSString*)fileName
- lineNumber:(int)line
- description:(NSString*)format,...;
-- (void)handleFailureInMethod:(SEL)selector
- object:(id)object
- file:(NSString*)fileName
- lineNumber:(int)line
- description:(NSString*)format,...;
-
-@end
-
-#ifndef PRECOMP
-
-#define NSAssert(condition, desc, arguments...) \
- ({ if(!(condition)) \
- [[NSAssertionHandler currentHandler] \
- handleFailureInMethod:_cmd \
- object:self \
- file:[NSString stringWithCString:__FILE__] \
- lineNumber:__LINE__ \
- description:(desc) , ##arguments]; \
- 0;})
-
-#define NSCAssert(condition, desc, arguments...) \
- ({ if(!(condition)) \
- [[NSAssertionHandler currentHandler] \
- handleFailureInFunction: \
- [NSString stringWithCString:__PRETTY_FUNCTION__] \
- file:[NSString stringWithCString:__FILE__] \
- lineNumber:__LINE__ \
- description:(desc) , ##arguments]; \
- 0;})
-
-#define Assert(condition) \
- ({if(!(condition)) {\
- NSLog([(@#condition) stringByPrependingString:@"Assertion failed: "]); \
- THROW([AssertException new]); \
- } \
- 0;})
-
-# define NSParameterAssert(condition) \
- ({if(!(condition)) {\
- NSLog([(@#condition) stringByPrependingString:@"Parameter Assertion failed: "]); \
- THROW([AssertException new]); \
- } \
- 0;})
-
-# define NSCParameterAssert(condition) \
- ({if(!(condition)) {\
- NSLog([(@#condition) stringByPrependingString:@"Parameter Assertion failed: "]); \
- THROW([AssertException new]); \
- } \
- 0;})
-
-#define NSAssert1(args...) NSAssert(##args)
-#define NSAssert2(args...) NSAssert(##args)
-#define NSAssert3(args...) NSAssert(##args)
-#define NSAssert4(args...) NSAssert(##args)
-#define NSAssert5(args...) NSAssert(##args)
-
-#define NSCAssert1(args...) NSCAssert(##args)
-#define NSCAssert2(args...) NSCAssert(##args)
-#define NSCAssert3(args...) NSCAssert(##args)
-#define NSCAssert4(args...) NSCAssert(##args)
-#define NSCAssert5(args...) NSCAssert(##args)
-
-#endif /* PRECOMP */
-
-
-#endif /* __NSException_h__ */
-
-/*
- Local Variables:
- c-basic-offset: 4
- tab-width: 8
- End:
-*/
Modified: trunk/Foundation/NSConcreteData.m
===================================================================
--- trunk/Foundation/NSConcreteData.m 2006-08-31 07:30:41 UTC (rev 280)
+++ trunk/Foundation/NSConcreteData.m 2006-08-31 22:26:13 UTC (rev 281)
@@ -94,7 +94,7 @@
}
@catch (id e) {
NSZoneFree(NULL, buffer);
- @throw e;
+ LFObjC_ExceptionThrow(e);
}
/* Instantiated NSData instances will free buffer upon deallocation */
Modified: trunk/Foundation/NSException.h
===================================================================
--- trunk/Foundation/NSException.h 2006-08-31 07:30:41 UTC (rev 280)
+++ trunk/Foundation/NSException.h 2006-08-31 22:26:13 UTC (rev 281)
@@ -36,6 +36,7 @@
#include <Foundation/NSString.h>
#include <stdarg.h>
+#include <setjmp.h>
@class NSString, NSDictionary;
@@ -77,7 +78,7 @@
@end
/*!
- * Function type used for NSSetUncaughtExceptionHandler() and NSGetUncaughtExceptionHandler()
+ * Function type used for NSSetUncaughtExceptionHandler() and NSGetUncaughtExceptionHandler().
* @ingroup NSException
*/
typedef void NSUncaughtExceptionHandler (NSException *exception);
@@ -85,11 +86,58 @@
void NSSetUncaughtExceptionHandler(NSUncaughtExceptionHandler *handler);
NSUncaughtExceptionHandler *NSGetUncaughtExceptionHandler(void);
-/* Legacy Exception Handling */
-#define NS_DURING @try {
-#define NS_HANDLER } @catch (NSException *localException) {
-#define NS_ENDHANDLER }
-#define NS_VALUERETURN(val, type) return (val);
-#define NS_VOIDRETURN return;
+/*
+ * Exception handling for the Apple runtime, and old-style exceptions
+ * in the GNU runtime.
+ *
+ * When language exceptions are enabled with Apple's runtime, the compiler
+ * will pass this structure to LFObjC_ExceptionThrow().
+ * Alternatively, old-style exception handling passes this structure manually.
+ *
+ * Do not touch these data structures, do not call these functions manually.
+ */
+typedef struct LFObjCLocalExceptionData {
+ jmp_buf buf;
+ void *pointers[4]; /* The exception is stored in the first pointer */
+} LFObjCLocalExceptionData;
+void _NSAddHandler (LFObjCLocalExceptionData *excData);
+void _NSRemoveHandler (LFObjCLocalExceptionData *excData);
+NSException *_NSExceptionFromHandler (LFObjCLocalExceptionData *excData);
+
+#ifdef LF_OBJC_LANGUAGE_EXCEPTIONS
+/* New-style Exception Handling */
+# define NS_DURING @try {
+# define NS_HANDLER } @catch (NSException *localException) {
+# define NS_ENDHANDLER }
+# define NS_VALUERETURN(val, type) return (val);
+# define NS_VOIDRETURN return;
+#else
+/* Old-style Exception Handling */
+# define NS_DURING { \
+ LFObjCLocalExceptionData _localHandler; \
+ if(!_setjmp(_localHandler.buf)) { \
+ _NSAddHandler(&_localHandler);
+
+#define NS_HANDLER \
+ _NSRemoveHandler(&_localHandler); \
+ } else { \
+ NSException *localException = _NSExceptionFromHandler(&_localHandler);
+
+#define NS_ENDHANDLER \
+ localException = nil; /* Avoid compiler warning */ \
+ } \
+}
+
+# define NS_VALUERETURN(value, type) { \
+ return (value); \
+}
+
+# define NS_VOIDRETURN { \
+ _NSRemoveHandler(&_localHandler); \
+ return; \
+}
+
+#endif /* !LF_OBJC_LANGUAGE_EXCEPTIONS */
+
#endif /* __NSException_h__ */
Modified: trunk/Foundation/NSException.m
===================================================================
--- trunk/Foundation/NSException.m 2006-08-31 07:30:41 UTC (rev 280)
+++ trunk/Foundation/NSException.m 2006-08-31 22:26:13 UTC (rev 281)
@@ -245,7 +245,7 @@
* Raise the receiver.
*/
- (void) raise {
- @throw self;
+ LFObjC_ExceptionThrow(self);
}
Deleted: trunk/Foundation/NSFuncallException.h
===================================================================
--- trunk/Foundation/NSFuncallException.h 2006-08-31 07:30:41 UTC (rev 280)
+++ trunk/Foundation/NSFuncallException.h 2006-08-31 22:26:13 UTC (rev 281)
@@ -1,391 +0,0 @@
-/*
- NSFuncallException.h
-
- Copyright (C) 1995, 1996 Ovidiu Predescu and Mircea Oancea.
- All rights reserved.
-
- Author: Ovidiu Predescu <ov...@bx...>
-
- This file is part of libFoundation.
-
- Permission to use, copy, modify, and distribute this software and its
- documentation for any purpose and without fee is hereby granted, provided
- that the above copyright notice appear in all copies and that both that
- copyright notice and this permission notice appear in supporting
- documentation.
-
- We disclaim all warranties with regard to this software, including all
- implied warranties of merchantability and fitness, in no event shall
- we be liable for any special, indirect or consequential damages or any
- damages whatsoever resulting from loss of use, data or profits, whether in
- an action of contract, negligence or other tortious action, arising out of
- or in connection with the use or performance of this software.
-*/
-
-#ifndef __NSException_h__
-#define __NSException_h__
-
-#include <setjmp.h>
-#include <stdarg.h>
-#include <Foundation/NSString.h>
-#include <Foundation/NSArray.h>
-
-@class NSDictionary;
-
-@interface NSException : NSObject
-{
- NSString *name;
- NSString *reason;
- NSDictionary *userInfo;
-}
-
-/* Creating and Raising Exceptions */
-
-+ (NSException *)exceptionWithName:(NSString *)name
- reason:(NSString *)reason
- userInfo:(NSDictionary *)userInfo;
-+ (void)raise:(NSString *)name
- format:(NSString *)format,...;
-+ (void)raise:(NSString *)name
- format:(NSString *)format
- arguments:(va_list)argList;
-
-- (id)initWithName:(NSString *)name
- reason:(NSString *)reason
- userInfo:(NSDictionary *)userInfo;
-- (void)raise;
-
-/* Querying Exceptions */
-
-- (NSString *)name;
-- (NSString *)reason;
-- (NSDictionary *)userInfo;
-
-@end /* NSException */
-
-
-@interface NSException (Extensions)
-- (BOOL)exceptionIsKindOfClass:(Class)class;
- /* return [self isKindOfClass:class] */
-- (BOOL)exceptionIsIn:(NSArray *)exceptions;
-- (NSString *)errorString;
-- (id)initWithFormat:(NSString *)format, ...;
-- (id)initWithFormat:(NSString *)format arguments:(va_list)ap;
-- (id)setName:(NSString *)name;
-- (id)setReason:(NSString *)reason;
-- (id)setUserInfo:(NSDictionary *)userInfo;
-@end /* NSException (Extension) */
-
-@interface NSException (Backtrace)
-+ (NSString *)backtrace;
-+ (void)printBacktrace;
-@end /* NSException(Backtrace) */
-
-typedef void NSUncaughtExceptionHandler(NSException *exception);
-
-NSUncaughtExceptionHandler *NSGetUncaughtExceptionHandler(void);
-void NSSetUncaughtExceptionHandler(NSUncaughtExceptionHandler *handler);
-
-/* Exception names */
-LF_EXPORT NSString *NSInconsistentArchiveException;
-LF_EXPORT NSString *NSGenericException;
-LF_EXPORT NSString *NSInternalInconsistencyException;
-LF_EXPORT NSString *NSInvalidArgumentException;
-LF_EXPORT NSString *NSMallocException;
-LF_EXPORT NSString *NSObjectInaccessibleException;
-LF_EXPORT NSString *NSObjectNotAvailableException;
-LF_EXPORT NSString *NSDestinationInvalidException;
-LF_EXPORT NSString *NSPortTimeoutException;
-LF_EXPORT NSString *NSInvalidSendPortException;
-LF_EXPORT NSString *NSInvalidReceivePortException;
-LF_EXPORT NSString *NSPortSendException;
-LF_EXPORT NSString *NSPortReceiveException;
-LF_EXPORT NSString *NSOldStyleException;
-LF_EXPORT NSString *NSRangeException;
-
-/* OpenStep macros for exception handling.
- Use the ones defined below instead. */
-
-#define NS_DURING TRY {
-
-#define NS_HANDLER } END_TRY OTHERWISE {
-
-#define NS_ENDHANDLER } END_CATCH
-
-#define NS_VALRETURN(value) \
- ({_NSRemoveHandler(&exceptionHandler); handler(nil); return (value);})
-
-#define NS_VOIDRETURN \
- ({_NSRemoveHandler(&exceptionHandler); handler(nil); return;})
-
-typedef void (*THandlerFunction)(id);
-
-typedef struct _NSHandler
-{
- struct _NSHandler *previousHandler;
- jmp_buf jmpState;
- THandlerFunction handler;
-} NSHandler;
-
-LF_EXPORT void _NSAddHandler(NSHandler *handler);
-LF_EXPORT void _NSRemoveHandler(NSHandler *handler);
-
-
-/*
- * The new macros for handling exceptions.
- */
-
-#define TRY \
-{ \
- auto void handler(); \
- NSHandler exceptionHandler; \
-\
- int _dummy = \
- ({ \
- __label__ _quit; \
- if(!setjmp(exceptionHandler.jmpState)) { \
- exceptionHandler.handler = handler; \
- _NSAddHandler(&exceptionHandler);
-
-#define END_TRY \
- _NSRemoveHandler(&exceptionHandler); \
- handler(nil); \
- goto _quit; /* to remove compiler warning about unused label*/ \
- }; \
- _quit: 0; \
- }); \
- void handler(NSException *localException) \
- { \
- BOOL _caught = NO; \
- RETAIN(localException);\
- if (localException != nil) \
- _NSRemoveHandler(&exceptionHandler); \
- if (localException == nil) { _dummy++;
-
-#define CATCH(exception_class) \
- } else if([localException exceptionIsKindOfClass:[exception_class class]]) { \
- _caught = YES;
-
-#ifndef PRECOMP
-# define MULTICATCH(exception_classes...) \
- } else if ([localException exceptionIsIn: \
- [NSArray arrayWithObjects:##exception_classes, nil]]) { \
- _caught = YES;
-#endif /* PRECOMP */
-
-#define OTHERWISE \
- } else { \
- _caught = YES;
-
-#define CLEANUP \
- } \
- if(localException && !_caught) {
-
-#define FINALLY \
- } \
- if(1) {
-
-#define END_CATCH \
- } \
- if (localException==nil) return; \
- if (!_caught) \
- [localException raise]; \
- else {\
- RELEASE(localException); \
- longjmp(exceptionHandler.jmpState, 1); \
- }\
- } \
-}
-
-
-/* Use BREAK inside a TRY block to get out of it */
-#define BREAK ({_NSRemoveHandler(&exceptionHandler); goto _quit;})
-
-#ifndef PRECOMP
-/* If you want to generate an exception issue a THROW with the exception
- an object derived from the NSException class. */
-# define THROW(exception...) [##exception raise]
-#else
-# define THROW(exception) [exception raise]
-#endif /* PRECOMP */
-
-/* If you want to reraise an exception inside an exception handler
- just say RERAISE. */
-#define RERAISE [localException raise]
-
-
-
-/*
- * Assertions.
- */
-
-#ifndef __FoundationException_definition__
-#define __FoundationException_definition__
-
-@interface FoundationException : NSException
-@end
-
-#endif /* __FoundationException_definition__ */
-
-@interface AssertException : FoundationException
-@end
-
-
-@interface NSAssertionHandler : NSObject
-
-/* Getting the Current Handler */
-+ (NSAssertionHandler*)currentHandler;
-
-/* Handling Failures */
-- (void)handleFailureInFunction:(NSString*)functionName
- file:(NSString*)fileName
- lineNumber:(int)line
- description:(NSString*)format,...;
-- (void)handleFailureInMethod:(SEL)selector
- object:(id)object
- file:(NSString*)fileName
- lineNumber:(int)line
- description:(NSString*)format,...;
-
-@end
-
-
-#ifndef PRECOMP
-# define NSAssert(condition, desc, arguments...) \
- ({ if(!(condition)) \
- [[NSAssertionHandler currentHandler] \
- handleFailureInMethod:_cmd \
- object:self \
- file:[NSString stringWithCString:__FILE__] \
- lineNumber:__LINE__ \
- description:(desc) , ##arguments]; \
- 0;})
-
-# define NSCAssert(condition, desc, arguments...) \
- ({ if(!(condition)) \
- [[NSAssertionHandler currentHandler] \
- handleFailureInFunction: \
- [NSString stringWithCString:__PRETTY_FUNCTION__] \
- file:[NSString stringWithCString:__FILE__] \
- lineNumber:__LINE__ \
- description:(desc) , ##arguments]; \
- 0;})
-
-# define Assert(condition) \
- ({if(!(condition)) {\
- NSLog([(@#condition) stringByPrependingString:@"Assertion failed: "]); \
- [[AssertException new] raise]; \
- } \
- 0;})
-
-# define NSParameterAssert(condition) \
- ({if(!(condition)) {\
- NSLog([(@#condition) stringByPrependingString:@"Parameter Assertion failed: "]); \
- [[AssertException new] raise]; \
- } \
- 0;})
-
-# define NSCParameterAssert(condition) \
- ({if(!(condition)) {\
- NSLog([(@#condition) stringByPrependingString:@"Parameter Assertion failed: "]); \
- [[AssertException new] raise]; \
- } \
- 0;})
-
-# define NSAssert1(condition, desc, a1) \
- ({ if(!(condition)) \
- [[NSAssertionHandler currentHandler] \
- handleFailureInMethod:_cmd object:self \
- file:[NSString stringWithCString:__FILE__] \
- lineNumber:__LINE__ \
- description:(desc) , a1]; \
- 0;})
-# define NSAssert2(condition, desc, a1, a2) \
- ({ if(!(condition)) \
- [[NSAssertionHandler currentHandler] \
- handleFailureInMethod:_cmd object:self \
- file:[NSString stringWithCString:__FILE__] \
- lineNumber:__LINE__ \
- description:(desc) , a1, a2]; \
- 0;})
-# define NSAssert3(condition, desc, a1, a2, a3) \
- ({ if(!(condition)) \
- [[NSAssertionHandler currentHandler] \
- handleFailureInMethod:_cmd object:self \
- file:[NSString stringWithCString:__FILE__] \
- lineNumber:__LINE__ \
- description:(desc) , a1, a2, a3]; \
- 0;})
-# define NSAssert4(condition, desc, a1, a2, a3, a4) \
- ({ if(!(condition)) \
- [[NSAssertionHandler currentHandler] \
- handleFailureInMethod:_cmd object:self \
- file:[NSString stringWithCString:__FILE__] \
- lineNumber:__LINE__ \
- description:(desc) , a1, a2, a3, a4]; \
- 0;})
-# define NSAssert5(condition, desc, a1, a2, a3, a4, a5) \
- ({ if(!(condition)) \
- [[NSAssertionHandler currentHandler] \
- handleFailureInMethod:_cmd object:self \
- file:[NSString stringWithCString:__FILE__] \
- lineNumber:__LINE__ \
- description:(desc) , a1, a2, a3, a4, a5]; \
- 0;})
-
-# define NSCAssert1(condition, desc, a1) \
- ({ if(!(condition)) \
- [[NSAssertionHandler currentHandler] \
- handleFailureInFunction: \
- [NSString stringWithCString:__PRETTY_FUNCTION__] \
- file:[NSString stringWithCString:__FILE__] \
- lineNumber:__LINE__ \
- description:(desc) , a1]; \
- 0;})
-# define NSCAssert2(condition, desc, a1, a2) \
- ({ if(!(condition)) \
- [[NSAssertionHandler currentHandler] \
- handleFailureInFunction: \
- [NSString stringWithCString:__PRETTY_FUNCTION__] \
- file:[NSString stringWithCString:__FILE__] \
- lineNumber:__LINE__ \
- description:(desc) , a1, a2]; \
- 0;})
-# define NSCAssert3(condition, desc, a1, a2, a3) \
- ({ if(!(condition)) \
- [[NSAssertionHandler currentHandler] \
- handleFailureInFunction: \
- [NSString stringWithCString:__PRETTY_FUNCTION__] \
- file:[NSString stringWithCString:__FILE__] \
- lineNumber:__LINE__ \
- description:(desc) , a1, a2, a3]; \
- 0;})
-# define NSCAssert4(condition, desc, a1, a2, a3, a4) \
- ({ if(!(condition)) \
- [[NSAssertionHandler currentHandler] \
- handleFailureInFunction: \
- [NSString stringWithCString:__PRETTY_FUNCTION__] \
- file:[NSString stringWithCString:__FILE__] \
- lineNumber:__LINE__ \
- description:(desc) , a1, a2, a3, a4]; \
- 0;})
-# define NSCAssert5(condition, desc, a1, a2, a3, a4, a5) \
- ({ if(!(condition)) \
- [[NSAssertionHandler currentHandler] \
- handleFailureInFunction: \
- [NSString stringWithCString:__PRETTY_FUNCTION__] \
- file:[NSString stringWithCString:__FILE__] \
- lineNumber:__LINE__ \
- description:(desc) , a1, a2, a3, a4, a5]; \
- 0;})
-
-#endif /* PRECOMP */
-
-#endif /* __NSException_h__ */
-
-/*
- Local Variables:
- c-basic-offset: 4
- tab-width: 8
- End:
-*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <la...@us...> - 2006-08-31 07:30:58
|
Revision: 280
http://svn.sourceforge.net/substrate/?rev=280&view=rev
Author: landonf
Date: 2006-08-31 00:30:41 -0700 (Thu, 31 Aug 2006)
Log Message:
-----------
Preserve user-supplied LD_LIBRARY_PATH
Modified Paths:
--------------
trunk/Tests/Makefile.in
Modified: trunk/Tests/Makefile.in
===================================================================
--- trunk/Tests/Makefile.in 2006-08-31 07:19:23 UTC (rev 279)
+++ trunk/Tests/Makefile.in 2006-08-31 07:30:41 UTC (rev 280)
@@ -25,14 +25,15 @@
${CC} -o $@ ${FOUNDATION_OBJS} ${LDFLAGS}
TestFoundation: Foundation
- @/usr/bin/env DYLD_LIBRARY_PATH=../Foundation LD_LIBRARY_PATH=../Foundation ./Foundation foundation.xml
+ @/usr/bin/env DYLD_LIBRARY_PATH=../Foundation:$$DYLD_LIBRARY_PATH LD_LIBRARY_PATH=../Foundation:$$LD_LIBRARY_PATH ./Foundation foundation.xml
+
# Spinlock Implementation
Spinlocks: $(SPINLOCK_OBJS)
${CC} -o $@ ${SPINLOCK_OBJS} ${LDFLAGS}
TestSpinlocks: Spinlocks
- @/usr/bin/env DYLD_LIBRARY_PATH=../Foundation LD_LIBRARY_PATH=../Foundation ./Spinlocks spinlocks.xml
+ @/usr/bin/env DYLD_LIBRARY_PATH=../Foundation:$$DYLD_LIBRARY_PATH LD_LIBRARY_PATH=../Foundation:$$LD_LIBRARY_PATH ./Spinlocks spinlocks.xml
test: TestFoundation TestSpinlocks
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <la...@us...> - 2006-08-31 07:19:32
|
Revision: 279
http://svn.sourceforge.net/substrate/?rev=279&view=rev
Author: landonf
Date: 2006-08-31 00:19:23 -0700 (Thu, 31 Aug 2006)
Log Message:
-----------
Fix return type -- unsigned int, not a pointer
Modified Paths:
--------------
trunk/Foundation/NSData.m
Modified: trunk/Foundation/NSData.m
===================================================================
--- trunk/Foundation/NSData.m 2006-08-31 07:05:34 UTC (rev 278)
+++ trunk/Foundation/NSData.m 2006-08-31 07:19:23 UTC (rev 279)
@@ -214,7 +214,7 @@
*/
- (unsigned int) length {
[self _subclassResponsibility: _cmd];
- return nil;
+ return 0;
}
/*!
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <la...@us...> - 2006-08-31 07:05:49
|
Revision: 278
http://svn.sourceforge.net/substrate/?rev=278&view=rev
Author: landonf
Date: 2006-08-31 00:05:34 -0700 (Thu, 31 Aug 2006)
Log Message:
-----------
A few more nils that should have been NULLs
Modified Paths:
--------------
trunk/Tests/NSConcreteData.m
trunk/Tests/NSObject.m
Modified: trunk/Tests/NSConcreteData.m
===================================================================
--- trunk/Tests/NSConcreteData.m 2006-08-31 07:00:37 UTC (rev 277)
+++ trunk/Tests/NSConcreteData.m 2006-08-31 07:05:34 UTC (rev 278)
@@ -50,7 +50,7 @@
data = [[NSData alloc] initWithBytes: testBytes length: sizeof(testBytes)];
ivar = [data bytes];
- fail_if(ivar == nil, "-[NSData bytes] returned nil.");
+ fail_if(ivar == NULL, "-[NSData bytes] returned NULL.");
fail_unless(strcmp(testBytes, ivar) == 0, "-[NSData bytes] returned unexpected byte string (Expected: %s, got: %s)", testBytes, ivar);
[data release];
Modified: trunk/Tests/NSObject.m
===================================================================
--- trunk/Tests/NSObject.m 2006-08-31 07:00:37 UTC (rev 277)
+++ trunk/Tests/NSObject.m 2006-08-31 07:05:34 UTC (rev 278)
@@ -351,9 +351,9 @@
START_TEST (test_NSObject_methodForSelector) {
Test *tst = [Test new];
- fail_if([tst methodForSelector:@selector(init)] == nil, "-[Test respondsToSelector:] returned nil for an inherited instance method (-[NSObject init].");
- fail_if([tst methodForSelector:@selector(testInstanceMethod)] == nil, "-[Test respondsToSelector:] returned nil for a valid instance method (testInstanceMethod).");
- fail_unless([tst methodForSelector:@selector(nonsense)] == nil, "-[Test respondsToSelector:] returned nil for a non-existent instance method ('nonsense').");
+ fail_if([tst methodForSelector:@selector(init)] == NULL, "-[Test respondsToSelector:] returned NULL for an inherited instance method (-[NSObject init].");
+ fail_if([tst methodForSelector:@selector(testInstanceMethod)] == NULL, "-[Test respondsToSelector:] returned NULL for a valid instance method (testInstanceMethod).");
+ fail_unless([tst methodForSelector:@selector(nonsense)] == NULL, "-[Test respondsToSelector:] returned NULL for a non-existent instance method ('nonsense').");
[tst release];
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <la...@us...> - 2006-08-31 07:00:47
|
Revision: 277
http://svn.sourceforge.net/substrate/?rev=277&view=rev
Author: landonf
Date: 2006-08-31 00:00:37 -0700 (Thu, 31 Aug 2006)
Log Message:
-----------
Let's try this without pulling in Obj-C into the C file
Modified Paths:
--------------
trunk/Foundation/LFHash.c
Modified: trunk/Foundation/LFHash.c
===================================================================
--- trunk/Foundation/LFHash.c 2006-08-31 06:51:41 UTC (rev 276)
+++ trunk/Foundation/LFHash.c 2006-08-31 07:00:37 UTC (rev 277)
@@ -46,6 +46,14 @@
#include <config.h>
#endif
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
@@ -53,7 +61,6 @@
#include <sys/types.h>
#include <sys/param.h>
-#include <Foundation/LFObjCRuntime.h>
/*
* My best guess at if you are big-endian or little-endian. This may
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <la...@us...> - 2006-08-31 06:51:45
|
Revision: 276
http://svn.sourceforge.net/substrate/?rev=276&view=rev
Author: landonf
Date: 2006-08-30 23:51:41 -0700 (Wed, 30 Aug 2006)
Log Message:
-----------
Pull in the LFObjCRuntime header for fixed-width integer types
Modified Paths:
--------------
trunk/Foundation/LFHash.c
Modified: trunk/Foundation/LFHash.c
===================================================================
--- trunk/Foundation/LFHash.c 2006-08-31 06:49:20 UTC (rev 275)
+++ trunk/Foundation/LFHash.c 2006-08-31 06:51:41 UTC (rev 276)
@@ -53,6 +53,8 @@
#include <sys/types.h>
#include <sys/param.h>
+#include <Foundation/LFObjCRuntime.h>
+
/*
* My best guess at if you are big-endian or little-endian. This may
* need adjustment.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <la...@us...> - 2006-08-31 06:49:33
|
Revision: 275
http://svn.sourceforge.net/substrate/?rev=275&view=rev
Author: landonf
Date: 2006-08-30 23:49:20 -0700 (Wed, 30 Aug 2006)
Log Message:
-----------
This should be NULL, if we're going to return something
Modified Paths:
--------------
trunk/Foundation/NSString.m
Modified: trunk/Foundation/NSString.m
===================================================================
--- trunk/Foundation/NSString.m 2006-08-31 06:47:06 UTC (rev 274)
+++ trunk/Foundation/NSString.m 2006-08-31 06:49:20 UTC (rev 275)
@@ -289,7 +289,7 @@
*/
- (char *) cString {
/* TODO Unimplemented */
- return nil;
+ return NULL;
}
- (NSString *) description {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <la...@us...> - 2006-08-31 06:47:10
|
Revision: 274
http://svn.sourceforge.net/substrate/?rev=274&view=rev
Author: landonf
Date: 2006-08-30 23:47:06 -0700 (Wed, 30 Aug 2006)
Log Message:
-----------
signal.h is needed for kill() and SIGTRAP
Modified Paths:
--------------
trunk/Foundation/LFObjCGNURuntime.m
Modified: trunk/Foundation/LFObjCGNURuntime.m
===================================================================
--- trunk/Foundation/LFObjCGNURuntime.m 2006-08-31 06:44:14 UTC (rev 273)
+++ trunk/Foundation/LFObjCGNURuntime.m 2006-08-31 06:47:06 UTC (rev 274)
@@ -45,6 +45,7 @@
#include <sys/types.h>
#include <unistd.h>
+#include <signal.h>
# include <dlfcn.h>
/* GCC's exception handling and stack unwinding routines */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <la...@us...> - 2006-08-31 06:44:21
|
Revision: 273
http://svn.sourceforge.net/substrate/?rev=273&view=rev
Author: landonf
Date: 2006-08-30 23:44:14 -0700 (Wed, 30 Aug 2006)
Log Message:
-----------
The correct stdint include will be pulled in via LFObjCRuntime.h
Modified Paths:
--------------
trunk/Foundation/NSObject.m
Modified: trunk/Foundation/NSObject.m
===================================================================
--- trunk/Foundation/NSObject.m 2006-08-31 06:43:25 UTC (rev 272)
+++ trunk/Foundation/NSObject.m 2006-08-31 06:44:14 UTC (rev 273)
@@ -34,10 +34,6 @@
#include <string.h>
#endif
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
-
#include <assert.h>
#include <Foundation/NSZone.h>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <la...@us...> - 2006-08-31 06:43:32
|
Revision: 272
http://svn.sourceforge.net/substrate/?rev=272&view=rev
Author: landonf
Date: 2006-08-30 23:43:25 -0700 (Wed, 30 Aug 2006)
Log Message:
-----------
The correct stdint include will be pulled in via LFObjCRuntime.h
Modified Paths:
--------------
trunk/Foundation/NSAutoreleasePool.h
Modified: trunk/Foundation/NSAutoreleasePool.h
===================================================================
--- trunk/Foundation/NSAutoreleasePool.h 2006-08-31 06:40:33 UTC (rev 271)
+++ trunk/Foundation/NSAutoreleasePool.h 2006-08-31 06:43:25 UTC (rev 272)
@@ -25,8 +25,6 @@
#ifndef __NSAutoreleasePool_h__
#define __NSAutoreleasePool_h__
-#include <stdint.h>
-
#include <Foundation/NSObject.h>
typedef struct _LFAutoreleasePoolBucket LFAutoreleasePoolBucket;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <la...@us...> - 2006-08-31 06:40:39
|
Revision: 271
http://svn.sourceforge.net/substrate/?rev=271&view=rev
Author: landonf
Date: 2006-08-30 23:40:33 -0700 (Wed, 30 Aug 2006)
Log Message:
-----------
Missing '>'
Modified Paths:
--------------
trunk/aclocal.m4
Modified: trunk/aclocal.m4
===================================================================
--- trunk/aclocal.m4 2006-08-31 02:11:51 UTC (rev 270)
+++ trunk/aclocal.m4 2006-08-31 06:40:33 UTC (rev 271)
@@ -32,7 +32,7 @@
],[
# Solaris uses inttypes.h
AC_CHECK_HEADER([inttypes.h],[
- LF_STDINT_INC="\\#include <inttypes.h"
+ LF_STDINT_INC="\\#include <inttypes.h>"
],[
LF_STDINT_INC="/* \\#include <stdint.h> */"
])
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <la...@us...> - 2006-08-31 02:12:00
|
Revision: 270
http://svn.sourceforge.net/substrate/?rev=270&view=rev
Author: landonf
Date: 2006-08-30 19:11:51 -0700 (Wed, 30 Aug 2006)
Log Message:
-----------
Small fix for failure handling
Modified Paths:
--------------
trunk/Foundation/NSUnicodeString.m
Modified: trunk/Foundation/NSUnicodeString.m
===================================================================
--- trunk/Foundation/NSUnicodeString.m 2006-08-31 02:09:09 UTC (rev 269)
+++ trunk/Foundation/NSUnicodeString.m 2006-08-31 02:11:51 UTC (rev 270)
@@ -522,17 +522,12 @@
allocSize = newAllocSize;
bytes = NSZoneRealloc(NULL, bytes, allocSize);
continue;
- } else if (err == U_ILLEGAL_CHAR_FOUND) {
+ } else {
/* Invalid character sequence found for the given
* destination encoding scheme */
NSZoneFree(NULL, bytes);
ucnv_close(conv);
return nil;
- } else {
- [NSException raise: NSInternalInconsistencyException format: @"Failure in IBM ICU's ucnv_toUChars()"];
- NSZoneFree(NULL, bytes);
- ucnv_close(conv);
- return nil;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <la...@us...> - 2006-08-31 02:09:20
|
Revision: 269
http://svn.sourceforge.net/substrate/?rev=269&view=rev
Author: landonf
Date: 2006-08-30 19:09:09 -0700 (Wed, 30 Aug 2006)
Log Message:
-----------
Add support for lossy and non-lossy conversions
Modified Paths:
--------------
trunk/Foundation/NSUnicodeString.h
trunk/Foundation/NSUnicodeString.m
trunk/Tests/NSUnicodeString.m
Modified: trunk/Foundation/NSUnicodeString.h
===================================================================
--- trunk/Foundation/NSUnicodeString.h 2006-08-31 00:02:26 UTC (rev 268)
+++ trunk/Foundation/NSUnicodeString.h 2006-08-31 02:09:09 UTC (rev 269)
@@ -33,8 +33,10 @@
*/
#include <Foundation/NSString.h>
+
+#include <unicode/ucnv.h>
+#include <unicode/ucnv_err.h>
#include <unicode/ustring.h>
-#include <unicode/ucnv.h>
/*!
* @ingroup NSUnicodeString
Modified: trunk/Foundation/NSUnicodeString.m
===================================================================
--- trunk/Foundation/NSUnicodeString.m 2006-08-31 00:02:26 UTC (rev 268)
+++ trunk/Foundation/NSUnicodeString.m 2006-08-31 02:09:09 UTC (rev 269)
@@ -228,6 +228,17 @@
return nil;
}
+ /* Skip bad code points. This *seems* to be what Apple does,
+ * but I could be wrong */
+ ucnv_setFromUCallBack(conv, UCNV_FROM_U_CALLBACK_SKIP, NULL, NULL, NULL, &err);
+
+ /* Did ucnv_setFromUCallback() fail? */
+ if (U_FAILURE(err)) {
+ [NSException raise: NSInternalInconsistencyException format: @"Failure in IBM ICU's ucnv_setFromUCallback()"];
+ ucnv_close(conv);
+ return nil;
+ }
+
/* Do the conversion */
_string = NSZoneMalloc(NULL, allocSize);
while (1) {
@@ -250,7 +261,7 @@
_string = NSZoneRealloc(NULL, _string, allocSize);
continue;
} else {
- [NSException raise: NSInternalInconsistencyException format: @"Failure in IBM ICU's ucnv_toUChars()"];
+ [NSException raise: NSCharacterConversionException format: @"Failure in IBM ICU's ucnv_toUChars()"];
NSZoneFree(NULL, _string);
ucnv_close(conv);
[self release];
@@ -475,10 +486,22 @@
/* Did ucnv_open() fail? */
if (U_FAILURE(err)) {
[NSException raise: NSInternalInconsistencyException format: @"Failure in IBM ICU's ucnv_open()"];
- [self release];
return nil;
}
+ /* Set up lossy character handling */
+ if (lossy)
+ ucnv_setFromUCallBack(conv, UCNV_FROM_U_CALLBACK_SKIP, NULL, NULL, NULL, &err);
+ else
+ ucnv_setFromUCallBack(conv, UCNV_FROM_U_CALLBACK_STOP, NULL, NULL, NULL, &err);
+
+ /* Did ucnv_setFromUCallback() fail? */
+ if (U_FAILURE(err)) {
+ [NSException raise: NSInternalInconsistencyException format: @"Failure in IBM ICU's ucnv_setFromUCallback()"];
+ ucnv_close(conv);
+ return nil;
+ }
+
/* Do the conversion */
bytes = NSZoneMalloc(NULL, allocSize);
while (1) {
@@ -499,11 +522,16 @@
allocSize = newAllocSize;
bytes = NSZoneRealloc(NULL, bytes, allocSize);
continue;
+ } else if (err == U_ILLEGAL_CHAR_FOUND) {
+ /* Invalid character sequence found for the given
+ * destination encoding scheme */
+ NSZoneFree(NULL, bytes);
+ ucnv_close(conv);
+ return nil;
} else {
[NSException raise: NSInternalInconsistencyException format: @"Failure in IBM ICU's ucnv_toUChars()"];
NSZoneFree(NULL, bytes);
ucnv_close(conv);
- [self release];
return nil;
}
}
@@ -511,8 +539,6 @@
/* Success. Let's shove it into an NSData instance */
return [NSData dataWithBytesNoCopy: bytes length: allocSize freeWhenDone: YES];
}
-
-
/*! @} */
Modified: trunk/Tests/NSUnicodeString.m
===================================================================
--- trunk/Tests/NSUnicodeString.m 2006-08-31 00:02:26 UTC (rev 268)
+++ trunk/Tests/NSUnicodeString.m 2006-08-31 02:09:09 UTC (rev 269)
@@ -33,8 +33,21 @@
#include <Foundation/NSAutoreleasePool.h>
#include <string.h>
+#include <stdlib.h>
/*
+ * Test setup/teardown
+ */
+static NSAutoreleasePool *releasePool;
+static void setUp(void) {
+ releasePool = [[NSAutoreleasePool alloc] init];
+}
+
+static void tearDown(void) {
+ [releasePool release];
+}
+
+/*
* Test data for all supported encodings
*/
@@ -164,7 +177,6 @@
#define ENCODING_INIT_TEST(stringEncoding) \
START_TEST(test_ ## stringEncoding) { \
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; \
NSString *string; \
NSData *data; \
string = [[NSString alloc] initWithBytes: stringEncoding ## _data length: sizeof(stringEncoding ## _data) encoding: stringEncoding]; \
@@ -172,7 +184,6 @@
data = [string dataUsingEncoding: stringEncoding allowLossyConversion: NO]; \
fail_if(data == nil, "-[NSString dataUsingEncoding: allowLossyConversion:] return nil for NSStringEncoding %d.", stringEncoding); \
fail_unless(memcmp([data bytes], stringEncoding ## _data, sizeof(stringEncoding ## _data)) == 0, "-[NSString dataUsingEncoding: allowLossyConversion:] return data that does not match the original for NSStringEncoding %d.", stringEncoding); \
- [pool release]; \
[string release]; \
} \
END_TEST
@@ -223,10 +234,26 @@
}
END_TEST
+START_TEST (test_dataUsingEncodingStringEncodingAllowLossyConversion) {
+ NSString *string;
+ NSData *data;
+
+ /* Try lossy and non-lossy conversion from EUC to ASCII */
+ string = [[NSString alloc] initWithBytes: NSJapaneseEUCStringEncoding_data length: sizeof(NSJapaneseEUCStringEncoding_data) encoding: NSJapaneseEUCStringEncoding];
+ data = [string dataUsingEncoding: NSASCIIStringEncoding allowLossyConversion: YES];
+ fail_if(data == nil, "-[NSString dataUsingEncoding: NSASCIIStringEncoding allowLossyConversion: YES] returned nil.");
+
+
+ data = [string dataUsingEncoding: NSASCIIStringEncoding allowLossyConversion: NO];
+ fail_unless(data == nil, "-[NSString dataUsingEncoding: NSASCIIStringEncoding allowLossyConversion: NO] did not return nil with lossy data.");
+}
+END_TEST
+
Suite *NSUnicodeString_suite(void) {
Suite *s = suite_create("NSUnicodeString");
TCase *tc_init = tcase_create("Initialization");
+ tcase_add_checked_fixture(tc_init, setUp, tearDown);
suite_add_tcase(s, tc_init);
tcase_add_test(tc_init, test_NSASCIIStringEncoding);
tcase_add_test(tc_init, test_NSJapaneseEUCStringEncoding);
@@ -245,5 +272,10 @@
tcase_add_test(tc_init, test_NSMacOSRomanStringEncoding);
tcase_add_test(tc_init, test_initWithBytesNoCopyLengthEncodingFreeWhenDone);
+ TCase *tc_conv = tcase_create("Conversion");
+ tcase_add_checked_fixture(tc_conv, setUp, tearDown);
+ suite_add_tcase(s, tc_conv);
+ tcase_add_test(tc_conv, test_dataUsingEncodingStringEncodingAllowLossyConversion);
+
return (s);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <la...@us...> - 2006-08-31 00:02:40
|
Revision: 268
http://svn.sourceforge.net/substrate/?rev=268&view=rev
Author: landonf
Date: 2006-08-30 17:02:26 -0700 (Wed, 30 Aug 2006)
Log Message:
-----------
Implement support for NSString's dataUsingEncoding:(NSStringEncoding)encoding allowLossyConversion:(BOOL)lossy, and modify the NSUnicodeString tests to use it.
allowLossyConversion: NO is still unimplemented.
Modified Paths:
--------------
trunk/Foundation/NSString.h
trunk/Foundation/NSString.m
trunk/Foundation/NSUnicodeString.m
trunk/Tests/NSString.m
trunk/Tests/NSUnicodeString.m
Property Changed:
----------------
trunk/
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 11572a18-12fc-0310-9209-f8edcc8181a7:/local/substrate/trunk:5682
+ 11572a18-12fc-0310-9209-f8edcc8181a7:/local/substrate/trunk:5684
Modified: trunk/Foundation/NSString.h
===================================================================
--- trunk/Foundation/NSString.h 2006-08-30 23:20:17 UTC (rev 267)
+++ trunk/Foundation/NSString.h 2006-08-31 00:02:26 UTC (rev 268)
@@ -39,6 +39,8 @@
#include <Foundation/NSObject.h>
#include <Foundation/NSRange.h>
+@class NSData;
+
/*!
* @ingroup NSString
* @{
@@ -117,13 +119,15 @@
- (const char *) cString;
/* Initialization */
-+ string;
-- initWithCString:(const char *)cStr encoding:(NSStringEncoding)encoding;
++ (id) string;
++ (id) stringWithCString:(const char *)cStr encoding:(NSStringEncoding)encoding;
+- (id) initWithCString:(const char *)cStr encoding:(NSStringEncoding)encoding;
- (id) initWithBytes:(const void *)bytes length:(unsigned int)len encoding:(NSStringEncoding)encoding;
- (id) initWithBytesNoCopy:(void *)bytes length:(unsigned int)len encoding:(NSStringEncoding)encoding freeWhenDone:(BOOL) shouldFree;
/* Encoding */
+ (NSStringEncoding) defaultCStringEncoding;
+- (NSData *) dataUsingEncoding:(NSStringEncoding)encoding allowLossyConversion:(BOOL)lossy;
/* Deprecated */
+ stringWithCString:(const char *)cStr;
Modified: trunk/Foundation/NSString.m
===================================================================
--- trunk/Foundation/NSString.m 2006-08-30 23:20:17 UTC (rev 267)
+++ trunk/Foundation/NSString.m 2006-08-31 00:02:26 UTC (rev 268)
@@ -94,6 +94,38 @@
return NSUTF8StringEncoding;
}
+/*!
+ * Convert the receiving string to the specified encoding, returning
+ * the result as an instance of NSData.
+ * If allowLossyConversion is NO, and the encoding conversion can not be done
+ * without data loss, nil will be returned.
+ * @param encoding Encoding to convert receiver to.
+ * @param lossy If YES, permits lossy conversion.
+ * @return NSData object containing the converted string data, or nil on failure.
+ */
+- (NSData *) dataUsingEncoding:(NSStringEncoding)encoding allowLossyConversion:(BOOL)lossy {
+ /*
+ * Ineffecient superclass implementation.
+ * We acquire a copy our UTF-16 byte array, instantiate a zero-copy
+ * NSUnicodeString instance, and ask it to convert the array for us.
+ */
+ NSUnicodeString *ucnv;
+ unsigned int length;
+ unichar *buffer;
+ NSData *result;
+
+ length = [self length];
+ buffer = NSZoneMalloc(NULL, length * sizeof(unichar));
+ [self getCharacters: buffer];
+ /* Length required here is byte length, not character length. Ugh */
+ ucnv = [[NSUnicodeString alloc] initWithBytesNoCopy: buffer length: length * sizeof(unichar) encoding: NSUnicodeStringEncoding freeWhenDone: YES];
+
+ result = [ucnv dataUsingEncoding: encoding allowLossyConversion: lossy];
+ [ucnv release];
+
+ return result;
+}
+
/*! @} */
@@ -103,19 +135,20 @@
*/
/*!
- * Allocate and initialize an NSString instance with the supplied C string.
+ * Allocate and initialize an NSString instance with the supplied C string, of the specified encoding.
* @param cStr NULL-terminted C string.
+ * @param encoding Character encoding for the C String
* @return Allocated and initialized NSString instance.
*/
-+ stringWithCString:(const char *)cStr {
- return [[[self alloc] initWithCString:cStr] autorelease];
++ (id) stringWithCString:(const char *)cStr encoding:(NSStringEncoding)encoding {
+ return [[[self alloc] initWithCString: cStr encoding: encoding] autorelease];
}
/*!
* Allocate and initialize an empty NSString instance.
* @return New empty NSString instance.
*/
-+ string {
++ (id) string {
[self release];
return [[[NSUnicodeString alloc] init] autorelease];
}
@@ -269,7 +302,18 @@
*/
/*!
- * Initialize the receiver with the supplied C string, using the default string encoding.
+ * Allocate and initialize an NSString instance with the supplied C string, using the default C string encoding.
+ * @deprecated Use stringWithCString:encoding: instead.
+ * @param cStr NULL-terminted C string.
+ * @return Allocated and initialized NSString instance.
+ */
++ stringWithCString:(const char *)cStr {
+ return [self stringWithCString: cStr encoding: [self defaultCStringEncoding]];
+}
+
+
+/*!
+ * Initialize the receiver with the supplied C string, using the default C string encoding.
* @deprecated Caller's should make use of initWithCString:encoding: instead.
* @param cStr NULL-terminted C string.
* @return Allocated and initialized NSString instance.
Modified: trunk/Foundation/NSUnicodeString.m
===================================================================
--- trunk/Foundation/NSUnicodeString.m 2006-08-30 23:20:17 UTC (rev 267)
+++ trunk/Foundation/NSUnicodeString.m 2006-08-31 00:02:26 UTC (rev 268)
@@ -34,6 +34,7 @@
#endif
#include <Foundation/NSUnicodeString.h>
+#include <Foundation/NSData.h>
#include <Foundation/NSException.h>
@@ -250,6 +251,7 @@
continue;
} else {
[NSException raise: NSInternalInconsistencyException format: @"Failure in IBM ICU's ucnv_toUChars()"];
+ NSZoneFree(NULL, _string);
ucnv_close(conv);
[self release];
return nil;
@@ -352,6 +354,168 @@
/*! @} */
+/*!
+ * @name Encoding
+ * @{
+ */
+
+/*! Convert to the specified encoding.
+ * @todo Need better heuristics for determining destination buffer length, and
+ * for deciding when we should call realloc.
+ */
+- (NSData *) dataUsingEncoding:(NSStringEncoding)encoding allowLossyConversion:(BOOL)lossy {
+ UConverter *conv;
+ UErrorCode err = U_ZERO_ERROR;
+ void *bytes;
+ size_t allocSize;
+
+ /* Acquire a converter, and make an educated guess as to the correct allocation */
+ switch (encoding) {
+ /* 7-bit ASCII encoding, using 8-bit characters. */
+ case NSASCIIStringEncoding:
+ conv = ucnv_open("US-ASCII", &err);
+ allocSize = _length;
+ break;
+
+ /* 8-bit EUC encoding for Japanese. */
+ case NSJapaneseEUCStringEncoding:
+ conv = ucnv_open("EUC-JP", &err);
+ allocSize = _length;
+ break;
+
+ /* 8-bit Unicode encoding (UTF-8). */
+ case NSUTF8StringEncoding:
+ conv = ucnv_open("UTF-8", &err);
+ allocSize = _length;
+ break;
+
+ /* 8-bit ISO Latin 1 Encoding. */
+ case NSISOLatin1StringEncoding:
+ conv = ucnv_open("latin1", &err);
+ allocSize = _length;
+ break;
+
+ /* 7-bit non-lossy Unicode encoding (UTF-7). */
+ case NSNonLossyASCIIStringEncoding:
+ conv = ucnv_open("UTF-7", &err);
+ allocSize = _length;
+ break;
+
+ /* 8-bit Japanese Shift_JIS Encoding. */
+ case NSShiftJISStringEncoding:
+ conv = ucnv_open("Shift_JIS", &err);
+ allocSize = _length;
+ break;
+
+ /* 8-bit ISO Latin 2 Encoding. */
+ case NSISOLatin2StringEncoding:
+ conv = ucnv_open("latin2", &err);
+ allocSize = _length;
+ break;
+
+ case NSProprietaryStringEncoding: /* Fall through to UTF-16 */
+ /* Canonical encoding for NSString objects (UTF-16). */
+ case NSUnicodeStringEncoding:
+ /* UTF-16-LE is the canonical byte ordering for UTF-16 strings in
+ * both Substrate and Apple's Foundation */
+ conv = ucnv_open("UTF-16-LE", &err);
+ allocSize = _length;
+ break;
+
+ /* Microsoft Windows codepage 1251 for Cryillic characters. */
+ case NSWindowsCP1251StringEncoding:
+ conv = ucnv_open("windows-1251", &err);
+ allocSize = _length;
+ break;
+
+ /* Microsoft Windows codepage 1252 (WinLatin1). */
+ case NSWindowsCP1252StringEncoding:
+ conv = ucnv_open("windows-1252", &err);
+ allocSize = _length;
+ break;
+
+ /* Microsoft Windows codepage 1253, for Greek characters. */
+ case NSWindowsCP1253StringEncoding:
+ conv = ucnv_open("windows-1253", &err);
+ allocSize = _length;
+ break;
+
+ /* Microsoft Windows codepage 1254, for Turkish characters. */
+ case NSWindowsCP1254StringEncoding:
+ conv = ucnv_open("windows-1254", &err);
+ allocSize = _length;
+ break;
+
+ /* Microsoft Windows codepage 1250 (WinLatin2). */
+ case NSWindowsCP1250StringEncoding:
+ conv = ucnv_open("windows-1250", &err);
+ allocSize = _length;
+ break;
+
+ /* ISO 2022 Japanese for e-mail. */
+ case NSISO2022JPStringEncoding:
+ conv = ucnv_open("ISO-2022-JP", &err);
+ allocSize = _length;
+ break;
+
+ /* Legacy Mac Roman Encoding. */
+ case NSMacOSRomanStringEncoding:
+ conv = ucnv_open("macintosh", &err);
+ allocSize = _length;
+ break;
+
+ /* Unhandled encodings */
+ case NSNEXTSTEPStringEncoding:
+ case NSSymbolStringEncoding:
+ default:
+ [NSException raise: NSInvalidArgumentException format: @"Unknown NSStringEncoding"];
+ return nil;
+ }
+
+ /* Did ucnv_open() fail? */
+ if (U_FAILURE(err)) {
+ [NSException raise: NSInternalInconsistencyException format: @"Failure in IBM ICU's ucnv_open()"];
+ [self release];
+ return nil;
+ }
+
+ /* Do the conversion */
+ bytes = NSZoneMalloc(NULL, allocSize);
+ while (1) {
+ size_t newAllocSize;
+
+ err = U_ZERO_ERROR;
+ newAllocSize = ucnv_fromUChars(conv, bytes, allocSize, _string, _length, &err);
+
+ if (U_SUCCESS(err)) {
+ /* Don't bother calling realloc for very small differences */
+ if (newAllocSize != allocSize && newAllocSize - allocSize >= 5)
+ bytes = NSZoneRealloc(NULL, bytes, newAllocSize);
+ allocSize = newAllocSize;
+ break;
+ }
+
+ if (err == U_BUFFER_OVERFLOW_ERROR) {
+ allocSize = newAllocSize;
+ bytes = NSZoneRealloc(NULL, bytes, allocSize);
+ continue;
+ } else {
+ [NSException raise: NSInternalInconsistencyException format: @"Failure in IBM ICU's ucnv_toUChars()"];
+ NSZoneFree(NULL, bytes);
+ ucnv_close(conv);
+ [self release];
+ return nil;
+ }
+ }
+
+ /* Success. Let's shove it into an NSData instance */
+ return [NSData dataWithBytesNoCopy: bytes length: allocSize freeWhenDone: YES];
+}
+
+
+
+/*! @} */
+
@end
/*! @} */
Modified: trunk/Tests/NSString.m
===================================================================
--- trunk/Tests/NSString.m 2006-08-30 23:20:17 UTC (rev 267)
+++ trunk/Tests/NSString.m 2006-08-31 00:02:26 UTC (rev 268)
@@ -34,6 +34,7 @@
#endif
#include <Foundation/NSString.h>
+#include <Foundation/NSData.h>
#include <Foundation/NSException.h>
#include <Foundation/NSAutoreleasePool.h>
#include "LFObjCRuntime.h"
@@ -48,6 +49,11 @@
@interface NSDumbString : NSString
@end
@implementation NSDumbString
+
+- (id) initWithBytes:(const void *)bytes length:(unsigned int) length encoding:(NSStringEncoding)encoding {
+ return self;
+}
+
- (unichar) characterAtIndex:(unsigned int) index {
return (unichar) TEST_STRING[index];
}
@@ -110,6 +116,14 @@
}
END_TEST
+START_TEST (test_dataUsingEncodingAllowLossyConversion) {
+ NSString *string = [NSDumbString stringWithCString: TEST_STRING encoding: NSASCIIStringEncoding];
+ NSData *data = [string dataUsingEncoding: NSASCIIStringEncoding allowLossyConversion: NO];
+ fail_if(data == nil, "-[NSData dataUsingEncoding: NSASCIIStringEncoding allowLossyConversion: NO] returned nil.");
+ fail_unless([data length] == sizeof(TEST_STRING) - 1, "-[NSData length] returned unexpected byte length (Expected %d, got %d)", sizeof(TEST_STRING), [data length]);
+ fail_unless(strncmp([data bytes], TEST_STRING, sizeof(TEST_STRING - 1)) == 0, "-[NSData dataUsingEncoding: NSASCIIStringEncoding allowLossyConversion: NO] returned unexpected data.");
+}
+END_TEST
/* Initialization */
@@ -176,6 +190,7 @@
tcase_add_checked_fixture(tc_encoding, setUp, tearDown);
suite_add_tcase(s, tc_encoding);
tcase_add_test(tc_encoding, test_cls_defaultCStringEncoding);
+ tcase_add_test(tc_encoding, test_dataUsingEncodingAllowLossyConversion);
TCase *tc_init = tcase_create("Initialization");
tcase_add_checked_fixture(tc_init, setUp, tearDown);
Modified: trunk/Tests/NSUnicodeString.m
===================================================================
--- trunk/Tests/NSUnicodeString.m 2006-08-30 23:20:17 UTC (rev 267)
+++ trunk/Tests/NSUnicodeString.m 2006-08-31 00:02:26 UTC (rev 268)
@@ -28,6 +28,7 @@
#include <config.h>
#endif
+#include <Foundation/NSData.h>
#include <Foundation/NSString.h>
#include <Foundation/NSAutoreleasePool.h>
@@ -88,20 +89,22 @@
0xb9, 0x74, 0x69, 0x6e, 0x79
};
+/* English UTF-16-LE "Hello, Universe", assembled by byte
+ * UTF-16-LE is the canonical UTF-16 string encoding for both Substrate
+ * and Apple's foundation. */
+static const unsigned char NSUnicodeStringEncoding_data[] = {
+ 0xff, 0xfe, 0x48, 0x00, 0x65, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x6f, 0x00,
+ 0x2c, 0x00, 0x20, 0x00, 0x55, 0x00, 0x6e, 0x00, 0x69, 0x00, 0x76, 0x00,
+ 0x65, 0x00, 0x72, 0x00, 0x73, 0x00, 0x65, 0x00, 0x0, 0x0
+};
+
/* English UTF-16-BE "Hello, Universe", assembled by byte */
-static const unsigned char NSUnicodeStringEncoding_data[] = {
+static const unsigned char NSUnicodeStringEncodingBE_data[] = {
0xfe, 0xff, 0x00, 0x48, 0x00, 0x65, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x6f,
0x00, 0x2c, 0x00, 0x20, 0x00, 0x55, 0x00, 0x6e, 0x00, 0x69, 0x00, 0x76,
0x00, 0x65, 0x00, 0x72, 0x00, 0x73, 0x00, 0x65, 0x0, 0x0
};
-/* English UTF-16-LE "Hello, Universe", assembled by byte */
-static const unsigned char NSUnicodeStringEncodingLE_data[] = {
- 0xff, 0xfe, 0x48, 0x00, 0x65, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x6f, 0x00,
- 0x2c, 0x00, 0x20, 0x00, 0x55, 0x00, 0x6e, 0x00, 0x69, 0x00, 0x76, 0x00,
- 0x65, 0x00, 0x72, 0x00, 0x73, 0x00, 0x65, 0x00, 0x0, 0x0
-};
-
/* Russian */
static const unsigned char NSWindowsCP1251StringEncoding_data[] = {
0xc0, 0xe2, 0xf2, 0xee, 0xec, 0xe0, 0xf2, 0xe8, 0xe7, 0xe0, 0xf6,
@@ -163,8 +166,12 @@
START_TEST(test_ ## stringEncoding) { \
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; \
NSString *string; \
+ NSData *data; \
string = [[NSString alloc] initWithBytes: stringEncoding ## _data length: sizeof(stringEncoding ## _data) encoding: stringEncoding]; \
fail_if(string == nil, "-[NSString initWithBytes: length: encoding:] return nil for NSStringEncoding %d.", stringEncoding); \
+ data = [string dataUsingEncoding: stringEncoding allowLossyConversion: NO]; \
+ fail_if(data == nil, "-[NSString dataUsingEncoding: allowLossyConversion:] return nil for NSStringEncoding %d.", stringEncoding); \
+ fail_unless(memcmp([data bytes], stringEncoding ## _data, sizeof(stringEncoding ## _data)) == 0, "-[NSString dataUsingEncoding: allowLossyConversion:] return data that does not match the original for NSStringEncoding %d.", stringEncoding); \
[pool release]; \
[string release]; \
} \
@@ -191,26 +198,26 @@
void *bytes;
/* No free, UTF-16-BE */
- string = [[NSString alloc] initWithBytesNoCopy: (void *) NSUnicodeStringEncoding_data length: sizeof(NSUnicodeStringEncoding_data) encoding: NSUnicodeStringEncoding freeWhenDone: NO];
+ string = [[NSString alloc] initWithBytesNoCopy: (void *) NSUnicodeStringEncodingBE_data length: sizeof(NSUnicodeStringEncodingBE_data) encoding: NSUnicodeStringEncoding freeWhenDone: NO];
fail_if(string == nil, "-[NSString initWithBytesNoCopy: length: encoding: freeWhenDone: NO] returned nil with a UTF-16-BE encoded string.");
[string release];
/* No free, UTF-16-LE */
- string = [[NSString alloc] initWithBytesNoCopy: (void *) NSUnicodeStringEncodingLE_data length: sizeof(NSUnicodeStringEncodingLE_data) encoding: NSUnicodeStringEncoding freeWhenDone: NO];
+ string = [[NSString alloc] initWithBytesNoCopy: (void *) NSUnicodeStringEncoding_data length: sizeof(NSUnicodeStringEncoding_data) encoding: NSUnicodeStringEncoding freeWhenDone: NO];
fail_if(string == nil, "-[NSString initWithBytesNoCopy: length: encoding: freeWhenDone: NO] returned nil with a UTF-16-LE encoded string.");
[string release];
/* Free, UTF-16-BE */
- bytes = malloc(sizeof(NSUnicodeStringEncoding_data));
- memcpy(bytes, NSUnicodeStringEncoding_data, sizeof(NSUnicodeStringEncoding_data));
- string = [[NSString alloc] initWithBytesNoCopy: bytes length: sizeof(NSUnicodeStringEncoding_data) encoding: NSUnicodeStringEncoding freeWhenDone: YES];
+ bytes = malloc(sizeof(NSUnicodeStringEncodingBE_data));
+ memcpy(bytes, NSUnicodeStringEncodingBE_data, sizeof(NSUnicodeStringEncodingBE_data));
+ string = [[NSString alloc] initWithBytesNoCopy: bytes length: sizeof(NSUnicodeStringEncodingBE_data) encoding: NSUnicodeStringEncoding freeWhenDone: YES];
fail_if(string == nil, "-[NSString initWithBytesNoCopy: length: encoding: freeWhenDone: YES] returned nil with a UTF-16-BE encoded string.");
[string release];
/* Free, UTF-16-LE */
- bytes = malloc(sizeof(NSUnicodeStringEncodingLE_data));
- memcpy(bytes, NSUnicodeStringEncodingLE_data, sizeof(NSUnicodeStringEncodingLE_data));
- string = [[NSString alloc] initWithBytesNoCopy: bytes length: sizeof(NSUnicodeStringEncodingLE_data) encoding: NSUnicodeStringEncoding freeWhenDone: YES];
+ bytes = malloc(sizeof(NSUnicodeStringEncoding_data));
+ memcpy(bytes, NSUnicodeStringEncoding_data, sizeof(NSUnicodeStringEncoding_data));
+ string = [[NSString alloc] initWithBytesNoCopy: bytes length: sizeof(NSUnicodeStringEncoding_data) encoding: NSUnicodeStringEncoding freeWhenDone: YES];
fail_if(string == nil, "-[NSString initWithBytesNoCopy: length: encoding: freeWhenDone: YES] returned nil with a UTF-16-LE encoded string.");
[string release];
}
@@ -238,9 +245,5 @@
tcase_add_test(tc_init, test_NSMacOSRomanStringEncoding);
tcase_add_test(tc_init, test_initWithBytesNoCopyLengthEncodingFreeWhenDone);
-#ifdef TODO_NSData
-#error Add a test on the conversion result using dataUsingEncoding:allowLossyConversion: once NSData has been implemented!
-#endif
-
return (s);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <la...@us...> - 2006-08-30 23:20:32
|
Revision: 267
http://svn.sourceforge.net/substrate/?rev=267&view=rev
Author: landonf
Date: 2006-08-30 16:20:17 -0700 (Wed, 30 Aug 2006)
Log Message:
-----------
r5681@zadder: landonf | 2006-08-30 15:35:05 -0700
Fixes for designated initializers, minor test reorganization
r5682@zadder: landonf | 2006-08-30 16:19:30 -0700
Fix a small bug in NSObject's methodForSelector
Modified Paths:
--------------
trunk/Foundation/NSObject.m
trunk/Foundation/NSUnicodeString.m
trunk/Tests/NSObject.m
trunk/Tests/NSString.m
Property Changed:
----------------
trunk/
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 11572a18-12fc-0310-9209-f8edcc8181a7:/local/substrate/trunk:5679
+ 11572a18-12fc-0310-9209-f8edcc8181a7:/local/substrate/trunk:5682
Modified: trunk/Foundation/NSObject.m
===================================================================
--- trunk/Foundation/NSObject.m 2006-08-30 21:43:26 UTC (rev 266)
+++ trunk/Foundation/NSObject.m 2006-08-30 23:20:17 UTC (rev 267)
@@ -423,7 +423,7 @@
if (aSelector == NULL)
[NSException raise: NSInvalidArgumentException format: @"null selector"];
- method = LFObjectGetInstanceMethod(LFObjectGetClass(self), aSelector);
+ method = LFObjectGetInstanceMethod(self, aSelector);
return LFMethodGetIMP(method);
}
Modified: trunk/Foundation/NSUnicodeString.m
===================================================================
--- trunk/Foundation/NSUnicodeString.m 2006-08-30 21:43:26 UTC (rev 266)
+++ trunk/Foundation/NSUnicodeString.m 2006-08-30 23:20:17 UTC (rev 267)
@@ -99,7 +99,8 @@
UErrorCode err = U_ZERO_ERROR;
size_t allocSize;
- if(![self init])
+ self = [super init];
+ if (!self)
return nil;
/* Acquire a converter, and make an educated guess as to the correct allocation */
@@ -267,9 +268,6 @@
* Unless the string is encoded as UTF-16 in the host's native byte order, it will be copied.
*/
- (id) initWithBytesNoCopy:(void *)bytes length:(unsigned int)length encoding:(NSStringEncoding)encoding freeWhenDone:(BOOL)freeWhenDone {
- if (![self init])
- return self;
-
/* If we're supplied a UTF-16 string, we might just be able to use it ... */
if (encoding == NSUnicodeStringEncoding && length) {
BOOL isNativeBOM;
@@ -302,6 +300,11 @@
/* UTF-16 in native byte order */
if (isNativeBOM) {
+ /* We're the designated initializer! */
+ self = [super init];
+ if (!self)
+ return nil;
+
if (stripBOM) {
/* Strip off the BOM and make sure we free() the
* original pointer */
Modified: trunk/Tests/NSObject.m
===================================================================
--- trunk/Tests/NSObject.m 2006-08-30 21:43:26 UTC (rev 266)
+++ trunk/Tests/NSObject.m 2006-08-30 23:20:17 UTC (rev 267)
@@ -348,6 +348,19 @@
}
END_TEST
+START_TEST (test_NSObject_methodForSelector) {
+ Test *tst = [Test new];
+
+ fail_if([tst methodForSelector:@selector(init)] == nil, "-[Test respondsToSelector:] returned nil for an inherited instance method (-[NSObject init].");
+ fail_if([tst methodForSelector:@selector(testInstanceMethod)] == nil, "-[Test respondsToSelector:] returned nil for a valid instance method (testInstanceMethod).");
+ fail_unless([tst methodForSelector:@selector(nonsense)] == nil, "-[Test respondsToSelector:] returned nil for a non-existent instance method ('nonsense').");
+
+ [tst release];
+}
+END_TEST
+
+
+
START_TEST (test_NSObject_conformsToProtocol) {
NSObject *obj = [NSObject new];
Test *tst = [Test new];
@@ -403,6 +416,7 @@
tcase_add_test(tc_introspection, test_NSObject_isMemberOfClass);
tcase_add_test(tc_introspection, test_NSObject_instancesRespondToSelector);
tcase_add_test(tc_introspection, test_NSObject_respondsToSelector);
+ tcase_add_test(tc_introspection, test_NSObject_methodForSelector);
tcase_add_test(tc_introspection, test_NSObject_conformsToProtocol);
return (s);
Modified: trunk/Tests/NSString.m
===================================================================
--- trunk/Tests/NSString.m 2006-08-30 21:43:26 UTC (rev 266)
+++ trunk/Tests/NSString.m 2006-08-30 23:20:17 UTC (rev 267)
@@ -45,6 +45,18 @@
@implementation NSStringBrokenSubclass
@end
+@interface NSDumbString : NSString
+@end
+@implementation NSDumbString
+- (unichar) characterAtIndex:(unsigned int) index {
+ return (unichar) TEST_STRING[index];
+}
+
+- (unsigned int) length {
+ return sizeof(TEST_STRING) - 1;
+}
+@end
+
static NSAutoreleasePool *releasePool;
static void setUp(void) {
@@ -160,15 +172,10 @@
suite_add_tcase(s, tc_constant);
tcase_add_test(tc_constant, test_NSConstantString);
- TCase *tc_subclass = tcase_create("Subclassing");
- tcase_add_checked_fixture(tc_subclass, setUp, tearDown);
- suite_add_tcase(s, tc_subclass);
- tcase_add_test(tc_subclass, test_subclass_initWithBytes);
-
TCase *tc_encoding = tcase_create("Encodings");
tcase_add_checked_fixture(tc_encoding, setUp, tearDown);
suite_add_tcase(s, tc_encoding);
- tcase_add_test(tc_subclass, test_cls_defaultCStringEncoding);
+ tcase_add_test(tc_encoding, test_cls_defaultCStringEncoding);
TCase *tc_init = tcase_create("Initialization");
tcase_add_checked_fixture(tc_init, setUp, tearDown);
@@ -179,5 +186,10 @@
tcase_add_test(tc_init, test_initWithBytes);
tcase_add_test(tc_init, test_initWithBytesNoCopyLengthEncodingFreeWhenDone);
+ TCase *tc_subclass = tcase_create("Subclassing");
+ tcase_add_checked_fixture(tc_subclass, setUp, tearDown);
+ suite_add_tcase(s, tc_subclass);
+ tcase_add_test(tc_subclass, test_subclass_initWithBytes);
+
return (s);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <la...@us...> - 2006-08-30 21:43:39
|
Revision: 266
http://svn.sourceforge.net/substrate/?rev=266&view=rev
Author: landonf
Date: 2006-08-30 14:43:26 -0700 (Wed, 30 Aug 2006)
Log Message:
-----------
r5679@zadder: landonf | 2006-08-30 14:37:37 -0700
Consolidate into two designated initializers, and implement a number of C string initialization methods.
Modified Paths:
--------------
trunk/Foundation/NSSimpleCString.m
trunk/Foundation/NSString.h
trunk/Foundation/NSString.m
trunk/Foundation/NSUnicodeString.m
trunk/Tests/Foundation.c
trunk/Tests/NSString.m
Property Changed:
----------------
trunk/
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 11572a18-12fc-0310-9209-f8edcc8181a7:/local/substrate/trunk:5677
+ 11572a18-12fc-0310-9209-f8edcc8181a7:/local/substrate/trunk:5679
Modified: trunk/Foundation/NSSimpleCString.m
===================================================================
--- trunk/Foundation/NSSimpleCString.m 2006-08-30 18:51:24 UTC (rev 265)
+++ trunk/Foundation/NSSimpleCString.m 2006-08-30 21:43:26 UTC (rev 266)
@@ -54,10 +54,22 @@
*/
@implementation NSSimpleCString
-- initWithCString:(const char *) byteString {
- _numBytes = strlen(byteString);
- _bytes = (char *)malloc(_numBytes+1);
- bcopy(byteString, _bytes, _numBytes+1);
+- initWithBytes:(const void *)bytes length:(unsigned int)length encoding:(NSStringEncoding)encoding {
+ self = [super init];
+ if (!self)
+ return nil;
+
+ /* We only speak one encoding. */
+ if (encoding != NSASCIIStringEncoding) {
+ [self release];
+ [NSException raise: NSInvalidArgumentException format: @"Unknown NSStringEncoding"];
+ return nil;
+ }
+
+ _bytes = NSZoneMalloc(NULL, length);
+ _numBytes = length;
+ memcpy(_bytes, bytes, _numBytes);
+
return self;
}
@@ -71,6 +83,7 @@
}
- (unichar) characterAtIndex:(unsigned int) index {
+ /* ASCII can be directly mapped to UTF-16 */
return (unichar) _bytes[index];
}
@@ -79,6 +92,7 @@
}
- (unsigned int) cStringLength {
+ /* 1 byte per character */
return _numBytes;
}
Modified: trunk/Foundation/NSString.h
===================================================================
--- trunk/Foundation/NSString.h 2006-08-30 18:51:24 UTC (rev 265)
+++ trunk/Foundation/NSString.h 2006-08-30 21:43:26 UTC (rev 266)
@@ -117,14 +117,24 @@
- (const char *) cString;
/* Initialization */
++ string;
+- initWithCString:(const char *)cStr encoding:(NSStringEncoding)encoding;
- (id) initWithBytes:(const void *)bytes length:(unsigned int)len encoding:(NSStringEncoding)encoding;
- (id) initWithBytesNoCopy:(void *)bytes length:(unsigned int)len encoding:(NSStringEncoding)encoding freeWhenDone:(BOOL) shouldFree;
+/* Encoding */
++ (NSStringEncoding) defaultCStringEncoding;
+
+/* Deprecated */
++ stringWithCString:(const char *)cStr;
+- initWithCString:(const char *)cStr;
+- initWithCString:(const char *)cStr length:(unsigned int)length;
+
@end
/*
* The following must be here to support compiler instantiation
- * of constant strings. Do not ever use the directly.
+ * of constant strings. Do not ever use them directly.
*/
extern struct objc_class _NSConstantStringClassReference;
Modified: trunk/Foundation/NSString.m
===================================================================
--- trunk/Foundation/NSString.m 2006-08-30 18:51:24 UTC (rev 265)
+++ trunk/Foundation/NSString.m 2006-08-30 21:43:26 UTC (rev 266)
@@ -80,6 +80,57 @@
@implementation NSString
/*!
+ * @name Encodings
+ * @{
+ */
+
+/*!
+ * Returns the default encoding used by C string handling methods.
+ * This value can not be changed programatically, and callers
+ * should avoid using implicit encoding.
+ */
++ (NSStringEncoding) defaultCStringEncoding {
+ /* Everything is a UTF-8 string. I swear. */
+ return NSUTF8StringEncoding;
+}
+
+/*! @} */
+
+
+/*!
+ * @name Allocation and Initialization
+ * @{
+ */
+
+/*!
+ * Allocate and initialize an NSString instance with the supplied C string.
+ * @param cStr NULL-terminted C string.
+ * @return Allocated and initialized NSString instance.
+ */
++ stringWithCString:(const char *)cStr {
+ return [[[self alloc] initWithCString:cStr] autorelease];
+}
+
+/*!
+ * Allocate and initialize an empty NSString instance.
+ * @return New empty NSString instance.
+ */
++ string {
+ [self release];
+ return [[[NSUnicodeString alloc] init] autorelease];
+}
+
+/*!
+ * Initialize the receiver with the supplied C string, encoded according to encoding.
+ * @param cStr NULL-terminated C string.
+ * @param encoding Character encoding for the C string.
+ * @return Newly initialized NSString instance.
+ */
+- initWithCString:(const char *)cStr encoding:(NSStringEncoding)encoding {
+ return [self initWithBytes: cStr length: strlen(cStr) encoding: encoding];
+}
+
+/*!
* Initializes the receiver with bytes, of length, of the specified encoding.
* @param bytes String data, not null-terminated.
* @param length Length of data.
@@ -87,7 +138,7 @@
* @return Newly initialized string.
*/
- (id) initWithBytes:(const void *)bytes length:(unsigned int)length encoding:(NSStringEncoding)encoding {
- self = [self init];
+ self = [super init];
if (!self)
return nil;
@@ -100,7 +151,10 @@
/* Otherwise, instantiate a concrete string */
[self release];
- self = [[NSUnicodeString alloc] initWithBytes: bytes length: length encoding: encoding];
+ if (encoding == NSASCIIStringEncoding)
+ self = [[NSSimpleCString alloc] initWithBytes: bytes length: length encoding: encoding];
+ else
+ self = [[NSUnicodeString alloc] initWithBytes: bytes length: length encoding: encoding];
return self;
}
@@ -119,7 +173,7 @@
* @return Newly initialized string.
*/
- (id) initWithBytesNoCopy:(void *)bytes length:(unsigned int)length encoding:(NSStringEncoding)encoding freeWhenDone:(BOOL)freeWhenDone {
- self = [self init];
+ self = [super init];
if (!self)
return nil;
@@ -136,11 +190,17 @@
return self;
}
+
/*!
+ * @}
+ * Allocation and Initialization.
+ */
+
+/*!
* Returns length.
*/
- (unsigned int) length {
- [NSException raise: NSGenericException format: @"-[NSString length] is abstract"];
+ [self _subclassResponsibility: _cmd];
/* Unreachable */
return 0;
}
@@ -151,7 +211,7 @@
* past the end of the receiver.
*/
- (unichar) characterAtIndex:(unsigned int) index {
- [NSException raise: NSGenericException format: @"-[NSString characterAtIndex:] is abstract"];
+ [self _subclassResponsibility: _cmd];
/* Unreachable */
return 0;
}
@@ -164,22 +224,6 @@
}
/*!
- * Returns representation of the receiver as a C string
- * in the default C encoding. This method has been deprecated in
- * favor of UTF8String.
- *
- * If the string can not be converted with the default encoding,
- * an NSCharacterConversionException will be raised.
- *
- * The string returned by this method will be freed when the
- * receiver is deallocated.
- */
-- (char *) cString {
- /* TODO Unimplemented */
- return nil;
-}
-
-/*!
* Fills buffer with the characters contained within aRange
* of the string. An NSRangeException is raised if aRange
* is not fully contained within the receiver.
@@ -198,23 +242,55 @@
}
}
+/*!
+ * Returns representation of the receiver as a C string
+ * in the default C encoding. This method has been deprecated in
+ * favor of UTF8String.
+ *
+ * If the string can not be converted with the default encoding,
+ * an NSCharacterConversionException will be raised.
+ *
+ * The string returned by this method will be freed when the
+ * receiver is deallocated.
+ * @todo Unimplemented.
+ */
+- (char *) cString {
+ /* TODO Unimplemented */
+ return nil;
+}
+
- (NSString *) description {
return self;
}
-@end
+/*!
+ * @name Deprecated
+ * @{
+ */
-@implementation NSString(NSStringCreation)
-
-+ stringWithCString:(const char *)cStr {
- return [[[self alloc] initWithCString:cStr] autorelease];
+/*!
+ * Initialize the receiver with the supplied C string, using the default string encoding.
+ * @deprecated Caller's should make use of initWithCString:encoding: instead.
+ * @param cStr NULL-terminted C string.
+ * @return Allocated and initialized NSString instance.
+ */
+- initWithCString:(const char *)cStr {
+ return [self initWithCString: cStr encoding: [NSString defaultCStringEncoding]];
}
-- initWithCString:(const char *)cStr {
- [self release];
- return [[NSSimpleCString alloc] initWithCString:cStr];
+/*!
+ * Initialize the receiver with the supplied C string, of length, using the default string encoding.
+ * @deprecated Caller's should make use of initWithCString:encoding: or initWithBytes:length:encoding: instead.
+ * @param cStr C string, using the default system encoding.
+ * @param length Number of characters in string.
+ * @return Newly initialized NSString instance.
+ */
+- initWithCString:(const char *)cStr length:(unsigned int)length {
+ return [self initWithBytes: cStr length: length encoding: [NSString defaultCStringEncoding]];
}
+/*! @} */
+
@end
/*! @} */
Modified: trunk/Foundation/NSUnicodeString.m
===================================================================
--- trunk/Foundation/NSUnicodeString.m 2006-08-30 18:51:24 UTC (rev 265)
+++ trunk/Foundation/NSUnicodeString.m 2006-08-30 21:43:26 UTC (rev 266)
@@ -84,6 +84,12 @@
[super dealloc];
}
+/*!
+ * @name Initialization
+ * @internal
+ * @{
+ */
+
/*! Initialize the string.
* @todo Need better heuristics for determining destination buffer length, and
* for deciding when we should call realloc.
@@ -329,6 +335,20 @@
return self;
}
+/*! @} */
+
+/*!
+ * @name Accessing Data
+ * @internal
+ * @{
+ */
+
+- (unsigned int) length {
+ return _length;
+}
+
+/*! @} */
+
@end
/*! @} */
Modified: trunk/Tests/Foundation.c
===================================================================
--- trunk/Tests/Foundation.c 2006-08-30 18:51:24 UTC (rev 265)
+++ trunk/Tests/Foundation.c 2006-08-30 21:43:26 UTC (rev 266)
@@ -43,6 +43,8 @@
/* Standard Foundation Suites */
Suite *s = NSZone_suite();
SRunner *sr = srunner_create(s);
+ srunner_add_suite(sr, NSString_suite());
+ srunner_add_suite(sr, NSUnicodeString_suite());
srunner_add_suite(sr, NSAutoreleasePool_suite());
srunner_add_suite(sr, NSData_suite());
srunner_add_suite(sr, NSMutableData_suite());
@@ -54,8 +56,6 @@
srunner_add_suite(sr, NSRange_suite());
srunner_add_suite(sr, NSGeometry_suite());
srunner_add_suite(sr, NSByteOrder_suite());
- srunner_add_suite(sr, NSString_suite());
- srunner_add_suite(sr, NSUnicodeString_suite());
if (argc == 2)
srunner_set_xml(sr, argv[1]);
Modified: trunk/Tests/NSString.m
===================================================================
--- trunk/Tests/NSString.m 2006-08-30 18:51:24 UTC (rev 265)
+++ trunk/Tests/NSString.m 2006-08-30 21:43:26 UTC (rev 266)
@@ -90,6 +90,32 @@
}
END_TEST
+/* Encodings */
+
+START_TEST (test_cls_defaultCStringEncoding) {
+ /* We can't test for much here. Let's just call the method */
+ fail_unless([NSString defaultCStringEncoding]);
+}
+END_TEST
+
+
+/* Initialization */
+
+START_TEST (test_cls_string) {
+ NSString *empty;
+
+ empty = [NSString string];
+ fail_unless([empty length] == 0, "+[NSString string] returned a string with a non-zero length");
+}
+END_TEST
+
+START_TEST (test_cls_stringWithCString) {
+ NSString *string;
+ string = [NSString stringWithCString: TEST_STRING];
+ fail_unless([string length] == sizeof(TEST_STRING) - 1, "+[NSString stringWithCString] returned a string with incorrect length (Expected %d, got %d)", sizeof(TEST_STRING) - 1, [string length]);
+}
+END_TEST
+
START_TEST (test_initWithBytes) {
NSString *string;
@@ -98,6 +124,14 @@
}
END_TEST
+START_TEST (test_initWithCStringEncoding) {
+ NSString *string;
+
+ string = [[NSString alloc] initWithCString: TEST_STRING encoding: NSUTF8StringEncoding];
+ fail_if(string == nil, "-[NSString initWithCString: encoding:] returned nil");
+}
+END_TEST
+
START_TEST (test_initWithBytesNoCopyLengthEncodingFreeWhenDone) {
NSString *string;
char testData[] = "Hello, Universe!";
@@ -131,9 +165,17 @@
suite_add_tcase(s, tc_subclass);
tcase_add_test(tc_subclass, test_subclass_initWithBytes);
+ TCase *tc_encoding = tcase_create("Encodings");
+ tcase_add_checked_fixture(tc_encoding, setUp, tearDown);
+ suite_add_tcase(s, tc_encoding);
+ tcase_add_test(tc_subclass, test_cls_defaultCStringEncoding);
+
TCase *tc_init = tcase_create("Initialization");
tcase_add_checked_fixture(tc_init, setUp, tearDown);
suite_add_tcase(s, tc_init);
+ tcase_add_test(tc_init, test_cls_string);
+ tcase_add_test(tc_init, test_cls_stringWithCString);
+ tcase_add_test(tc_init, test_initWithCStringEncoding);
tcase_add_test(tc_init, test_initWithBytes);
tcase_add_test(tc_init, test_initWithBytesNoCopyLengthEncodingFreeWhenDone);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <la...@us...> - 2006-08-30 18:51:29
|
Revision: 265
http://svn.sourceforge.net/substrate/?rev=265&view=rev
Author: landonf
Date: 2006-08-30 11:51:24 -0700 (Wed, 30 Aug 2006)
Log Message:
-----------
r5677@zadder: landonf | 2006-08-30 11:49:09 -0700
Clean up some compile warnings
Modified Paths:
--------------
trunk/Tests/NSUnicodeString.m
Property Changed:
----------------
trunk/
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
+ 11572a18-12fc-0310-9209-f8edcc8181a7:/local/substrate/trunk:5677
Modified: trunk/Tests/NSUnicodeString.m
===================================================================
--- trunk/Tests/NSUnicodeString.m 2006-08-30 07:57:46 UTC (rev 264)
+++ trunk/Tests/NSUnicodeString.m 2006-08-30 18:51:24 UTC (rev 265)
@@ -31,6 +31,8 @@
#include <Foundation/NSString.h>
#include <Foundation/NSAutoreleasePool.h>
+#include <string.h>
+
/*
* Test data for all supported encodings
*/
@@ -186,15 +188,15 @@
START_TEST (test_initWithBytesNoCopyLengthEncodingFreeWhenDone) {
NSString *string;
- const void *bytes;
+ void *bytes;
/* No free, UTF-16-BE */
- string = [[NSString alloc] initWithBytesNoCopy: NSUnicodeStringEncoding_data length: sizeof(NSUnicodeStringEncoding_data) encoding: NSUnicodeStringEncoding freeWhenDone: NO];
+ string = [[NSString alloc] initWithBytesNoCopy: (void *) NSUnicodeStringEncoding_data length: sizeof(NSUnicodeStringEncoding_data) encoding: NSUnicodeStringEncoding freeWhenDone: NO];
fail_if(string == nil, "-[NSString initWithBytesNoCopy: length: encoding: freeWhenDone: NO] returned nil with a UTF-16-BE encoded string.");
[string release];
/* No free, UTF-16-LE */
- string = [[NSString alloc] initWithBytesNoCopy: NSUnicodeStringEncodingLE_data length: sizeof(NSUnicodeStringEncodingLE_data) encoding: NSUnicodeStringEncoding freeWhenDone: NO];
+ string = [[NSString alloc] initWithBytesNoCopy: (void *) NSUnicodeStringEncodingLE_data length: sizeof(NSUnicodeStringEncodingLE_data) encoding: NSUnicodeStringEncoding freeWhenDone: NO];
fail_if(string == nil, "-[NSString initWithBytesNoCopy: length: encoding: freeWhenDone: NO] returned nil with a UTF-16-LE encoded string.");
[string release];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <la...@us...> - 2006-08-30 07:57:51
|
Revision: 264 Author: landonf Date: 2006-08-30 00:57:46 -0700 (Wed, 30 Aug 2006) ViewCVS: http://svn.sourceforge.net/substrate/?rev=264&view=rev Log Message: ----------- Sigh. Use the correct image size for the logo. Modified Paths: -------------- www/index.html Modified: www/index.html =================================================================== --- www/index.html 2006-08-30 07:26:52 UTC (rev 263) +++ www/index.html 2006-08-30 07:57:46 UTC (rev 264) @@ -111,7 +111,7 @@ written by Ovidiu Predescu, Mircea Oancea, and Helge Hess. </p> <p> - <a href="http://sourceforge.net"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=175904&type=4" width="210" height="62" border="0" alt="SourceForge.net Logo" /></a> + <a href="http://sourceforge.net"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=175904&type=4" width="125" height="37" border="0" alt="SourceForge.net Logo" /></a> </p> </body> </html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <la...@us...> - 2006-08-30 07:26:57
|
Revision: 263 Author: landonf Date: 2006-08-30 00:26:52 -0700 (Wed, 30 Aug 2006) ViewCVS: http://svn.sourceforge.net/substrate/?rev=263&view=rev Log Message: ----------- Display a better logo Modified Paths: -------------- www/index.html Modified: www/index.html =================================================================== --- www/index.html 2006-08-30 07:22:11 UTC (rev 262) +++ www/index.html 2006-08-30 07:26:52 UTC (rev 263) @@ -111,7 +111,7 @@ written by Ovidiu Predescu, Mircea Oancea, and Helge Hess. </p> <p> - <a href="http://sourceforge.net"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=175904&type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></a> + <a href="http://sourceforge.net"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=175904&type=4" width="210" height="62" border="0" alt="SourceForge.net Logo" /></a> </p> </body> </html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <la...@us...> - 2006-08-30 07:22:16
|
Revision: 262 Author: landonf Date: 2006-08-30 00:22:11 -0700 (Wed, 30 Aug 2006) ViewCVS: http://svn.sourceforge.net/substrate/?rev=262&view=rev Log Message: ----------- Minor HTML fixes Modified Paths: -------------- www/index.html Modified: www/index.html =================================================================== --- www/index.html 2006-08-30 07:17:11 UTC (rev 261) +++ www/index.html 2006-08-30 07:22:11 UTC (rev 262) @@ -74,7 +74,8 @@ <ul> <li>Landon Fuller (landonf [at] opendarwin [dot] org)</li> </ul> - + </p> + <p> Past contributors include: <ul> <li>David Leimbach (leimy [at] opendarwin [dot] org)</li> @@ -110,7 +111,7 @@ written by Ovidiu Predescu, Mircea Oancea, and Helge Hess. </p> <p> - <a href="http://sourceforge.net"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=175904&type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></a> + <a href="http://sourceforge.net"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=175904&type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></a> </p> </body> </html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <la...@us...> - 2006-08-30 07:17:16
|
Revision: 261 Author: landonf Date: 2006-08-30 00:17:11 -0700 (Wed, 30 Aug 2006) ViewCVS: http://svn.sourceforge.net/substrate/?rev=261&view=rev Log Message: ----------- Maintain web pages outside of trunk/ Added Paths: ----------- www/ Removed Paths: ------------- trunk/www/ Copied: www (from rev 260, trunk/www) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <la...@us...> - 2006-08-30 07:04:42
|
Revision: 260 Author: landonf Date: 2006-08-30 00:04:35 -0700 (Wed, 30 Aug 2006) ViewCVS: http://svn.sourceforge.net/substrate/?rev=260&view=rev Log Message: ----------- s/OpenDarwin libFoundation/Substrate/g Modified Paths: -------------- trunk/www/index.html Added Paths: ----------- trunk/www/default.css Removed Paths: ------------- trunk/www/lf.css Copied: trunk/www/default.css (from rev 259, trunk/www/lf.css) =================================================================== --- trunk/www/default.css (rev 0) +++ trunk/www/default.css 2006-08-30 07:04:35 UTC (rev 260) @@ -0,0 +1,77 @@ +body { + background-color: white; + color: #212121; + margin: 1em; + font: 75% "Lucida Grande", Verdana, Lucida, Helvetica, Arial, sans-serif; +} + +a { + text-decoration: none; + color: #0669B2; + background-color: transparent; +} + +p { + margin: 0.5em 1em 1em 1em; + line-height: 1.5em; +} + +p a { + text-decoration: underline; +} + +p a:visited { + color: #044476; + background-color: transparent; +} + +p a:active { + color: #67087B; + background-color: transparent; +} + +h1, h2, h3 { + color: #595959; + background-color: transparent; + font-family: "Lucida Grande", Verdana, Lucida, Helvetica, Arial, sans-serif; + font-size: 100%; + font-weight: normal; + margin: 0.5em 0 0 0; + padding-top: 0.5em; + font-weight: bold; +} + +h1 { + font-size: 200%; + border-bottom: 1px solid #B4B4B4; +} + +h2 { + font-size: 180%; +} + +h3 { + font-size: 140%; +} + +ul { + line-height: 1.5em; + list-style-type: square; + margin: 0.5em 0 0 1.5em; + padding: 0; +} + +ul a, ol a { + text-decoration: underline; +} + +li { + margin-left: 1em; +} + +pre { + margin-left: 1em; + margin-right: 1em; + padding: 0.5em; + background-color: #E6E6E6; +} Modified: trunk/www/index.html =================================================================== --- trunk/www/index.html 2006-08-30 05:20:33 UTC (rev 259) +++ trunk/www/index.html 2006-08-30 07:04:35 UTC (rev 260) @@ -1,53 +1,50 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> - <title>OpenDarwin libFoundation</title> + <title>Objective-C Substrate</title> <meta http-equiv="Content-type" content="text/html; charset=iso-8859-1"/> <meta name="author" content="Will Barton (wb...@op...)"/> <meta name="copyright" content="2004, OpenDarwin"/> <meta name="robots" content="all"/> - <link rel="stylesheet" type="text/css" href="lf.css"/> + <link rel="stylesheet" type="text/css" href="default.css"/> </head> <body> - <h1>OpenDarwin libFoundation</h1> + <h1>Objective-C Substrate</h1> <ul id="nav"> <li><a href="#about">About</a></li> <li><a href="#get">Download</a></li> <li><a href="#dev">Development</a></li> <li><a href="#doc">Documentation</a></li> + <li><a href="#hist">History</a></li> </ul> <a name="about"><h2>About</h2></a> <p> - OpenDarwin's libFoundation is a light-weight standalone library which implements a large portion of the OpenStep specification and is designed to work with both the GNU and NeXT/Apple Objective-C runtimes. + Substrate is a light-weight standalone library which + implements a large portion of the OpenStep specification + and is designed to work with both the GNU and NeXT/Apple Objective-C + runtimes. Substrate is a continuation of the OpenDarwin libFoundation + project. </p> <p> - OpenDarwin's libFoundation is currently under active development, - and is not complete or currently useful. In its current state it + Substrate is currently under active development, and is not + complete or even very useful. In its current state it is known to compile and pass unit tests on Darwin, FreeBSD, - Debian GNU/Linux, and Windows. + and Debian GNU/Linux. Nightly <a href="testing">unit test results</a> are available for some of our supported platforms. </p> - <p> - OpenDarwin's libFoundation is based on the original libFoundation, - written by Ovidiu Predescu, Mircea Oancea, and Helge Hess. - </p> <a name="get"><h2>Download</h2></a> <p> - To get the latest source of OpenDarwin's libFoundation from - OpenDarwin CVS, you can use the following commands: + To get the latest source, you can use the following command: </p> - <pre>cvs -d :pserver:ano...@an...:/Volumes/src/cvs/od login -cvs -d :pserver:ano...@an...:/Volumes/src/cvs/od co -P libFoundation</pre> + <pre>svn co https://svn.sourceforge.net/svnroot/substrate substrate</pre> <p> - When the server asks you for a password you can simply hit - return; the password is empty. The CVS repository can also be - browsed through <a - href="http://www.opendarwin.org/cgi-bin/cvsweb.cgi/projects/libFoundation">CVSWeb</a>. + The CVS repository can also be browsed through <a + href="http://svn.sourceforge.net/viewvc/substrate/">ViewVC</a>. </p> <a name="dev"><h2>Development</h2></a> @@ -55,8 +52,8 @@ If you're interested in contributing, the following are current areas of focus: <ul> <li>Documentation Writing. Beyond simply writing doxygen documentation, - further documentation is required on building, testing, and using OpenDarwin - libFoundation on all of our supported operating systems.</li> + further documentation is required on building, testing, and using + Substrate on all of our supported operating systems.</li> <li>Foundation Implementation. This one is obvious; we can always use more hands writing code and corresponding unit tests.</li> @@ -64,18 +61,22 @@ </p> <p> The <a - href="http://opendarwin.org/mailman/listinfo/libFoundation">libFoundation</a> + href="https://lists.sourceforge.net/lists/listinfo/substrate-devel">substrate-devel</a> mailing list is where most discussions are held. Only list subscribers can post to the list, but subscription is open to - anyone. If you want to track cvs commits to libFoundation, + anyone. If you want to track cvs commits to Substrate, you can subscribe to the <a - href="http://opendarwin.org/mailman/listinfo/cvs-libfoundation-all">cvs-libfoundation-all</a> + href="https://lists.sourceforge.net/lists/listinfo/substrate-commits">substrate-commits</a> mailing list. </p> <p> - Current OpenDarwin libFoundation developers are: + Current Substrate developers are: <ul> <li>Landon Fuller (landonf [at] opendarwin [dot] org)</li> + </ul> + + Past contributors include: + <ul> <li>David Leimbach (leimy [at] opendarwin [dot] org)</li> <li>Felix Kronlage (fkr [at] opendarwin [dot] org)</li> <li>Will Barton (wbb4 [at] opendarwin [dot] org)</li> @@ -85,19 +86,31 @@ <a name="doc"><h2>Documentation</h2></a> <p> - OpenDarwin libFoundation's Doxygen-based documentation is regenerated nightly and can + Subtrate's Doxygen-based documentation is regenerated nightly and can be browsed <a href="docs/">on-line</a>. Documentation is being written in conjunction with the library implementation. - Any noteworthy differences between OpenDarwin's libFoundation and Apple's Foundation + Any noteworthy differences between Substrate and Apple's Foundation are explained in the documentation. </p> <p> - If you are interested in contributing to the libFoundation documentation, - please send an e-mail to the libFoundation mailing list. + If you are interested in contributing to the Substrate documentation, + please send an e-mail to the Substrate mailing list. Your contributions will be most appreciated. </p> + <a name="hist"><h2>History</h2></a> + <p> + Substrate is a continuation of OpenDarwin's libFoundation project. Substrate + was moved to SourceForge and renamed upon the cessation of the OpenDarwin + project. + + OpenDarwin's libFoundation itself was based on the original libFoundation, + written by Ovidiu Predescu, Mircea Oancea, and Helge Hess. + </p> + <p> + <a href="http://sourceforge.net"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=175904&type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></a> + </p> </body> </html> Deleted: trunk/www/lf.css =================================================================== --- trunk/www/lf.css 2006-08-30 05:20:33 UTC (rev 259) +++ trunk/www/lf.css 2006-08-30 07:04:35 UTC (rev 260) @@ -1,77 +0,0 @@ -body { - background-color: white; - color: #212121; - margin: 1em; - font: 75% "Lucida Grande", Verdana, Lucida, Helvetica, Arial, sans-serif; -} - -a { - text-decoration: none; - color: #0669B2; - background-color: transparent; -} - -p { - margin: 0.5em 1em 1em 1em; - line-height: 1.5em; -} - -p a { - text-decoration: underline; -} - -p a:visited { - color: #044476; - background-color: transparent; -} - -p a:active { - color: #67087B; - background-color: transparent; -} - -h1, h2, h3 { - color: #595959; - background-color: transparent; - font-family: "Lucida Grande", Verdana, Lucida, Helvetica, Arial, sans-serif; - font-size: 100%; - font-weight: normal; - margin: 0.5em 0 0 0; - padding-top: 0.5em; - font-weight: bold; -} - -h1 { - font-size: 200%; - border-bottom: 1px solid #B4B4B4; -} - -h2 { - font-size: 180%; -} - -h3 { - font-size: 140%; -} - -ul { - line-height: 1.5em; - list-style-type: square; - margin: 0.5em 0 0 1.5em; - padding: 0; -} - -ul a, ol a { - text-decoration: underline; -} - -li { - margin-left: 1em; -} - -pre { - margin-left: 1em; - margin-right: 1em; - padding: 0.5em; - background-color: #E6E6E6; -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |