13
14
15
16
17
18
19
20
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
56
57
58
59
60
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
96
97
98
99
100
101
102
103
104
|
* file.
*/
#include "config.h"
#include <stdlib.h>
#import "OFMutableMapTableDictionary.h"
#import "OFArray.h"
#import "OFString.h"
static struct {
Class isa;
} placeholder;
@interface OFMutableDictionaryPlaceholder: OFDictionary
@end
@implementation OFMutableDictionaryPlaceholder
- (instancetype)init
{
return (id)[[OFMutableMapTableDictionary alloc] init];
}
- (instancetype)initWithDictionary: (OFDictionary *)dictionary
{
return (id)[[OFMutableMapTableDictionary alloc]
initWithDictionary: dictionary];
}
- (instancetype)initWithObject: (id)object forKey: (id)key
{
return (id)[[OFMutableMapTableDictionary alloc] initWithObject: object
forKey: key];
}
- (instancetype)initWithObjects: (OFArray *)objects forKeys: (OFArray *)keys
{
return (id)[[OFMutableMapTableDictionary alloc] initWithObjects: objects
forKeys: keys];
}
- (instancetype)initWithObjects: (id const *)objects
forKeys: (id const *)keys
count: (size_t)count
{
return (id)[[OFMutableMapTableDictionary alloc] initWithObjects: objects
forKeys: keys
count: count];
}
- (instancetype)initWithKeysAndObjects: (id)firstKey, ...
{
id ret;
va_list arguments;
va_start(arguments, firstKey);
ret = (id)[[OFMutableMapTableDictionary alloc] initWithKey: firstKey
arguments: arguments];
va_end(arguments);
return ret;
}
- (instancetype)initWithKey: (id)firstKey arguments: (va_list)arguments
{
return (id)[[OFMutableMapTableDictionary alloc] initWithKey: firstKey
arguments: arguments];
}
- (instancetype)initWithCapacity: (size_t)capacity
{
return (id)[[OFMutableMapTableDictionary alloc]
initWithCapacity: capacity];
}
OF_SINGLETON_METHODS
@end
@implementation OFMutableDictionary
+ (void)initialize
{
if (self == [OFMutableDictionary class])
object_setClass((id)&placeholder,
[OFMutableDictionaryPlaceholder class]);
}
+ (instancetype)alloc
{
if (self == [OFMutableDictionary class])
return (id)&placeholder;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13
14
15
16
17
18
19
20
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
56
57
58
59
60
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
96
97
98
99
100
101
102
103
104
|
* file.
*/
#include "config.h"
#include <stdlib.h>
#import "OFConcreteMutableDictionary.h"
#import "OFArray.h"
#import "OFString.h"
static struct {
Class isa;
} placeholder;
@interface OFPlaceholderMutableDictionary: OFDictionary
@end
@implementation OFPlaceholderMutableDictionary
- (instancetype)init
{
return (id)[[OFConcreteMutableDictionary alloc] init];
}
- (instancetype)initWithDictionary: (OFDictionary *)dictionary
{
return (id)[[OFConcreteMutableDictionary alloc]
initWithDictionary: dictionary];
}
- (instancetype)initWithObject: (id)object forKey: (id)key
{
return (id)[[OFConcreteMutableDictionary alloc] initWithObject: object
forKey: key];
}
- (instancetype)initWithObjects: (OFArray *)objects forKeys: (OFArray *)keys
{
return (id)[[OFConcreteMutableDictionary alloc] initWithObjects: objects
forKeys: keys];
}
- (instancetype)initWithObjects: (id const *)objects
forKeys: (id const *)keys
count: (size_t)count
{
return (id)[[OFConcreteMutableDictionary alloc] initWithObjects: objects
forKeys: keys
count: count];
}
- (instancetype)initWithKeysAndObjects: (id)firstKey, ...
{
id ret;
va_list arguments;
va_start(arguments, firstKey);
ret = (id)[[OFConcreteMutableDictionary alloc] initWithKey: firstKey
arguments: arguments];
va_end(arguments);
return ret;
}
- (instancetype)initWithKey: (id)firstKey arguments: (va_list)arguments
{
return (id)[[OFConcreteMutableDictionary alloc] initWithKey: firstKey
arguments: arguments];
}
- (instancetype)initWithCapacity: (size_t)capacity
{
return (id)[[OFConcreteMutableDictionary alloc]
initWithCapacity: capacity];
}
OF_SINGLETON_METHODS
@end
@implementation OFMutableDictionary
+ (void)initialize
{
if (self == [OFMutableDictionary class])
object_setClass((id)&placeholder,
[OFPlaceholderMutableDictionary class]);
}
+ (instancetype)alloc
{
if (self == [OFMutableDictionary class])
return (id)&placeholder;
|