From 7765ad52e00034edd23bb09bade83d8b282f8040 Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Fri, 21 Sep 2007 19:52:30 +0200 Subject: Objective-C layer: Add functions for determining the Objective-C runtime used and for asking for the size of types by typespec. darcs-hash:197f36840c1568c5b3431833a0118d06729b9247 --- Objective-C/libobjcl.h | 12 ++++++++++++ Objective-C/libobjcl.m | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) (limited to 'Objective-C') diff --git a/Objective-C/libobjcl.h b/Objective-C/libobjcl.h index c84dbb9..2ebea37 100644 --- a/Objective-C/libobjcl.h +++ b/Objective-C/libobjcl.h @@ -69,3 +69,15 @@ objcl_get_yes (void); long objcl_get_no (void); + +const char * +objcl_get_runtime_type (void); + +long +objcl_sizeof_type (const char *typespec); + +long +objcl_sizeof_return_type (const char *typespec); + +long +objcl_alignof_type (const char *typespec); diff --git a/Objective-C/libobjcl.m b/Objective-C/libobjcl.m index 205a998..8c4f3fd 100644 --- a/Objective-C/libobjcl.m +++ b/Objective-C/libobjcl.m @@ -248,3 +248,41 @@ objcl_get_no (void) fprintf (stderr, "WARNING: objcl_get_no: NO might not fit into a long.\n"); return NO; } + + +const char * +objcl_get_runtime_type (void) +{ +#ifdef __NEXT_RUNTIME__ + return "NeXT"; +#else + return "GNU"; +#endif +} + + +long +objcl_sizeof_type (const char *typespec) +{ + if (sizeof (ssize_t) > sizeof (long)) + fprintf (stderr, "WARNING: objcl_sizeof_typespec: Size might not fit into a long.\n"); + return PyObjCRT_SizeOfType (typespec); +} + + +long +objcl_sizeof_return_type (const char *typespec) +{ + if (sizeof (ssize_t) > sizeof (long)) + fprintf (stderr, "WARNING: objcl_sizeof_return_typespec: Size might not fit into a long.\n"); + return PyObjCRT_SizeOfReturnType (typespec); +} + + +long +objcl_alignof_type (const char *typespec) +{ + if (sizeof (ssize_t) > sizeof (long)) + fprintf (stderr, "WARNING: objcl_align_typespec: Alignment might not fit into a long.\n"); + return PyObjCRT_AlignOfType (typespec); +} -- cgit v1.2.3