ObjFW  Check-in [2edae50b86]

Overview
Comment:Move ObjC feature checks to OFObject.h.

This way, it is theoretically possible to compile ObjFW with one
compiler and then use it with another.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2edae50b86bc3dfc09d2b8bb99a40dca999b6ff7bed488bbff8202eb997fa47a
User & Date: js on 2012-10-03 15:47:15
Other Links: manifest | tags
Context
2012-10-05
09:54
Add -[OFDataArray description]. check-in: 23ad67cdf7 user: js tags: trunk
2012-10-03
15:47
Move ObjC feature checks to OFObject.h. check-in: 2edae50b86 user: js tags: trunk
15:41
Move definition of restricted to OFObject.h. check-in: 7239333455 user: js tags: trunk
Changes

Modified configure.ac from [0c2ce536c1] to [cc4568e947].

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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-














-



-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-










-







AX_CHECK_COMPILER_FLAGS(-Wshorten-64-to-32,
	[OBJCFLAGS="$OBJCFLAGS -Wshorten-64-to-32"])
AX_CHECK_COMPILER_FLAGS(-Wsemicolon-before-method-body,
	[OBJCFLAGS="$OBJCFLAGS -Wsemicolon-before-method-body"])
AX_CHECK_COMPILER_FLAGS(-Wno-objc-root-class,
	[OBJCFLAGS="$OBJCFLAGS -Wno-objc-root-class"])

AC_MSG_CHECKING(whether Objective C compiler supports fast enumeration)
AC_TRY_COMPILE([
	@protocol OFFastEnumeration
	- (int)countByEnumeratingWithState: (void*)state
				   objects: (id*)objects
				     count: (int)count;
	@end
], [
	id n = (id)0;
	for (id i in n);
], [
	AC_DEFINE(OF_HAVE_FAST_ENUMERATION, 1,
		[Compiler support for Fast Enumeration])
	AC_MSG_RESULT(yes)
], [
	AC_MSG_RESULT(no)
])

AC_MSG_CHECKING(whether Objective C compiler supports properties)
AC_TRY_COMPILE([
	@interface Foo
	{
		id bar;
	}

	@property (retain, nonatomic) id bar;
	@end
], [
	Foo *foo = (id)0;
	[foo setBar: (id)0];
	[foo bar];
], [
	AC_DEFINE(OF_HAVE_PROPERTIES, 1, [Compiler support for properties])
	AC_SUBST(PROPERTIESTESTS_M, "PropertiesTests.m")
	AC_MSG_RESULT(yes)
], [
	AC_MSG_RESULT(no)
])

AC_MSG_CHECKING(whether Objective C compiler supports optional protocols)
AC_TRY_COMPILE([
	@protocol Proto
	@optional
	+ (void)foo;
	@end

	@interface Foo <Proto>
	@end

	@implementation Foo
	@end
], [
	[Foo foo];
], [
	AC_DEFINE(OF_HAVE_OPTIONAL_PROTOCOLS, 1,
		[Compiler support for optional protocols])
	AC_MSG_RESULT(yes)
], [
	AC_MSG_RESULT(no)
])

AC_MSG_CHECKING(whether Objective C compiler supports blocks)
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -fblocks"
AC_TRY_COMPILE([], [
	int (^foo)(int bar);
	foo = ^ (int bar) { return 0; }
], [
	AC_DEFINE(OF_HAVE_BLOCKS, 1, [Compiler support for blocks])
	AC_SUBST(BLOCKS_FLAGS, "-fblocks")
	AC_SUBST(OFBLOCKTESTS_M, "OFBlockTests.m")
	AC_MSG_RESULT(yes)
], [
	AC_MSG_RESULT(no)
	OBJCFLAGS="$old_OBJCFLAGS"
])

Modified src/OFObject.h from [d0b36af00e] to [5242dae164].

42
43
44
45
46
47
48
















49
50
51
52
53
54
55
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







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







#elif __STDC_VERSION__ < 199901L
# define restrict
#endif

#ifndef __has_feature
# define __has_feature(x) 0
#endif

#if defined(__clang__)
# define OF_HAVE_PROPERTIES
# define OF_HAVE_OPTIONAL_PROTOCOLS
# define OF_HAVE_FAST_ENUMERATION
#elif defined(__GNUC__)
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#  define OF_HAVE_PROPERTIES
#  define OF_HAVE_OPTIONAL_PROTOCOLS
#  define OF_HAVE_FAST_ENUMERATION
# endif
#endif

#if __has_feature(blocks)
# define OF_HAVE_BLOCKS
#endif

#if __has_feature(objc_bool)
# undef YES
# define YES __objc_yes
# undef NO
# define NO __objc_no
#endif

Modified src/objfw-defs.h.in from [13f2356be6] to [2392df0876].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1
2
3
4
5
6


7

8
9

10
11
12
13
14
15
16
17
18






-
-

-


-









#undef OF_APPLE_RUNTIME
#undef OF_ATOMIC_OPS
#undef OF_BIG_ENDIAN
#undef OF_COMPILER_TLS
#undef OF_FLOAT_BIG_ENDIAN
#undef OF_HAVE_ASPRINTF
#undef OF_HAVE_BLOCKS
#undef OF_HAVE_FAST_ENUMERATION
#undef OF_HAVE_GCC_ATOMIC_OPS
#undef OF_HAVE_OPTIONAL_PROTOCOLS
#undef OF_HAVE_OSATOMIC
#undef OF_HAVE_OSATOMIC_64
#undef OF_HAVE_PROPERTIES
#undef OF_HAVE_PTHREADS
#undef OF_HAVE_PTHREAD_SPINLOCKS
#undef OF_HAVE_RECURSIVE_PTHREAD_MUTEXES
#undef OF_HAVE_SCHED_YIELD
#undef OF_HAVE_SYS_SELECT_H
#undef OF_OBJFW_RUNTIME
#undef OF_PLUGINS
#undef OF_THREADS
#undef SIZE_MAX