[GRASS-SVN] r37387 - in grass/trunk/swig: . include include/python
python
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri May 22 22:02:40 EDT 2009
Author: glynn
Date: 2009-05-22 22:02:40 -0400 (Fri, 22 May 2009)
New Revision: 37387
Added:
grass/trunk/swig/include/
grass/trunk/swig/include/arraystats.i
grass/trunk/swig/include/cluster.i
grass/trunk/swig/include/date.i
grass/trunk/swig/include/dbmi.i
grass/trunk/swig/include/display.i
grass/trunk/swig/include/g3d.i
grass/trunk/swig/include/grass.i
grass/trunk/swig/include/imagery.i
grass/trunk/swig/include/math.i
grass/trunk/swig/include/proj.i
grass/trunk/swig/include/python/
grass/trunk/swig/include/python/common.i
grass/trunk/swig/include/python/my_typemaps.i
grass/trunk/swig/include/python/utils.i
grass/trunk/swig/include/raster.i
grass/trunk/swig/include/stats.i
grass/trunk/swig/include/trans.i
grass/trunk/swig/include/vector.i
grass/trunk/swig/include/vedit.i
Removed:
grass/trunk/swig/python/arraystats.i
grass/trunk/swig/python/cluster.i
grass/trunk/swig/python/common.i
grass/trunk/swig/python/date.i
grass/trunk/swig/python/dbmi.i
grass/trunk/swig/python/display.i
grass/trunk/swig/python/g3d.i
grass/trunk/swig/python/grass.i
grass/trunk/swig/python/imagery.i
grass/trunk/swig/python/math.i
grass/trunk/swig/python/my_typemaps.i
grass/trunk/swig/python/proj.i
grass/trunk/swig/python/raster.i
grass/trunk/swig/python/stats.i
grass/trunk/swig/python/trans.i
grass/trunk/swig/python/utils.i
grass/trunk/swig/python/vector.i
grass/trunk/swig/python/vedit.i
Modified:
grass/trunk/swig/python/Makefile
Log:
Move SWIG interfaces to swig/include
Copied: grass/trunk/swig/include/arraystats.i (from rev 37384, grass/trunk/swig/python/arraystats.i)
===================================================================
--- grass/trunk/swig/include/arraystats.i (rev 0)
+++ grass/trunk/swig/include/arraystats.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -0,0 +1,8 @@
+
+%include "common.i"
+
+%{
+#include <grass/arraystats.h>
+%}
+
+%include "grass/arraystats.h"
Copied: grass/trunk/swig/include/cluster.i (from rev 37384, grass/trunk/swig/python/cluster.i)
===================================================================
--- grass/trunk/swig/include/cluster.i (rev 0)
+++ grass/trunk/swig/include/cluster.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -0,0 +1,8 @@
+
+%include "common.i"
+
+%{
+#include <grass/cluster.h>
+%}
+
+%include "grass/cluster.h"
Copied: grass/trunk/swig/include/date.i (from rev 37384, grass/trunk/swig/python/date.i)
===================================================================
--- grass/trunk/swig/include/date.i (rev 0)
+++ grass/trunk/swig/include/date.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -0,0 +1,9 @@
+
+%include "common.i"
+
+%{
+#include <grass/datetime.h>
+%}
+
+%include "grass/datetime.h"
+%include "grass/P_datetime.h"
Copied: grass/trunk/swig/include/dbmi.i (from rev 37384, grass/trunk/swig/python/dbmi.i)
===================================================================
--- grass/trunk/swig/include/dbmi.i (rev 0)
+++ grass/trunk/swig/include/dbmi.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -0,0 +1,8 @@
+
+%include "common.i"
+
+%{
+#include <grass/dbmi.h>
+%}
+
+%include "grass/dbmi.h"
Copied: grass/trunk/swig/include/display.i (from rev 37384, grass/trunk/swig/python/display.i)
===================================================================
--- grass/trunk/swig/include/display.i (rev 0)
+++ grass/trunk/swig/include/display.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -0,0 +1,8 @@
+
+%include "common.i"
+
+%{
+#include <grass/display.h>
+%}
+
+%include "grass/display.h"
Copied: grass/trunk/swig/include/g3d.i (from rev 37384, grass/trunk/swig/python/g3d.i)
===================================================================
--- grass/trunk/swig/include/g3d.i (rev 0)
+++ grass/trunk/swig/include/g3d.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -0,0 +1,8 @@
+
+%include "common.i"
+
+%{
+#include <grass/G3d.h>
+%}
+
+%include "grass/G3d.h"
Copied: grass/trunk/swig/include/grass.i (from rev 37384, grass/trunk/swig/python/grass.i)
===================================================================
--- grass/trunk/swig/include/grass.i (rev 0)
+++ grass/trunk/swig/include/grass.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -0,0 +1,31 @@
+
+%include "common.i"
+
+%include "grass/gis.h"
+%include "grass/gisdefs.h"
+
+%pythoncode %{
+import sys
+
+def G_gisinit(pgm):
+ G__gisinit(GIS_H_VERSION, pgm)
+
+def G__get_trace():
+ f = sys._getframe(1)
+ ln = f.f_lineno
+ fi = f.f_code.co_filename
+ return fi, ln
+
+def G_malloc(n):
+ fi, ln = G__get_trace()
+ return G__malloc(fi, ln, n)
+
+def G_calloc(m, n):
+ fi, ln = G__get_trace()
+ return G__calloc(fi, ln, m, n)
+
+def G_realloc(p, n):
+ fi, ln = G__get_trace()
+ return G__realloc(fi, ln, p, n)
+%}
+
Copied: grass/trunk/swig/include/imagery.i (from rev 37384, grass/trunk/swig/python/imagery.i)
===================================================================
--- grass/trunk/swig/include/imagery.i (rev 0)
+++ grass/trunk/swig/include/imagery.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -0,0 +1,9 @@
+
+%include "common.i"
+
+%{
+#include <grass/imagery.h>
+%}
+
+%include "grass/imagery.h"
+%include "grass/imagedefs.h"
Copied: grass/trunk/swig/include/math.i (from rev 37384, grass/trunk/swig/python/math.i)
===================================================================
--- grass/trunk/swig/include/math.i (rev 0)
+++ grass/trunk/swig/include/math.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -0,0 +1,8 @@
+
+%include "common.i"
+
+%{
+#include <grass/gmath.h>
+%}
+
+%include "grass/gmath.h"
Copied: grass/trunk/swig/include/proj.i (from rev 37384, grass/trunk/swig/python/proj.i)
===================================================================
--- grass/trunk/swig/include/proj.i (rev 0)
+++ grass/trunk/swig/include/proj.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -0,0 +1,8 @@
+
+%include "common.i"
+
+%{
+#include <grass/gprojects.h>
+%}
+
+%include "grass/gprojects.h"
Copied: grass/trunk/swig/include/python/common.i (from rev 37384, grass/trunk/swig/python/common.i)
===================================================================
--- grass/trunk/swig/include/python/common.i (rev 0)
+++ grass/trunk/swig/include/python/common.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -0,0 +1,11 @@
+%{
+#include <stdio.h>
+#include <grass/gis.h>
+%}
+
+%rename(my_def) def;
+//%rename(my_class) class;
+
+%include "file.i"
+
+%include "my_typemaps.i"
Copied: grass/trunk/swig/include/python/my_typemaps.i (from rev 37384, grass/trunk/swig/python/my_typemaps.i)
===================================================================
--- grass/trunk/swig/include/python/my_typemaps.i (rev 0)
+++ grass/trunk/swig/include/python/my_typemaps.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -0,0 +1,172 @@
+#ifdef SWIGPYTHON
+
+%typemap(in) string_allows_none {
+ if($input==Py_None) {
+ $1=NULL;
+ } else {
+ $1=PyString_AsString($input);
+ if(!$1) {
+ return NULL;
+ }
+ }
+}
+
+%inline %{
+typedef char * string_allows_none;
+%}
+
+%typemap(out) char ** {
+ int len=0,i;
+ PyObject * stringobject;
+
+ if(!$1) {
+ $result=PyList_New(0);
+ } else {
+
+ for(len=0;$1[len];len++);
+
+ $result=PyList_New(len);
+ if(!$result){
+ // G_free_list($1);
+ return NULL;
+ }
+
+ for(i=0;i<len;i++) {
+ stringobject=PyString_FromString($1[i]);
+ if(!stringobject) return NULL;
+ PyList_SetItem($result,i,stringobject);
+ }
+// G_free_list($1);
+ }
+}
+
+%typemap(argout) return_string (char * temp) {
+ if($1 && *$1) {
+ $result=t_output_helper($result,PyString_FromString(*$1));
+ G_free(*$1);
+ } else {
+ $result=t_output_helper($result,Py_None);
+ Py_INCREF(Py_None);
+ }
+
+}
+
+%inline %{
+typedef char ** return_string;
+%}
+
+#undef __attribute__
+#define __attribute__(x)
+
+%{
+
+static void *pyseq_to_ptr(PyObject *input, int data_type) __attribute__ ((unused));
+static void *pyobj_to_ptr(PyObject *input, int data_type) __attribute__ ((unused));
+
+static void *pyseq_to_ptr(PyObject *input, int data_type)
+{
+ size_t size;
+ Py_ssize_t len;
+ void *array;
+ int i;
+
+ if (!PySequence_Check(input)) {
+ PyErr_SetString(PyExc_ValueError,"Expected a CObject, buffer or sequence");
+ return NULL;
+ }
+
+ switch (data_type) {
+ case (int) 'c': size = sizeof(char ); break;
+ case (int) 'b': size = sizeof(signed char ); break;
+ case (int) 'B': size = sizeof(unsigned char ); break;
+ case (int) 'u': size = sizeof(Py_UNICODE ); break;
+ case (int) 'h': size = sizeof(signed short ); break;
+ case (int) 'H': size = sizeof(unsigned short ); break;
+ case (int) 'i': size = sizeof(signed int ); break;
+ case (int) 'I': size = sizeof(unsigned int ); break;
+ case (int) 'l': size = sizeof(signed long ); break;
+ case (int) 'L': size = sizeof(unsigned long ); break;
+ case (int) 'f': size = sizeof(float ); break;
+ case (int) 'd': size = sizeof(double ); break;
+ default:
+ PyErr_SetString(PyExc_ValueError,"Invalid type code; must be one of [cbBuhHiIlLfd]");
+ return NULL;
+ }
+
+ len = PySequence_Length(input);
+ array = malloc(len * size);
+
+ for (i = 0; i < len; i++) {
+ PyObject *val = PySequence_GetItem(input, i);
+ DCELL n;
+
+ if (!PyNumber_Check(val)) {
+ PyErr_SetString(PyExc_ValueError,"Sequence elements must be numbers");
+ Py_XDECREF(val);
+ return NULL;
+ }
+
+ n = PyFloat_AsDouble(val);
+ if (PyErr_Occurred()) {
+ PyErr_SetString(PyExc_ValueError,"Sequence elements must be numbers");
+ Py_XDECREF(val);
+ return NULL;
+ }
+
+ Py_DECREF(val);
+
+ switch (data_type) {
+ case (int) 'c': ((char *) array)[i] = (char ) n; break;
+ case (int) 'b': ((signed char *) array)[i] = (signed char ) n; break;
+ case (int) 'B': ((unsigned char *) array)[i] = (unsigned char ) n; break;
+ case (int) 'u': ((Py_UNICODE *) array)[i] = (Py_UNICODE ) n; break;
+ case (int) 'h': ((signed short *) array)[i] = (signed short ) n; break;
+ case (int) 'H': ((unsigned short*) array)[i] = (unsigned short ) n; break;
+ case (int) 'i': ((signed int *) array)[i] = (signed int ) n; break;
+ case (int) 'I': ((unsigned int *) array)[i] = (unsigned int ) n; break;
+ case (int) 'l': ((signed long *) array)[i] = (signed long ) n; break;
+ case (int) 'L': ((unsigned long *) array)[i] = (unsigned long ) n; break;
+ case (int) 'f': ((float *) array)[i] = (float ) n; break;
+ case (int) 'd': ((double *) array)[i] = (double ) n; break;
+ default:
+ PyErr_SetString(PyExc_ValueError,"Invalid type code; must be one of [cbBuhHiIlLfd]");
+ return NULL;
+ }
+ }
+
+ return array;
+}
+
+static void *pyobj_to_ptr(PyObject *input, int data_type)
+{
+ const void *cbuffer;
+ void *buffer;
+ Py_ssize_t len;
+
+ if (PyCObject_Check(input))
+ return PyCObject_AsVoidPtr(input);
+
+ if (PyObject_AsWriteBuffer(input, &buffer, &len) == 0)
+ return buffer;
+
+ if (PyObject_AsReadBuffer(input, &cbuffer, &len) == 0)
+ return (void *) cbuffer;
+
+ return pyseq_to_ptr(input, data_type);
+}
+
+%}
+
+%typemap(in) CELL * {
+ $1 = (CELL *) pyobj_to_ptr($input, 'i');
+}
+
+%typemap(in) FCELL * {
+ $1 = (FCELL *) pyobj_to_ptr($input, 'f');
+}
+
+%typemap(in) DCELL * {
+ $1 = (DCELL *) pyobj_to_ptr($input, 'd');
+}
+
+#endif
Copied: grass/trunk/swig/include/python/utils.i (from rev 37384, grass/trunk/swig/python/utils.i)
===================================================================
--- grass/trunk/swig/include/python/utils.i (rev 0)
+++ grass/trunk/swig/include/python/utils.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -0,0 +1,72 @@
+
+%include "common.i"
+
+%include "carrays.i"
+%array_functions(int, intArray);
+%array_functions(float, floatArray);
+%array_functions(double, doubleArray);
+
+%include "cpointer.i"
+%pointer_functions(int, intp);
+%pointer_functions(float, floatp);
+%pointer_functions(double, doublep);
+
+PyObject *ptr_to_cobj(void *p);
+void *cobj_to_ptr(PyObject *o);
+PyObject *ptr_to_buffer_const(const void *p, int size);
+PyObject *ptr_to_buffer(void *p, int size);
+const void *buffer_to_ptr_const(PyObject *o);
+void *buffer_to_ptr(PyObject *o);
+
+%{
+
+static PyObject *ptr_to_cobj(void *p)
+{
+ return PyCObject_FromVoidPtr(p, NULL);
+}
+
+static void *cobj_to_ptr(PyObject *o)
+{
+ if (PyCObject_Check(o))
+ return PyCObject_AsVoidPtr(o);
+
+ PyErr_SetString(PyExc_ValueError,"CObject Expected");
+ return NULL;
+}
+
+static PyObject *ptr_to_buffer_const(const void *p, int size)
+{
+ return PyBuffer_FromMemory((void *) p, size);
+}
+
+static PyObject *ptr_to_buffer(void *p, int size)
+{
+ return PyBuffer_FromReadWriteMemory(p, size);
+}
+
+static const void *buffer_to_ptr_const(PyObject *o)
+{
+ const void *p;
+ Py_ssize_t len;
+
+ if (PyObject_AsReadBuffer(o, &p, &len) == 0)
+ return p;
+
+ PyErr_SetString(PyExc_ValueError,"buffer object expected");
+ return NULL;
+}
+
+static void *buffer_to_ptr(PyObject *o)
+{
+ void *p;
+ Py_ssize_t len;
+
+ if (PyObject_AsWriteBuffer(o, &p, &len) == 0)
+ return p;
+
+ PyErr_SetString(PyExc_ValueError,"buffer object expected");
+ return NULL;
+}
+
+%}
+
Copied: grass/trunk/swig/include/raster.i (from rev 37384, grass/trunk/swig/python/raster.i)
===================================================================
--- grass/trunk/swig/include/raster.i (rev 0)
+++ grass/trunk/swig/include/raster.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -0,0 +1,8 @@
+
+%include "common.i"
+
+%{
+#include <grass/raster.h>
+%}
+
+%include "grass/raster.h"
Copied: grass/trunk/swig/include/stats.i (from rev 37384, grass/trunk/swig/python/stats.i)
===================================================================
--- grass/trunk/swig/include/stats.i (rev 0)
+++ grass/trunk/swig/include/stats.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -0,0 +1,9 @@
+
+%include "common.i"
+
+%{
+#undef c_sum
+#include <grass/stats.h>
+%}
+
+%include "grass/stats.h"
Copied: grass/trunk/swig/include/trans.i (from rev 37384, grass/trunk/swig/python/trans.i)
===================================================================
--- grass/trunk/swig/include/trans.i (rev 0)
+++ grass/trunk/swig/include/trans.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -0,0 +1,8 @@
+
+%include "common.i"
+
+%{
+#include <grass/transform.h>
+%}
+
+%include "grass/transform.h"
Copied: grass/trunk/swig/include/vector.i (from rev 37384, grass/trunk/swig/python/vector.i)
===================================================================
--- grass/trunk/swig/include/vector.i (rev 0)
+++ grass/trunk/swig/include/vector.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -0,0 +1,11 @@
+
+%include "common.i"
+
+%{
+#include <grass/Vect.h>
+#include <grass/vect/dig_structs.h>
+%}
+
+%include "grass/Vect.h"
+%include "grass/vect/dig_structs.h"
+%include "grass/vect/dig_defines.h"
Copied: grass/trunk/swig/include/vedit.i (from rev 37384, grass/trunk/swig/python/vedit.i)
===================================================================
--- grass/trunk/swig/include/vedit.i (rev 0)
+++ grass/trunk/swig/include/vedit.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -0,0 +1,8 @@
+
+%include "common.i"
+
+%{
+#include <grass/vedit.h>
+%}
+
+%include "grass/vedit.h"
Modified: grass/trunk/swig/python/Makefile
===================================================================
--- grass/trunk/swig/python/Makefile 2009-05-23 01:28:07 UTC (rev 37386)
+++ grass/trunk/swig/python/Makefile 2009-05-23 02:02:40 UTC (rev 37387)
@@ -32,7 +32,8 @@
vector_wrap_c_FLAGS = $(VECT_INC)
proj_wrap_c_FLAGS = $(PROJINC) $(GDALCFLAGS)
-EXTRA_SWIG = my_typemaps.i common.i
+EXTRA_SWIG = ../include/python/my_typemaps.i ../include/python/common.i
+SWIGFLAGS = $(ARCH_INC) -I../include/python -outdir .
EXTRA_CFLAGS = $(PYMOD_CFLAGS)
EXTRA_CLEAN_FILES := $(foreach M,$(MODULES),$(M)_wrap.o $(M)_wrap.c $(M).pyc $(M).py _$(M).so)
CLEAN_SUBDIRS = NumPtr
@@ -50,6 +51,12 @@
$(MAKE) $(DSTDIR)
$(MAKE) $(LIBFILES) $(PYFILES)
+%_wrap.c %.py: ../include/%.i $(EXTRA_SWIG)
+ $(SWIG) $(SWIGFLAGS) -python -o $*_wrap.c -module $* -shadow $<
+
+%_wrap.c %.py: ../include/python/%.i $(EXTRA_SWIG)
+ $(SWIG) $(SWIGFLAGS) -python -o $*_wrap.c -module $* -shadow $<
+
$(PYDIR):
test -d $@ || $(MKDIR) -p $@
Deleted: grass/trunk/swig/python/arraystats.i
===================================================================
--- grass/trunk/swig/python/arraystats.i 2009-05-23 01:28:07 UTC (rev 37386)
+++ grass/trunk/swig/python/arraystats.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -1,8 +0,0 @@
-
-%include "common.i"
-
-%{
-#include <grass/arraystats.h>
-%}
-
-%include "grass/arraystats.h"
Deleted: grass/trunk/swig/python/cluster.i
===================================================================
--- grass/trunk/swig/python/cluster.i 2009-05-23 01:28:07 UTC (rev 37386)
+++ grass/trunk/swig/python/cluster.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -1,8 +0,0 @@
-
-%include "common.i"
-
-%{
-#include <grass/cluster.h>
-%}
-
-%include "grass/cluster.h"
Deleted: grass/trunk/swig/python/common.i
===================================================================
--- grass/trunk/swig/python/common.i 2009-05-23 01:28:07 UTC (rev 37386)
+++ grass/trunk/swig/python/common.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -1,11 +0,0 @@
-%{
-#include <stdio.h>
-#include <grass/gis.h>
-%}
-
-%rename(my_def) def;
-//%rename(my_class) class;
-
-%include "file.i"
-
-%include "my_typemaps.i"
Deleted: grass/trunk/swig/python/date.i
===================================================================
--- grass/trunk/swig/python/date.i 2009-05-23 01:28:07 UTC (rev 37386)
+++ grass/trunk/swig/python/date.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -1,9 +0,0 @@
-
-%include "common.i"
-
-%{
-#include <grass/datetime.h>
-%}
-
-%include "grass/datetime.h"
-%include "grass/P_datetime.h"
Deleted: grass/trunk/swig/python/dbmi.i
===================================================================
--- grass/trunk/swig/python/dbmi.i 2009-05-23 01:28:07 UTC (rev 37386)
+++ grass/trunk/swig/python/dbmi.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -1,8 +0,0 @@
-
-%include "common.i"
-
-%{
-#include <grass/dbmi.h>
-%}
-
-%include "grass/dbmi.h"
Deleted: grass/trunk/swig/python/display.i
===================================================================
--- grass/trunk/swig/python/display.i 2009-05-23 01:28:07 UTC (rev 37386)
+++ grass/trunk/swig/python/display.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -1,8 +0,0 @@
-
-%include "common.i"
-
-%{
-#include <grass/display.h>
-%}
-
-%include "grass/display.h"
Deleted: grass/trunk/swig/python/g3d.i
===================================================================
--- grass/trunk/swig/python/g3d.i 2009-05-23 01:28:07 UTC (rev 37386)
+++ grass/trunk/swig/python/g3d.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -1,8 +0,0 @@
-
-%include "common.i"
-
-%{
-#include <grass/G3d.h>
-%}
-
-%include "grass/G3d.h"
Deleted: grass/trunk/swig/python/grass.i
===================================================================
--- grass/trunk/swig/python/grass.i 2009-05-23 01:28:07 UTC (rev 37386)
+++ grass/trunk/swig/python/grass.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -1,31 +0,0 @@
-
-%include "common.i"
-
-%include "grass/gis.h"
-%include "grass/gisdefs.h"
-
-%pythoncode %{
-import sys
-
-def G_gisinit(pgm):
- G__gisinit(GIS_H_VERSION, pgm)
-
-def G__get_trace():
- f = sys._getframe(1)
- ln = f.f_lineno
- fi = f.f_code.co_filename
- return fi, ln
-
-def G_malloc(n):
- fi, ln = G__get_trace()
- return G__malloc(fi, ln, n)
-
-def G_calloc(m, n):
- fi, ln = G__get_trace()
- return G__calloc(fi, ln, m, n)
-
-def G_realloc(p, n):
- fi, ln = G__get_trace()
- return G__realloc(fi, ln, p, n)
-%}
-
Deleted: grass/trunk/swig/python/imagery.i
===================================================================
--- grass/trunk/swig/python/imagery.i 2009-05-23 01:28:07 UTC (rev 37386)
+++ grass/trunk/swig/python/imagery.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -1,9 +0,0 @@
-
-%include "common.i"
-
-%{
-#include <grass/imagery.h>
-%}
-
-%include "grass/imagery.h"
-%include "grass/imagedefs.h"
Deleted: grass/trunk/swig/python/math.i
===================================================================
--- grass/trunk/swig/python/math.i 2009-05-23 01:28:07 UTC (rev 37386)
+++ grass/trunk/swig/python/math.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -1,8 +0,0 @@
-
-%include "common.i"
-
-%{
-#include <grass/gmath.h>
-%}
-
-%include "grass/gmath.h"
Deleted: grass/trunk/swig/python/my_typemaps.i
===================================================================
--- grass/trunk/swig/python/my_typemaps.i 2009-05-23 01:28:07 UTC (rev 37386)
+++ grass/trunk/swig/python/my_typemaps.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -1,172 +0,0 @@
-#ifdef SWIGPYTHON
-
-%typemap(in) string_allows_none {
- if($input==Py_None) {
- $1=NULL;
- } else {
- $1=PyString_AsString($input);
- if(!$1) {
- return NULL;
- }
- }
-}
-
-%inline %{
-typedef char * string_allows_none;
-%}
-
-%typemap(out) char ** {
- int len=0,i;
- PyObject * stringobject;
-
- if(!$1) {
- $result=PyList_New(0);
- } else {
-
- for(len=0;$1[len];len++);
-
- $result=PyList_New(len);
- if(!$result){
- // G_free_list($1);
- return NULL;
- }
-
- for(i=0;i<len;i++) {
- stringobject=PyString_FromString($1[i]);
- if(!stringobject) return NULL;
- PyList_SetItem($result,i,stringobject);
- }
-// G_free_list($1);
- }
-}
-
-%typemap(argout) return_string (char * temp) {
- if($1 && *$1) {
- $result=t_output_helper($result,PyString_FromString(*$1));
- G_free(*$1);
- } else {
- $result=t_output_helper($result,Py_None);
- Py_INCREF(Py_None);
- }
-
-}
-
-%inline %{
-typedef char ** return_string;
-%}
-
-#undef __attribute__
-#define __attribute__(x)
-
-%{
-
-static void *pyseq_to_ptr(PyObject *input, int data_type) __attribute__ ((unused));
-static void *pyobj_to_ptr(PyObject *input, int data_type) __attribute__ ((unused));
-
-static void *pyseq_to_ptr(PyObject *input, int data_type)
-{
- size_t size;
- Py_ssize_t len;
- void *array;
- int i;
-
- if (!PySequence_Check(input)) {
- PyErr_SetString(PyExc_ValueError,"Expected a CObject, buffer or sequence");
- return NULL;
- }
-
- switch (data_type) {
- case (int) 'c': size = sizeof(char ); break;
- case (int) 'b': size = sizeof(signed char ); break;
- case (int) 'B': size = sizeof(unsigned char ); break;
- case (int) 'u': size = sizeof(Py_UNICODE ); break;
- case (int) 'h': size = sizeof(signed short ); break;
- case (int) 'H': size = sizeof(unsigned short ); break;
- case (int) 'i': size = sizeof(signed int ); break;
- case (int) 'I': size = sizeof(unsigned int ); break;
- case (int) 'l': size = sizeof(signed long ); break;
- case (int) 'L': size = sizeof(unsigned long ); break;
- case (int) 'f': size = sizeof(float ); break;
- case (int) 'd': size = sizeof(double ); break;
- default:
- PyErr_SetString(PyExc_ValueError,"Invalid type code; must be one of [cbBuhHiIlLfd]");
- return NULL;
- }
-
- len = PySequence_Length(input);
- array = malloc(len * size);
-
- for (i = 0; i < len; i++) {
- PyObject *val = PySequence_GetItem(input, i);
- DCELL n;
-
- if (!PyNumber_Check(val)) {
- PyErr_SetString(PyExc_ValueError,"Sequence elements must be numbers");
- Py_XDECREF(val);
- return NULL;
- }
-
- n = PyFloat_AsDouble(val);
- if (PyErr_Occurred()) {
- PyErr_SetString(PyExc_ValueError,"Sequence elements must be numbers");
- Py_XDECREF(val);
- return NULL;
- }
-
- Py_DECREF(val);
-
- switch (data_type) {
- case (int) 'c': ((char *) array)[i] = (char ) n; break;
- case (int) 'b': ((signed char *) array)[i] = (signed char ) n; break;
- case (int) 'B': ((unsigned char *) array)[i] = (unsigned char ) n; break;
- case (int) 'u': ((Py_UNICODE *) array)[i] = (Py_UNICODE ) n; break;
- case (int) 'h': ((signed short *) array)[i] = (signed short ) n; break;
- case (int) 'H': ((unsigned short*) array)[i] = (unsigned short ) n; break;
- case (int) 'i': ((signed int *) array)[i] = (signed int ) n; break;
- case (int) 'I': ((unsigned int *) array)[i] = (unsigned int ) n; break;
- case (int) 'l': ((signed long *) array)[i] = (signed long ) n; break;
- case (int) 'L': ((unsigned long *) array)[i] = (unsigned long ) n; break;
- case (int) 'f': ((float *) array)[i] = (float ) n; break;
- case (int) 'd': ((double *) array)[i] = (double ) n; break;
- default:
- PyErr_SetString(PyExc_ValueError,"Invalid type code; must be one of [cbBuhHiIlLfd]");
- return NULL;
- }
- }
-
- return array;
-}
-
-static void *pyobj_to_ptr(PyObject *input, int data_type)
-{
- const void *cbuffer;
- void *buffer;
- Py_ssize_t len;
-
- if (PyCObject_Check(input))
- return PyCObject_AsVoidPtr(input);
-
- if (PyObject_AsWriteBuffer(input, &buffer, &len) == 0)
- return buffer;
-
- if (PyObject_AsReadBuffer(input, &cbuffer, &len) == 0)
- return (void *) cbuffer;
-
- return pyseq_to_ptr(input, data_type);
-}
-
-%}
-
-%typemap(in) CELL * {
- $1 = (CELL *) pyobj_to_ptr($input, 'i');
-}
-
-%typemap(in) FCELL * {
- $1 = (FCELL *) pyobj_to_ptr($input, 'f');
-}
-
-%typemap(in) DCELL * {
- $1 = (DCELL *) pyobj_to_ptr($input, 'd');
-}
-
-#endif
Deleted: grass/trunk/swig/python/proj.i
===================================================================
--- grass/trunk/swig/python/proj.i 2009-05-23 01:28:07 UTC (rev 37386)
+++ grass/trunk/swig/python/proj.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -1,8 +0,0 @@
-
-%include "common.i"
-
-%{
-#include <grass/gprojects.h>
-%}
-
-%include "grass/gprojects.h"
Deleted: grass/trunk/swig/python/raster.i
===================================================================
--- grass/trunk/swig/python/raster.i 2009-05-23 01:28:07 UTC (rev 37386)
+++ grass/trunk/swig/python/raster.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -1,8 +0,0 @@
-
-%include "common.i"
-
-%{
-#include <grass/raster.h>
-%}
-
-%include "grass/raster.h"
Deleted: grass/trunk/swig/python/stats.i
===================================================================
--- grass/trunk/swig/python/stats.i 2009-05-23 01:28:07 UTC (rev 37386)
+++ grass/trunk/swig/python/stats.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -1,9 +0,0 @@
-
-%include "common.i"
-
-%{
-#undef c_sum
-#include <grass/stats.h>
-%}
-
-%include "grass/stats.h"
Deleted: grass/trunk/swig/python/trans.i
===================================================================
--- grass/trunk/swig/python/trans.i 2009-05-23 01:28:07 UTC (rev 37386)
+++ grass/trunk/swig/python/trans.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -1,8 +0,0 @@
-
-%include "common.i"
-
-%{
-#include <grass/transform.h>
-%}
-
-%include "grass/transform.h"
Deleted: grass/trunk/swig/python/utils.i
===================================================================
--- grass/trunk/swig/python/utils.i 2009-05-23 01:28:07 UTC (rev 37386)
+++ grass/trunk/swig/python/utils.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -1,72 +0,0 @@
-
-%include "common.i"
-
-%include "carrays.i"
-%array_functions(int, intArray);
-%array_functions(float, floatArray);
-%array_functions(double, doubleArray);
-
-%include "cpointer.i"
-%pointer_functions(int, intp);
-%pointer_functions(float, floatp);
-%pointer_functions(double, doublep);
-
-PyObject *ptr_to_cobj(void *p);
-void *cobj_to_ptr(PyObject *o);
-PyObject *ptr_to_buffer_const(const void *p, int size);
-PyObject *ptr_to_buffer(void *p, int size);
-const void *buffer_to_ptr_const(PyObject *o);
-void *buffer_to_ptr(PyObject *o);
-
-%{
-
-static PyObject *ptr_to_cobj(void *p)
-{
- return PyCObject_FromVoidPtr(p, NULL);
-}
-
-static void *cobj_to_ptr(PyObject *o)
-{
- if (PyCObject_Check(o))
- return PyCObject_AsVoidPtr(o);
-
- PyErr_SetString(PyExc_ValueError,"CObject Expected");
- return NULL;
-}
-
-static PyObject *ptr_to_buffer_const(const void *p, int size)
-{
- return PyBuffer_FromMemory((void *) p, size);
-}
-
-static PyObject *ptr_to_buffer(void *p, int size)
-{
- return PyBuffer_FromReadWriteMemory(p, size);
-}
-
-static const void *buffer_to_ptr_const(PyObject *o)
-{
- const void *p;
- Py_ssize_t len;
-
- if (PyObject_AsReadBuffer(o, &p, &len) == 0)
- return p;
-
- PyErr_SetString(PyExc_ValueError,"buffer object expected");
- return NULL;
-}
-
-static void *buffer_to_ptr(PyObject *o)
-{
- void *p;
- Py_ssize_t len;
-
- if (PyObject_AsWriteBuffer(o, &p, &len) == 0)
- return p;
-
- PyErr_SetString(PyExc_ValueError,"buffer object expected");
- return NULL;
-}
-
-%}
-
Deleted: grass/trunk/swig/python/vector.i
===================================================================
--- grass/trunk/swig/python/vector.i 2009-05-23 01:28:07 UTC (rev 37386)
+++ grass/trunk/swig/python/vector.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -1,11 +0,0 @@
-
-%include "common.i"
-
-%{
-#include <grass/Vect.h>
-#include <grass/vect/dig_structs.h>
-%}
-
-%include "grass/Vect.h"
-%include "grass/vect/dig_structs.h"
-%include "grass/vect/dig_defines.h"
Deleted: grass/trunk/swig/python/vedit.i
===================================================================
--- grass/trunk/swig/python/vedit.i 2009-05-23 01:28:07 UTC (rev 37386)
+++ grass/trunk/swig/python/vedit.i 2009-05-23 02:02:40 UTC (rev 37387)
@@ -1,8 +0,0 @@
-
-%include "common.i"
-
-%{
-#include <grass/vedit.h>
-%}
-
-%include "grass/vedit.h"
More information about the grass-commit
mailing list