@@ -16,13 +16,26 @@ module fpm_compile_commands
16
16
17
17
contains
18
18
19
- ! > Serialization procedures
19
+ ! > Serialization interface
20
20
procedure :: serializable_is_same = > compile_command_is_same
21
21
procedure :: dump_to_toml = > compile_command_dump_toml
22
22
procedure :: load_from_toml = > compile_command_load_toml
23
23
24
24
end type compile_command_t
25
25
26
+ type, extends(serializable_t) :: compile_command_table_t
27
+
28
+ type (compile_command_t), allocatable :: command(:)
29
+
30
+ contains
31
+
32
+ ! > Serialization interface
33
+ procedure :: serializable_is_same = > cct_is_same
34
+ procedure :: dump_to_toml = > cct_dump_toml
35
+ procedure :: load_from_toml = > cct_load_toml
36
+
37
+
38
+ end type compile_command_table_t
26
39
27
40
contains
28
41
@@ -92,5 +105,78 @@ logical function compile_command_is_same(this,that)
92
105
93
106
end function compile_command_is_same
94
107
108
+ ! > Dump compile_command_table_t to toml table
109
+ subroutine cct_dump_toml (self , table , error )
110
+
111
+ ! > Instance of the serializable object
112
+ class(compile_command_table_t), intent (inout ) :: self
113
+
114
+ ! > Data structure
115
+ type (toml_table), intent (inout ) :: table
116
+
117
+ ! > Error handling
118
+ type (error_t), allocatable , intent (out ) :: error
119
+
120
+ ! call set_string(table, "directory", self%directory, error, 'compile_command_table_t')
121
+ ! if (allocated(error)) return
122
+ ! call set_list(table, "arguments", self%arguments, error)
123
+ ! if (allocated(error)) return
124
+ ! call set_string(table, "file", self%file, error, 'compile_command_table_t')
125
+ ! if (allocated(error)) return
126
+
127
+ end subroutine cct_dump_toml
128
+
129
+ ! > Read compile_command_table_t from toml table (no checks made at this stage)
130
+ subroutine cct_load_toml (self , table , error )
131
+
132
+ ! > Instance of the serializable object
133
+ class(compile_command_table_t), intent (inout ) :: self
134
+
135
+ ! > Data structure
136
+ type (toml_table), intent (inout ) :: table
137
+
138
+ ! > Error handling
139
+ type (error_t), allocatable , intent (out ) :: error
140
+
141
+ ! call get_value(table, "directory", self%directory, error, 'compile_command_table_t')
142
+ ! if (allocated(error)) return
143
+ ! call get_list(table, "arguments", self%arguments, error)
144
+ ! if (allocated(error)) return
145
+ ! call get_value(table, "file", self%file, error, 'compile_command_table_t')
146
+ ! if (allocated(error)) return
147
+
148
+ end subroutine cct_load_toml
149
+
150
+ ! > Check that two compile_command_table_t objects are equal
151
+ logical function cct_is_same (this ,that )
152
+ class(compile_command_table_t), intent (in ) :: this
153
+ class(serializable_t), intent (in ) :: that
154
+
155
+ integer :: i
156
+
157
+ cct_is_same = .false.
158
+
159
+ select type (other= >that)
160
+ type is (compile_command_table_t)
161
+
162
+ if (allocated (this% command).neqv. allocated (other% command)) return
163
+ if (allocated (this% command)) then
164
+ if (.not. (size (this% command) ==size (other% command))) return
165
+ if (.not. (ubound (this% command,1 )==ubound (other% command,1 ))) return
166
+ if (.not. (lbound (this% command,1 )==lbound (other% command,1 ))) return
167
+ do i= lbound (this% command,1 ),ubound (this% command,1 )
168
+ if (.not. this% command(i)==other% command(i)) return
169
+ end do
170
+ end if
171
+
172
+ class default
173
+ ! Not the same type
174
+ return
175
+ end select
176
+
177
+ ! > All checks passed!
178
+ cct_is_same = .true.
179
+
180
+ end function cct_is_same
95
181
96
182
end module fpm_compile_commands
0 commit comments