22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#import "OFOnce.h"
#import "OFString.h"
#import "OFTaggedPointerColor.h"
@interface OFColorSingleton: OFConcreteColor
@end
@interface OFColorPlaceholder: OFColorSingleton
@end
static struct {
Class isa;
} placeholder;
#ifdef OF_OBJFW_RUNTIME
|
|
|
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#import "OFOnce.h"
#import "OFString.h"
#import "OFTaggedPointerColor.h"
@interface OFColorSingleton: OFConcreteColor
@end
@interface OFColorPlaceholder: OFColor
@end
static struct {
Class isa;
} placeholder;
#ifdef OF_OBJFW_RUNTIME
|
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
#endif
return (id)[[OFConcreteColor alloc] initWithRed: red
green: green
blue: blue
alpha: alpha];
}
@end
@implementation OFColorSingleton
- (instancetype)autorelease
{
return self;
}
- (instancetype)retain
{
return self;
}
- (void)release
{
}
- (unsigned int)retainCount
{
return OFMaxRetainCount;
}
@end
@implementation OFColor
+ (void)initialize
{
if (self == [OFColor class])
object_setClass((id)&placeholder, [OFColorPlaceholder class]);
|
>
>
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
|
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#endif
return (id)[[OFConcreteColor alloc] initWithRed: red
green: green
blue: blue
alpha: alpha];
}
OF_SINGLETON_METHODS
@end
@implementation OFColorSingleton
OF_SINGLETON_METHODS
@end
@implementation OFColor
+ (void)initialize
{
if (self == [OFColor class])
object_setClass((id)&placeholder, [OFColorPlaceholder class]);
|