Lines Matching refs:cls
457 cls = super(MetaSimObject, mcls).__new__(mcls, name, bases, cls_dict)
459 allClasses[name] = cls
460 return cls
463 def __init__(cls, name, bases, dict):
466 super(MetaSimObject, cls).__init__(name, bases, dict)
471 cls._params = multidict() # param descriptions
472 cls._ports = multidict() # port descriptions
475 cls._values = multidict() # param values
476 cls._hr_values = multidict() # human readable param values
477 cls._children = multidict() # SimObject children
478 cls._port_refs = multidict() # port ref objects
479 cls._instantiated = False # really instantiated, cloned, or subclassed
499 cls._base = base
500 cls._params.parent = base._params
501 cls._ports.parent = base._ports
502 cls._values.parent = base._values
503 cls._hr_values.parent = base._hr_values
504 cls._children.parent = base._children
505 cls._port_refs.parent = base._port_refs
509 cls._base = None
512 if 'type' in cls._value_dict:
513 if 'cxx_class' not in cls._value_dict:
514 cls._value_dict['cxx_class'] = cls._value_dict['type']
516 cls._value_dict['cxx_type'] = '%s *' % cls._value_dict['cxx_class']
518 if 'cxx_header' not in cls._value_dict:
530 for key,val in cls._value_dict.items():
533 cls._new_param(key, val)
537 cls._new_port(key, val)
540 elif key in cls.init_keywords:
541 cls._set_keyword(key, val, cls.init_keywords[key])
545 setattr(cls, key, val)
547 def _set_keyword(cls, keyword, val, kwtype):
553 type.__setattr__(cls, keyword, val)
555 def _new_param(cls, name, pdesc):
559 cls._params[name] = pdesc
561 cls._set_param(name, pdesc.default, pdesc)
563 def _set_param(cls, name, value, param):
570 (e, cls.__name__, name, value)
573 cls._values[name] = value
577 cls._add_cls_child(name, value)
582 cls._hr_values[name] = hr_value
584 def _add_cls_child(cls, name, child):
590 child.set_parent(cls, name)
592 cls._children[name] = child
594 def _new_port(cls, name, port):
598 cls._ports[name] = port
601 def _cls_get_port_ref(cls, attr):
605 ref = cls._port_refs.get(attr)
607 ref = cls._ports[attr].makeRef(cls)
608 cls._port_refs[attr] = ref
612 # instance of class cls).
613 def __setattr__(cls, attr, value):
616 type.__setattr__(cls, attr, value)
619 if attr in cls.keywords:
620 cls._set_keyword(attr, value, cls.keywords[attr])
623 if attr in cls._ports:
624 cls._cls_get_port_ref(attr).connect(value)
627 if isSimObjectOrSequence(value) and cls._instantiated:
631 % (attr, cls.__name__))
634 param = cls._params.get(attr)
636 cls._set_param(attr, value, param)
641 cls._add_cls_child(attr, coerceSimObjectOrVector(value))
646 "Class %s has no parameter \'%s\'" % (cls.__name__, attr))
648 def __getattr__(cls, attr):
650 return cls.cxx_class.split('::')
653 return cls.cxx_class_path[-1]
656 return cls.cxx_class_path[:-1]
659 return '_COLONS_'.join(cls.cxx_class_path)
661 if attr in cls._values:
662 return cls._values[attr]
664 if attr in cls._children:
665 return cls._children[attr]
668 return getattr(cls.getCCClass(), attr)
671 "object '%s' has no attribute '%s'" % (cls.__name__, attr))
673 def __str__(cls):
674 return cls.__name__
676 def getCCClass(cls):
677 return getattr(m5.internal.params, cls.pybind_class)
680 def cxx_predecls(cls, code):
681 code('#include "params/$cls.hh"')
683 def pybind_predecls(cls, code):
684 code('#include "${{cls.cxx_header}}"')
686 def pybind_decl(cls, code):
687 py_class_name = cls.pybind_class
693 params = map(lambda k_v: k_v[1], sorted(cls._params.local.items()))
694 ports = cls._ports.local
699 #include "params/$cls.hh"
704 #include "${{cls.cxx_header}}"
716 py::module m = m_internal.def_submodule("param_${cls}");
719 if cls._base:
720 code('py::class_<${cls}Params, ${{cls._base.type}}Params, ' \
721 'std::unique_ptr<${{cls}}Params, py::nodelete>>(' \
722 'm, "${cls}Params")')
724 code('py::class_<${cls}Params, ' \
725 'std::unique_ptr<${cls}Params, py::nodelete>>(' \
726 'm, "${cls}Params")')
729 if not hasattr(cls, 'abstract') or not cls.abstract:
731 code('.def("create", &${cls}Params::create)')
733 param_exports = cls.cxx_param_exports + [
735 for k, v in sorted(cls._params.local.items())
741 exp.export(code, "%sParams" % cls)
748 if 'cxx_base' in cls._value_dict:
751 if cls.cxx_base:
752 bases.append(cls.cxx_base)
753 elif cls._base:
756 bases.append(cls._base.cxx_class)
758 bases.extend(cls.cxx_extra_bases)
762 code('py::class_<${{cls.cxx_class}}, ${base_str}, ' \
763 'std::unique_ptr<${{cls.cxx_class}}, py::nodelete>>(' \
766 code('py::class_<${{cls.cxx_class}}, ' \
767 'std::unique_ptr<${{cls.cxx_class}}, py::nodelete>>(' \
770 for exp in cls.cxx_exports:
771 exp.export(code, cls.cxx_class)
779 cls, cls._base.type if cls._base else "")
785 def cxx_param_decl(cls, code):
790 params = map(lambda k_v: k_v[1], sorted(cls._params.local.items()))
791 ports = cls._ports.local
795 print(cls, p, p.ptype_str)
873 #ifndef __PARAMS__${cls}__
874 #define __PARAMS__${cls}__
883 if cls == SimObject:
886 cxx_class = CxxClass(cls._value_dict['cxx_class'],
887 cls._value_dict['cxx_template_params'])
899 if cls._base:
900 code('#include "params/${{cls._base.type}}.hh"')
909 code("struct ${cls}Params")
910 if cls._base:
911 code(" : public ${{cls._base.type}}Params")
913 if not hasattr(cls, 'abstract') or not cls.abstract:
914 if 'type' in cls.__dict__:
915 code(" ${{cls.cxx_type}} create();")
918 if cls == SimObject:
935 code('#endif // __PARAMS__${cls}__')
940 def cxx_config_param_file(cls, code, is_header):
941 createCxxConfigDirectoryEntryFile(code, cls.__name__, cls, is_header)
1284 # instance of class cls).