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.
This commit is contained in:
parent
8cec870568
commit
262b2e2b94
|
@ -527,6 +527,13 @@ class SimObject(object):
|
||||||
if self._values.has_key(attr):
|
if self._values.has_key(attr):
|
||||||
return self._values[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'" \
|
raise AttributeError, "object '%s' has no attribute '%s'" \
|
||||||
% (self.__class__.__name__, attr)
|
% (self.__class__.__name__, attr)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue