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:
Alexandre Duret-Lutz 2017-04-23 15:22:08 +02:00
parent 5e8f3ee629
commit f185aabf44
6 changed files with 120 additions and 2 deletions

1
python/.gitignore vendored
View file

@ -12,3 +12,4 @@ buddy.py*
ajax/*.py
spot/impl.py
spot/ltsmin.py
spot/gen.py

View file

@ -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
View 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>