ObjFW  Check-in [7feac9e596]

Overview
Comment:[self alloc] isn't a good idea with the new API.
The reason is that a derived class, for example derived from OFArray,
would not return an OFArray when + arrayWithItemSize is called.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 7feac9e596f62d0030e2567b153b3ea70a5ff9f22ed0168024b830fec9ae4372
User & Date: js on 2009-01-24 20:28:31
Other Links: manifest | tags
Context
2009-02-14
17:08
Big diff, see details. check-in: 61a6ac873a user: js tags: trunk
2009-01-24
20:28
[self alloc] isn't a good idea with the new API.
The reason is that a derived class, for example derived from OFArray,
would not return an OFArray when + arrayWithItemSize is called.
check-in: 7feac9e596 user: js tags: trunk
15:33
Remove now useless release calls. check-in: e635b9a3fc user: js tags: trunk
Changes

Modified src/OFArray.m from [ea5c3825ad] to [0b15af59f1].

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

static size_t lastpagebyte = 0;
extern int getpagesize(void);

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

+ bigArrayWithItemSize: (size_t)is
{
	return [[[OFBigArray alloc] initWithItemSize: is] autorelease];
}








|







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

static size_t lastpagebyte = 0;
extern int getpagesize(void);

@implementation OFArray
+ arrayWithItemSize: (size_t)is
{
	return [[[OFArray alloc] initWithItemSize: is] autorelease];
}

+ bigArrayWithItemSize: (size_t)is
{
	return [[[OFBigArray alloc] initWithItemSize: is] autorelease];
}

Modified src/OFFile.m from [f8ec01874b] to [637ff38638].

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#import "OFFile.h"
#import "OFExceptions.h"

@implementation OFFile
+ fileWithPath: (const char*)path
       andMode: (const char*)mode
{
	return [[[self alloc] initWithPath: path
				   andMode: mode] autorelease];
}

+ (void)changeModeOfFile: (const char*)path
		  toMode: (mode_t)mode
{
	/*







|







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#import "OFFile.h"
#import "OFExceptions.h"

@implementation OFFile
+ fileWithPath: (const char*)path
       andMode: (const char*)mode
{
	return [[[OFFile alloc] initWithPath: path
				   andMode: mode] autorelease];
}

+ (void)changeModeOfFile: (const char*)path
		  toMode: (mode_t)mode
{
	/*

Modified src/OFHashes.m from [8790812f47] to [b5ad7687f9].

113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
	buf[2] += c;
	buf[3] += d;
}

@implementation OFMD5Hash
+ md5Hash
{
	return [[[self alloc] init] autorelease];
}

- init
{
	if ((self = [super init])) {
		buf[0] = 0x67452301;
		buf[1] = 0xEFCDAB89;







|







113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
	buf[2] += c;
	buf[3] += d;
}

@implementation OFMD5Hash
+ md5Hash
{
	return [[[OFMD5Hash alloc] init] autorelease];
}

- init
{
	if ((self = [super init])) {
		buf[0] = 0x67452301;
		buf[1] = 0xEFCDAB89;
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370

	memcpy(&buffer[j], &buf[i], size - i);
}

@implementation OFSHA1Hash
+ sha1Hash
{
	return [[[self alloc] init] autorelease];
}

- init
{
	if ((self = [super init])) {
		count = 0;
		state[0] = 0x67452301;







|







356
357
358
359
360
361
362
363
364
365
366
367
368
369
370

	memcpy(&buffer[j], &buf[i], size - i);
}

@implementation OFSHA1Hash
+ sha1Hash
{
	return [[[OFSHA1Hash alloc] init] autorelease];
}

- init
{
	if ((self = [super init])) {
		count = 0;
		state[0] = 0x67452301;

Modified src/OFList.m from [d340619ba8] to [b318f43264].

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#import "config.h"

#import "OFList.h"

@implementation OFList
+ list
{
	return [[[self alloc] init] autorelease];
}

- init
{
	if ((self = [super init])) {
		first = NULL;
		last = NULL;







|







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#import "config.h"

#import "OFList.h"

@implementation OFList
+ list
{
	return [[[OFList alloc] init] autorelease];
}

- init
{
	if ((self = [super init])) {
		first = NULL;
		last = NULL;

Modified src/OFNumber.m from [714973113c] to [5618431ef2].

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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
		/* Make gcc happy */					      \
		return 0;						      \
	}

@implementation OFNumber
+ numberWithChar: (char)char_
{
	return [[[self alloc] initWithChar: char_] autorelease];
}

+ numberWithShort: (short)short_
{
	return [[[self alloc] initWithShort: short_] autorelease];
}

+ numberWithInt: (int)int_
{
	return [[[self alloc] initWithInt: int_] autorelease];
}

+ numberWithLong: (long)long_
{
	return [[[self alloc] initWithLong: long_] autorelease];
}

+ numberWithUChar: (unsigned char)uchar
{
	return [[[self alloc] initWithUChar: uchar] autorelease];
}

+ numberWithUShort: (unsigned short)ushort
{
	return [[[self alloc] initWithUShort: ushort] autorelease];
}

+ numberWithUInt: (unsigned int)uint
{
	return [[[self alloc] initWithUInt: uint] autorelease];
}

+ numberWithULong: (unsigned long)ulong
{
	return [[[self alloc] initWithULong: ulong] autorelease];
}

+ numberWithInt8: (int8_t)int8
{
	return [[[self alloc] initWithInt8: int8] autorelease];
}

+ numberWithInt16: (int16_t)int16
{
	return [[[self alloc] initWithInt16: int16] autorelease];
}

+ numberWithInt32: (int32_t)int32
{
	return [[[self alloc] initWithInt32: int32] autorelease];
}

+ numberWithInt64: (int64_t)int64
{
	return [[[self alloc] initWithInt64: int64] autorelease];
}

+ numberWithUInt8: (uint8_t)uint8
{
	return [[[self alloc] initWithUInt8: uint8] autorelease];
}

+ numberWithUInt16: (uint16_t)uint16
{
	return [[[self alloc] initWithUInt16: uint16] autorelease];
}

+ numberWithUInt32: (uint32_t)uint32
{
	return [[[self alloc] initWithUInt32: uint32] autorelease];
}

+ numberWithUInt64: (uint64_t)uint64
{
	return [[[self alloc] initWithUInt64: uint64] autorelease];
}

+ numberWithSize: (size_t)size
{
	return [[[self alloc] initWithSize: size] autorelease];
}

+ numberWithSSize: (ssize_t)ssize
{
	return [[[self alloc] initWithSSize: ssize] autorelease];
}

+ numberWithPtrDiff: (ptrdiff_t)ptrdiff
{
	return [[[self alloc] initWithPtrDiff: ptrdiff] autorelease];
}

+ numberWithIntPtr: (intptr_t)intptr
{
	return [[[self alloc] initWithIntPtr: intptr] autorelease];
}

+ numberWithFloat: (float)float_
{
	return [[[self alloc] initWithFloat: float_] autorelease];
}

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

+ numberWithLongDouble: (long double)longdouble
{
	return [[[self alloc] initWithLongDouble: longdouble] autorelease];
}

- initWithChar: (char)char_
{
	if ((self = [super init])) {
		value.char_ = char_;
		type = OF_NUMBER_CHAR;







|




|




|




|




|




|




|




|




|




|




|




|




|




|




|




|




|




|




|




|




|




|




|







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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
		/* Make gcc happy */					      \
		return 0;						      \
	}

@implementation OFNumber
+ numberWithChar: (char)char_
{
	return [[[OFNumber alloc] initWithChar: char_] autorelease];
}

+ numberWithShort: (short)short_
{
	return [[[OFNumber alloc] initWithShort: short_] autorelease];
}

+ numberWithInt: (int)int_
{
	return [[[OFNumber alloc] initWithInt: int_] autorelease];
}

+ numberWithLong: (long)long_
{
	return [[[OFNumber alloc] initWithLong: long_] autorelease];
}

+ numberWithUChar: (unsigned char)uchar
{
	return [[[OFNumber alloc] initWithUChar: uchar] autorelease];
}

+ numberWithUShort: (unsigned short)ushort
{
	return [[[OFNumber alloc] initWithUShort: ushort] autorelease];
}

+ numberWithUInt: (unsigned int)uint
{
	return [[[OFNumber alloc] initWithUInt: uint] autorelease];
}

+ numberWithULong: (unsigned long)ulong
{
	return [[[OFNumber alloc] initWithULong: ulong] autorelease];
}

+ numberWithInt8: (int8_t)int8
{
	return [[[OFNumber alloc] initWithInt8: int8] autorelease];
}

+ numberWithInt16: (int16_t)int16
{
	return [[[OFNumber alloc] initWithInt16: int16] autorelease];
}

+ numberWithInt32: (int32_t)int32
{
	return [[[OFNumber alloc] initWithInt32: int32] autorelease];
}

+ numberWithInt64: (int64_t)int64
{
	return [[[OFNumber alloc] initWithInt64: int64] autorelease];
}

+ numberWithUInt8: (uint8_t)uint8
{
	return [[[OFNumber alloc] initWithUInt8: uint8] autorelease];
}

+ numberWithUInt16: (uint16_t)uint16
{
	return [[[OFNumber alloc] initWithUInt16: uint16] autorelease];
}

+ numberWithUInt32: (uint32_t)uint32
{
	return [[[OFNumber alloc] initWithUInt32: uint32] autorelease];
}

+ numberWithUInt64: (uint64_t)uint64
{
	return [[[OFNumber alloc] initWithUInt64: uint64] autorelease];
}

+ numberWithSize: (size_t)size
{
	return [[[OFNumber alloc] initWithSize: size] autorelease];
}

+ numberWithSSize: (ssize_t)ssize
{
	return [[[OFNumber alloc] initWithSSize: ssize] autorelease];
}

+ numberWithPtrDiff: (ptrdiff_t)ptrdiff
{
	return [[[OFNumber alloc] initWithPtrDiff: ptrdiff] autorelease];
}

+ numberWithIntPtr: (intptr_t)intptr
{
	return [[[OFNumber alloc] initWithIntPtr: intptr] autorelease];
}

+ numberWithFloat: (float)float_
{
	return [[[OFNumber alloc] initWithFloat: float_] autorelease];
}

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

+ numberWithLongDouble: (long double)longdouble
{
	return [[[OFNumber alloc] initWithLongDouble: longdouble] autorelease];
}

- initWithChar: (char)char_
{
	if ((self = [super init])) {
		value.char_ = char_;
		type = OF_NUMBER_CHAR;

Modified src/OFString.m from [f753114c1f] to [69097c8dd7].

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

	return (utf8 ? 1 : 0);
}

@implementation OFString
+ string
{
	return [[[self alloc] init] autorelease];
}

+ stringWithCString: (const char*)str
{
	return [[[self alloc] initWithCString: str] autorelease];
}

+ stringWithFormat: (const char*)fmt, ...
{
	id ret;
	va_list args;

	va_start(args, fmt);
	ret = [[[self alloc] initWithFormat: fmt
			       andArguments: args] autorelease];
	va_end(args);

	return ret;
}

+ stringWithFormat: (const char*)fmt
      andArguments: (va_list)args
{
	return [[[self alloc] initWithFormat: fmt
				andArguments: args] autorelease];
}

- init
{
	if ((self = [super init])) {
		length = 0;







|




|








|









|







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

	return (utf8 ? 1 : 0);
}

@implementation OFString
+ string
{
	return [[[OFString alloc] init] autorelease];
}

+ stringWithCString: (const char*)str
{
	return [[[OFString alloc] initWithCString: str] autorelease];
}

+ stringWithFormat: (const char*)fmt, ...
{
	id ret;
	va_list args;

	va_start(args, fmt);
	ret = [[[OFString alloc] initWithFormat: fmt
			       andArguments: args] autorelease];
	va_end(args);

	return ret;
}

+ stringWithFormat: (const char*)fmt
      andArguments: (va_list)args
{
	return [[[OFString alloc] initWithFormat: fmt
				andArguments: args] autorelease];
}

- init
{
	if ((self = [super init])) {
		length = 0;

Modified src/OFTCPSocket.m from [c9f6264550] to [bf7391c607].

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef INVALID_SOCKET
#define INVALID_SOCKET -1
#endif

@implementation OFTCPSocket
+ tcpSocket
{
	return [[[self alloc] init] autorelease];
}

#ifdef _WIN32
+ (void)initialize
{
	WSADATA wsa;








|







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef INVALID_SOCKET
#define INVALID_SOCKET -1
#endif

@implementation OFTCPSocket
+ tcpSocket
{
	return [[[OFTCPSocket alloc] init] autorelease];
}

#ifdef _WIN32
+ (void)initialize
{
	WSADATA wsa;