fgen.wrapping_strategies.interface#

Interface definition for wrapping strategies

WrappingStrategyLike#

class WrappingStrategyLike(*args, **kwargs)[source]#

Bases: Protocol

Wrapping strategy interface

generate_python_for_fortran_return_value_processing(value, fortran_module_callable, fortran_module_callable_args, dynamic_unit)[source]#

Generate the Python code that processes the value returned from Fortran

Parameters:
Returns:

str – Python code that calls the callable and processes the results into the expected Python type.

get_fortran_for_getter(value, class_being_wrapped, value_manager_get_free_instance_number=None, value_manager_get_instance=None)[source]#

Get the Fortran for the wrapper module’s getter.

Parameters:
Returns:

str – Fortran for the wrapper module’s getter.

get_fortran_for_method_returning_wrapped_type(fortran_wrapper_module_callable, receiving_from_python_steps, return_value, class_being_wrapped, method_name, return_value_manager_get_free_instance_number, return_value_manager_get_instance)[source]#

Get the Fortran for a method which returns the wrapped type

Parameters:
Returns:

str – Fortran for wrapping the method

get_fortran_wrapper_module_getter(value)[source]#

Get the name of the getter in the Fortran wrapper module

Parameters:

value (typing.Union[fgen.data_models.multi_return.MultiReturn, fgen.data_models.value.Value]) – Value for which to get the getter

Returns:

str – Name of the getter in the Fortran wrapper module

get_fortran_wrapper_module_setter(value)[source]#

Get the name of the setter in the Fortran wrapper module

Parameters:

value (typing.Union[fgen.data_models.multi_return.MultiReturn, fgen.data_models.value.Value]) – Value for which to get the getter

Returns:

str – Name of the getter in the Fortran wrapper module

get_fortran_wrapper_statement_declarations_for_returning_method_result_to_python(method, prefix)[source]#

Get statement declarations for the returning a method’s result to Python

Parameters:
Returns:

list[str] – Statement declarations for the returning a method’s result to Python.

get_fortran_wrapper_statement_declarations_getters_and_setters(value)[source]#

Get statement declarations for the getters/setters in the Fortran wrapper module

Parameters:

value (typing.Union[fgen.data_models.multi_return.MultiReturn, fgen.data_models.value.Value]) – Value for which to get the statement declarations

Returns:

list[str] – Statement declarations for the getters and setters in the Fortran wrapper module.

get_passing_to_fortran_steps(value, dynamic_unit)[source]#

Get the steps required to pass this value to the Fortran

Parameters:
Returns:

fgen.wrapping_strategies.passing_to_fortran_steps.PassingToFortranSteps – Steps required to pass the value into the Fortran

get_python_argument_declaration_type_annotation(value)[source]#

Get the type annotation to use in Python user-facing declarations

Parameters:

value (fgen.data_models.value.Value) – Value for which to get the type annotation

Returns:

str – Type annotation to use in the Python argument declaration

get_python_getter_docstring(value)[source]#

Get docstring for the Python getter for the value

Parameters:

value (fgen.data_models.value.Value) – Value for which to get the Python getter docstring

Returns:

str – Python getter docstring

get_python_post_verify_units_input_type_annotation(value)[source]#

Get input type annotation, assuming the verify_units decorator is applied.

The type annotation is for when value is used as an input to a Python callable.

Parameters:

value (typing.Union[fgen.data_models.multi_return.MultiReturn, fgen.data_models.value.Value]) – Value for which to get the type annotation

Returns:

str – Type annotation for the value, assuming the verify_units decorator is applied.

get_python_return_type_annotation(value)[source]#

Get the return type annotation for the Python attribute

Parameters:

value (typing.Union[fgen.data_models.multi_return.MultiReturn, fgen.data_models.value.Value]) – Value for which to get the return type annotation for the Python attribute

Returns:

str – Return type annotation for the Python attribute

get_python_setter_docstring(value)[source]#

Get docstring for the Python setter for the value

Parameters:

value (fgen.data_models.value.Value) – Value for which to get the Python setter docstring

Returns:

str – Python setter docstring

get_python_user_facing_name(value)[source]#

Get the name that Python users will use for this value

For example, when naming attributes or using this value as an argument in a function/method.

Parameters:

value (typing.Union[fgen.data_models.multi_return.MultiReturn, fgen.data_models.value.Value]) – Name that Python users will use for this value

Returns:

str – Name to use for the Python attribute

get_receiving_from_python_steps(value, dynamic_unit=None, providing_module=None, get_instance_callable_name=None)[source]#

Get the steps required to receive the value from Python

Parameters:
Returns:

fgen.wrapping_strategies.receiving_from_python_steps.ReceivingFromPythonSteps – Steps required to receive the value from Python

get_type_attribute_declaration_for_value_to_pass_to_original_fortran_module(value)[source]#

Get the type attribute declaration for the value used to pass information to the original Fortran module

This is not always the same as the type used by the original Fortran module, particularly when allocatable types are involved.

For the definition of a type attribute declaration, see fgen.fortran_parsing.

Parameters:

value (typing.Union[fgen.data_models.multi_return.MultiReturn, fgen.data_models.value.Value]) – Value for which to get the type attribute declaration for the value to pass to the original Fortran.

Returns:

str – Type attribute declaration for the value to use to pass value to the original Fortran.