ObjFW  Check-in [42e16978dc]

Overview
Comment:Prevent calling -[init] if parameters are required.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 42e16978dce89bbac9c827480ee7d1da43b2a1bd035dbdc3434a87901f4cc81b
User & Date: js on 2009-07-19 16:01:21
Other Links: manifest | tags
Context
2009-07-19
16:32
Add PLATFORMS file. check-in: 0123352146 user: js tags: trunk
16:01
Prevent calling -[init] if parameters are required. check-in: 42e16978dc user: js tags: trunk
14:05
Rename andFoo: to foo: in all methods. check-in: 4eae61a78f user: js tags: trunk
Changes

Modified src/OFConstString.m from [d8470a1fff] to [8dadde45bc].

22
23
24
25
26
27
28












































29
30
31
32
33
34
35
#ifndef __objc_INCLUDE_GNU
+ (void)load
{
	objc_setFutureClass((Class)&_OFConstStringClassReference,
	    "OFConstString");
}
#endif













































- addMemoryToPool: (void*)ptr
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
#ifndef __objc_INCLUDE_GNU
+ (void)load
{
	objc_setFutureClass((Class)&_OFConstStringClassReference,
	    "OFConstString");
}
#endif

+ alloc
{
	@throw [OFNotImplementedException newWithClass: self
					      selector: _cmd];
}

- init
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithCString: (const char*)str
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithCString: (const char*)str
           length: (size_t)len
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithFormat: (OFString*)fmt, ...
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithFormat: (OFString*)fmt
       arguments: (va_list)args
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithString: (OFString*)str
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- addMemoryToPool: (void*)ptr
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

Modified src/OFDataArray.m from [3d750bfc13] to [f70a5505ca].

27
28
29
30
31
32
33






34
35
36
37
38
39
40
static int lastpagebyte = 0;

@implementation OFDataArray
+ dataArrayWithItemSize: (size_t)is
{
	return [[[self alloc] initWithItemSize: is] autorelease];
}







- initWithItemSize: (size_t)is
{
	Class c;

	self = [super init];








>
>
>
>
>
>







27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
static int lastpagebyte = 0;

@implementation OFDataArray
+ dataArrayWithItemSize: (size_t)is
{
	return [[[self alloc] initWithItemSize: is] autorelease];
}

- init
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithItemSize: (size_t)is
{
	Class c;

	self = [super init];

Modified src/OFExceptions.m from [0cd8668484] to [6da0c73362].

68
69
70
71
72
73
74






75
76
77
78
79
80
81
@end

@implementation OFException
+ newWithClass: (Class)class_
{
	return [[self alloc] initWithClass: class_];
}







- initWithClass: (Class)class_
{
	self = [super init];

	class = class_;








>
>
>
>
>
>







68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
@end

@implementation OFException
+ newWithClass: (Class)class_
{
	return [[self alloc] initWithClass: class_];
}

- init
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithClass: (Class)class_
{
	self = [super init];

	class = class_;

103
104
105
106
107
108
109






110
111
112
113
114
115
116
@implementation OFOutOfMemoryException
+ newWithClass: (Class)class_
	  size: (size_t)size
{
	return [[self alloc] initWithClass: class_
				      size: size];
}







- initWithClass: (Class)class_
	   size: (size_t)size
{
	self = [super initWithClass: class_];

	req_size = size;







>
>
>
>
>
>







109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
@implementation OFOutOfMemoryException
+ newWithClass: (Class)class_
	  size: (size_t)size
{
	return [[self alloc] initWithClass: class_
				      size: size];
}

- initWithClass: (Class)class_
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithClass: (Class)class_
	   size: (size_t)size
{
	self = [super initWithClass: class_];

	req_size = size;
139
140
141
142
143
144
145






146
147
148
149
150
151
152
@implementation OFMemoryNotPartOfObjectException
+ newWithClass: (Class)class_
       pointer: (void*)ptr
{
	return [[self alloc] initWithClass: class_
				   pointer: ptr];
}







- initWithClass: (Class)class_
	pointer: (void*)ptr
{
	self = [super initWithClass: class_];

	pointer = ptr;







>
>
>
>
>
>







151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
@implementation OFMemoryNotPartOfObjectException
+ newWithClass: (Class)class_
       pointer: (void*)ptr
{
	return [[self alloc] initWithClass: class_
				   pointer: ptr];
}

- initWithClass: (Class)class_
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithClass: (Class)class_
	pointer: (void*)ptr
{
	self = [super initWithClass: class_];

	pointer = ptr;
177
178
179
180
181
182
183






184
185
186
187
188
189
190
@implementation OFNotImplementedException
+ newWithClass: (Class)class_
      selector: (SEL)selector_
{
	return [[self alloc] initWithClass: class_
				  selector: selector_];
}







- initWithClass: (Class)class_
       selector: (SEL)selector_
{
	self = [super initWithClass: class_];

	selector = selector_;







>
>
>
>
>
>







195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
@implementation OFNotImplementedException
+ newWithClass: (Class)class_
      selector: (SEL)selector_
{
	return [[self alloc] initWithClass: class_
				  selector: selector_];
}

- initWithClass: (Class)class_
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithClass: (Class)class_
       selector: (SEL)selector_
{
	self = [super initWithClass: class_];

	selector = selector_;
221
222
223
224
225
226
227






228
229
230
231
232
233
234
@implementation OFInvalidArgumentException
+ newWithClass: (Class)class_
      selector: (SEL)selector_
{
	return [[self alloc] initWithClass: class_
				  selector: selector_];
}







- initWithClass: (Class)class_
       selector: (SEL)selector_
{
	self = [super initWithClass: class_];

	selector = selector_;







>
>
>
>
>
>







245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
@implementation OFInvalidArgumentException
+ newWithClass: (Class)class_
      selector: (SEL)selector_
{
	return [[self alloc] initWithClass: class_
				  selector: selector_];
}

- initWithClass: (Class)class_
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithClass: (Class)class_
       selector: (SEL)selector_
{
	self = [super initWithClass: class_];

	selector = selector_;
293
294
295
296
297
298
299






300
301
302
303
304
305
306
	  path: (OFString*)path_
	  mode: (OFString*)mode_
{
	return [[self alloc] initWithClass: class_
				      path: path_
				      mode: mode_];
}







- initWithClass: (Class)class_
	   path: (OFString*)path_
	   mode: (OFString*)mode_
{
	self = [super initWithClass: class_];








>
>
>
>
>
>







323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
	  path: (OFString*)path_
	  mode: (OFString*)mode_
{
	return [[self alloc] initWithClass: class_
				      path: path_
				      mode: mode_];
}

- initWithClass: (Class)class_
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithClass: (Class)class_
	   path: (OFString*)path_
	   mode: (OFString*)mode_
{
	self = [super initWithClass: class_];

359
360
361
362
363
364
365






366
367
368
369
370
371
372

+ newWithClass: (Class)class_
	  size: (size_t)size
{
	return [[self alloc] initWithClass: class_
				      size: size];
}







- initWithClass: (Class)class_
	   size: (size_t)size
	  items: (size_t)items
{
	self = [super initWithClass: class_];








>
>
>
>
>
>







395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414

+ newWithClass: (Class)class_
	  size: (size_t)size
{
	return [[self alloc] initWithClass: class_
				      size: size];
}

- initWithClass: (Class)class_
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithClass: (Class)class_
	   size: (size_t)size
	  items: (size_t)items
{
	self = [super initWithClass: class_];

503
504
505
506
507
508
509






510
511
512
513
514
515
516
	  node: (OFString*)node_
       service: (OFString*)service_
{
	return [[self alloc] initWithClass: class_
				      node: node_
				   service: service_];
}







- initWithClass: (Class)class_
	   node: (OFString*)node_
	service: (OFString*)service_
{
	self = [super initWithClass: class_];








>
>
>
>
>
>







545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
	  node: (OFString*)node_
       service: (OFString*)service_
{
	return [[self alloc] initWithClass: class_
				      node: node_
				   service: service_];
}

- initWithClass: (Class)class_
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithClass: (Class)class_
	   node: (OFString*)node_
	service: (OFString*)service_
{
	self = [super initWithClass: class_];

566
567
568
569
570
571
572






573
574
575
576
577
578
579
	  node: (OFString*)node_
       service: (OFString*)service_
{
	return [[self alloc] initWithClass: class_
				      node: node_
				   service: service_];
}







- initWithClass: (Class)class_
	   node: (OFString*)node_
	service: (OFString*)service_
{
	self = [super initWithClass: class_];








>
>
>
>
>
>







614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
	  node: (OFString*)node_
       service: (OFString*)service_
{
	return [[self alloc] initWithClass: class_
				      node: node_
				   service: service_];
}

- initWithClass: (Class)class_
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithClass: (Class)class_
	   node: (OFString*)node_
	service: (OFString*)service_
{
	self = [super initWithClass: class_];

628
629
630
631
632
633
634






635
636
637
638
639
640
641
	family: (int)family_
{
	return [[self alloc] initWithClass: class_
				      node: node_
				   service: service_
				    family: family_];
}







- initWithClass: (Class)class_
	   node: (OFString*)node_
	service: (OFString*)service_
	 family: (int)family_
{
	self = [super initWithClass: class_];







>
>
>
>
>
>







682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
	family: (int)family_
{
	return [[self alloc] initWithClass: class_
				      node: node_
				   service: service_
				    family: family_];
}

- initWithClass: (Class)class_
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithClass: (Class)class_
	   node: (OFString*)node_
	service: (OFString*)service_
	 family: (int)family_
{
	self = [super initWithClass: class_];
693
694
695
696
697
698
699






700
701
702
703
704
705
706
@implementation OFListenFailedException
+ newWithClass: (Class)class_
       backLog: (int)backlog_
{
	return [[self alloc] initWithClass: class_
				   backLog: backlog_];
}







- initWithClass: (Class)class_
	backLog: (int)backlog_
{
	self = [super initWithClass: class_];

	backlog = backlog_;







>
>
>
>
>
>







753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
@implementation OFListenFailedException
+ newWithClass: (Class)class_
       backLog: (int)backlog_
{
	return [[self alloc] initWithClass: class_
				   backLog: backlog_];
}

- initWithClass: (Class)class_
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithClass: (Class)class_
	backLog: (int)backlog_
{
	self = [super initWithClass: class_];

	backlog = backlog_;

Modified src/OFFile.m from [4d9a49c8b5] to [e3abf581b8].

103
104
105
106
107
108
109






110
111
112
113
114
115
116
	     to: (OFString*)dest
{
	/* FIXME: On error, throw exception */
#ifndef _WIN32
	symlink([src cString], [dest cString]);
#endif
}







- initWithPath: (OFString*)path
	  mode: (OFString*)mode
{
	Class c;

	self = [super init];







>
>
>
>
>
>







103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
	     to: (OFString*)dest
{
	/* FIXME: On error, throw exception */
#ifndef _WIN32
	symlink([src cString], [dest cString]);
#endif
}

- init
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithPath: (OFString*)path
	  mode: (OFString*)mode
{
	Class c;

	self = [super init];

Modified src/OFIterator.m from [2650b6ee1b] to [6e8102a07c].

15
16
17
18
19
20
21






22
23
24
25
26
27
28
#import "OFDictionary.h"
#import "OFExceptions.h"

/* Reference for static linking */
int _OFIterator_reference;

@implementation OFIterator






- initWithData: (OFList**)data_
	  size: (size_t)size_
{
	self = [super init];

	data = data_;
	size = size_;







>
>
>
>
>
>







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#import "OFDictionary.h"
#import "OFExceptions.h"

/* Reference for static linking */
int _OFIterator_reference;

@implementation OFIterator
- init
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithData: (OFList**)data_
	  size: (size_t)size_
{
	self = [super init];

	data = data_;
	size = size_;

Modified src/OFNumber.m from [d35a23e51f] to [1760655c76].

338
339
340
341
342
343
344






345
346
347
348
349
350
351
	return [[[self alloc] initWithFloat: float_] autorelease];
}

+ numberWithDouble: (double)double_
{
	return [[[self alloc] initWithDouble: double_] autorelease];
}







- initWithChar: (char)char_
{
	self = [super init];

	value.char_ = char_;
	type = OF_NUMBER_CHAR;







>
>
>
>
>
>







338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
	return [[[self alloc] initWithFloat: float_] autorelease];
}

+ numberWithDouble: (double)double_
{
	return [[[self alloc] initWithDouble: double_] autorelease];
}

- init
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithChar: (char)char_
{
	self = [super init];

	value.char_ = char_;
	type = OF_NUMBER_CHAR;

Modified src/OFPlugin.m from [310c254d06] to [59ef9c4044].

50
51
52
53
54
55
56









57
58
59
60
61
62
63
64
		dlclose(handle);
		@throw [OFInitializationFailedException newWithClass: self];
	}

	plugin->handle = handle;
	return [plugin autorelease];
}










- (void)dealloc
{
	dlclose(handle);

	[super dealloc];
}
@end







>
>
>
>
>
>
>
>
>








50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
		dlclose(handle);
		@throw [OFInitializationFailedException newWithClass: self];
	}

	plugin->handle = handle;
	return [plugin autorelease];
}

- init
{
	if (isa == [OFPlugin class])
		@throw [OFNotImplementedException newWithClass: isa
						      selector: _cmd];

	return [super init];
}

- (void)dealloc
{
	dlclose(handle);

	[super dealloc];
}
@end

Modified src/OFStream.m from [5bb8f6d8aa] to [a24c081951].

24
25
26
27
28
29
30




31
32
33
34
35
36
37

static int pagesize = 0;

@implementation OFStream
- init
{
	self = [super init];





	cache = NULL;

#ifndef _WIN32
	if (pagesize == 0)
		if ((pagesize = sysconf(_SC_PAGESIZE)) == -1)
			pagesize = 4096;







>
>
>
>







24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

static int pagesize = 0;

@implementation OFStream
- init
{
	self = [super init];

	if (isa == [OFStream class])
		@throw [OFNotImplementedException newWithClass: isa
						      selector: _cmd];

	cache = NULL;

#ifndef _WIN32
	if (pagesize == 0)
		if ((pagesize = sysconf(_SC_PAGESIZE)) == -1)
			pagesize = 4096;

Modified src/OFThread.m from [0f49dc44da] to [1a195479da].

73
74
75
76
77
78
79






80
81
82
83
84
85
86
	 * to nil to release the old object.
	 */
	if (ret == NULL)
		return nil;

	return (id)ret;
}







- initWithObject: (id)obj
{
	Class c;

	self = [super init];
	object = [obj copy];







>
>
>
>
>
>







73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
	 * to nil to release the old object.
	 */
	if (ret == NULL)
		return nil;

	return (id)ret;
}

- init
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithObject: (id)obj
{
	Class c;

	self = [super init];
	object = [obj copy];

Modified src/OFXMLElement.m from [ffae94dc12] to [f1c60b4b45].

29
30
31
32
33
34
35






36
37
38
39
40
41
42

+ elementWithName: (OFString*)name_
      stringValue: (OFString*)stringval_
{
	return [[[self alloc] initWithName: name_
			       stringValue: stringval_] autorelease];
}







- initWithName: (OFString*)name_
{
	self = [super init];

	name = [name_ retain];








>
>
>
>
>
>







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

+ elementWithName: (OFString*)name_
      stringValue: (OFString*)stringval_
{
	return [[[self alloc] initWithName: name_
			       stringValue: stringval_] autorelease];
}

- init
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithName: (OFString*)name_
{
	self = [super init];

	name = [name_ retain];