compile_command_table_t Derived Type

type, public, extends(serializable_t) :: compile_command_table_t


Components

Type Visibility Attributes Name Initial
type(compile_command_t), public, allocatable :: command(:)

Type-Bound Procedures

procedure, public :: destroy => cct_destroy

Operation

  • public elemental subroutine cct_destroy(self)

    Cleanup a compile command table

    Arguments

    Type IntentOptional Attributes Name
    class(compile_command_table_t), intent(inout) :: self

    Instance of the serializable object

generic, public :: dump => dump_to_toml, dump_to_file, dump_to_unit

  • private subroutine srcfile_dump_to_toml(self, table, error)

    Dump dependency to toml table

    Arguments

    Type IntentOptional Attributes Name
    class(srcfile_t), intent(inout) :: self

    Instance of the serializable object

    type(toml_table), intent(inout) :: table

    Data structure

    type(error_t), intent(out), allocatable :: error

    Error handling

  • private subroutine dump_to_file(self, file, error, json)

    Write serializable object to file

    Arguments

    Type IntentOptional Attributes Name
    class(serializable_t), intent(inout) :: self

    Instance of the dependency tree

    character(len=*), intent(in) :: file

    File name

    type(error_t), intent(out), allocatable :: error

    Error handling

    logical, intent(in), optional :: json

    Optional JSON format

  • private subroutine dump_to_unit(self, unit, error, json)

    Write serializable object to a formatted Fortran unit

    Arguments

    Type IntentOptional Attributes Name
    class(serializable_t), intent(inout) :: self

    Instance of the dependency tree

    integer, intent(in) :: unit

    Formatted unit

    type(error_t), intent(out), allocatable :: error

    Error handling

    logical, intent(in), optional :: json

    Optional JSON format requested?

procedure, public :: dump_to_toml => cct_dump_toml

  • public subroutine cct_dump_toml(self, table, error)

    Dump compile_command_table_t to toml table

    Arguments

    Type IntentOptional Attributes Name
    class(compile_command_table_t), intent(inout) :: self

    Instance of the serializable object

    type(toml_table), intent(inout) :: table

    Data structure

    type(error_t), intent(out), allocatable :: error

    Error handling

generic, public :: load => load_from_toml, load_from_file, load_from_unit

  • private subroutine srcfile_load_from_toml(self, table, error)

    Read dependency from toml table (no checks made at this stage)

    Arguments

    Type IntentOptional Attributes Name
    class(srcfile_t), intent(inout) :: self

    Instance of the serializable object

    type(toml_table), intent(inout) :: table

    Data structure

    type(error_t), intent(out), allocatable :: error

    Error handling

  • private subroutine load_from_file(self, file, error, json)

    Read dependency tree from file

    Arguments

    Type IntentOptional Attributes Name
    class(serializable_t), intent(inout) :: self

    Instance of the dependency tree

    character(len=*), intent(in) :: file

    File name

    type(error_t), intent(out), allocatable :: error

    Error handling

    logical, intent(in), optional :: json

    Optional JSON format

  • private subroutine load_from_unit(self, unit, error, json)

    Read dependency tree from file init JSON interpreter Read object from TOML table

    use default TOML parser

    Read object from TOML table

    Arguments

    Type IntentOptional Attributes Name
    class(serializable_t), intent(inout) :: self

    Instance of the dependency tree

    integer, intent(in) :: unit

    File name

    type(error_t), intent(out), allocatable :: error

    Error handling

    logical, intent(in), optional :: json

    Optional JSON format

procedure, public :: load_from_toml => cct_load_toml

  • public subroutine cct_load_toml(self, table, error)

    Read compile_command_table_t from toml table (no checks made at this stage)

    Arguments

    Type IntentOptional Attributes Name
    class(compile_command_table_t), intent(inout) :: self

    Instance of the serializable object

    type(toml_table), intent(inout) :: table

    Data structure

    type(error_t), intent(out), allocatable :: error

    Error handling

generic, public :: operator(==) => serializable_is_same

  • private function srcfile_is_same(this, that)

    Check that two source files are equal All checks passed!

    Arguments

    Type IntentOptional Attributes Name
    class(srcfile_t), intent(in) :: this
    class(serializable_t), intent(in) :: that

    Return Value logical

generic, public :: register => cct_register, cct_register_object

  • public subroutine cct_register(self, command, target_os, error)

    Register a new compile command

    Arguments

    Type IntentOptional Attributes Name
    class(compile_command_table_t), intent(inout) :: self

    Instance of the serializable object

    character(len=*), intent(in) :: command

    Data structure

    integer, intent(in) :: target_os

    The target OS of the compile_commands.json (may be cross-compiling)

    type(error_t), intent(out), allocatable :: error

    Error handling

  • public pure subroutine cct_register_object(self, command, error)

    Arguments

    Type IntentOptional Attributes Name
    class(compile_command_table_t), intent(inout) :: self

    Instance of the serializable object

    type(compile_command_t), intent(in) :: command

    Data structure

    type(error_t), intent(out), allocatable :: error

    Error handling

procedure, public :: serializable_is_same => cct_is_same

Serialization interface

  • public function cct_is_same(this, that)

    Check that two compile_command_table_t objects are equal All checks passed!

    Arguments

    Type IntentOptional Attributes Name
    class(compile_command_table_t), intent(in) :: this
    class(serializable_t), intent(in) :: that

    Return Value logical

procedure, public, non_overridable :: test_serialization

Test load/write roundtrip

  • private subroutine test_serialization(self, message, error)

    Test serialization of a serializable object Dump to scratch file Load from scratch file Check same

    Arguments

    Type IntentOptional Attributes Name
    class(serializable_t), intent(inout) :: self
    character(len=*), intent(in) :: message
    type(error_t), intent(out), allocatable :: error

procedure, public :: write => cct_write

  • public subroutine cct_write(self, filename, error)

    Write compile_commands.json file. Because Jonquil does not support non-named arrays, create a custom json here.

    Arguments

    Type IntentOptional Attributes Name
    class(compile_command_table_t), intent(inout) :: self

    Instance of the serializable object

    character(len=*), intent(in) :: filename

    The file name

    type(error_t), intent(out), allocatable :: error

    Error handling

Source Code

    type, extends(serializable_t) :: compile_command_table_t
        
        type(compile_command_t), allocatable :: command(:)
        
        contains
        
        !> Operation
        procedure :: destroy              => cct_destroy        
        procedure :: write                => cct_write
        
        procedure, private :: cct_register
        procedure, private :: cct_register_object
        generic   :: register             => cct_register, &
                                             cct_register_object
        
        !> Serialization interface
        procedure :: serializable_is_same => cct_is_same
        procedure :: dump_to_toml         => cct_dump_toml
        procedure :: load_from_toml       => cct_load_toml
        
        
    end type compile_command_table_t