python: add wrapper for libspotgen
For #254. * python/spot/gen.i, tests/python/gen.py: New files. * python/Makefile.am, tests/Makefile.am: Adjust. * NEWS: Mention the spot.gen python package.
This commit is contained in:
parent
5e8f3ee629
commit
f185aabf44
6 changed files with 120 additions and 2 deletions
5
NEWS
5
NEWS
|
|
@ -61,6 +61,11 @@ New in spot 2.3.3.dev (not yet released)
|
|||
spot::acc_cond::rabin_like_pairs() are implemented for Rabin-like
|
||||
pairs.
|
||||
|
||||
Python:
|
||||
|
||||
- The 'spot.gen' package is a wrapper around the functions from
|
||||
the libspotgen library.
|
||||
|
||||
Bugs fixed:
|
||||
|
||||
- the transformation to state-based acceptance (spot::sbacc()) was
|
||||
|
|
|
|||
1
python/.gitignore
vendored
1
python/.gitignore
vendored
|
|
@ -12,3 +12,4 @@ buddy.py*
|
|||
ajax/*.py
|
||||
spot/impl.py
|
||||
spot/ltsmin.py
|
||||
spot/gen.py
|
||||
|
|
|
|||
|
|
@ -34,18 +34,21 @@ AM_CPPFLAGS = -I$(PYTHONINC) -I$(top_builddir) -I$(top_srcdir) \
|
|||
# this.
|
||||
SWIGFLAGS = -c++ -python -py3 -O -nofastproxy -MD
|
||||
|
||||
EXTRA_DIST = buddy.i spot/impl.i spot/ltsmin.i
|
||||
EXTRA_DIST = buddy.i spot/impl.i spot/ltsmin.i spot/gen.i
|
||||
nobase_python_PYTHON = \
|
||||
spot/__init__.py \
|
||||
spot/aux.py \
|
||||
spot/impl.py \
|
||||
spot/ltsmin.py \
|
||||
spot/gen.py \
|
||||
buddy.py
|
||||
nobase_pyexec_LTLIBRARIES = _buddy.la spot/_impl.la spot/_ltsmin.la
|
||||
nobase_pyexec_LTLIBRARIES = _buddy.la spot/_impl.la \
|
||||
spot/_ltsmin.la spot/_gen.la
|
||||
|
||||
MAINTAINERCLEANFILES = \
|
||||
$(srcdir)/spot/impl_wrap.cxx $(srcdir)/spot/impl.py \
|
||||
$(srcdir)/spot/ltsmin_wrap.cxx $(srcdir)/spot/ltsmin.py \
|
||||
$(srcdir)/spot/gen_wrap.cxx $(srcdir)/spot/gen.py \
|
||||
$(srcdir)/buddy_wrap.cxx $(srcdir)/buddy.py
|
||||
|
||||
## spot
|
||||
|
|
@ -81,6 +84,23 @@ spot/ltsmin.py: spot/ltsmin.i
|
|||
$(MAKE) $(AM_MAKEFLAGS) spot/ltsmin_wrap.cxx
|
||||
|
||||
|
||||
## spot-gen
|
||||
|
||||
spot__gen_la_SOURCES = spot/gen_wrap.cxx
|
||||
spot__gen_la_LDFLAGS = -avoid-version -module $(SYMBOLIC_LDFLAGS)
|
||||
spot__gen_la_LIBADD = $(top_builddir)/spot/libspot.la \
|
||||
$(top_builddir)/spot/gen/libspotgen.la
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./spot/$(DEPDIR)/gen_wrap.Pcxx@am__quote@
|
||||
|
||||
${srcdir}/spot/gen_wrap.cxx: spot/gen.i
|
||||
$(SWIG) $(SWIGFLAGS) -I$(srcdir) -I$(top_srcdir) -MF spot/$(DEPDIR)/gen_wrap.TPcxx $(srcdir)/spot/gen.i
|
||||
mv spot/$(DEPDIR)/gen_wrap.TPcxx spot/$(DEPDIR)/gen_wrap.Pcxx
|
||||
|
||||
spot/gen.py: spot/gen.i
|
||||
$(MAKE) $(AM_MAKEFLAGS) spot/gen_wrap.cxx
|
||||
|
||||
|
||||
## buddy
|
||||
|
||||
_buddy_la_SOURCES = buddy_wrap.cxx
|
||||
|
|
|
|||
53
python/spot/gen.i
Normal file
53
python/spot/gen.i
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2017 Laboratoire de Recherche et Développement de
|
||||
// l'Epita (LRDE).
|
||||
//
|
||||
// This file is part of Spot, a model checking library.
|
||||
//
|
||||
// Spot is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Spot is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
// License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
%{
|
||||
// Workaround for SWIG 2.0.2 using ptrdiff_t but not including cstddef.
|
||||
// It matters with g++ 4.6.
|
||||
#include <cstddef>
|
||||
%}
|
||||
|
||||
%module(package="spot", director="1") gen
|
||||
|
||||
%include "std_string.i"
|
||||
%include "exception.i"
|
||||
%include "std_shared_ptr.i"
|
||||
|
||||
%shared_ptr(spot::twa_graph)
|
||||
|
||||
%{
|
||||
#include <spot/gen/automata.hh>
|
||||
using namespace spot;
|
||||
%}
|
||||
|
||||
%import(module="spot.impl") <spot/misc/common.hh>
|
||||
%import(module="spot.impl") <spot/tl/formula.hh>
|
||||
%import(module="spot.impl") <spot/twa/fwd.hh>
|
||||
|
||||
%exception {
|
||||
try {
|
||||
$action
|
||||
}
|
||||
catch (const std::runtime_error& e)
|
||||
{
|
||||
SWIG_exception(SWIG_RuntimeError, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
%include <spot/gen/automata.hh>
|
||||
|
|
@ -335,6 +335,7 @@ TESTS_python = \
|
|||
python/declenv.py \
|
||||
python/decompose_scc.py \
|
||||
python/dualize.py \
|
||||
python/gen.py \
|
||||
python/implies.py \
|
||||
python/interdep.py \
|
||||
python/ltl2tgba.test \
|
||||
|
|
|
|||
38
tests/python/gen.py
Normal file
38
tests/python/gen.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
# -*- mode: python; coding: utf-8 -*-
|
||||
# Copyright (C) 2017 Laboratoire de Recherche et Développement de
|
||||
# l'Epita (LRDE).
|
||||
#
|
||||
# This file is part of Spot, a model checking library.
|
||||
#
|
||||
# Spot is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Spot is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
# License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Test that the spot.gen package works, in particular, we want
|
||||
# to make sure that the objects created from spot.gen methods
|
||||
# are usable with methods from the spot package.
|
||||
|
||||
import spot.gen as gen
|
||||
from sys import exit
|
||||
|
||||
k2 = gen.ks_cobuchi(2)
|
||||
assert k2.num_states() == 5
|
||||
# to_str is defined in the spot package, so this makes sure
|
||||
# the type returned by spot.gen.ks_cobuchi() is the correct one.
|
||||
assert 'to_str' in dir(k2)
|
||||
|
||||
try:
|
||||
gen.ks_cobuchi(0)
|
||||
except RuntimeError as e:
|
||||
assert 'positive argument' in str(e)
|
||||
else:
|
||||
exit(2)
|
||||
Loading…
Add table
Add a link
Reference in a new issue