ObjFW  Check-in [c7bfcc9e92]

Overview
Comment:Add +[isSubclassOfClass:] to OFObject.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c7bfcc9e922e0013e8947054f831973d23235baf886aedd11f8187052b61bab7
User & Date: js on 2009-12-05 11:06:17
Other Links: manifest | tags
Context
2009-12-05
13:19
Get rid of float in OFMutableDictionary. check-in: 7d0a27a751 user: js tags: trunk
11:06
Add +[isSubclassOfClass:] to OFObject. check-in: c7bfcc9e92 user: js tags: trunk
10:50
Don't try to find another CC in acx_pthread.m4. check-in: 84dd396274 user: js tags: trunk
Changes

Modified src/OFExceptions.m from [528afc5c1f] to [0ba93b17bb].

420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
- initWithClass: (Class)class__
	   size: (size_t)size
{
	self = [super initWithClass: class__];

	req_size = size;

	/* FIXME: We need something that works for subclasses as well */
	if (class__ == [OFTCPSocket class])
		err = GET_SOCK_ERR;
	else
		err = GET_ERR;

	return self;
}








<
|







420
421
422
423
424
425
426

427
428
429
430
431
432
433
434
- initWithClass: (Class)class__
	   size: (size_t)size
{
	self = [super initWithClass: class__];

	req_size = size;


	if ([class__ isSubclassOfClass: [OFTCPSocket class]])
		err = GET_SOCK_ERR;
	else
		err = GET_ERR;

	return self;
}

Modified src/OFObject.h from [a51d330892] to [310003f809].

74
75
76
77
78
79
80







81
82
83
84
85
86
87
+ (Class)class;

/**
 * \return The name of the class as a C string
 */
+ (const char*)className;








/**
 * Checks whether instances of the class respond to a given selector.
 *
 * \param selector The selector which should be checked for respondance
 * \return A boolean whether instances of the class respond to the specified
 *	   selector
 */







>
>
>
>
>
>
>







74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
+ (Class)class;

/**
 * \return The name of the class as a C string
 */
+ (const char*)className;

/**
 * \param class_ The class which is checked for being a superclass
 * \return A boolean whether the class class is a subclass of the specified
 *	   class
 */
+ (BOOL)isSubclassOfClass: (Class)class_;

/**
 * Checks whether instances of the class respond to a given selector.
 *
 * \param selector The selector which should be checked for respondance
 * \return A boolean whether instances of the class respond to the specified
 *	   selector
 */

Modified src/OFObject.m from [6b6a2eea9a] to [6eaebd22dd].

97
98
99
100
101
102
103















104
105
106
107
108
109
110
{
#ifdef OF_APPLE_RUNTIME
	return class_getName(self);
#else
	return class_get_class_name(self);
#endif
}
















+ (BOOL)instancesRespondToSelector: (SEL)selector
{
#ifdef OF_APPLE_RUNTIME
	return class_respondsToSelector(self, selector);
#else
	return class_get_instance_method(self, selector) != METHOD_NULL;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
{
#ifdef OF_APPLE_RUNTIME
	return class_getName(self);
#else
	return class_get_class_name(self);
#endif
}

+ (BOOL)isSubclassOfClass: (Class)class
{
	Class iter;

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

	return NO;
}

+ (BOOL)instancesRespondToSelector: (SEL)selector
{
#ifdef OF_APPLE_RUNTIME
	return class_respondsToSelector(self, selector);
#else
	return class_get_instance_method(self, selector) != METHOD_NULL;