fix python bindings for spot::parsed_formula::f getter
* python/spot/impl.i: Add a typemap. * tests/python/ltlsimple.py: Add a test case for an issue. * NEWS: Mention the bug.
This commit is contained in:
parent
701a3b1c6a
commit
5c8cf1bc47
3 changed files with 21 additions and 0 deletions
4
NEWS
4
NEWS
|
|
@ -21,6 +21,10 @@ New in spot 2.6.0.dev (not yet released)
|
||||||
documentation was also matching the code, so this is a backward
|
documentation was also matching the code, so this is a backward
|
||||||
incompatible change.
|
incompatible change.
|
||||||
|
|
||||||
|
- The Python binding of the getter of spot::parsed_formula::f was
|
||||||
|
returning a reference instead of a copy, causing issues if the
|
||||||
|
reference outlasted the parsed_formula struct.
|
||||||
|
|
||||||
|
|
||||||
New in spot 2.6 (2018-07-04)
|
New in spot 2.6 (2018-07-04)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -384,6 +384,15 @@ namespace swig
|
||||||
SWIG_POINTER_IMPLICIT_CONV));
|
SWIG_POINTER_IMPLICIT_CONV));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Access to stucture members, such as spot::parsed_formula::f are done via
|
||||||
|
// the pointer typemap. We want to enforce a copy.
|
||||||
|
%typemap(out) spot::formula* {
|
||||||
|
if (!*$1)
|
||||||
|
$result = SWIG_Py_Void();
|
||||||
|
else
|
||||||
|
$result = SWIG_NewPointerObj(new spot::formula(*$1), $descriptor(spot::formula*), SWIG_POINTER_OWN);
|
||||||
|
}
|
||||||
|
|
||||||
%typemap(out) spot::formula {
|
%typemap(out) spot::formula {
|
||||||
if (!$1)
|
if (!$1)
|
||||||
$result = SWIG_Py_Void();
|
$result = SWIG_Py_Void();
|
||||||
|
|
|
||||||
|
|
@ -134,3 +134,11 @@ for (input, output) in [('(a&b)<->b', 'b->(a&b)'),
|
||||||
print(input, f, output)
|
print(input, f, output)
|
||||||
assert(f == output)
|
assert(f == output)
|
||||||
assert(spot.are_equivalent(input, output))
|
assert(spot.are_equivalent(input, output))
|
||||||
|
|
||||||
|
def myparse(input):
|
||||||
|
env = spot.default_environment.instance()
|
||||||
|
pf = spot.parse_infix_psl(input, env)
|
||||||
|
return pf.f
|
||||||
|
# This used to fail, because myparse would return a pointer
|
||||||
|
# to pf.f inside the destroyed pf.
|
||||||
|
assert myparse('a U b') == spot.formula('a U b')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue