ObjFW  Check-in [c70922ee1c]

Overview
Comment:Update the dtable so we can replace methods at runtime.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c70922ee1c0efd820ba9748ae25c01448a94bec8d58a2190a5ec01a38d975cb0
User & Date: js on 2009-06-09 23:28:44
Other Links: manifest | tags
Context
2009-06-09
23:33
Return plugins autoreleased in OFPlugin. check-in: 5df8f61fe4 user: js tags: trunk
23:28
Update the dtable so we can replace methods at runtime. check-in: c70922ee1c user: js tags: trunk
21:01
Fix a forgotten -[cString] in OFExceptions. check-in: d2b906b7f1 user: js tags: trunk
Changes

Modified src/OFObject.m from [0fa5062289] to [da7bffba83].

19
20
21
22
23
24
25
26



27
28
29
30
31
32
33
19
20
21
22
23
24
25

26
27
28
29
30
31
32
33
34
35







-
+
+
+








#import "OFObject.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "OFMacros.h"

#import <objc/objc-api.h>
#ifndef __objc_INCLUDE_GNU
#ifdef __objc_INCLUDE_GNU
#import <objc/sarray.h>
#else
#import <objc/runtime.h>
#endif

struct pre_ivar {
	void   **memchunks;
	size_t memchunks_size;
	size_t retain_count;
135
136
137
138
139
140
141







142
143
144
145
146
147
148
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157







+
+
+
+
+
+
+







	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);
	IMP imp = class_getMethodImplementation(class, selector);

	if (method == NULL || imp == NULL)
		@throw [OFInvalidArgumentException newWithClass: self