summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Schleifer <js@webkeks.org>2010-02-01 19:11:51 +0100
committerJonathan Schleifer <js@webkeks.org>2010-02-01 19:11:51 +0100
commita623b42e4d682cad10e0630a612e2df48f5a9208 (patch)
treea1cb0317b3858c5dcf5619c0053b0b21b0f8efef
parent814badfa009cfcb91accd2b48518d450b947ec0d (diff)
Merge latest changes from default branch into 0.2 branch.
-rw-r--r--ChangeLog33
-rw-r--r--src/Makefile1
-rw-r--r--src/OFArray.h5
-rw-r--r--src/OFDictionary.h1
-rw-r--r--src/OFEnumerator.h26
-rw-r--r--src/OFFastEnumeration.h38
-rw-r--r--src/OFMutableString.m5
-rw-r--r--src/OFObject.m4
-rw-r--r--src/OFThread.m2
-rw-r--r--src/threading.h8
10 files changed, 71 insertions, 52 deletions
diff --git a/ChangeLog b/ChangeLog
index 824ae4eb..744c72e1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,36 @@
+Legend:
+ * Changes of existing features or bugfixes.
+ + New features.
+
+ObjFW 0.1.2 -> 0.2, 01.02.2010
+ + Support for ObjC 2 Fast Enumerations on every platform which has
+ compiler support for fast enumerations.
+ + Support for ObjC 2 properties on every platform with compiler support.
+ + Fast Enumeration through arrays and dictionaries.
+ * OFIterator has been removed.
+ + OFEnumerator was added to replace OFIterator, which is more general
+ and works with arrays and dictionaries.
+ + Portable implementation for atomic operations.
+ + Portable implementation for spinlocks. They use atomic operations if
+ available, if not they fall back to pthread spinlocks. If both are
+ unavailable, mutexes are used as a last fallback.
+ * -[retain] and -[release] are now atomic. If no atomic operations are
+ available, spinlocks are used (which can fall back to mutexes, see
+ above).
+ * -[readLine] now handles \r\n without having the \r included in the
+ returned line.
+ + OFThread now has -[tryLock].
+ * Mutation methods have been removed from immutable interfaces, thus
+ already giving an error at compilation instead of at runtime.
+ * Dependencies between headers have been reduced, leading to faster
+ compile times.
+ * The interfaces of OFSocket and OFStream were cleaned up and some
+ methods were moved to OFTCPSocket, as they make sense only there.
+ * File methods unavailable on Windows don't throw an exception at
+ runtime anymore, but instead are not even in the interface on
+ Windows. This way, it is a compile time error instead of a runtime
+ error.
+
ObjFW 0.1.1 -> 0.1.2, 15.01.2010
* Fix a bug in OFMutableArray's -[removeObject:] and
-[removeObjectIdenticalTo:] that could lead to not removing all
diff --git a/src/Makefile b/src/Makefile
index 078a9c7f..c76441a2 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -31,7 +31,6 @@ SRCS = OFArray.m \
unicode.m
INCLUDES := ${SRCS:.m=.h} \
- OFFastEnumeration.h \
OFMacros.h \
ObjFW.h \
asprintf.h \
diff --git a/src/OFArray.h b/src/OFArray.h
index ad497742..586377f5 100644
--- a/src/OFArray.h
+++ b/src/OFArray.h
@@ -13,7 +13,6 @@
#import "OFObject.h"
#import "OFEnumerator.h"
-#import "OFFastEnumeration.h"
@class OFDataArray;
@class OFString;
@@ -50,7 +49,7 @@
/**
* Creates a new OFArray with the objects from the specified C array.
*
- * \param objs A C array of objects.
+ * \param objs A C array of objects, terminated with nil
* \return A new autoreleased OFArray
*/
+ arrayWithCArray: (OFObject**)objs;
@@ -84,7 +83,7 @@
/**
* Initializes an OFArray with the objects from the specified C array.
*
- * \param objs A C array of objects
+ * \param objs A C array of objects, terminated with nil
* \return An initialized OFArray
*/
- initWithCArray: (OFObject**)objs;
diff --git a/src/OFDictionary.h b/src/OFDictionary.h
index 1c9fe9e9..e8ceacf7 100644
--- a/src/OFDictionary.h
+++ b/src/OFDictionary.h
@@ -13,7 +13,6 @@
#import "OFObject.h"
#import "OFEnumerator.h"
-#import "OFFastEnumeration.h"
@class OFArray;
diff --git a/src/OFEnumerator.h b/src/OFEnumerator.h
index a53234e4..aaabb28a 100644
--- a/src/OFEnumerator.h
+++ b/src/OFEnumerator.h
@@ -26,3 +26,29 @@
*/
- reset;
@end
+
+/*
+ * This needs to be exactly like this because it's hardcoded in the compiler.
+ *
+ * We need this bad check to see if we already imported Cocoa, which defines
+ * this as well.
+ */
+#define of_fast_enumeration_state_t NSFastEnumerationState
+#ifndef NSINTEGER_DEFINED
+typedef struct __of_fast_enumeration_state {
+ unsigned long state;
+ id *itemsPtr;
+ unsigned long *mutationsPtr;
+ unsigned long extra[5];
+} of_fast_enumeration_state_t;
+#endif
+
+/**
+ * The OFFastEnumeration protocol needs to be implemented by all classes
+ * supporting fast enumeration.
+ */
+@protocol OFFastEnumeration
+- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
+ objects: (id*)objects
+ count: (int)count;
+@end
diff --git a/src/OFFastEnumeration.h b/src/OFFastEnumeration.h
deleted file mode 100644
index e81c91c6..00000000
--- a/src/OFFastEnumeration.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2008 - 2009
- * Jonathan Schleifer <js@webkeks.org>
- *
- * All rights reserved.
- *
- * This file is part of ObjFW. It may be distributed under the terms of the
- * Q Public License 1.0, which can be found in the file LICENSE included in
- * the packaging of this file.
- */
-
-#import "OFObject.h"
-
-/*
- * This needs to be exactly like this because it's hardcoded in the compiler.
- *
- * We need this bad check to see if we already imported Cocoa, which defines
- * this as well.
- */
-#define of_fast_enumeration_state_t NSFastEnumerationState
-#ifndef NSINTEGER_DEFINED
-typedef struct __of_fast_enumeration_state {
- unsigned long state;
- id *itemsPtr;
- unsigned long *mutationsPtr;
- unsigned long extra[5];
-} of_fast_enumeration_state_t;
-#endif
-
-/**
- * The OFFastEnumeration protocol needs to be implemented by all classes
- * supporting fast enumeration.
- */
-@protocol OFFastEnumeration
-- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
- objects: (id*)objects
- count: (int)count;
-@end
diff --git a/src/OFMutableString.m b/src/OFMutableString.m
index 046d512e..9b5c60f8 100644
--- a/src/OFMutableString.m
+++ b/src/OFMutableString.m
@@ -45,10 +45,11 @@ apply_table(id self, Class isa, char **string, unsigned int *length,
assert(table_size >= 1);
uint8_t *p = (uint8_t*)*string + *length;
+ uint8_t t;
while (--p >= (uint8_t*)*string)
- if (table[0][*p])
- *p = table[0][*p];
+ if ((t = table[0][*p]) != 0)
+ *p = t;
return;
}
diff --git a/src/OFObject.m b/src/OFObject.m
index b8c42dfb..1f46792e 100644
--- a/src/OFObject.m
+++ b/src/OFObject.m
@@ -31,9 +31,9 @@
#endif
#ifdef OF_ATOMIC_OPS
-#import "atomic.h"
+# import "atomic.h"
#else
-#import "threading.h"
+# import "threading.h"
#endif
struct pre_ivar {
diff --git a/src/OFThread.m b/src/OFThread.m
index 107b56b7..3c91433c 100644
--- a/src/OFThread.m
+++ b/src/OFThread.m
@@ -69,7 +69,7 @@ call_main(id obj)
- initWithObject: (OFObject <OFCopying>*)obj
{
self = [super init];
- object = [obj copy];
+ object = [obj retain];
if (!of_thread_new(&thread, call_main, self)) {
Class c = isa;
diff --git a/src/threading.h b/src/threading.h
index 16cb4147..1cbd5b78 100644
--- a/src/threading.h
+++ b/src/threading.h
@@ -16,19 +16,19 @@
#endif
#if defined(OF_HAVE_PTHREADS)
-#include <pthread.h>
+# include <pthread.h>
typedef pthread_t of_thread_t;
typedef pthread_mutex_t of_mutex_t;
typedef pthread_key_t of_tlskey_t;
#elif defined(_WIN32)
-#include <windows.h>
+# include <windows.h>
typedef HANDLE of_thread_t;
typedef CRITICAL_SECTION of_mutex_t;
typedef DWORD of_tlskey_t;
#endif
#if defined(OF_ATOMIC_OPS)
-#import "atomic.h"
+# import "atomic.h"
typedef int32_t of_spinlock_t;
#elif defined(OF_HAVE_PTHREAD_SPINLOCKS)
typedef pthread_spinlock_t of_spinlock_t;
@@ -242,7 +242,7 @@ static OF_INLINE BOOL
of_spinlock_unlock(of_spinlock_t *s)
{
#if defined(OF_ATOMIC_OPS)
- *s = 0;
+ of_atomic_and32((uint32_t*)s, 0);
return YES;
#elif defined(OF_HAVE_PTHREAD_SPINLOCKS)
return (pthread_spin_unlock(s) ? NO : YES);