ObjFW  Diff

Differences From Artifact [0c9f7f6c34]:

To Artifact [57c5a42ed5]:


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

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
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







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

-
-
-
-
-
-



-
+







-
-
+
+




-
+




+
-
+




-
+




-
+




+
-
+




+
-
+





-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-







#import "OFPointerValue.h"
#import "OFRangeValue.h"
#import "OFRectangleValue.h"
#import "OFString.h"

#import "OFOutOfMemoryException.h"

static struct {
	Class isa;
} placeholder;

@interface OFValuePlaceholder: OFValue
@end

@implementation OFValuePlaceholder
- (instancetype)initWithBytes: (const void *)bytes
		     objCType: (const char *)objCType
{
	return (id)[[OFBytesValue alloc] initWithBytes: bytes
					      objCType: objCType];
}

- (instancetype)initWithPointer: (const void *)pointer
{
	return (id)[[OFPointerValue alloc] initWithPointer: pointer];
}

- (instancetype)initWithNonretainedObject: (id)object
{
	return (id)[[OFNonretainedObjectValue alloc]
	    initWithNonretainedObject: object];
}

- (instancetype)initWithRange: (of_range_t)range
{
	return (id)[[OFRangeValue alloc] initWithRange: range];
}

- (instancetype)initWithPoint: (of_point_t)point
{
	return (id)[[OFPointValue alloc] initWithPoint: point];
}

- (instancetype)initWithDimension: (of_dimension_t)dimension
{
	return (id)[[OFDimensionValue alloc] initWithDimension: dimension];
}

- (instancetype)initWithRectangle: (of_rectangle_t)rectangle
{
	return (id)[[OFRectangleValue alloc] initWithRectangle: rectangle];
}
@end

@implementation OFValue
+ (void)initialize
{
	if (self == [OFValue class])
		placeholder.isa = [OFValuePlaceholder class];
}

+ (instancetype)alloc
{
	if (self == [OFValue class])
		return (id)&placeholder;
		return [OFBytesValue alloc];

	return [super alloc];
}

+ (instancetype)valueWithBytes: (const void *)bytes
		      objCType: (const char *)objCType
{
	return [[[self alloc] initWithBytes: bytes
				   objCType: objCType] autorelease];
	return [[[OFBytesValue alloc] initWithBytes: bytes
					   objCType: objCType] autorelease];
}

+ (instancetype)valueWithPointer: (const void *)pointer
{
	return [[[self alloc] initWithPointer: pointer] autorelease];
	return [[[OFPointerValue alloc] initWithPointer: pointer] autorelease];
}

+ (instancetype)valueWithNonretainedObject: (id)object
{
	return [[[OFNonretainedObjectValue alloc]
	return [[[self alloc] initWithNonretainedObject: object] autorelease];
	    initWithNonretainedObject: object] autorelease];
}

+ (instancetype)valueWithRange: (of_range_t)range
{
	return [[[self alloc] initWithRange: range] autorelease];
	return [[[OFRangeValue alloc] initWithRange: range] autorelease];
}

+ (instancetype)valueWithPoint: (of_point_t)point
{
	return [[[self alloc] initWithPoint: point] autorelease];
	return [[[OFPointValue alloc] initWithPoint: point] autorelease];
}

+ (instancetype)valueWithDimension: (of_dimension_t)dimension
{
	return [[[OFDimensionValue alloc]
	return [[[self alloc] initWithDimension: dimension] autorelease];
	    initWithDimension: dimension] autorelease];
}

+ (instancetype)valueWithRectangle: (of_rectangle_t)rectangle
{
	return [[[OFRectangleValue alloc]
	return [[[self alloc] initWithRectangle: rectangle] autorelease];
	    initWithRectangle: rectangle] autorelease];
}

- (instancetype)initWithBytes: (const void *)bytes
		     objCType: (const char *)objCType
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithPointer: (const void *)pointer
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithNonretainedObject: (id)object
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithRange: (of_range_t)range
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithPoint: (of_point_t)point
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithDimension: (of_dimension_t)dimension
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithRectangle: (of_rectangle_t)rectangle
{
	OF_INVALID_INIT_METHOD
}

- (bool)isEqual: (id)object
{
	const char *objCType;
	size_t size;