ObjFW  Check-in [67bb344ba6]

Overview
Comment:A few renames in OFObject, see details.

* +[conformsTo:] to +[conformsToProtocol:].
* -[isKindOf:] to -[isKindOfClass:].
* -[respondsTo:] to -[respondsToSelector:].
* -[conformsTo:] to -[conformsToProtocol:].
* -[methodFor:] to -[methodForSelector:].

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 67bb344ba6f4f09758454050cd1b30c881718ae80ceba2748a4ca315ef872237
User & Date: js on 2009-06-30 12:07:21
Other Links: manifest | tags
Context
2009-06-30
12:55
Add some missing documentation. check-in: 973e19f23c user: js tags: trunk
12:07
A few renames in OFObject, see details. check-in: 67bb344ba6 user: js tags: trunk
2009-06-29
17:42
Don't use OFMutableStrings in OFExceptions. check-in: 8d61f0f51d user: js tags: trunk
Changes

Modified src/OFArray.m from [37a3e697c0] to [88c47b37c1].

177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
}

- (BOOL)isEqual: (id)obj
{
	OFObject **objs, **objs2;
	size_t i, len, len2;

	if (![obj isKindOf: [OFArray class]])
		return NO;

	len = [array count];
	len2 = [obj count];

	if (len != len2)
		return NO;







|







177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
}

- (BOOL)isEqual: (id)obj
{
	OFObject **objs, **objs2;
	size_t i, len, len2;

	if (![obj isKindOfClass: [OFArray class]])
		return NO;

	len = [array count];
	len2 = [obj count];

	if (len != len2)
		return NO;

Modified src/OFAutoreleasePool.m from [bb48a7e604] to [f5bf7ad9a3].

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
static void
release_list(void *list)
{
	of_list_object_t *first, *iter;
	IMP release;

	if ((first = [(OFList*)list first]) != NULL)
		release = [first->object methodFor: @selector(release)];

	for (iter = first; iter != NULL; iter = iter->next)
		release(iter->object, @selector(release));

	[(OFList*)list release];
}








|







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
static void
release_list(void *list)
{
	of_list_object_t *first, *iter;
	IMP release;

	if ((first = [(OFList*)list first]) != NULL)
		release = [first->object methodForSelector: @selector(release)];

	for (iter = first; iter != NULL; iter = iter->next)
		release(iter->object, @selector(release));

	[(OFList*)list release];
}

Modified src/OFDataArray.m from [118e82fbe1] to [91a0ea19b6].

130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
	    fromCArray: data];

	return new;
}

- (BOOL)isEqual: (id)obj
{
	if (![obj isKindOf: [OFDataArray class]])
		return NO;
	if ([obj count] != count || [obj itemsize] != itemsize)
		return NO;
	if (memcmp([obj data], data, count * itemsize))
		return NO;

	return YES;
}

- (int)compare: (id)obj
{
	int ret;

	if (![obj isKindOf: [OFDataArray class]])
		@throw [OFInvalidArgumentException newWithClass: isa
						    andSelector: _cmd];
	if ([obj itemsize] != itemsize)
		@throw [OFInvalidArgumentException newWithClass: isa
						    andSelector: _cmd];

	if ([obj count] == count)







|













|







130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
	    fromCArray: data];

	return new;
}

- (BOOL)isEqual: (id)obj
{
	if (![obj isKindOfClass: [OFDataArray class]])
		return NO;
	if ([obj count] != count || [obj itemsize] != itemsize)
		return NO;
	if (memcmp([obj data], data, count * itemsize))
		return NO;

	return YES;
}

- (int)compare: (id)obj
{
	int ret;

	if (![obj isKindOfClass: [OFDataArray class]])
		@throw [OFInvalidArgumentException newWithClass: isa
						    andSelector: _cmd];
	if ([obj itemsize] != itemsize)
		@throw [OFInvalidArgumentException newWithClass: isa
						    andSelector: _cmd];

	if ([obj count] == count)

Modified src/OFList.m from [f1ec98a7a2] to [ca08344bc3].

204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
	return i;
}

- (BOOL)isEqual: (id)obj
{
	of_list_object_t *iter, *iter2;

	if (![obj isKindOf: [OFList class]])
		return NO;

	for (iter = first, iter2 = [obj first]; iter != NULL && iter2 != NULL;
	    iter = iter->next, iter2 = iter2->next)
		if (![iter->object isEqual: iter2->object])
			return NO;








|







204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
	return i;
}

- (BOOL)isEqual: (id)obj
{
	of_list_object_t *iter, *iter2;

	if (![obj isKindOfClass: [OFList class]])
		return NO;

	for (iter = first, iter2 = [obj first]; iter != NULL && iter2 != NULL;
	    iter = iter->next, iter2 = iter2->next)
		if (![iter->object isEqual: iter2->object])
			return NO;

Modified src/OFNumber.m from [886273d0e1] to [6fac52d2f8].

711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
- (long double)asLongDouble
{
	RETURN_AS(long double)
}

- (BOOL)isEqual: (id)obj
{
	if (![obj isKindOf: [OFNumber class]])
		return NO;

	switch (type) {
	case OF_NUMBER_CHAR:
	case OF_NUMBER_SHORT:
	case OF_NUMBER_INT:
	case OF_NUMBER_LONG:







|







711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
- (long double)asLongDouble
{
	RETURN_AS(long double)
}

- (BOOL)isEqual: (id)obj
{
	if (![obj isKindOfClass: [OFNumber class]])
		return NO;

	switch (type) {
	case OF_NUMBER_CHAR:
	case OF_NUMBER_SHORT:
	case OF_NUMBER_INT:
	case OF_NUMBER_LONG:

Modified src/OFObject.h from [2c81425fe1] to [f2a66cf4f4].

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
+ (const char*)name;

/**
 * \param protocol The protocol which should be checked for conformance
 *
 * \return A boolean whether the class conforms to the specified protocol
 */
+ (BOOL)conformsTo: (Protocol*)protocol;

/**
 * Replace a method implementation with another implementation.
 *
 * \param selector The selector of the method to replace
 * \param imp The new implementation for the method
 * \return The old implementation







|







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
+ (const char*)name;

/**
 * \param protocol The protocol which should be checked for conformance
 *
 * \return A boolean whether the class conforms to the specified protocol
 */
+ (BOOL)conformsToProtocol: (Protocol*)protocol;

/**
 * Replace a method implementation with another implementation.
 *
 * \param selector The selector of the method to replace
 * \param imp The new implementation for the method
 * \return The old implementation
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
- (const char*)name;

/**
 * \param class The class whose kind is checked
 *
 * \return A boolean whether the object is of the specified kind
 */
- (BOOL)isKindOf: (Class)class;

/**
 * \param selector The selector which should be checked for respondance
 *
 * \return A boolean whether the objects responds to the specified selector
 */
- (BOOL)respondsTo: (SEL)selector;

/**
 * \param protocol The protocol which should be checked for conformance
 *
 * \return A boolean whether the objects conforms to the specified protocol
 */
- (BOOL)conformsTo: (Protocol*)protocol;

/**
 * \param selector The selector for which the method should be returned
 *
 * \return The implementation for the specified selector
 */
- (IMP)methodFor: (SEL)selector;

/**
 * Compare two objects.
 * Classes containing data (like strings, arrays, lists etc.) should reimplement
 * this!
 *
 * \param obj The object which is tested for equality







|






|






|






|







103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
- (const char*)name;

/**
 * \param class The class whose kind is checked
 *
 * \return A boolean whether the object is of the specified kind
 */
- (BOOL)isKindOfClass: (Class)class;

/**
 * \param selector The selector which should be checked for respondance
 *
 * \return A boolean whether the objects responds to the specified selector
 */
- (BOOL)respondsToSelector: (SEL)selector;

/**
 * \param protocol The protocol which should be checked for conformance
 *
 * \return A boolean whether the objects conforms to the specified protocol
 */
- (BOOL)conformsToProtocol: (Protocol*)protocol;

/**
 * \param selector The selector for which the method should be returned
 *
 * \return The implementation for the specified selector
 */
- (IMP)methodForSelector: (SEL)selector;

/**
 * Compare two objects.
 * Classes containing data (like strings, arrays, lists etc.) should reimplement
 * this!
 *
 * \param obj The object which is tested for equality

Modified src/OFObject.m from [afcd5f1e07] to [434aadda8c].

93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#ifdef __objc_INCLUDE_GNU
	return class_get_class_name(self);
#else
	return class_getName(self);
#endif
}

+ (BOOL)conformsTo: (Protocol*)protocol
{
#ifdef __objc_INCLUDE_GNU
	Class c;
	struct objc_protocol_list *pl;
	size_t i;

	for (c = self; c != Nil; c = class_get_super_class(c))
		for (pl = c->protocols; pl != NULL; pl = pl->next)
			for (i = 0; i < pl->count; i++)
				if ([pl->list[i] conformsTo: protocol])
					return YES;

	return NO;
#else
	Class c;

	for (c = self; c != Nil; c = class_getSuperclass(c))







|









|







93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#ifdef __objc_INCLUDE_GNU
	return class_get_class_name(self);
#else
	return class_getName(self);
#endif
}

+ (BOOL)conformsToProtocol: (Protocol*)protocol
{
#ifdef __objc_INCLUDE_GNU
	Class c;
	struct objc_protocol_list *pl;
	size_t i;

	for (c = self; c != Nil; c = class_get_super_class(c))
		for (pl = c->protocols; pl != NULL; pl = pl->next)
			for (i = 0; i < pl->count; i++)
				if ([pl->list[i] conformsToProtocol: protocol])
					return YES;

	return NO;
#else
	Class c;

	for (c = self; c != Nil; c = class_getSuperclass(c))
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
#ifdef __objc_INCLUDE_GNU
	return object_get_class_name(self);
#else
	return class_getName(isa);
#endif
}

- (BOOL)isKindOf: (Class)class
{
	Class iter;

#ifdef __objc_INCLUDE_GNU
	for (iter = isa; iter != Nil; iter = class_get_super_class(iter))
#else
	for (iter = isa; iter != Nil; iter = class_getSuperclass(iter))
#endif
		if (iter == class)
			return YES;

	return NO;
}

- (BOOL)respondsTo: (SEL)selector
{
#ifdef __objc_INCLUDE_GNU
	if (object_is_instance(self))
		return class_get_instance_method(isa, selector) != METHOD_NULL;
	else
		return class_get_class_method(isa, selector) != METHOD_NULL;
#else
	return class_respondsToSelector(isa, selector);
#endif
}

- (BOOL)conformsTo: (Protocol*)protocol
{
	return [isa conformsTo: protocol];
}

- (IMP)methodFor: (SEL)selector
{
#ifdef __objc_INCLUDE_GNU
	if (object_is_instance(self))
		return method_get_imp(class_get_instance_method(isa, selector));
	else
		return method_get_imp(class_get_class_method(isa, selector));
#else







|














|











|

|


|







187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
#ifdef __objc_INCLUDE_GNU
	return object_get_class_name(self);
#else
	return class_getName(isa);
#endif
}

- (BOOL)isKindOfClass: (Class)class
{
	Class iter;

#ifdef __objc_INCLUDE_GNU
	for (iter = isa; iter != Nil; iter = class_get_super_class(iter))
#else
	for (iter = isa; iter != Nil; iter = class_getSuperclass(iter))
#endif
		if (iter == class)
			return YES;

	return NO;
}

- (BOOL)respondsToSelector: (SEL)selector
{
#ifdef __objc_INCLUDE_GNU
	if (object_is_instance(self))
		return class_get_instance_method(isa, selector) != METHOD_NULL;
	else
		return class_get_class_method(isa, selector) != METHOD_NULL;
#else
	return class_respondsToSelector(isa, selector);
#endif
}

- (BOOL)conformsToProtocol: (Protocol*)protocol
{
	return [isa conformsToProtocol: protocol];
}

- (IMP)methodForSelector: (SEL)selector
{
#ifdef __objc_INCLUDE_GNU
	if (object_is_instance(self))
		return method_get_imp(class_get_instance_method(isa, selector));
	else
		return method_get_imp(class_get_class_method(isa, selector));
#else

Modified src/OFString.m from [1b2b877044] to [98df1c138a].

277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
- (id)mutableCopy
{
	return [[OFMutableString alloc] initWithString: self];
}

- (BOOL)isEqual: (id)obj
{
	if (![obj isKindOf: [OFString class]])
		return NO;
	if (strcmp(string, [obj cString]))
		return NO;

	return YES;
}

- (int)compare: (id)obj
{
	if (![obj isKindOf: [OFString class]])
		@throw [OFInvalidArgumentException newWithClass: isa
						    andSelector: _cmd];

	return strcmp(string, [obj cString]);
}

- (uint32_t)hash







|









|







277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
- (id)mutableCopy
{
	return [[OFMutableString alloc] initWithString: self];
}

- (BOOL)isEqual: (id)obj
{
	if (![obj isKindOfClass: [OFString class]])
		return NO;
	if (strcmp(string, [obj cString]))
		return NO;

	return YES;
}

- (int)compare: (id)obj
{
	if (![obj isKindOfClass: [OFString class]])
		@throw [OFInvalidArgumentException newWithClass: isa
						    andSelector: _cmd];

	return strcmp(string, [obj cString]);
}

- (uint32_t)hash

Modified src/OFXMLElement.m from [8ca104aaaa] to [d97af29834].

112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
			tmp = [stringval stringByXMLEscaping];
		else if (children != nil) {
			OFXMLElement **data = [children data];
			size_t count = [children count];
			IMP append;

			tmp = [OFMutableString string];
			append = [tmp methodFor: @selector(
			    appendCStringWithoutUTF8Checking:)];

			for (j = 0; j < count; j++)
				append(tmp, @selector(
				    appendCStringWithoutUTF8Checking:),
				    [[data[j] string] cString]);
		}








|
|







112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
			tmp = [stringval stringByXMLEscaping];
		else if (children != nil) {
			OFXMLElement **data = [children data];
			size_t count = [children count];
			IMP append;

			tmp = [OFMutableString string];
			append = [tmp methodForSelector:
			    @selector(appendCStringWithoutUTF8Checking:)];

			for (j = 0; j < count; j++)
				append(tmp, @selector(
				    appendCStringWithoutUTF8Checking:),
				    [[data[j] string] cString]);
		}