ObjFW  Check-in [0707c56762]

Overview
Comment:Add +[instanceMethodForSelector:] to OFObject.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 0707c567629acbda2aa9da22c87d7fe9aa6c12c2ba72f3fd296e5ee7a938cb46
User & Date: js on 2009-06-30 14:22:04
Other Links: manifest | tags
Context
2009-06-30
20:12
Implement -[substringFromIndex:toIndex:] for OFString. check-in: cfb401ed3a user: js tags: trunk
14:22
Add +[instanceMethodForSelector:] to OFObject. check-in: 0707c56762 user: js tags: trunk
14:15
Add +[instancesRespondToSelector:] to OFObject. check-in: 5f47e81a9e user: js tags: trunk
Changes

Modified src/OFObject.h from [2922396d0b] to [7edb49c81c].

64
65
66
67
68
69
70







71
72
73
74
75
76
77
/**
 * \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
 */







>
>
>
>
>
>
>







64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
 * \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;

/**
 * \param selector The selector for which the method should be returned
 *
 * \return The implementation of the instance method for the specified selector
 */
+ (IMP)instanceMethodForSelector: (SEL)selector;

/**
 * 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
 */

Modified src/OFObject.m from [b8dec711ff] to [cb5875a194].

126
127
128
129
130
131
132









133
134
135
136
137
138
139
	for (c = self; c != Nil; c = class_getSuperclass(c))
		if (class_conformsToProtocol(c, protocol))
			return YES;

	return NO;
#endif
}










+ (IMP)setImplementation: (IMP)newimp
	       forMethod: (SEL)selector
{
#ifdef __objc_INCLUDE_GNU
	Method_t method = class_get_instance_method(self, selector);
	IMP oldimp;







>
>
>
>
>
>
>
>
>







126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
	for (c = self; c != Nil; c = class_getSuperclass(c))
		if (class_conformsToProtocol(c, protocol))
			return YES;

	return NO;
#endif
}

+ (IMP)instanceMethodForSelector: (SEL)selector
{
#ifdef __objc_INCLUDE_GNU
	return method_get_imp(class_get_instance_method(self, selector));
#else
	return class_getMethodImplementation(self, selector);
#endif
}

+ (IMP)setImplementation: (IMP)newimp
	       forMethod: (SEL)selector
{
#ifdef __objc_INCLUDE_GNU
	Method_t method = class_get_instance_method(self, selector);
	IMP oldimp;