Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
9f57dbb0
"wrappers/python/src/vscode:/vscode.git/clone" did not exist on "6371f855ba2c2b41f5b07227562ee8d63934fa06"
Commit
9f57dbb0
authored
Jul 01, 2020
by
Peter Eastman
Browse files
Handle overloaded functions in C and Fortran wrappers
parent
5e392f97
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
2 deletions
+66
-2
plugins/amoeba/wrappers/generateAmoebaWrappers.py
plugins/amoeba/wrappers/generateAmoebaWrappers.py
+33
-1
wrappers/generateWrappers.py
wrappers/generateWrappers.py
+33
-1
No files found.
plugins/amoeba/wrappers/generateAmoebaWrappers.py
View file @
9f57dbb0
...
...
@@ -257,6 +257,7 @@ class CHeaderGenerator(WrapperGenerator):
methodNames
[
methodNode
]
=
shortMethodDefinition
.
split
()[
-
1
]
# Write other methods
nameCount
=
{}
for
methodNode
in
methodList
:
methodName
=
methodNames
[
methodNode
]
if
methodName
in
(
shortClassName
,
destructorName
):
...
...
@@ -268,6 +269,13 @@ class CHeaderGenerator(WrapperGenerator):
# There are two identical methods that differ only in whether they are const. Skip the const one.
continue
returnType
=
self
.
getType
(
getText
(
"type"
,
methodNode
))
if
methodName
in
nameCount
:
# There are multiple methods with the same name.
count
=
nameCount
[
methodName
]
methodName
=
"%s_%d"
%
(
methodName
,
count
)
nameCount
[
methodName
]
=
count
+
1
else
:
nameCount
[
methodName
]
=
1
self
.
out
.
write
(
"extern OPENMM_EXPORT_AMOEBA %s %s_%s("
%
(
returnType
,
typeName
,
methodName
))
isInstanceMethod
=
(
methodNode
.
attrib
[
'static'
]
!=
'yes'
)
if
isInstanceMethod
:
...
...
@@ -438,6 +446,7 @@ class CSourceGenerator(WrapperGenerator):
methodNames
[
methodNode
]
=
shortMethodDefinition
.
split
()[
-
1
]
# Write other methods
nameCount
=
{}
for
methodNode
in
methodList
:
methodName
=
methodNames
[
methodNode
]
if
methodName
in
(
shortClassName
,
destructorName
):
...
...
@@ -448,6 +457,13 @@ class CSourceGenerator(WrapperGenerator):
if
isConstMethod
and
any
(
methodNames
[
m
]
==
methodName
and
m
.
attrib
[
'const'
]
==
'no'
for
m
in
methodList
):
# There are two identical methods that differ only in whether they are const. Skip the const one.
continue
if
methodName
in
nameCount
:
# There are multiple methods with the same name.
count
=
nameCount
[
methodName
]
methodName
=
"%s_%d"
%
(
methodName
,
count
)
nameCount
[
methodName
]
=
count
+
1
else
:
nameCount
[
methodName
]
=
1
methodType
=
getText
(
"type"
,
methodNode
)
returnType
=
self
.
getType
(
methodType
)
if
methodType
in
self
.
classesByShortName
:
...
...
@@ -474,7 +490,7 @@ class CSourceGenerator(WrapperGenerator):
self
.
out
.
write
(
'%s*>(target)->'
%
className
)
else
:
self
.
out
.
write
(
'%s::'
%
className
)
self
.
out
.
write
(
'%s('
%
methodName
)
self
.
out
.
write
(
'%s('
%
methodName
s
[
methodNode
]
)
self
.
writeInvocationArguments
(
methodNode
,
False
)
self
.
out
.
write
(
');
\n
'
)
if
returnType
!=
'void'
:
...
...
@@ -758,6 +774,7 @@ class FortranHeaderGenerator(WrapperGenerator):
methodNames
[
methodNode
]
=
shortMethodDefinition
.
split
()[
-
1
]
# Write other methods
nameCount
=
{}
for
methodNode
in
methodList
:
methodName
=
methodNames
[
methodNode
]
if
methodName
in
(
shortClassName
,
destructorName
):
...
...
@@ -768,6 +785,13 @@ class FortranHeaderGenerator(WrapperGenerator):
if
isConstMethod
and
any
(
methodNames
[
m
]
==
methodName
and
m
.
attrib
[
'const'
]
==
'no'
for
m
in
methodList
):
# There are two identical methods that differ only in whether they are const. Skip the const one.
continue
if
methodName
in
nameCount
:
# There are multiple methods with the same name.
count
=
nameCount
[
methodName
]
methodName
=
"%s_%d"
%
(
methodName
,
count
)
nameCount
[
methodName
]
=
count
+
1
else
:
nameCount
[
methodName
]
=
1
returnType
=
self
.
getType
(
getText
(
"type"
,
methodNode
))
hasReturnValue
=
(
returnType
in
(
'integer*4'
,
'real*8'
))
hasReturnArg
=
not
(
hasReturnValue
or
returnType
==
'void'
)
...
...
@@ -973,6 +997,7 @@ class FortranSourceGenerator(WrapperGenerator):
methodNames
[
methodNode
]
=
shortMethodDefinition
.
split
()[
-
1
]
# Write other methods
nameCount
=
{}
for
methodNode
in
methodList
:
methodName
=
methodNames
[
methodNode
]
if
methodName
in
(
shortClassName
,
destructorName
):
...
...
@@ -985,6 +1010,13 @@ class FortranSourceGenerator(WrapperGenerator):
if
isConstMethod
and
any
(
methodNames
[
m
]
==
methodName
and
m
.
attrib
[
'const'
]
==
'no'
for
m
in
methodList
):
# There are two identical methods that differ only in whether they are const. Skip the const one.
continue
if
methodName
in
nameCount
:
# There are multiple methods with the same name.
count
=
nameCount
[
methodName
]
methodName
=
"%s_%d"
%
(
methodName
,
count
)
nameCount
[
methodName
]
=
count
+
1
else
:
nameCount
[
methodName
]
=
1
functionName
=
"%s_%s"
%
(
typeName
,
methodName
)
self
.
writeOneMethod
(
classNode
,
methodNode
,
functionName
,
functionName
.
lower
()
+
'_'
)
self
.
writeOneMethod
(
classNode
,
methodNode
,
functionName
,
functionName
.
upper
())
...
...
wrappers/generateWrappers.py
View file @
9f57dbb0
...
...
@@ -267,6 +267,7 @@ class CHeaderGenerator(WrapperGenerator):
methodNames
[
methodNode
]
=
shortMethodDefinition
.
split
()[
-
1
]
# Write other methods
nameCount
=
{}
for
methodNode
in
methodList
:
methodName
=
methodNames
[
methodNode
]
if
methodName
in
(
shortClassName
,
destructorName
):
...
...
@@ -278,6 +279,13 @@ class CHeaderGenerator(WrapperGenerator):
# There are two identical methods that differ only in whether they are const. Skip the const one.
continue
returnType
=
self
.
getType
(
getText
(
"type"
,
methodNode
))
if
methodName
in
nameCount
:
# There are multiple methods with the same name.
count
=
nameCount
[
methodName
]
methodName
=
"%s_%d"
%
(
methodName
,
count
)
nameCount
[
methodName
]
=
count
+
1
else
:
nameCount
[
methodName
]
=
1
self
.
out
.
write
(
"extern OPENMM_EXPORT %s %s_%s("
%
(
returnType
,
typeName
,
methodName
))
isInstanceMethod
=
(
methodNode
.
attrib
[
'static'
]
!=
'yes'
)
if
isInstanceMethod
:
...
...
@@ -526,6 +534,7 @@ class CSourceGenerator(WrapperGenerator):
methodNames
[
methodNode
]
=
shortMethodDefinition
.
split
()[
-
1
]
# Write other methods
nameCount
=
{}
for
methodNode
in
methodList
:
methodName
=
methodNames
[
methodNode
]
if
methodName
in
(
shortClassName
,
destructorName
):
...
...
@@ -536,6 +545,13 @@ class CSourceGenerator(WrapperGenerator):
if
isConstMethod
and
any
(
methodNames
[
m
]
==
methodName
and
m
.
attrib
[
'const'
]
==
'no'
for
m
in
methodList
):
# There are two identical methods that differ only in whether they are const. Skip the const one.
continue
if
methodName
in
nameCount
:
# There are multiple methods with the same name.
count
=
nameCount
[
methodName
]
methodName
=
"%s_%d"
%
(
methodName
,
count
)
nameCount
[
methodName
]
=
count
+
1
else
:
nameCount
[
methodName
]
=
1
methodType
=
getText
(
"type"
,
methodNode
)
returnType
=
self
.
getType
(
methodType
)
if
methodType
in
self
.
classesByShortName
:
...
...
@@ -562,7 +578,7 @@ class CSourceGenerator(WrapperGenerator):
self
.
out
.
write
(
'%s*>(target)->'
%
className
)
else
:
self
.
out
.
write
(
'%s::'
%
className
)
self
.
out
.
write
(
'%s('
%
methodName
)
self
.
out
.
write
(
'%s('
%
methodName
s
[
methodNode
]
)
self
.
writeInvocationArguments
(
methodNode
,
False
)
self
.
out
.
write
(
');
\n
'
)
if
returnType
!=
'void'
:
...
...
@@ -982,6 +998,7 @@ class FortranHeaderGenerator(WrapperGenerator):
methodNames
[
methodNode
]
=
shortMethodDefinition
.
split
()[
-
1
]
# Write other methods
nameCount
=
{}
for
methodNode
in
methodList
:
methodName
=
methodNames
[
methodNode
]
if
methodName
in
(
shortClassName
,
destructorName
):
...
...
@@ -992,6 +1009,13 @@ class FortranHeaderGenerator(WrapperGenerator):
if
isConstMethod
and
any
(
methodNames
[
m
]
==
methodName
and
m
.
attrib
[
'const'
]
==
'no'
for
m
in
methodList
):
# There are two identical methods that differ only in whether they are const. Skip the const one.
continue
if
methodName
in
nameCount
:
# There are multiple methods with the same name.
count
=
nameCount
[
methodName
]
methodName
=
"%s_%d"
%
(
methodName
,
count
)
nameCount
[
methodName
]
=
count
+
1
else
:
nameCount
[
methodName
]
=
1
returnType
=
self
.
getType
(
getText
(
"type"
,
methodNode
))
hasReturnValue
=
(
returnType
in
(
'integer*4'
,
'real*8'
))
hasReturnArg
=
not
(
hasReturnValue
or
returnType
==
'void'
)
...
...
@@ -1539,6 +1563,7 @@ class FortranSourceGenerator(WrapperGenerator):
methodNames
[
methodNode
]
=
shortMethodDefinition
.
split
()[
-
1
]
# Write other methods
nameCount
=
{}
for
methodNode
in
methodList
:
methodName
=
methodNames
[
methodNode
]
if
methodName
in
(
shortClassName
,
destructorName
):
...
...
@@ -1551,6 +1576,13 @@ class FortranSourceGenerator(WrapperGenerator):
if
isConstMethod
and
any
(
methodNames
[
m
]
==
methodName
and
m
.
attrib
[
'const'
]
==
'no'
for
m
in
methodList
):
# There are two identical methods that differ only in whether they are const. Skip the const one.
continue
if
methodName
in
nameCount
:
# There are multiple methods with the same name.
count
=
nameCount
[
methodName
]
methodName
=
"%s_%d"
%
(
methodName
,
count
)
nameCount
[
methodName
]
=
count
+
1
else
:
nameCount
[
methodName
]
=
1
functionName
=
"%s_%s"
%
(
typeName
,
methodName
)
truncatedName
=
functionName
[:
63
]
self
.
writeOneMethod
(
classNode
,
methodNode
,
functionName
,
truncatedName
.
lower
()
+
'_'
)
...
...
Write
Preview
Markdown
is supported
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