ObjFW  Check-in [8de8df50e9]

Overview
Comment:Make the return type of retainCount unsigned int.
This way, the OFObject protocol is compatible to NSObject.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 8de8df50e987a977450a3b0a74f59003e3cd5a3d9d0570c340fa6c19cad485ce
User & Date: js on 2011-03-23 12:58:36
Other Links: manifest | tags
Context
2011-03-23
13:05
Use OF_INVALID_INDEX instead of SIZE_MAX. check-in: a252dc5c69 user: js tags: trunk
12:58
Make the return type of retainCount unsigned int.
This way, the OFObject protocol is compatible to NSObject.
check-in: 8de8df50e9 user: js tags: trunk
01:14
Work around GCC bugs. check-in: 4444a8c246 user: js tags: trunk
Changes

Modified src/OFBlock.m from [1de0172b54] to [1ed9ce6a37].

405
406
407
408
409
410
411
412

413
414
415
416
417
418

419
420
421
422
423
424
425
405
406
407
408
409
410
411

412
413
414
415
416
417

418
419
420
421
422
423
424
425







-
+





-
+







{
	if (isa == (Class)&_NSConcreteMallocBlock)
		return [super autorelease];

	return self;
}

- (size_t)retainCount
- (unsigned int)retainCount
{
	if (isa == (Class)&_NSConcreteMallocBlock)
		return ((of_block_literal_t*)self)->flags &
		    OF_BLOCK_REFCOUNT_MASK;

	return SIZE_MAX;
	return OF_RETAIN_COUNT_MAX;
}

- (void)release
{
	Block_release(self);
}

Modified src/OFConstantString.m from [5e08953a1a] to [42c1e31ffa].

144
145
146
147
148
149
150
151

152
153

154
155
156
157
158
159
160
161
162
163
164
165
166
144
145
146
147
148
149
150

151
152

153
154
155
156
157
158
159
160
161
162
163
164
165
166







-
+

-
+













}

- autorelease
{
	return self;
}

- (size_t)retainCount
- (unsigned int)retainCount
{
	return SIZE_MAX;
	return OF_RETAIN_COUNT_MAX;
}

- (void)release
{
}

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

Modified src/OFExceptions.m from [cd4f398255] to [cb05df6236].

123
124
125
126
127
128
129
130

131
132

133
134
135
136
137
138
139
123
124
125
126
127
128
129

130
131

132
133
134
135
136
137
138
139







-
+

-
+







}

- autorelease
{
	return self;
}

- (size_t)retainCount
- (unsigned int)retainCount
{
	return SIZE_MAX;
	return OF_RETAIN_COUNT_MAX;
}

- (void)release
{
}

- (void)dealloc

Modified src/OFFile.m from [3a17566619] to [80c543eb4d].

640
641
642
643
644
645
646
647

648
649

650
651
652
653
654
655
656
640
641
642
643
644
645
646

647
648

649
650
651
652
653
654
655
656







-
+

-
+







	return self;
}

- (void)release
{
}

- (size_t)retainCount
- (unsigned int)retainCount
{
	return SIZE_MAX;
	return OF_RETAIN_COUNT_MAX;
}

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

Modified src/OFObject.h from [2a5a45e545] to [1c80d73d6b].

29
30
31
32
33
34
35


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







+
+








#ifdef OF_OBJFW_RUNTIME
# import <objfw-rt.h>
#else
# import <objc/objc.h>
#endif

#define OF_RETAIN_COUNT_MAX UINT_MAX

/**
 * \brief A result of a comparison.
 */
typedef enum of_comparison_result_t {
	/// The left object is smaller than the right
	OF_ORDERED_ASCENDING = -1,
	/// Both objects are equal
106
107
108
109
110
111
112
113

114
115
116
117
118
119
120
108
109
110
111
112
113
114

115
116
117
118
119
120
121
122







-
+







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

/**
 * \return The retain count
 */
- (size_t)retainCount;
- (unsigned int)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 [73e373ae9d] to [e58d7ba883].

698
699
700
701
702
703
704
705

706
707
708

709
710
711
712
713
714
715
698
699
700
701
702
703
704

705
706
707

708
709
710
711
712
713
714
715







-
+


-
+







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

	return self;
}

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

- (void)release
{
#if defined(OF_ATOMIC_OPS)
	if (of_atomic_dec_32(&PRE_IVAR->retain_count) <= 0)
		[self dealloc];
837
838
839
840
841
842
843
844

845
846

847
848
849
850
851
852
853
837
838
839
840
841
842
843

844
845

846
847
848
849
850
851
852
853







-
+

-
+







}

+ autorelease
{
	return self;
}

+ (size_t)retainCount
+ (unsigned int)retainCount
{
	return SIZE_MAX;
	return OF_RETAIN_COUNT_MAX;
}

+ (void)release
{
}

+ (void)dealloc