summaryrefslogtreecommitdiff
path: root/src/python/m5/params.py
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2010-09-09 14:26:29 -0700
committerNathan Binkert <nate@binkert.org>2010-09-09 14:26:29 -0700
commit47ef97b9caad0a72751523855d145dcd96fc5738 (patch)
tree9c221cdf3826302b1a908c06ea279fe4c6d8b722 /src/python/m5/params.py
parente6ee56c6571999631ce31b05d0e563d66a7bbdd8 (diff)
downloadgem5-47ef97b9caad0a72751523855d145dcd96fc5738.tar.xz
scons: Stop building the big monolithic swigged params module
kill params.i and create a separate .i for each object (param, enums, etc.)
Diffstat (limited to 'src/python/m5/params.py')
-rw-r--r--src/python/m5/params.py62
1 files changed, 46 insertions, 16 deletions
diff --git a/src/python/m5/params.py b/src/python/m5/params.py
index 00bba636b..0143fe2e7 100644
--- a/src/python/m5/params.py
+++ b/src/python/m5/params.py
@@ -241,18 +241,43 @@ class VectorParamDesc(ParamDesc):
return VectorParamValue(tmp_list)
def swig_predecls(self, code):
- code('%include "${{self.ptype_str}}_vptype.i"')
+ code('%import "${{self.ptype_str}}_vptype.i"')
def swig_decl(self, code):
- cxx_type = re.sub('std::', '', self.ptype.cxx_type)
- code('%include "std_vector.i"')
+ code('%{')
+ self.ptype.cxx_predecls(code)
+ code('%}')
+ code()
self.ptype.swig_predecls(code)
+ code()
+ code('%include "std_vector.i"')
+ code()
+
+ ptype = self.ptype_str
+ cxx_type = self.ptype.cxx_type
+
code('''\
-namespace std {
-%template(vector_${{self.ptype_str}}) vector< $cxx_type >;
+%typemap(in) std::vector< $cxx_type >::value_type {
+ if (SWIG_ConvertPtr($$input, (void **)&$$1, $$1_descriptor, 0) == -1) {
+ if (SWIG_ConvertPtr($$input, (void **)&$$1,
+ $$descriptor($cxx_type), 0) == -1) {
+ return NULL;
+ }
+ }
+}
+
+%typemap(in) std::vector< $cxx_type >::value_type * {
+ if (SWIG_ConvertPtr($$input, (void **)&$$1, $$1_descriptor, 0) == -1) {
+ if (SWIG_ConvertPtr($$input, (void **)&$$1,
+ $$descriptor($cxx_type *), 0) == -1) {
+ return NULL;
+ }
+ }
}
''')
+ code('%template(vector_$ptype) std::vector< $cxx_type >;')
+
def cxx_predecls(self, code):
code('#include <vector>')
self.ptype.cxx_predecls(code)
@@ -537,18 +562,19 @@ class Range(ParamValue):
@classmethod
def cxx_predecls(cls, code):
- code('#include "base/range.hh"')
cls.type.cxx_predecls(code)
-
-class AddrRange(Range):
- type = Addr
+ code('#include "base/range.hh"')
@classmethod
def swig_predecls(cls, code):
- code('%include "python/swig/range.i"')
+ cls.type.swig_predecls(code)
+ code('%import "python/swig/range.i"')
+
+class AddrRange(Range):
+ type = Addr
def getValue(self):
- from m5.objects.params import AddrRange
+ from m5.internal.range import AddrRange
value = AddrRange()
value.start = long(self.first)
@@ -558,12 +584,8 @@ class AddrRange(Range):
class TickRange(Range):
type = Tick
- @classmethod
- def swig_predecls(cls, code):
- code('%include "python/swig/range.i"')
-
def getValue(self):
- from m5.objects.params import TickRange
+ from m5.internal.range import TickRange
value = TickRange()
value.start = long(self.first)
@@ -838,6 +860,14 @@ class Enum(ParamValue):
% (value, self.vals)
self.value = value
+ @classmethod
+ def cxx_predecls(cls, code):
+ code('#include "enums/$0.hh"', cls.__name__)
+
+ @classmethod
+ def swig_predecls(cls, code):
+ code('%import "enums/$0.i"', cls.__name__)
+
def getValue(self):
return int(self.map[self.value])