From 4b49bd47f464fb3fe31a943b913edb565fa68423 Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Wed, 31 Oct 2007 18:04:22 -0700 Subject: String constant const-ness changes to placate g++ 4.2. Also some bug fixes in MIPS ISA uncovered by g++ warnings (Python string compares don't work in C++!). --HG-- extra : convert_revision : b347cc0108f23890e9b73b3ee96059f0cea96cf6 --- src/python/swig/pyobject.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/python') diff --git a/src/python/swig/pyobject.cc b/src/python/swig/pyobject.cc index c682b0fd7..eaa8baa8b 100644 --- a/src/python/swig/pyobject.cc +++ b/src/python/swig/pyobject.cc @@ -147,20 +147,28 @@ inifile() */ extern "C" SimObject *convertSwigSimObjectPtr(PyObject *); +// Python.h is notoriously not const-correct (for 2.4, anyway)... make +// a little define here to reduce the noise and make it easier to +// #ifdef away if Python.h gets fixed. Note there are a couple of +// these in sim/main.cc as well that are handled without this define. +#define PCC(s) const_cast(s) + + SimObject * resolveSimObject(const string &name) { - PyObject *module = PyImport_ImportModule("m5.SimObject"); + PyObject *module = PyImport_ImportModule(PCC("m5.SimObject")); if (module == NULL) panic("Could not import m5.SimObject"); - PyObject *resolver = PyObject_GetAttrString(module, "resolveSimObject"); + PyObject *resolver = + PyObject_GetAttrString(module, PCC("resolveSimObject")); if (resolver == NULL) { PyErr_Print(); panic("resolveSimObject: failed to find resolveSimObject"); } - PyObject *ptr = PyObject_CallFunction(resolver, "(s)", name.c_str()); + PyObject *ptr = PyObject_CallFunction(resolver, PCC("(s)"), name.c_str()); if (ptr == NULL) { PyErr_Print(); panic("resolveSimObject: failure on call to Python for %s", name); -- cgit v1.2.3