Ejemplo n.º 1
0
        def invoke_python(*inner_arguments):
            from qy import constant_pointer_to

            call_object = \
                Function.named(
                    "PyObject_CallObject",
                    object_ptr_type,
                    [object_ptr_type, object_ptr_type],
                    )

            argument_tuple = qy.py_tuple(*inner_arguments[1:])
            call_result    = call_object(inner_arguments[0], argument_tuple)

            qy.py_dec_ref(argument_tuple)
            qy.py_check_null(call_result)
            qy.py_dec_ref(call_result)
            qy.return_()
Ejemplo n.º 2
0
        def py_printf(*inner_arguments):
            """
            Emit the body of the generated print function.
            """

            # build the output string
            format_object    = py_from_string(self.string_literal(format_))
            arguments_object = qy.py_tuple(*inner_arguments)
            output_object    = py_format(format_object, arguments_object)

            self.py_dec_ref(format_object)
            self.py_dec_ref(arguments_object)
            self.py_check_null(output_object)

            # write it to the standard output stream
            self.py_print(output_object)
            self.py_dec_ref(output_object)
            self.return_()