Skip to content

Commit 6aba40d

Browse files
committed
Apply suggestion: don't use TBP for new constructors
1 parent 4556e7a commit 6aba40d

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

src/fpm_backend.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ subroutine build_package(targets,model,verbose)
110110
plain_output = .true.
111111
#endif
112112

113-
call progress%init(queue,plain_output)
113+
progress = build_progress_t(queue,plain_output)
114114

115115
! Loop over parallel schedule regions
116116
do i=1,size(schedule_ptr)-1

src/fpm_backend_console.f90

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,25 @@ module fpm_backend_console
3030
!> Escape code for moving down one line
3131
character(:), allocatable :: LINE_DOWN
3232
contains
33-
!> Initialise the console object
34-
procedure :: init => console_init
3533
!> Write a single line to the console
3634
procedure :: write_line => console_write_line
3735
!> Update a previously-written console line
3836
procedure :: update_line => console_update_line
3937
end type console_t
4038

39+
!> Constructor for console_t
40+
interface console_t
41+
procedure :: new_console
42+
end interface console_t
43+
4144
contains
4245

43-
!> Initialise the console object
44-
subroutine console_init(console,plain_mode)
45-
!> Console object to initialise
46-
class(console_t), intent(out), target :: console
46+
!> Initialise a new console object
47+
function new_console(plain_mode) result(console)
4748
!> 'Plain' output (no escape codes)
4849
logical, intent(in), optional :: plain_mode
50+
!> Console object to initialise
51+
type(console_t) :: console
4952

5053
if (present(plain_mode)) then
5154
console%plain_mode = plain_mode
@@ -61,12 +64,12 @@ subroutine console_init(console,plain_mode)
6164
console%LINE_DOWN = ESC//"[1B"
6265
end if
6366

64-
end subroutine console_init
67+
end function new_console
6568

6669
!> Write a single line to the standard output
6770
subroutine console_write_line(console,str,line,advance)
6871
!> Console object
69-
class(console_t), intent(inout), target :: console
72+
class(console_t), intent(inout) :: console
7073
!> String to write
7174
character(*), intent(in) :: str
7275
!> Integer needed to later update console line

src/fpm_backend_output.f90

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ module fpm_backend_output
3535
!> Queue of scheduled build targets
3636
type(build_target_ptr), pointer :: target_queue(:)
3737
contains
38-
!> Initialise build progress object
39-
procedure :: init => output_init
4038
!> Output 'compiling' status for build target
4139
procedure :: compiling_status => output_status_compiling
4240
!> Output 'complete' status for build target
@@ -45,32 +43,38 @@ module fpm_backend_output
4543
procedure :: success => output_progress_success
4644
end type build_progress_t
4745

46+
!> Constructor for build_progress_t
47+
interface build_progress_t
48+
procedure :: new_build_progress
49+
end interface build_progress_t
50+
4851
contains
4952

50-
!> Initialise build progress object
51-
subroutine output_init(progress,target_queue,plain_mode)
52-
!> Progress object to initialise
53-
class(build_progress_t), intent(out) :: progress
53+
!> Initialise a new build progress object
54+
function new_build_progress(target_queue,plain_mode) result(progress)
5455
!> The queue of scheduled targets
5556
type(build_target_ptr), intent(in), target :: target_queue(:)
5657
!> Enable 'plain' output for progress object
5758
logical, intent(in), optional :: plain_mode
59+
!> Progress object to initialise
60+
type(build_progress_t) :: progress
5861

5962
if (plain_mode) then
6063
call attr_mode('plain')
6164
else
6265
call attr_mode('color')
6366
end if
6467

65-
call progress%console%init(plain_mode)
68+
progress%console = console_t(plain_mode)
6669

6770
progress%n_target = size(target_queue,1)
6871
progress%target_queue => target_queue
6972
progress%plain_mode = plain_mode
73+
progress%n_complete = 0
7074

7175
allocate(progress%output_lines(progress%n_target))
7276

73-
end subroutine output_init
77+
end function new_build_progress
7478

7579
!> Output 'compiling' status for build target and overall percentage progress
7680
subroutine output_status_compiling(progress, queue_index)

0 commit comments

Comments
 (0)