ObjFW  Diff

Differences From Artifact [055b4111d5]:

To Artifact [b1d260547d]:


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "config.h"

#define OF_SET_M

#import "OFSet.h"
#import "OFDictionary.h"
#import "OFArray.h"
#import "OFNull.h"
#import "OFString.h"
#import "OFAutoreleasePool.h"

@implementation OFSet
+ set
{
	return [[[self alloc] init] autorelease];
}







|
|







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "config.h"

#define OF_SET_M

#import "OFSet.h"
#import "OFDictionary.h"
#import "OFArray.h"
#import "OFString.h"
#import "OFNumber.h"
#import "OFAutoreleasePool.h"

@implementation OFSet
+ set
{
	return [[[self alloc] init] autorelease];
}
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
	}

	return self;
}

- initWithSet: (OFSet*)set
{
	self = [super init];

	@try {




		dictionary = [[OFMutableDictionary alloc]





		    _initWithDictionary: set->dictionary

			       copyKeys: NO];


	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithArray: (OFArray*)array
{
	self = [self init];

	@try {


		id *cArray = [array cArray];
		size_t i, count = [array count];
		OFNull *null = [OFNull null];

		for (i = 0; i < count; i++)
			[dictionary _setObject: null
					forKey: cArray[i]
				       copyKey: NO];


	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}







|


>
>
>
>
|
>
>
>
>
>
|
>
|
>
>













>
>


<


|


>
>







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
	}

	return self;
}

- initWithSet: (OFSet*)set
{
	self = [self init];

	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
		OFNumber *one = [OFNumber numberWithSize: 1];
		OFEnumerator *enumerator = [set objectEnumerator];
		id object;

		/*
		 * We can't just copy the dictionary as the specified set might
		 * be a counted set, but we're just a normal set.
		 */
		while ((object = [enumerator nextObject]) != nil)
			[dictionary _setObject: one
					forKey: object
				       copyKey: NO];

		[pool release];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithArray: (OFArray*)array
{
	self = [self init];

	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
		OFNumber *one = [OFNumber numberWithSize: 1];
		id *cArray = [array cArray];
		size_t i, count = [array count];


		for (i = 0; i < count; i++)
			[dictionary _setObject: one
					forKey: cArray[i]
				       copyKey: NO];

		[pool release];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}
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

- initWithObject: (id)firstObject
       arguments: (va_list)arguments
{
	self = [self init];

	@try {

		OFNull *null = [OFNull null];
		id object;

		[dictionary _setObject: null
				forKey: firstObject
			       copyKey: NO];

		while ((object = va_arg(arguments, id)) != nil)
			[dictionary _setObject: null
					forKey: object
				       copyKey: NO];


	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}







>
|


|




|


>
>







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

- initWithObject: (id)firstObject
       arguments: (va_list)arguments
{
	self = [self init];

	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
		OFNumber *one = [OFNumber numberWithSize: 1];
		id object;

		[dictionary _setObject: one
				forKey: firstObject
			       copyKey: NO];

		while ((object = va_arg(arguments, id)) != nil)
			[dictionary _setObject: one
					forKey: object
				       copyKey: NO];

		[pool release];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}