From 021421d66355dd0c3ebb0728407c3da569ee32e2 Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Tue, 4 Sep 2007 13:12:58 -0400 Subject: Config: Remove some ini file code that no longer works --HG-- extra : convert_revision : cb01dc0abeabc97b03d7af10959d92ceb62ea936 --- src/python/swig/core.i | 1 - src/python/swig/pyobject.cc | 13 ------------- src/python/swig/pyobject.hh | 2 -- 3 files changed, 16 deletions(-) (limited to 'src') diff --git a/src/python/swig/core.i b/src/python/swig/core.i index 8960fb228..770765ca4 100644 --- a/src/python/swig/core.i +++ b/src/python/swig/core.i @@ -47,7 +47,6 @@ extern const char *compileDate; void setOutputDir(const std::string &dir); void setOutputFile(const std::string &file); -void loadIniFile(PyObject *); void SimStartup(); void doExitCleanup(); diff --git a/src/python/swig/pyobject.cc b/src/python/swig/pyobject.cc index 5ae2aa177..fad280e1b 100644 --- a/src/python/swig/pyobject.cc +++ b/src/python/swig/pyobject.cc @@ -168,16 +168,3 @@ resolveSimObject(const string &name) return simObj; } -/** - * Load config.ini into C++ database. Exported to Python via SWIG; - * invoked from m5.instantiate(). - */ -void -loadIniFile(PyObject *_resolveFunc) -{ - resolveFunc = _resolveFunc; - - // The configuration database is now complete; start processing it. - inifile().load(simout.resolve("config.ini")); -} - diff --git a/src/python/swig/pyobject.hh b/src/python/swig/pyobject.hh index 8e3a96994..e895be636 100644 --- a/src/python/swig/pyobject.hh +++ b/src/python/swig/pyobject.hh @@ -38,8 +38,6 @@ extern "C" SimObject *convertSwigSimObjectPtr(PyObject *); SimObject *resolveSimObject(const std::string &name); -void loadIniFile(PyObject *_resolveFunc); - /** * Connect the described MemObject ports. Called from Python via SWIG. -- cgit v1.2.3 From 276a3825579e3a88dca6cec5e2af84c68f1194cc Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Tue, 4 Sep 2007 13:12:58 -0400 Subject: Serialization: Fix unserialization of object pointers --HG-- extra : convert_revision : a5aed880b2fc05841067e8597a58a9484e30b84a --- src/python/swig/pyobject.cc | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/python/swig/pyobject.cc b/src/python/swig/pyobject.cc index fad280e1b..c682b0fd7 100644 --- a/src/python/swig/pyobject.cc +++ b/src/python/swig/pyobject.cc @@ -141,11 +141,6 @@ inifile() return inifile; } -/** - * Pointer to the Python function that maps names to SimObjects. - */ -PyObject *resolveFunc = NULL; - /** * Convert a pointer to the Python object that SWIG wraps around a C++ * SimObject pointer back to the actual C++ pointer. See main.i. @@ -155,16 +150,29 @@ extern "C" SimObject *convertSwigSimObjectPtr(PyObject *); SimObject * resolveSimObject(const string &name) { - PyObject *pyPtr = PyEval_CallFunction(resolveFunc, "(s)", name.c_str()); - if (pyPtr == NULL) { + PyObject *module = PyImport_ImportModule("m5.SimObject"); + if (module == NULL) + panic("Could not import m5.SimObject"); + + PyObject *resolver = PyObject_GetAttrString(module, "resolveSimObject"); + if (resolver == NULL) { + PyErr_Print(); + panic("resolveSimObject: failed to find resolveSimObject"); + } + + PyObject *ptr = PyObject_CallFunction(resolver, "(s)", name.c_str()); + if (ptr == NULL) { PyErr_Print(); panic("resolveSimObject: failure on call to Python for %s", name); } - SimObject *simObj = convertSwigSimObjectPtr(pyPtr); - if (simObj == NULL) + SimObject *obj = convertSwigSimObjectPtr(ptr); + if (obj == NULL) panic("resolveSimObject: failure on pointer conversion for %s", name); - return simObj; -} + Py_DECREF(module); + Py_DECREF(resolver); + Py_DECREF(ptr); + return obj; +} -- cgit v1.2.3