Commit 6c5ac2cb authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Replace unnecessary string interpolation with concatenation.

parent ddf02b60
......@@ -461,7 +461,7 @@ $returnTypeTemplates = [
:helperVars => '',
:precallStatements => '',
:receiveAs => 'type(c_ptr)',
:assignVariable => "#{$wrapperResultVarName}%ptr",
:assignVariable => $wrapperResultVarName + '%ptr',
:postcallStatements => ''
}
]
......@@ -615,7 +615,7 @@ end
def defineConstant(name, value)
if /^(\+|-|)\d+$/.match(value)
formatLines($declarationLines, 1, "integer(c_int), public, parameter :: #{name} = #{value}")
formatLines($declarationLines, 1, "integer(c_int), public, parameter :: #{name} = " + value)
else
$stderr.puts("Error: value '#{value}' of constant '#{name}' is not an integer literal")
end
......@@ -646,12 +646,12 @@ def definePublicType(name, body)
body.gsub(/[^;]+;/) do |variableDeclaration|
if template = findTemplate(variableDeclaration, $typeTemplates)
variable = TemplateInstanciation.new(variableDeclaration, template)
formatLines($declarationLines, 2, "#{variable.expandTemplate(:declareAs)}")
formatLines($declarationLines, 2, variable.expandTemplate(:declareAs))
else
$stderr.puts("Error: Can't translate the declaration '#{variableDeclaration}'")
$stderr.puts("Error: Can't translate the declaration '" + variableDeclaration + "'")
end
end
formatLines($declarationLines, 1, "end type t_#{name}")
formatLines($declarationLines, 1, 'end type t_' + name)
$publicTypes.push(name)
end
......@@ -823,7 +823,7 @@ end
#Scan the given header and collect the interface information in the global variables.
def scanHeader(headerPath)
#Scan the given header.
headerLines = IO.popen("cpp -fpreprocessed -dD #{headerPath}").readlines #The options cause the preprocessor to strip all comments, but retain all #defines, and ignore #includes.
headerLines = IO.popen('cpp -fpreprocessed -dD ' + headerPath).readlines #The options cause the preprocessor to strip all comments, but retain all #defines, and ignore #includes.
headerLines.each do |line|
line.chomp!
......@@ -880,7 +880,7 @@ def writeFortranModule(scriptPath, headerPath, modulePath, moduleName)
fortranLine(file, "! Generated by \"#{scriptPath}\" from input file \"#{headerPath}\".")
fortranLine(file, "");
fortranLine(file, "module #{moduleName}")
fortranLine(file, 'module ' + moduleName)
fortranLine(file, "\tuse iso_c_binding")
fortranLine(file, "\timplicit none")
fortranLine(file, "\tprivate")
......@@ -910,7 +910,7 @@ def writeFortranModule(scriptPath, headerPath, modulePath, moduleName)
fortranLine(file, line)
end
fortranLine(file, "end module #{moduleName}")
fortranLine(file, 'end module ' + moduleName)
end
def main
......@@ -944,8 +944,8 @@ def main
writeFortranModule($0, headerPath, outputPath, moduleName)
else
puts("Usage:")
puts("#{$0} cHeader outputPath [ moduleName ]")
puts("#{$0} ( -h | --help )")
puts($0 + ' cHeader outputPath [ moduleName ]')
puts($0 + ' ( -h | --help )')
puts("")
puts("\tcHeader: input C header file")
puts("\toutputPath: output fortran file name")
......
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