Пример #1
0
    def descr_def_extern(self, w_name, w_error, w_onerror):
        """\
A decorator.  Attaches the decorated Python function to the C code
generated for the 'extern "Python" function of the same name.
Calling the C function will then invoke the Python function.

Optional arguments: 'name' is the name of the C function, if
different from the Python function; and 'error' and 'onerror'
handle what occurs if the Python function raises an exception
(see the docs for details)."""
        #
        # returns a single-argument function
        space = self.space
        w_ffi = self
        w_decorator = call_python.get_generic_decorator(space)
        return space.appexec([w_decorator, w_ffi, w_name, w_error, w_onerror],
        """(decorator, ffi, name, error, onerror):
            return lambda python_callable: decorator(ffi, python_callable,
                                                     name, error, onerror)""")
Пример #2
0
    def descr_def_extern(self, w_name, w_error, w_onerror):
        """\
A decorator.  Attaches the decorated Python function to the C code
generated for the 'extern "Python" function of the same name.
Calling the C function will then invoke the Python function.

Optional arguments: 'name' is the name of the C function, if
different from the Python function; and 'error' and 'onerror'
handle what occurs if the Python function raises an exception
(see the docs for details)."""
        #
        # returns a single-argument function
        space = self.space
        w_ffi = space.wrap(self)
        w_decorator = call_python.get_generic_decorator(space)
        return space.appexec([w_decorator, w_ffi, w_name, w_error, w_onerror],
        """(decorator, ffi, name, error, onerror):
            return lambda python_callable: decorator(ffi, python_callable,
                                                     name, error, onerror)""")