[PyObjC-svn] r2147 - in trunk/pyobjc/pyobjc-core: . Lib/objc Lib/objc/test Modules/objc

[email protected]
Newsgroups gmane.comp.python.pyobjc.cvs
Message-ID <[email protected]>
Author: ronaldoussoren
Date: Sun Apr 12 07:03:22 2009
New Revision: 2147

Log:
A collection of minor fixes

Modified:
   trunk/pyobjc/pyobjc-core/Lib/objc/_descriptors.py
   trunk/pyobjc/pyobjc-core/Lib/objc/test/test_arrays.py
   trunk/pyobjc/pyobjc-core/Lib/objc/test/test_subclass.py
   trunk/pyobjc/pyobjc-core/Modules/objc/libffi_support.m
   trunk/pyobjc/pyobjc-core/Modules/objc/objc_support.m
   trunk/pyobjc/pyobjc-core/Modules/objc/selector.m
   trunk/pyobjc/pyobjc-core/setup.py

Modified: trunk/pyobjc/pyobjc-core/Lib/objc/_descriptors.py
==============================================================================
--- trunk/pyobjc/pyobjc-core/Lib/objc/_descriptors.py	(original)
+++ trunk/pyobjc/pyobjc-core/Lib/objc/_descriptors.py	Sun Apr 12 07:03:22 2009
@@ -50,13 +50,16 @@
 
     if not (minArgs <= selArgs <= maxArgs):
         if selArgs == 3 and (minArgs <= 2 <= maxArgs) and funcName.startswith('validate') and funcName.endswith('_error_'):
-            return selector(func, signature='c@:N^@o^@')
+            return selector(func, signature='Z@:N^@o^@')
         elif minArgs == maxArgs:
             raise TypeError('%s expected to take %d args, but must accept %d from Objective-C (implicit self plus count of underscores)' % (funcName, maxArgs, selArgs))
         else:
             raise TypeError('%s expected to take between %d and %d args, but must accept %d from Objective-C (implicit self plus count of underscores)' % (funcName, minArgs, maxArgs, selArgs))
     
     if selArgs == 3:
+        if funcName.startswith('validate') and funcName.endswith('_error_'):
+            return selector(func, signature='Z@:N^@o^@')
+
         if funcName.startswith('insertObject_in') and funcName.endswith('AtIndex_'):
             return selector(func, signature='v@:@i')
         elif funcName.startswith('replaceObjectIn') and funcName.endswith('AtIndex_withObject_'):

Modified: trunk/pyobjc/pyobjc-core/Lib/objc/test/test_arrays.py
==============================================================================
--- trunk/pyobjc/pyobjc-core/Lib/objc/test/test_arrays.py	(original)
+++ trunk/pyobjc/pyobjc-core/Lib/objc/test/test_arrays.py	Sun Apr 12 07:03:22 2009
@@ -133,11 +133,26 @@
     ]
 )
 
+class OC_TestArrayInt_In (NSObject):
+    def arrayOf4Ints_(self, array):
+        return array
+
+class OC_TestArrayInt_Out (NSObject):
+    def arrayOf4IntsOut_(self, array):
+        if array is None:
+            return [ 99, 100, 98, 101 ]
+
+class OC_TestArrayStruct_Out (NSObject):
+    def arrayOf4StructsOut_(self, array):
+        if array is None:
+            return [ (44, 45), (46, 47), (48, 49), (50, 51) ]
+
+class OC_TestArrayStruct_In (NSObject):
+    def arrayOf4Structs_(self, array):
+        return array
+
 class TestArrayCallbacks (TestCase):
     def testCallArrayInt(self):
-        class OC_TestArrayInt_In (NSObject):
-            def arrayOf4Ints_(self, array):
-                return array
 
         obj = OC_TestArrayInt_In.alloc().init()
 
@@ -145,10 +160,6 @@
         self.assertEquals(v, (1, 2, 3, 4))
 
     def testCallArrayIntsOut(self):
-        class OC_TestArrayInt_Out (NSObject):
-            def arrayOf4IntsOut_(self, array):
-                if array is None:
-                    return [ 99, 100, 98, 101 ]
 
         obj = OC_TestArrayInt_Out.alloc().init()
 
@@ -156,9 +167,6 @@
         self.assertEquals(v, [99, 100, 98, 101])
 
     def testCallArrayStruct(self):
-        class OC_TestArrayStruct_In (NSObject):
-            def arrayOf4Structs_(self, array):
-                return array
 
         obj = OC_TestArrayStruct_In.alloc().init()
 
@@ -166,10 +174,6 @@
         self.assertEquals(v, ((1,2), (3,4), (5,6), (7,8)))
 
     def testCallArrayStructsOut(self):
-        class OC_TestArrayStruct_Out (NSObject):
-            def arrayOf4StructsOut_(self, array):
-                if array is None:
-                    return [ (44, 45), (46, 47), (48, 49), (50, 51) ]
 
         obj = OC_TestArrayStruct_Out.alloc().init()
 

Modified: trunk/pyobjc/pyobjc-core/Lib/objc/test/test_subclass.py
==============================================================================
--- trunk/pyobjc/pyobjc-core/Lib/objc/test/test_subclass.py	(original)
+++ trunk/pyobjc/pyobjc-core/Lib/objc/test/test_subclass.py	Sun Apr 12 07:03:22 2009
@@ -418,7 +418,7 @@
 
     def testImplementingSetValueForKey(self):
         values = {}
-        class CrashTest(NSObject):
+        class CrashTest (NSObject):
             def setValue_forKey_(self, v, k):
                 values[k] = v
 

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	Sun Apr 12 07:03:22 2009
@@ -381,8 +381,11 @@
 	case _C_PTR: return &ffi_type_pointer;
 	case _C_ARY_B: 
 		return array_to_ffi_type(argtype);
-	case _C_IN: case _C_OUT: case _C_INOUT: case _C_CONST:
+	case _C_IN: case _C_OUT: case _C_INOUT: case _C_CONST: 
+#if 0	/* 'O' is used by remote objects ??? */
+	  case 'O':
 		return signature_to_ffi_type(argtype+1);
+#endif
 	case _C_STRUCT_B: 
 		return struct_to_ffi_type(argtype);
 	case _C_UNDEF:
@@ -1023,6 +1026,12 @@
 
 		const char* argtype = methinfo->argtype[i].type;
 
+#if 0
+		if (argtype[0] == 'O') {
+			argtype ++;
+		}
+#endif
+
 		switch (*argtype) {
 		case _C_INOUT: 
 			if (argtype[1] == _C_PTR) {
@@ -2026,6 +2035,11 @@
 	
 	for (i = argOffset; i < methinfo->ob_size; i++) {
 		const char *argtype = methinfo->argtype[i].type;
+#if 0
+		if (argtype[0] == 'O') {
+			argtype++;
+		}
+#endif
 
 		switch (*argtype) {
 		case _C_INOUT:
@@ -2357,6 +2371,9 @@
 			/* Encode argument, maybe after allocating space */
 
 			if (argtype[0] == _C_OUT) argtype ++; /* XXX: is this correct ???? */
+#if 0
+			if (argtype[0] == 'O') argtype ++; 
+#endif
 
 			argument = PyTuple_GET_ITEM (args, py_arg);
 			switch (*argtype) {
@@ -2841,6 +2858,9 @@
 			} else {
 				/* Encode argument, maybe after allocating space */
 				if (argtype[0] == _C_OUT) argtype ++;
+#if 0
+				if (argtype[0] == 'O') argtype ++;
+#endif
 
 				argument = PyTuple_GET_ITEM (args, py_arg);
 				py_arg ++; 
@@ -3237,7 +3257,7 @@
 								count = methinfo->argtype[i].arrayArg;
 							}
 
-							if (*resttype == *@encode(UniChar)) {
+							if (*resttype == _C_UNICHAR) {
 								v = PyUnicode_FromUnicode(NULL, count);
 								if (!v) goto error_cleanup;
 
@@ -3291,7 +3311,7 @@
 							}
 							if (count == -1 && PyErr_Occurred()) goto error_cleanup;
 
-							if (*resttype == *@encode(UniChar)) {
+							if (*resttype == _C_UNICHAR) {
 								v = PyUnicode_FromUnicode(NULL, count);
 								if (!v) goto error_cleanup;
 
@@ -3668,10 +3688,11 @@
 		PyObjCErr_FromObjC(localException);
 
 	PyObjC_ENDHANDLER
-
+#if 1
 	if (isUninitialized && PyObjCObject_Check(self)) {
 		((PyObjCObject*)self)->flags  |= PyObjCObject_kUNINITIALIZED;
 	}
+#endif
 
 	if (PyErr_Occurred()) goto error_cleanup;
 

Modified: trunk/pyobjc/pyobjc-core/Modules/objc/objc_support.m
==============================================================================
--- trunk/pyobjc/pyobjc-core/Modules/objc/objc_support.m	(original)
+++ trunk/pyobjc/pyobjc-core/Modules/objc/objc_support.m	Sun Apr 12 07:03:22 2009
@@ -333,7 +333,8 @@
 			*type == _C_INOUT ||
 			*type == _C_OUT ||
 			*type == _C_BYCOPY ||
-			*type == _C_ONEWAY) {
+			*type == _C_ONEWAY ||
+			*type == 'O') {
 		type++;
 	}
 	while (*type && isdigit(*type)) type++;

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	Sun Apr 12 07:03:22 2009
@@ -589,8 +589,8 @@
 	if (pyres && PyObjCObject_Check(pyres)) {
 		if (self->sel_flags & PyObjCSelector_kRETURNS_UNINITIALIZED) {
 			((PyObjCObject*)pyres)->flags |= PyObjCObject_kUNINITIALIZED;
-		} else if (((PyObjCObject*)pyres)->flags & PyObjCObject_kUNINITIALIZED) {
-			((PyObjCObject*)pyres)->flags &= 
+		} else if (((PyObjCObject*)pyself)->flags & PyObjCObject_kUNINITIALIZED) {
+			((PyObjCObject*)pyself)->flags &= 
 				~PyObjCObject_kUNINITIALIZED;
 			if (self->sel_self && self->sel_self != pyres && !PyErr_Occurred()) {
 				PyObjCObject_ClearObject(self->sel_self);
@@ -1199,6 +1199,7 @@
 			"Objective-C callable methods must take at least one argument");
 		return NULL;
 	}
+
 	
 	/* arguments + return-type + selector */
 	result = PyMem_Malloc(arg_count+3);
@@ -1239,8 +1240,6 @@
 			i += 2;
 		}
 	}
-	
-
 	return result;
 }
 
@@ -1888,7 +1887,7 @@
 	} else {
 		meth = class_getInstanceMethod(oc_class, selector);
 		
-		if (!meth && !sel_isEqual(selector, @selector(copyWithZone:))) {
+		if (!meth && !sel_isEqual(selector, @selector(copyWithZone:)) && !sel_isEqual(selector, @selector(mutableCopyWithZone:))) {
 		        /* Look for a classmethod, but don't do that for copyWithZone:
 			 * because that method is commonly defined in Python, and
 			 * overriding "NSObject +copyWithZone:" is almost certainly

Modified: trunk/pyobjc/pyobjc-core/setup.py
==============================================================================
--- trunk/pyobjc/pyobjc-core/setup.py	(original)
+++ trunk/pyobjc/pyobjc-core/setup.py	Sun Apr 12 07:03:22 2009
@@ -8,6 +8,11 @@
 import glob
 import site
 
+if 'MallocStackLogging' in os.environ:
+    del os.environ['MallocStackLogging']
+if 'MallocStackLoggingNoCompact' in os.environ:
+    del os.environ['MallocStackLoggingNoCompact']
+
 # See the news file:
 #os.environ['MACOSX_DEPLOYMENT_TARGET']='10.5'
 

------------------------------------------------------------------------------
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.