ObjFW  Check-in [f8005a79c1]

Overview
Comment:Completely remove tests/OFAutoreleasePool, it's for the old version.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f8005a79c10daf6fffffddd39a9074c0451b3615daac6afd0a065599eac592b5
User & Date: js on 2009-09-16 17:22:42
Other Links: manifest | tags
Context
2009-09-16
17:23
A few very small mingw32 fixes. check-in: 0375b1e0ea user: js tags: trunk
17:22
Completely remove tests/OFAutoreleasePool, it's for the old version. check-in: f8005a79c1 user: js tags: trunk
16:22
Rework OFAutoreleasePool and remove now unnecessary hack from OFList. check-in: a99f512a4a user: js tags: trunk
Changes

Deleted tests/OFAutoreleasePool/Makefile version [1170abbd81].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
PROG_NOINST = ofautoreleasepool${PROG_SUFFIX}
SRCS = OFAutoreleasePool.m

include ../../buildsys.mk
include ../../extra.mk

CPPFLAGS += -I../../src -I../..
LIBS := -L../../src -lobjfw ${LIBS}

.PHONY: run

all: run
run: ${PROG_NOINST}
	rm -f libobjfw.so.0 libobjfw.so.0.1 libobjfw.dll libobjfw.dylib
	ln -s ../../src/libobjfw.so libobjfw.so.0
	ln -s ../../src/libobjfw.so libobjfw.so.0.1
	if test -f ../../src/libobjfw.dll; then \
		ln ../../src/libobjfw.dll libobjfw.dll; \
	fi
	ln -s ../../src/libobjfw.dylib libobjfw.dylib
	LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \
	DYLD_LIBRARY_PATH=.$${DYLD_LIBRARY_PATH+:}$$DYLD_LIBRARY_PATH \
	${TEST_LAUNCHER} ./${PROG_NOINST}; EXIT=$$?; \
	rm -f libobjfw.so.0 libobjfw.so.0.1 libobjfw.dll libobjfw.dylib; \
	exit $$EXIT
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































Deleted tests/OFAutoreleasePool/OFAutoreleasePool.m version [33e54774eb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
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
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#include "config.h"

#include <stdio.h>

#import "OFAutoreleasePool.h"

#ifndef _WIN32
#define ZD "%zd"
#else
#define ZD "%u"
#endif

int inits;
int retains;
int releases;

IMP init;
IMP retain;
IMP release;

@interface TestObject: OFObject
- init;
- retain;
- (void)release;
@end

@implementation TestObject
- init
{
	id ret;

	inits++;

	ret = init(self, _cmd);
	printf("New %s with retain cnt " ZD "\n", [self className],
	    [ret retainCount]);

	return ret;
}

- retain
{
	id ret;

	retains++;

	ret = retain(self, _cmd);
	printf("Retaining %s to " ZD "\n", [self className], [ret retainCount]);

	return ret;
}

- (void)release
{
	releases++;

	printf("Releasing %s to " ZD "\n", [self className],
	    [self retainCount] - 1);
	release(self, _cmd);
}
@end

int
main()
{
	inits = retains = releases = 0;

	init    = [OFObject replaceMethod: @selector(init)
		      withMethodFromClass: [TestObject class]];
	retain  = [OFObject replaceMethod: @selector(retain)
		      withMethodFromClass: [TestObject class]];
	release = [OFObject replaceMethod: @selector(release)
		      withMethodFromClass: [TestObject class]];

	OFObject *o1, *o2, *o3;
	OFAutoreleasePool *pool1, *pool2;

	o1 = [[[OFObject alloc] init] autorelease];

	pool1 = [[OFAutoreleasePool alloc] init];
	o2 = [[[OFObject alloc] init] autorelease];
	[pool1 releaseObjects];

	o2 = [[[OFObject alloc] init] autorelease];

	pool2 = [[OFAutoreleasePool alloc] init];
	o3 = [[[OFObject alloc] init] autorelease];

	[pool1 release];

	printf("inits:    %02d\nretains:  %02d\nreleases: %02d\n",
	   inits, retains, releases);
	return (inits == 17 && retains == 5 && releases == 16 ? 0 : 1);
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<