Deleted Added
sdiff udiff text old ( 8596:e6e22fa77883 ) new ( 8597:45c9f664a365 )
full compact
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;

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

185
186 # default keyword values
187 if 'type' in cls._value_dict:
188 if 'cxx_class' not in cls._value_dict:
189 cls._value_dict['cxx_class'] = cls._value_dict['type']
190
191 cls._value_dict['cxx_type'] = '%s *' % cls._value_dict['cxx_class']
192
193 # Now process the _value_dict items. They could be defining
194 # new (or overriding existing) parameters or ports, setting
195 # class keywords (e.g., 'abstract'), or setting parameter
196 # values or port bindings. The first 3 can only be set when
197 # the class is defined, so we handle them here. The others
198 # can be set later too, so just emulate that by calling
199 # setattr().
200 for key,val in cls._value_dict.items():

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

335 # See ParamValue.cxx_predecls for description.
336 def cxx_predecls(cls, code):
337 code('#include "params/$cls.hh"')
338
339 # See ParamValue.swig_predecls for description.
340 def swig_predecls(cls, code):
341 code('%import "python/m5/internal/param_$cls.i"')
342
343 # Generate the declaration for this object for wrapping with SWIG.
344 # Generates code that goes into a SWIG .i file. Called from
345 # src/SConscript.
346 def swig_decl(cls, code):
347 class_path = cls.cxx_class.split('::')
348 classname = class_path[-1]
349 namespaces = class_path[:-1]
350

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

355 params = cls._params.local.values()
356
357 code('%module(package="m5.internal") param_$cls')
358 code()
359 code('%{')
360 code('#include "params/$cls.hh"')
361 for param in params:
362 param.cxx_predecls(code)
363 code('%}')
364 code()
365
366 for param in params:
367 param.swig_predecls(code)
368
369 code()
370 if cls._base:
371 code('%import "python/m5/internal/param_${{cls._base}}.i"')
372 code()
373
374 for ns in namespaces:
375 code('namespace $ns {')
376
377 if namespaces:
378 code('// avoid name conflicts')
379 sep_string = '_COLONS_'
380 flat_name = sep_string.join(class_path)
381 code('%rename($flat_name) $classname;')
382
383 if cls == SimObject:
384 code('%include "python/swig/sim_object.i"')
385 else:
386 code()
387 code('// stop swig from creating/wrapping default ctor/dtor')
388 code('%nodefault $classname;')
389 code('class $classname')
390 if cls._base:
391 code(' : public ${{cls._base.cxx_class}}')
392 code('{};')
393
394 for ns in reversed(namespaces):
395 code('} // namespace $ns')
396
397 code()
398 code('%include "params/$cls.hh"')
399
400

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

425 # declaring a pointer.
426 for ns in class_path[:-1]:
427 code('namespace $ns {')
428 code('class $0;', class_path[-1])
429 for ns in reversed(class_path[:-1]):
430 code('} // namespace $ns')
431 code()
432
433 for param in params:
434 param.cxx_predecls(code)
435 code()
436
437 if cls._base:
438 code('#include "params/${{cls._base.type}}.hh"')
439 code()
440
441 for ptype in ptypes:
442 if issubclass(ptype, Enum):
443 code('#include "enums/${{ptype.__name__}}.hh"')
444 code()
445
446 # now generate the actual param struct
447 if cls == SimObject:
448 code('#include "sim/sim_object_params.hh"')
449 else:
450 code("struct ${cls}Params")
451 if cls._base:
452 code(" : public ${{cls._base.type}}Params")
453 code("{")
454 if not hasattr(cls, 'abstract') or not cls.abstract:
455 if 'type' in cls.__dict__:
456 code(" ${{cls.cxx_type}} create();")
457
458 code.indent()
459 for param in params:
460 param.cxx_decl(code)
461 code.dedent()
462 code('};')
463
464 code()
465 code('#endif // __PARAMS__${cls}__')
466 return code
467
468
469
470# The SimObject class is the root of the special hierarchy. Most of
471# the code in this class deals with the configuration hierarchy itself
472# (parent/child node relationships).
473class SimObject(object):
474 # Specify metaclass. Any class inheriting from SimObject will
475 # get this metaclass.
476 __metaclass__ = MetaSimObject
477 type = 'SimObject'
478 abstract = True
479
480 # Initialize new instance. For objects with SimObject-valued
481 # children, we need to recursively clone the classes represented
482 # by those param values as well in a consistent "deep copy"-style
483 # fashion. That is, we want to make sure that each instance is
484 # cloned only once, and that if there are multiple references to
485 # the same original object, we end up with the corresponding
486 # cloned references all pointing to the same cloned instance.
487 def __init__(self, **kwargs):

--- 506 unchanged lines hidden ---