summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Schleifer <js@heap.zone>2018-04-22 18:13:04 +0200
committerJonathan Schleifer <js@heap.zone>2018-04-22 18:13:04 +0200
commitbd945d82640c9aa84f66931a87609a2eab3750cb (patch)
tree38dd34c15517cba434d9493938b92bdad2553c17
parent4a8d968b6d12984dfb0bd085d1626f78c0177a61 (diff)
runtime: Define BOOL to be the same as bool
As we define the ABI, we can just replace BOOL with bool everywhere, including in ObjFW itself. For the Apple platforms where BOOL and bool are different, this is not a problem as BOOL and bool are passed and returned the same way in the ABI. This still defines BOOL to bool for compatibility, except on AmigaOS and Wii, which both have its own BOOL type.
-rw-r--r--src/OFApplication.m2
-rw-r--r--src/OFFile.h2
-rw-r--r--src/OFFile.m2
-rw-r--r--src/OFFileManager.m2
-rw-r--r--src/OFLocalization.m2
-rw-r--r--src/OFObject.h4
-rw-r--r--src/OFObject.m4
-rw-r--r--src/OFStdIOStream.h2
-rw-r--r--src/OFStdIOStream.m2
-rw-r--r--src/OFSystemInfo.m2
-rw-r--r--src/OFThread.m4
-rw-r--r--src/OFURLHandler_file.m2
-rw-r--r--src/runtime/ObjFW_RT.h18
-rw-r--r--src/runtime/class.m2
-rw-r--r--src/runtime/lookup.m4
-rw-r--r--src/runtime/morphos-library.m2
-rw-r--r--src/runtime/property.m12
-rw-r--r--src/runtime/protos.h8
-rw-r--r--src/socket.h8
-rw-r--r--src/unistd_wrapper.h8
-rw-r--r--tests/ForwardingTests.m4
-rw-r--r--tests/TestsAppDelegate.m2
22 files changed, 28 insertions, 70 deletions
diff --git a/src/OFApplication.m b/src/OFApplication.m
index 51d58574..0b951a1d 100644
--- a/src/OFApplication.m
+++ b/src/OFApplication.m
@@ -53,10 +53,8 @@
extern int _CRT_glob;
extern void __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, int *);
#elif defined(OF_MORPHOS)
-# define BOOL EXEC_BOOL
# include <proto/exec.h>
# include <proto/dos.h>
-# undef BOOL
#elif !defined(OF_IOS)
extern char **environ;
#endif
diff --git a/src/OFFile.h b/src/OFFile.h
index 3f858391..8698725f 100644
--- a/src/OFFile.h
+++ b/src/OFFile.h
@@ -23,9 +23,7 @@
# define OF_INVALID_FILE_HANDLE (-1)
typedef int of_file_handle_t;
#else
-# define BOOL EXEC_BOOL
# include <proto/dos.h>
-# undef BOOL
# define OF_INVALID_FILE_HANDLE NULL
typedef struct of_file_handle *of_file_handle_t;
#endif
diff --git a/src/OFFile.m b/src/OFFile.m
index 54af26bb..11816333 100644
--- a/src/OFFile.m
+++ b/src/OFFile.m
@@ -49,9 +49,7 @@
#endif
#ifdef OF_WII
-# define BOOL OGC_BOOL
# include <fat.h>
-# undef BOOL
#endif
#ifdef OF_NINTENDO_DS
diff --git a/src/OFFileManager.m b/src/OFFileManager.m
index 77366ca2..d55bdbb2 100644
--- a/src/OFFileManager.m
+++ b/src/OFFileManager.m
@@ -57,10 +57,8 @@
#endif
#ifdef OF_MORPHOS
-# define BOOL EXEC_BOOL
# include <proto/dos.h>
# include <proto/locale.h>
-# undef BOOL
#endif
@interface OFFileManager_default: OFFileManager
diff --git a/src/OFLocalization.m b/src/OFLocalization.m
index 139bab49..c4e28a58 100644
--- a/src/OFLocalization.m
+++ b/src/OFLocalization.m
@@ -35,11 +35,9 @@
# define __NOGLOBALIFACE__
# define __USE_INLINE__
# endif
-# define BOOL EXEC_BOOL
# include <proto/dos.h>
# include <proto/exec.h>
# include <proto/locale.h>
-# undef BOOL
#endif
static OFLocalization *sharedLocalization = nil;
diff --git a/src/OFObject.h b/src/OFObject.h
index 570ac5a3..3b355f4e 100644
--- a/src/OFObject.h
+++ b/src/OFObject.h
@@ -700,7 +700,7 @@ OF_ROOT_CLASS
*
* @return Whether the method has been added to the class
*/
-+ (BOOL)resolveClassMethod: (SEL)selector;
++ (bool)resolveClassMethod: (SEL)selector;
/*!
* @brief Try to resolve the specified instance method.
@@ -710,7 +710,7 @@ OF_ROOT_CLASS
*
* @return Whether the method has been added to the class
*/
-+ (BOOL)resolveInstanceMethod: (SEL)selector;
++ (bool)resolveInstanceMethod: (SEL)selector;
/*!
* @brief Returns the class.
diff --git a/src/OFObject.m b/src/OFObject.m
index 3fe7ea03..d27716dc 100644
--- a/src/OFObject.m
+++ b/src/OFObject.m
@@ -468,12 +468,12 @@ _references_to_categories_of_OFObject(void)
[self inheritMethodsFromClass: superclass];
}
-+ (BOOL)resolveClassMethod: (SEL)selector
++ (bool)resolveClassMethod: (SEL)selector
{
return NO;
}
-+ (BOOL)resolveInstanceMethod: (SEL)selector
++ (bool)resolveInstanceMethod: (SEL)selector
{
return NO;
}
diff --git a/src/OFStdIOStream.h b/src/OFStdIOStream.h
index b748da19..6b5ebf58 100644
--- a/src/OFStdIOStream.h
+++ b/src/OFStdIOStream.h
@@ -19,9 +19,7 @@
#import "OFKernelEventObserver.h"
#ifdef OF_MORPHOS
-# define BOOL EXEC_BOOL
# include <proto/dos.h>
-# undef BOOL
#endif
OF_ASSUME_NONNULL_BEGIN
diff --git a/src/OFStdIOStream.m b/src/OFStdIOStream.m
index 17883917..5c317dbb 100644
--- a/src/OFStdIOStream.m
+++ b/src/OFStdIOStream.m
@@ -42,9 +42,7 @@
#import "OFWriteFailedException.h"
#ifdef OF_MORPHOS
-# define BOOL EXEC_BOOL
# include <proto/exec.h>
-# undef BOOL
#endif
/* References for static linking */
diff --git a/src/OFSystemInfo.m b/src/OFSystemInfo.m
index 71040fff..ac3a40cc 100644
--- a/src/OFSystemInfo.m
+++ b/src/OFSystemInfo.m
@@ -33,10 +33,8 @@
#endif
#ifdef OF_MORPHOS
-# define BOOL EXEC_BOOL
# include <exec/system.h>
# include <proto/exec.h>
-# undef BOOL
#endif
#import "OFSystemInfo.h"
diff --git a/src/OFThread.m b/src/OFThread.m
index 1bfd7226..75c1a90a 100644
--- a/src/OFThread.m
+++ b/src/OFThread.m
@@ -33,16 +33,12 @@
#include "platform.h"
#ifdef OF_MORPHOS
-# define BOOL EXEC_BOOL
# include <proto/dos.h>
-# undef BOOL
#endif
#ifdef OF_WII
-# define BOOL OGC_BOOL
# define nanosleep ogc_nanosleep
# include <ogcsys.h>
-# undef BOOL
# undef nanosleep
#endif
diff --git a/src/OFURLHandler_file.m b/src/OFURLHandler_file.m
index 2e71afe1..6fadaa8a 100644
--- a/src/OFURLHandler_file.m
+++ b/src/OFURLHandler_file.m
@@ -67,10 +67,8 @@
#endif
#ifdef OF_MORPHOS
-# define BOOL EXEC_BOOL
# include <proto/dos.h>
# include <proto/locale.h>
-# undef BOOL
#endif
#if defined(OF_WINDOWS)
diff --git a/src/runtime/ObjFW_RT.h b/src/runtime/ObjFW_RT.h
index 5cefe380..ad5fc57d 100644
--- a/src/runtime/ObjFW_RT.h
+++ b/src/runtime/ObjFW_RT.h
@@ -55,13 +55,15 @@
#define Nil (Class _Null_unspecified)0
#define nil (id _Null_unspecified)0
-#define YES (BOOL)1
-#define NO (BOOL)0
+#define YES true
+#define NO false
typedef struct objc_class *Class;
typedef struct objc_object *id;
typedef const struct objc_selector *SEL;
-typedef signed char BOOL;
+#if !defined(OF_WII) && !defined(OF_AMIGAOS)
+typedef bool BOOL;
+#endif
typedef id _Nullable (*IMP)(id _Nonnull, SEL _Nonnull, ...);
typedef void (*objc_uncaught_exception_handler)(id _Nullable);
typedef void (*objc_enumeration_mutation_handler)(id _Nonnull);
@@ -249,9 +251,7 @@ extern void objc_zero_weak_references(id _Nonnull);
}
# endif
#else
-# define BOOL EXEC_BOOL
# include <ppcinline/macros.h>
-# undef BOOL
# ifdef __cplusplus
extern "C" {
# endif
@@ -288,13 +288,13 @@ extern void objc_exception_throw(id _Nullable);
extern int objc_sync_enter(id _Nullable);
extern int objc_sync_exit(id _Nullable);
extern id _Nullable objc_getProperty(id _Nonnull, SEL _Nonnull, ptrdiff_t,
- BOOL);
+ bool);
extern void objc_setProperty(id _Nonnull, SEL _Nonnull, ptrdiff_t, id _Nullable,
- BOOL, signed char);
+ bool, signed char);
extern void objc_getPropertyStruct(void *_Nonnull, const void *_Nonnull,
- ptrdiff_t, BOOL, BOOL);
+ ptrdiff_t, bool, bool);
extern void objc_setPropertyStruct(void *_Nonnull, const void *_Nonnull,
- ptrdiff_t, BOOL, BOOL);
+ ptrdiff_t, bool, bool);
extern void objc_enumerationMutation(id _Nonnull);
#ifdef __cplusplus
}
diff --git a/src/runtime/class.m b/src/runtime/class.m
index 0e9ba938..ef7a1f2b 100644
--- a/src/runtime/class.m
+++ b/src/runtime/class.m
@@ -54,7 +54,7 @@ register_class(struct objc_abi_class *cls)
classes_cnt++;
}
-BOOL
+bool
class_registerAlias_np(Class cls, const char *name)
{
if (classes == NULL)
diff --git a/src/runtime/lookup.m b/src/runtime/lookup.m
index 4d167e5c..db125da8 100644
--- a/src/runtime/lookup.m
+++ b/src/runtime/lookup.m
@@ -29,8 +29,8 @@
Class isa;
}
-+ (BOOL)resolveClassMethod: (SEL)selector;
-+ (BOOL)resolveInstanceMethod: (SEL)selector;
++ (bool)resolveClassMethod: (SEL)selector;
++ (bool)resolveInstanceMethod: (SEL)selector;
@end
static IMP forward_handler = (IMP)0;
diff --git a/src/runtime/morphos-library.m b/src/runtime/morphos-library.m
index be05de9e..ebc272d0 100644
--- a/src/runtime/morphos-library.m
+++ b/src/runtime/morphos-library.m
@@ -20,7 +20,6 @@
#import "ObjFW_RT.h"
#import "macros.h"
-#define BOOL EXEC_BOOL
#include <dos/dos.h>
#include <emul/emulregs.h>
#include <exec/execbase.h>
@@ -28,7 +27,6 @@
#include <exec/resident.h>
#include <exec/types.h>
#include <proto/exec.h>
-#undef BOOL
struct ObjFWRTBase {
struct Library library;
diff --git a/src/runtime/property.m b/src/runtime/property.m
index 2edaf6bd..4bcd9e6f 100644
--- a/src/runtime/property.m
+++ b/src/runtime/property.m
@@ -41,7 +41,7 @@ OF_CONSTRUCTOR()
#endif
id
-objc_getProperty(id self, SEL _cmd, ptrdiff_t offset, BOOL atomic)
+objc_getProperty(id self, SEL _cmd, ptrdiff_t offset, bool atomic)
{
if (atomic) {
id *ptr = (id *)(void *)((char *)self + offset);
@@ -63,7 +63,7 @@ objc_getProperty(id self, SEL _cmd, ptrdiff_t offset, BOOL atomic)
}
void
-objc_setProperty(id self, SEL _cmd, ptrdiff_t offset, id value, BOOL atomic,
+objc_setProperty(id self, SEL _cmd, ptrdiff_t offset, id value, bool atomic,
signed char copy)
{
if (atomic) {
@@ -116,8 +116,8 @@ objc_setProperty(id self, SEL _cmd, ptrdiff_t offset, id value, BOOL atomic,
/* The following methods are only required for GCC >= 4.6 */
void
-objc_getPropertyStruct(void *dest, const void *src, ptrdiff_t size, BOOL atomic,
- BOOL strong)
+objc_getPropertyStruct(void *dest, const void *src, ptrdiff_t size, bool atomic,
+ bool strong)
{
if (atomic) {
#ifdef OF_HAVE_THREADS
@@ -137,8 +137,8 @@ objc_getPropertyStruct(void *dest, const void *src, ptrdiff_t size, BOOL atomic,
}
void
-objc_setPropertyStruct(void *dest, const void *src, ptrdiff_t size, BOOL atomic,
- BOOL strong)
+objc_setPropertyStruct(void *dest, const void *src, ptrdiff_t size, bool atomic,
+ bool strong)
{
if (atomic) {
#ifdef OF_HAVE_THREADS
diff --git a/src/runtime/protos.h b/src/runtime/protos.h
index ad9a1fce..bf2a6e3c 100644
--- a/src/runtime/protos.h
+++ b/src/runtime/protos.h
@@ -31,10 +31,10 @@ id objc_getRequiredClass_inline(const char *);
void objc_exception_throw_inline(id);
int objc_sync_enter_inline(id);
int objc_sync_exit_inline(id);
-id objc_getProperty_inline(id, SEL, ptrdiff_t, BOOL);
-void objc_setProperty_inline(id, SEL, ptrdiff_t, id, BOOL, signed char);
-void objc_getPropertyStruct_inline(void *, const void *, ptrdiff_t, BOOL, BOOL);
-void objc_setPropertyStruct_inline(void *, const void *, ptrdiff_t, BOOL, BOOL);
+id objc_getProperty_inline(id, SEL, ptrdiff_t, bool);
+void objc_setProperty_inline(id, SEL, ptrdiff_t, id, bool, signed char);
+void objc_getPropertyStruct_inline(void *, const void *, ptrdiff_t, bool, bool);
+void objc_setPropertyStruct_inline(void *, const void *, ptrdiff_t, bool, bool);
void objc_enumerationMutation_inline(id);
SEL sel_registerName(const char *);
diff --git a/src/socket.h b/src/socket.h
index cb5b7a79..6cbb128a 100644
--- a/src/socket.h
+++ b/src/socket.h
@@ -26,13 +26,7 @@
#import "platform.h"
#ifdef OF_HAVE_SYS_SOCKET_H
-# ifdef OF_MORPHOS
-# define BOOL EXEC_BOOL
-# endif
# include <sys/socket.h>
-# ifdef OF_MORPHOS
-# undef BOOL
-# endif
#endif
#ifdef OF_HAVE_NETINET_IN_H
# include <netinet/in.h>
@@ -77,9 +71,7 @@ struct sockaddr_storage {
#endif
#ifdef OF_WII
-# define BOOL OGC_BOOL
# include <network.h>
-# undef BOOL
struct sockaddr_storage {
u8 ss_len;
diff --git a/src/unistd_wrapper.h b/src/unistd_wrapper.h
index 9e96e772..8651e52b 100644
--- a/src/unistd_wrapper.h
+++ b/src/unistd_wrapper.h
@@ -18,14 +18,6 @@
#include <stdlib.h> /* Make sure we have any libc include */
-#import "platform.h"
-
-#ifdef OF_MORPHOS
-# define BOOL EXEC_BOOL
-# include <exec/types.h>
-# undef BOOL
-#endif
-
#if defined(HAVE_UNISTD_H)
# ifdef __GLIBC__
# undef __USE_XOPEN /* Needed to avoid old glibc using __block */
diff --git a/tests/ForwardingTests.m b/tests/ForwardingTests.m
index 1af8ea5c..f2cd0bee 100644
--- a/tests/ForwardingTests.m
+++ b/tests/ForwardingTests.m
@@ -69,7 +69,7 @@ test(id self, SEL _cmd)
}
@implementation ForwardingTest
-+ (BOOL)resolveClassMethod: (SEL)selector
++ (bool)resolveClassMethod: (SEL)selector
{
forwardings++;
@@ -82,7 +82,7 @@ test(id self, SEL _cmd)
return NO;
}
-+ (BOOL)resolveInstanceMethod: (SEL)selector
++ (bool)resolveInstanceMethod: (SEL)selector
{
forwardings++;
diff --git a/tests/TestsAppDelegate.m b/tests/TestsAppDelegate.m
index 8366d280..7adc8324 100644
--- a/tests/TestsAppDelegate.m
+++ b/tests/TestsAppDelegate.m
@@ -42,11 +42,9 @@ PSP_MODULE_INFO("ObjFW Tests", 0, 0, 0);
#endif
#ifdef OF_WII
-# define BOOL OGC_BOOL
# define asm __asm__
# include <gccore.h>
# include <wiiuse/wpad.h>
-# undef BOOL
# undef asm
#endif