ObjFW  Diff

Differences From Artifact [da7bffba83]:

To Artifact [afcd5f1e07]:


118
119
120
121
122
123
124

125

126
127
128
129
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
159
160

161















162
163
164
165
166
167
168
118
119
120
121
122
123
124
125

126

127
128
129

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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179







+
-
+
-



-
+





-
+
-
-
-













-
+
-

-
+



-
+

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







		if (class_conformsToProtocol(c, protocol))
			return YES;

	return NO;
#endif
}

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

	if (method == NULL)
		@throw [OFInvalidArgumentException newWithClass: self
						    andSelector: _cmd];

	oldimp = method_get_imp(method);
	if ((oldimp = method_get_imp(method)) == (IMP)0 || newimp == (IMP)0)
	newimp = method_get_imp(class_get_instance_method(class, selector));

	if (oldimp == (IMP)0 || newimp == (IMP)0)
		@throw [OFInvalidArgumentException newWithClass: self
						    andSelector: _cmd];

	method->method_imp = newimp;

	/* Update the dtable if necessary */
	if (sarray_get_safe(((Class)self)->dtable,
	    (sidx)method->method_name->sel_id))
		sarray_at_put_safe(((Class)self)->dtable,
		    (sidx)method->method_name->sel_id, method->method_imp);

	return oldimp;
#else
	Method method = class_getInstanceMethod(self, selector);
	Method method;
	IMP imp = class_getMethodImplementation(class, selector);

	if (method == NULL || imp == NULL)
	if ((method = class_getInstanceMethod(self, selector)) == NULL)
		@throw [OFInvalidArgumentException newWithClass: self
						    andSelector: _cmd];

	return method_setImplementation(method, imp);
	return method_setImplementation(method, newimp);
#endif
}

+  (IMP)replaceMethod: (SEL)selector
  withMethodFromClass: (Class)class;
{
	IMP newimp;

#ifdef __objc_INCLUDE_GNU
	newimp = method_get_imp(class_get_instance_method(class, selector));
#else
	newimp = class_getMethodImplementation(class, selector);
#endif

	return [self setImplementation: newimp
			     forMethod: selector];
}

- init
{
	return self;
}