Ronald Oussoren committed 31e85b1

Python2.5 related cleanups

Comments (0)

Files changed (15)


 @interface OC_PythonData : NSData
 	PyObject* value;
-	unsigned buffer_len;
+	Py_ssize_t buffer_len;
 	const void *buffer;


  * XXX - document these, internal
--(BOOL)wrappedKey:(id*)keyPtr value:(id*)valuePtr atPosition:(int*)positionPtr;
+-(BOOL)wrappedKey:(id*)keyPtr value:(id*)valuePtr atPosition:(Py_ssize_t*)positionPtr;
 -(int)depythonify:(PyObject*)v toId:(id*)datum;


 + newWithObject:(PyObject *) obj;
 + depythonifyTable;
 + pythonifyStructTable;
-+ (PyObject *)__pythonifyStruct:(PyObject *) obj withType:(const char *) type length:(int) length;
++ (PyObject *)__pythonifyStruct:(PyObject *) obj withType:(const char *) type length:(Py_ssize_t) length;
 + newWithCoercedObject:(PyObject *) obj;
 - initWithObject:(PyObject *) obj;


 typedef void (*PyObjCFFI_ClosureFunc)(ffi_cif*, void*, void**, void*);
 void PyObjCFFI_FreeCIF(ffi_cif* cif);
-ffi_cif* PyObjCFFI_CIFForSignature(PyObjCMethodSignature* signature, int* pArgOffset);
+ffi_cif* PyObjCFFI_CIFForSignature(PyObjCMethodSignature* signature, Py_ssize_t* pArgOffset);
 IMP PyObjCFFI_MakeClosure(PyObjCMethodSignature* signature,
 			PyObjCFFI_ClosureFunc func, void* userdata);
 void* PyObjCFFI_FreeClosure(IMP closure);
 PyObject *PyObjCFFI_Caller(PyObject *aMeth, PyObject* self, PyObject *args);
 int PyObjCFFI_CountArguments(
-	PyObjCMethodSignature* methinfo, int argOffset, 
-	int* byref_in_count,
-	int* byref_out_count,
-	int* plain_count,
-	int* argbuf_len);
+	PyObjCMethodSignature* methinfo, Py_ssize_t argOffset, 
+	Py_ssize_t* byref_in_count,
+	Py_ssize_t* byref_out_count,
+	Py_ssize_t* plain_count,
+	Py_ssize_t* argbuf_len);
 int PyObjCFFI_ParseArguments(
-	PyObjCMethodSignature* methinfo, int argOffset,
-	PyObject* args, int argbuf_cur, unsigned char* argbuf,
+	PyObjCMethodSignature* methinfo, Py_ssize_t argOffset,
+	PyObject* args, Py_ssize_t argbuf_cur, unsigned char* argbuf,
 	void** byref,
 	ffi_type** arglist, void** values);
 PyObject* PyObjCFFI_BuildResult(
-	PyObjCMethodSignature* methinfo, int argOffset,
-	void* pRetval, void** byref, int byref_out_count,
+	PyObjCMethodSignature* methinfo, Py_ssize_t argOffset,
+	void* pRetval, void** byref, Py_ssize_t byref_out_count,
 	PyObject* self, int flags);
 #endif /* PyObjC_FFI_SUPPORT_H */


  * 	pointers point to substrings of signature.
 typedef struct {
-	int   retainCount;
-	int   nargs;
+	int retainCount;
+	Py_ssize_t nargs;
 	const char* rettype;
 	const char* signature;
 	const char* argtype[1];


 	Class class;
 	PyObject* sel_to_py;
 	int method_magic;
-	int dictoffset;
+	Py_ssize_t dictoffset;
 	PyObject* delmethod;
 	int hasPythonImpl;
 	int generation;
 int PyObjCClass_IsSubClass(Class child, Class parent);
 int ObjC_RegisterClassProxy(Class cls, PyObject* classProxy);
 void PyObjCClass_CheckMethodList(PyObject* cls, int recursive);
-int PyObjCClass_DictOffset(PyObject* cls);
+Py_ssize_t PyObjCClass_DictOffset(PyObject* cls);
 PyObject* PyObjCClass_GetDelMethod(PyObject* cls);
 void PyObjCClass_SetDelMethod(PyObject* cls, PyObject* newval);
 int  PyObjCClass_HasPythonImplementation(PyObject* cls);


-extern struct objc_method_list* PyObjCRT_AllocMethodList(int);
-extern struct objc_protocol_list* PyObjCRT_AllocProtocolList(int);
+extern struct objc_method_list* PyObjCRT_AllocMethodList(Py_ssize_t);
+extern struct objc_protocol_list* PyObjCRT_AllocProtocolList(Py_ssize_t);
 typedef Method PyObjCRT_Method_t;
 typedef Ivar PyObjCRT_Ivar_t;


-extern MethodList_t PyObjCRT_AllocMethodList(int);
-extern struct objc_protocol_list* PyObjCRT_AllocProtocolList(int);
+extern MethodList_t PyObjCRT_AllocMethodList(Py_ssize_t);
+extern struct objc_protocol_list* PyObjCRT_AllocProtocolList(Py_ssize_t);
 typedef Method_t PyObjCRT_Method_t;


 					PyObject *arg,
 					void *datum);
-extern int PyObjCRT_SizeOfReturnType(const char* type);
-extern int PyObjCRT_SizeOfType(const char *type);
-extern int PyObjCRT_AlignOfType(const char *type);
+extern Py_ssize_t PyObjCRT_SizeOfReturnType(const char* type);
+extern Py_ssize_t PyObjCRT_SizeOfType(const char *type);
+extern Py_ssize_t PyObjCRT_AlignOfType(const char *type);
 extern const char *PyObjCRT_SkipTypeSpec (const char *type);
 extern const char* PyObjCRT_SkipTypeQualifiers (const char* type);
 extern int PyObjCRT_SetupClass(
-	Class, Class, const char*, Class, Class, int, struct objc_ivar_list*,
+	Class, Class, const char*, Class, Class, Py_ssize_t, struct objc_ivar_list*,
 	struct objc_protocol_list*);
 extern void PyObjCRT_ClearClass(Class cls);


 void    PyObjC_FreeCArray(int, void*);
 int     PyObjC_PythonToCArray(const char*, PyObject*, PyObject*, void**, int*);
-PyObject* PyObjC_CArrayToPython(const char*, void*, int);
+PyObject* PyObjC_CArrayToPython(const char*, void*, Py_ssize_t);
 int     PyObjC_IsPythonKeyword(const char* word);


  * - Version 14 adds PyObjCObject_NewTransient, PyObjCObject_ReleaseTransient
  * - Version 15 changes the interface of PyObjCObject_New
  * - Version 16 adds PyObjC_PerformWeaklinking
+ * - Version 17 introduces Py_ssize_t support
 #define PYOBJC_API_NAME "__C_API__"
 	PyObject* (*objc_to_py)(const char*, void*);
 	/* PyObjC_SizeOfType */
-	int 	   (*sizeof_type)(const char*);
+	Py_ssize_t   (*sizeof_type)(const char*);
 	/* PyObjCSelector_GetClass */
 	Class	   (*sel_get_class)(PyObject* sel);
 	void (*err_python_to_objc_gil)(PyGILState_STATE* state);
 	/* PyObjCRT_AlignOfType */
-	int (*alignof_type)(const char* typestr);
+	Py_ssize_t (*alignof_type)(const char* typestr);
 	/* PyObjCRT_SELName */
 	const char* (*selname)(SEL sel);
 	int     (*py_to_c_array)(const char*, PyObject*, PyObject*, void**, int*);
 	/* PyObjC_CArrayToPython */
-	PyObject* (*c_array_to_py)(const char*, void*, int);
+	PyObject* (*c_array_to_py)(const char*, void*, Py_ssize_t);
 	/* PyObjC_RegisterStructType */
-	PyObject* (*register_struct)(const char*, const char*, const char*, initproc, int, const char**);
+	PyObject* (*register_struct)(const char*, const char*, const char*, initproc, Py_ssize_t, const char**);
 	/* PyObjCIMP_Type */
 	PyTypeObject* imp_type;


+#if (PY_VERSION_HEX < 0x02050000)
+typedef int Py_ssize_t;
+#define PY_FORMAT_SIZE_T ""
+#define Py_ARG_SIZE_T "n"
+#define Py_ARG_SIZE_T "i"
 #endif /* PyObjC_COMPAT_H */


 // Loading in AppKit on Mac OS X 10.3 results in
 // a bit less than 1500 classes.
 #include <Python.h>
 #include "structmember.h"


 	const char* name,
 	const char* doc,
 	initproc tpinit,
-	int numFields,
+	Py_ssize_t numFields,
 	const char** fieldnames,
 	const char* typestr);
 	const char* name,
 	const char* doc,
 	initproc tpinit,
-	int numFields,
+	Py_ssize_t numFields,
 	const char** fieldnames);
  *     The returned instance is uninitialized, all fields are NULL. The 
  *     __init__ method has not been called.
-PyObject* PyObjC_CreateRegisteredStruct(const char* signature, int len);
+PyObject* PyObjC_CreateRegisteredStruct(const char* signature, Py_ssize_t len);
 #endif /* PyObjC_STRUCT_MEMBER */


  *     This value is used by the objc-class module to detect if the methods in
  *     a class should be regenerated.
-extern int PyObjC_MappingCount;
+extern Py_ssize_t PyObjC_MappingCount;