Only used for writing Python extension modules. Datastructure to hold table of methods of your Python extension module. Put exactly one instance at Fortran module level.
Python 3: initialise and configure in PyInit_module name function with bind(c, name="PyInit_module_name") attribute and type(c_ptr) return value. Python 2: initialise in initmodule name subroutine with bind(c) attribute
Pass the configured PythonMethodTable to PythonModule%init
Initialises the method table. Call in PyInit_module name (Py3) / initmodule name (Py2)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(PythonMethodTable), | intent(inout) | :: | self | |||
integer, | intent(in) | :: | num_methods | The number of methods your Python module shall have. |
Adds a method to your Python module
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(PythonMethodTable), | intent(inout) | :: | self | |||
character(kind=C_CHAR,len=*), | intent(in) | :: | method_name | Name of the Python method. |
||
character(kind=C_CHAR,len=*), | intent(in) | :: | doc_string | Doc string for the Python method |
||
integer(kind=C_INT), | intent(in) | :: | flags | Controls which kind of arguments the Python method shall take. use flags=METH_VARARGS if method shall take only arguments. use flags=METH_KWARGS if method shall take only keyword args. use flags=METH_VARARGS+METH_KWARGS if method shall take both arguments and keyword args. use flags=METH_NOARGS if method shall take no arguments. |
||
type(c_funptr), | intent(in) | :: | method_funptr | Function pointer to the Fortran implementation of the method. Use C_FUNLOC( |
Used only internally. Gets type(c_ptr) to method table.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(PythonMethodTable), | intent(in) | :: | self |