Deleted Added
sdiff udiff text old ( 13764:1647bbdc9444 ) new ( 13778:318f777400e9 )
full compact
1# Copyright (c) 2017-2018 ARM Limited
2# All rights reserved.
3#
4# The license below extends only to copyright in the software and shall
5# not be construed as granting a license to any other intellectual
6# property including but not limited to intellectual property relating
7# to a hardware implementation of the functionality of the software
8# licensed hereunder. You may use the software subject to the license

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

410 'cxx_class' : str,
411 'cxx_type' : str,
412 'cxx_header' : str,
413 'type' : str,
414 'cxx_base' : (str, type(None)),
415 'cxx_extra_bases' : list,
416 'cxx_exports' : list,
417 'cxx_param_exports' : list,
418 }
419 # Attributes that can be set any time
420 keywords = { 'check' : FunctionType }
421
422 # __new__ is called before __init__, and is where the statements
423 # in the body of the class definition get loaded into the class's
424 # __dict__. We intercept this to filter out parameter & port assignments
425 # and only allow "private" attributes to be passed to the base

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

449 if 'cxx_extra_bases' not in value_dict:
450 value_dict['cxx_extra_bases'] = []
451 if 'cxx_exports' not in value_dict:
452 value_dict['cxx_exports'] = cxx_exports
453 else:
454 value_dict['cxx_exports'] += cxx_exports
455 if 'cxx_param_exports' not in value_dict:
456 value_dict['cxx_param_exports'] = []
457 cls_dict['_value_dict'] = value_dict
458 cls = super(MetaSimObject, mcls).__new__(mcls, name, bases, cls_dict)
459 if 'type' in value_dict:
460 allClasses[name] = cls
461 return cls
462
463 # subclass initialization
464 def __init__(cls, name, bases, dict):

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

768 code.dedent()
769 code()
770 code.dedent()
771 code('}')
772 code()
773 code('static EmbeddedPyBind embed_obj("${0}", module_init, "${1}");',
774 cls, cls._base.type if cls._base else "")
775
776
777 # Generate the C++ declaration (.hh file) for this SimObject's
778 # param struct. Called from src/SConscript.
779 def cxx_param_decl(cls, code):
780 # The 'local' attribute restricts us to the params declared in
781 # the object itself, not including inherited params (which
782 # will also be inherited from the base class's param struct
783 # here). Sort the params based on their key
784 params = map(lambda k_v: k_v[1], sorted(cls._params.local.items()))
785 ports = cls._ports.local
786 try:
787 ptypes = [p.ptype for p in params]
788 except:
789 print(cls, p, p.ptype_str)
790 print(params)
791 raise
792
793 class_path = cls._value_dict['cxx_class'].split('::')
794
795 code('''\
796#ifndef __PARAMS__${cls}__
797#define __PARAMS__${cls}__
798
799''')
800
801
802 # The base SimObject has a couple of params that get
803 # automatically set from Python without being declared through
804 # the normal Param mechanism; we slip them in here (needed
805 # predecls now, actual declarations below)
806 if cls == SimObject:
807 code('''#include <string>''')
808
809 # A forward class declaration is sufficient since we are just
810 # declaring a pointer.
811 for ns in class_path[:-1]:
812 code('namespace $ns {')
813 code('class $0;', class_path[-1])
814 for ns in reversed(class_path[:-1]):
815 code('} // namespace $ns')
816 code()
817
818 for param in params:
819 param.cxx_predecls(code)
820 for port in ports.values():
821 port.cxx_predecls(code)
822 code()
823
824 if cls._base:

--- 857 unchanged lines hidden ---