summaryrefslogtreecommitdiff
path: root/src/python/m5/SimObject.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/python/m5/SimObject.py')
-rw-r--r--src/python/m5/SimObject.py26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/python/m5/SimObject.py b/src/python/m5/SimObject.py
index dca7d4095..317ae6c33 100644
--- a/src/python/m5/SimObject.py
+++ b/src/python/m5/SimObject.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2017-2018 ARM Limited
+# Copyright (c) 2017-2019 ARM Limited
# All rights reserved.
#
# The license below extends only to copyright in the software and shall
@@ -655,18 +655,27 @@ class MetaSimObject(type):
if attr == 'cxx_namespaces':
return cls.cxx_class_path[:-1]
+ if attr == 'pybind_class':
+ return '_COLONS_'.join(cls.cxx_class_path)
+
if attr in cls._values:
return cls._values[attr]
if attr in cls._children:
return cls._children[attr]
- raise AttributeError(
- "object '%s' has no attribute '%s'" % (cls.__name__, attr))
+ try:
+ return getattr(cls.getCCClass(), attr)
+ except AttributeError:
+ raise AttributeError(
+ "object '%s' has no attribute '%s'" % (cls.__name__, attr))
def __str__(cls):
return cls.__name__
+ def getCCClass(cls):
+ return getattr(m5.internal.params, cls.pybind_class)
+
# See ParamValue.cxx_predecls for description.
def cxx_predecls(cls, code):
code('#include "params/$cls.hh"')
@@ -675,10 +684,7 @@ class MetaSimObject(type):
code('#include "${{cls.cxx_header}}"')
def pybind_decl(cls, code):
- class_path = cls.cxx_class.split('::')
- namespaces, classname = class_path[:-1], class_path[-1]
- py_class_name = '_COLONS_'.join(class_path) if namespaces else \
- classname;
+ py_class_name = cls.pybind_class
# The 'local' attribute restricts us to the params declared in
# the object itself, not including inherited params (which
@@ -952,6 +958,7 @@ def cxxMethod(*args, **kwargs):
override = kwargs.get("override", False)
cxx_name = kwargs.get("cxx_name", name)
return_value_policy = kwargs.get("return_value_policy", None)
+ static = kwargs.get("static", False)
args, varargs, keywords, defaults = inspect.getargspec(func)
if varargs or keywords:
@@ -968,7 +975,7 @@ def cxxMethod(*args, **kwargs):
@wraps(func)
def cxx_call(self, *args, **kwargs):
- ccobj = self.getCCObject()
+ ccobj = self.getCCClass() if static else self.getCCObject()
return getattr(ccobj, name)(*args, **kwargs)
@wraps(func)
@@ -977,7 +984,8 @@ def cxxMethod(*args, **kwargs):
f = py_call if override else cxx_call
f.__pybind = PyBindMethod(name, cxx_name=cxx_name, args=args,
- return_value_policy=return_value_policy)
+ return_value_policy=return_value_policy,
+ static=static)
return f