Overview
Comment: | Add OFFastEnumeration protocol and OFEnumerationMutationException. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
9a881883befa272fece76300a16e18df |
User & Date: | js on 2010-01-03 17:22:05 |
Other Links: | manifest | tags |
Context
2010-01-03
| ||
17:28 | OFMutableArray: Fix out of range check for -[removeNItems:atIndex:]. check-in: 14fe09e7fa user: js tags: trunk | |
17:22 | Add OFFastEnumeration protocol and OFEnumerationMutationException. check-in: 9a881883be user: js tags: trunk | |
2010-01-02
| ||
18:18 | Fix a typo. check-in: bd408f1cee user: js tags: trunk | |
Changes
Modified ObjFW.xcodeproj/project.pbxproj from [5f8f5e0893] to [121f4fad30].
︙ | ︙ | |||
122 123 124 125 126 127 128 129 130 131 132 133 134 135 | 4B67998A1099E7C50041064A /* OFXMLParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFXMLParser.m; path = src/OFXMLParser.m; sourceTree = "<group>"; }; 4B67998B1099E7C50041064A /* threading.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = threading.h; path = src/threading.h; sourceTree = "<group>"; }; 4B67998C1099E7C50041064A /* unicode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = unicode.h; path = src/unicode.h; sourceTree = "<group>"; }; 4B6AF96C10A8D3E40003FB0A /* asprintf.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = asprintf.m; path = src/asprintf.m; sourceTree = "<group>"; }; 4B6AF96F10A8D40E0003FB0A /* iso_8859_15.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = iso_8859_15.m; path = src/iso_8859_15.m; sourceTree = "<group>"; }; 4B6AF97210A8D42E0003FB0A /* windows_1252.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = windows_1252.m; path = src/windows_1252.m; sourceTree = "<group>"; }; 4B6AF97310A8D4450003FB0A /* ObjFW.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjFW.h; path = src/ObjFW.h; sourceTree = "<group>"; }; 4BFBDD1610A0724800051AFB /* unicode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = unicode.m; path = src/unicode.m; sourceTree = "<group>"; }; /* End PBXFileReference section */ /* Begin PBXGroup section */ 08FB7794FE84155DC02AAC07 /* ObjFW */ = { isa = PBXGroup; children = ( | > | 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | 4B67998A1099E7C50041064A /* OFXMLParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFXMLParser.m; path = src/OFXMLParser.m; sourceTree = "<group>"; }; 4B67998B1099E7C50041064A /* threading.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = threading.h; path = src/threading.h; sourceTree = "<group>"; }; 4B67998C1099E7C50041064A /* unicode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = unicode.h; path = src/unicode.h; sourceTree = "<group>"; }; 4B6AF96C10A8D3E40003FB0A /* asprintf.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = asprintf.m; path = src/asprintf.m; sourceTree = "<group>"; }; 4B6AF96F10A8D40E0003FB0A /* iso_8859_15.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = iso_8859_15.m; path = src/iso_8859_15.m; sourceTree = "<group>"; }; 4B6AF97210A8D42E0003FB0A /* windows_1252.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = windows_1252.m; path = src/windows_1252.m; sourceTree = "<group>"; }; 4B6AF97310A8D4450003FB0A /* ObjFW.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjFW.h; path = src/ObjFW.h; sourceTree = "<group>"; }; 4B7F32B210EB90D500201BC1 /* OFFastEnumeration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFFastEnumeration.h; path = src/OFFastEnumeration.h; sourceTree = SOURCE_ROOT; }; 4BFBDD1610A0724800051AFB /* unicode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = unicode.m; path = src/unicode.m; sourceTree = "<group>"; }; /* End PBXFileReference section */ /* Begin PBXGroup section */ 08FB7794FE84155DC02AAC07 /* ObjFW */ = { isa = PBXGroup; children = ( |
︙ | ︙ | |||
143 144 145 146 147 148 149 150 151 152 153 154 155 156 | 4B6799611099E7C50041064A /* OFDataArray.m */, 4B6799621099E7C50041064A /* OFDictionary.h */, 4B6799631099E7C50041064A /* OFDictionary.m */, 4B0108C910EB8C9300631877 /* OFEnumerator.h */, 4B0108CA10EB8C9300631877 /* OFEnumerator.m */, 4B6799641099E7C50041064A /* OFExceptions.h */, 4B6799651099E7C50041064A /* OFExceptions.m */, 4B6799661099E7C50041064A /* OFFile.h */, 4B6799671099E7C50041064A /* OFFile.m */, 4B6799681099E7C50041064A /* OFHashes.h */, 4B6799691099E7C50041064A /* OFHashes.m */, 4B67996C1099E7C50041064A /* OFList.h */, 4B67996D1099E7C50041064A /* OFList.m */, 4B67996E1099E7C50041064A /* OFMacros.h */, | > | 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | 4B6799611099E7C50041064A /* OFDataArray.m */, 4B6799621099E7C50041064A /* OFDictionary.h */, 4B6799631099E7C50041064A /* OFDictionary.m */, 4B0108C910EB8C9300631877 /* OFEnumerator.h */, 4B0108CA10EB8C9300631877 /* OFEnumerator.m */, 4B6799641099E7C50041064A /* OFExceptions.h */, 4B6799651099E7C50041064A /* OFExceptions.m */, 4B7F32B210EB90D500201BC1 /* OFFastEnumeration.h */, 4B6799661099E7C50041064A /* OFFile.h */, 4B6799671099E7C50041064A /* OFFile.m */, 4B6799681099E7C50041064A /* OFHashes.h */, 4B6799691099E7C50041064A /* OFHashes.m */, 4B67996C1099E7C50041064A /* OFList.h */, 4B67996D1099E7C50041064A /* OFList.m */, 4B67996E1099E7C50041064A /* OFMacros.h */, |
︙ | ︙ |
Modified src/Makefile from [e7003197c7] to [56eedcf2bc].
︙ | ︙ | |||
27 28 29 30 31 32 33 34 35 36 37 38 39 40 | ${OFTHREAD_M} \ OFURLEncoding.m \ OFXMLElement.m \ OFXMLParser.m \ unicode.m INCLUDES := ${SRCS:.m=.h} \ OFMacros.h \ ObjFW.h \ asprintf.h \ objfw-defs.h \ ${THREADING_H} SRCS += ${OBJC_SYNC_M} \ | > | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | ${OFTHREAD_M} \ OFURLEncoding.m \ OFXMLElement.m \ OFXMLParser.m \ unicode.m INCLUDES := ${SRCS:.m=.h} \ OFFastEnumeration.h \ OFMacros.h \ ObjFW.h \ asprintf.h \ objfw-defs.h \ ${THREADING_H} SRCS += ${OBJC_SYNC_M} \ |
︙ | ︙ |
Modified src/OFEnumerator.h from [7d873ef675] to [63f8eed5f2].
1 2 3 4 5 6 7 8 9 10 11 12 | /* * 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" | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /* * 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" #import "OFDictionary.h" /** * An enumerator pair combines a key and its object in a single struct. */ typedef struct __of_enumerator_pair { /// The key |
︙ | ︙ |
Modified src/OFExceptions.h from [b3fc0e5ad0] to [cfd86aca94].
︙ | ︙ | |||
105 106 107 108 109 110 111 112 113 114 115 116 117 118 | /** * \return The size of the memoory that couldn't be allocated */ - (size_t)requestedSize; @end /** * An OFException indicating the given memory is not part of the object. */ @interface OFMemoryNotPartOfObjectException: OFException { void *pointer; } | > > > > > > | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | /** * \return The size of the memoory that couldn't be allocated */ - (size_t)requestedSize; @end /** * An OFException indicating that a mutation was detected while enumerating. */ @interface OFEnumerationMutationException: OFException {} @end /** * An OFException indicating the given memory is not part of the object. */ @interface OFMemoryNotPartOfObjectException: OFException { void *pointer; } |
︙ | ︙ |
Modified src/OFExceptions.m from [dd4a5ac59f] to [d63d79f2b9].
︙ | ︙ | |||
149 150 151 152 153 154 155 156 157 158 159 160 161 162 | } - (size_t)requestedSize { return req_size; } @end @implementation OFMemoryNotPartOfObjectException + newWithClass: (Class)class__ pointer: (void*)ptr { return [[self alloc] initWithClass: class__ pointer: ptr]; | > > > > > > > > > > > > > > | 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | } - (size_t)requestedSize { return req_size; } @end @implementation OFEnumerationMutationException - (OFString*)string { if (string != nil) return string; string = [[OFString alloc] initWithFormat: @"Object of class %s was mutated during enumeration!", [class_ className]]; return string; } @end @implementation OFMemoryNotPartOfObjectException + newWithClass: (Class)class__ pointer: (void*)ptr { return [[self alloc] initWithClass: class__ pointer: ptr]; |
︙ | ︙ |
Added src/OFFastEnumeration.h version [7da30d91d4].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | /* * 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 |
Modified src/OFObject.m from [ff3d52f1b1] to [529e251348].
︙ | ︙ | |||
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | static struct { Class isa; } alloc_failed_exception; #ifdef NEED_OBJC_SYNC_INIT extern BOOL objc_sync_init(); #endif @implementation OFObject + (void)load { #ifdef NEED_OBJC_SYNC_INIT if (!objc_sync_init()) { fputs("Runtime error: objc_sync_init() failed!\n", stderr); abort(); } #endif } + (void)initialize { } + alloc | > > > > > > > > > > | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | static struct { Class isa; } alloc_failed_exception; #ifdef NEED_OBJC_SYNC_INIT extern BOOL objc_sync_init(); #endif void enumeration_mutation_handler(id object) { @throw [OFEnumerationMutationException newWithClass: [object class]]; } @implementation OFObject + (void)load { #ifdef NEED_OBJC_SYNC_INIT if (!objc_sync_init()) { fputs("Runtime error: objc_sync_init() failed!\n", stderr); abort(); } #endif #ifdef OF_APPLE_RUNTIME objc_setEnumerationMutationHandler(enumeration_mutation_handler); #endif } + (void)initialize { } + alloc |
︙ | ︙ |