ObjFW  Diff

Differences From Artifact [28d5671231]:

To Artifact [521053ff4d]:

  • File src/OFIntrospection.m — part of check-in [48980f2297] at 2015-11-29 11:43:05 on branch trunk — Make properties a requirement and clean up code

    This increases the required GCC version from 4.0 to 4.6 (exception:
    Apple GCC, which already supports this with >= 4.0 starting with OS X
    10.5). Since even GCC 4.6 is really old by now, there is no point in
    still supporting something even older and making the code ugly because
    of that. While some hardware and OS support was dropped from GCC 4.6
    compared to GCC 4.0, there is nothing in there that would be an
    interesting target with the exception of BeOS maybe - but a port to BeOS
    can also be achieved using the Haiku support. The other dropped OSes are
    mostly old versions of OSes while newer ones are still being supported
    (and those newer versions of those OSes still support the same
    hardware). (user: js, size: 12539) [annotate] [blame] [check-ins using]


22
23
24
25
26
27
28


29
30
31
32
33
34
35
#import "OFIntrospection.h"
#import "OFString.h"
#import "OFArray.h"

#import "OFInitializationFailedException.h"

@implementation OFMethod


#if defined(OF_OBJFW_RUNTIME)
- (instancetype)OF_initWithMethod: (struct objc_method*)method
{
	self = [super init];

	@try {
		_selector = (SEL)&method->sel;







>
>







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#import "OFIntrospection.h"
#import "OFString.h"
#import "OFArray.h"

#import "OFInitializationFailedException.h"

@implementation OFMethod
@synthesize selector = _selector, name = _name, typeEncoding = _typeEncoding;

#if defined(OF_OBJFW_RUNTIME)
- (instancetype)OF_initWithMethod: (struct objc_method*)method
{
	self = [super init];

	@try {
		_selector = (SEL)&method->sel;
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
- (void)dealloc
{
	[_name release];

	[super dealloc];
}

- (SEL)selector
{
	return _selector;
}

- (OFString*)name
{
	OF_GETTER(_name, true)
}

- (const char*)typeEncoding
{
	return _typeEncoding;
}

- (OFString*)description
{
	return [OFString stringWithFormat: @"<%@: %@ [%s]>",
					   [self class], _name, _typeEncoding];
}

- (bool)isEqual: (id)object







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







74
75
76
77
78
79
80















81
82
83
84
85
86
87
- (void)dealloc
{
	[_name release];

	[super dealloc];
}
















- (OFString*)description
{
	return [OFString stringWithFormat: @"<%@: %@ [%s]>",
					   [self class], _name, _typeEncoding];
}

- (bool)isEqual: (id)object
142
143
144
145
146
147
148



149
150
151
152
153
154
155
	OF_HASH_FINALIZE(hash);

	return hash;
}
@end

@implementation OFProperty



#if defined(OF_OBJFW_RUNTIME)
- (instancetype)OF_initWithProperty: (struct objc_property*)property
{
	self = [super init];

	@try {
		_name = [[OFString alloc] initWithUTF8String: property->name];







>
>
>







129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
	OF_HASH_FINALIZE(hash);

	return hash;
}
@end

@implementation OFProperty
@synthesize name = _name, attributes = _attributes;
@synthesize getter = _getter, setter = _setter;

#if defined(OF_OBJFW_RUNTIME)
- (instancetype)OF_initWithProperty: (struct objc_property*)property
{
	self = [super init];

	@try {
		_name = [[OFString alloc] initWithUTF8String: property->name];
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
	[_name release];
	[_getter release];
	[_setter release];

	[super dealloc];
}

- (OFString*)name
{
	OF_GETTER(_name, true)
}

- (unsigned)attributes
{
	return _attributes;
}

- (OFString*)getter
{
	OF_GETTER(_getter, true)
}

- (OFString*)setter
{
	OF_GETTER(_setter, true)
}

- (OFString*)description
{
	return [OFString
	    stringWithFormat: @"<%@: %@\n"
			      @"\tAttributes = 0x%03X\n"
			      @"\tGetter = %@\n"
			      @"\tSetter = %@\n"







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







302
303
304
305
306
307
308




















309
310
311
312
313
314
315
	[_name release];
	[_getter release];
	[_setter release];

	[super dealloc];
}





















- (OFString*)description
{
	return [OFString
	    stringWithFormat: @"<%@: %@\n"
			      @"\tAttributes = 0x%03X\n"
			      @"\tGetter = %@\n"
			      @"\tSetter = %@\n"
384
385
386
387
388
389
390


391
392
393
394
395
396
397
	OF_HASH_FINALIZE(hash);

	return hash;
}
@end

@implementation OFInstanceVariable


#if defined(OF_OBJFW_RUNTIME)
- (instancetype)OF_initWithIvar: (struct objc_ivar*)ivar
{
	self = [super init];

	@try {
		_name = [[OFString alloc] initWithUTF8String: ivar->name];







>
>







354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
	OF_HASH_FINALIZE(hash);

	return hash;
}
@end

@implementation OFInstanceVariable
@synthesize name = _name, offset = _offset, typeEncoding = _typeEncoding;

#if defined(OF_OBJFW_RUNTIME)
- (instancetype)OF_initWithIvar: (struct objc_ivar*)ivar
{
	self = [super init];

	@try {
		_name = [[OFString alloc] initWithUTF8String: ivar->name];
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
- (void)dealloc
{
	[_name release];

	[super dealloc];
}

- (OFString*)name
{
	OF_GETTER(_name, true);
}

- (ptrdiff_t)offset
{
	return _offset;
}

- (const char*)typeEncoding
{
	return _typeEncoding;
}

- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"<OFInstanceVariable: %@ [%s] @ 0x%tx>",
	    _name, _typeEncoding, _offset];
}
@end

@implementation OFIntrospection



+ (instancetype)introspectionWithClass: (Class)class
{
	return [[[self alloc] initWithClass: class] autorelease];
}

- initWithClass: (Class)class
{







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<









>
>
>







405
406
407
408
409
410
411















412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
- (void)dealloc
{
	[_name release];

	[super dealloc];
}
















- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"<OFInstanceVariable: %@ [%s] @ 0x%tx>",
	    _name, _typeEncoding, _offset];
}
@end

@implementation OFIntrospection
@synthesize classMethods = _classMethods, instanceMethods = _instanceMethods;
@synthesize properties = _properties, instanceVariables = _instanceVariables;

+ (instancetype)introspectionWithClass: (Class)class
{
	return [[[self alloc] initWithClass: class] autorelease];
}

- initWithClass: (Class)class
{
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
{
	[_classMethods release];
	[_instanceMethods release];
	[_instanceVariables release];

	[super dealloc];
}

- (OFArray*)classMethods
{
	OF_GETTER(_classMethods, true)
}

- (OFArray*)instanceMethods
{
	OF_GETTER(_instanceMethods, true)
}

- (OFArray*)properties
{
	OF_GETTER(_properties, true)
}

- (OFArray*)instanceVariables
{
	OF_GETTER(_instanceVariables, true)
}
@end







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

578
579
580
581
582
583
584




















585
{
	[_classMethods release];
	[_instanceMethods release];
	[_instanceVariables release];

	[super dealloc];
}




















@end