Overview
Comment: | Add support for the new GNU runtime.
Currently, the properties test for nonatomic fails. This is a bug in |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
6f4eb004a3185dbf1fba6069be85d762 |
User & Date: | js on 2010-12-18 23:39:20 |
Other Links: | manifest | tags |
Context
2010-12-20
| ||
15:12 | Documentation improvements. check-in: bf836060fb user: js tags: trunk | |
2010-12-18
| ||
23:39 | Add support for the new GNU runtime. check-in: 6f4eb004a3 user: js tags: trunk | |
2010-12-16
| ||
18:22 | Allow -Wl,* in objfw-compile. check-in: 12e47e3771 user: js tags: trunk | |
Changes
Modified configure.ac from [206a8f73e3] to [6b24bd807a].
︙ | ︙ | |||
8 9 10 11 12 13 14 | AC_PROG_OBJCPP AC_PROG_LN_S AC_PROG_INSTALL AC_PROG_EGREP CPP="$OBJCPP" CPPFLAGS="$CPPFLAGS $OBJCPPFLAGS" | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | AC_PROG_OBJCPP AC_PROG_LN_S AC_PROG_INSTALL AC_PROG_EGREP CPP="$OBJCPP" CPPFLAGS="$CPPFLAGS $OBJCPPFLAGS" OBJCFLAGS="$OBJCFLAGS -Wall -fexceptions -fobjc-exceptions" OBJCFLAGS="$OBJCFLAGS -fconstant-string-class=OFConstantString" AX_CHECK_COMPILER_FLAGS(-pipe, [OBJCFLAGS="$OBJCFLAGS -pipe"]) AX_CHECK_COMPILER_FLAGS(-fno-common, [OBJCFLAGS="$OBJCFLAGS -fno-common"]) AX_CHECK_COMPILER_FLAGS(-fno-constant-cfstrings, [ NO_CONST_CFSTRINGS="-fno-constant-cfstrings" OBJCFLAGS="$OBJCFLAGS -fno-constant-cfstrings" |
︙ | ︙ | |||
83 84 85 86 87 88 89 | ]) AC_CHECK_HEADERS([objfw-rt.h objc/objc.h]) test x"$ac_cv_header_objfw_rt_h" = x"yes" && objc_runtime="ObjFW-RT" AS_IF([test x"$ac_cv_header_objc_objc_h" = x"yes"], [ | < | | < > > > > > > > > > > | > | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | ]) AC_CHECK_HEADERS([objfw-rt.h objc/objc.h]) test x"$ac_cv_header_objfw_rt_h" = x"yes" && objc_runtime="ObjFW-RT" AS_IF([test x"$ac_cv_header_objc_objc_h" = x"yes"], [ AC_EGREP_CPP(yes, [ #import <objc/objc.h> #ifdef __GNU_LIBOBJC__ yes #endif ], [ test x"$objc_runtime" = "x" && objc_runtime="GNU" ], [ dnl TODO: This is ugly. Let's think of a better check. AC_EGREP_CPP(yes, [ #import <objc/objc.h> #ifdef __objc_INCLUDE_GNU yes #endif ], [ test x"$objc_runtime" = "x" && objc_runtime="old GNU" ], [ objc_runtime="Apple" ]) ]) ]) AC_MSG_CHECKING(which Objective C runtime we use) case $objc_runtime in ObjFW-RT) AC_DEFINE(OF_OBJFW_RUNTIME, 1, |
︙ | ︙ | |||
115 116 117 118 119 120 121 122 123 124 125 126 127 128 | LIBS="$LIBS -lobjc" ;; GNU) AC_DEFINE(OF_GNU_RUNTIME, 1, [Whether we use the GNU ObjC runtime]) LIBS="$LIBS -lobjc" ;; *) AC_MSG_RESULT(none) AC_MSG_ERROR(No ObjC runtime found! Please install ObjFW-RT!) ;; esac AC_MSG_RESULT($objc_runtime) | > > > > > | 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | LIBS="$LIBS -lobjc" ;; GNU) AC_DEFINE(OF_GNU_RUNTIME, 1, [Whether we use the GNU ObjC runtime]) LIBS="$LIBS -lobjc" ;; "old GNU") AC_DEFINE(OF_OLD_GNU_RUNTIME, 1, [Whether we use the old GNU ObjC runtime]) LIBS="$LIBS -lobjc" ;; *) AC_MSG_RESULT(none) AC_MSG_ERROR(No ObjC runtime found! Please install ObjFW-RT!) ;; esac AC_MSG_RESULT($objc_runtime) |
︙ | ︙ |
Modified src/OFBlock.m from [d6602a5fe7] to [49b08c57ae].
︙ | ︙ | |||
24 25 26 27 28 29 30 | #import "atomic.h" @protocol RetainRelease - retain; - (void)release; @end | | > | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #import "atomic.h" @protocol RetainRelease - retain; - (void)release; @end #if defined(OF_OBJFW_RUNTIME) || defined(OF_GNU_RUNTIME) || \ defined(OF_OLD_GNU_RUNTIME) struct objc_abi_class { struct objc_abi_metaclass *metaclass; const char *superclass, *name; unsigned long version, info, instance_size; void *ivars, *methodlist, *dtable, *subclass_list, *sibling_class; void *protocols, *gc_object_type; long abi_version; |
︙ | ︙ |
Modified src/OFExceptions.m from [e89fd4d506] to [250b6ae1fd].
︙ | ︙ | |||
12 13 14 15 16 17 18 | #include "config.h" #define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <string.h> | | < | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include "config.h" #define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <string.h> #if defined(OF_APPLE_RUNTIME) || defined(OF_GNU_RUNTIME) # import <objc/runtime.h> #endif #ifdef OF_OLD_GNU_RUNTIME # import <objc/objc-api.h> # define sel_getName(x) sel_get_name(x) #endif #import "OFExceptions.h" #import "OFString.h" #import "OFTCPSocket.h" |
︙ | ︙ |
Modified src/OFObject.m from [5f364917f3] to [72f139fc0b].
︙ | ︙ | |||
21 22 23 24 25 26 27 | #import "OFObject.h" #import "OFAutoreleasePool.h" #import "OFExceptions.h" #import "macros.h" #if defined(OF_OBJFW_RUNTIME) # import <objfw-rt.h> | | | | < | | | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | #import "OFObject.h" #import "OFAutoreleasePool.h" #import "OFExceptions.h" #import "macros.h" #if defined(OF_OBJFW_RUNTIME) # import <objfw-rt.h> #elif defined(OF_OLD_GNU_RUNTIME) # import <objc/objc-api.h> # import <objc/sarray.h> #else # import <objc/runtime.h> #endif #ifdef _WIN32 # include <windows.h> #endif #import "OFString.h" #ifdef OF_ATOMIC_OPS # import "atomic.h" #else # import "threading.h" #endif /* A few macros to reduce #ifdefs */ #ifdef OF_OLD_GNU_RUNTIME # define class_getInstanceSize class_get_instance_size # define class_getName class_get_class_name # define class_getSuperclass class_get_super_class #endif struct pre_ivar { void **memchunks; |
︙ | ︙ | |||
108 109 110 111 112 113 114 | if (!objc_properties_init()) { fputs("Runtime error: objc_properties_init() failed!\n", stderr); abort(); } #endif | | | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | if (!objc_properties_init()) { fputs("Runtime error: objc_properties_init() failed!\n", stderr); abort(); } #endif #if defined(OF_APPLE_RUNTIME) || defined(OF_GNU_RUNTIME) objc_setEnumerationMutationHandler(enumeration_mutation_handler); #endif #ifndef _WIN32 if ((of_pagesize = sysconf(_SC_PAGESIZE)) < 1) of_pagesize = 4096; #else |
︙ | ︙ | |||
182 183 184 185 186 187 188 | + (Class)superclass { return class_getSuperclass(self); } + (BOOL)instancesRespondToSelector: (SEL)selector { | | | | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | + (Class)superclass { return class_getSuperclass(self); } + (BOOL)instancesRespondToSelector: (SEL)selector { #ifdef OF_OLD_GNU_RUNTIME return class_get_instance_method(self, selector) != METHOD_NULL; #else return class_respondsToSelector(self, selector); #endif } + (BOOL)conformsToProtocol: (Protocol*)protocol { #ifdef OF_OLD_GNU_RUNTIME 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++) |
︙ | ︙ | |||
218 219 220 221 222 223 224 | #endif } + (IMP)instanceMethodForSelector: (SEL)selector { #if defined(OF_OBJFW_RUNTIME) return objc_get_instance_method(self, selector); | | | | | < | < | | > | > | 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | #endif } + (IMP)instanceMethodForSelector: (SEL)selector { #if defined(OF_OBJFW_RUNTIME) return objc_get_instance_method(self, selector); #elif defined(OF_OLD_GNU_RUNTIME) return method_get_imp(class_get_instance_method(self, selector)); #else return class_getMethodImplementation(self, selector); #endif } + (const char*)typeEncodingForInstanceSelector: (SEL)selector { #if defined(OF_OBJFW_RUNTIME) const char *ret; if ((ret = objc_get_type_encoding(self, selector)) == NULL) @throw [OFNotImplementedException newWithClass: self selector: selector]; return ret; #elif defined(OF_OLD_GNU_RUNTIME) Method_t m; if ((m = class_get_instance_method(self, selector)) == NULL || m->method_types == NULL) @throw [OFNotImplementedException newWithClass: self selector: selector]; return m->method_types; #else Method m; const char *ret; if ((m = class_getInstanceMethod(self, selector)) == NULL || (ret = method_getTypeEncoding(m)) == NULL) @throw [OFNotImplementedException newWithClass: self selector: selector]; return ret; #endif } |
︙ | ︙ | |||
271 272 273 274 275 276 277 | { #if defined(OF_OBJFW_RUNTIME) if (newimp == (IMP)0 || !class_respondsToSelector(self->isa, selector)) @throw [OFInvalidArgumentException newWithClass: self selector: _cmd]; return objc_replace_class_method(self, selector, newimp); | | < < < < < < < < < < | 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | { #if defined(OF_OBJFW_RUNTIME) if (newimp == (IMP)0 || !class_respondsToSelector(self->isa, selector)) @throw [OFInvalidArgumentException newWithClass: self selector: _cmd]; return objc_replace_class_method(self, selector, newimp); #elif defined(OF_OLD_GNU_RUNTIME) Method_t method; IMP oldimp; /* The class method is the instance method of the meta class */ if ((method = class_get_instance_method(self->class_pointer, selector)) == NULL) @throw [OFInvalidArgumentException newWithClass: self |
︙ | ︙ | |||
304 305 306 307 308 309 310 311 312 313 314 315 316 317 | /* Update the dtable if necessary */ if (sarray_get_safe(((Class)self->class_pointer)->dtable, (sidx)method->method_name->sel_id)) sarray_at_put_safe(((Class)self->class_pointer)->dtable, (sidx)method->method_name->sel_id, method->method_imp); return oldimp; #endif } + (IMP)replaceClassMethod: (SEL)selector withMethodFromClass: (Class)class; { IMP newimp; | > > > > > > > > > > > > > > | 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | /* Update the dtable if necessary */ if (sarray_get_safe(((Class)self->class_pointer)->dtable, (sidx)method->method_name->sel_id)) sarray_at_put_safe(((Class)self->class_pointer)->dtable, (sidx)method->method_name->sel_id, method->method_imp); return oldimp; #else Method method; if (newimp == (IMP)0 || (method = class_getClassMethod(self, selector)) == NULL) @throw [OFInvalidArgumentException newWithClass: self selector: _cmd]; /* * Cast needed because it's isa in the Apple runtime, but class_pointer * in the GNU runtime. */ return class_replaceMethod(((OFObject*)self)->isa, selector, newimp, method_getTypeEncoding(method)); #endif } + (IMP)replaceClassMethod: (SEL)selector withMethodFromClass: (Class)class; { IMP newimp; |
︙ | ︙ | |||
331 332 333 334 335 336 337 | { #if defined(OF_OBJFW_RUNTIME) if (newimp == (IMP)0 || !class_respondsToSelector(self, selector)) @throw [OFInvalidArgumentException newWithClass: self selector: _cmd]; return objc_replace_instance_method(self, selector, newimp); | | < < < < < < < < < < > > > > > > > > > > | 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | { #if defined(OF_OBJFW_RUNTIME) if (newimp == (IMP)0 || !class_respondsToSelector(self, selector)) @throw [OFInvalidArgumentException newWithClass: self selector: _cmd]; return objc_replace_instance_method(self, selector, newimp); #elif defined(OF_OLD_GNU_RUNTIME) Method_t method = class_get_instance_method(self, selector); IMP oldimp; if (method == NULL) @throw [OFInvalidArgumentException newWithClass: self selector: _cmd]; if ((oldimp = method_get_imp(method)) == (IMP)0 || newimp == (IMP)0) @throw [OFInvalidArgumentException newWithClass: self selector: _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; if (newimp == (IMP)0 || (method = class_getInstanceMethod(self, selector)) == NULL) @throw [OFInvalidArgumentException newWithClass: self selector: _cmd]; return class_replaceMethod(self, selector, newimp, method_getTypeEncoding(method)); #endif } + (IMP)replaceInstanceMethod: (SEL)selector withMethodFromClass: (Class)class; { IMP newimp; |
︙ | ︙ | |||
408 409 410 411 412 413 414 | return YES; return NO; } - (BOOL)respondsToSelector: (SEL)selector { | | | | | | < | < | | > | > | 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 | return YES; return NO; } - (BOOL)respondsToSelector: (SEL)selector { #ifdef OF_OLD_GNU_RUNTIME 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 { #if defined(OF_OBJFW_RUNTIME) || defined(OF_OLD_GNU_RUNTIME) return objc_msg_lookup(self, selector); #else return class_getMethodImplementation(isa, selector); #endif } - (const char*)typeEncodingForSelector: (SEL)selector { #if defined(OF_OBJFW_RUNTIME) const char *ret; if ((ret = objc_get_type_encoding(isa, selector)) == NULL) @throw [OFNotImplementedException newWithClass: isa selector: selector]; return ret; #elif defined(OF_OLD_GNU_RUNTIME) Method_t m; if ((m = class_get_instance_method(isa, selector)) == NULL || m->method_types == NULL) @throw [OFNotImplementedException newWithClass: isa selector: selector]; return m->method_types; #else Method m; const char *ret; if ((m = class_getInstanceMethod(isa, selector)) == NULL || (ret = method_getTypeEncoding(m)) == NULL) @throw [OFNotImplementedException newWithClass: isa selector: selector]; return ret; #endif } |
︙ | ︙ |
Modified src/objfw-defs.h.in from [24da91ee6d] to [5535a2e37e].
︙ | ︙ | |||
12 13 14 15 16 17 18 19 20 21 | #undef OF_HAVE_POLL #undef OF_HAVE_PROPERTIES #undef OF_HAVE_PTHREADS #undef OF_HAVE_PTHREAD_SPINLOCKS #undef OF_HAVE_SCHED_YIELD #undef OF_HAVE_SYS_SELECT_H #undef OF_OBJFW_RUNTIME #undef OF_PLUGINS #undef OF_THREADS #undef SIZE_MAX | > | 12 13 14 15 16 17 18 19 20 21 22 | #undef OF_HAVE_POLL #undef OF_HAVE_PROPERTIES #undef OF_HAVE_PTHREADS #undef OF_HAVE_PTHREAD_SPINLOCKS #undef OF_HAVE_SCHED_YIELD #undef OF_HAVE_SYS_SELECT_H #undef OF_OBJFW_RUNTIME #undef OF_OLD_GNU_RUNTIME #undef OF_PLUGINS #undef OF_THREADS #undef SIZE_MAX |
Modified tests/OFBlockTests.m from [3714ef1c3f] to [e76b67d1d2].
︙ | ︙ | |||
14 15 16 17 18 19 20 | #import "OFString.h" #import "OFBlock.h" #import "OFAutoreleasePool.h" #import "OFExceptions.h" #if defined(OF_OBJFW_RUNTIME) # include <objfw-rt.h> | | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #import "OFString.h" #import "OFBlock.h" #import "OFAutoreleasePool.h" #import "OFExceptions.h" #if defined(OF_OBJFW_RUNTIME) # include <objfw-rt.h> #elif defined(OF_OLD_GNU_RUNTIME) # include <objc/objc-api.h> #endif #if defined(OF_OLD_GNU_RUNTIME) || defined(OF_OBJFW_RUNTIME) # define objc_getClass objc_get_class #endif #import "TestsAppDelegate.h" static OFString *module = @"OFBlock"; |
︙ | ︙ |