1. Ronald Oussoren
  2. pyobjc

Commits

Ronald Oussoren  committed 6ba1eb3

Some minor cleanup in py3k support code.

  • Participants
  • Parent commits 6f2b1e6
  • Branches pyobjc-ancient

Comments (0)

Files changed (10)

File pyobjc-core/Modules/objc/bundle-variables.m

View file
 		}
 
 		if (!PyArg_ParseTuple(item, 
+				"O!"Py_ARG_BYTES":variableInfo", 
 #if PY_VERSION_HEX < 0x03000000
-				"O!s:variableInfo", &PyBaseString_Type,
+				&PyBaseString_Type,
 #else
-				"O!y:variableInfo", &PyUnicode_Type,
+				&PyUnicode_Type,
 #endif
 				&py_name, &signature)) {
 			Py_DECREF(seq);

File pyobjc-core/Modules/objc/instance-var.m

View file
 	PyObject* isOutletObj = NULL;
 
 	if (!PyArg_ParseTupleAndKeywords(args, kwds, 
-#if PY_VERSION_HEX < 0x03000000
-				"|ssO:objc_ivar",
-#else
-				"|syO:objc_ivar",
-#endif
+				"|s"Py_ARG_BYTES"O:objc_ivar",
 			keywords, &name, &type, &isOutletObj)) {
 		return -1;
 	}

File pyobjc-core/Modules/objc/ivar-accessor.m

View file
 
 	/* Handle 'isa' specially, due to Objective-C 2.0 weirdness */
 	v = Py_BuildValue(
-#if PY_VERSION_HEX < 0x03000000
-			"(ss)", 
-#else
-			"(sy)", 
-#endif
+			"(s"Py_ARG_BYTES")", 
 			"isa", @encode(Class));
 	if (v == NULL) {
 		Py_DECREF(result);
 			}
 
 			v = Py_BuildValue(
-#if PY_VERSION_HEX < 0x03000000
-				"(ss)", 
-#else
-				"(sy)", 
-#endif
+				"(s"Py_ARG_BYTES")", 
 				ivar_name,
 				ivar_getTypeEncoding(ivar));
 			if (v == NULL) {

File pyobjc-core/Modules/objc/module.m

View file
 {
 	static char* keywords[] = { "obj", NULL };
 	PyObject *o;
-	if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:pyobjc_id",
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, "O",
 		keywords, &o)) {
 		return NULL;
 	}
 	Py_ssize_t size;
 	PyObject *o;
 	if (!PyArg_ParseTupleAndKeywords(args, kwds, 
-#if PY_VERSION_HEX < 0x03000000
-				"O|s:repythonify",
-#else
-				"O|y:repythonify",
-#endif
+				"O|"Py_ARG_BYTES,
 		keywords, &o, &type)) {
 		return NULL;
 	}
 	PyObject* tuple;
 
 	if (!PyArg_ParseTupleAndKeywords(args, kwds, 
-#if PY_VERSION_HEX < 0x03000000
-			"s",
-#else
-			"y",
-#endif
+			Py_ARG_BYTES,
 			keywords, &signature)) {
 		return NULL;
 	}
 	char* docstr = NULL;
 
 	if (!PyArg_ParseTupleAndKeywords(args, kwds, 
-#if PY_VERSION_HEX < 0x03000000
-				"ss|s", 
-#else
-				"sy|s", 
-#endif
+				"s"Py_ARG_BYTES"|s", 
 				keywords, 
 				&name, &typestr, &docstr)) {
 		return NULL;
 	Py_ssize_t field_count;
 
 	if (!PyArg_ParseTupleAndKeywords(args, kwds, 
-#if PY_VERSION_HEX < 0x03000000
-				"ssO|s", 
-#else
-				"syO|s", 
-#endif
+				"s"Py_ARG_BYTES"O|s", 
 				keywords, 
 				&name, &typestr, &pyfieldnames, &docstr)) {
 		return NULL;
 	char* tollfreeName = NULL;
 
 	if (!PyArg_ParseTupleAndKeywords(args, kwds, 
-#if PY_VERSION_HEX < 0x03000000
-		"ssO|s",
-#else
-		"syO|s",
-#endif
+		"s"Py_ARG_BYTES"O|s",
 		keywords, &name, &encoding, &pTypeId, &tollfreeName)) {
 		return NULL;
 	}

File pyobjc-core/Modules/objc/objc-class.m

View file
 		const char* e;
 
 		item = Py_BuildValue(
-#if PY_VERSION_HEX < 0x03000000
-			"{ssss}",
-#else
-			"{sssy}",
-#endif
+			"{sss"Py_ARG_BYTES"}",
 			"name", name,
 			"raw_attr", attr);
 		if (item == NULL) {

File pyobjc-core/Modules/objc/objc_support.m

View file
 		return __alignof__(void*);
 
 	default:
-		printf("alignoftype\n");
-		abort();
 		PyErr_Format(PyObjCExc_InternalError, 
 			"PyObjCRT_AlignOfType: Unhandled type '%#x' %s", *type, type);
 		return -1;

File pyobjc-core/Modules/objc/pyobjc-api.h

View file
 #define PyObjC_VarList_New  (PyObjC_API->varlistnew)
 #define PyObjCObject_Convert (PyObjC_API->pyobjcobject_convert)
 
+typedef void (*PyObjC_Function_Pointer)(void);
+
+typedef struct PyObjC_function_map {
+    const char* 		name;
+    PyObjC_Function_Pointer     function;
+} PyObjC_function_map;
+
 
 
 #ifndef PYOBJC_METHOD_STUB_IMPL
 
-static int
+static inline PyObject*
+PyObjC_CreateInlineTab(PyObjC_function_map* map)
+{
+#if PY_VERSION_HEX < 0x03000000
+	return PyCObject_FromVoidPtr(map, NULL);
+#else
+	return PyCapsule_New(map, "objc.__functionlist__", NULL);
+#endif
+}
+
+static inline int
 PyObjC_ImportAPI(PyObject* calling_module)
 {
 	PyObject* m;

File pyobjc-core/Modules/objc/pyobjc-compat.h

View file
 #define Py_ARG_SIZE_T "n"
 #endif
 
+
+#endif
+
+#if PY_VERSION_HEX < 0x03000000
+
+#ifndef Py_ARG_BYTES
+#define Py_ARG_BYTES "s"
+#endif
+
+#else
+
+#ifndef Py_ARG_BYTES
+#define Py_ARG_BYTES "y"
+#endif
+
 #endif
 
 #if PY_VERSION_HEX < 0x03000000

File pyobjc-core/Modules/objc/selector.m

View file
 	int       required = 1;
 
 	if (!PyArg_ParseTupleAndKeywords(args, kwds, 
-#if PY_VERSION_HEX < 0x03000000
-				"O|ssissi:selector",
-#else
-				"O|yyissi:selector",
-#endif
+				"O|"Py_ARG_BYTES Py_ARG_BYTES"issi:selector",
 			keywords, &callable, &selector, &signature,
 			&class_method, &argtypes, &rettype, &required)) {
 		return NULL;

File pyobjc-core/setup.py

View file
                 sys.path.remove(rootdir)
             from PyObjCTest.loader import makeTestSuite
             import unittest
-            
+           
+            print (sys.path)
             unittest.main(None, None, [unittest.__file__]+self.test_args)
 
 from setuptools.command import egg_info as orig_egg_info