summaryrefslogtreecommitdiff
path: root/Objective-C/objc_support.m
diff options
context:
space:
mode:
authorMatthias Benkard <code@mail.matthias.benkard.de>2007-09-15 14:03:32 +0200
committerMatthias Benkard <code@mail.matthias.benkard.de>2007-09-15 14:03:32 +0200
commitd0dd29fcf87b51280dd5c2685063ea42cf4fc115 (patch)
tree6492eb0477db2e07978554e4b865f9a812de252b /Objective-C/objc_support.m
parent63a0b732f2f8f7acc054ab4a9d2eb3fa121b1a95 (diff)
Make the code copied from PyObjC compilable stand-alone.
darcs-hash:6a1f1865b6259fc5a7551ffb10494f914359ecc6
Diffstat (limited to 'Objective-C/objc_support.m')
-rw-r--r--Objective-C/objc_support.m72
1 files changed, 28 insertions, 44 deletions
diff --git a/Objective-C/objc_support.m b/Objective-C/objc_support.m
index 5bbd338..862879c 100644
--- a/Objective-C/objc_support.m
+++ b/Objective-C/objc_support.m
@@ -15,6 +15,9 @@
* Created Tue Sep 10 14:16:02 1996.
*/
+#include "objc_support.h"
+#include "pyobjc.h"
+
#include <objc/Protocol.h>
#include <unistd.h>
@@ -36,6 +39,10 @@
#endif /* MACOSX */
+/* Define in order to throw exceptions when a typespec cannot be parsed. */
+#undef STRICT_TYPE_PARSING
+
+
#ifndef MAX
static inline ssize_t
MAX(ssize_t x, ssize_t y)
@@ -169,8 +176,13 @@ PyObjCRT_SkipTypeSpec (const char *type)
default:
- PyErr_Format(PyObjCExc_InternalError,
- "PyObjCRT_SkipTypeSpec: Unhandled type '%#x'", *type);
+#ifdef STRICT_TYPE_PARSING
+ [[NSException exceptionWithName: @"PyObjCRT_SkipTypeSpec"
+ reason: [NSString stringWithFormat: @"Unhandled type: '%c'", *type]
+ userInfo: NULL] raise];
+#else
+ NSLog (@"PyObjCRT_SkipTypeSpec: Unhandled type: '%c'", *type);
+#endif
return NULL;
}
@@ -335,8 +347,13 @@ PyObjCRT_AlignOfType (const char *type)
return PyObjCRT_AlignOfType(type+1);
default:
- PyErr_Format(PyObjCExc_InternalError,
- "PyObjCRT_AlignOfType: Unhandled type '%#x'", *type);
+#ifdef STRICT_TYPE_PARSING
+ [[NSException exceptionWithName: @"PyObjCRT_SkipTypeSpec"
+ reason: [NSString stringWithFormat: @"Unhandled type: '%c'", *type]
+ userInfo: NULL] raise];
+#else
+ NSLog (@"PyObjCRT_SkipTypeSpec: Unhandled type: '%c'", *type);
+#endif
return -1;
}
}
@@ -461,51 +478,18 @@ PyObjCRT_SizeOfType (const char *type)
return PyObjCRT_SizeOfType(type+1);
default:
- PyErr_Format(PyObjCExc_InternalError,
- "PyObjCRT_SizeOfType: Unhandled type '%#x", *type);
+#ifdef STRICT_TYPE_PARSING
+ [[NSException exceptionWithName: @"PyObjCRT_SkipTypeSpec"
+ reason: [NSString stringWithFormat: @"Unhandled type: '%c'", *type]
+ userInfo: NULL] raise];
+#else
+ NSLog (@"PyObjCRT_SkipTypeSpec: Unhandled type: '%c'", *type);
+#endif
return -1;
}
}
-/*#F Returns a tuple of objects representing the content of a C array
-of type @var{type} pointed by @var{datum}. */
-static PyObject *
-pythonify_c_array (const char *type, void *datum)
-{
- PyObject *ret;
- ssize_t nitems, itemidx, sizeofitem;
- unsigned char* curdatum;
-
- nitems = atoi (type+1);
- while (isdigit (*++type))
- ;
- sizeofitem = PyObjCRT_SizeOfType (type);
- if (sizeofitem == -1) return NULL;
-
- ret = PyTuple_New (nitems);
- if (!ret) return NULL;
-
- curdatum = datum;
- for (itemidx=0; itemidx < nitems; itemidx++) {
- PyObject *pyitem = NULL;
-
- pyitem = pythonify_c_value (type, curdatum);
-
- if (pyitem) {
- PyTuple_SET_ITEM (ret, itemidx, pyitem);
- } else {
- Py_DECREF(ret);
- return NULL;
- }
-
- curdatum += sizeofitem;
- }
-
- return ret;
-}
-
-
ssize_t
PyObjCRT_SizeOfReturnType(const char* type)
{