summaryrefslogtreecommitdiff
path: root/src/python
diff options
context:
space:
mode:
authorSteve Reinhardt <steve.reinhardt@amd.com>2010-07-17 08:56:49 -0700
committerSteve Reinhardt <steve.reinhardt@amd.com>2010-07-17 08:56:49 -0700
commit262b2e2b942f15384393b421ece5bb9a2ac48ee1 (patch)
treeab4756241015a86dd2fd042d06c98427ced14c06 /src/python
parent8cec87056824782e061eac152b83432899d9b6d9 (diff)
downloadgem5-262b2e2b942f15384393b421ece5bb9a2ac48ee1.tar.xz
SimObject: transparently forward Python attribute refs to C++.
This tidbit was pulled from a larger patch for Tim's sake, so the comment reflects functions that haven't been exported yet. I hope to commit them soon so it didn't seem worth cleaning up.
Diffstat (limited to 'src/python')
-rw-r--r--src/python/m5/SimObject.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/python/m5/SimObject.py b/src/python/m5/SimObject.py
index e6f0e36b2..3b84d6000 100644
--- a/src/python/m5/SimObject.py
+++ b/src/python/m5/SimObject.py
@@ -527,6 +527,13 @@ class SimObject(object):
if self._values.has_key(attr):
return self._values[attr]
+ # If the attribute exists on the C++ object, transparently
+ # forward the reference there. This is typically used for
+ # SWIG-wrapped methods such as init(), regStats(),
+ # regFormulas(), resetStats(), and startup().
+ if self._ccObject and hasattr(self._ccObject, attr):
+ return getattr(self._ccObject, attr)
+
raise AttributeError, "object '%s' has no attribute '%s'" \
% (self.__class__.__name__, attr)