Ejemplo n.º 1
0
    def uint32x16(number1,
                  number2=None,
                  number3=None,
                  number4=None,
                  number5=None,
                  number6=None,
                  number7=None,
                  number8=None,
                  number9=None,
                  number10=None,
                  number11=None,
                  number12=None,
                  number13=None,
                  number14=None,
                  number15=None,
                  number16=None,
                  name=None):
        if name is not None:
            Name.check_name(name)
            name = Name(name=name)
        else:
            import inspect
            name = Name(prename=parse_assigned_variable_name(
                inspect.stack(), "Constant.uint32x16"))

        return Constant._uint32xN(name, 16, number1, number2, number3, number4,
                                  number5, number6, number7, number8, number9,
                                  number10, number11, number12, number13,
                                  number14, number15, number16)
Ejemplo n.º 2
0
    def float32x4(number1, number2=None, number3=None, number4=None, name=None):
        if name is not None:
            Name.check_name(name)
            name = Name(name=name)
        else:
            import inspect
            name = Name(prename=parse_assigned_variable_name(inspect.stack(), "Constant.float32x4"))

        return Constant._float32xN(name, 4, number1, number2, number3, number4)
Ejemplo n.º 3
0
    def float64(number, name=None):
        if name is not None:
            Name.check_name(name)
            name = Name(name=name)
        else:
            import inspect
            name = Name(prename=parse_assigned_variable_name(inspect.stack(), "Constant.float64"))

        return Constant._float64xN(name, 1, number)
Ejemplo n.º 4
0
    def uint32x2(number1, number2=None, name=None):
        if name is not None:
            Name.check_name(name)
            name = Name(name=name)
        else:
            import inspect
            name = Name(prename=parse_assigned_variable_name(inspect.stack(), "Constant.uint32x2"))

        return Constant._uint32xN(name, 2, number1, number2)
Ejemplo n.º 5
0
    def float32x4(number1, number2=None, number3=None, number4=None, name=None):
        if name is not None:
            Name.check_name(name)
            name = Name(name=name)
        else:
            import inspect
            name = Name(prename=parse_assigned_variable_name(inspect.stack(), "Constant.float32x4"))

        return Constant._float32xN(name, 4, number1, number2, number3, number4)
Ejemplo n.º 6
0
    def float64(number, name=None):
        if name is not None:
            Name.check_name(name)
            name = Name(name=name)
        else:
            import inspect
            name = Name(prename=parse_assigned_variable_name(inspect.stack(), "Constant.float64"))

        return Constant._float64xN(name, 1, number)
Ejemplo n.º 7
0
    def uint32x2(number1, number2=None, name=None):
        if name is not None:
            Name.check_name(name)
            name = Name(name=name)
        else:
            import inspect
            name = Name(prename=parse_assigned_variable_name(inspect.stack(), "Constant.uint32x2"))

        return Constant._uint32xN(name, 2, number1, number2)
Ejemplo n.º 8
0
    def uint32x8(number1, number2=None, number3=None, number4=None,
                 number5=None, number6=None, number7=None, number8=None,
                 name=None):
        if name is not None:
            Name.check_name(name)
            name = Name(name=name)
        else:
            import inspect
            name = Name(prename=parse_assigned_variable_name(inspect.stack(), "Constant.uint32x8"))

        return Constant._uint32xN(name, 8,
                                  number1, number2, number3, number4, number5, number6, number7, number8)
Ejemplo n.º 9
0
 def __init__(self, name=None):
     from peachpy.name import Name
     if name is None:
         import inspect
         self.name = (Name(prename=parse_assigned_variable_name(inspect.stack(), "Label")),)
     elif isinstance(name, tuple):
         assert all(isinstance(part, Name) for part in name), \
             "Name must a string or a tuple or Name objects"
         self.name = name
     else:
         Name.check_name(name)
         self.name = (Name(name=name),)
Ejemplo n.º 10
0
    def __init__(self, c_type, name=None):
        """
        :param peachpy.c.types.Type c_type: the type of the argument in C.
            When Go function is generated, the type is automatically converted to similar Go type.
            Note that the ``short``, ``int``, ``long``, and ``long long`` types do not have an equivalents in Go.
            In particular, C's ``int`` type is not an equivalent of Go's ``int`` type. To get Go's ``int`` and ``uint``
            types use ``ptrdiff_t`` and ``size_t`` correspondingly.

        :param str name: the name of the argument. If the name is not provided explicitly, PeachPy tries to parse it
            from the caller code. The name must follow the C rules for identifiers:

            - It can contain only Latin letters, digits, and underscore symbol
            - It can not start with a digit
            - It can not start with double underscore (these names are reserved for PeachPy)
            - Name must be unique among the function arguments
        """

        from peachpy.c.types import Type
        if not isinstance(c_type, Type):
            raise TypeError("%s is not a C type" % str(c_type))
        self.c_type = c_type

        if name is None:
            import inspect
            import re

            _, _, _, _, caller_lines, _ = inspect.stack()[1]
            if caller_lines is None:
                raise ValueError(
                    "Argument name is not specified and the caller context is not available"
                )
            source_line = caller_lines[0].strip()
            match = re.match(
                "(?:\\w+\\.)*(\\w+)\\s*=\\s*(?:\\w+\\.)*Argument\\(.+\\)",
                source_line)
            if match:
                name = match.group(1)
                while name.startswith("_"):
                    name = name[1:]
                if name.endswith("argument") or name.endswith("Argument"):
                    name = name[:-len("argument")]
                if name.endswith("arg") or name.endswith("Arg"):
                    name = name[:-len("arg")]
                while name.endswith("_"):
                    name = name[:-1]
            if not name:
                raise ValueError(
                    "Argument name is not specified and can not be parsed from the code"
                )

        from peachpy.name import Name
        Name.check_name(name)
        self.name = name
Ejemplo n.º 11
0
    def uint16x8(number1, number2=None, number3=None, number4=None,
                 number5=None, number6=None, number7=None, number8=None,
                 name=None):
        if name is not None:
            Name.check_name(name)
            name = Name(name=name)
        else:
            import inspect
            name = Name(prename=parse_assigned_variable_name(inspect.stack(), "Constant.uint16x8"))

        return Constant._uint16xN(name, 8,
                                  number1, number2, number3, number4, number5, number6, number7, number8)
Ejemplo n.º 12
0
 def __init__(self, name=None):
     from peachpy.name import Name
     if name is None:
         import inspect
         self.name = (Name(prename=parse_assigned_variable_name(
             inspect.stack(), "Label")), )
     elif isinstance(name, tuple):
         assert all(isinstance(part, Name) for part in name), \
             "Name must a string or a tuple or Name objects"
         self.name = name
     else:
         Name.check_name(name)
         self.name = (Name(name=name), )
Ejemplo n.º 13
0
    def uint32x16(number1, number2=None, number3=None, number4=None,
                  number5=None, number6=None, number7=None, number8=None,
                  number9=None, number10=None, number11=None, number12=None,
                  number13=None, number14=None, number15=None, number16=None,
                  name=None):
        if name is not None:
            Name.check_name(name)
            name = Name(name=name)
        else:
            import inspect
            name = Name(prename=parse_assigned_variable_name(inspect.stack(), "Constant.uint32x16"))

        return Constant._uint32xN(name, 16,
                                  number1, number2, number3, number4, number5, number6, number7, number8,
                                  number9, number10, number11, number12, number13, number14, number15, number16)
Ejemplo n.º 14
0
    def __init__(self, c_type, name=None):
        """
        :param peachpy.c.types.Type c_type: the type of the argument in C.
            When Go function is generated, the type is automatically converted to similar Go type.
            Note that the ``short``, ``int``, ``long``, and ``long long`` types do not have an equivalents in Go.
            In particular, C's ``int`` type is not an equivalent of Go's ``int`` type. To get Go's ``int`` and ``uint``
            types use ``ptrdiff_t`` and ``size_t`` correspondingly.

        :param str name: the name of the argument. If the name is not provided explicitly, PeachPy tries to parse it
            from the caller code. The name must follow the C rules for identifiers:

            - It can contain only Latin letters, digits, and underscore symbol
            - It can not start with a digit
            - It can not start with double underscore (these names are reserved for PeachPy)
            - Name must be unique among the function arguments
        """

        from peachpy.c.types import Type
        if not isinstance(c_type, Type):
            raise TypeError("%s is not a C type" % str(c_type))
        self.c_type = c_type

        if name is None:
            import inspect
            import re

            _, _, _, _, caller_lines, _ = inspect.stack()[1]
            if caller_lines is None:
                raise ValueError("Argument name is not specified and the caller context is not available")
            source_line = caller_lines[0].strip()
            match = re.match("(?:\\w+\\.)*(\\w+)\\s*=\\s*(?:\\w+\\.)*Argument\\(.+\\)", source_line)
            if match:
                name = match.group(1)
                while name.startswith("_"):
                    name = name[1:]
                if name.endswith("argument") or name.endswith("Argument"):
                    name = name[:-len("argument")]
                if name.endswith("arg") or name.endswith("Arg"):
                    name = name[:-len("arg")]
                while name.endswith("_"):
                    name = name[:-1]
            if not name:
                raise ValueError("Argument name is not specified and can not be parsed from the code")

        from peachpy.name import Name
        Name.check_name(name)
        self.name = name
Ejemplo n.º 15
0
 def __init__(self, name=None):
     from peachpy.name import Name
     if name is None:
         import inspect
         prename = parse_assigned_variable_name(inspect.stack(), "Loop")
         if prename is None:
             prename = parse_with_variable_name(inspect.stack(), "Loop")
         self.name = (Name(prename=prename),)
     elif isinstance(name, tuple):
         assert all(isinstance(part, Name) for part in name), \
             "Name must a string or a tuple or Name objects"
         self.name = name
     else:
         Name.check_name(name)
         self.name = (Name(name=name),)
     self.begin = Label(self.name + (Name(name="begin"),))
     self.end = Label(self.name + (Name(name="end"),))
Ejemplo n.º 16
0
 def __init__(self, name=None):
     from peachpy.name import Name
     if name is None:
         import inspect
         prename = parse_assigned_variable_name(inspect.stack(), "Loop")
         if prename is None:
             prename = parse_with_variable_name(inspect.stack(), "Loop")
         self.name = (Name(prename=prename), )
     elif isinstance(name, tuple):
         assert all(isinstance(part, Name) for part in name), \
             "Name must a string or a tuple or Name objects"
         self.name = name
     else:
         Name.check_name(name)
         self.name = (Name(name=name), )
     self.begin = Label(self.name + (Name(name="begin"), ))
     self.end = Label(self.name + (Name(name="end"), ))