Index: ChangeLog ================================================================== --- ChangeLog +++ ChangeLog @@ -1,5 +1,38 @@ +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 occurrences of the object from the array and to out of bounds reads. * Change the URL in the framework plist to the homepage. Index: src/Makefile ================================================================== --- src/Makefile +++ src/Makefile @@ -29,11 +29,10 @@ OFXMLElement.m \ OFXMLParser.m \ unicode.m INCLUDES := ${SRCS:.m=.h} \ - OFFastEnumeration.h \ OFMacros.h \ ObjFW.h \ asprintf.h \ ${ATOMIC_H} \ objfw-defs.h \ Index: src/OFArray.h ================================================================== --- src/OFArray.h +++ src/OFArray.h @@ -11,11 +11,10 @@ #include #import "OFObject.h" #import "OFEnumerator.h" -#import "OFFastEnumeration.h" @class OFDataArray; @class OFString; /** @@ -48,11 +47,11 @@ + arrayWithObjects: (OFObject*)first, ...; /** * 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; /** @@ -82,11 +81,11 @@ argList: (va_list)args; /** * 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; /** Index: src/OFDictionary.h ================================================================== --- src/OFDictionary.h +++ src/OFDictionary.h @@ -11,11 +11,10 @@ #include #import "OFObject.h" #import "OFEnumerator.h" -#import "OFFastEnumeration.h" @class OFArray; struct of_dictionary_bucket { Index: src/OFEnumerator.h ================================================================== --- src/OFEnumerator.h +++ src/OFEnumerator.h @@ -24,5 +24,31 @@ * Resets the enumerator, so the next call to nextObject returns the first * object again. */ - 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 DELETED src/OFFastEnumeration.h Index: src/OFFastEnumeration.h ================================================================== --- src/OFFastEnumeration.h +++ src/OFFastEnumeration.h @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2008 - 2009 - * Jonathan Schleifer - * - * 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 Index: src/OFMutableString.m ================================================================== --- src/OFMutableString.m +++ src/OFMutableString.m @@ -43,14 +43,15 @@ if (!is_utf8) { 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; } ulen = [self length]; Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -29,13 +29,13 @@ #ifdef OF_GNU_RUNTIME # import #endif #ifdef OF_ATOMIC_OPS -#import "atomic.h" +# import "atomic.h" #else -#import "threading.h" +# import "threading.h" #endif struct pre_ivar { void **memchunks; size_t memchunks_size; Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -67,11 +67,11 @@ } - initWithObject: (OFObject *)obj { self = [super init]; - object = [obj copy]; + object = [obj retain]; if (!of_thread_new(&thread, call_main, self)) { Class c = isa; [object release]; [super dealloc]; Index: src/threading.h ================================================================== --- src/threading.h +++ src/threading.h @@ -14,23 +14,23 @@ #if !defined(OF_THREADS) || (!defined(OF_HAVE_PTHREADS) && !defined(_WIN32)) # error No threads available! #endif #if defined(OF_HAVE_PTHREADS) -#include +# include typedef pthread_t of_thread_t; typedef pthread_mutex_t of_mutex_t; typedef pthread_key_t of_tlskey_t; #elif defined(_WIN32) -#include +# include 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; #else typedef pthread_mutex_t of_spinlock_t; @@ -240,11 +240,11 @@ 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); #else return of_mutex_unlock(s);