MethodBody

A Swift function callable from Python.

Declaration

typealias MethodBody = (
    Object,
    ArgumentParser
) throws -> (
    any Parsable
)?

Discussion

Expected by Method as the Swift side of a Python function.

Parameters

The first parameter is the receiver of the method, which can be a module, an instance or a class depending on where the method was registered. The second one is an ArgumentParser which can be used to parse the passed arguments or retrieve them directly and get access to the owning module object if it is not the direct receiver.

Throws

Exception errors will be raised as is in the Python stack. Any other kind of error will be wrapped in a :py:class:PytoRuntime.pyto_runtime.SwiftError.

Returns

Any Parsable value.