SimObject.py (5467:6d9df90d70d7) | SimObject.py (5488:c8571e8ce7b6) |
---|---|
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 | 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 |
|
399 # now generate the actual param struct | 409 # now generate the actual param struct |
400 code += "struct %sParams" % cls | 410 code = "struct %sParams" % cls |
401 if base: 402 code += " : public %sParams" % base 403 code += "\n{\n" | 411 if base: 412 code += " : public %sParams" % base 413 code += "\n{\n" |
404 if cls == SimObject: 405 code += " virtual ~%sParams() {}\n" % cls | |
406 if not hasattr(cls, 'abstract') or not cls.abstract: 407 if 'type' in cls.__dict__: 408 code += " %s create();\n" % cls.cxx_type 409 decls = [p.cxx_decl() for p in params] 410 decls.sort() 411 code += "".join([" %s\n" % d for d in decls]) 412 code += "};\n" 413 | 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" | |
416 return code 417 418 def cxx_type_decl(cls): 419 base = cls.get_base() 420 code = '' 421 422 if base: 423 code += '#include "%s_type.h"\n' % base --- 54 unchanged lines hidden (view full) --- 478# (parent/child node relationships). 479class SimObject(object): 480 # Specify metaclass. Any class inheriting from SimObject will 481 # get this metaclass. 482 __metaclass__ = MetaSimObject 483 type = 'SimObject' 484 abstract = True 485 | 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") | |
487 swig_objdecls = [ '%include "python/swig/sim_object.i"' ] 488 489 # Initialize new instance. For objects with SimObject-valued 490 # children, we need to recursively clone the classes represented 491 # by those param values as well in a consistent "deep copy"-style 492 # fashion. That is, we want to make sure that each instance is 493 # cloned only once, and that if there are multiple references to 494 # the same original object, we end up with the corresponding --- 262 unchanged lines hidden (view full) --- 757 self._children[child].print_ini(ini_file) 758 759 def getCCParams(self): 760 if self._ccParams: 761 return self._ccParams 762 763 cc_params_struct = getattr(m5.objects.params, '%sParams' % self.type) 764 cc_params = cc_params_struct() | 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 |
766 cc_params.name = str(self) 767 768 param_names = self._params.keys() 769 param_names.sort() 770 for param in param_names: 771 value = self._values.get(param) 772 if value is None: 773 continue --- 139 unchanged lines hidden --- | 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 --- |