Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
ba300299
Commit
ba300299
authored
Aug 05, 2015
by
Thomas Jahns
🤸
Browse files
Add explicit declaration of optional arguments.
parent
70196bde
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
interfaces/f2003/bindGen.rb
View file @
ba300299
...
...
@@ -218,10 +218,13 @@ $argumentTemplates = [
:passAs
=>
'integer(c_<type>), intent(in) :: <name>_dummy(<lineSize>, <lineCount>)'
,
:postcallStatements
=>
""
},
#Pointer arguments. These match both pointers and arrays, so they must appear after the more special array templates.
#Most of these are wrapped by optional arguments which have to be named in calling code, which is why we don't use the _dummy suffix for them.
#Optional pointer arguments. These match both pointers and arrays,
#so they must appear after the more special array templates. Most
#of these are wrapped by optional arguments which have to be named
#in calling code, which is why we don't use the _dummy suffix for
#them.
{
#<integerTypes>*
:regex
=>
'^\s*(?<type><integerTypes>)\s*\*\s*(?<name>\w+)\s*$'
,
:regex
=>
'^\s*(?<type><integerTypes>)\s*\*\s*(?<name>\w+
_optional
)\s*$'
,
:placeholders
=>
%w[name type]
,
:dummyName
=>
'<name>'
,
:acceptAs
=>
'integer(c_<type>), optional, intent(inout) :: <name>'
,
...
...
@@ -231,7 +234,7 @@ $argumentTemplates = [
:passAs
=>
'type(c_ptr), value :: <name>'
,
:postcallStatements
=>
"if(present(<name>)) <name> = <name>_temp"
},
{
#<floatTypes>*
:regex
=>
'^\s*(?<type><floatTypes>)\s*\*\s*(?<name>\w+)\s*$'
,
:regex
=>
'^\s*(?<type><floatTypes>)\s*\*\s*(?<name>\w+
_optional
)\s*$'
,
:placeholders
=>
%w[name type]
,
:dummyName
=>
'<name>'
,
:acceptAs
=>
'real(c_<type>), optional, intent(inout) :: <name>'
,
...
...
@@ -241,16 +244,49 @@ $argumentTemplates = [
:passAs
=>
'type(c_ptr), value :: <name>'
,
:postcallStatements
=>
"if(present(<name>)) <name> = <name>_temp"
},
{
#unsigned char (*<name>)[<size>]
:regex
=>
'^\s*unsigned\s+char\s*\(\s*\*\s*(?<name>\w+)\s*\)\s*\[\s*(?<size>[^\]]+)\s*\]\s*$'
,
:regex
=>
'^\s*unsigned\s+char\s*\(\s*\*\s*(?<name>\w+
_optional
)\s*\)\s*\[\s*(?<size>[^\]]+)\s*\]\s*$'
,
:placeholders
=>
%w[name size]
,
:dummyName
=>
'<name>'
,
:acceptAs
=>
'
charact
er(kind = c_char), optional, intent(inout) :: <name>(<size>)'
,
:helperVars
=>
"
charact
er(kind = c_char), target :: <name>_temp(<size>)
\n
type(c_ptr) :: <name>_ptr"
,
:acceptAs
=>
'
integ
er(kind = c_
signed_
char), optional, intent(inout) :: <name>(<size>)'
,
:helperVars
=>
"
integ
er(kind = c_
signed_
char), target :: <name>_temp(<size>)
\n
type(c_ptr) :: <name>_ptr"
,
:precallStatements
=>
"<name>_ptr = c_null_ptr
\n
if(present(<name>)) <name>_ptr = c_loc(<name>_temp)"
,
:callExpression
=>
'<name>_ptr'
,
:passAs
=>
'type(c_ptr), value :: <name>'
,
:postcallStatements
=>
"if(present(<name>)) <name> = <name>_temp"
},
#Non-optional pointer arguments. These match both pointers and
#arrays, so they must appear after the more special array templates.
{
#<integerTypes>*
:regex
=>
'^\s*(?<type><integerTypes>)\s*\*\s*(?<name>\w+)\s*$'
,
:placeholders
=>
%w[name type]
,
:dummyName
=>
'<name>_dummy'
,
:acceptAs
=>
'integer(c_<type>), intent(inout) :: <name>_dummy'
,
:helperVars
=>
""
,
:precallStatements
=>
""
,
:callExpression
=>
'<name>_dummy'
,
:passAs
=>
'integer(c_<type>), intent(inout) :: <name>_dummy'
,
:postcallStatements
=>
""
},
{
#<floatTypes>*
:regex
=>
'^\s*(?<type><floatTypes>)\s*\*\s*(?<name>\w+)\s*$'
,
:placeholders
=>
%w[name type]
,
:dummyName
=>
'<name>_dummy'
,
:acceptAs
=>
'real(c_<type>), intent(inout) :: <name>_dummy'
,
:helperVars
=>
""
,
:precallStatements
=>
""
,
:callExpression
=>
'<name>_dummy'
,
:passAs
=>
'real(c_<type>), intent(inout) :: <name>_dummy'
,
:postcallStatements
=>
""
},
{
#unsigned char (*<name>)[<size>]
:regex
=>
'^\s*unsigned\s+char\s*\(\s*\*\s*(?<name>\w+)\s*\)\s*\[\s*(?<size>[^\]]+)\s*\]\s*$'
,
:placeholders
=>
%w[name size]
,
:dummyName
=>
'<name>_dummy'
,
:acceptAs
=>
'integer(kind = c_signed_char), intent(inout) :: <name>(<size>)'
,
:helperVars
=>
""
,
:precallStatements
=>
""
,
:callExpression
=>
'<name>_dummy'
,
:passAs
=>
'integer(kind = c_signed_char), intent(inout) :: <name>(<size>)'
,
:postcallStatements
=>
""
},
#String arguments.
{
#char* Unsafe buffer passing
:regex
=>
'^\s*char\s*\*\s*(?<name>\w+)\s*$'
,
...
...
src/mo_cdi.f90
View file @
ba300299
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment