[PyObjC-svn] r2052 - 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 Feb  3 10:00:27 2009
New Revision: 2052

Log:
Minor fixes needed for SearchKit wrappers

Modified:
   trunk/pyobjc/pyobjc-core/Lib/PyObjCTools/TestSupport.py
   trunk/pyobjc/pyobjc-core/Modules/objc/corefoundation.m
   trunk/pyobjc/pyobjc-core/Modules/objc/libffi_support.m

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 Feb  3 10:00:27 2009
@@ -105,6 +105,7 @@
 
 
 _poolclass = objc.lookUpClass('NSAutoreleasePool')
+_nscftype = objc.lookUpClass('NSCFType')
 
 class TestCase (_unittest.TestCase):
     """
@@ -113,9 +114,24 @@
 
     This also adds a number of useful assertion methods
     """
+    def failUnlessIsCFType(self, tp, message = None):
+        if not isinstance(tp, objc.objc_class):
+            self.fail(message or "%r is not a CFTypeRef type"%(tp,))
+
+        if tp is _nscftype:
+            self.fail(message or "%r is not a unique CFTypeRef type"%(tp,))
+
+    def failUnlessIsOpaquePointer(self, tp, message = None):
+        if not hasattr(tp, "__pointer__"):
+            self.fail(message or "%r is not an opaque-pointer"%(tp,))
+
+        if not hasattr(tp, "__typestr__"):
+            self.fail(message or "%r is not an opaque-pointer"%(tp,))
+
+
     def failUnlessIsNone(self, value, message = None):
         if value is not None:
-            sel.fail(message, "%r is not %r"%(value, test))
+            sel.fail(message or "%r is not %r"%(value, test))
 
     def failIfIsNone(self, value,  message = None):
         if value is None:

Modified: trunk/pyobjc/pyobjc-core/Modules/objc/corefoundation.m
==============================================================================
--- trunk/pyobjc/pyobjc-core/Modules/objc/corefoundation.m	(original)
+++ trunk/pyobjc/pyobjc-core/Modules/objc/corefoundation.m	Tue Feb  3 10:00:27 2009
@@ -102,12 +102,24 @@
 	/*
 	 * First look for an already registerd type
 	 */
+	if (encoding[0] != _C_ID) {
+		if (PyObjCPointerWrapper_RegisterID(encoding) == -1) {
+			return NULL;
+		}
+	}
+	if (typeID == 0) {
+		/* Partially registered type, just wrap is a
+		 * a plain CFTypeRef
+		 */
+		return NULL;
+	}
 
 	PyObject* cf = PyLong_FromUnsignedLongLong(typeID);
 	if (cf == NULL) {
 		return NULL;
 	}
 
+
 	result = PyDict_GetItem(gTypeid2class, cf);
 	if (result != NULL) {
 		/* This type is the same as an already registered type,
@@ -179,12 +191,6 @@
 		return NULL;
 	}
 
-	if (PyObjCPointerWrapper_RegisterID(encoding) == -1) {
-		PyDict_DelItem(gTypeid2class, cf);
-		Py_DECREF(cf);
-		Py_DECREF(result);
-		return NULL;
-	}
 	Py_DECREF(cf); cf = NULL;
 
 	/* Force an artificially high refcount to avoid deallocation of the

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	Tue Feb  3 10:00:27 2009
@@ -389,7 +389,7 @@
 		return &ffi_type_pointer;
 	default:
 		PyErr_Format(PyExc_NotImplementedError,
-			"Type '%#x' not supported", *argtype);
+			"Type '%#x' (%c) not supported", *argtype, *argtype);
 		return NULL;
 	}
 }

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-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.