summaryrefslogtreecommitdiff
path: root/data/uicaboodle.py
diff options
context:
space:
mode:
authorJay Freeman <saurik@saurik.com>2008-02-14 11:04:20 +0000
committerJay Freeman <saurik@saurik.com>2008-02-14 11:04:20 +0000
commit62882fc0471895bc1a47c13e22daf35dcaafecd0 (patch)
treec5fb76fc3f64e729fdabeb9c35774e722000fd4e /data/uicaboodle.py
parent8e60af7ad00762fb8a89ae39c771287f3c5efed4 (diff)
Got PyObjC working.
git-svn-id: http://svn.telesphoreo.org/trunk@74 514c082c-b64e-11dc-b46d-3d985efe055d
Diffstat (limited to 'data/uicaboodle.py')
-rw-r--r--data/uicaboodle.py/_metadata/description1
l---------data/uicaboodle.py/_metadata/license1
l---------data/uicaboodle.py/_metadata/maintainer1
-rw-r--r--data/uicaboodle.py/_metadata/name1
-rw-r--r--data/uicaboodle.py/_metadata/priority1
l---------data/uicaboodle.py/_metadata/pyobjc.dep1
-rw-r--r--data/uicaboodle.py/_metadata/section1
-rw-r--r--data/uicaboodle.py/_metadata/version1
-rw-r--r--data/uicaboodle.py/make.sh3
-rw-r--r--data/uicaboodle.py/uicaboodle.m92
10 files changed, 103 insertions, 0 deletions
diff --git a/data/uicaboodle.py/_metadata/description b/data/uicaboodle.py/_metadata/description
new file mode 100644
index 000000000..009000489
--- /dev/null
+++ b/data/uicaboodle.py/_metadata/description
@@ -0,0 +1 @@
+iPhone-specific PyObjC extensions
diff --git a/data/uicaboodle.py/_metadata/license b/data/uicaboodle.py/_metadata/license
new file mode 120000
index 000000000..b9c4e3684
--- /dev/null
+++ b/data/uicaboodle.py/_metadata/license
@@ -0,0 +1 @@
+../../../licenses/menes \ No newline at end of file
diff --git a/data/uicaboodle.py/_metadata/maintainer b/data/uicaboodle.py/_metadata/maintainer
new file mode 120000
index 000000000..0fa66e077
--- /dev/null
+++ b/data/uicaboodle.py/_metadata/maintainer
@@ -0,0 +1 @@
+../../../people/saurik \ No newline at end of file
diff --git a/data/uicaboodle.py/_metadata/name b/data/uicaboodle.py/_metadata/name
new file mode 100644
index 000000000..15b83dace
--- /dev/null
+++ b/data/uicaboodle.py/_metadata/name
@@ -0,0 +1 @@
+UICaboodle.py
diff --git a/data/uicaboodle.py/_metadata/priority b/data/uicaboodle.py/_metadata/priority
new file mode 100644
index 000000000..134d9bc32
--- /dev/null
+++ b/data/uicaboodle.py/_metadata/priority
@@ -0,0 +1 @@
+optional
diff --git a/data/uicaboodle.py/_metadata/pyobjc.dep b/data/uicaboodle.py/_metadata/pyobjc.dep
new file mode 120000
index 000000000..a208096d6
--- /dev/null
+++ b/data/uicaboodle.py/_metadata/pyobjc.dep
@@ -0,0 +1 @@
+../../pyobjc \ No newline at end of file
diff --git a/data/uicaboodle.py/_metadata/section b/data/uicaboodle.py/_metadata/section
new file mode 100644
index 000000000..46c5d2cde
--- /dev/null
+++ b/data/uicaboodle.py/_metadata/section
@@ -0,0 +1 @@
+Python
diff --git a/data/uicaboodle.py/_metadata/version b/data/uicaboodle.py/_metadata/version
new file mode 100644
index 000000000..14fde4785
--- /dev/null
+++ b/data/uicaboodle.py/_metadata/version
@@ -0,0 +1 @@
+1.0.2307
diff --git a/data/uicaboodle.py/make.sh b/data/uicaboodle.py/make.sh
new file mode 100644
index 000000000..6fe3a7ede
--- /dev/null
+++ b/data/uicaboodle.py/make.sh
@@ -0,0 +1,3 @@
+arm-apple-darwin-gcc -o _uicaboodle.dylib "${PKG_DATA}/uicaboodle.m" -I"${PKG_ROOT}"/usr/include/python2.5 -I "$(PKG_WORK_ pyobjc)"/*/pyobjc-core/Modules/objc -lpython2.5 -framework UIKit -dynamiclib -framework Foundation
+pkg: mkdir -p /usr/lib/python2.5/lib-dynload
+pkg: cp -a _uicaboodle.dylib /usr/lib/python2.5/lib-dynload
diff --git a/data/uicaboodle.py/uicaboodle.m b/data/uicaboodle.py/uicaboodle.m
new file mode 100644
index 000000000..6cd372868
--- /dev/null
+++ b/data/uicaboodle.py/uicaboodle.m
@@ -0,0 +1,92 @@
+#include <Python.h>
+#include "pyobjc-api.h"
+#import <UIKit/UIKit.h>
+
+#define _trace() \
+ fprintf(stderr, "_trace():%s(%d):%s\n", __FILE__, __LINE__, __FUNCTION__)
+
+#define _assert(test) \
+ do if (!(test)) { \
+ fprintf(stderr, "_assert(%s):%s(%d):%s\n", #test, __FILE__, __LINE__, __FUNCTION__); \
+ exit(-1); \
+ } while (false)
+
+static PyObject* objc_UIApplicationMain(
+ PyObject *self __attribute__((__unused__)),
+ PyObject *args
+) {
+ int argc;
+ char **argv;
+ size_t i;
+ int res = -1;
+
+ PyObject *arga;
+ PyObject *_class;
+
+ _assert(PyObjC_API != NULL);
+ _assert(args != NULL);
+
+ if (!PyArg_ParseTuple(args, "OO", &arga, &_class)) {
+ PyErr_SetString(PyExc_TypeError, "Invalid Arguments");
+ return NULL;
+ }
+
+ _assert(arga != NULL);
+ _assert(_class != NULL);
+
+ argc = PySequence_Size(arga);
+ argv = calloc(argc + 1, sizeof(char *));
+
+ if (argv == NULL) {
+ PyErr_SetString(PyExc_MemoryError, "Out of memory");
+ return NULL;
+ }
+
+ for (i = 0; i != argc; ++i) {
+ PyObject *arg = PySequence_GetItem(arga, i);
+ if (arg == NULL) {
+ PyErr_SetString(PyExc_TypeError, "UIApplicationMain: null argument");
+ goto error;
+ }
+
+ if (!PyString_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError, "UIApplicationMain: non-string argument");
+ goto error;
+ }
+
+ argv[i] = strdup(PyString_AsString(arg));
+ if (argv[i] == NULL) {
+ PyErr_SetString(PyExc_MemoryError, "Out of memory");
+ goto error;
+ }
+ }
+
+ PyObjC_DURING
+ res = UIApplicationMain(argc, argv, PyObjC_API->cls_get_class(_class));
+ PyObjC_HANDLER
+ PyObjCErr_FromObjC(localException);
+ PyObjC_ENDHANDLER
+
+ error:
+ for (i = 0; i != argc; ++i)
+ free(argv[i]);
+ free(argv);
+
+ if (res == -1 && PyErr_Occurred())
+ return NULL;
+ return PyInt_FromLong(res);
+}
+
+static PyMethodDef mod_methods[] = {{
+ "UIApplicationMain",
+ /*(PyCFunction)*/ objc_UIApplicationMain,
+ METH_VARARGS|METH_KEYWORDS,
+ "int UIApplicationMain(int argc, const char *argv[], Class _class);"
+}, {
+ NULL, NULL, 0, NULL
+}};
+
+void init_uicaboodle(void) {
+ PyObject *module = Py_InitModule4("_uicaboodle", mod_methods, "", NULL, PYTHON_API_VERSION);
+ PyObjC_ImportAPI(module);
+}