[PyObjC-svn] r2260 - trunk/pyobjc/pyobjc-core/Modules/objc
[email protected] Thu, 11 Jun 2009 17:19:43 -0500
| Newsgroups | gmane.comp.python.pyobjc.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: ronaldoussoren
Date: Thu Jun 11 17:19:42 2009
New Revision: 2260
Log:
Always -copy blocks instead of using -retain, to
avoid hard to diagnose issues.
Modified:
trunk/pyobjc/pyobjc-core/Modules/objc/libffi_support.m
Modified: trunk/pyobjc/pyobjc-core/Modules/objc/libffi_support.m
==============================================================================
--- trunk/pyobjc/pyobjc-core/Modules/objc/libffi_support.m (original)
+++ trunk/pyobjc/pyobjc-core/Modules/objc/libffi_support.m Thu Jun 11 17:19:42 2009
@@ -3261,18 +3261,35 @@
/* default behaviour: */
if (objc_result == NULL) {
- objc_result = pythonify_c_return_value (tp, pRetval);
- if (objc_result == NULL) {
- return NULL;
- }
-
if (tp[0] == _C_ID && tp[1] == '?') {
+ /* The value is a block, those values are
+ * treated slightly differently than normal:
+ * - always use -copy on them to ensure we
+ * can safely store them.
+ * - try to attach the calling signature to the
+ * block.
+ */
+ id v = [*(id*)pRetval copy];
+ objc_result = pythonify_c_return_value (tp, &v);
+ [v release];
+ if (objc_result == NULL) {
+ return NULL;
+ }
+
if (methinfo->rettype.callable != NULL) {
if (PyObjCObject_IsBlock(objc_result) && PyObjCObject_GetBlock(objc_result) == NULL) {
PyObjCObject_SET_BLOCK(objc_result, methinfo->rettype.callable);
Py_INCREF(methinfo->rettype.callable);
}
}
+
+ } else {
+
+ objc_result = pythonify_c_return_value (tp, pRetval);
+ if (objc_result == NULL) {
+ return NULL;
+ }
+
}
if (methinfo->rettype.alreadyRetained) {
@@ -3359,14 +3376,20 @@
} else {
switch (methinfo->argtype[i].ptrType) {
case PyObjC_kPointerPlain:
- v = pythonify_c_value(resttype, arg);
+
if (resttype[0] == _C_ID && resttype[1] == '?') {
+ id tmp = [*(id*)arg copy];
+ v = pythonify_c_value(resttype, &tmp);
+ [tmp release];
+
if (methinfo->argtype[i].callable != NULL) {
if (PyObjCObject_IsBlock(v) && PyObjCObject_GetBlock(v) == NULL) {
PyObjCObject_SET_BLOCK(v, methinfo->argtype[i].callable);
Py_INCREF(methinfo->argtype[i].callable);
}
}
+ } else {
+ v = pythonify_c_value(resttype, arg);
}
if (methinfo->argtype[i].alreadyRetained && PyObjCObject_Check(v)) {
[PyObjCObject_GetObject(v) release];
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects