ObjFW  Check-in [2cb37ce407]

Overview
Comment:Change -[retainCount] back to size_t and cast, so we keep the old API.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2cb37ce407d9418dbeef08649209cf80b7c2a8094dbd344ce2d141561ed55e73
User & Date: js on 2010-01-30 12:46:47
Other Links: manifest | tags
Context
2010-01-30
13:33
Move some stuff from OFSocket to OFTCPSocket. check-in: fe6787bc79 user: js tags: trunk
12:46
Change -[retainCount] back to size_t and cast, so we keep the old API. check-in: 2cb37ce407 user: js tags: trunk
12:33
Convert more macros to OF_INLINE functions. check-in: 8acda3b3fd user: js tags: trunk
Changes

Modified src/OFConstString.m from [d39251187d] to [d9b21f0f8e].

134
135
136
137
138
139
140
141

142
143

144
145
146
147
148
149
150
151
152
153
154
155
156
134
135
136
137
138
139
140

141
142

143
144
145
146
147
148
149
150
151
152
153
154
155
156







-
+

-
+













}

- autorelease
{
	return self;
}

- (int32_t)retainCount
- (size_t)retainCount
{
	return INT32_MAX;
	return SIZE_MAX;
}

- (void)release
{
}

- (void)dealloc
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	[super dealloc];	/* Get rid of a stupid warning */
}
@end

Modified src/OFFile.m from [f0b3a13578] to [cfa00f6d8b].

255
256
257
258
259
260
261
262

263
264

265
266
267
268
269
270
271
272
273
255
256
257
258
259
260
261

262
263

264
265
266
267
268
269
270
271
272
273







-
+

-
+









	return self;
}

- (void)release
{
}

- (int32_t)retainCount
- (size_t)retainCount
{
	return INT32_MAX;
	return SIZE_MAX;
}

- (void)dealloc
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
	[super dealloc];	/* Get rid of stupid warning */
}
@end

Modified src/OFObject.h from [58427ce6f5] to [9367c723f3].

262
263
264
265
266
267
268
269

270
271
272
273
274
275
276
262
263
264
265
266
267
268

269
270
271
272
273
274
275
276







-
+







 * object deallocated if it reaches 0.
 */
- retain;

/**
 * \return The retain count
 */
- (int32_t)retainCount;
- (size_t)retainCount;

/**
 * Decreases the retain count.
 *
 * Each time an object is released, the retain count gets decreased and the
 * object deallocated if it reaches 0.
 */

Modified src/OFObject.m from [7ae92c5eec] to [695579ca2f].

26
27
28
29
30
31
32

33
34

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

35

36
37
38
39
40
41
42







+

-
+
-







#ifdef OF_APPLE_RUNTIME
# import <objc/runtime.h>
#endif
#ifdef OF_GNU_RUNTIME
# import <objc/sarray.h>
#endif

#ifdef OF_ATOMIC_OPS
#import "atomic.h"

#else
#ifndef OF_ATOMIC_OPS
#import "threading.h"
#endif

struct pre_ivar {
	void	      **memchunks;
	size_t	      memchunks_size;
	int32_t	      retain_count; /* int32_t because atomic ops use int32_t */
508
509
510
511
512
513
514
515

516

517

518
519
520
521
522
523

524
525
526

527
528
529
530
531
532
533
508
509
510
511
512
513
514

515
516
517

518
519
520
521
522
523

524
525
526

527
528
529
530
531
532
533
534







-
+

+
-
+





-
+


-
+







	PRE_IVAR->retain_count++;
	assert(of_spinlock_unlock(&PRE_IVAR->retain_spinlock));
#endif

	return self;
}

- (int32_t)retainCount
- (size_t)retainCount
{
	assert(PRE_IVAR->retain_count >= 0);
	return PRE_IVAR->retain_count;
	return (size_t)PRE_IVAR->retain_count;
}

- (void)release
{
#ifdef OF_ATOMIC_OPS
	if (!of_atomic_dec32(&PRE_IVAR->retain_count))
	if (of_atomic_dec32(&PRE_IVAR->retain_count) <= 0)
		[self dealloc];
#else
	int32_t c;
	size_t c;

	assert(of_spinlock_lock(&PRE_IVAR->retain_spinlock));
	c = --PRE_IVAR->retain_count;
	assert(of_spinlock_unlock(&PRE_IVAR->retain_spinlock));

	if (!c)
		[self dealloc];
623
624
625
626
627
628
629
630

631
632

633
634
635
636
637
638
639
624
625
626
627
628
629
630

631
632

633
634
635
636
637
638
639
640







-
+

-
+







}

+ autorelease
{
	return self;
}

+ (int32_t)retainCount
+ (size_t)retainCount
{
	return INT32_MAX;
	return SIZE_MAX;
}

+ (void)release
{
}

+ (void)dealloc