Commits

Ronald Oussoren committed 925f493

give access to the raw signature, needed for the signatures tool

  • Participants
  • Parent commits ad439ba
  • Branches pyobjc-ancient

Comments (0)

Files changed (2)

Modules/objc/selector.h

 #define PyObjCSelector_HEAD \
 	PyObject_HEAD 			\
 	char*		sel_signature;  \
+	char* 		sel_native_signature; \
 	SEL		sel_selector;	\
 	PyObject*	sel_self;	\
 	Class		sel_class;	\

Modules/objc/selector.m

 	return PyString_FromString(self->sel_signature);
 }
 
+PyDoc_STRVAR(base_native_signature_doc, "original Objective-C signature for the method");
+static PyObject*
+base_native_signature(PyObjCSelector* self, void* closure __attribute__((__unused__)))
+{
+	if (self->sel_native_signature == NULL) {
+		Py_INCREF(Py_None);
+		return Py_None;
+	}
+
+	return PyString_FromString(self->sel_native_signature);
+}
+
 static int
 base_signature_setter(PyObjCNativeSelector* self, PyObject* newVal, void* closure __attribute__((__unused__)))
 {
 		base_signature_doc, 
 		0
 	},
+	{
+		"native_signature",
+		(getter)base_native_signature,
+		0,
+		base_native_signature_doc,
+		0
+	},
 	{ 
 		"self", 
 		(getter)base_self, 
 
 	PyMem_Free(self->sel_signature);
 	self->sel_signature = NULL;
+
+	if (self->sel_native_signature != NULL) {
+		PyMem_Free(self->sel_native_signature);
+		self->sel_native_signature = NULL;
+	}
 	if (self->sel_self) { 
 		Py_DECREF(self->sel_self); 
 		self->sel_self = NULL;
 		Py_DECREF(result);
 		return NULL;
 	}
+
+	if (meth->sel_native_signature != NULL) {
+		result->sel_native_signature = PyObjCUtil_Strdup(meth->sel_native_signature);
+		if (result->sel_native_signature == NULL) {
+			Py_DECREF(result);
+			return NULL;
+		}
+	} else {
+		result->sel_native_signature = NULL;
+	}
 	result->sel_flags = meth->sel_flags;
 	result->sel_class = meth->sel_class;
 
 			SEL selector, const char* signature, int class_method)
 {
 	PyObjCNativeSelector* result;
+	const char* native_signature = signature;
 	char* repl_sig;
 
 	repl_sig = PyObjC_FindReplacementSignature(class, selector);
 
 	result->sel_selector = selector;
 	result->sel_signature = PyObjCUtil_Strdup(signature);
+	result->sel_native_signature = PyObjCUtil_Strdup(native_signature);
 	if (result->sel_signature == NULL) {
 		Py_DECREF(result);
 		return NULL;
 
 	result->sel_selector = selector;
 	result->sel_signature = signature;
+	result->sel_native_signature = NULL;
 	result->sel_self = NULL;
 	result->sel_class = cls;
 	result->sel_flags = 0;
 		Py_DECREF(result);
 		return NULL;
 	}
+	if (meth->sel_native_signature) {
+		result->sel_native_signature  = PyObjCUtil_Strdup(meth->sel_native_signature);
+		if (result->sel_native_signature == NULL) {
+			Py_DECREF(result);
+			return NULL;
+		}
+	} else {
+		result->sel_native_signature = NULL;
+	}
+
 	result->sel_self       = obj;
 	result->sel_flags = meth->sel_flags;
 	result->callable = meth->callable;
 			Py_DECREF(result);
 			return NULL;
 		}
+		result->sel_native_signature = NULL;
 		result->sel_self       = NULL;
 		result->sel_flags = ((PyObjCPythonSelector*)callable)->sel_flags;
 		result->callable = ((PyObjCPythonSelector*)callable)->callable;