ObjFW  Check-in [a2effa2a7f]

Overview
Comment:Check for fast enumeration support in compiler and run tests.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: a2effa2a7feaec3afdddb359d2cd4317fb2df60e4029994e656afee3b73eed99
User & Date: js on 2010-01-03 18:39:49
Other Links: manifest | tags
Context
2010-01-03
18:48
Check for objc_enumerationMutation and provide it if it's missing. check-in: 2c40c95434 user: js tags: trunk
18:39
Check for fast enumeration support in compiler and run tests. check-in: a2effa2a7f user: js tags: trunk
18:28
Implement fast enumeration for OFArray. check-in: 45869ac8ac user: js tags: trunk
Changes

Modified configure.ac from [0b6d5ca915] to [9b2731e7d3].

18
19
20
21
22
23
24












25
26
27
28
29
30
31

AX_CHECK_COMPILER_FLAGS(-pipe, [OBJCFLAGS="$OBJCFLAGS -pipe"])
AX_CHECK_COMPILER_FLAGS(-fno-common, [OBJCFLAGS="$OBJCFLAGS -fno-common"])
AX_CHECK_COMPILER_FLAGS(-fno-constant-cfstrings, [
	NO_CONST_CFSTRINGS="-fno-constant-cfstrings"
	OBJCFLAGS="$OBJCFLAGS -fno-constant-cfstrings"])
AC_SUBST(NO_CONST_CFSTRINGS)













AC_MSG_CHECKING(which Objective C runtime we use)
dnl TODO: This is ugly. Let's think of a better check.
AC_EGREP_CPP(gnu, [
	#import <objc/objc.h>
	#ifdef __objc_INCLUDE_GNU
	gnu







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







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

AX_CHECK_COMPILER_FLAGS(-pipe, [OBJCFLAGS="$OBJCFLAGS -pipe"])
AX_CHECK_COMPILER_FLAGS(-fno-common, [OBJCFLAGS="$OBJCFLAGS -fno-common"])
AX_CHECK_COMPILER_FLAGS(-fno-constant-cfstrings, [
	NO_CONST_CFSTRINGS="-fno-constant-cfstrings"
	OBJCFLAGS="$OBJCFLAGS -fno-constant-cfstrings"])
AC_SUBST(NO_CONST_CFSTRINGS)

AC_MSG_CHECKING(whether Objective C compiler supports fast enumeration)
AC_TRY_COMPILE([
	#import <objc/objc.h>
	], [
	id n = nil;
	for (id i in n);
	], [
	AC_DEFINE(OF_HAVE_FAST_ENUMERATION, 1, [Fast Enumeration support])
	AC_MSG_RESULT(yes)
	], [
	AC_MSG_RESULT(no)])

AC_MSG_CHECKING(which Objective C runtime we use)
dnl TODO: This is ugly. Let's think of a better check.
AC_EGREP_CPP(gnu, [
	#import <objc/objc.h>
	#ifdef __objc_INCLUDE_GNU
	gnu
141
142
143
144
145
146
147
148

149
150
151
152
153
154
155
	#ifndef _WIN32
	#include <sys/types.h>
	#include <sys/socket.h>
	#include <netdb.h>
	#else
	#define _WIN32_WINNT 0x0501
	#include <ws2tcpip.h>
	#endif], [

	struct addrinfo ai;
	getaddrinfo(NULL, NULL, NULL, NULL);
	], [
	AC_MSG_RESULT(yes)
	AC_DEFINE(HAVE_GETADDRINFO, 1, [Whether we have getaddrinfo])

	if test x"$enable_threads" != x"no"; then







|
>







153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
	#ifndef _WIN32
	#include <sys/types.h>
	#include <sys/socket.h>
	#include <netdb.h>
	#else
	#define _WIN32_WINNT 0x0501
	#include <ws2tcpip.h>
	#endif
	], [
	struct addrinfo ai;
	getaddrinfo(NULL, NULL, NULL, NULL);
	], [
	AC_MSG_RESULT(yes)
	AC_DEFINE(HAVE_GETADDRINFO, 1, [Whether we have getaddrinfo])

	if test x"$enable_threads" != x"no"; then

Modified tests/OFArray.m from [dad59ff475] to [927bb4293a].

61
62
63
64
65
66
67













68
69
70
71
72
73
74
	    [[a[2] objectAtIndex: 1] isEqual: c_ary[1]] &&
	    [[a[2] objectAtIndex: 2] isEqual: c_ary[2]])

	TEST(@"-[indexOfObject:]", [a[0] indexOfObject: c_ary[1]] == 1)

	TEST(@"-[indexOfObjectIdenticalTo:]",
	    [a[0] indexOfObjectIdenticalTo: c_ary[1]] == 1)














	TEST(@"-[replaceObject:withObject:]",
	    [a[0] replaceObject: c_ary[1]
		     withObject: c_ary[0]] &&
	    [[a[0] objectAtIndex: 0] isEqual: c_ary[0]] &&
	    [[a[0] objectAtIndex: 1] isEqual: c_ary[0]] &&
	    [[a[0] objectAtIndex: 2] isEqual: c_ary[2]])







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







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
	    [[a[2] objectAtIndex: 1] isEqual: c_ary[1]] &&
	    [[a[2] objectAtIndex: 2] isEqual: c_ary[2]])

	TEST(@"-[indexOfObject:]", [a[0] indexOfObject: c_ary[1]] == 1)

	TEST(@"-[indexOfObjectIdenticalTo:]",
	    [a[0] indexOfObjectIdenticalTo: c_ary[1]] == 1)

#ifdef OF_HAVE_FAST_ENUMERATION
	size_t i = 0;
	BOOL ok = YES;

	for (OFString *s in a[0]) {
		if (![s isEqual: c_ary[i]])
			ok = NO;
		i++;
	}

	TEST(@"Fast Enumeration", ok)
#endif

	TEST(@"-[replaceObject:withObject:]",
	    [a[0] replaceObject: c_ary[1]
		     withObject: c_ary[0]] &&
	    [[a[0] objectAtIndex: 0] isEqual: c_ary[0]] &&
	    [[a[0] objectAtIndex: 1] isEqual: c_ary[0]] &&
	    [[a[0] objectAtIndex: 2] isEqual: c_ary[2]])