Fix:binding_python:Converted to new api
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Mon, 2 Nov 2009 11:33:08 +0000 (11:33 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Mon, 2 Nov 2009 11:33:08 +0000 (11:33 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit@2717 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/binding/python/Makefile.am
navit/binding/python/binding_python.c
navit/binding/python/common.h
navit/binding/python/config.c [new file with mode: 0644]
navit/binding/python/main.c [deleted file]
navit/binding/python/startup.py

index dd74229..a716323 100644 (file)
@@ -1,6 +1,6 @@
 include $(top_srcdir)/Makefile.inc
 AM_CPPFLAGS = @NAVIT_CFLAGS@ @PYTHON_CFLAGS@ -I$(top_srcdir)/navit -DMODULE=binding_python
 modulebinding_LTLIBRARIES = libbinding_python.la
-libbinding_python_la_SOURCES = binding_python.c main.c navit.c pcoord.c route.c navigation.c attr.c common.h
+libbinding_python_la_SOURCES = binding_python.c config.c navit.c pcoord.c route.c navigation.c attr.c common.h
 libbinding_python_la_LIBADD = @PYTHON_LIBS@
 libbinding_python_la_LDFLAGS = -module -avoid-version
index 6d4fcc7..318ef0f 100644 (file)
@@ -328,7 +328,7 @@ static PyMethodDef navitMethods[]={
        {"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"},
-       {"main", main_py, METH_VARARGS, "Get Main Object"},
+       {"config", config_py, METH_VARARGS, "Get Config Object"},
        {"pcoord", pcoord_py, METH_VARARGS},
        {NULL, NULL, 0, NULL}
 };
index 5c1a270..c9af7a8 100644 (file)
@@ -31,7 +31,7 @@ struct map;
 
 PyObject * python_object_from_attr(struct attr *attr);
 
-PyObject * main_py(PyObject *self, PyObject *args);
+PyObject * config_py(PyObject *self, PyObject *args);
 
 PyObject * map_py_ref(struct map *map);
 
diff --git a/navit/binding/python/config.c b/navit/binding/python/config.c
new file mode 100644 (file)
index 0000000..ffcaed2
--- /dev/null
@@ -0,0 +1,73 @@
+/**
+ * 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 "item.h"
+#include "config_.h"
+
+typedef struct {
+       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;
+}
+
+
+
+static PyMethodDef config_methods[] = {
+       {"navit",       (PyCFunction) config_navit, METH_VARARGS },
+       {NULL, NULL },
+};
+
+
+static PyObject *
+config_getattr_py(PyObject *self, char *name)
+{
+       return Py_FindMethod(config_methods, self, name);
+}
+
+static void
+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,
+};
+
+PyObject *
+config_py(PyObject *self, PyObject *args)
+{
+       configObject *ret;
+
+       dbg(0,"enter\n");       
+       ret=PyObject_NEW(configObject, &config_Type);
+       return (PyObject *)ret;
+}
+
diff --git a/navit/binding/python/main.c b/navit/binding/python/main.c
deleted file mode 100644 (file)
index 5a782cc..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * 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 "main.h"
-
-typedef struct {
-       PyObject_HEAD
-} mainObject;
-
-static PyObject *
-main_navit(PyObject *self, PyObject *args)
-{
-       struct navit *navit;
-       navit=main_get_navit(NULL);
-       return navit_py_ref(navit);
-}
-
-
-
-static PyMethodDef main_methods[] = {
-       {"navit",       (PyCFunction) main_navit, METH_VARARGS },
-       {NULL, NULL },
-};
-
-
-static PyObject *
-main_getattr_py(PyObject *self, char *name)
-{
-       return Py_FindMethod(main_methods, self, name);
-}
-
-static void
-main_destroy_py(mainObject *self)
-{
-}
-
-PyTypeObject main_Type = {
-       Obj_HEAD
-       .tp_name="main",
-       .tp_basicsize=sizeof(mainObject),
-       .tp_dealloc=(destructor)main_destroy_py,
-       .tp_getattr=main_getattr_py,
-};
-
-PyObject *
-main_py(PyObject *self, PyObject *args)
-{
-       mainObject *ret;
-
-       dbg(0,"enter\n");       
-       ret=PyObject_NEW(mainObject, &main_Type);
-       return (PyObject *)ret;
-}
-
index 02b2070..f8e8015 100644 (file)
@@ -2,7 +2,7 @@ import navit
 navit.config_load("navit.xml.local")
 pos=navit.pcoord("5023.7493 N 00730.2898 E",1);
 dest=navit.pcoord("5023.6604 N 00729.8500 E",1);
-inst=navit.main().navit();
+inst=navit.config().navit();
 inst.set_position(pos);
 inst.set_destination(dest,"Test");
 inst.set_center(pos);