Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Christian Butz
VTK
Commits
00cc21c5
Commit
00cc21c5
authored
May 04, 2010
by
David Gobbi
Committed by
Marcus D. Hanwell
Jun 16, 2010
Browse files
ENH: Raise a python error if overload resolution is ambiguous.
parent
640aa0d6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Common/vtkPythonUtil.cxx
View file @
00cc21c5
...
...
@@ -1595,6 +1595,7 @@ PyObject *PyVTKCallOverloadedMethod(
PyMethodDef
*
methods
,
PyObject
*
self
,
PyObject
*
args
)
{
PyMethodDef
*
meth
=
&
methods
[
0
];
int
matchCount
=
1
;
// Make sure there is more than one method
if
(
methods
[
1
].
ml_meth
!=
0
)
...
...
@@ -1707,19 +1708,24 @@ PyObject *PyVTKCallOverloadedMethod(
}
// Loop through methods and identify the best match
int
minPenalty
=
VTK_
INT_MAX
;
int
minPenalty
=
VTK_
PYTHON_INCOMPATIBLE
;
meth
=
0
;
matchCount
=
0
;
for
(
sig
=
0
;
sig
<
nsig
;
sig
++
)
{
// the "helper->next" check is to ensure that there are no leftover args
helper
=
&
helperArray
[
sig
];
int
penalty
=
helper
->
penalty
();
if
(
penalty
!=
VTK_PYTHON_INCOMPATIBLE
&&
penalty
<
minPenalty
&&
if
(
penalty
<=
minPenalty
&&
penalty
<
VTK_PYTHON_INCOMPATIBLE
&&
!
helper
->
next
(
&
format
,
&
classname
))
{
minPenalty
=
penalty
;
meth
=
&
methods
[
sig
];
if
(
penalty
<
minPenalty
)
{
matchCount
=
0
;
minPenalty
=
penalty
;
meth
=
&
methods
[
sig
];
}
matchCount
++
;
}
}
...
...
@@ -1730,6 +1736,14 @@ PyObject *PyVTKCallOverloadedMethod(
}
}
if
(
meth
&&
matchCount
>
1
)
{
PyErr_SetString
(
PyExc_TypeError
,
"ambiguous call, multiple overloaded methods match the arguments"
);
return
NULL
;
}
if
(
meth
)
{
return
meth
->
ml_meth
(
self
,
args
);
...
...
@@ -1752,6 +1766,7 @@ PyMethodDef *PyVTKFindConversionMethod(
const
char
*
format
,
*
classname
,
*
dummy1
,
*
dummy2
;
int
minPenalty
=
VTK_PYTHON_NEEDS_CONVERSION
;
PyMethodDef
*
method
=
0
;
int
matchCount
=
0
;
for
(
PyMethodDef
*
meth
=
methods
;
meth
->
ml_meth
!=
NULL
;
meth
++
)
{
...
...
@@ -1766,12 +1781,19 @@ PyMethodDef *PyVTKFindConversionMethod(
if
(
penalty
<
minPenalty
)
{
matchCount
=
1
;
minPenalty
=
penalty
;
method
=
meth
;
}
else
if
(
meth
&&
penalty
==
minPenalty
)
{
matchCount
++
;
}
}
}
// if matchCount > 1, there was ambiguity
return
method
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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