Commits

Bob Ippolito committed f4efdfd

Use sequence protocol
Use "PyObjCRT" function instead of class_addMethods directly

Comments (0)

Files changed (2)

pyobjc/Modules/objc/module.m

 		return NULL;
 	}
 
+	methodsArray = PySequence_Fast(methodsArray, "methodsArray must be a sequence");
+	if (methodsArray == NULL) return NULL;
+	
 	targetClass  = PyObjCClass_GetClass(classObject);
-	methodCount  = PyList_Size(methodsArray);
+	methodCount  = PySequence_Fast_GET_SIZE(methodsArray);
 
 	if (methodCount == 0) {
 		Py_INCREF(Py_None);
 	methodsToAdd->method_count = methodCount;
 
 	for (methodIndex = 0; methodIndex < methodCount; methodIndex++) {
-		PyObject* aMethod = PyList_GetItem(methodsArray, methodIndex);
+		PyObject* aMethod = PySequence_Fast_GET_ITEM(methodsArray, methodIndex);
 		struct objc_method *objcMethod;
 
 		/* check
 	}
 
 	/* add the methods */
-	class_addMethods(targetClass, methodsToAdd);
+	PyObjCRT_ClassAddMethodList(targetClass, methodsToAdd);
 
 	/* This one shouldn't be necessary, but we get crashes without 
 	 * the next line. The crashes happen when 'targetClass' is a Python

pyobjc/Modules/objc/objc-runtime-apple.h

 	m->method_imp = imp;
 }
 
-static void
+static inline void
 PyObjCRT_ClassAddMethodList(Class cls, struct objc_method_list* lst)
 {
 	class_addMethods(cls, lst);