Commit f969abb8 authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Fix handling of unsigned char array arguments.

parent a7a014c1
......@@ -171,11 +171,11 @@ $argumentTemplates = [
:regex => '^\s*unsigned\s+char\s+(?<name>\w+)\s*\[\s*(?<size>[^\]]+)\s*\]\s*$',
:placeholders => %w[name size],
:dummyName => '<name>_dummy',
:acceptAs => 'character(kind = c_char), intent(inout) :: <name>_dummy(<size>)',
:acceptAs => 'integer(kind = c_signed_char), intent(inout) :: <name>_dummy(<size>)',
:helperVars => "",
:precallStatements => "",
:callExpression => '<name>_dummy',
:passAs => 'character(kind = c_char), intent(inout) :: <name>_dummy(*)',
:passAs => 'integer(kind = c_signed_char), intent(inout) :: <name>_dummy(<size>)',
:postcallStatements => ""
}, { #const <integerTypes>* <name>_vec
:regex => '^\s*const\s+(?<type><integerTypes>)\s*\*\s*(?<name>\w+_vec)\s*$',
......@@ -201,11 +201,11 @@ $argumentTemplates = [
:regex => '^\s*(const\s+unsigned\s+char|unsigned\s+char\s+const)\s+(?<name>\w+)\s*\[\s*(?<size>[^\]]+)\s*\]\s*$',
:placeholders => %w[name size],
:dummyName => '<name>_dummy',
:acceptAs => 'character(kind = c_char), intent(in) :: <name>_dummy(<size>)',
:acceptAs => 'integer(kind = c_signed_char), intent(in) :: <name>_dummy(<size>)',
:helperVars => "",
:precallStatements => "",
:callExpression => '<name>_dummy',
:passAs => 'character(kind = c_char), intent(in) :: <name>_dummy(*)',
:passAs => 'integer(kind = c_signed_char), intent(in) :: <name>_dummy(<size>)',
:postcallStatements => ""
}, { #const <integerTypes> <name>[<lineCount>][<lineSize>]
:regex => '^\s*const\s+(?<type><integerTypes>)\s+(?<name>\w+)\s*\[\s*(?<lineCount>[^\]]+)\s*\]\s*\[\s*(?<lineSize>[^\]]+)\s*\]\s*$',
......@@ -627,12 +627,32 @@ def collectImportConstants(importConstantsArray, typeString)
end
end
def collectArrayBoundImports(importConstantsArray, argPassString)
if array_bounds_match =
/(?<=\()\s*(?:[a-zA-Z_]\w*|:|\d+)\s*(?:,\s*(?:[a-zA-Z_]\w*|:|\d+)\s*?)*(?=\s*\)$)/.match(argPassString)
$stderr.puts('Found array bounds: \'' +
array_bounds_match.to_a.join('\', \'') + "'",
'for \'' + argPassString + "'") if $debug > 3
array_bounds_match = array_bounds_match[0]
array_bounds_match.lstrip!
array_bounds_match = array_bounds_match.split(/\s*,\s*/)
array_bounds_match.select! do |bound|
bound != ':' && bound !~ /^\d+$/
end
$stderr.puts('Possible import symbols in array bounds: \'' +
array_bounds_match.join('\', \'') + "'") if $debug > 3
importConstantsArray.push(*array_bounds_match)
end
end
#Collect the c_* and t_* constants/types from the arguments and the return type and build the corresponding `import` statement from them.
def importStatement(returnType, argumentArray)
importConstants = []
collectImportConstants(importConstants, returnType)
argumentArray.each { |arg|
collectImportConstants(importConstants, arg.expandTemplate(:passAs))
argStr = arg.expandTemplate(:passAs)
collectArrayBoundImports(importConstants, argStr)
collectImportConstants(importConstants, argStr)
}
$stderr.puts('Returning \'' + importConstants.sort.uniq.join(', ') +
"' for import\n") if $debug > 2
......
......@@ -1938,6 +1938,20 @@ module mo_cdi
integer(c_int) :: result
end function gridInqPosition
subroutine gridDefUUID(gridID_dummy, uuid_dummy) bind(c, name =&
& 'gridDefUUID')
import CDI_UUID_SIZE, c_int, c_signed_char
integer(c_int), value :: gridID_dummy
integer(kind = c_signed_char), intent(in) :: uuid_dummy(CDI_UUID_SIZE)
end subroutine gridDefUUID
subroutine gridInqUUID(gridID_dummy, uuid_dummy) bind(c, name =&
& 'gridInqUUID')
import CDI_UUID_SIZE, c_int, c_signed_char
integer(c_int), value :: gridID_dummy
integer(kind = c_signed_char), intent(inout) :: uuid_dummy(CDI_UUID_SIZE)
end subroutine gridInqUUID
subroutine gridDefLCC(gridID_dummy, originLon_dummy, originLat_dummy,&
& lonParY_dummy, lat1_dummy, lat2_dummy, xinc_dummy, yinc_dummy,&
& projflag_dummy, scanflag_dummy) bind(c, name = 'gridDefLCC')
......@@ -2181,6 +2195,20 @@ module mo_cdi
integer(c_int) :: result
end function zaxisInqNumber
subroutine zaxisDefUUID(zaxisID_dummy, uuid_dummy) bind(c, name =&
& 'zaxisDefUUID')
import CDI_UUID_SIZE, c_int, c_signed_char
integer(c_int), value :: zaxisID_dummy
integer(kind = c_signed_char), intent(in) :: uuid_dummy(CDI_UUID_SIZE)
end subroutine zaxisDefUUID
subroutine zaxisInqUUID(zaxisID_dummy, uuid_dummy) bind(c, name =&
& 'zaxisInqUUID')
import CDI_UUID_SIZE, c_int, c_signed_char
integer(c_int), value :: zaxisID_dummy
integer(kind = c_signed_char), intent(inout) :: uuid_dummy(CDI_UUID_SIZE)
end subroutine zaxisInqUUID
subroutine zaxisDefPrec(zaxisID_dummy, prec_dummy) bind(c, name =&
& 'zaxisDefPrec')
import c_int
......@@ -5436,34 +5464,6 @@ contains
end do
end function gridInqReference
subroutine gridDefUUID(gridID_dummy, uuid_dummy)
integer(c_int), value :: gridID_dummy
character(kind = c_char), intent(in) :: uuid_dummy(CDI_UUID_SIZE)
interface
subroutine lib_gridDefUUID(gridID_dummy, uuid_dummy) bind(c, name =&
& 'gridDefUUID')
import c_char, c_int
integer(c_int), value :: gridID_dummy
character(kind = c_char), intent(in) :: uuid_dummy(*)
end subroutine lib_gridDefUUID
end interface
call lib_gridDefUUID(gridID_dummy, uuid_dummy)
end subroutine gridDefUUID
subroutine gridInqUUID(gridID_dummy, uuid_dummy)
integer(c_int), value :: gridID_dummy
character(kind = c_char), intent(inout) :: uuid_dummy(CDI_UUID_SIZE)
interface
subroutine lib_gridInqUUID(gridID_dummy, uuid_dummy) bind(c, name =&
& 'gridInqUUID')
import c_char, c_int
integer(c_int), value :: gridID_dummy
character(kind = c_char), intent(inout) :: uuid_dummy(*)
end subroutine lib_gridInqUUID
end interface
call lib_gridInqUUID(gridID_dummy, uuid_dummy)
end subroutine gridInqUUID
subroutine gridInqLCC(gridID_dummy, originLon, originLat, lonParY, lat1,&
& lat2, xinc, yinc, projflag, scanflag)
integer(c_int), value :: gridID_dummy
......@@ -5660,34 +5660,6 @@ contains
end do
end subroutine zaxisName
subroutine zaxisDefUUID(zaxisID_dummy, uuid_dummy)
integer(c_int), value :: zaxisID_dummy
character(kind = c_char), intent(in) :: uuid_dummy(CDI_UUID_SIZE)
interface
subroutine lib_zaxisDefUUID(zaxisID_dummy, uuid_dummy) bind(c, name =&
& 'zaxisDefUUID')
import c_char, c_int
integer(c_int), value :: zaxisID_dummy
character(kind = c_char), intent(in) :: uuid_dummy(*)
end subroutine lib_zaxisDefUUID
end interface
call lib_zaxisDefUUID(zaxisID_dummy, uuid_dummy)
end subroutine zaxisDefUUID
subroutine zaxisInqUUID(zaxisID_dummy, uuid_dummy)
integer(c_int), value :: zaxisID_dummy
character(kind = c_char), intent(inout) :: uuid_dummy(CDI_UUID_SIZE)
interface
subroutine lib_zaxisInqUUID(zaxisID_dummy, uuid_dummy) bind(c, name =&
& 'zaxisInqUUID')
import c_char, c_int
integer(c_int), value :: zaxisID_dummy
character(kind = c_char), intent(inout) :: uuid_dummy(*)
end subroutine lib_zaxisInqUUID
end interface
call lib_zaxisInqUUID(zaxisID_dummy, uuid_dummy)
end subroutine zaxisInqUUID
subroutine zaxisDefName(zaxisID_dummy, name_dummy)
integer(c_int), value :: zaxisID_dummy
character(kind = c_char, len = *), intent(in) :: name_dummy
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment