[GRASS-SVN] r37775 - grass/branches/releasebranch_6_4/swig/include/python

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jun 7 11:14:06 EDT 2009


Author: neteler
Date: 2009-06-07 11:14:06 -0400 (Sun, 07 Jun 2009)
New Revision: 37775

Modified:
   grass/branches/releasebranch_6_4/swig/include/python/my_typemaps.i
Log:
Add typemaps for numeric arrays (merge from trunk, r37773)

Modified: grass/branches/releasebranch_6_4/swig/include/python/my_typemaps.i
===================================================================
--- grass/branches/releasebranch_6_4/swig/include/python/my_typemaps.i	2009-06-07 15:13:55 UTC (rev 37774)
+++ grass/branches/releasebranch_6_4/swig/include/python/my_typemaps.i	2009-06-07 15:14:06 UTC (rev 37775)
@@ -149,14 +149,16 @@
 	if (PyCObject_Check(input))
 		return PyCObject_AsVoidPtr(input);
 
+	if (PyString_Check(input) && strchr("cbB", data_type))
+		return (void *) PyString_AsString(input);
+
 	if (PyObject_AsWriteBuffer(input, &buffer, &len) == 0)
 		return buffer;
 
 	if (PyObject_AsReadBuffer(input, &cbuffer, &len) == 0)
 		return (void *) cbuffer;
 
-	if (PyString_Check(input) && strchr("cbB", data_type))
-		return (void *) PyString_AsString(input);
+	PyErr_Clear();
 
 	return pyseq_to_ptr(input, data_type);
 }
@@ -175,6 +177,54 @@
 	$1 = (DCELL *) pyobj_to_ptr($input, 'd');
 }
 
+%typemap(in) signed char * {
+	$1 = (signed char *) pyobj_to_ptr($input, 'b');
+}
+
+%typemap(in) unsigned char * {
+	$1 = (unsigned char *) pyobj_to_ptr($input, 'B');
+}
+
+%typemap(in) signed short * {
+	$1 = (signed short *) pyobj_to_ptr($input, 'h');
+}
+
+%typemap(in) unsigned short * {
+	$1 = (unsigned short *) pyobj_to_ptr($input, 'H');
+}
+
+%typemap(in) int * {
+	$1 = (int *) pyobj_to_ptr($input, 'i');
+}
+
+%typemap(in) signed int * {
+	$1 = (int *) pyobj_to_ptr($input, 'i');
+}
+
+%typemap(in) unsigned int * {
+	$1 = (int *) pyobj_to_ptr($input, 'I');
+}
+
+%typemap(in) long * {
+	$1 = (long *) pyobj_to_ptr($input, 'l');
+}
+
+%typemap(in) signed long * {
+	$1 = (long *) pyobj_to_ptr($input, 'l');
+}
+
+%typemap(in) unsigned long * {
+	$1 = (long *) pyobj_to_ptr($input, 'L');
+}
+
+%typemap(in) float * {
+	$1 = (float *) pyobj_to_ptr($input, 'f');
+}
+
+%typemap(in) double * {
+	$1 = (double *) pyobj_to_ptr($input, 'd');
+}
+
 %{
 
 static void **pyseq_to_ptr_ptr(PyObject *input, int data_type) __attribute__ ((unused));



More information about the grass-commit mailing list