summaryrefslogtreecommitdiff
path: root/src/python/m5/params.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/python/m5/params.py')
-rw-r--r--src/python/m5/params.py30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/python/m5/params.py b/src/python/m5/params.py
index ee94ae004..87fc25131 100644
--- a/src/python/m5/params.py
+++ b/src/python/m5/params.py
@@ -81,10 +81,17 @@ class MetaParamValue(type):
class ParamValue(object):
__metaclass__ = MetaParamValue
+
+ # Generate the code needed as a prerequisite for declaring a C++
+ # object of this type. Typically generates one or more #include
+ # statements. Used when declaring parameters of this type.
@classmethod
def cxx_predecls(cls, code):
pass
+ # Generate the code needed as a prerequisite for including a
+ # reference to a C++ object of this type in a SWIG .i file.
+ # Typically generates one or more %import or %include statements.
@classmethod
def swig_predecls(cls, code):
pass
@@ -101,8 +108,6 @@ class ParamValue(object):
# Regular parameter description.
class ParamDesc(object):
- file_ext = 'ptype'
-
def __init__(self, ptype_str, ptype, *args, **kwargs):
self.ptype_str = ptype_str
# remember ptype only if it is provided
@@ -223,8 +228,6 @@ class SimObjectVector(VectorParamValue):
yield obj
class VectorParamDesc(ParamDesc):
- file_ext = 'vptype'
-
# Convert assigned value to appropriate type. If the RHS is not a
# list or tuple, it generates a single-element list.
def convert(self, value):
@@ -240,10 +243,14 @@ class VectorParamDesc(ParamDesc):
else:
return VectorParamValue(tmp_list)
+ def swig_module_name(self):
+ return "%s_vector" % self.ptype_str
+
def swig_predecls(self, code):
- code('%import "vptype_${{self.ptype_str}}.i"')
+ code('%import "${{self.swig_module_name()}}.i"')
def swig_decl(self, code):
+ code('%module(package="m5.internal") ${{self.swig_module_name()}}')
code('%{')
self.ptype.cxx_predecls(code)
code('%}')
@@ -1043,6 +1050,19 @@ namespace Enums {
} // namespace Enums
''')
+ def swig_decl(cls, code):
+ name = cls.__name__
+ code('''\
+%module(package="m5.internal") enum_$name
+
+%{
+#include "enums/$name.hh"
+%}
+
+%include "enums/$name.hh"
+''')
+
+
# Base class for enum types.
class Enum(ParamValue):
__metaclass__ = MetaEnum