diff options
| -rw-r--r-- | include/Paradox/Object.h | 4 | ||||
| -rw-r--r-- | meson.build | 6 | ||||
| -rw-r--r-- | meson.options | 1 | ||||
| -rw-r--r-- | src/Object.m | 4 | ||||
| -rw-r--r-- | tests/Object.m | 4 |
5 files changed, 16 insertions, 3 deletions
diff --git a/include/Paradox/Object.h b/include/Paradox/Object.h index ca602d7..23488fd 100644 --- a/include/Paradox/Object.h +++ b/include/Paradox/Object.h @@ -8,14 +8,18 @@ void* dummy; // it doesn't work without this so don't touch it } + (instancetype)alloc; +#ifdef PARADOX_DEBUG_FEATURES + (instancetype)allocDebug; +#endif + (instancetype)new; - (instancetype)retain; - (instancetype)init; - (void)dealloc; - (void)release; - (instancetype)autorelease; +#ifdef PARADOX_DEBUG_FEATURES - (void)healthCheck; +#endif @end #endif diff --git a/meson.build b/meson.build index 09e4649..b7c5809 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,11 @@ -project('paradox', 'objc', version: '0.0.1') +project('paradox', 'objc', version: '0.0.1', meson_version: '>=1.1.0') add_project_arguments('-Wno-objc-root-class', '-Werror', '-pedantic', '-Wall', '-fobjc-runtime=gnustep-2.0', language: 'objc') +if get_option('debug_features') + add_project_arguments('-DPARADOX_DEBUG_FEATURES', language: 'objc') +endif + deps = [] deps += dependency('libobjc') # This is libobjc2, not libobjc - do not be fooled diff --git a/meson.options b/meson.options new file mode 100644 index 0000000..eca6541 --- /dev/null +++ b/meson.options @@ -0,0 +1 @@ +option('debug_features', type: 'boolean', value: false, description: 'Enable debugging features') diff --git a/src/Object.m b/src/Object.m index f9a0184..de0f343 100644 --- a/src/Object.m +++ b/src/Object.m @@ -10,6 +10,7 @@ return class_createInstance(self, 0); } +#ifdef PARADOX_DEBUG_FEATURES + (instancetype)allocDebug { printf("alloc: self = %p\n", (void*)self); printf("alloc: instance size = %zu\n", class_getInstanceSize(self)); @@ -21,6 +22,7 @@ return object; } +#endif + (instancetype) new { return [[self alloc] init]; @@ -46,8 +48,10 @@ object_dispose(self); } +#ifdef PARADOX_DEBUG_FEATURES - (void)healthCheck { printf("PXObject health check: %p\n", (void*)self); } +#endif @end diff --git a/tests/Object.m b/tests/Object.m index 2814489..df955cf 100644 --- a/tests/Object.m +++ b/tests/Object.m @@ -2,9 +2,9 @@ #include <stdio.h> int main(void) { - printf("PXObject test (allocDebug)\n"); + printf("PXObject test (alloc)\n"); - PXObject *object = [PXObject allocDebug]; + PXObject *object = [PXObject alloc]; if (object == nil) { fprintf(stderr, "PXObject failed to alloc :c\n"); |
