diff options
author | Matthias Benkard <code@mail.matthias.benkard.de> | 2007-09-21 19:52:30 +0200 |
---|---|---|
committer | Matthias Benkard <code@mail.matthias.benkard.de> | 2007-09-21 19:52:30 +0200 |
commit | 7765ad52e00034edd23bb09bade83d8b282f8040 (patch) | |
tree | 61f3087a64d9667c80ce4bec853b26f8c858927e /Objective-C | |
parent | e8081745f009f2f7c3dc9b46d072094e6bab30d6 (diff) |
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
Diffstat (limited to 'Objective-C')
-rw-r--r-- | Objective-C/libobjcl.h | 12 | ||||
-rw-r--r-- | Objective-C/libobjcl.m | 38 |
2 files changed, 50 insertions, 0 deletions
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); +} |