Skip to content

Commit 300694f

Browse files
committed
class(results) fun
1 parent 9402f91 commit 300694f

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

src/example_fgen_basic/result/result.f90

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
!> https://github.com/samharrison7/fortran-error-handler
55
module m_result
66

7+
use m_error_v, only: ErrorV
8+
79
implicit none
810
private
911

@@ -75,19 +77,21 @@ function finalise(self) result(res)
7577
class(Result), intent(inout) :: self
7678
! Hopefully can leave without docstring (like Python)
7779

78-
type(ResultNone) :: res
80+
! type(ResultNone) :: res
81+
82+
res = Result()
7983

80-
if (allocated(self % data_v) .and. allocated(self % error)) then
84+
if (allocated(self % data_v) .and. allocated(self % error_v)) then
8185
deallocate(self % data_v)
82-
deallocate(self % error)
86+
deallocate(self % error_v)
8387
call res % build(message="Both data and error were allocated")
8488

8589
elseif (allocated(self % data_v)) then
8690
deallocate(self % data_v)
8791
! No error - no need to call res % build
8892

89-
elseif (allocated(self % error)) then
90-
deallocate(self % error)
93+
elseif (allocated(self % error_v)) then
94+
deallocate(self % error_v)
9195
! No error - no need to call res % build
9296

9397
else

src/example_fgen_basic/result/result_int.f90

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
module m_result_int
66

77
use m_error_v, only: ErrorV
8+
use m_result, only: Result
89

910
implicit none
1011
private
@@ -42,12 +43,14 @@ subroutine build(self, res, data_v, error_v)
4243
type(ResultInteger), intent(inout) :: self
4344
! Hopefully can leave without docstring (like Python)
4445

45-
type(ResultNone), intent(inout) :: res
46+
!type(ResultNone), intent(inout) :: res
4647
!! Result
4748

4849
integer, optional, intent(in) :: data_v
4950
!! Data
5051

52+
res = Result()
53+
5154
class(ErrorV), optional, intent(in) :: error_v
5255
!! Error message
5356

0 commit comments

Comments
 (0)