Deleted Added
sdiff udiff text old ( 13892:0182a0601f66 ) new ( 14061:bd3e8e7a983d )
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
9# terms below provided that you ensure that this notice is replicated

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

650 return cls.cxx_class.split('::')
651
652 if attr == 'cxx_class_name':
653 return cls.cxx_class_path[-1]
654
655 if attr == 'cxx_namespaces':
656 return cls.cxx_class_path[:-1]
657
658 if attr in cls._values:
659 return cls._values[attr]
660
661 if attr in cls._children:
662 return cls._children[attr]
663
664 raise AttributeError(
665 "object '%s' has no attribute '%s'" % (cls.__name__, attr))
666
667 def __str__(cls):
668 return cls.__name__
669
670 # See ParamValue.cxx_predecls for description.
671 def cxx_predecls(cls, code):
672 code('#include "params/$cls.hh"')
673
674 def pybind_predecls(cls, code):
675 code('#include "${{cls.cxx_header}}"')
676
677 def pybind_decl(cls, code):
678 class_path = cls.cxx_class.split('::')
679 namespaces, classname = class_path[:-1], class_path[-1]
680 py_class_name = '_COLONS_'.join(class_path) if namespaces else \
681 classname;
682
683 # The 'local' attribute restricts us to the params declared in
684 # the object itself, not including inherited params (which
685 # will also be inherited from the base class's param struct
686 # here). Sort the params based on their key
687 params = map(lambda k_v: k_v[1], sorted(cls._params.local.items()))
688 ports = cls._ports.local
689

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

947def cxxMethod(*args, **kwargs):
948 """Decorator to export C++ functions to Python"""
949
950 def decorate(func):
951 name = func.__name__
952 override = kwargs.get("override", False)
953 cxx_name = kwargs.get("cxx_name", name)
954 return_value_policy = kwargs.get("return_value_policy", None)
955
956 args, varargs, keywords, defaults = inspect.getargspec(func)
957 if varargs or keywords:
958 raise ValueError("Wrapped methods must not contain variable " \
959 "arguments")
960
961 # Create tuples of (argument, default)
962 if defaults:
963 args = args[:-len(defaults)] + \
964 list(zip(args[-len(defaults):], defaults))
965 # Don't include self in the argument list to PyBind
966 args = args[1:]
967
968
969 @wraps(func)
970 def cxx_call(self, *args, **kwargs):
971 ccobj = self.getCCObject()
972 return getattr(ccobj, name)(*args, **kwargs)
973
974 @wraps(func)
975 def py_call(self, *args, **kwargs):
976 return func(self, *args, **kwargs)
977
978 f = py_call if override else cxx_call
979 f.__pybind = PyBindMethod(name, cxx_name=cxx_name, args=args,
980 return_value_policy=return_value_policy)
981
982 return f
983
984 if len(args) == 0:
985 return decorate
986 elif len(args) == 1 and len(kwargs) == 0:
987 return decorate(*args)
988 else:

--- 766 unchanged lines hidden ---