diff options
| author | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2008-12-16 12:40:29 +0000 |
|---|---|---|
| committer | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2008-12-16 12:40:29 +0000 |
| commit | 388d8f506a67dcf745c26f0c59d6609bcdafa7a5 (patch) | |
| tree | dc69730a1c11a9ffaf5825fb4671294540b4306d /navit/binding/python/navit.c | |
| parent | 7d4a44ebe7d6783fe8ae380e882828a7a7b9dad7 (diff) | |
| download | navit-388d8f506a67dcf745c26f0c59d6609bcdafa7a5.tar.gz | |
Add:binding_python:Make it do actually something useful
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@1805 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/binding/python/navit.c')
| -rw-r--r-- | navit/binding/python/navit.c | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/navit/binding/python/navit.c b/navit/binding/python/navit.c new file mode 100644 index 000000000..e35b93119 --- /dev/null +++ b/navit/binding/python/navit.c @@ -0,0 +1,106 @@ +/** + * Navit, a modular navigation system. + * Copyright (C) 2005-2008 Navit Team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "common.h" +#include "navit.h" + +typedef struct { + PyObject_HEAD + struct navit *navit; +} navitObject; + +static PyObject * +navit_set_center_py(navitObject *self, PyObject *args) +{ + PyObject *pcoord; + if (!PyArg_ParseTuple(args, "O!", &pcoord_Type, &pcoord)) + return NULL; + navit_set_center(self->navit, pcoord_py_get(pcoord)); + Py_RETURN_NONE; +} + +static PyObject * +navit_set_destination_py(navitObject *self, PyObject *args) +{ + PyObject *pcoord; + const char *description; + if (!PyArg_ParseTuple(args, "O!s", &pcoord_Type, &pcoord, &description)) + return NULL; + navit_set_destination(self->navit, pcoord_py_get(pcoord), description); + Py_RETURN_NONE; +} + +static PyObject * +navit_set_position_py(navitObject *self, PyObject *args) +{ + PyObject *pcoord; + if (!PyArg_ParseTuple(args, "O!", &pcoord_Type, &pcoord)) + return NULL; + navit_set_position(self->navit, pcoord_py_get(pcoord)); + Py_RETURN_NONE; +} + + + + +static PyMethodDef navit_methods[] = { + {"set_center", (PyCFunction) navit_set_center_py, METH_VARARGS }, + {"set_destination", (PyCFunction) navit_set_destination_py, METH_VARARGS }, + {"set_position", (PyCFunction) navit_set_position_py, METH_VARARGS }, + {NULL, NULL }, +}; + + +static PyObject * +navit_getattr_py(PyObject *self, char *name) +{ + return Py_FindMethod(navit_methods, self, name); +} + +static void +navit_destroy_py(navitObject *self) +{ +} + +PyTypeObject navit_Type = { + Obj_HEAD + .tp_name="navit", + .tp_basicsize=sizeof(navitObject), + .tp_dealloc=(destructor)navit_destroy_py, + .tp_getattr=navit_getattr_py, +}; + +PyObject * +navit_py(PyObject *self, PyObject *args) +{ + navitObject *ret; + + dbg(0,"enter\n"); + ret=PyObject_NEW(navitObject, &navit_Type); + return (PyObject *)ret; +} + +PyObject * +navit_py_ref(struct navit *navit) +{ + dbg(0,"navit=%p\n", navit); + navitObject *ret=PyObject_NEW(navitObject, &navit_Type); + ret->navit=navit; + return (PyObject *)ret; +} |
