Differences From Artifact [495179aec4]:
- File
src/OFIntrospection.m
— part of check-in
[9df84ee33d]
at
2012-07-17 00:02:05
on branch trunk
— Implement introspection for the ObjFW runtime.
Currently, only methods can be introspected. This means that ivars and
properties are still on the todo list. However, the ObjFW runtime does
not export structs for those yet, so this needs to be done first. (user: js, size: 6620) [annotate] [blame] [check-ins using]
To Artifact [fd9ea3d6be]:
- File src/OFIntrospection.m — part of check-in [82b9b5f7c8] at 2012-07-17 23:59:52 on branch trunk — Add ivar introspection for the ObjFW runtime. (user: js, size: 7255) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
94 95 96 97 98 99 100 | { return [OFString stringWithFormat: @"<OFMethod: %@ [%s]>", name, typeEncoding]; } @end @implementation OFInstanceVariable | > > > > > > > > > > > > > > > > > > | < > | 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 | { return [OFString stringWithFormat: @"<OFMethod: %@ [%s]>", name, typeEncoding]; } @end @implementation OFInstanceVariable #if defined(OF_OBJFW_RUNTIME) - _initWithIvar: (struct objc_ivar*)ivar { self = [super init]; @try { name = [[OFString alloc] initWithCString: ivar->name encoding: OF_STRING_ENCODING_ASCII]; typeEncoding = ivar->type; offset = ivar->offset; } @catch (id e) { [self release]; @throw e; } return self; } #elif defined(OF_APPLE_RUNTIME) - _initWithIvar: (Ivar)ivar { self = [super init]; @try { name = [[OFString alloc] initWithCString: ivar_getName(ivar) encoding: OF_STRING_ENCODING_ASCII]; typeEncoding = ivar_getTypeEncoding(ivar); offset = ivar_getOffset(ivar); } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ | |||
242 243 244 245 246 247 248 | _initWithMethod: &methodList->methods[i]]; [instanceMethods addObject: [method autorelease]]; [pool releaseObjects]; } } | > > > > > > > > > > > > > > | | 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | _initWithMethod: &methodList->methods[i]]; [instanceMethods addObject: [method autorelease]]; [pool releaseObjects]; } } if (class->ivars != NULL) { unsigned i; for (i = 0; i < class->ivars->count; i++) { OFInstanceVariable *ivar; ivar = [[OFInstanceVariable alloc] _initWithIvar: &class->ivars->ivars[i]]; [instanceVariables addObject: [ivar autorelease]]; [pool releaseObjects]; } } /* TODO: properties */ #elif defined(OF_APPLE_RUNTIME) methodList = class_copyMethodList(object_getClass(class), &count); @try { for (i = 0; i < count; i++) { [classMethods addObject: [[[OFMethod alloc] _initWithMethod: methodList[i]] |
︙ | ︙ |