ObjFW  Check-in [2f85ceeed7]

Overview
Comment:Add -[drain] to OFAutoreleasePool.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2f85ceeed76acefca8ad95344afcf12e4c7f3550061bec6a1763b66d3718f05c
User & Date: js on 2009-11-22 16:33:04
Other Links: manifest | tags
Context
2009-11-22
16:57
Make it very clear that OFExceptions don't use autorelease pools. check-in: 0fbbfb7158 user: js tags: trunk
16:33
Add -[drain] to OFAutoreleasePool. check-in: 2f85ceeed7 user: js tags: trunk
15:44
Add -[removeObjectAtIndex] and -[removeNObjects:atIndex:] to OFArray. check-in: 0b6fc2523a user: js tags: trunk
Changes

Modified src/OFAutoreleasePool.h from [19776ae923] to [2aeb457e29].

39
40
41
42
43
44
45





46
47













48
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66







+
+
+
+
+


+
+
+
+
+
+
+
+
+
+
+
+
+

 *
 * \param obj The object to add to the autorelease pool
 */
- addObject: (OFObject*)obj;

/**
 * Releases all objects in the autorelease pool.
 *
 * If a garbage collector is added in the future, it will tell the GC that now
 * is a good time to clean up, as this is often used after a lot of objects
 * have been added to the pool that should be released before the next iteration
 * of a loop, which adds objects again. Thus, it is usually a clean up call.
 */
- releaseObjects;

/**
 * Releases all objects in the autorelease pool and deallocates the pool.
 */
- (void)release;

/**
 * Calling drain is equivalent to calling release.
 *
 * If a garbage collector is added in the future, it will tell the GC that now
 * is a good time to clean up.
 */
- (void)drain;
@end

Modified src/OFAutoreleasePool.m from [8c6dcd3941] to [3ea4e1ab45].

147
148
149
150
151
152
153










154
155
156
157
158
159
160
161
162
163
164
165
166
147
148
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







+
+
+
+
+
+
+
+
+
+













		return self;

	[objects release];
	objects = nil;

	return self;
}

- (void)release
{
	[self dealloc];
}

- (void)drain
{
	[self dealloc];
}

- retain
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- autorelease
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}
@end

Modified tests/OFArray.m from [c96ae57ccf] to [e9a290fd61].

72
73
74
75
76
77
78
79

80
72
73
74
75
76
77
78

79
80







-
+


	EXPECT_EXCEPTION(@"Detect out of range in -[objectAtIndex:]",
	    OFOutOfRangeException, [a[0] objectAtIndex: [a[0] count]])

	EXPECT_EXCEPTION(@"Detect out of range in -[removeNItems:]",
	    OFOutOfRangeException, [a[0] removeNObjects: [a[0] count] + 1])

	[pool release];
	[pool drain];
}

Modified tests/OFDataArray.m from [adb8e9f54e] to [8dcec7e9e3].

113
114
115
116
117
118
119
120

121
113
114
115
116
117
118
119

120
121







-
+


	module = @"OFDataArray";
	do_tests([OFDataArray class]);

	module = @"OFBigDataArray";
	do_tests([OFBigDataArray class]);

	[pool release];
	[pool drain];
}

Modified tests/OFDictionary.m from [1fa12ca59b] to [aef130b0e8].

108
109
110
111
112
113
114
115

116
108
109
110
111
112
113
114

115
116







-
+

	TEST(@"-[isEqual:]", ![dict isEqual: dict2] &&
	    [dict removeObjectForKey: @"key3"] &&
	    ![dict isEqual: dict2] &&
	    [dict setObject: values[0]
		     forKey: keys[0]] &&
	    [dict isEqual: dict2])

	[pool release];
	[pool drain];
}

Modified tests/OFHashes.m from [9ce9d2717f] to [0665970b7b].

60
61
62
63
64
65
66
67

68
60
61
62
63
64
65
66

67
68







-
+

	EXPECT_EXCEPTION(@"Detect invalid call of -[updateWithBuffer] #1",
	    OFHashAlreadyCalculatedException, [md5 updateWithBuffer: ""
							     ofSize: 1])
	EXPECT_EXCEPTION(@"Detect invalid call of -[updateWithBuffer] #2",
	    OFHashAlreadyCalculatedException, [sha1 updateWithBuffer: ""
							      ofSize: 1])

	[pool release];
	[pool drain];
}

Modified tests/OFList.m from [fe55bb3699] to [fd7f869c09].

64
65
66
67
68
69
70
71

72
64
65
66
67
68
69
70

71
72







-
+

	TEST(@"-[copy]", (list = [[list copy] autorelease]) &&
	    [[list first]->object isEqual: strings[0]] &&
	    [[list first]->next->object isEqual: strings[1]] &&
	    [[list last]->object isEqual: strings[2]])

	TEST(@"-[isEqual:]", [list isEqual: [[list copy] autorelease]])

	[pool release];
	[pool drain];
}

Modified tests/OFObject.m from [252192396d] to [e5fa4b99d7].

59
60
61
62
63
64
65
66

67
59
60
61
62
63
64
65

66
67







-
+

			    toSize: 1024]) != NULL)
	[obj freeMemory: p];

	EXPECT_EXCEPTION(@"Detect resizing of memory not allocated by object",
	    OFMemoryNotPartOfObjectException, [obj resizeMemory: (void*)1
							 toSize: 1024])

	[pool release];
	[pool drain];
}

Modified tests/OFPlugin.m from [29d7d69c71] to [279405b90d].

29
30
31
32
33
34
35
36

37
29
30
31
32
33
34
35

36
37







-
+

	TestPlugin *plugin;

	TEST(@"+[pluginFromFile:]",
	    (plugin = [OFPlugin pluginFromFile: @"plugin/TestPlugin"]))

	TEST(@"TestPlugin's -[test:]", [plugin test: 1234] == 2468)

	[pool release];
	[pool drain];
}

Modified tests/OFString.m from [ade3ad2d15] to [826552dfff].

335
336
337
338
339
340
341
342

343
335
336
337
338
339
340
341

342
343







-
+

	    @"#6", OFInvalidEncodingException, [@"&#xg;" stringByXMLUnescaping])

	TEST(@"-[stringByXMLUnescapingWithHandler:]",
	    (h = [[[EntityHandler alloc] init] autorelease]) &&
	    (s[0] = [@"x&foo;y" stringByXMLUnescapingWithHandler: h]) &&
	    [s[0] isEqual: @"xbary"])

	[pool release];
	[pool drain];
}

Modified tests/OFTCPSocket.m from [1ff40bde1e] to [90a6cf5f0f].

59
60
61
62
63
64
65
66

67
59
60
61
62
63
64
65

66
67







-
+


	TEST(@"-[writeString:]", [client writeString: @"Hello!"])

	TEST(@"-[readNBytes:intoBuffer:]", [accepted readNBytes: 6
						     intoBuffer: buf] &&
	    !memcmp(buf, "Hello!", 6))

	[pool release];
	[pool drain];
}

Modified tests/OFThread.m from [df11548239] to [c32c5ecaa2].

49
50
51
52
53
54
55
56

57
49
50
51
52
53
54
55

56
57







-
+


	TEST(@"+[setObject:forTLSKey:]", [OFThread setObject: @"foo"
						   forTLSKey: key])

	TEST(@"+[objectForTLSKey:]",
	    [[OFThread objectForTLSKey: key] isEqual: @"foo"])

	[pool release];
	[pool drain];
}

Modified tests/OFXMLElement.m from [35425fa806] to [b8335657fb].

43
44
45
46
47
48
49
50

51
43
44
45
46
47
48
49

50
51







-
+

			      stringValue: @"b&ar"] &&
	    [[elem[1] string] isEqual: @"<foo foo='b&amp;ar'>b&amp;ar</foo>"])

	TEST(@"-[addChild:]",
	    [elem[0] addChild: [OFXMLElement elementWithName: @"bar"]] &&
	    [[elem[0] string] isEqual: @"<foo foo='b&amp;ar'><bar/></foo>"])

	[pool release];
	[pool drain];
}

Modified tests/OFXMLParser.m from [55a0425a5e] to [0c5c8dbd56].

182
183
184
185
186
187
188
189

190
182
183
184
185
186
187
188

189
190







-
+

		else
			[parser parseBuffer: str + j
				   withSize: 2];
	}

	TEST(@"Checking if everything was parsed", i == 11)

	[pool release];
	[pool drain];
}