diff options
author | Gabe Black <gblack@eecs.umich.edu> | 2007-09-04 23:46:08 -0700 |
---|---|---|
committer | Gabe Black <gblack@eecs.umich.edu> | 2007-09-04 23:46:08 -0700 |
commit | 57da0594157058f9d741dd19a4f08830652789f3 (patch) | |
tree | 09c9169cbd57b764b2717107a97ac45ff8bd9982 /src | |
parent | fea46ee6e3c55e5245f8954a3fa771a6ec3aca84 (diff) | |
parent | 276a3825579e3a88dca6cec5e2af84c68f1194cc (diff) | |
download | gem5-57da0594157058f9d741dd19a4f08830652789f3.tar.xz |
Merge with head.
--HG--
extra : convert_revision : 19bea7995285eeb7e277d3064f427429ade2bcb8
Diffstat (limited to 'src')
-rw-r--r-- | src/python/swig/core.i | 1 | ||||
-rw-r--r-- | src/python/swig/pyobject.cc | 41 | ||||
-rw-r--r-- | src/python/swig/pyobject.hh | 2 |
3 files changed, 18 insertions, 26 deletions
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..c682b0fd7 100644 --- a/src/python/swig/pyobject.cc +++ b/src/python/swig/pyobject.cc @@ -142,11 +142,6 @@ 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,29 +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; -} - -/** - * Load config.ini into C++ database. Exported to Python via SWIG; - * invoked from m5.instantiate(). - */ -void -loadIniFile(PyObject *_resolveFunc) -{ - resolveFunc = _resolveFunc; + Py_DECREF(module); + Py_DECREF(resolver); + Py_DECREF(ptr); - // The configuration database is now complete; start processing it. - inifile().load(simout.resolve("config.ini")); + return obj; } - 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. |