summaryrefslogtreecommitdiff
path: root/Objective-C
diff options
context:
space:
mode:
Diffstat (limited to 'Objective-C')
-rw-r--r--Objective-C/PyObjC/pyobjc-compat.h95
-rw-r--r--Objective-C/PyObjC/pyobjc.h9
2 files changed, 104 insertions, 0 deletions
diff --git a/Objective-C/PyObjC/pyobjc-compat.h b/Objective-C/PyObjC/pyobjc-compat.h
new file mode 100644
index 0000000..20e7301
--- /dev/null
+++ b/Objective-C/PyObjC/pyobjc-compat.h
@@ -0,0 +1,95 @@
+#ifndef PyObjC_COMPAT_H
+#define PyObjC_COMPAT_H
+
+/*
+ * Compatibilty definitions
+ */
+
+#ifdef __GNUC__
+#define unlikely(x) __builtin_expect (!!(x), 0)
+#define likely(x) __builtin_expect (!!(x), 1)
+#else
+#define likely(x) x
+#define likely(x) x
+#endif
+
+#import <AvailabilityMacros.h>
+/* On 10.1 there are no defines for the OS version. */
+#ifndef MAC_OS_X_VERSION_10_1
+#define MAC_OS_X_VERSION_10_1 1010
+#define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_10_1
+
+#error "MAC_OS_X_VERSION_10_1 not defined. You aren't running 10.1 are you?"
+
+#endif
+
+
+#ifndef MAC_OS_X_VERSION_10_2
+#define MAC_OS_X_VERSION_10_2 1020
+#endif
+
+#ifndef MAC_OS_X_VERSION_10_3
+#define MAC_OS_X_VERSION_10_3 1030
+#endif
+
+#ifndef MAC_OS_X_VERSION_10_4
+#define MAC_OS_X_VERSION_10_4 1040
+#endif
+
+#ifndef MAC_OS_X_VERSION_10_5
+#define MAC_OS_X_VERSION_10_5 1050
+#endif
+
+
+/* On some versions of GCC <limits.h> defines LONG_LONG_MAX but not LLONG_MAX,
+ * compensate.
+ */
+#ifndef LLONG_MIN
+#ifdef LONG_LONG_MIN
+#define LLONG_MIN LONG_LONG_MIN
+#define LLONG_MAX LONG_LONG_MAX
+#define ULLONG_MAX ULONG_LONG_MAX
+#endif
+#endif
+
+#if (PY_VERSION_HEX < 0x02050000)
+typedef int Py_ssize_t;
+#define PY_FORMAT_SIZE_T ""
+#define Py_ARG_SIZE_T "i"
+#define PY_SSIZE_T_MAX INT_MAX
+
+#else
+
+#ifndef Py_ARG_SIZE_T
+#define Py_ARG_SIZE_T "n"
+#endif
+
+#endif
+
+
+/* NSInteger and friends are available on Leopard and later, define them here
+ * for compatibility with earlier versions.
+ *
+ * Note that the guard definition is the same as used by Leopard itself.
+ */
+#import <Foundation/NSObjCRuntime.h>
+
+#ifndef NSINTEGER_DEFINED
+
+#ifdef __LP64__
+# error "Huh? 64-bit but no NSINTEGER available???"
+#endif
+
+typedef int NSInteger;
+typedef unsigned int NSUInteger;
+
+#define NSIntegerMax LONG_MAX
+#define NSIntegerMin LONG_MIN
+#define NSUIntegerMax ULONG_MAX
+
+#define NSINTEGER_DEFINED
+
+#endif
+
+
+#endif /* PyObjC_COMPAT_H */
diff --git a/Objective-C/PyObjC/pyobjc.h b/Objective-C/PyObjC/pyobjc.h
index 6a2d6b4..3a159c8 100644
--- a/Objective-C/PyObjC/pyobjc.h
+++ b/Objective-C/PyObjC/pyobjc.h
@@ -7,6 +7,15 @@
#include <stdio.h>
#include "libobjcl.h"
+#ifdef __NEXT_RUNTIME__
+#include "pyobjc-compat.h"
+#endif
+
+#ifndef __OBJC2__
+#define NO_OBJC2_RUNTIME
+#endif
+
+/* #define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_4 */
#ifdef __NEXT_RUNTIME__