Recreate the navit git/gerrit project that vanished
[profile/ivi/navit.git] / navit / binding / python / navigation.c
1 /**
2  * Navit, a modular navigation system.
3  * Copyright (C) 2005-2008 Navit Team
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * version 2 as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA  02110-1301, USA.
18  */
19
20 #include "common.h"
21 #include "navigation.h"
22
23 typedef struct {
24         PyObject_HEAD
25         struct navigation *navigation;
26 } navigationObject;
27
28 static PyObject *
29 navigation_get_map_py(navigationObject *self, PyObject *args)
30 {
31         if (!PyArg_ParseTuple(args, ""))
32                 return NULL;
33         return map_py_ref(navigation_get_map(self->navigation));
34 }
35
36
37
38 static PyMethodDef navigation_methods[] = {
39         {"get_map",     (PyCFunction) navigation_get_map_py, METH_VARARGS },
40         {NULL, NULL },
41 };
42
43
44 static PyObject *
45 navigation_getattr_py(PyObject *self, char *name)
46 {
47         return Py_FindMethod(navigation_methods, self, name);
48 }
49
50 static void
51 navigation_destroy_py(navigationObject *self)
52 {
53 }
54
55 PyTypeObject navigation_Type = {
56         Obj_HEAD
57         .tp_name="navigation",
58         .tp_basicsize=sizeof(navigationObject),
59         .tp_dealloc=(destructor)navigation_destroy_py,
60         .tp_getattr=navigation_getattr_py,
61 };
62
63 PyObject *
64 navigation_py(PyObject *self, PyObject *args)
65 {
66         navigationObject *ret;
67
68         ret=PyObject_NEW(navigationObject, &navigation_Type);
69         return (PyObject *)ret;
70 }
71
72 PyObject *
73 navigation_py_ref(struct navigation *navigation)
74 {
75         navigationObject *ret;
76
77         ret=PyObject_NEW(navigationObject, &navigation_Type);
78         ret->navigation=navigation;
79         return (PyObject *)ret;
80 }
81
82