params.py (7673:b28bd1fa9a35) params.py (7675:2221ec64132f)
1# Copyright (c) 2004-2006 The Regents of The University of Michigan
2# Copyright (c) 2010 Advanced Micro Devices, Inc.
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

--- 227 unchanged lines hidden (view full) ---

236 tmp_list = [ ParamDesc.convert(self, value) ]
237
238 if isSimObjectSequence(tmp_list):
239 return SimObjectVector(tmp_list)
240 else:
241 return VectorParamValue(tmp_list)
242
243 def swig_predecls(self, code):
1# Copyright (c) 2004-2006 The Regents of The University of Michigan
2# Copyright (c) 2010 Advanced Micro Devices, Inc.
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

--- 227 unchanged lines hidden (view full) ---

236 tmp_list = [ ParamDesc.convert(self, value) ]
237
238 if isSimObjectSequence(tmp_list):
239 return SimObjectVector(tmp_list)
240 else:
241 return VectorParamValue(tmp_list)
242
243 def swig_predecls(self, code):
244 code('%include "${{self.ptype_str}}_vptype.i"')
244 code('%import "${{self.ptype_str}}_vptype.i"')
245
246 def swig_decl(self, code):
245
246 def swig_decl(self, code):
247 cxx_type = re.sub('std::', '', self.ptype.cxx_type)
248 code('%include "std_vector.i"')
247 code('%{')
248 self.ptype.cxx_predecls(code)
249 code('%}')
250 code()
249 self.ptype.swig_predecls(code)
251 self.ptype.swig_predecls(code)
252 code()
253 code('%include "std_vector.i"')
254 code()
255
256 ptype = self.ptype_str
257 cxx_type = self.ptype.cxx_type
258
250 code('''\
259 code('''\
251namespace std {
252%template(vector_${{self.ptype_str}}) vector< $cxx_type >;
260%typemap(in) std::vector< $cxx_type >::value_type {
261 if (SWIG_ConvertPtr($$input, (void **)&$$1, $$1_descriptor, 0) == -1) {
262 if (SWIG_ConvertPtr($$input, (void **)&$$1,
263 $$descriptor($cxx_type), 0) == -1) {
264 return NULL;
265 }
266 }
253}
267}
268
269%typemap(in) std::vector< $cxx_type >::value_type * {
270 if (SWIG_ConvertPtr($$input, (void **)&$$1, $$1_descriptor, 0) == -1) {
271 if (SWIG_ConvertPtr($$input, (void **)&$$1,
272 $$descriptor($cxx_type *), 0) == -1) {
273 return NULL;
274 }
275 }
276}
254''')
255
277''')
278
279 code('%template(vector_$ptype) std::vector< $cxx_type >;')
280
256 def cxx_predecls(self, code):
257 code('#include <vector>')
258 self.ptype.cxx_predecls(code)
259
260 def cxx_decl(self, code):
261 code('std::vector< ${{self.ptype.cxx_type}} > ${{self.name}};')
262
263class ParamFactory(object):

--- 268 unchanged lines hidden (view full) ---

532 if kwargs:
533 raise TypeError, "too many keywords: %s" % kwargs.keys()
534
535 def __str__(self):
536 return '%s:%s' % (self.first, self.second)
537
538 @classmethod
539 def cxx_predecls(cls, code):
281 def cxx_predecls(self, code):
282 code('#include <vector>')
283 self.ptype.cxx_predecls(code)
284
285 def cxx_decl(self, code):
286 code('std::vector< ${{self.ptype.cxx_type}} > ${{self.name}};')
287
288class ParamFactory(object):

--- 268 unchanged lines hidden (view full) ---

557 if kwargs:
558 raise TypeError, "too many keywords: %s" % kwargs.keys()
559
560 def __str__(self):
561 return '%s:%s' % (self.first, self.second)
562
563 @classmethod
564 def cxx_predecls(cls, code):
540 code('#include "base/range.hh"')
541 cls.type.cxx_predecls(code)
565 cls.type.cxx_predecls(code)
566 code('#include "base/range.hh"')
542
567
543class AddrRange(Range):
544 type = Addr
545
546 @classmethod
547 def swig_predecls(cls, code):
568 @classmethod
569 def swig_predecls(cls, code):
548 code('%include "python/swig/range.i"')
570 cls.type.swig_predecls(code)
571 code('%import "python/swig/range.i"')
549
572
573class AddrRange(Range):
574 type = Addr
575
550 def getValue(self):
576 def getValue(self):
551 from m5.objects.params import AddrRange
577 from m5.internal.range import AddrRange
552
553 value = AddrRange()
554 value.start = long(self.first)
555 value.end = long(self.second)
556 return value
557
558class TickRange(Range):
559 type = Tick
560
578
579 value = AddrRange()
580 value.start = long(self.first)
581 value.end = long(self.second)
582 return value
583
584class TickRange(Range):
585 type = Tick
586
561 @classmethod
562 def swig_predecls(cls, code):
563 code('%include "python/swig/range.i"')
564
565 def getValue(self):
587 def getValue(self):
566 from m5.objects.params import TickRange
588 from m5.internal.range import TickRange
567
568 value = TickRange()
569 value.start = long(self.first)
570 value.end = long(self.second)
571 return value
572
573# Boolean parameter type. Python doesn't let you subclass bool, since
574# it doesn't want to let you create multiple instances of True and

--- 258 unchanged lines hidden (view full) ---

833 vals = []
834
835 def __init__(self, value):
836 if value not in self.map:
837 raise TypeError, "Enum param got bad value '%s' (not in %s)" \
838 % (value, self.vals)
839 self.value = value
840
589
590 value = TickRange()
591 value.start = long(self.first)
592 value.end = long(self.second)
593 return value
594
595# Boolean parameter type. Python doesn't let you subclass bool, since
596# it doesn't want to let you create multiple instances of True and

--- 258 unchanged lines hidden (view full) ---

855 vals = []
856
857 def __init__(self, value):
858 if value not in self.map:
859 raise TypeError, "Enum param got bad value '%s' (not in %s)" \
860 % (value, self.vals)
861 self.value = value
862
863 @classmethod
864 def cxx_predecls(cls, code):
865 code('#include "enums/$0.hh"', cls.__name__)
866
867 @classmethod
868 def swig_predecls(cls, code):
869 code('%import "enums/$0.i"', cls.__name__)
870
841 def getValue(self):
842 return int(self.map[self.value])
843
844 def __str__(self):
845 return self.value
846
847# how big does a rounding error need to be before we warn about it?
848frequency_tolerance = 0.001 # 0.1%

--- 451 unchanged lines hidden ---
871 def getValue(self):
872 return int(self.map[self.value])
873
874 def __str__(self):
875 return self.value
876
877# how big does a rounding error need to be before we warn about it?
878frequency_tolerance = 0.001 # 0.1%

--- 451 unchanged lines hidden ---