Merge with head.
--HG-- extra : convert_revision : 19bea7995285eeb7e277d3064f427429ade2bcb8
This commit is contained in:
commit
57da059415
3 changed files with 19 additions and 27 deletions
|
@ -47,7 +47,6 @@ extern const char *compileDate;
|
||||||
|
|
||||||
void setOutputDir(const std::string &dir);
|
void setOutputDir(const std::string &dir);
|
||||||
void setOutputFile(const std::string &file);
|
void setOutputFile(const std::string &file);
|
||||||
void loadIniFile(PyObject *);
|
|
||||||
void SimStartup();
|
void SimStartup();
|
||||||
void doExitCleanup();
|
void doExitCleanup();
|
||||||
|
|
||||||
|
|
|
@ -141,11 +141,6 @@ inifile()
|
||||||
return 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++
|
* Convert a pointer to the Python object that SWIG wraps around a C++
|
||||||
* SimObject pointer back to the actual C++ pointer. See main.i.
|
* SimObject pointer back to the actual C++ pointer. See main.i.
|
||||||
|
@ -155,29 +150,29 @@ extern "C" SimObject *convertSwigSimObjectPtr(PyObject *);
|
||||||
SimObject *
|
SimObject *
|
||||||
resolveSimObject(const string &name)
|
resolveSimObject(const string &name)
|
||||||
{
|
{
|
||||||
PyObject *pyPtr = PyEval_CallFunction(resolveFunc, "(s)", name.c_str());
|
PyObject *module = PyImport_ImportModule("m5.SimObject");
|
||||||
if (pyPtr == NULL) {
|
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();
|
PyErr_Print();
|
||||||
panic("resolveSimObject: failure on call to Python for %s", name);
|
panic("resolveSimObject: failure on call to Python for %s", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
SimObject *simObj = convertSwigSimObjectPtr(pyPtr);
|
SimObject *obj = convertSwigSimObjectPtr(ptr);
|
||||||
if (simObj == NULL)
|
if (obj == NULL)
|
||||||
panic("resolveSimObject: failure on pointer conversion for %s", name);
|
panic("resolveSimObject: failure on pointer conversion for %s", name);
|
||||||
|
|
||||||
return simObj;
|
Py_DECREF(module);
|
||||||
|
Py_DECREF(resolver);
|
||||||
|
Py_DECREF(ptr);
|
||||||
|
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,6 @@
|
||||||
|
|
||||||
extern "C" SimObject *convertSwigSimObjectPtr(PyObject *);
|
extern "C" SimObject *convertSwigSimObjectPtr(PyObject *);
|
||||||
SimObject *resolveSimObject(const std::string &name);
|
SimObject *resolveSimObject(const std::string &name);
|
||||||
void loadIniFile(PyObject *_resolveFunc);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connect the described MemObject ports. Called from Python via SWIG.
|
* Connect the described MemObject ports. Called from Python via SWIG.
|
||||||
|
|
Loading…
Reference in a new issue