subroutineread_externalrecursiveprivate
recursive subroutine read_external(p, json, node, base, parent, id)
Add the entity described by node of an external modules.json, with those inside it.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| p | type(project_t) | inout | the project | |
| json | type(json_core) | inout | the JSON handler | |
| node | type(json_value) | in | pointer | the entity |
| base | character(len=*) | in | the external project's address, ending in | |
| parent | integer | in | the entity it goes in, or 0 | |
| id | integer | out | the new entity, or 0 |
Calls
Source
Show the code
recursive subroutine read_external(p, json, node, base, parent, id)
type(project_t), intent(inout) :: p !! the project
type(json_core), intent(inout) :: json !! the JSON handler
type(json_value), pointer, intent(in) :: node !! the entity
character(len=*), intent(in) :: base !! the external project's address, ending in `/`
integer, intent(in) :: parent !! the entity it goes in, or 0
integer, intent(out) :: id !! the new entity, or 0
character(len=*), parameter :: LISTS(*) = [character(len=13) :: 'pub_procs', 'pub_absints', 'pub_types', 'pub_vars', &
'boundprocs', 'variables']
character(len=:), allocatable :: name, url, obj, proctype, text
type(json_value), pointer :: list, item
logical :: found
integer :: k, n, j, child, kind
id = 0
call json%get(node, 'name', name, found)
if (.not. found) return
call json%get(node, 'obj', obj, found)
call json%get(node, 'proctype', proctype, found)
if (.not. found) proctype = ''
select case (obj)
case ('module'); kind = E_MODULE
case ('type'); kind = E_TYPE
case ('variable'); kind = E_VARIABLE
case ('boundprocedure'); kind = E_BOUNDPROC
case ('interface'); kind = E_INTERFACE
case default; kind = merge(E_FUNCTION, E_SUBROUTINE, proctype == 'Function')
end select
id = p%list%add(kind, parent)
call json%get(node, 'external_url', url, found)
associate (e => p%list%box(id)%e)
e%name = name
if (found) then
if (starts_with(url, './')) url = url(3:)
e%external_url = base//url
end if
call json%get(node, 'permission', text, found)
e%permission = 'public'
if (found) e%permission = text
call json%get(node, 'vartype', text, found)
e%vartype = ''
if (found) e%vartype = text
allocate (e%more%uses(0), e%more%public_list(0), e%attribs(0), e%doc(0), e%meta(0))
e%var_role = VAR_PLAIN
end associate
do k = 1, size(LISTS)
call json%get_child(node, trim(LISTS(k)), list, found)
if (.not. found) cycle
call json%info(list, n_children=n)
do j = 1, n
call json%get_child(list, j, item, found)
call read_external(p, json, item, base, id, child)
end do
end do
end subroutine read_external