Ronald Oussoren avatar Ronald Oussoren committed e8dcb55

- add wrapper for NSCoder decodeBytesWithReturnedLength: + more tests
- don't realloc(NULL, ...) in class-list.m, use malloc instead.

Comments (0)

Files changed (6)

pyobjc/Doc/api-notes-macosx.txt

   This method is not supported.
 
 * ``graphicsPort``
-  This method is not yet supported.
+  This method is not yet supported, MacPython doesn't wrap ``CGContextRef``
+  at the moment.
 
 Class ``NSLayoutManager``
 .........................
 The following methods are not supported in the current version of PyObjC.
 This limitation will be lifted in a future version of the bridge.
 
-* ``decodeBytesWithReturnedLength:``
-
-* ``decodeBytesForKey:returnedLength:``
-
 * ``encodeValuesOfObjCType:``
 
   Use multiple calls to ``encodeValueOfObjCType:at:`` instead.
 * ``deserializeInts:count:atIndex:``
   This is a depricated method, see Apple documentation.
 
+* ``getBytes:``, ``getBytes:length:``, ``getBytes:range:``
+  Use ``bytes`` instead, and then use subscripting to get the
+  desired range.
 
 
 Class ``NSDictionary``

pyobjc/Lib/Foundation/test/test_nsarray.py

 
         self.assertEquals(a, (0, 1, 2, 3))
 
+    def test_unsupportedMethods(self):
+        """
+        Check that calling unsupported methods results in a TypeError
+        """
+        o = NSArray.arrayWithArray_(range(4))
+        self.assertRaises(TypeError, o.getObjects_)
+        self.assertRaises(TypeError, o.getObjects_range_, (1,2))
+        self.assertRaises(TypeError, o.apply_context_, lambda x, y:None, 0)
+
 if __name__ == '__main__':
     unittest.main()

pyobjc/Lib/Foundation/test/test_nscoder.py

 
 from Foundation import *
 
-
 class TestNSCoderUsage(unittest.TestCase):
     if not hasattr(unittest.TestCase, 'assertAlmostEquals'):
+        # XXX Move to a PyObjC unittest module?
         def assertAlmostEquals(self, val1, val2):
             self.assert_ (abs(val1 - val2) <  0.000001)
 
                 coder.encodeValueOfObjCType_at_(objc._C_INT, 2)
                 coder.encodeValueOfObjCType_at_(objc._C_DBL, 2.0)
                 coder.encodeArrayOfObjCType_count_at_(objc._C_DBL, 4, (1.0, 2.0, 3.0, 4.0))
+                coder.encodeBytes_length_("hello world!", 5)
 
             def initWithCoder_(self, coder):
                 # NSObject does not implement NSCoding, no need to
                 self.intVal = coder.decodeValueOfObjCType_at_(objc._C_INT)
                 self.dblVal = coder.decodeValueOfObjCType_at_(objc._C_DBL)
                 self.dblArray = coder.decodeArrayOfObjCType_count_at_(objc._C_DBL, 4)
+                self.decodedBytes = coder.decodeBytesWithReturnedLength_()
                 return self
 
         origObj = CoderClass1.alloc().init()
         self.assertAlmostEquals(newObj.dblArray[1], 2.0)
         self.assertAlmostEquals(newObj.dblArray[2], 3.0)
         self.assertAlmostEquals(newObj.dblArray[3], 4.0)
+        self.assertEquals(newObj.decodedBytes[0], "hello")
+        self.assertEquals(newObj.decodedBytes[1], 5)
 
 if __name__ == '__main__':
     unittest.main( )

pyobjc/Modules/Foundation/_FoundationMapping_NSCoder.m

  * - decodeArrayOfObjCType:count:at:		[call, imp]
  * - encodeBytes:length:			[call, imp]
  * - encodeBytes:length:forKey:			[call, imp]
- *
- * TODO:
- * - decodeBytesWithReturnedLength:
- * - decodeBytesForKey:returnedLength:
- * - encodeValuesOfObjCType: 
- * - decodeValuesOfObjCType:
+ * - decodeBytesWithReturnedLength:		[call, imp]
+ * - decodeBytesForKey:returnedLength:		[call, imp]
  *
  * Unsupported method:
+ * - encodeValuesOfObjCTypes: 
+ * - decodeValuesOfObjCTypes:
+ *   These two require varargs parsing, might add this later on
  * - decodeBytesWithoutReturnedLength:
  *   Use ...WithReturnedLenght instead.
  *
 #include "pyobjc-api.h"
 
 
-static PyObject* call_NSCoder_encodeValueOfObjCType_at_(
-		PyObject* method __attribute__((__unused__)), PyObject* self, PyObject* arguments)
+static PyObject* 
+call_NSCoder_encodeValueOfObjCType_at_(
+	PyObject* method, PyObject* self, PyObject* arguments)
 {
 	char* signature;
 	PyObject* value;
 
 	NS_DURING
 		PyObjC_InitSuper(&super, 
-			PyObjCClass_GetClass((PyObject*)(self->ob_type)),
+			PyObjCSelector_GetClass(method),
 			PyObjCObject_GetObject(self));
 
 		(void)objc_msgSendSuper(&super,
-				@selector(encodeValueOfObjCType:at:),
+				PyObjCSelector_GetSelector(method),
 				signature, buf);
 		result = Py_None;
 		Py_INCREF(result);
 	return result;
 }
 
-static void imp_NSCoder_encodeValueOfObjCType_at_(id self, SEL sel,
-		char* signature, void* buf)	
+static void 
+imp_NSCoder_encodeValueOfObjCType_at_(id self, SEL sel,
+	char* signature, void* buf)	
 {
 	PyObject* result;
 	PyObject* arglist;
 
-	arglist = PyTuple_New(2);
+	arglist = PyTuple_New(3);
 	if (arglist == NULL) {
 		PyObjCErr_ToObjC();
 		return;
 	}
-
-	PyTuple_SetItem(arglist, 0, PyString_FromString(signature));
-	PyTuple_SetItem(arglist, 1, PyObjC_ObjCToPython(signature, buf));
+	
+	PyTuple_SetItem(arglist, 0, PyObjC_IdToPython(self));
+	PyTuple_SetItem(arglist, 1, PyString_FromString(signature));
+	PyTuple_SetItem(arglist, 2, PyObjC_ObjCToPython(signature, buf));
 
 	if (PyErr_Occurred()) {
 		Py_DECREF(arglist);
 }
 
 
-static PyObject* call_NSCoder_encodeArrayOfObjCType_count_at_(
-		PyObject* method __attribute__((__unused__)), PyObject* self, PyObject* arguments)
+static PyObject* 
+call_NSCoder_encodeArrayOfObjCType_count_at_(
+	PyObject* method, PyObject* self, PyObject* arguments)
 {
 	char* signature;
 	int   count;
 
 	NS_DURING
 		PyObjC_InitSuper(&super, 
-			PyObjCClass_GetClass((PyObject*)(self->ob_type)),
+			PyObjCSelector_GetClass(method),
 			PyObjCObject_GetObject(self));
 
 		(void)objc_msgSendSuper(&super,
-				@selector(encodeArrayOfObjCType:count:at:),
+				PyObjCSelector_GetSelector(method),
 				signature, count, buf);
 		result = Py_None;
 		Py_INCREF(result);
 	return result;
 }
 
-static void imp_NSCoder_encodeArrayOfObjCType_count_at_(id self, SEL sel,
-		char* signature, unsigned count, void* buf)	
+static void 
+imp_NSCoder_encodeArrayOfObjCType_count_at_(id self, SEL sel,
+	char* signature, unsigned count, void* buf)	
 {
 	PyObject* result;
 	PyObject* arglist;
 	int       size;
 	int       i;
 
-	arglist = PyTuple_New(3);
+	arglist = PyTuple_New(4);
 	if (arglist == NULL) {
 		PyObjCErr_ToObjC();
 		return;
 		return;
 	}
 
-	PyTuple_SetItem(arglist, 0, PyString_FromString(signature));
-	PyTuple_SetItem(arglist, 1, PyInt_FromLong(count));
+	PyTuple_SetItem(arglist, 0, PyObjC_IdToPython(self));
+	PyTuple_SetItem(arglist, 1, PyString_FromString(signature));
+	PyTuple_SetItem(arglist, 2, PyInt_FromLong(count));
 
 	values = PyTuple_New(count);
 	if (values == NULL) {
 		PyObjCErr_ToObjC();
 		return;
 	}
-	PyTuple_SetItem(arglist, 2, values);
+	PyTuple_SetItem(arglist, 3, values);
 
 	if (PyErr_Occurred()) {
 		Py_DECREF(arglist);
 	Py_DECREF(result);
 }
 
-static PyObject* call_NSCoder_decodeValueOfObjCType_at_(
-		PyObject* method __attribute__((__unused__)), PyObject* self, PyObject* arguments)
+static PyObject* 
+call_NSCoder_decodeValueOfObjCType_at_(
+	PyObject* method, PyObject* self, PyObject* arguments)
 {
 	char* signature;
 	PyObject* value;
 
 	NS_DURING
 		PyObjC_InitSuper(&super, 
-			PyObjCClass_GetClass((PyObject*)(self->ob_type)),
+			PyObjCSelector_GetClass(method),
 			PyObjCObject_GetObject(self));
 
 		(void)objc_msgSendSuper(&super,
-				@selector(decodeValueOfObjCType:at:),
+				PyObjCSelector_GetSelector(method),
 				signature, buf);
 	NS_HANDLER
 		PyObjCErr_FromObjC(localException);
 	return value;
 }
 
-static void imp_NSCoder_decodeValueOfObjCType_at_(id self, SEL sel,
-		char* signature, void* buf)	
+static void 
+imp_NSCoder_decodeValueOfObjCType_at_(id self, SEL sel,
+	char* signature, void* buf)	
 {
 	PyObject* result;
 	PyObject* arglist;
 	int err;
 
-	arglist = PyTuple_New(1);
+	arglist = PyTuple_New(2);
 	if (arglist == NULL) {
 		PyObjCErr_ToObjC();
 		return;
 	}
 
-	PyTuple_SetItem(arglist, 0, PyString_FromString(signature));
+	PyTuple_SetItem(arglist, 0, PyObjC_IdToPython(self));
+	PyTuple_SetItem(arglist, 1, PyString_FromString(signature));
 
 	if (PyErr_Occurred()) {
 		Py_DECREF(arglist);
 	}
 }
 
-static PyObject* call_NSCoder_decodeArrayOfObjCType_count_at_(
-		PyObject* method __attribute__((__unused__)), PyObject* self, PyObject* arguments)
+static PyObject* 
+call_NSCoder_decodeArrayOfObjCType_count_at_(
+	PyObject* method, PyObject* self, PyObject* arguments)
 {
 	char* signature;
 	int   count;
 
 	NS_DURING
 		PyObjC_InitSuper(&super, 
-			PyObjCClass_GetClass((PyObject*)(self->ob_type)),
+			PyObjCSelector_GetClass(method), 
 			PyObjCObject_GetObject(self));
 
 		(void)objc_msgSendSuper(&super,
-				@selector(decodeArrayOfObjCType:count:at:),
+				PyObjCSelector_GetSelector(method),
 				signature, count, buf);
 	NS_HANDLER
 		PyObjCErr_FromObjC(localException);
 	return result;
 }
 
-static void imp_NSCoder_decodeArrayOfObjCType_count_at_(id self, SEL sel,
-		char* signature, unsigned count, void* buf)	
+static void 
+imp_NSCoder_decodeArrayOfObjCType_count_at_(id self, SEL sel,
+	char* signature, unsigned count, void* buf)	
 {
 	PyObject* result;
 	PyObject* arglist;
 	int       i;
 	int res;
 
-	arglist = PyTuple_New(2);
+	arglist = PyTuple_New(3);
 	if (arglist == NULL) {
 		PyObjCErr_ToObjC();
 		return;
 		return;
 	}
 
-	PyTuple_SetItem(arglist, 0, PyString_FromString(signature));
-	PyTuple_SetItem(arglist, 1, PyInt_FromLong(count));
+	PyTuple_SetItem(arglist, 0, PyObjC_IdToPython(self));
+	PyTuple_SetItem(arglist, 1, PyString_FromString(signature));
+	PyTuple_SetItem(arglist, 2, PyInt_FromLong(count));
 
 	if (PyErr_Occurred()) {
 		Py_DECREF(arglist);
 	Py_DECREF(values);
 }
 
-static PyObject* call_NSCoder_encodeBytes_length_(
-		PyObject* method __attribute__((__unused__)), 
-		PyObject* self, PyObject* arguments)
+static PyObject* 
+call_NSCoder_encodeBytes_length_(
+	PyObject* method, PyObject* self, PyObject* arguments)
 {
 	char* bytes;
 	int    size;
+	int    length;
 
 	PyObject* result;
 	struct objc_super super;
 
-	if  (!PyArg_ParseTuple(arguments, "t#", &bytes, &size)) {
+	if  (!PyArg_ParseTuple(arguments, "t#i", &bytes, &size, &length)) {
+		return NULL;
+	}
+
+	if (length > size) {
+		PyErr_SetString(PyExc_ValueError, "length > len(buf)");
 		return NULL;
 	}
 
 	NS_DURING
 		PyObjC_InitSuper(&super, 
-			PyObjCClass_GetClass((PyObject*)(self->ob_type)),
+			PyObjCSelector_GetClass(method),
 			PyObjCObject_GetObject(self));
 
 		(void)objc_msgSendSuper(&super,
-				@selector(encodeBytes:length:),
-				bytes, size);
+				PyObjCSelector_GetSelector(method),
+				bytes, length);
 		result = Py_None;
 		Py_INCREF(result);
 	NS_HANDLER
 	return result;
 }
 
-static void imp_NSCoder_encodeBytes_length_(id self, SEL sel,
-		char* bytes, int length)	
+static void 
+imp_NSCoder_encodeBytes_length_(id self, SEL sel, char* bytes, int length)	
 {
 	PyObject* result;
 	PyObject* arglist;
 
-	arglist = PyTuple_New(2);
+	arglist = PyTuple_New(3);
 	if (arglist == NULL) {
 		PyObjCErr_ToObjC();
 		return;
 	}
 
-	PyTuple_SetItem(arglist, 0, PyString_FromStringAndSize(bytes, length));
-	PyTuple_SetItem(arglist, 1, PyInt_FromLong(length));
+	PyTuple_SetItem(arglist, 0, PyObjC_IdToPython(self));
+	PyTuple_SetItem(arglist, 1, PyString_FromStringAndSize(bytes, length));
+	PyTuple_SetItem(arglist, 2, PyInt_FromLong(length));
 
 	if (PyErr_Occurred()) {
 		Py_DECREF(arglist);
 	Py_DECREF(result);
 }
 
-static PyObject* call_NSCoder_encodeBytes_length_forKey_(
-		PyObject* method __attribute__((__unused__)), 
-		PyObject* self, PyObject* arguments)
+static PyObject* 
+call_NSCoder_decodeBytesWithReturnedLength_(
+	PyObject* method, PyObject* self, PyObject* arguments)
+{
+	char* 		bytes;
+	unsigned int    size = 0;
+	PyObject* v;
+	PyObject* result;
+	struct objc_super super;
+
+	if  (!PyArg_ParseTuple(arguments, "")) {
+		return NULL;
+	}
+
+	NS_DURING
+		PyObjC_InitSuper(&super, 
+			PyObjCSelector_GetClass(method),
+			PyObjCObject_GetObject(self));
+
+		bytes = (void*)objc_msgSendSuper(&super,
+				PyObjCSelector_GetSelector(method),
+				&size);
+	NS_HANDLER
+		PyObjCErr_FromObjC(localException);
+		bytes = NULL;
+	NS_ENDHANDLER
+
+	if (bytes == NULL) {
+		if (PyErr_Occurred()) {
+			return NULL;
+		}
+
+		result = PyTuple_New(2);
+		if (result == NULL) {
+			return NULL;
+		}
+
+		PyTuple_SET_ITEM(result, 0, Py_None);
+		Py_INCREF(Py_None);
+
+		v = PyObjC_ObjCToPython(@encode(unsigned), &size);
+		if (v == NULL) {
+			Py_DECREF(result);
+			return NULL;
+		}
+		PyTuple_SET_ITEM(result, 1, v);
+		return result;
+	}
+
+	result = PyTuple_New(2);
+	if (result == NULL) {
+		return NULL;
+	}
+
+	v = PyString_FromStringAndSize((char*)bytes, size);
+	if (v == NULL) {
+		Py_DECREF(result);
+		return NULL;
+	}
+
+	PyTuple_SET_ITEM(result, 0, v);
+
+	v = PyObjC_ObjCToPython(@encode(unsigned), &size);
+	if (v == NULL) {
+		Py_DECREF(result);
+		return NULL;
+	}
+	PyTuple_SET_ITEM(result, 1, v);
+
+	return result;
+}
+
+static void* 
+imp_NSCoder_decodeBytesWithReturnedLength_(id self, SEL sel, unsigned* length)
+{
+	PyObject* result;
+	PyObject* arglist;
+	void* bufptr;
+	int buflen;
+	int len;
+
+	arglist = PyTuple_New(1);
+	if (arglist == NULL) {
+		PyObjCErr_ToObjC();
+		return nil;
+	}
+
+	PyTuple_SetItem(arglist, 0, PyObjC_IdToPython(self));
+
+	if (PyErr_Occurred()) {
+		Py_DECREF(arglist);
+		PyObjCErr_ToObjC();
+		return nil;
+	}
+
+	result = PyObjC_CallPython(self, sel, arglist, NULL);
+	Py_DECREF(arglist);
+	if (result == NULL) {
+		PyObjCErr_ToObjC();
+		return nil;
+	}
+
+	if (!PyTuple_Check(result)) {
+		Py_DECREF(result);
+		PyErr_SetString(PyExc_ValueError, 
+			"Should return (bytes, length)");
+		PyObjCErr_ToObjC();
+		return nil;
+	}
+
+	if (PyObject_AsReadBuffer(
+			PyTuple_GET_ITEM(result, 0), 
+			(const void**)&bufptr, &buflen) < 0) {
+		
+		Py_DECREF(result);
+		PyObjCErr_ToObjC();
+		return nil;
+	}
+	
+	if (PyObjC_PythonToObjC(@encode(int), 
+			PyTuple_GET_ITEM(result, 1), &len) < 0) {
+		Py_DECREF(result);
+		return nil;
+	}
+
+	if (len < buflen) {
+		Py_DECREF(result);
+		PyErr_SetString(PyExc_ValueError, 
+			"Should return (bytes, length)");
+		PyObjCErr_ToObjC();
+		return nil;
+	}
+
+	*length = len;
+
+	/* Should return an autoreleased buffer, do this by createing an 
+	 * NSData that will release the buffer
+	 */
+	bufptr =  (void*)[[[[NSData alloc] initWithBytes:bufptr length:len] 
+		  autorelease] bytes];
+
+	Py_DECREF(result);
+
+	return bufptr;
+}
+
+static PyObject* 
+call_NSCoder_decodeBytesForKey_returnedLength_(
+	PyObject* method, PyObject* self, PyObject* arguments)
+{
+	char* 		bytes;
+	unsigned int    size = 0;
+	PyObject* v;
+	PyObject* result;
+	id key;
+	struct objc_super super;
+
+	if  (!PyArg_ParseTuple(arguments, "O&", PyObjCObject_Convert, &key)) {
+		return NULL;
+	}
+
+	NS_DURING
+		PyObjC_InitSuper(&super, 
+			PyObjCSelector_GetClass(method),
+			PyObjCObject_GetObject(self));
+
+		bytes = (void*)objc_msgSendSuper(&super,
+				PyObjCSelector_GetSelector(method),
+				key,
+				&size);
+	NS_HANDLER
+		PyObjCErr_FromObjC(localException);
+		bytes = NULL;
+	NS_ENDHANDLER
+
+	if (bytes == NULL) {
+		if (PyErr_Occurred()) {
+			return NULL;
+		}
+
+		result = PyTuple_New(2);
+		if (result == NULL) {
+			return NULL;
+		}
+
+		PyTuple_SET_ITEM(result, 0, Py_None);
+		Py_INCREF(Py_None);
+
+		v = PyObjC_ObjCToPython(@encode(unsigned), &size);
+		if (v == NULL) {
+			Py_DECREF(result);
+			return NULL;
+		}
+		PyTuple_SET_ITEM(result, 1, v);
+		return result;
+	}
+
+	result = PyTuple_New(2);
+	if (result == NULL) {
+		return NULL;
+	}
+
+	v = PyString_FromStringAndSize(bytes, size);
+	if (v == NULL) {
+		Py_DECREF(result);
+		return NULL;
+	}
+
+	PyTuple_SET_ITEM(result, 0, v);
+
+	v = PyObjC_ObjCToPython(@encode(unsigned), &size);
+	if (v == NULL) {
+		Py_DECREF(result);
+		return NULL;
+	}
+	PyTuple_SET_ITEM(result, 1, v);
+
+	return result;
+}
+
+static void* 
+imp_NSCoder_decodeBytesForKey_returnedLength_(id self, SEL sel, id key, unsigned* length)
+{
+	PyObject* result;
+	PyObject* arglist;
+	void* bufptr;
+	int buflen;
+	int len;
+
+	arglist = PyTuple_New(2);
+	if (arglist == NULL) {
+		PyObjCErr_ToObjC();
+		return nil;
+	}
+
+	PyTuple_SetItem(arglist, 0, PyObjC_IdToPython(self));
+	PyTuple_SetItem(arglist, 1, PyObjC_IdToPython(key));
+
+	if (PyErr_Occurred()) {
+		Py_DECREF(arglist);
+		PyObjCErr_ToObjC();
+		return nil;
+	}
+
+	result = PyObjC_CallPython(self, sel, arglist, NULL);
+	Py_DECREF(arglist);
+	if (result == NULL) {
+		PyObjCErr_ToObjC();
+		return nil;
+	}
+
+	if (!PyTuple_Check(result)) {
+		Py_DECREF(result);
+		PyErr_SetString(PyExc_ValueError, 
+			"Should return (bytes, length)");
+		PyObjCErr_ToObjC();
+		return nil;
+	}
+
+	if (PyObject_AsReadBuffer(
+			PyTuple_GET_ITEM(result, 0), 
+			(const void**)&bufptr, &buflen) < 0) {
+		
+		Py_DECREF(result);
+		PyObjCErr_ToObjC();
+		return nil;
+	}
+	
+	if (PyObjC_PythonToObjC(@encode(int), 
+			PyTuple_GET_ITEM(result, 1), &len) < 0) {
+		Py_DECREF(result);
+		return nil;
+	}
+
+	if (len < buflen) {
+		Py_DECREF(result);
+		PyErr_SetString(PyExc_ValueError, 
+			"Should return (bytes, length)");
+		PyObjCErr_ToObjC();
+		return nil;
+	}
+
+	*length = len;
+
+	/* Should return an autoreleased buffer, do this by createing an 
+	 * NSData that will release the buffer
+	 */
+	bufptr =  (void*)[[[[NSData alloc] initWithBytes:bufptr length:len] 
+		  autorelease] bytes];
+
+	Py_DECREF(result);
+
+	return bufptr;
+}
+static PyObject* 
+call_NSCoder_encodeBytes_length_forKey_(
+	PyObject* method, PyObject* self, PyObject* arguments)
 {
 	char* bytes;
 	int    size;
 
 	NS_DURING
 		PyObjC_InitSuper(&super, 
-			PyObjCClass_GetClass((PyObject*)(self->ob_type)),
+			PyObjCSelector_GetClass(method),
 			PyObjCObject_GetObject(self));
 
 		(void)objc_msgSendSuper(&super,
-				@selector(encodeBytes:length:forKey:),
+				PyObjCSelector_GetSelector(method),
 				bytes, size, key);
 		result = Py_None;
 		Py_INCREF(result);
 	return result;
 }
 
-static void imp_NSCoder_encodeBytes_length_forKey_(id self, SEL sel,
-		char* bytes, int length, id key)	
+static void 
+imp_NSCoder_encodeBytes_length_forKey_(
+	id self, SEL sel, char* bytes, int length, id key)	
 {
 	PyObject* result;
 	PyObject* arglist;
 
-	arglist = PyTuple_New(3);
+	arglist = PyTuple_New(4);
 	if (arglist == NULL) {
 		PyObjCErr_ToObjC();
 		return;
 	}
 
-	PyTuple_SetItem(arglist, 0, PyString_FromStringAndSize(bytes, length));
-	PyTuple_SetItem(arglist, 1, PyInt_FromLong(length));
-	PyTuple_SetItem(arglist, 2, PyObjC_IdToPython(key));
+	PyTuple_SetItem(arglist, 0, PyObjC_IdToPython(self));
+	PyTuple_SetItem(arglist, 1, PyString_FromStringAndSize(bytes, length));
+	PyTuple_SetItem(arglist, 2, PyInt_FromLong(length));
+	PyTuple_SetItem(arglist, 3, PyObjC_IdToPython(key));
 
 	if (PyErr_Occurred()) {
 		Py_DECREF(arglist);
 		return -1;
 	}
 
+	if (PyObjC_RegisterMethodMapping(
+			classNSCoder,
+			@selector(decodeBytesWithReturnedLength:),
+			call_NSCoder_decodeBytesWithReturnedLength_,
+			(IMP)imp_NSCoder_decodeBytesWithReturnedLength_) < 0) {
+		return -1;
+	}
+
+	if (PyObjC_RegisterMethodMapping(
+			classNSCoder,
+			@selector(decodeBytesForKey:returnedLength::),
+			call_NSCoder_decodeBytesForKey_returnedLength_,
+			(IMP)imp_NSCoder_decodeBytesForKey_returnedLength_) < 0) {
+		return -1;
+	}
+
+	if (PyObjC_RegisterMethodMapping(
+			classNSCoder,
+			@selector(decodeBytesWithoutReturnedLength),
+			PyObjCUnsupportedMethod_Caller,
+			PyObjCUnsupportedMethod_IMP) < 0) {
+		return -1;
+	}
+
+	if (PyObjC_RegisterMethodMapping(
+			classNSCoder,
+			@selector(encodeValuesOfObjCTypes:),
+			PyObjCUnsupportedMethod_Caller,
+			PyObjCUnsupportedMethod_IMP) < 0) {
+		return -1;
+	}
+
+	if (PyObjC_RegisterMethodMapping(
+			classNSCoder,
+			@selector(decodeValuesOfObjCTypes:),
+			PyObjCUnsupportedMethod_Caller,
+			PyObjCUnsupportedMethod_IMP) < 0) {
+		return -1;
+	}
+
 	return 0;
 }

pyobjc/Modules/Foundation/_FoundationMapping_NSValue.m

  * -getValue:
  * -pointerValue:
  *
- NSValue_getValue_
- NSValue_pointerValue
-
  */
 #include <Python.h>
 #include <Foundation/Foundation.h>

pyobjc/Modules/objc/class-list.m

 		while (bufferLen < neededLen) {
 			Class*    newBuffer;
 			bufferLen = neededLen;
-			newBuffer = realloc(buffer, sizeof(Class) * bufferLen);
+			if (buffer == NULL) {
+				newBuffer = malloc(sizeof(Class) * bufferLen);
+			} else {
+				newBuffer = realloc(buffer, sizeof(Class) * bufferLen);
+			}
 			if (newBuffer == NULL) {
 				PyErr_SetString(PyExc_MemoryError, 
 					"ObjC_GetClassList");
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.