|
| 1 | +!> Wrapper for interfacing `m_error_v` with Python |
| 2 | +!> |
| 3 | +!> Written by hand here. |
| 4 | +!> Generation to be automated in future (including docstrings of some sort). |
| 5 | +module m_error_v_w |
| 6 | + |
| 7 | + ! => allows us to rename on import to avoid clashes |
| 8 | + use m_error_v, only: ErrorV |
| 9 | + |
| 10 | + ! The manager module, which makes this all work |
| 11 | + use m_error_v_manager, only: & |
| 12 | + get_free_instance_number, & |
| 13 | + error_v_manager_associate_pointer_with_instance => associate_pointer_with_instance |
| 14 | + ! TODO: build and finalisation |
| 15 | + |
| 16 | + implicit none |
| 17 | + private |
| 18 | + |
| 19 | + public :: get_free_instance_number, iget_code, iget_message |
| 20 | + |
| 21 | +contains |
| 22 | + |
| 23 | + ! Full set of wrapping strategies to pass different types in e.g. |
| 24 | + ! https://gitlab.com/magicc/fgen/-/blob/switch-to-uv/tests/test-data/exposed_attrs/src/exposed_attrs/exposed_attrs_wrapped.f90 |
| 25 | + ! (we will do a full re-write of the code which generates this, |
| 26 | + ! but the strategies will probably stay as they are) |
| 27 | + subroutine iget_code( & |
| 28 | + instance_index, & |
| 29 | + code & |
| 30 | + ) |
| 31 | + |
| 32 | + integer, intent(in) :: instance_index |
| 33 | + |
| 34 | + integer, intent(out) :: code |
| 35 | + |
| 36 | + type(ErrorV), pointer :: instance |
| 37 | + |
| 38 | + call error_v_manager_associate_pointer_with_instance(instance_index, instance) |
| 39 | + |
| 40 | + code = instance % code |
| 41 | + |
| 42 | + end subroutine iget_code |
| 43 | + |
| 44 | + subroutine iget_message( & |
| 45 | + instance_index, & |
| 46 | + message & |
| 47 | + ) |
| 48 | + |
| 49 | + integer, intent(in) :: instance_index |
| 50 | + |
| 51 | + character(len=128), intent(out) :: message |
| 52 | + |
| 53 | + type(ErrorV), pointer :: instance |
| 54 | + |
| 55 | + call error_v_manager_associate_pointer_with_instance(instance_index, instance) |
| 56 | + |
| 57 | + message = instance % message |
| 58 | + |
| 59 | + end subroutine iget_message |
| 60 | + |
| 61 | +end module m_error_v_w |
0 commit comments