summaryrefslogtreecommitdiff
path: root/navit/binding/python
diff options
context:
space:
mode:
Diffstat (limited to 'navit/binding/python')
-rw-r--r--navit/binding/python/attr.c84
-rw-r--r--navit/binding/python/binding_python.c355
-rw-r--r--navit/binding/python/config.c46
-rw-r--r--navit/binding/python/navigation.c55
-rw-r--r--navit/binding/python/navit.c148
-rw-r--r--navit/binding/python/pcoord.c73
-rw-r--r--navit/binding/python/route.c55
-rw-r--r--navit/binding/python/template.c82
8 files changed, 420 insertions, 478 deletions
diff --git a/navit/binding/python/attr.c b/navit/binding/python/attr.c
index 2d5ed92b6..e9365c3d3 100644
--- a/navit/binding/python/attr.c
+++ b/navit/binding/python/attr.c
@@ -22,78 +22,72 @@
#include "attr.h"
typedef struct {
- PyObject_HEAD
- int ref;
- struct attr *attr;
+ PyObject_HEAD
+ int ref;
+ struct attr *attr;
} attrObject;
static PyObject *
-attr_func(attrObject *self, PyObject *args)
-{
- const char *file;
- int ret;
- if (!PyArg_ParseTuple(args, "s", &file))
- return NULL;
- ret=0;
- return Py_BuildValue("i",ret);
+attr_func(attrObject *self, PyObject *args) {
+ const char *file;
+ int ret;
+ if (!PyArg_ParseTuple(args, "s", &file))
+ return NULL;
+ ret=0;
+ return Py_BuildValue("i",ret);
}
static PyMethodDef attr_methods[] = {
- {"func", (PyCFunction) attr_func, METH_VARARGS },
- {NULL, NULL },
+ {"func", (PyCFunction) attr_func, METH_VARARGS },
+ {NULL, NULL },
};
static PyObject *
-attr_getattr_py(PyObject *self, char *name)
-{
- return Py_FindMethod(attr_methods, self, name);
+attr_getattr_py(PyObject *self, char *name) {
+ return Py_FindMethod(attr_methods, self, name);
}
static void
-attr_destroy_py(attrObject *self)
-{
- if (! self->ref)
- attr_free(self->attr);
+attr_destroy_py(attrObject *self) {
+ if (! self->ref)
+ attr_free(self->attr);
}
PyTypeObject attr_Type = {
- Obj_HEAD
- .tp_name="attr",
- .tp_basicsize=sizeof(attrObject),
- .tp_dealloc=(destructor)attr_destroy_py,
- .tp_getattr=attr_getattr_py,
+ Obj_HEAD
+ .tp_name="attr",
+ .tp_basicsize=sizeof(attrObject),
+ .tp_dealloc=(destructor)attr_destroy_py,
+ .tp_getattr=attr_getattr_py,
};
struct attr *
-attr_py_get(PyObject *self)
-{
- return ((attrObject *)self)->attr;
+attr_py_get(PyObject *self) {
+ return ((attrObject *)self)->attr;
}
PyObject *
-attr_new_py(PyObject *self, PyObject *args)
-{
- attrObject *ret;
- const char *name,*value;
- if (!PyArg_ParseTuple(args, "ss", &name, &value))
- return NULL;
- ret=PyObject_NEW(attrObject, &attr_Type);
- ret->attr=attr_new_from_text(name, value);
- ret->ref=0;
- return (PyObject *)ret;
+attr_new_py(PyObject *self, PyObject *args) {
+ attrObject *ret;
+ const char *name,*value;
+ if (!PyArg_ParseTuple(args, "ss", &name, &value))
+ return NULL;
+ ret=PyObject_NEW(attrObject, &attr_Type);
+ ret->attr=attr_new_from_text(name, value);
+ ret->ref=0;
+ return (PyObject *)ret;
}
PyObject *
-attr_new_py_ref(struct attr *attr)
-{
- attrObject *ret;
+attr_new_py_ref(struct attr *attr) {
+ attrObject *ret;
- ret=PyObject_NEW(attrObject, &attr_Type);
- ret->ref=1;
- ret->attr=attr;
- return (PyObject *)ret;
+ ret=PyObject_NEW(attrObject, &attr_Type);
+ ret->ref=1;
+ ret->attr=attr;
+ return (PyObject *)ret;
}
diff --git a/navit/binding/python/binding_python.c b/navit/binding/python/binding_python.c
index 51d84fe10..df90371cf 100644
--- a/navit/binding/python/binding_python.c
+++ b/navit/binding/python/binding_python.c
@@ -42,37 +42,37 @@
/* *** coord *** */
typedef struct {
- PyObject_HEAD
- struct coord *c;
+ PyObject_HEAD
+ struct coord *c;
} coordObject;
static void coord_destroy_py(coordObject *self);
PyTypeObject coord_Type = {
- Obj_HEAD
- .tp_name="coord",
- .tp_basicsize=sizeof(coordObject),
- .tp_dealloc=(destructor)coord_destroy_py,
+ Obj_HEAD
+ .tp_name="coord",
+ .tp_basicsize=sizeof(coordObject),
+ .tp_dealloc=(destructor)coord_destroy_py,
};
/* *** map *** */
typedef struct {
- PyObject_HEAD
- int ref;
- struct map *m;
+ PyObject_HEAD
+ int ref;
+ struct map *m;
} mapObject;
static void map_destroy_py(mapObject *self);
static PyObject *map_getattr_py(PyObject *self, char *name);
PyTypeObject map_Type = {
- Obj_HEAD
- .tp_name="map",
- .tp_basicsize=sizeof(mapObject),
- .tp_dealloc=(destructor)map_destroy_py,
- .tp_getattr=map_getattr_py,
+ Obj_HEAD
+ .tp_name="map",
+ .tp_basicsize=sizeof(mapObject),
+ .tp_dealloc=(destructor)map_destroy_py,
+ .tp_getattr=map_getattr_py,
};
/* *** IMPLEMENTATIONS *** */
@@ -80,28 +80,26 @@ PyTypeObject map_Type = {
/* *** coord *** */
static PyObject *
-coord_new_py(PyObject *self, PyObject *args)
-{
- coordObject *ret;
- int x,y;
- if (!PyArg_ParseTuple(args, "ii:navit.coord",&x,&y))
- return NULL;
- ret=PyObject_NEW(coordObject, &coord_Type);
- ret->c=coord_new(x,y);
- return (PyObject *)ret;
+coord_new_py(PyObject *self, PyObject *args) {
+ coordObject *ret;
+ int x,y;
+ if (!PyArg_ParseTuple(args, "ii:navit.coord",&x,&y))
+ return NULL;
+ ret=PyObject_NEW(coordObject, &coord_Type);
+ ret->c=coord_new(x,y);
+ return (PyObject *)ret;
}
static void
-coord_destroy_py(coordObject *self)
-{
- coord_destroy(self->c);
+coord_destroy_py(coordObject *self) {
+ coord_destroy(self->c);
}
/* *** coord_rect *** */
typedef struct {
- PyObject_HEAD
- struct coord_rect *r;
+ PyObject_HEAD
+ struct coord_rect *r;
} coord_rectObject;
@@ -109,38 +107,36 @@ static void coord_rect_destroy_py(coord_rectObject *self);
PyTypeObject coord_rect_Type = {
#if defined(MS_WINDOWS) || defined(__CYGWIN__)
- PyObject_HEAD_INIT(NULL);
+ PyObject_HEAD_INIT(NULL);
#else
- PyObject_HEAD_INIT(&PyType_Type)
+ PyObject_HEAD_INIT(&PyType_Type)
#endif
- .tp_name="coord_rect",
- .tp_basicsize=sizeof(coord_rectObject),
- .tp_dealloc=(destructor)coord_rect_destroy_py,
+ .tp_name="coord_rect",
+ .tp_basicsize=sizeof(coord_rectObject),
+ .tp_dealloc=(destructor)coord_rect_destroy_py,
};
static PyObject *
-coord_rect_new_py(PyObject *self, PyObject *args)
-{
- coord_rectObject *ret;
- coordObject *lu,*rd;
- if (!PyArg_ParseTuple(args, "O!O!:navit.coord_rect_rect",&coord_Type,&lu,&coord_Type,&rd))
- return NULL;
- ret=PyObject_NEW(coord_rectObject, &coord_rect_Type);
- ret->r=coord_rect_new(lu->c,rd->c);
- return (PyObject *)ret;
+coord_rect_new_py(PyObject *self, PyObject *args) {
+ coord_rectObject *ret;
+ coordObject *lu,*rd;
+ if (!PyArg_ParseTuple(args, "O!O!:navit.coord_rect_rect",&coord_Type,&lu,&coord_Type,&rd))
+ return NULL;
+ ret=PyObject_NEW(coord_rectObject, &coord_rect_Type);
+ ret->r=coord_rect_new(lu->c,rd->c);
+ return (PyObject *)ret;
}
static void
-coord_rect_destroy_py(coord_rectObject *self)
-{
- coord_rect_destroy(self->r);
+coord_rect_destroy_py(coord_rectObject *self) {
+ coord_rect_destroy(self->r);
}
/* *** map_rect *** */
typedef struct {
- PyObject_HEAD
- struct map_rect *mr;
+ PyObject_HEAD
+ struct map_rect *mr;
} map_rectObject;
@@ -148,110 +144,102 @@ static void map_rect_destroy_py(map_rectObject *self);
PyTypeObject map_rect_Type = {
#if defined(MS_WINDOWS) || defined(__CYGWIN__)
- PyObject_HEAD_INIT(NULL);
+ PyObject_HEAD_INIT(NULL);
#else
- PyObject_HEAD_INIT(&PyType_Type)
+ PyObject_HEAD_INIT(&PyType_Type)
#endif
- .tp_name="map_rect",
- .tp_basicsize=sizeof(map_rectObject),
- .tp_dealloc=(destructor)map_rect_destroy_py,
+ .tp_name="map_rect",
+ .tp_basicsize=sizeof(map_rectObject),
+ .tp_dealloc=(destructor)map_rect_destroy_py,
};
static PyObject *
-map_rect_new_py(mapObject *self, PyObject *args)
-{
- map_rectObject *ret;
- coord_rectObject *r;
- if (!PyArg_ParseTuple(args, "O!:navit.map_rect_rect",&coord_rect_Type,&r))
- return NULL;
- ret=PyObject_NEW(map_rectObject, &map_rect_Type);
- ret->mr=map_rect_new(self->m, NULL);
- return (PyObject *)ret;
+map_rect_new_py(mapObject *self, PyObject *args) {
+ map_rectObject *ret;
+ coord_rectObject *r;
+ if (!PyArg_ParseTuple(args, "O!:navit.map_rect_rect",&coord_rect_Type,&r))
+ return NULL;
+ ret=PyObject_NEW(map_rectObject, &map_rect_Type);
+ ret->mr=map_rect_new(self->m, NULL);
+ return (PyObject *)ret;
}
static void
-map_rect_destroy_py(map_rectObject *self)
-{
- map_rect_destroy(self->mr);
+map_rect_destroy_py(map_rectObject *self) {
+ map_rect_destroy(self->mr);
}
/* *** map *** */
static PyObject *
-map_dump_file_py(mapObject *self, PyObject *args)
-{
- const char *s;
- if (!PyArg_ParseTuple(args, "s",&s))
- return NULL;
- map_dump_file(self->m, s);
- Py_RETURN_NONE;
+map_dump_file_py(mapObject *self, PyObject *args) {
+ const char *s;
+ if (!PyArg_ParseTuple(args, "s",&s))
+ return NULL;
+ map_dump_file(self->m, s);
+ Py_RETURN_NONE;
}
static PyObject *
-map_set_attr_py(mapObject *self, PyObject *args)
-{
- PyObject *attr;
- if (!PyArg_ParseTuple(args, "O!", &attr_Type, &attr))
- return NULL;
- map_set_attr(self->m, attr_py_get(attr));
- Py_RETURN_NONE;
+map_set_attr_py(mapObject *self, PyObject *args) {
+ PyObject *attr;
+ if (!PyArg_ParseTuple(args, "O!", &attr_Type, &attr))
+ return NULL;
+ map_set_attr(self->m, attr_py_get(attr));
+ Py_RETURN_NONE;
}
static PyMethodDef map_methods[] = {
- {"dump_file", (PyCFunction) map_dump_file_py, METH_VARARGS },
- {"map_rect_new", (PyCFunction) map_rect_new_py, METH_VARARGS },
- {"set_attr", (PyCFunction) map_set_attr_py, METH_VARARGS },
- {NULL, NULL },
+ {"dump_file", (PyCFunction) map_dump_file_py, METH_VARARGS },
+ {"map_rect_new", (PyCFunction) map_rect_new_py, METH_VARARGS },
+ {"set_attr", (PyCFunction) map_set_attr_py, METH_VARARGS },
+ {NULL, NULL },
};
static PyObject *
-map_getattr_py(PyObject *self, char *name)
-{
- return Py_FindMethod(map_methods, self, name);
+map_getattr_py(PyObject *self, char *name) {
+ return Py_FindMethod(map_methods, self, name);
}
static PyObject *
-map_new_py(PyObject *self, PyObject *args)
-{
- mapObject *ret;
- char *type, *filename;
-
- if (!PyArg_ParseTuple(args, "ss:navit.map", &type, &filename))
- return NULL;
- ret=PyObject_NEW(mapObject, &map_Type);
- ret->m=map_new(NULL,NULL);
- ret->ref=0;
- return (PyObject *)ret;
+map_new_py(PyObject *self, PyObject *args) {
+ mapObject *ret;
+ char *type, *filename;
+
+ if (!PyArg_ParseTuple(args, "ss:navit.map", &type, &filename))
+ return NULL;
+ ret=PyObject_NEW(mapObject, &map_Type);
+ ret->m=map_new(NULL,NULL);
+ ret->ref=0;
+ return (PyObject *)ret;
}
PyObject *
-map_py_ref(struct map *map)
-{
- mapObject *ret;
- ret=PyObject_NEW(mapObject, &map_Type);
- ret->m=map;
- ret->ref=1;
- return (PyObject *)ret;
+map_py_ref(struct map *map) {
+ mapObject *ret;
+ ret=PyObject_NEW(mapObject, &map_Type);
+ ret->m=map;
+ ret->ref=1;
+ return (PyObject *)ret;
}
static void
-map_destroy_py(mapObject *self)
-{
- if (!self->ref)
- map_destroy(self->m);
+map_destroy_py(mapObject *self) {
+ if (!self->ref)
+ map_destroy(self->m);
}
/* *** mapset *** */
typedef struct {
- PyObject_HEAD
- struct mapset *ms;
+ PyObject_HEAD
+ struct mapset *ms;
} mapsetObject;
@@ -260,111 +248,106 @@ static PyObject *mapset_getattr_py(PyObject *self, char *name);
PyTypeObject mapset_Type = {
#if defined(MS_WINDOWS) || defined(__CYGWIN__)
- PyObject_HEAD_INIT(NULL);
+ PyObject_HEAD_INIT(NULL);
#else
- PyObject_HEAD_INIT(&PyType_Type)
+ PyObject_HEAD_INIT(&PyType_Type)
#endif
- .tp_name="mapset",
- .tp_basicsize=sizeof(mapsetObject),
- .tp_dealloc=(destructor)mapset_destroy_py,
- .tp_getattr=mapset_getattr_py,
+ .tp_name="mapset",
+ .tp_basicsize=sizeof(mapsetObject),
+ .tp_dealloc=(destructor)mapset_destroy_py,
+ .tp_getattr=mapset_getattr_py,
};
static PyObject *
-mapset_add_py(mapsetObject *self, PyObject *args)
-{
- mapObject *map;
- if (!PyArg_ParseTuple(args, "O:navit.mapset", &map))
- return NULL;
- Py_INCREF(map);
- mapset_add_attr(self->ms, &(struct attr){attr_map,.u.map=map->m});
- return Py_BuildValue("");
+mapset_add_py(mapsetObject *self, PyObject *args) {
+ mapObject *map;
+ if (!PyArg_ParseTuple(args, "O:navit.mapset", &map))
+ return NULL;
+ Py_INCREF(map);
+ mapset_add_attr(self->ms, &(struct attr) {
+ attr_map,.u.map=map->m
+ });
+ return Py_BuildValue("");
}
static PyMethodDef mapset_methods[] = {
- {"add", (PyCFunction) mapset_add_py, METH_VARARGS },
- {NULL, NULL },
+ {"add", (PyCFunction) mapset_add_py, METH_VARARGS },
+ {NULL, NULL },
};
static PyObject *
-mapset_getattr_py(PyObject *self, char *name)
-{
- return Py_FindMethod(mapset_methods, self, name);
+mapset_getattr_py(PyObject *self, char *name) {
+ return Py_FindMethod(mapset_methods, self, name);
}
static PyObject *
-mapset_new_py(PyObject *self, PyObject *args)
-{
- mapsetObject *ret;
- if (!PyArg_ParseTuple(args, ":navit.mapset"))
- return NULL;
- ret=PyObject_NEW(mapsetObject, &mapset_Type);
- ret->ms=mapset_new(NULL,NULL);
- return (PyObject *)ret;
+mapset_new_py(PyObject *self, PyObject *args) {
+ mapsetObject *ret;
+ if (!PyArg_ParseTuple(args, ":navit.mapset"))
+ return NULL;
+ ret=PyObject_NEW(mapsetObject, &mapset_Type);
+ ret->ms=mapset_new(NULL,NULL);
+ return (PyObject *)ret;
}
static void
-mapset_destroy_py(mapsetObject *self)
-{
- mapset_destroy(self->ms);
+mapset_destroy_py(mapsetObject *self) {
+ mapset_destroy(self->ms);
}
static PyObject *
-config_load_py(PyObject *self, PyObject *args)
-{
- const char *file;
- int ret;
- xmlerror *error;
- if (!PyArg_ParseTuple(args, "s", &file))
- return NULL;
- ret=config_load(file, &error);
- return Py_BuildValue("i",ret);
+config_load_py(PyObject *self, PyObject *args) {
+ const char *file;
+ int ret;
+ xmlerror *error;
+ if (!PyArg_ParseTuple(args, "s", &file))
+ return NULL;
+ ret=config_load(file, &error);
+ return Py_BuildValue("i",ret);
}
-static PyMethodDef navitMethods[]={
- {"attr", attr_new_py, METH_VARARGS},
- {"coord", coord_new_py, METH_VARARGS, "Create a new coordinate point."},
- {"coord_rect", coord_rect_new_py, METH_VARARGS, "Create a new coordinate rectangle."},
- {"map", map_new_py, METH_VARARGS, "Create a new map."},
- {"mapset", mapset_new_py, METH_VARARGS, "Create a new mapset."},
- {"config_load", config_load_py, METH_VARARGS, "Load a config"},
- {"config", config_py, METH_VARARGS, "Get Config Object"},
- {"pcoord", pcoord_py, METH_VARARGS},
- {NULL, NULL, 0, NULL}
+static PyMethodDef navitMethods[]= {
+ {"attr", attr_new_py, METH_VARARGS},
+ {"coord", coord_new_py, METH_VARARGS, "Create a new coordinate point."},
+ {"coord_rect", coord_rect_new_py, METH_VARARGS, "Create a new coordinate rectangle."},
+ {"map", map_new_py, METH_VARARGS, "Create a new map."},
+ {"mapset", mapset_new_py, METH_VARARGS, "Create a new mapset."},
+ {"config_load", config_load_py, METH_VARARGS, "Load a config"},
+ {"config", config_py, METH_VARARGS, "Get Config Object"},
+ {"pcoord", pcoord_py, METH_VARARGS},
+ {NULL, NULL, 0, NULL}
};
PyObject *
-python_object_from_attr(struct attr *attr)
-{
- switch (attr->type) {
- case attr_navigation:
- return navigation_py_ref(attr->u.navigation);
- case attr_route:
- return route_py_ref(attr->u.route);
- default:
- return NULL;
- }
- return NULL;
+python_object_from_attr(struct attr *attr) {
+ switch (attr->type) {
+ case attr_navigation:
+ return navigation_py_ref(attr->u.navigation);
+ case attr_route:
+ return route_py_ref(attr->u.route);
+ default:
+ return NULL;
+ }
+ return NULL;
}
void
-plugin_init(void)
-{
- int fd,size;
- char buffer[65536];
-
- Py_Initialize();
- Py_InitModule("navit", navitMethods);
- fd=open("startup.py",O_RDONLY);
- if (fd >= 0) {
- size=read(fd, buffer, 65535);
- if (size > 0) {
- buffer[size]='\0';
- PyRun_SimpleString(buffer);
- }
- }
-
- Py_Finalize();
+plugin_init(void) {
+ int fd,size;
+ char buffer[65536];
+
+ Py_Initialize();
+ Py_InitModule("navit", navitMethods);
+ fd=open("startup.py",O_RDONLY);
+ if (fd >= 0) {
+ size=read(fd, buffer, 65535);
+ if (size > 0) {
+ buffer[size]='\0';
+ PyRun_SimpleString(buffer);
+ }
+ }
+
+ Py_Finalize();
}
diff --git a/navit/binding/python/config.c b/navit/binding/python/config.c
index 9d5b1ae87..d8d91ead7 100644
--- a/navit/binding/python/config.c
+++ b/navit/binding/python/config.c
@@ -22,52 +22,48 @@
#include "config_.h"
typedef struct {
- PyObject_HEAD
+ PyObject_HEAD
} configObject;
static PyObject *
-config_navit(PyObject *self, PyObject *args)
-{
- struct attr navit;
- if (config_get_attr(config, attr_navit, &navit, NULL))
- return navit_py_ref(navit.u.navit);
- return NULL;
+config_navit(PyObject *self, PyObject *args) {
+ struct attr navit;
+ if (config_get_attr(config, attr_navit, &navit, NULL))
+ return navit_py_ref(navit.u.navit);
+ return NULL;
}
static PyMethodDef config_methods[] = {
- {"navit", (PyCFunction) config_navit, METH_VARARGS },
- {NULL, NULL },
+ {"navit", (PyCFunction) config_navit, METH_VARARGS },
+ {NULL, NULL },
};
static PyObject *
-config_getattr_py(PyObject *self, char *name)
-{
- return Py_FindMethod(config_methods, self, name);
+config_getattr_py(PyObject *self, char *name) {
+ return Py_FindMethod(config_methods, self, name);
}
static void
-config_destroy_py(configObject *self)
-{
+config_destroy_py(configObject *self) {
}
PyTypeObject config_Type = {
- Obj_HEAD
- .tp_name="config",
- .tp_basicsize=sizeof(configObject),
- .tp_dealloc=(destructor)config_destroy_py,
- .tp_getattr=config_getattr_py,
+ Obj_HEAD
+ .tp_name="config",
+ .tp_basicsize=sizeof(configObject),
+ .tp_dealloc=(destructor)config_destroy_py,
+ .tp_getattr=config_getattr_py,
};
PyObject *
-config_py(PyObject *self, PyObject *args)
-{
- configObject *ret;
+config_py(PyObject *self, PyObject *args) {
+ configObject *ret;
- dbg(lvl_debug,"enter");
- ret=PyObject_NEW(configObject, &config_Type);
- return (PyObject *)ret;
+ dbg(lvl_debug,"enter");
+ ret=PyObject_NEW(configObject, &config_Type);
+ return (PyObject *)ret;
}
diff --git a/navit/binding/python/navigation.c b/navit/binding/python/navigation.c
index 75a421d52..3e027cef3 100644
--- a/navit/binding/python/navigation.c
+++ b/navit/binding/python/navigation.c
@@ -21,62 +21,57 @@
#include "navigation.h"
typedef struct {
- PyObject_HEAD
- struct navigation *navigation;
+ PyObject_HEAD
+ struct navigation *navigation;
} navigationObject;
static PyObject *
-navigation_get_map_py(navigationObject *self, PyObject *args)
-{
- if (!PyArg_ParseTuple(args, ""))
- return NULL;
- return map_py_ref(navigation_get_map(self->navigation));
+navigation_get_map_py(navigationObject *self, PyObject *args) {
+ if (!PyArg_ParseTuple(args, ""))
+ return NULL;
+ return map_py_ref(navigation_get_map(self->navigation));
}
static PyMethodDef navigation_methods[] = {
- {"get_map", (PyCFunction) navigation_get_map_py, METH_VARARGS },
- {NULL, NULL },
+ {"get_map", (PyCFunction) navigation_get_map_py, METH_VARARGS },
+ {NULL, NULL },
};
static PyObject *
-navigation_getattr_py(PyObject *self, char *name)
-{
- return Py_FindMethod(navigation_methods, self, name);
+navigation_getattr_py(PyObject *self, char *name) {
+ return Py_FindMethod(navigation_methods, self, name);
}
static void
-navigation_destroy_py(navigationObject *self)
-{
+navigation_destroy_py(navigationObject *self) {
}
PyTypeObject navigation_Type = {
- Obj_HEAD
- .tp_name="navigation",
- .tp_basicsize=sizeof(navigationObject),
- .tp_dealloc=(destructor)navigation_destroy_py,
- .tp_getattr=navigation_getattr_py,
+ Obj_HEAD
+ .tp_name="navigation",
+ .tp_basicsize=sizeof(navigationObject),
+ .tp_dealloc=(destructor)navigation_destroy_py,
+ .tp_getattr=navigation_getattr_py,
};
PyObject *
-navigation_py(PyObject *self, PyObject *args)
-{
- navigationObject *ret;
+navigation_py(PyObject *self, PyObject *args) {
+ navigationObject *ret;
- ret=PyObject_NEW(navigationObject, &navigation_Type);
- return (PyObject *)ret;
+ ret=PyObject_NEW(navigationObject, &navigation_Type);
+ return (PyObject *)ret;
}
PyObject *
-navigation_py_ref(struct navigation *navigation)
-{
- navigationObject *ret;
+navigation_py_ref(struct navigation *navigation) {
+ navigationObject *ret;
- ret=PyObject_NEW(navigationObject, &navigation_Type);
- ret->navigation=navigation;
- return (PyObject *)ret;
+ ret=PyObject_NEW(navigationObject, &navigation_Type);
+ ret->navigation=navigation;
+ return (PyObject *)ret;
}
diff --git a/navit/binding/python/navit.c b/navit/binding/python/navit.c
index 2ee7c3126..6991e30d7 100644
--- a/navit/binding/python/navit.c
+++ b/navit/binding/python/navit.c
@@ -22,125 +22,115 @@
#include "navit.h"
typedef struct {
- PyObject_HEAD
- struct navit *navit;
+ PyObject_HEAD
+ struct navit *navit;
} navitObject;
static PyObject *
-navit_set_attr_py(navitObject *self, PyObject *args)
-{
- PyObject *attr;
- if (!PyArg_ParseTuple(args, "O!", &attr_Type, &attr))
- return NULL;
- navit_set_attr(self->navit, attr_py_get(attr));
- Py_RETURN_NONE;
+navit_set_attr_py(navitObject *self, PyObject *args) {
+ PyObject *attr;
+ if (!PyArg_ParseTuple(args, "O!", &attr_Type, &attr))
+ return NULL;
+ navit_set_attr(self->navit, attr_py_get(attr));
+ Py_RETURN_NONE;
}
static PyObject *
-navit_get_attr_py(navitObject *self, PyObject *args)
-{
- char *name;
- struct attr attr;
- if (!PyArg_ParseTuple(args, "s", &name))
- return NULL;
- if (!navit_get_attr(self->navit, attr_from_name(name), &attr, NULL)) {
- dbg(lvl_error,"get_attr not ok");
- Py_RETURN_NONE;
- }
- dbg(lvl_debug,"get_attr ok");
- return python_object_from_attr(&attr);
+navit_get_attr_py(navitObject *self, PyObject *args) {
+ char *name;
+ struct attr attr;
+ if (!PyArg_ParseTuple(args, "s", &name))
+ return NULL;
+ if (!navit_get_attr(self->navit, attr_from_name(name), &attr, NULL)) {
+ dbg(lvl_error,"get_attr not ok");
+ Py_RETURN_NONE;
+ }
+ dbg(lvl_debug,"get_attr ok");
+ return python_object_from_attr(&attr);
}
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), 0);
- Py_RETURN_NONE;
+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), 0);
+ Py_RETURN_NONE;
}
static PyObject *
-navit_set_destination_py(navitObject *self, PyObject *args)
-{
- PyObject *pcoord;
- const char *description;
- int async;
- if (!PyArg_ParseTuple(args, "O!si", &pcoord_Type, &pcoord, &description, &async))
- return NULL;
- navit_set_destination(self->navit, pcoord_py_get(pcoord), description, async);
- Py_RETURN_NONE;
+navit_set_destination_py(navitObject *self, PyObject *args) {
+ PyObject *pcoord;
+ const char *description;
+ int async;
+ if (!PyArg_ParseTuple(args, "O!si", &pcoord_Type, &pcoord, &description, &async))
+ return NULL;
+ navit_set_destination(self->navit, pcoord_py_get(pcoord), description, async);
+ 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;
+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 PyObject *
-navit_zoom_to_route_py(navitObject *self, PyObject *args)
-{
- if (!PyArg_ParseTuple(args, ""))
- return NULL;
- navit_zoom_to_route(self->navit,0);
- Py_RETURN_NONE;
+navit_zoom_to_route_py(navitObject *self, PyObject *args) {
+ if (!PyArg_ParseTuple(args, ""))
+ return NULL;
+ navit_zoom_to_route(self->navit,0);
+ Py_RETURN_NONE;
}
static PyMethodDef navit_methods[] = {
- {"set_attr", (PyCFunction) navit_set_attr_py, METH_VARARGS },
- {"get_attr", (PyCFunction) navit_get_attr_py, METH_VARARGS },
- {"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 },
- {"zoom_to_route", (PyCFunction) navit_zoom_to_route_py, METH_VARARGS },
- {NULL, NULL },
+ {"set_attr", (PyCFunction) navit_set_attr_py, METH_VARARGS },
+ {"get_attr", (PyCFunction) navit_get_attr_py, METH_VARARGS },
+ {"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 },
+ {"zoom_to_route", (PyCFunction) navit_zoom_to_route_py, METH_VARARGS },
+ {NULL, NULL },
};
static PyObject *
-navit_getattr_py(PyObject *self, char *name)
-{
- return Py_FindMethod(navit_methods, self, name);
+navit_getattr_py(PyObject *self, char *name) {
+ return Py_FindMethod(navit_methods, self, name);
}
static void
-navit_destroy_py(navitObject *self)
-{
+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,
+ 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;
+navit_py(PyObject *self, PyObject *args) {
+ navitObject *ret;
- dbg(lvl_debug,"enter");
- ret=PyObject_NEW(navitObject, &navit_Type);
- return (PyObject *)ret;
+ dbg(lvl_debug,"enter");
+ ret=PyObject_NEW(navitObject, &navit_Type);
+ return (PyObject *)ret;
}
PyObject *
-navit_py_ref(struct navit *navit)
-{
- dbg(lvl_debug,"navit=%p", navit);
- navitObject *ret=PyObject_NEW(navitObject, &navit_Type);
- ret->navit=navit;
- return (PyObject *)ret;
+navit_py_ref(struct navit *navit) {
+ dbg(lvl_debug,"navit=%p", navit);
+ navitObject *ret=PyObject_NEW(navitObject, &navit_Type);
+ ret->navit=navit;
+ return (PyObject *)ret;
}
diff --git a/navit/binding/python/pcoord.c b/navit/binding/python/pcoord.c
index 1588067bd..e27c44a75 100644
--- a/navit/binding/python/pcoord.c
+++ b/navit/binding/python/pcoord.c
@@ -21,68 +21,63 @@
#include "coord.h"
typedef struct {
- PyObject_HEAD
- struct pcoord pc;
+ PyObject_HEAD
+ struct pcoord pc;
} pcoordObject;
static PyObject *
-pcoord_func(pcoordObject *self, PyObject *args)
-{
- const char *file;
- int ret=0;
- if (!PyArg_ParseTuple(args, "s", &file))
- return NULL;
- return Py_BuildValue("i",ret);
+pcoord_func(pcoordObject *self, PyObject *args) {
+ const char *file;
+ int ret=0;
+ if (!PyArg_ParseTuple(args, "s", &file))
+ return NULL;
+ return Py_BuildValue("i",ret);
}
static PyMethodDef pcoord_methods[] = {
- {"func", (PyCFunction) pcoord_func, METH_VARARGS },
- {NULL, NULL },
+ {"func", (PyCFunction) pcoord_func, METH_VARARGS },
+ {NULL, NULL },
};
static PyObject *
-pcoord_getattr_py(PyObject *self, char *name)
-{
- return Py_FindMethod(pcoord_methods, self, name);
+pcoord_getattr_py(PyObject *self, char *name) {
+ return Py_FindMethod(pcoord_methods, self, name);
}
static void
-pcoord_destroy_py(pcoordObject *self)
-{
+pcoord_destroy_py(pcoordObject *self) {
}
PyTypeObject pcoord_Type = {
- Obj_HEAD
- .tp_name="pcoord",
- .tp_basicsize=sizeof(pcoordObject),
- .tp_dealloc=(destructor)pcoord_destroy_py,
- .tp_getattr=pcoord_getattr_py,
+ Obj_HEAD
+ .tp_name="pcoord",
+ .tp_basicsize=sizeof(pcoordObject),
+ .tp_dealloc=(destructor)pcoord_destroy_py,
+ .tp_getattr=pcoord_getattr_py,
};
PyObject *
-pcoord_py(PyObject *self, PyObject *args)
-{
- pcoordObject *ret;
- const char *str;
- enum projection pro;
- struct coord c;
- if (!PyArg_ParseTuple(args, "si", &str, &pro))
- return NULL;
- ret=PyObject_NEW(pcoordObject, &pcoord_Type);
- coord_parse(str, pro, &c);
- ret->pc.pro=pro;
- ret->pc.x=c.x;
- ret->pc.y=c.y;
- dbg(lvl_debug,"0x%x,0x%x", c.x, c.y);
- return (PyObject *)ret;
+pcoord_py(PyObject *self, PyObject *args) {
+ pcoordObject *ret;
+ const char *str;
+ enum projection pro;
+ struct coord c;
+ if (!PyArg_ParseTuple(args, "si", &str, &pro))
+ return NULL;
+ ret=PyObject_NEW(pcoordObject, &pcoord_Type);
+ coord_parse(str, pro, &c);
+ ret->pc.pro=pro;
+ ret->pc.x=c.x;
+ ret->pc.y=c.y;
+ dbg(lvl_debug,"0x%x,0x%x", c.x, c.y);
+ return (PyObject *)ret;
}
struct pcoord *
-pcoord_py_get(PyObject *self)
-{
- return &((pcoordObject *)self)->pc;
+pcoord_py_get(PyObject *self) {
+ return &((pcoordObject *)self)->pc;
}
diff --git a/navit/binding/python/route.c b/navit/binding/python/route.c
index dfbd08cf9..8010b416f 100644
--- a/navit/binding/python/route.c
+++ b/navit/binding/python/route.c
@@ -23,62 +23,57 @@
#include "route.h"
typedef struct {
- PyObject_HEAD
- struct route *route;
+ PyObject_HEAD
+ struct route *route;
} routeObject;
static PyObject *
-route_get_map_py(routeObject *self, PyObject *args)
-{
- if (!PyArg_ParseTuple(args, ""))
- return NULL;
- return map_py_ref(route_get_map(self->route));
+route_get_map_py(routeObject *self, PyObject *args) {
+ if (!PyArg_ParseTuple(args, ""))
+ return NULL;
+ return map_py_ref(route_get_map(self->route));
}
static PyMethodDef route_methods[] = {
- {"get_map", (PyCFunction) route_get_map_py, METH_VARARGS },
- {NULL, NULL },
+ {"get_map", (PyCFunction) route_get_map_py, METH_VARARGS },
+ {NULL, NULL },
};
static PyObject *
-route_getattr_py(PyObject *self, char *name)
-{
- return Py_FindMethod(route_methods, self, name);
+route_getattr_py(PyObject *self, char *name) {
+ return Py_FindMethod(route_methods, self, name);
}
static void
-route_destroy_py(routeObject *self)
-{
+route_destroy_py(routeObject *self) {
}
PyTypeObject route_Type = {
- Obj_HEAD
- .tp_name="route",
- .tp_basicsize=sizeof(routeObject),
- .tp_dealloc=(destructor)route_destroy_py,
- .tp_getattr=route_getattr_py,
+ Obj_HEAD
+ .tp_name="route",
+ .tp_basicsize=sizeof(routeObject),
+ .tp_dealloc=(destructor)route_destroy_py,
+ .tp_getattr=route_getattr_py,
};
PyObject *
-route_py(PyObject *self, PyObject *args)
-{
- routeObject *ret;
+route_py(PyObject *self, PyObject *args) {
+ routeObject *ret;
- ret=PyObject_NEW(routeObject, &route_Type);
- return (PyObject *)ret;
+ ret=PyObject_NEW(routeObject, &route_Type);
+ return (PyObject *)ret;
}
PyObject *
-route_py_ref(struct route *route)
-{
- routeObject *ret;
+route_py_ref(struct route *route) {
+ routeObject *ret;
- ret=PyObject_NEW(routeObject, &route_Type);
- ret->route=route;
- return (PyObject *)ret;
+ ret=PyObject_NEW(routeObject, &route_Type);
+ ret->route=route;
+ return (PyObject *)ret;
}
diff --git a/navit/binding/python/template.c b/navit/binding/python/template.c
index 088cb5ee3..2019173a3 100644
--- a/navit/binding/python/template.c
+++ b/navit/binding/python/template.c
@@ -21,76 +21,70 @@
#include "template.h"
typedef struct {
- PyObject_HEAD
- int ref;
- struct template *template;
+ PyObject_HEAD
+ int ref;
+ struct template *template;
} templateObject;
static PyObject *
-template_func(templateObject *self, PyObject *args)
-{
- const char *file;
- int ret;
- if (!PyArg_ParseTuple(args, "s", &file))
- return NULL;
- ret=0;
- return Py_BuildValue("i",ret);
+template_func(templateObject *self, PyObject *args) {
+ const char *file;
+ int ret;
+ if (!PyArg_ParseTuple(args, "s", &file))
+ return NULL;
+ ret=0;
+ return Py_BuildValue("i",ret);
}
static PyMethodDef template_methods[] = {
- {"func", (PyCFunction) template_func, METH_VARARGS },
- {NULL, NULL },
+ {"func", (PyCFunction) template_func, METH_VARARGS },
+ {NULL, NULL },
};
static PyObject *
-template_getattr_py(PyObject *self, char *name)
-{
- return Py_FindMethod(template_methods, self, name);
+template_getattr_py(PyObject *self, char *name) {
+ return Py_FindMethod(template_methods, self, name);
}
static void
-template_destroy_py(templateObject *self)
-{
- if (! self->ref)
- template_destroy(self->template);
+template_destroy_py(templateObject *self) {
+ if (! self->ref)
+ template_destroy(self->template);
}
PyTypeObject template_Type = {
- Obj_HEAD
- .tp_name="template",
- .tp_basicsize=sizeof(templateObject),
- .tp_dealloc=(destructor)template_destroy_py,
- .tp_getattr=template_getattr_py,
+ Obj_HEAD
+ .tp_name="template",
+ .tp_basicsize=sizeof(templateObject),
+ .tp_dealloc=(destructor)template_destroy_py,
+ .tp_getattr=template_getattr_py,
};
struct template *
-template_py_get(PyObject *self)
-{
- return ((templateObject *)self)->template;
+template_py_get(PyObject *self) {
+ return ((templateObject *)self)->template;
}
PyObject *
-template_new_py(PyObject *self, PyObject *args)
-{
- templateObject *ret;
-
- ret=PyObject_NEW(templateObject, &template_Type);
- ret->template=template_new();
- ret->ref=0;
- return (PyObject *)ret;
+template_new_py(PyObject *self, PyObject *args) {
+ templateObject *ret;
+
+ ret=PyObject_NEW(templateObject, &template_Type);
+ ret->template=template_new();
+ ret->ref=0;
+ return (PyObject *)ret;
}
PyObject *
-template_new_py_ref(struct template *template)
-{
- templateObject *ret;
-
- ret=PyObject_NEW(templateObject, &template_Type);
- ret->ref=1;
- ret->template=template;
- return (PyObject *)ret;
+template_new_py_ref(struct template *template) {
+ templateObject *ret;
+
+ ret=PyObject_NEW(templateObject, &template_Type);
+ ret->ref=1;
+ ret->template=template;
+ return (PyObject *)ret;
}