Overview
Comment: | Better checking which runtime we use. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
240b72cd71b213487d02dd25b0a02946 |
User & Date: | js on 2009-12-01 13:35:25 |
Other Links: | manifest | tags |
Context
2009-12-01
| ||
14:54 | Update buildsys. check-in: bab351d9a5 user: js tags: trunk | |
13:35 | Better checking which runtime we use. check-in: 240b72cd71 user: js tags: trunk | |
13:28 | Adjust OFObject test to recent change to -[freeMemory:]. check-in: 5b8ab2c427 user: js tags: trunk | |
Changes
Modified configure.ac from [2adbb067d7] to [da87975601].
︙ | ︙ | |||
21 22 23 24 25 26 27 28 29 30 31 32 33 34 | AX_CHECK_COMPILER_FLAGS(-fno-constant-cfstrings, [ NO_CONST_CFSTRINGS="-fno-constant-cfstrings" OBJCFLAGS="$OBJCFLAGS -fno-constant-cfstrings"]) AC_SUBST(NO_CONST_CFSTRINGS) AC_DEFINE(OF_CONFIGURED, 1, [Define so that we know we got our config.h]) BUILDSYS_LIB AC_DEFINE_UNQUOTED(PLUGIN_SUFFIX, "$PLUGIN_SUFFIX", [Suffix for plugins]) if test x"$PLUGIN_SUFFIX" != "x"; then AC_SUBST(OFPLUGIN_M, "OFPlugin.m") AC_SUBST(TESTPLUGIN, "plugin") AC_DEFINE(OF_PLUGINS, 1, [Whether we have plugin support]) AC_SUBST(OFPLUGINS_DEF, "-DOF_PLUGINS") | > > > > > > > > > > > > > > > > > | 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 | AX_CHECK_COMPILER_FLAGS(-fno-constant-cfstrings, [ NO_CONST_CFSTRINGS="-fno-constant-cfstrings" OBJCFLAGS="$OBJCFLAGS -fno-constant-cfstrings"]) AC_SUBST(NO_CONST_CFSTRINGS) AC_DEFINE(OF_CONFIGURED, 1, [Define so that we know we got our config.h]) AC_MSG_CHECKING(which Objective C runtime we use) dnl TODO: This is ugly. Let's think of a better check. AC_EGREP_CPP(gnu, [ #import <objc/objc.h> #ifdef __objc_INCLUDE_GNU gnu #endif ], [ AC_DEFINE(OF_GNU_RUNTIME, 1, [Whether we use the GNU ObjC runtime]) AC_SUBST(RUNTIME_DEF, "-DOF_GNU_RUNTIME") objc_runtime="GNU" ], [ AC_DEFINE(OF_APPLE_RUNTIME, 1, [Whether we use the Apple ObjC runtime]) AC_SUBST(RUNTIME_DEF, "-DOF_APPLE_RUNTIME") objc_runtime="Apple"]) AC_MSG_RESULT($objc_runtime) BUILDSYS_LIB AC_DEFINE_UNQUOTED(PLUGIN_SUFFIX, "$PLUGIN_SUFFIX", [Suffix for plugins]) if test x"$PLUGIN_SUFFIX" != "x"; then AC_SUBST(OFPLUGIN_M, "OFPlugin.m") AC_SUBST(TESTPLUGIN, "plugin") AC_DEFINE(OF_PLUGINS, 1, [Whether we have plugin support]) AC_SUBST(OFPLUGINS_DEF, "-DOF_PLUGINS") |
︙ | ︙ | |||
60 61 62 63 64 65 66 | ], [ AC_MSG_RESULT(yes) size_max="SIZE_T_MAX"], [ AC_MSG_RESULT(no) size_max="((size_t)-1)"]) AC_DEFINE_UNQUOTED(SIZE_MAX, $size_max, [Maximum value for size_t])]) | < < < | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | ], [ AC_MSG_RESULT(yes) size_max="SIZE_T_MAX"], [ AC_MSG_RESULT(no) size_max="((size_t)-1)"]) AC_DEFINE_UNQUOTED(SIZE_MAX, $size_max, [Maximum value for size_t])]) AC_CHECK_FUNC(objc_sync_enter,, [ AC_SUBST(OBJC_SYNC, "objc_sync") AC_SUBST(OBJC_SYNC_M, "objc_sync.m") AC_DEFINE(NEED_OBJC_SYNC_INIT, 1, [Whether objc_sync_init needs to be called])]) AC_CHECK_FUNC(asprintf, [ |
︙ | ︙ |
Modified objfw-config.in from [e7c2d2a924] to [53fa41ac7d].
1 2 3 4 5 | #!/bin/sh prefix="@prefix@" exec_prefix="@exec_prefix@" libdir="@libdir@" CFLAGS="" | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #!/bin/sh prefix="@prefix@" exec_prefix="@exec_prefix@" libdir="@libdir@" CFLAGS="" CPPFLAGS="-I@includedir@ -DOF_CONFIGURED @RUNTIME_DEF@ @ENDIANESS_DEF@" CPPFLAGS="$CPPFLAGS @ASPRINTF_DEF@ @OFPLUGINS_DEF@" CXXFLAGS="" OBJCFLAGS="-fobjc-exceptions -fconstant-string-class=OFConstString" OBJCFLAGS="$OBJCFLAGS @NO_CONST_CFSTRINGS@ @NO_WARN_UNUSED@" LDFLAGS="@RPATH_LDFLAGS@" LIBS="-L${libdir} -lobjfw @LIBS@" VERSION="0.1" |
︙ | ︙ |
Modified src/OFConstString.h from [7c0af79c83] to [250582e910].
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* * Copyright (c) 2008 - 2009 * Jonathan Schleifer <js@webkeks.org> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #import "OFString.h" | < < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* * Copyright (c) 2008 - 2009 * Jonathan Schleifer <js@webkeks.org> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #import "OFString.h" #ifdef OF_APPLE_RUNTIME extern void *_OFConstStringClassReference; #endif /** * A class for storing static strings using the @"" literal. */ @interface OFConstString: OFString {} |
︙ | ︙ |
Modified src/OFConstString.m from [3572d5dacd] to [884dfeb01d].
︙ | ︙ | |||
10 11 12 13 14 15 16 | */ #include "config.h" #import "OFConstString.h" #import "OFExceptions.h" | > > | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | */ #include "config.h" #import "OFConstString.h" #import "OFExceptions.h" #ifdef OF_APPLE_RUNTIME #import <objc/runtime.h> void *_OFConstStringClassReference; #endif @implementation OFConstString #ifdef OF_APPLE_RUNTIME + (void)load { objc_setFutureClass((Class)&_OFConstStringClassReference, "OFConstString"); } #endif |
︙ | ︙ |
Modified src/OFObject.h from [a9bb10dc6d] to [5c9737ae0e].
︙ | ︙ | |||
14 15 16 17 18 19 20 | #error Please use objfw-config! #endif #include <stddef.h> #include <stdint.h> #import <objc/objc.h> | < < < | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | #error Please use objfw-config! #endif #include <stddef.h> #include <stdint.h> #import <objc/objc.h> /** * A result of a comparison. */ typedef enum { /// The left object is smaller than the right OF_ORDERED_ASCENDING = -1, |
︙ | ︙ |
Modified src/OFObject.m from [f65ab03140] to [e42ffed2f9].
︙ | ︙ | |||
19 20 21 22 23 24 25 | #import "OFObject.h" #import "OFAutoreleasePool.h" #import "OFExceptions.h" #import "OFMacros.h" #import <objc/objc-api.h> | | | | > | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | #import "OFObject.h" #import "OFAutoreleasePool.h" #import "OFExceptions.h" #import "OFMacros.h" #import <objc/objc-api.h> #ifdef OF_APPLE_RUNTIME #import <objc/runtime.h> #endif #ifdef OF_GNU_RUNTIME #import <objc/sarray.h> #endif struct pre_ivar { void **memchunks; size_t memchunks_size; size_t retain_count; }; |
︙ | ︙ | |||
61 62 63 64 65 66 67 | + (void)initialize { } + alloc { OFObject *instance; | | | | | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | + (void)initialize { } + alloc { OFObject *instance; #ifdef OF_APPLE_RUNTIME size_t isize = class_getInstanceSize(self); #else size_t isize = class_get_instance_size(self); #endif if ((instance = malloc(isize + PRE_IVAR_ALIGN)) == NULL) { alloc_failed_exception.isa = [OFAllocFailedException class]; @throw (OFAllocFailedException*)&alloc_failed_exception; } |
︙ | ︙ | |||
90 91 92 93 94 95 96 | + (Class)class { return self; } + (const char*)className { | | | | | | | > > | > > > > > > < < < < < < < < | | | > > | > > > > > > < < < < < < < < | | | | | | | | | | > > < < | > > < < | 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 116 117 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 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 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 263 264 | + (Class)class { return self; } + (const char*)className { #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; #endif } + (BOOL)conformsToProtocol: (Protocol*)protocol { #ifdef OF_APPLE_RUNTIME Class c; for (c = self; c != Nil; c = class_getSuperclass(c)) if (class_conformsToProtocol(c, protocol)) return YES; return NO; #else 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++) if ([pl->list[i] conformsToProtocol: protocol]) return YES; return NO; #endif } + (IMP)instanceMethodForSelector: (SEL)selector { #ifdef OF_APPLE_RUNTIME return class_getMethodImplementation(self, selector); #else return method_get_imp(class_get_instance_method(self, selector)); #endif } + (IMP)setImplementation: (IMP)newimp forMethod: (SEL)selector { #ifdef OF_APPLE_RUNTIME Method method; if ((method = class_getInstanceMethod(self, selector)) == NULL) @throw [OFInvalidArgumentException newWithClass: self selector: _cmd]; return method_setImplementation(method, newimp); #else 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; #endif } + (IMP)replaceMethod: (SEL)selector withMethodFromClass: (Class)class; { IMP newimp; #ifdef OF_APPLE_RUNTIME newimp = class_getMethodImplementation(class, selector); #else newimp = method_get_imp(class_get_instance_method(class, selector)); #endif return [self setImplementation: newimp forMethod: selector]; } - init { return self; } - (Class)class { return isa; } - (const char*)className { #ifdef OF_APPLE_RUNTIME return class_getName(isa); #else return object_get_class_name(self); #endif } - (BOOL)isKindOfClass: (Class)class { Class iter; #ifdef OF_APPLE_RUNTIME for (iter = isa; iter != Nil; iter = class_getSuperclass(iter)) #else for (iter = isa; iter != Nil; iter = class_get_super_class(iter)) #endif if (iter == class) return YES; return NO; } - (BOOL)respondsToSelector: (SEL)selector { #ifdef OF_APPLE_RUNTIME return class_respondsToSelector(isa, selector); #else if (object_is_instance(self)) return class_get_instance_method(isa, selector) != METHOD_NULL; else return class_get_class_method(isa, selector) != METHOD_NULL; #endif } - (BOOL)conformsToProtocol: (Protocol*)protocol { return [isa conformsToProtocol: protocol]; } - (IMP)methodForSelector: (SEL)selector { #ifdef OF_APPLE_RUNTIME return class_getMethodImplementation(isa, selector); #else if (object_is_instance(self)) return method_get_imp(class_get_instance_method(isa, selector)); else return method_get_imp(class_get_class_method(isa, selector)); #endif } - (BOOL)isEqual: (id)obj { /* Classes containing data should reimplement this! */ return (self == obj ? YES : NO); |
︙ | ︙ |
Modified src/OFString.h from [eec9378345] to [bb02b7e8a2].
︙ | ︙ | |||
33 34 35 36 37 38 39 | /** * A class for managing strings. */ @interface OFString: OFObject <OFCopying, OFMutableCopying> { char *string; unsigned int length; | | | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | /** * A class for managing strings. */ @interface OFString: OFObject <OFCopying, OFMutableCopying> { char *string; unsigned int length; #if defined(OF_APPLE_RUNTIME) && __LP64__ int _unused; #endif BOOL is_utf8; } /** * \return A new autoreleased OFString |
︙ | ︙ |