[PyObjC-svn] r2163 - in trunk/pyobjc/pyobjc-core: . Lib/PyObjCTools Modules/objc

[email protected]
Newsgroups gmane.comp.python.pyobjc.cvs
Message-ID <[email protected]>
Author: ronaldoussoren
Date: Tue Apr 14 05:28:28 2009
New Revision: 2163

Log:
- More testsupport
- Automaticly detect the name of the callback method
  for sheets and deduce the correct signature for those
  methods, takeing away most of the need for
  the ``AppHelper.endSheetMethod`` decorator.


Modified:
   trunk/pyobjc/pyobjc-core/Lib/PyObjCTools/TestSupport.py
   trunk/pyobjc/pyobjc-core/Modules/objc/selector.m
   trunk/pyobjc/pyobjc-core/NEWS.txt

Modified: trunk/pyobjc/pyobjc-core/Lib/PyObjCTools/TestSupport.py
==============================================================================
--- trunk/pyobjc/pyobjc-core/Lib/PyObjCTools/TestSupport.py	(original)
+++ trunk/pyobjc/pyobjc-core/Lib/PyObjCTools/TestSupport.py	Tue Apr 14 05:28:28 2009
@@ -164,6 +164,11 @@
         if not info['arguments'][argno+offset].get('c_array_of_variable_length'):
             self.fail(message or "argument %d of %r is not a variable sized array"%(argno, method))
 
+    def failUnlessResultIsVariableSize(self, method, message = None):
+        info = method.__metadata__()
+        if not info['retval'].get('c_array_of_variable_length'):
+            self.fail(message or "result of %r is not a variable sized array"%(argno, method))
+
     def failUnlessArgSizeInResult(self, method, argno, message = None):
         if isinstance(method, objc.selector):
             offset = 2

Modified: trunk/pyobjc/pyobjc-core/Modules/objc/selector.m
==============================================================================
--- trunk/pyobjc/pyobjc-core/Modules/objc/selector.m	(original)
+++ trunk/pyobjc/pyobjc-core/Modules/objc/selector.m	Tue Apr 14 05:28:28 2009
@@ -857,13 +857,22 @@
 	return (PyObject*)result;
 }
 
+
+static char gSheetMethodSignature[] = { _C_VOID, _C_ID, _C_SEL, _C_ID, _C_INT, _C_PTR , _C_VOID, 0 };
+
 PyObject*
 PyObjCSelector_New(PyObject* callable, 
 	SEL selector, char* signature, int class_method, Class cls)
 {
 	PyObjCPythonSelector* result;
 	if (signature == NULL) {
-		signature = pysel_default_signature(callable);
+		const char* selname = sel_getName(selector);
+		size_t len = strlen(selname);
+		if (len > 30 && strcmp(selname+len-30, "DidEnd:returnCode:contextInfo:") == 0) {
+			signature = PyObjCUtil_Strdup(gSheetMethodSignature);
+		} else {
+			signature = pysel_default_signature(callable);
+		}
 	} else {
 		signature = PyObjCUtil_Strdup(signature);
 	}

Modified: trunk/pyobjc/pyobjc-core/NEWS.txt
==============================================================================
--- trunk/pyobjc/pyobjc-core/NEWS.txt	(original)
+++ trunk/pyobjc/pyobjc-core/NEWS.txt	Tue Apr 14 05:28:28 2009
@@ -4,9 +4,17 @@
 
 An overview of the relevant changes in new, and older, releases.
 
-Version 2.1 (...)
+Version 2.2 (...)
 -----------------
 
+- Added more magic signature heuristics: the delegate selector for
+  sheets is now automaticly recognized, removing the need for
+  the decorator ``AppHelper.didEndSelector`` (which will stay present
+  for backward compatibility).
+
+  FIXME: Do the same thing for ``objc.accessor``. Both are a frequent
+  source for errors.
+
 - Added ``PyObjC.TestSupport``. This is an unsupported module containing
   useful functionality for testing PyObjC itself.
 

------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.