SimObject.py (12742:a48daf1c7e56) SimObject.py (12770:42f6afaab313)
1# Copyright (c) 2017 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

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

402class MetaSimObject(type):
403 # Attributes that can be set only at initialization time
404 init_keywords = {
405 'abstract' : bool,
406 'cxx_class' : str,
407 'cxx_type' : str,
408 'cxx_header' : str,
409 'type' : str,
1# Copyright (c) 2017 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

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

402class MetaSimObject(type):
403 # Attributes that can be set only at initialization time
404 init_keywords = {
405 'abstract' : bool,
406 'cxx_class' : str,
407 'cxx_type' : str,
408 'cxx_header' : str,
409 'type' : str,
410 'cxx_base' : (str, type(None)),
410 'cxx_extra_bases' : list,
411 'cxx_exports' : list,
412 'cxx_param_exports' : list,
413 }
414 # Attributes that can be set any time
415 keywords = { 'check' : FunctionType }
416
417 # __new__ is called before __init__, and is where the statements

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

729 ]
730 for exp in param_exports:
731 exp.export(code, "%sParams" % cls)
732
733 code(';')
734 code()
735 code.dedent()
736
411 'cxx_extra_bases' : list,
412 'cxx_exports' : list,
413 'cxx_param_exports' : list,
414 }
415 # Attributes that can be set any time
416 keywords = { 'check' : FunctionType }
417
418 # __new__ is called before __init__, and is where the statements

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

730 ]
731 for exp in param_exports:
732 exp.export(code, "%sParams" % cls)
733
734 code(';')
735 code()
736 code.dedent()
737
737 bases = [ cls._base.cxx_class ] + cls.cxx_extra_bases if \
738 cls._base else cls.cxx_extra_bases
738 bases = []
739 if 'cxx_base' in cls._value_dict:
740 # If the c++ base class implied by python inheritance was
741 # overridden, use that value.
742 if cls.cxx_base:
743 bases.append(cls.cxx_base)
744 elif cls._base:
745 # If not and if there was a SimObject base, use its c++ class
746 # as this class' base.
747 bases.append(cls._base.cxx_class)
748 # Add in any extra bases that were requested.
749 bases.extend(cls.cxx_extra_bases)
750
739 if bases:
740 base_str = ", ".join(bases)
741 code('py::class_<${{cls.cxx_class}}, ${base_str}, ' \
742 'std::unique_ptr<${{cls.cxx_class}}, py::nodelete>>(' \
743 'm, "${py_class_name}")')
744 else:
745 code('py::class_<${{cls.cxx_class}}, ' \
746 'std::unique_ptr<${{cls.cxx_class}}, py::nodelete>>(' \

--- 836 unchanged lines hidden ---
751 if bases:
752 base_str = ", ".join(bases)
753 code('py::class_<${{cls.cxx_class}}, ${base_str}, ' \
754 'std::unique_ptr<${{cls.cxx_class}}, py::nodelete>>(' \
755 'm, "${py_class_name}")')
756 else:
757 code('py::class_<${{cls.cxx_class}}, ' \
758 'std::unique_ptr<${{cls.cxx_class}}, py::nodelete>>(' \

--- 836 unchanged lines hidden ---