From 6aba40db1385007e0bf4e9c2b9b4afe8bb105593 Mon Sep 17 00:00:00 2001 From: Laurence Kedward Date: Sun, 28 Nov 2021 11:24:41 +0000 Subject: Apply suggestion: don't use TBP for new constructors --- src/fpm_backend.F90 | 2 +- src/fpm_backend_console.f90 | 19 +++++++++++-------- src/fpm_backend_output.f90 | 20 ++++++++++++-------- 3 files changed, 24 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/fpm_backend.F90 b/src/fpm_backend.F90 index f8d491f..e666d03 100644 --- a/src/fpm_backend.F90 +++ b/src/fpm_backend.F90 @@ -110,7 +110,7 @@ subroutine build_package(targets,model,verbose) plain_output = .true. #endif - call progress%init(queue,plain_output) + progress = build_progress_t(queue,plain_output) ! Loop over parallel schedule regions do i=1,size(schedule_ptr)-1 diff --git a/src/fpm_backend_console.f90 b/src/fpm_backend_console.f90 index 4422037..73bcd5d 100644 --- a/src/fpm_backend_console.f90 +++ b/src/fpm_backend_console.f90 @@ -30,22 +30,25 @@ type console_t !> Escape code for moving down one line character(:), allocatable :: LINE_DOWN contains - !> Initialise the console object - procedure :: init => console_init !> Write a single line to the console procedure :: write_line => console_write_line !> Update a previously-written console line procedure :: update_line => console_update_line end type console_t +!> Constructor for console_t +interface console_t + procedure :: new_console +end interface console_t + contains -!> Initialise the console object -subroutine console_init(console,plain_mode) - !> Console object to initialise - class(console_t), intent(out), target :: console +!> Initialise a new console object +function new_console(plain_mode) result(console) !> 'Plain' output (no escape codes) logical, intent(in), optional :: plain_mode + !> Console object to initialise + type(console_t) :: console if (present(plain_mode)) then console%plain_mode = plain_mode @@ -61,12 +64,12 @@ subroutine console_init(console,plain_mode) console%LINE_DOWN = ESC//"[1B" end if -end subroutine console_init +end function new_console !> Write a single line to the standard output subroutine console_write_line(console,str,line,advance) !> Console object - class(console_t), intent(inout), target :: console + class(console_t), intent(inout) :: console !> String to write character(*), intent(in) :: str !> Integer needed to later update console line diff --git a/src/fpm_backend_output.f90 b/src/fpm_backend_output.f90 index 8c7fd7d..2cc8597 100644 --- a/src/fpm_backend_output.f90 +++ b/src/fpm_backend_output.f90 @@ -35,8 +35,6 @@ type build_progress_t !> Queue of scheduled build targets type(build_target_ptr), pointer :: target_queue(:) contains - !> Initialise build progress object - procedure :: init => output_init !> Output 'compiling' status for build target procedure :: compiling_status => output_status_compiling !> Output 'complete' status for build target @@ -45,16 +43,21 @@ contains procedure :: success => output_progress_success end type build_progress_t +!> Constructor for build_progress_t +interface build_progress_t + procedure :: new_build_progress +end interface build_progress_t + contains - !> Initialise build progress object - subroutine output_init(progress,target_queue,plain_mode) - !> Progress object to initialise - class(build_progress_t), intent(out) :: progress + !> Initialise a new build progress object + function new_build_progress(target_queue,plain_mode) result(progress) !> The queue of scheduled targets type(build_target_ptr), intent(in), target :: target_queue(:) !> Enable 'plain' output for progress object logical, intent(in), optional :: plain_mode + !> Progress object to initialise + type(build_progress_t) :: progress if (plain_mode) then call attr_mode('plain') @@ -62,15 +65,16 @@ contains call attr_mode('color') end if - call progress%console%init(plain_mode) + progress%console = console_t(plain_mode) progress%n_target = size(target_queue,1) progress%target_queue => target_queue progress%plain_mode = plain_mode + progress%n_complete = 0 allocate(progress%output_lines(progress%n_target)) - end subroutine output_init + end function new_build_progress !> Output 'compiling' status for build target and overall percentage progress subroutine output_status_compiling(progress, queue_index) -- cgit v1.2.3