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

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

391 if base:
392 code += '#include "params/%s.hh"\n\n' % base
393
394 for ptype in ptypes:
395 if issubclass(ptype, Enum):
396 code += '#include "enums/%s.hh"\n' % ptype.__name__
397 code += "\n\n"
398
399 code += cls.cxx_struct(base, params)
400
401 # close #ifndef __PARAMS__* guard
402 code += "\n#endif\n"
403 return code
404
405 def cxx_struct(cls, base, params):
406 if cls == SimObject:
407 return '#include "sim/sim_object_params.hh"\n'
408
409 # now generate the actual param struct
400 code += "struct %sParams" % cls
410 code = "struct %sParams" % cls
411 if base:
412 code += " : public %sParams" % base
413 code += "\n{\n"
404 if cls == SimObject:
405 code += " virtual ~%sParams() {}\n" % cls
414 if not hasattr(cls, 'abstract') or not cls.abstract:
415 if 'type' in cls.__dict__:
416 code += " %s create();\n" % cls.cxx_type
417 decls = [p.cxx_decl() for p in params]
418 decls.sort()
419 code += "".join([" %s\n" % d for d in decls])
420 code += "};\n"
421
414 # close #ifndef __PARAMS__* guard
415 code += "\n#endif\n"
422 return code
423
424 def cxx_type_decl(cls):
425 base = cls.get_base()
426 code = ''
427
428 if base:
429 code += '#include "%s_type.h"\n' % base

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

484# (parent/child node relationships).
485class SimObject(object):
486 # Specify metaclass. Any class inheriting from SimObject will
487 # get this metaclass.
488 __metaclass__ = MetaSimObject
489 type = 'SimObject'
490 abstract = True
491
486 name = Param.String("Object name")
492 swig_objdecls = [ '%include "python/swig/sim_object.i"' ]
493
494 # Initialize new instance. For objects with SimObject-valued
495 # children, we need to recursively clone the classes represented
496 # by those param values as well in a consistent "deep copy"-style
497 # fashion. That is, we want to make sure that each instance is
498 # cloned only once, and that if there are multiple references to
499 # the same original object, we end up with the corresponding

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

762 self._children[child].print_ini(ini_file)
763
764 def getCCParams(self):
765 if self._ccParams:
766 return self._ccParams
767
768 cc_params_struct = getattr(m5.objects.params, '%sParams' % self.type)
769 cc_params = cc_params_struct()
765 cc_params.object = self
770 cc_params.pyobj = self
771 cc_params.name = str(self)
772
773 param_names = self._params.keys()
774 param_names.sort()
775 for param in param_names:
776 value = self._values.get(param)
777 if value is None:
778 continue

--- 139 unchanged lines hidden ---