rename src/ as spot/ and use include <spot/...>

* NEWS: Mention the change.
* src/: Rename as ...
* spot/: ... this, adjust all headers to include <spot/...> instead of
"...", and adjust all Makefile.am to search headers from the top-level
directory.
* HACKING: Add conventions about #include.
* spot/sanity/style.test: Add a few more grep to catch cases
that do not follow these conventions.
* .gitignore, Makefile.am, README, bench/stutter/Makefile.am,
bench/stutter/stutter_invariance_formulas.cc,
bench/stutter/stutter_invariance_randomgraph.cc, configure.ac,
debian/rules, doc/Doxyfile.in, doc/Makefile.am,
doc/org/.dir-locals.el.in, doc/org/g++wrap.in, doc/org/init.el.in,
doc/org/tut01.org, doc/org/tut02.org, doc/org/tut03.org,
doc/org/tut10.org, doc/org/tut20.org, doc/org/tut21.org,
doc/org/tut22.org, doc/org/tut30.org, iface/ltsmin/Makefile.am,
iface/ltsmin/kripke.test, iface/ltsmin/ltsmin.cc,
iface/ltsmin/ltsmin.hh, iface/ltsmin/modelcheck.cc,
wrap/python/Makefile.am, wrap/python/ajax/spotcgi.in,
wrap/python/spot_impl.i, wrap/python/tests/ltl2tgba.py,
wrap/python/tests/randgen.py, wrap/python/tests/run.in: Adjust.
This commit is contained in:
Alexandre Duret-Lutz 2015-12-04 19:42:23 +01:00
parent 1fddfe60ec
commit f120dd3206
529 changed files with 1308 additions and 1262 deletions

33
spot/priv/Makefile.am Normal file
View file

@ -0,0 +1,33 @@
## -*- coding: utf-8 -*-
## Copyright (C) 2013, 2014, 2015 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/>.
AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) $(BUDDY_CPPFLAGS)
AM_CXXFLAGS = $(WARNING_CXXFLAGS)
noinst_HEADERS = \
accmap.hh \
bddalloc.hh \
freelist.hh \
trim.hh
noinst_LTLIBRARIES = libpriv.la
libpriv_la_SOURCES = \
bddalloc.cc \
freelist.cc \
trim.cc

119
spot/priv/accmap.hh Normal file
View file

@ -0,0 +1,119 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2014 Laboratoire de Recherche et Developpement 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/>.
#pragma once
#include <bddx.h>
#include <spot/misc/hash.hh>
#include <spot/tl/formula.hh>
#include <spot/twa/twagraph.hh>
namespace spot
{
class acc_mapper_common
{
protected:
bdd_dict_ptr dict_;
twa_graph_ptr aut_;
acc_mapper_common(const twa_graph_ptr& aut)
: dict_(aut->get_dict()), aut_(aut)
{
}
};
class acc_mapper_string: public acc_mapper_common
{
std::unordered_map<std::string, unsigned> map_;
public:
acc_mapper_string(const twa_graph_ptr& aut)
: acc_mapper_common(aut)
{
}
// Declare an acceptance name.
bool declare(const std::string& name)
{
auto i = map_.find(name);
if (i != map_.end())
return true;
auto v = aut_->acc().add_set();
map_[name] = v;
return true;
}
std::pair<bool, acc_cond::mark_t> lookup(std::string name) const
{
auto p = map_.find(name);
if (p == map_.end())
return std::make_pair(false, 0U);
return std::make_pair(true, aut_->acc().marks({p->second}));
}
};
// The acceptance sets are named using count consecutive integers.
class acc_mapper_consecutive_int: public acc_mapper_common
{
public:
acc_mapper_consecutive_int(const twa_graph_ptr& aut, unsigned count)
: acc_mapper_common(aut)
{
std::vector<unsigned> vmap(count);
aut->acc().add_sets(count);
}
std::pair<bool, acc_cond::mark_t> lookup(unsigned n)
{
if (n < aut_->acc().num_sets())
return std::make_pair(true, aut_->acc().marks({n}));
else
return std::make_pair(false, 0U);
}
};
// The acceptance sets are named using count integers, but we do not
// assume the numbers are necessarily consecutive.
class acc_mapper_int: public acc_mapper_consecutive_int
{
unsigned used_;
std::map<unsigned, acc_cond::mark_t> map_;
public:
acc_mapper_int(const twa_graph_ptr& aut, unsigned count)
: acc_mapper_consecutive_int(aut, count), used_(0)
{
}
std::pair<bool, acc_cond::mark_t> lookup(unsigned n)
{
auto p = map_.find(n);
if (p != map_.end())
return std::make_pair(true, p->second);
if (used_ < aut_->acc().num_sets())
{
auto res = aut_->acc().marks({used_++});
map_[n] = res;
return std::make_pair(true, res);
}
return std::make_pair(false, 0U);
}
};
}

116
spot/priv/bddalloc.cc Normal file
View file

@ -0,0 +1,116 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2007, 2011, 2014, 2015 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
// Copyright (C) 2003, 2004, 2006, 2007 Laboratoire d'Informatique de
// Paris 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
// Université Pierre et Marie Curie.
//
// 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/>.
#include <bddx.h>
#include <cassert>
#include "spot/priv/bddalloc.hh"
namespace spot
{
bool bdd_allocator::initialized = false;
bdd_allocator::bdd_allocator()
{
initialize();
lvarnum = bdd_varnum();
fl.emplace_front(0, lvarnum);
}
void
bdd_allocator::initialize()
{
if (initialized)
return;
initialized = true;
// Buddy might have been initialized by a third-party library.
if (bdd_isrunning())
return;
// The values passed to bdd_init should depends on the problem
// the library is solving. It would be nice to allow users
// to tune this. By the meantime, we take the typical values
// for large examples advocated by the BuDDy manual.
bdd_init(1000000, 10000);
bdd_setvarnum(2);
// Disable the default GC handler. (Note that this will only be
// done if Buddy is initialized by Spot. Otherwise we prefer not
// to overwrite a handler that might have been set by the user.)
bdd_gbc_hook(nullptr);
// When the node time is full, add 500000 nodes, i.e., 10MB.
bdd_setmaxincrease(500000);
}
void
bdd_allocator::extvarnum(int more)
{
int varnum = bdd_varnum();
// If varnum has been extended from another allocator (or
// externally), use the new variables.
if (lvarnum < varnum)
{
more -= varnum - lvarnum;
lvarnum = varnum;
}
// If we still need more variable, do allocate them.
if (more > 0)
{
bdd_extvarnum(more);
varnum += more;
lvarnum = varnum;
}
}
int
bdd_allocator::allocate_variables(int n)
{
return register_n(n);
}
void
bdd_allocator::release_variables(int base, int n)
{
release_n(base, n);
}
int
bdd_allocator::extend(int n)
{
// If we already have some free variable at the end
// of the variable space, allocate just the difference.
if (!fl.empty() && fl.back().first + fl.back().second == lvarnum)
{
int res = fl.back().first;
int endvar = fl.back().second;
assert(n > endvar);
extvarnum(n - endvar);
fl.pop_back();
return res;
}
else
{
// Otherwise, allocate as much variables as we need.
int res = lvarnum;
extvarnum(n);
return res;
}
}
}

54
spot/priv/bddalloc.hh Normal file
View file

@ -0,0 +1,54 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2013 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// 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/>.
#pragma once
#include "spot/priv/freelist.hh"
#include <list>
#include <utility>
namespace spot
{
/// \ingroup misc_tools
/// \brief Manage ranges of variables.
class bdd_allocator: private free_list
{
public:
/// Default constructor.
bdd_allocator();
/// Initialize the BDD library.
static void initialize();
/// Allocate \a n BDD variables.
int allocate_variables(int n);
/// Release \a n BDD variables starting at \a base.
void release_variables(int base, int n);
using free_list::dump_free_list;
protected:
static bool initialized; ///< Whether the BDD library has been initialized.
int lvarnum; ///< number of variables in use in this allocator.
private:
/// Require more variables.
void extvarnum(int more);
virtual int extend(int n);
};
}

221
spot/priv/freelist.cc Normal file
View file

@ -0,0 +1,221 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2014 Laboratoire de Recherche et Développement de
// l'Epita.
// Copyright (C) 2004, 2006 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// 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/>.
#include "spot/priv/freelist.hh"
#include <cassert>
#include <iostream>
namespace spot
{
free_list::~free_list()
{
}
int
free_list::register_n(int n)
{
// Browse the free list until we find N consecutive variables. We
// try not to fragment the list my allocating the variables in the
// smallest free range we find.
free_list_type::iterator best = fl.end();
free_list_type::iterator cur;
for (cur = fl.begin(); cur != fl.end(); ++cur)
{
if (cur->second < n)
continue;
if (n == cur->second)
{
best = cur;
break;
}
if (best == fl.end()
|| cur->second < best->second)
best = cur;
}
// We have found enough free variables.
if (best != fl.end())
{
int result = best->first;
remove(best, result, n);
return result;
}
// We haven't found enough adjacent free variables;
// ask for some more.
return extend(n);
}
void
free_list::insert(int base, int n)
{
free_list_type::iterator cur;
int end = base + n;
for (cur = fl.begin(); cur != fl.end(); ++cur)
{
int cend = cur->first + cur->second;
// cur [...]
// to insert [...]
// -----------------------
// result [...] [...]
// (Insert a new range, unconnected.)
if (cur->first > end)
{
break;
}
// cur [...]
// to insert [...]
// -----------------------
// result unknown : we should look at the rest of the freelist.
else if (base > cend)
{
continue;
}
// cur [....[ [......[
// to insert [....[ [..[
// ----------------------------------
// result [......[ [......[
else if (cur->first <= base)
{
if (cend >= end)
// second case : nothing to do
return;
// cur->second is set below.
}
// cur [....[ [..[
// to insert [....[ [.......[
// ----------------------------------
// result [......[ [.......[
else
{
cur->first = base;
// cur->second is set below.
}
// We get here in one of these three situations:
//
// cur [....[ [....[ [..[
// to insert [....[ [....[ [.......[
// -------------------------------------------
// result [......[ [......[ [.......[
//
// cur->first is already set, be cur->second has yet to be.
end = std::max(cend, end);
cur->second = end - cur->first;
// Since we have extended the current range, maybe the next
// items on the list should be merged.
free_list_type::iterator next = cur;
++next;
while (next != fl.end() && next->first <= end)
{
end = std::max(next->first + next->second, end);
cur->second = end - cur->first;
free_list_type::iterator next2 = next++;
fl.erase(next2);
}
return;
}
// We reach this place either because a new unconnected range
// should be inserted in the middle of FL, or at the end.
fl.insert(cur, pos_lenght_pair(base, n));
}
void
free_list::remove(int base, int n)
{
free_list_type::iterator cur = fl.begin();
int end = base + n;
while (cur != fl.end() && cur->first < end)
{
int cend = cur->first + cur->second;
// Remove may invalidate the current iterator, so advance it first.
free_list_type::iterator old = cur++;
if (cend >= base)
{
int newbase = std::max(base, old->first);
int q = std::min(cend, end) - newbase;
remove(old, newbase, q);
}
}
}
void
free_list::remove(free_list_type::iterator i, int base, int n)
{
if (base == i->first)
{
// Removing at the beginning of the range
i->second -= n;
assert(i->second >= 0);
// Erase the range if it's now empty.
if (i->second == 0)
fl.erase(i);
else
i->first += n;
}
else if (base + n == i->first + i->second)
{
// Removing at the end of the range
i->second -= n;
assert(i->second > 0); // cannot be empty because base != i->first
}
else
{
// Removing in the middle of a range.
int b1 = i->first;
int n1 = base - i->first;
int n2 = i->first + i->second - base - n;
assert(n1 > 0);
assert(n2 > 0);
*i = pos_lenght_pair(base + n, n2);
fl.insert(i, pos_lenght_pair(b1, n1));
}
}
void
free_list::release_n(int base, int n)
{
insert(base, n);
}
std::ostream&
free_list::dump_free_list(std::ostream& os) const
{
free_list_type::const_iterator i;
for (i = fl.begin(); i != fl.end(); ++i)
os << " (" << i->first << ", " << i->second << ')';
return os;
}
int
free_list::free_count() const
{
int res = 0;
free_list_type::const_iterator i;
for (i = fl.begin(); i != fl.end(); ++i)
res += i->second;
return res;
}
}

80
spot/priv/freelist.hh Normal file
View file

@ -0,0 +1,80 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2008,2013 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
// Copyright (C) 2004, 2006 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// 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/>.
#pragma once
#include <list>
#include <utility>
#include <iosfwd>
namespace spot
{
/// \ingroup misc_tools
/// \brief Manage list of free integers.
class free_list
{
public:
virtual ~free_list();
/// \brief Find \a n consecutive integers.
///
/// Browse the list of free integers until \a n consecutive
/// integers are found. Extend the list (using extend()) otherwise.
/// \return the first integer of the range
int register_n(int n);
/// Release \a n consecutive integers starting at \a base.
void release_n(int base, int n);
/// Dump the list to \a os for debugging.
std::ostream& dump_free_list(std::ostream& os) const;
/// Extend the list by inserting a new pos-lenght pair.
void insert(int base, int n);
/// Remove \a n consecutive entries from the list, starting at \a base.
void remove(int base, int n = 0);
/// Return the number of free integers on the list.
int free_count() const;
protected:
/// Allocate \a n integer.
///
/// This function is called by register_n() when the free list is
/// empty or if \a n consecutive integers could not be found. It
/// should allocate more integers, possibly changing the list, and
/// return the first integer on a range of n consecutive integer
/// requested by the user.
virtual int extend(int n) = 0;
/// Such pairs describe \c second free integer starting at \c first.
typedef std::pair<int, int> pos_lenght_pair;
typedef std::list<pos_lenght_pair> free_list_type;
free_list_type fl; ///< Tracks unused BDD variables.
/// Remove \a n consecutive entries from the list, starting at \a base.
void remove(free_list_type::iterator i, int base, int n);
};
}

39
spot/priv/trim.cc Normal file
View file

@ -0,0 +1,39 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2015 Laboratoire de Recherche et Developpement 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/>.
#include <spot/priv/trim.hh>
#include <algorithm>
#include <functional>
#include <cctype>
#include <locale>
namespace spot
{
void
trim(std::string& str)
{
str.erase(std::find_if(str.rbegin(), str.rend(),
std::not1(std::ptr_fun<int, int>
(std::isspace))).base(),
str.end());
str.erase(str.begin(),
std::find_if(str.begin(), str.end(),
std::not1(std::ptr_fun<int, int>(std::isspace))));
}
}

28
spot/priv/trim.hh Normal file
View file

@ -0,0 +1,28 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2015 Laboratoire de Recherche et Developpement 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/>.
#pragma once
#include <string>
namespace spot
{
/// \brief Remove spaces at the front and back of \a str.
void trim(std::string& str);
}