Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
March 2008
- 12 participants
- 83 discussions
18 Mar '08
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Sandbox: Site/Psite refactorization: finalize the example.
* sandbox/ballas/refactorization/test/test.cc: Remove this tes.
* sandbox/ballas/refactorization/test/rle.cc,
* sandbox/ballas/refactorization/test/image2d.cc: update tests.
* sandbox/ballas/refactorization/image2d.hh: update values_.
* sandbox/ballas/refactorization/concept.hh: u.
* sandbox/ballas/refactorization/internal/impl.hh,
* sandbox/ballas/refactorization/internal/force_exact.hh,
* sandbox/ballas/refactorization/internal/piter_base.hh,
* sandbox/ballas/refactorization/internal/psite_base.hh,
* sandbox/ballas/refactorization/point2d_impl.hh: Impl recovering.
concept.hh | 2 -
image2d.hh | 23 ++++++++++----
internal/force_exact.hh | 77 ++++++++++++++++++++++++++++++++++++++++++++++++
internal/impl.hh | 2 -
internal/piter_base.hh | 2 -
internal/psite_base.hh | 2 -
point2d_impl.hh | 11 +++---
test/image2d.cc | 11 ++++++
test/rle.cc | 43 +++++++++++++++++++-------
9 files changed, 146 insertions(+), 27 deletions(-)
Index: sandbox/ballas/refactorization/test/rle.cc
--- sandbox/ballas/refactorization/test/rle.cc (revision 1784)
+++ sandbox/ballas/refactorization/test/rle.cc (working copy)
@@ -5,6 +5,7 @@
//# include <p_run.hh>
//# include <rle_psite.hh>
# include <rle_image.hh>
+# include <image2d.hh>
int main()
@@ -13,20 +14,15 @@
typedef point2d<int> point;
- point p1(5, 5), p2(12, 2), p3(7, 6);
+ point p1(5, 5), p3(12, 6), p2(7, 6);
+ std::cout << "p1: " << p1 << std::endl;
+ std::cout << "p2: " << p2 << std::endl;
+ std::cout << "p3: " << p3 << std::endl;
+
p_run<point> prun1(p1, 5);
p_run<point> prun2(p2, 12);
p_run<point> prun3(p3, 4);
- rle_pset<point> pset;
-// pset.insert(prun1);
-// pset.insert(prun2);
-// pset.insert(prun3);
-
-// rle_pset<point>::piter p(pset);
-// for (p.start(); p.is_valid(); p.next())
-// std::cout << (point) p << std::endl;
-
rle_image<point, int> ima;
ima.insert(prun1, 1);
@@ -35,7 +31,32 @@
rle_image<point, int>::piter p(ima.domain());
for (p.start(); p.is_valid(); p.next())
- std::cout << ima(p) << std::endl;
+ {
+ std::cout << "coord: " << p[0] << ","
+ << p[1] << std::endl;
+ std::cout << "ima: "<< ima(p) << std::endl;
+ }
+
+
+ /// Interoperability
+ std::cout << "------------------------------------------------" << std::endl;
+ int i = 0;
+ point2d<int> p4(12, 17);
+ box2d<int> bb(p1, p4);
+ image2d<int> ima2d(bb);
+ image2d<int>::fwd_piter piter2(ima2d.domain());
+ for (piter2.start(); piter2.is_valid(); piter2.next())
+ {
+ ++i;
+ ima2d(piter2) = i;
+ }
+ for (p.start(); p.is_valid(); p.next())
+ {
+ std::cout << "coord: " << p[0] << ","
+ << p[1] << std::endl;
+ std::cout << "ima: "<< ima(p) << std::endl;
+ std::cout << "ima2d: "<< ima2d(p) << std::endl;
+ }
}
Index: sandbox/ballas/refactorization/test/image2d.cc
--- sandbox/ballas/refactorization/test/image2d.cc (revision 1784)
+++ sandbox/ballas/refactorization/test/image2d.cc (working copy)
@@ -5,13 +5,22 @@
{
using namespace mln;
- point2d<int> pmin(0, 0), pmax(5, 5);
+ point2d<int> pmin(0, 0), pmax(0, 5);
box2d<int> b(pmin, pmax);
image2d<int> ima(b);
ima(pmin) = 5;
+ int i = 0;
image2d<int>::fwd_piter p(ima.domain());
for (p.start(); p.is_valid(); p.next())
+ {
+ ++i;
+ ima(p) = i;
+ }
+
+
+
+ for (p.start(); p.is_valid(); p.next())
std::cout << ima(p) << std::endl;
}
Index: sandbox/ballas/refactorization/image2d.hh
--- sandbox/ballas/refactorization/image2d.hh (revision 1784)
+++ sandbox/ballas/refactorization/image2d.hh (working copy)
@@ -26,6 +26,7 @@
image2d(int nrows, int ncols);
image2d(const box2d<int>& b);
+ ~image2d();
///typedef mln::value::set<T> vset;
// const vset& values() const;
@@ -39,7 +40,7 @@
private:
- T value_;
+ T* values_;
box2d<int> b_;
bool is_ready_;
};
@@ -51,6 +52,8 @@
b_(nrows, ncols),
is_ready_(false)
{
+ values_ = new T[nrows * ncols];
+ is_ready_ = true;
}
template <typename T>
@@ -58,6 +61,15 @@
b_(b),
is_ready_(false)
{
+ values_ = new T[(b.pmax()[0] - b.pmin()[0] + 1) *
+ (b.pmax()[1] - b.pmin()[1] + 1)];
+ is_ready_ = true;
+ }
+
+ template <typename T>
+ image2d<T>::~image2d()
+ {
+ delete[] values_;
}
template <typename T>
@@ -69,17 +81,16 @@
template <typename T>
const T&
- image2d<T>::operator()(const point2d<int>&) const
+ image2d<T>::operator()(const point2d<int>& p) const
{
- return value_;
+ return values_[p[0] * b_.pmax()[1] + p[1]];
}
template <typename T>
T&
- image2d<T>::operator()(const point2d<int>&)
+ image2d<T>::operator()(const point2d<int>& p)
{
- is_ready_ = true;
- return value_;
+ return values_[p[0] * b_.pmax()[1] + p[1]];
}
template <typename T>
Index: sandbox/ballas/refactorization/concept.hh
--- sandbox/ballas/refactorization/concept.hh (revision 1784)
+++ sandbox/ballas/refactorization/concept.hh (working copy)
@@ -67,7 +67,7 @@
};
template <typename E>
- struct Dpsite : public Object<E>
+ struct Dpsite : public Dsite<E>
{
/*
typedef dpsite;
Index: sandbox/ballas/refactorization/internal/impl.hh
--- sandbox/ballas/refactorization/internal/impl.hh (revision 1784)
+++ sandbox/ballas/refactorization/internal/impl.hh (working copy)
@@ -4,7 +4,7 @@
namespace mln
{
- template <typename S>
+ template <typename E, typename S>
struct impl
{
/// empty implementation
Index: sandbox/ballas/refactorization/internal/force_exact.hh
--- sandbox/ballas/refactorization/internal/force_exact.hh (revision 0)
+++ sandbox/ballas/refactorization/internal/force_exact.hh (revision 0)
@@ -0,0 +1,77 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_INTERNAL_FORCE_EXACT_HH
+# define MLN_CORE_INTERNAL_FORCE_EXACT_HH
+
+/*! \file mln/core/internal/force_exact.hh
+ *
+ * \brief Definition of a violent cast for internal use only.
+ *
+ */
+
+
+
+namespace mln
+{
+
+ namespace internal
+ {
+
+ /*! \internal Violent cast.
+ * This cast is an alternative to the mln::exact cast.
+ * It is used for objects that do not derive from
+ * mln::Object.
+ * Warning Do not to use this cast!
+ * see mln::exact
+ */
+ template <typename E, typename T>
+ E& force_exact(const T& ref)
+ {
+ /*
+ static const E exact_obj;
+ static const Type& exact_obj_ref = exact_obj;
+ static const int exact_offset =
+ (const char*)(void*)(&exact_obj_ref)
+ - (const char*)(void*)(&exact_obj);
+ return *(E*)((char*)(this_) - exact_offset);
+ */
+ static const E* exact_obj;
+ static const T& exact_obj_ref = *exact_obj;
+ static const int exact_offset =
+ (const char*)(void*)(&exact_obj_ref)
+ - (const char*)(void*)( exact_obj);
+
+ return *(E*)((char*)(&ref) - exact_offset);
+ }
+
+ } // end of namespace mln::internal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_INTERNAL_FORCE_EXACT_HH
Index: sandbox/ballas/refactorization/internal/piter_base.hh
--- sandbox/ballas/refactorization/internal/piter_base.hh (revision 1784)
+++ sandbox/ballas/refactorization/internal/piter_base.hh (working copy)
@@ -34,7 +34,7 @@
/// Piter base
template <typename E, typename Site, typename Psite>
struct piter_base_ :
- public impl<Site>,
+ public impl<E, Site>,
public piter_base_site_cast<E, Site,
typename mlc_equal(Site, Psite)::eval>
{
Index: sandbox/ballas/refactorization/internal/psite_base.hh
--- sandbox/ballas/refactorization/internal/psite_base.hh (revision 1784)
+++ sandbox/ballas/refactorization/internal/psite_base.hh (working copy)
@@ -11,7 +11,7 @@
template <typename E, typename P>
struct psite_base_ : public Psite<E>,
- public impl<P>
+ public impl<E, P>
{
operator E() const;
Index: sandbox/ballas/refactorization/point2d_impl.hh
--- sandbox/ballas/refactorization/point2d_impl.hh (revision 1784)
+++ sandbox/ballas/refactorization/point2d_impl.hh (working copy)
@@ -2,6 +2,7 @@
# define POINT2D_IMPL_HH_
# include <internal/impl.hh>
+# include <internal/force_exact.hh>
namespace mln
@@ -11,8 +12,8 @@
template <typename C>
struct point2d;
- template <typename C>
- struct impl< point2d<C> >
+ template <typename E, typename C>
+ struct impl< E, point2d<C> >
{
C operator[](unsigned i) const;
@@ -26,11 +27,11 @@
# ifndef MLN_INCLUDE_ONLY
- template <typename C>
+ template <typename E, typename C>
C
- impl< point2d<C> >::operator[] (unsigned i) const
+ impl< E, point2d<C> >::operator[] (unsigned i) const
{
- return this->to_site()[i];
+ return internal::force_exact<E>(*this).to_site()[i];
}
# endif // ! MLN_INCLUDE_ONLY
1
0
Re: [Olena-patches] 1784: Icp legacy. algebra:: now contains types vec, mat and quat.
by Ugo Jardonnet 17 Mar '08
by Ugo Jardonnet 17 Mar '08
17 Mar '08
Ugo Jardonnet wrote:
> https://svn.lrde.epita.fr/svn/oln/trunk/milena
>
>
> Index: ChangeLog
> from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
>
> Icp legacy. algebra:: now contains types vec, mat and quat.
>
> * sandbox/jardonnet/test/icp.cc: New test.
> * sandbox/jardonnet/TODO: Up my TODO.
> * sandbox/jardonnet/registration/quat7.hh: New quat rot + tr.
> * sandbox/jardonnet/registration/cloud.hh: New tools.
> * sandbox/jardonnet/registration/jacobi.hh: New jacobu < nr.
> * sandbox/jardonnet/registration/icp.hh: Up icp.
> * sandbox/jardonnet/registration/projection.hh: New projection.
> * sandbox/jardonnet/registration/quat/misc.hh: New misc.
> * sandbox/jardonnet/registration/quat/interpol.hh: New quat tool.
> * sandbox/jardonnet/registration/quat/rotation.hh: New quat tool.
1
0
17 Mar '08
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
sandbox: psite/site refactorization: add the rle image type.
* sandbox/ballas/refactorization/test/rle.cc: New tests.
* sandbox/ballas/refactorization/p_run.hh,
* sandbox/ballas/refactorization/rle_pset.hh,
* sandbox/ballas/refactorization/rle_psite.hh,
* sandbox/ballas/refactorization/rle_image.hh: New, rle image type.
* sandbox/ballas/refactorization/internal/pset_base.hh,
* sandbox/ballas/refactorization/internal/image_base.hh,
* sandbox/ballas/refactorization/internal/piter_base.hh,
* sandbox/ballas/refactorization/internal/psite_base.hh,
* sandbox/ballas/refactorization/box2d.hh,
* sandbox/ballas/refactorization/point2d.hh: update
box2d.hh | 4
internal/image_base.hh | 9 +
internal/piter_base.hh | 27 ++--
internal/pset_base.hh | 25 +++
internal/psite_base.hh | 20 +--
p_run.hh | 286 +++++++++++++++++++++++++++++++++++++++++++++
point2d.hh | 13 ++
rle_image.hh | 118 ++++++++++++++++++
rle_pset.hh | 308 +++++++++++++++++++++++++++++++++++++++++++++++++
rle_psite.hh | 137 +++++++++++++++++++++
test/rle.cc | 41 ++++++
11 files changed, 962 insertions(+), 26 deletions(-)
Index: sandbox/ballas/refactorization/test/rle.cc
--- sandbox/ballas/refactorization/test/rle.cc (revision 0)
+++ sandbox/ballas/refactorization/test/rle.cc (revision 0)
@@ -0,0 +1,41 @@
+// # include <rle_pset.hh>
+# include <iostream>
+
+# include <point2d.hh>
+//# include <p_run.hh>
+//# include <rle_psite.hh>
+# include <rle_image.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ typedef point2d<int> point;
+
+ point p1(5, 5), p2(12, 2), p3(7, 6);
+ p_run<point> prun1(p1, 5);
+ p_run<point> prun2(p2, 12);
+ p_run<point> prun3(p3, 4);
+
+ rle_pset<point> pset;
+// pset.insert(prun1);
+// pset.insert(prun2);
+// pset.insert(prun3);
+
+// rle_pset<point>::piter p(pset);
+// for (p.start(); p.is_valid(); p.next())
+// std::cout << (point) p << std::endl;
+
+ rle_image<point, int> ima;
+
+ ima.insert(prun1, 1);
+ ima.insert(prun2, 2);
+ ima.insert(prun3, 3);
+
+ rle_image<point, int>::piter p(ima.domain());
+ for (p.start(); p.is_valid(); p.next())
+ std::cout << ima(p) << std::endl;
+
+}
+
Index: sandbox/ballas/refactorization/p_run.hh
--- sandbox/ballas/refactorization/p_run.hh (revision 0)
+++ sandbox/ballas/refactorization/p_run.hh (revision 0)
@@ -0,0 +1,286 @@
+#ifndef P_RUN_HH_
+# define P_RUN_HH_
+
+# include <cstddef>
+# include <iostream>
+# include <internal/pset_base.hh>
+# include <internal/piter_base.hh>
+
+namespace mln
+{
+ // Fwd decls.
+ template <typename P> struct p_run_fwd_piter_;
+
+ template <typename P>
+ class p_run :
+ public internal::pset_base_< P, p_run<P> >
+ {
+ public:
+ typedef P site;
+ typedef P psite;
+
+ typedef p_run_fwd_piter_<P> fwd_piter;
+ typedef p_run_fwd_piter_<P> bkd_piter;
+ typedef fwd_piter piter;
+
+ p_run();
+ p_run(const P& start, std::size_t len);
+ void set_run(const P& start, std::size_t len);
+
+ bool owns_(const P& p) const;
+ std::size_t nsites() const;
+ std::size_t length() const;
+
+ P operator[](unsigned i) const;
+
+ const P& first() const;
+
+ protected:
+ P p_;
+ std::size_t len_;
+ bool is_valid_;
+ };
+
+ template <typename P>
+ std::ostream& operator<<(std::ostream& out, const p_run<P>& pr);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ p_run<P>::p_run()
+ {
+ is_valid_ = false;
+ }
+
+ template <typename P>
+ inline
+ p_run<P>::p_run(const P& start, std::size_t len)
+ : p_(start),
+ len_(len)
+ {
+ assert(len != 0);
+ P p = start;
+// bb_.init();
+// bb_.take(p);
+// p[P::dim - 1] += len - 1;
+// bb_.take(p);
+ is_valid_ = true;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_run<P>::set_run(const P& start, std::size_t len)
+ {
+ assert(len != 0);
+ p_ = start;
+ len_ = len;
+ P p = start;
+// bb_.init();
+// bb_.take(p);
+// p[P::dim - 1] += len - 1;
+// bb_.take(p);
+ is_valid_ = true;
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_run<P>::owns_(const P& p) const
+ {
+ assert(is_valid_);
+ bool res = true;
+ for (int i = P::dim - 2; i >= 0; --i)
+ if (!(res = (res && p[i] == p_[i])))
+ return false;
+ return (p[P::dim - 1] >= p_[P::dim - 1]
+ && p[P::dim - 1] < p_[P::dim - 1] + (signed)len_);
+ }
+
+ template <typename P>
+ inline
+ std::size_t
+ p_run<P>::nsites() const
+ {
+ assert(is_valid_);
+ return len_;
+ }
+
+ template <typename P>
+ inline
+ std::size_t
+ p_run<P>::length() const
+ {
+ assert(is_valid_);
+ return len_;
+ }
+
+ template <typename P>
+ inline
+ P
+ p_run<P>::operator[](unsigned i) const
+ {
+ assert(is_valid_);
+ assert(i < nsites());
+ P p = p_;
+ p[P::dim - 1] += i;
+ return p;
+ }
+
+ template <typename P>
+ inline
+ const P&
+ p_run<P>::first() const
+ {
+ return p_;
+ }
+
+
+ template <typename P>
+ std::ostream&
+ operator<<(std::ostream& out, const p_run<P>& pr)
+ {
+ out << "Run: (" << pr.first() << ", " << pr.length() << ")";
+ return out;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ /// Iterators
+
+ template <typename P>
+ struct p_run_fwd_piter_ :
+ public internal::piter_base_< p_run_fwd_piter_<P>, P, p_run<P> >
+ {
+ typedef p_run_fwd_piter_<P> self_;
+ typedef internal::piter_base_< p_run_fwd_piter_<P>, P, p_run<P> > super_;
+ public:
+
+ typedef P site;
+ typedef p_run<P> psite;
+
+ enum { dim = P::dim };
+
+ p_run_fwd_piter_();
+ p_run_fwd_piter_(const p_run<P>& pr);
+ void assign_run(const p_run<P>& pr);
+
+ const site& to_site() const;
+ const psite& to_psite() const;
+
+ /// operator[] ?
+
+ bool is_valid() const;
+ void invalidate();
+ void start();
+ void next_();
+
+ /// Get the index of the point in the run.
+ unsigned ind() const;
+
+
+ protected:
+ const p_run<P>* run_;
+ bool is_valid_;
+ unsigned i_;
+ P p_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ p_run_fwd_piter_<P>::p_run_fwd_piter_()
+ : run_ (0),
+ is_valid_(false)
+ {
+ }
+
+ template <typename P>
+ inline
+ p_run_fwd_piter_<P>::p_run_fwd_piter_(const p_run<P>& pr)
+ : run_(&pr),
+ is_valid_(false)
+ {
+ }
+
+ template <typename P>
+ inline
+ void
+ p_run_fwd_piter_<P>::assign_run(const p_run<P>& pr)
+ {
+ run_ = ≺
+ is_valid_ = false;
+ }
+
+ template <typename P>
+ inline
+ const typename p_run_fwd_piter_<P>::site&
+ p_run_fwd_piter_<P>::to_site() const
+ {
+ assert(is_valid());
+ return p_;
+ }
+
+ template <typename P>
+ inline
+ const typename p_run_fwd_piter_<P>::psite&
+ p_run_fwd_piter_<P>::to_psite() const
+ {
+ assert(is_valid());
+ return *run_;
+ }
+
+ template <typename P>
+ inline
+ bool
+ p_run_fwd_piter_<P>::is_valid() const
+ {
+ return is_valid_;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_run_fwd_piter_<P>::invalidate()
+ {
+ is_valid_ = false;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_run_fwd_piter_<P>::start()
+ {
+ p_ = run_->first();
+ i_ = 0;
+ is_valid_ = true;
+ }
+
+ template <typename P>
+ inline
+ void
+ p_run_fwd_piter_<P>::next_()
+ {
+ p_[dim - 1]++;
+ ++i_;
+ is_valid_ = p_[dim - 1] - run_->first()[dim - 1] < (signed)run_->length();
+ }
+
+ template <typename P>
+ inline
+ unsigned
+ p_run_fwd_piter_<P>::ind() const
+ {
+ return i_;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // !P_RUN_HH_
Index: sandbox/ballas/refactorization/rle_image.hh
--- sandbox/ballas/refactorization/rle_image.hh (revision 0)
+++ sandbox/ballas/refactorization/rle_image.hh (revision 0)
@@ -0,0 +1,118 @@
+#ifndef RLE_IMAGE_CC_
+# define RLE_IMAGE_CC_
+
+
+# include <rle_pset.hh>
+# include <internal/image_base.hh>
+
+namespace mln
+{
+
+ // note P must be a point
+ template <typename P, typename T>
+ class rle_image :
+ public internal::image_base_<rle_pset<P>, rle_image<P, T> >
+ {
+ public:
+
+ typedef T value;
+ typedef T& lvalue;
+ typedef const T rvalue;
+
+ typedef P site;
+ typedef rle_psite<P> psite;
+
+ typedef rle_pset<P> pset;
+ typedef typename pset::fwd_piter fwd_piter;
+ typedef typename pset::bkd_piter bkd_piter;
+ typedef typename pset::fwd_piter piter;
+
+
+ rle_image();
+
+ void insert(const p_run<P>& pr, T value);
+ rvalue operator() (const rle_psite<P>& psite) const;
+ lvalue operator() (const rle_psite<P>& psite);
+ bool has_data() const;
+
+ bool owns_(const rle_psite<P>& ps) const;
+ const pset& domain() const;
+
+ protected:
+ std::vector<T> values_;
+ rle_pset<P> domain_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P, typename T>
+ inline
+ rle_image<P, T>::rle_image()
+ {
+ }
+
+ template <typename P, typename T>
+ inline
+ bool
+ rle_image<P, T>::has_data() const
+ {
+ return this->values_.size() != 0;
+ }
+
+ template <typename P, typename T>
+ inline
+ void
+ rle_image<P, T>::insert(const p_run<P>& pr, T value)
+ {
+ this->domain_.insert(pr);
+ this->values_.push_back(value);
+ }
+
+ template <typename P, typename T>
+ inline
+ typename rle_image<P, T>::rvalue
+ rle_image<P, T>::operator() (const rle_psite<P>& psite)
+ const
+ {
+ assert(this->owns_(psite));
+ return this->values_[psite.p_of_run()];
+ }
+
+ template <typename P, typename T>
+ inline
+ typename rle_image<P, T>::lvalue
+ rle_image<P, T>::operator() (const rle_psite<P>& psite)
+ {
+ assert(this->owns_(psite));
+ return this->values_[psite.p_of_run()];
+ }
+
+ template <typename P, typename T>
+ inline
+ const typename rle_image<P, T>::pset&
+ rle_image<P, T>::domain() const
+ {
+ return this->domain_;
+ }
+
+ template <typename P, typename T>
+ inline
+ bool
+ rle_image<P, T>::owns_(const rle_psite<P>& ps) const
+ {
+ if (!this->has_data())
+ return false;
+ else
+ return (ps.p_of_run() < this->domain_.nruns() &&
+ ps.p_in_run() < this->domain_[ps.p_of_run()].length() &&
+ this->domain_[ps.p_of_run()][ps.p_in_run()] == ps.to_site());
+ /// FIXME -> to_site....
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // !RLE_IMAGE_CC_
Index: sandbox/ballas/refactorization/rle_psite.hh
--- sandbox/ballas/refactorization/rle_psite.hh (revision 0)
+++ sandbox/ballas/refactorization/rle_psite.hh (revision 0)
@@ -0,0 +1,137 @@
+#ifndef RLE_PSITE_HH_
+# define RLE_PSITE_HH_
+
+
+# include <internal/psite_base.hh>
+
+namespace mln
+{
+
+ template <typename P> class rle_pset;
+
+ template <typename P>
+ class rle_psite : public internal::psite_base_< rle_psite<P>, P>
+ {
+ public:
+
+ enum { dim = 2 };
+
+ typedef P site;
+ typedef rle_psite<P> psite;
+ // FIXME dpsite??
+
+ rle_psite(const rle_pset<P>& pr, unsigned in_run, unsigned of_run);
+
+ P& range_start_();
+ const P& range_start_() const;
+ unsigned p_of_run() const;
+ unsigned& p_of_run();
+ unsigned p_in_run() const;
+ unsigned& p_in_run();
+ const P& to_site() const;
+ void update_();
+
+ protected:
+ const rle_pset<P>& pr_;
+
+ unsigned p_in_run_;
+ unsigned p_of_run_;
+
+ P p_;
+ };
+
+ template <typename P>
+ inline
+ bool operator==(const rle_psite<P>& lhs_, const rle_psite<P>& rhs_);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ void
+ rle_psite<P>::update_()
+ {
+ this->p_.operator= (pr_[p_of_run_][p_in_run_]);
+ }
+
+ template <typename P>
+ inline
+ rle_psite<P>::rle_psite(const rle_pset<P>& pr,
+ unsigned in_run,
+ unsigned of_run)
+ : pr_(pr),
+ p_in_run_(in_run),
+ p_of_run_(of_run),
+ p_(pr[p_of_run_][p_in_run_])
+ {
+ }
+
+ template <typename P>
+ inline
+ const P&
+ rle_psite<P>::range_start_() const
+ {
+ return pr_[p_of_run_].first();
+ }
+
+ template <typename P>
+ inline
+ P&
+ rle_psite<P>::range_start_()
+ {
+ return pr_[p_of_run_].first();
+ }
+
+ template <typename P>
+ inline
+ unsigned
+ rle_psite<P>::p_of_run() const
+ {
+ return p_of_run_;
+ }
+
+ template <typename P>
+ inline
+ unsigned&
+ rle_psite<P>::p_of_run()
+ {
+ return p_of_run_;
+ }
+
+ template <typename P>
+ inline
+ unsigned
+ rle_psite<P>::p_in_run() const
+ {
+ return p_in_run_;
+ }
+
+ template <typename P>
+ inline
+ unsigned&
+ rle_psite<P>::p_in_run()
+ {
+ return p_in_run_;
+ }
+
+ template <typename P>
+ inline
+ const P&
+ rle_psite<P>::to_site() const
+ {
+ return p_;
+ }
+
+ template <typename P>
+ inline
+ bool operator==(const rle_psite<P>& lhs_, const rle_psite<P>& rhs_)
+ {
+ return lhs_.p_of_run_ == lhs_.p_of_run && lhs_.p_in_run_ == rhs_.p_in_run_;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+# include <rle_psite.hh>
+
+#endif // !RLE_PSITE_HH_
Index: sandbox/ballas/refactorization/rle_pset.hh
--- sandbox/ballas/refactorization/rle_pset.hh (revision 0)
+++ sandbox/ballas/refactorization/rle_pset.hh (revision 0)
@@ -0,0 +1,308 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef RLE_PSET_HH_
+# define RLE_PSET_HH_
+
+
+
+# include <internal/pset_base.hh>
+# include <internal/psite_base.hh>
+
+# include <rle_psite.hh>
+# include <p_run.hh>
+
+# include <vector>
+# include <utility>
+
+
+
+namespace mln
+{
+
+ // Forward declaration
+ template <typename P> struct rle_pset_fwd_piter_;
+
+ template <typename P>
+ class rle_pset :
+ public internal::pset_base_< rle_psite<P>, rle_pset<P> >
+ {
+ typedef std::vector< p_run<P> >container;
+ public:
+ typedef rle_pset_fwd_piter_<P> fwd_piter;
+ typedef fwd_piter bkd_piter;
+ typedef fwd_piter piter;
+
+ rle_pset();
+
+ /// Test is \p p belongs to this point set.
+ bool owns_(const rle_psite<P>& ps) const;
+
+ typename std::size_t nsites() const;
+ void insert(const p_run<P>& pr);
+
+
+ unsigned nruns() const;
+ unsigned range_len_(const P& p) const;
+
+ const p_run<P>& operator[](unsigned i) const;
+
+ const container& con() const;
+
+ protected:
+
+ typename std::size_t nsites_;
+ container con_;
+
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ rle_pset<P>::rle_pset() :
+ nsites_(0)
+ {
+ }
+
+ template <typename P>
+ inline
+ bool
+ rle_pset<P>::owns_(const rle_psite<P>& ps) const
+ {
+ if (ps.p_of_run() < nruns()
+ && ps.p_in_run() < con_[ps.p_of_run()].length())
+ return (ps == con_[ps.p_of_run()][ps.p_in_run()]);
+ else
+ return false;
+ }
+
+ template <typename P>
+ inline
+ typename std::size_t
+ rle_pset<P>::nsites() const
+ {
+ return nsites_;
+ }
+
+ template <typename P>
+ inline
+ void
+ rle_pset<P>::insert(const p_run<P>& pr)
+ {
+ /// This doesn't deal with recovering pset.
+ con_.push_back(pr);
+ nsites_ += pr.nsites();
+ }
+
+ template <typename P>
+ inline
+ unsigned
+ rle_pset<P>::nruns() const
+ {
+ return con_.size();
+ }
+
+ template <typename P>
+ inline
+ unsigned
+ rle_pset<P>::range_len_(const P& p) const
+ {
+ unsigned i;
+ for (i = 0; i < con_.size(); ++i)
+ {
+ if (con_[i].first == p)
+ return con_[i].nsites();
+ }
+
+ assert(i < con_.size());
+ return (con_.size());
+ }
+
+ template <typename P>
+ inline
+ const p_run<P>&
+ rle_pset<P>::operator[](unsigned i) const
+ {
+ return con_[i];
+ }
+
+ template <typename P>
+ const typename rle_pset<P>::container&
+ rle_pset<P>::con() const
+ {
+ return con_;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ template <typename P, typename E>
+ class rle_pset_piter_ : public internal::piter_base_<E, P, rle_psite<P> >
+ {
+ public:
+ typedef P site;
+ typedef rle_psite<P> psite;
+
+ const P& to_site() const;
+
+ protected:
+ P p_;
+ const rle_pset<P>& con_;
+ rle_pset_piter_(const rle_pset<P>& pset);
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P, typename E>
+ inline
+ rle_pset_piter_<P, E>::rle_pset_piter_(const rle_pset<P>& pset) :
+ con_(pset)
+ {
+ }
+
+ template <typename P, typename E>
+ inline
+ const P&
+ rle_pset_piter_<P, E>::to_site() const
+ {
+ assert(exact(this)->is_valid());
+ return p_;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ template <typename P>
+ class rle_pset_fwd_piter_ :
+ public rle_pset_piter_<P, rle_pset_fwd_piter_<P> >
+ {
+ typedef rle_pset_piter_<P, rle_pset_fwd_piter_<P> > super;
+ public:
+
+ rle_pset_fwd_piter_(const rle_pset<P>& pset);
+
+ bool is_valid() const;
+ void invalidate();
+ void start();
+ void next_();
+
+ const rle_psite<P>& to_psite() const;
+
+ protected:
+ void update_();
+
+ unsigned i_;
+ p_run_fwd_piter_<P> it_;
+ rle_psite<P> ps_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ rle_pset_fwd_piter_<P>::rle_pset_fwd_piter_(const rle_pset<P>& pset) :
+ super(pset),
+ ps_(pset, 0, 0)
+ {
+ invalidate();
+ }
+
+ template <typename P>
+ inline
+ bool
+ rle_pset_fwd_piter_<P>::is_valid() const
+ {
+ return i_ < this->con_.nruns();
+ }
+
+ template <typename P>
+ inline
+ void
+ rle_pset_fwd_piter_<P>::invalidate()
+ {
+ i_ = this->con_.nruns();
+ }
+
+ template <typename P>
+ inline
+ void
+ rle_pset_fwd_piter_<P>::start()
+ {
+ i_ = 0;
+ it_.assign_run(this->con_[i_]);
+ it_.start();
+ this->p_ = it_;
+ this->update_();
+ }
+
+ template <typename P>
+ inline
+ void
+ rle_pset_fwd_piter_<P>::next_()
+ {
+ assert(this->is_valid());
+ it_.next();
+ if (!it_.is_valid())
+ {
+ ++i_;
+ if (is_valid())
+ {
+ it_.assign_run(this->con_[i_]);
+ it_.start();
+ }
+ else
+ return;
+ }
+ this->update_();
+ }
+
+ template <typename P>
+ void
+ rle_pset_fwd_piter_<P>::update_()
+ {
+ this->p_ = it_;
+ ps_.p_in_run() = it_.ind();
+ ps_.p_of_run() = i_;
+ this->ps_.update_();
+ }
+
+ template <typename P>
+ const rle_psite<P>&
+ rle_pset_fwd_piter_<P>::to_psite() const
+ {
+ return ps_;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+} // end of namespace mln
+
+
+#endif // !RLE_PSET_HH_
Index: sandbox/ballas/refactorization/internal/pset_base.hh
--- sandbox/ballas/refactorization/internal/pset_base.hh (revision 1782)
+++ sandbox/ballas/refactorization/internal/pset_base.hh (working copy)
@@ -3,6 +3,7 @@
# include <concept.hh>
+# include <exact.hh>
namespace mln
{
@@ -15,9 +16,33 @@
template <typename P, typename E>
struct pset_base_ : public Pset<E>
{
+ /// !!!
typedef typename P::site site;
typedef P psite;
+
+
+ bool has(const P& ps) const;
+ protected:
+ pset_base_();
};
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P, typename E>
+ pset_base_<P, E>::pset_base_()
+ {
+ }
+
+ template <typename P, typename E>
+ bool
+ pset_base_<P, E>::has(const P& ps) const
+ {
+ return exact(this)->owns_(ps);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
}
}
Index: sandbox/ballas/refactorization/internal/image_base.hh
--- sandbox/ballas/refactorization/internal/image_base.hh (revision 1782)
+++ sandbox/ballas/refactorization/internal/image_base.hh (working copy)
@@ -19,7 +19,7 @@
typedef typename S::fwd_piter fwd_piter;
typedef typename S::bkd_piter bkd_piter;
- bool has(const psite&) const;
+ bool has(const psite& ps) const;
protected:
image_base_();
@@ -34,6 +34,13 @@
{
}
+ template <typename S, typename E>
+ bool
+ image_base_<S, E>::has(const psite& ps) const
+ {
+ return exact(this)->owns_(ps);
+ }
+
# endif // ! MLN_INCLUDE_ONLY
}
Index: sandbox/ballas/refactorization/internal/piter_base.hh
--- sandbox/ballas/refactorization/internal/piter_base.hh (revision 1782)
+++ sandbox/ballas/refactorization/internal/piter_base.hh (working copy)
@@ -2,6 +2,8 @@
# define INTERNAL_PITER_BASE_HH_
# include <concept.hh>
+# include <point2d_impl.hh>
+
# include <exact.hh>
# include <metal/bool.hh>
# include <metal/equal.hh>
@@ -13,40 +15,39 @@
{
/// fwd declaration
- template <typename E, typename B>
+ template <typename E, typename Site, typename B>
struct piter_base_site_cast;
/// Psite = Site
- template <typename E>
- struct piter_base_site_cast<E, metal::true_> : public Piter<E>
+ template <typename E, typename Site>
+ struct piter_base_site_cast<E, Site, metal::true_> : public Piter<E>
{
};
/// Psite != site
- template <typename E>
- struct piter_base_site_cast<E, metal::false_> : public Piter<E>
+ template <typename E, typename Site>
+ struct piter_base_site_cast<E, Site, metal::false_> : public Piter<E>
{
- operator typename E::site() const;
+ operator Site() const;
};
/// Piter base
template <typename E, typename Site, typename Psite>
struct piter_base_ :
- public piter_base_site_cast<E,
- typename mlc_equal(Site,
- Psite)::eval>
+ public impl<Site>,
+ public piter_base_site_cast<E, Site,
+ typename mlc_equal(Site, Psite)::eval>
{
operator Psite () const;
protected:
piter_base_();
-
};
# ifndef MLN_INCLUDE_ONLY
- template <typename E>
- piter_base_site_cast<E, metal::false_>::operator typename E::site () const
+ template <typename E, typename Site>
+ piter_base_site_cast<E, Site, metal::false_>::operator Site () const
{
return exact(this)->to_site();
}
@@ -55,7 +56,7 @@
template <typename E, typename Site, typename Psite>
piter_base_<E, Site, Psite>::operator Psite () const
{
- return exact(this)->to_site();
+ return exact(this)->to_psite();
}
Index: sandbox/ballas/refactorization/internal/psite_base.hh
--- sandbox/ballas/refactorization/internal/psite_base.hh (revision 1782)
+++ sandbox/ballas/refactorization/internal/psite_base.hh (working copy)
@@ -9,26 +9,26 @@
namespace internal
{
- template <typename E>
- struct psite_base : public Psite<E>,
- public impl<typename E::site>
+ template <typename E, typename P>
+ struct psite_base_ : public Psite<E>,
+ public impl<P>
{
- operator typename E::psite () const;
+ operator E() const;
protected:
- psite_base();
+ psite_base_();
};
# ifndef MLN_INCLUDE_ONLY
- template <typename E>
- psite_base<E>::operator typename E::psite () const
+ template <typename E, typename P>
+ psite_base_<E, P>::operator E() const
{
- return exact(this)->to_site();
+ return exact(this)->to_psite();
}
- template <typename E>
- psite_base<E>::psite_base()
+ template <typename E, typename P>
+ psite_base_<E, P>::psite_base_()
{
}
Index: sandbox/ballas/refactorization/box2d.hh
--- sandbox/ballas/refactorization/box2d.hh (revision 1782)
+++ sandbox/ballas/refactorization/box2d.hh (working copy)
@@ -36,7 +36,7 @@
box2d();
box2d(const site& pmin, const site& pmax);
- bool has(const site& p) const;
+ bool owns_(const site& p) const;
protected:
point2d<C> pmin_, pmax_;
@@ -98,7 +98,7 @@
template <typename C>
inline
bool
- box2d<C>::has(const site& p) const
+ box2d<C>::owns_(const site& p) const
{
for (unsigned i = 0; i < C::dim; ++i)
if (p[i] < pmin_[i] || p[i] > pmax_[i])
Index: sandbox/ballas/refactorization/point2d.hh
--- sandbox/ballas/refactorization/point2d.hh (revision 1782)
+++ sandbox/ballas/refactorization/point2d.hh (working copy)
@@ -38,6 +38,7 @@
enum { dim = 2 };
typedef dpoint2d<C> dpoint;
+ typedef point2d<C> site;
typedef C coord;
@@ -51,6 +52,7 @@
point2d<C>& operator+=(const dpoint& dp);
point2d<C>& operator-=(const dpoint& dp);
+ point2d<C>& operator=(const point2d<C>& p);
protected:
std::vector<C> coord_;
@@ -189,6 +191,17 @@
}
template <typename C>
+ inline
+ point2d<C>&
+ point2d<C>::operator=(const point2d<C>& p)
+ {
+ if (&p != this)
+ for (unsigned i = 0; i < dim; ++i)
+ this->coord_[i] = p.coord_[i];
+ return *this;
+ }
+
+ template <typename C>
std::ostream& operator<<(std::ostream& ostr, const point2d<C>& p)
{
return ostr << "(" << p[0] << "," << p[1] << ")";
1
0
URL: https://svn.lrde.epita.fr/svn/scool/trunk
ChangeLog:
2008-03-13 Maxime van Noppen <yabo(a)lrde.epita.fr>
Add tests and refs
* input/concept_1.scl: New.
* input/sample_5.scl: New.
* parser/sample_5.ref: New.
* parser/sample_container.ref: New.
* parser/var_decl_7.ref: New.
* transformer/class_dec.ref: New.
* transformer/consinit.ref: New.
* transformer/funcall.ref: New.
* transformer/funcall_no-args.ref: New.
* transformer/function.ref: New.
* transformer/function_call_1.ref: New.
* transformer/function_call_2.ref: New.
* transformer/function_decl_2.ref: New.
* transformer/fundec.ref: New.
* transformer/guard.ref: New.
* transformer/manydec.ref: New.
* transformer/sample_5.ref: New.
* transformer/sample_container.ref: New.
* transformer/vardec.ref: New.
* transformer/varinit.ref: New.
* transformer/wiki1.ref: New.
* transformer/wiki3.ref: New.
input/concept_1.scl | 6 ++++++
input/sample_5.scl | 4 ++++
parser/sample_5.ref | 1 +
parser/sample_container.ref | 1 +
parser/var_decl_7.ref | 1 +
transformer/class_dec.ref | 15 +++++++++++++++
transformer/consinit.ref | 1 +
transformer/funcall.ref | 4 ++++
transformer/funcall_no-args.ref | 4 ++++
transformer/function.ref | 4 ++++
transformer/function_call_1.ref | 4 ++++
transformer/function_call_2.ref | 4 ++++
transformer/function_decl_2.ref | 4 ++++
transformer/fundec.ref | 3 +++
transformer/guard.ref | 4 ++++
transformer/manydec.ref | 3 +++
transformer/sample_5.ref | 4 ++++
transformer/sample_container.ref | 19 +++++++++++++++++++
transformer/vardec.ref | 1 +
transformer/varinit.ref | 1 +
transformer/wiki1.ref | 7 +++++++
transformer/wiki3.ref | 8 ++++++++
22 files changed, 103 insertions(+)
Index: trunk/tests/input/sample_5.scl
===================================================================
--- trunk/tests/input/sample_5.scl (revision 0)
+++ trunk/tests/input/sample_5.scl (revision 53)
@@ -0,0 +1,4 @@
+sqrt : (arg : float) -> float =
+{
+ -> |[ std::sqrt(arg); ]|;
+}
Index: trunk/tests/input/concept_1.scl
===================================================================
--- trunk/tests/input/concept_1.scl (revision 0)
+++ trunk/tests/input/concept_1.scl (revision 53)
@@ -0,0 +1,6 @@
+box : concept =
+{
+ value : type;
+
+ decl get_value : () -> value;
+}
Index: trunk/tests/transformer/sample_5.ref
===================================================================
--- trunk/tests/transformer/sample_5.ref (revision 0)
+++ trunk/tests/transformer/sample_5.ref (revision 53)
@@ -0,0 +1,4 @@
+float sqrt(float arg)
+{
+ return std::sqrt(arg);
+}
Index: trunk/tests/transformer/funcall_no-args.ref
===================================================================
--- trunk/tests/transformer/funcall_no-args.ref (revision 0)
+++ trunk/tests/transformer/funcall_no-args.ref (revision 53)
@@ -0,0 +1,4 @@
+int doit()
+{
+ return foo();
+}
Index: trunk/tests/transformer/class_dec.ref
===================================================================
--- trunk/tests/transformer/class_dec.ref (revision 0)
+++ trunk/tests/transformer/class_dec.ref (revision 53)
@@ -0,0 +1,15 @@
+// Class point
+
+template < typename E >
+class point
+{
+ public:
+ int x()
+ {
+ return x;
+ }
+
+ private:
+ int x;
+ int y;
+};
Index: trunk/tests/transformer/manydec.ref
===================================================================
--- trunk/tests/transformer/manydec.ref (revision 0)
+++ trunk/tests/transformer/manydec.ref (revision 53)
@@ -0,0 +1,3 @@
+const int answer = 42;
+int i;
+int j = i;
Index: trunk/tests/transformer/function.ref
===================================================================
--- trunk/tests/transformer/function.ref (revision 0)
+++ trunk/tests/transformer/function.ref (revision 53)
@@ -0,0 +1,4 @@
+int answer()
+{
+ return 42;
+}
Index: trunk/tests/transformer/consinit.ref
===================================================================
--- trunk/tests/transformer/consinit.ref (revision 0)
+++ trunk/tests/transformer/consinit.ref (revision 53)
@@ -0,0 +1 @@
+const int i = 3;
Index: trunk/tests/transformer/function_decl_2.ref
===================================================================
--- trunk/tests/transformer/function_decl_2.ref (revision 0)
+++ trunk/tests/transformer/function_decl_2.ref (revision 53)
@@ -0,0 +1,4 @@
+template < int i >
+int f()
+{
+}
Index: trunk/tests/transformer/function_call_1.ref
===================================================================
--- trunk/tests/transformer/function_call_1.ref (revision 0)
+++ trunk/tests/transformer/function_call_1.ref (revision 53)
@@ -0,0 +1,4 @@
+int doit()
+{
+ return foo();
+}
Index: trunk/tests/transformer/function_call_2.ref
===================================================================
--- trunk/tests/transformer/function_call_2.ref (revision 0)
+++ trunk/tests/transformer/function_call_2.ref (revision 53)
@@ -0,0 +1,4 @@
+int doit()
+{
+ return foo(bar, baz);
+}
Index: trunk/tests/transformer/fundec.ref
===================================================================
--- trunk/tests/transformer/fundec.ref (revision 0)
+++ trunk/tests/transformer/fundec.ref (revision 53)
@@ -0,0 +1,3 @@
+bool f(int a, int b)
+{
+}
Index: trunk/tests/transformer/vardec.ref
===================================================================
--- trunk/tests/transformer/vardec.ref (revision 0)
+++ trunk/tests/transformer/vardec.ref (revision 53)
@@ -0,0 +1 @@
+int i;
Index: trunk/tests/transformer/varinit.ref
===================================================================
--- trunk/tests/transformer/varinit.ref (revision 0)
+++ trunk/tests/transformer/varinit.ref (revision 53)
@@ -0,0 +1 @@
+int i = 42;
Index: trunk/tests/transformer/sample_container.ref
===================================================================
--- trunk/tests/transformer/sample_container.ref (revision 0)
+++ trunk/tests/transformer/sample_container.ref (revision 53)
@@ -0,0 +1,19 @@
+// Class Container
+
+template < typename E >
+class Container
+{
+ public:
+ type value_type;
+ type iterator;
+ type const_iterator;
+ type reference;
+ type const_reference;
+ type size_type;
+ iterator begin();
+ const_iterator begin();
+ iterator end();
+ const_iterator end();
+ size_type size();
+ bool empty();
+};
Index: trunk/tests/transformer/funcall.ref
===================================================================
--- trunk/tests/transformer/funcall.ref (revision 0)
+++ trunk/tests/transformer/funcall.ref (revision 53)
@@ -0,0 +1,4 @@
+int doit()
+{
+ return foo(bar, baz);
+}
Index: trunk/tests/transformer/wiki1.ref
===================================================================
--- trunk/tests/transformer/wiki1.ref (revision 0)
+++ trunk/tests/transformer/wiki1.ref (revision 53)
@@ -0,0 +1,7 @@
+void f()
+{
+ const int16 i = 3;
+ i = 4;
+ int16 j = 3;
+ j = 4;
+}
Index: trunk/tests/transformer/wiki3.ref
===================================================================
--- trunk/tests/transformer/wiki3.ref (revision 0)
+++ trunk/tests/transformer/wiki3.ref (revision 53)
@@ -0,0 +1,8 @@
+void f()
+{
+ int i;
+ int j;
+ i = 0;
+ j = i;
+ i = j + i;
+}
Index: trunk/tests/transformer/guard.ref
===================================================================
--- trunk/tests/transformer/guard.ref (revision 0)
+++ trunk/tests/transformer/guard.ref (revision 53)
@@ -0,0 +1,4 @@
+template < int i >
+int f()
+{
+}
Index: trunk/tests/parser/sample_5.ref
===================================================================
--- trunk/tests/parser/sample_5.ref (revision 0)
+++ trunk/tests/parser/sample_5.ref (revision 53)
@@ -0,0 +1 @@
+Program([FunDec([],"sqrt",[("arg",Var("float"))],Var("float"),[Return(Cxx("std::sqrt(arg);"))])])
Index: trunk/tests/parser/var_decl_7.ref
===================================================================
--- trunk/tests/parser/var_decl_7.ref (revision 0)
+++ trunk/tests/parser/var_decl_7.ref (revision 53)
@@ -0,0 +1 @@
+Program([VarDec([],"a",StaticFunCall("test",[Var("int")]))])
Index: trunk/tests/parser/sample_container.ref
===================================================================
--- trunk/tests/parser/sample_container.ref (revision 0)
+++ trunk/tests/parser/sample_container.ref (revision 53)
@@ -0,0 +1 @@
+Program([ConstDec([],"Container",Class,ClassVal([Accessblock(Public,[ConstDec([],"value_type",None,Var("type")),ConstDec([],"iterator",None,Var("type")),ConstDec([],"const_iterator",None,Var("type")),ConstDec([],"reference",None,Var("type")),ConstDec([],"const_reference",None,Var("type")),ConstDec([],"size_type",None,Var("type")),ConstDec(["decl"],"begin",None,FunType([],Var("iterator"))),ConstDec(["decl"],"begin",Some("const"),FunType([],Var("const_iterator"))),ConstDec(["decl"],"end",None,FunType([],Var("iterator"))),ConstDec(["decl"],"end",Some("const"),FunType([],Var("const_iterator"))),ConstDec(["decl"],"size",Some("const"),FunType([],Var("size_type"))),ConstDec(["decl"],"empty",Some("const"),FunType([],Var("bool")))])]))])
--
\__/ \__/
(00) Maxime `yabo` van Noppen (00)
___) \ Epita 2009 / (___
(_____/ Président de Prologin \_____)
2
1
URL: https://svn.lrde.epita.fr/svn/scool/trunk
ChangeLog:
2008-03-13 Maxime van Noppen <yabo(a)lrde.epita.fr>
Start work on concepts
* scl-syn/Concept.sdf: New.
* scl-syn/Decl.sdf,
* scl-syn/Lexical.sdf,
* scl-syn/Makefile.am: Modify grammar to parse concepts.
Concept.sdf | 9 +++++++++
Decl.sdf | 3 ++-
Lexical.sdf | 1 +
Makefile.am | 2 +-
4 files changed, 13 insertions(+), 2 deletions(-)
Index: trunk/src/scl-syn/Decl.sdf
===================================================================
--- trunk/src/scl-syn/Decl.sdf (revision 53)
+++ trunk/src/scl-syn/Decl.sdf (revision 54)
@@ -1,7 +1,7 @@
module Decl
imports
- Lexical Type Stm
+ Lexical Type Stm Concept
exports
sorts Decl
@@ -9,6 +9,7 @@
Cxx -> Decl
+ Concept -> Decl
Qualifier* "var" Id ":" Type ";" -> Decl
{cons("VarDec")}
Index: trunk/src/scl-syn/Concept.sdf
===================================================================
--- trunk/src/scl-syn/Concept.sdf (revision 0)
+++ trunk/src/scl-syn/Concept.sdf (revision 54)
@@ -0,0 +1,9 @@
+module Concept
+
+imports
+ Lexical Decl
+
+exports
+ sorts Concept
+ context-free syntax
+ Id ":" "concept" "=" "{" Decl* "}" -> Concept {cons("Concept")}
Index: trunk/src/scl-syn/Makefile.am
===================================================================
--- trunk/src/scl-syn/Makefile.am (revision 53)
+++ trunk/src/scl-syn/Makefile.am (revision 54)
@@ -1,7 +1,7 @@
# Makefile.am -*-Makefile-*-
MODULES = Scool
-SDFS = Class Decl Exp ExpOrType Lexical Scool Stm Type
+SDFS = Class Concept Decl Exp ExpOrType Lexical Scool Stm Type
include $(top_srcdir)/config/Makefile.xt
-include $(MODULES:=.dep)
Index: trunk/src/scl-syn/Lexical.sdf
===================================================================
--- trunk/src/scl-syn/Lexical.sdf (revision 53)
+++ trunk/src/scl-syn/Lexical.sdf (revision 54)
@@ -16,6 +16,7 @@
[\ \t\n] -> LAYOUT
~[\ ]~[\]\|]*~[\ ] -> RawCxx
"class" -> Id {reject}
+ "concept" -> Id {reject}
BlockComment -> LAYOUT
--
\__/ \__/
(00) Maxime `yabo` van Noppen (00)
___) \ Epita 2009 / (___
(_____/ Président de Prologin \_____)
1
0
URL: https://svn.lrde.epita.fr/svn/scool/trunk
ChangeLog:
2008-03-12 Maxime van Noppen <yabo(a)lrde.epita.fr>
Improve verbatim C++ handling
* pp-cxx/CxxExp.str: Handle more Cxx constructors.
* pp-cxx/CxxStm.str: Fix the double semicolon problem
when inserting verbatim C++.
* pp-cxx/CxxDecl.str: Remove a FIXME comment.
* scoolt/Exp.str: Improve verbatim C++ handling.
pp-cxx/CxxDecl.str | 2 --
pp-cxx/CxxExp.str | 33 +++++++++++++++++++++------------
pp-cxx/CxxStm.str | 12 +++++++++++-
scoolt/Decl.str | 1 +
scoolt/Exp.str | 10 +++++++++-
5 files changed, 42 insertions(+), 16 deletions(-)
Index: trunk/src/pp-cxx/CxxFun.str
===================================================================
Index: trunk/src/pp-cxx/CxxExp.str
===================================================================
--- trunk/src/pp-cxx/CxxExp.str (revision 51)
+++ trunk/src/pp-cxx/CxxExp.str (revision 52)
@@ -4,8 +4,14 @@
rules
- CxxExpToAbox:
- CxxInt(i) -> S(i)
+ CxxArgListToStr:
+ [ e | [h|tail] ] -> <concat-strings> [ e, ", ", <CxxArgListToStr> [h|tail] ]
+
+ CxxArgListToStr:
+ [e | []] -> e
+
+ CxxArgListToStr:
+ [] -> ""
CxxExpToStr:
CxxInt(i) -> i
@@ -14,18 +20,21 @@
CxxSum(e1, e2) -> <concat-strings> [<CxxExpToStr> e1, " + ", <CxxExpToStr> e2]
CxxExpToStr:
+ CxxKeyword(idf, exp) -> <concat-strings> [idf, " ", <CxxExpToStr> exp]
+
+ CxxExpToStr:
+ CxxAffect(idf, exp) -> <concat-strings> [idf, " = ", <CxxExpToStr> exp]
+
+ CxxExpToStr:
+ CxxFunCall(idf, args) -> <concat-strings> [ idf, "(", <CxxArgListToStr> args, ")" ]
+
+ CxxExpToStr:
+ CxxProgram(exp) -> exp
+
+ CxxExpToStr:
x -> x
where <is-string> x
- /*
- * Handle the CxxKeyword ctor.
- * TODO: Generalize the type of exp.
- */
CxxExpToAbox:
- CxxKeyword(idf, exp) -> S(<concat-strings> [idf, " ", <CxxExpToStr> exp, ";"])
+ x -> S(<CxxExpToStr> x)
- CxxExpToAbox:
- CxxAffect(idf, exp) -> S(<concat-strings> [idf, " = ", <CxxExpToStr> exp, ";"])
-
- CxxExpToAbox:
- x -> S(x)
Index: trunk/src/pp-cxx/CxxStm.str
===================================================================
--- trunk/src/pp-cxx/CxxStm.str (revision 51)
+++ trunk/src/pp-cxx/CxxStm.str (revision 52)
@@ -5,4 +5,14 @@
rules
CxxStmToAbox:
- CxxExpStm(e) -> <CxxExpToAbox> e
+ CxxExpStm(e) -> H hs=0 [ ~<CxxExpToAbox> e ~<Semicolon> e]
+
+ // Don't add an extra ';' to verbatim C++ that we insert.
+ // As said on https://trac.lrde.org/scool/wiki/SCOOL/Specs/Misc the C++ inserted
+ // must be valid and so contain an ending ';'
+ Semicolon:
+ _#([_, CxxProgram(exp)]) -> S("")
+
+ Semicolon:
+ _#([_, _]) -> S(";")
+
Index: trunk/src/pp-cxx/CxxDecl.str
===================================================================
--- trunk/src/pp-cxx/CxxDecl.str (revision 51)
+++ trunk/src/pp-cxx/CxxDecl.str (revision 52)
@@ -45,8 +45,6 @@
CxxComment(txt) ->
H hs=1 [ "//" ~S(txt) ]
-// FIXME: MERGE!!!
-
CxxBodyToAbox:
CxxPublic(b) -> V is=2 [ "public:" V [ ~*<map(CxxTopLevelToAbox)> b ] ]
Index: trunk/src/scoolt/Exp.str
===================================================================
--- trunk/src/scoolt/Exp.str (revision 51)
+++ trunk/src/scoolt/Exp.str (revision 52)
@@ -8,6 +8,9 @@
Int(i) -> CxxInt(i)
ExpToCxx:
+ String(s) -> <un-double-quote> s
+
+ ExpToCxx:
Var(v) -> v
ExpToCxx:
@@ -18,4 +21,9 @@
where <debug> e
ExpToCxx:
- Cxx(s) -> s
+ Cxx(s) -> CxxProgram(s)
+
+ ExpToCxx:
+ FunCall(name, args) -> CxxFunCall(name, <map (ExpToCxx)> args)
+
+
Index: trunk/src/scoolt/Decl.str
===================================================================
--- trunk/src/scoolt/Decl.str (revision 51)
+++ trunk/src/scoolt/Decl.str (revision 52)
@@ -197,6 +197,7 @@
! (CxxType(t), idf)
end>
+
ArgDefToCxx:
(idf, t) -> (<TypeToConstRefCxx <+ TypeToCxx> t, idf)
//(idf, t) -> (<TypeToCxx; try(CxxTypeToStc(|CxxType(p-idf)))> t, idf)
--
\__/ \__/
(00) Maxime `yabo` van Noppen (00)
___) \ Epita 2009 / (___
(_____/ Président de Prologin \_____)
1
0
12 Mar '08
URL: https://svn.lrde.epita.fr/svn/scool/trunk
ChangeLog:
2008-03-12 Maxime van Noppen <yabo(a)lrde.epita.fr>
Update tests regarding to the Olena to Milena switch
* mouline.sh: Add summary feature.
* transformer/command: Exit with the good exit value.
* transformer/class_decl_1.ref,
* transformer/class_decl_2.ref,
* transformer/class_decl_3.ref,
* transformer/class_decl_inh.ref,
* transformer/class_decl_inh_abst.ref,
* transformer/class_decl_inh_fin.ref,
* transformer/class_members_1.ref,
* transformer/class_predecl.ref,
* transformer/class_predecl_inh.ref,
* transformer/class_template_1.ref,
* transformer/class_template_2.ref,
* transformer/cons_decl_1.ref,
* transformer/cons_decl_2.ref,
* transformer/empty.ref,
* transformer/function_decl_1.ref,
* transformer/function_decl_10.ref,
* transformer/function_decl_3.ref,
* transformer/function_decl_4.ref,
* transformer/function_decl_5.ref,
* transformer/function_decl_6.ref,
* transformer/function_decl_7.ref,
* transformer/function_decl_8.ref,
* transformer/function_decl_9.ref,
* transformer/function_return_1.ref,
* transformer/function_return_2.ref,
* transformer/function_return_3.ref,
* transformer/sample_1.ref,
* transformer/sample_3.ref,
* transformer/sample_4.ref,
* transformer/var_decl_1.ref,
* transformer/var_decl_2.ref,
* transformer/var_decl_3.ref,
* transformer/var_decl_5.ref,
* transformer/var_decl_6.ref: Update ref.
mouline.sh | 28 +++++++++++++++++++++++++++-
transformer/class_decl_1.ref | 9 ++-------
transformer/class_decl_2.ref | 9 ++-------
transformer/class_decl_3.ref | 9 ++-------
transformer/class_decl_inh.ref | 15 ++++-----------
transformer/class_decl_inh_abst.ref | 13 ++++---------
transformer/class_decl_inh_fin.ref | 19 +++++--------------
transformer/class_members_1.ref | 9 ++-------
transformer/class_predecl.ref | 5 +----
transformer/class_predecl_inh.ref | 3 ---
transformer/class_template_1.ref | 3 ---
transformer/class_template_2.ref | 3 ---
transformer/command | 25 +++++++++++++++++++------
transformer/cons_decl_1.ref | 3 ---
transformer/cons_decl_2.ref | 3 ---
transformer/empty.ref | 3 +--
transformer/function_decl_1.ref | 3 ---
transformer/function_decl_10.ref | 3 ---
transformer/function_decl_3.ref | 3 ---
transformer/function_decl_4.ref | 3 ---
transformer/function_decl_5.ref | 3 ---
transformer/function_decl_6.ref | 3 ---
transformer/function_decl_7.ref | 3 ---
transformer/function_decl_8.ref | 3 ---
transformer/function_decl_9.ref | 3 ---
transformer/function_return_1.ref | 3 ---
transformer/function_return_2.ref | 3 ---
transformer/function_return_3.ref | 3 ---
transformer/sample_1.ref | 3 ---
transformer/sample_3.ref | 3 ---
transformer/sample_4.ref | 5 +----
transformer/var_decl_1.ref | 3 ---
transformer/var_decl_2.ref | 3 ---
transformer/var_decl_3.ref | 3 ---
transformer/var_decl_5.ref | 3 ---
transformer/var_decl_6.ref | 3 ---
36 files changed, 70 insertions(+), 151 deletions(-)
Index: trunk/tests/mouline.sh
===================================================================
--- trunk/tests/mouline.sh (revision 50)
+++ trunk/tests/mouline.sh (revision 51)
@@ -12,6 +12,10 @@
print_diff=0
gen_ref=0
+nb_pass=0
+nb_skip=0
+nb_fail=0
+
align ()
{
echo -e -n "\033[$1G"
@@ -36,14 +40,25 @@
if [ $gen_ref -eq 1 ]; then
$cmd $input > $ref
+ exit_val=$?
+ if [ $exit_val -ne 0 ]; then
+ echo -e "$bblue[$byell sk $bblue]"
+ nb_skip=$(($nb_skip + 1))
+ rm $ref
+ else
+ echo -e "$bblue[$bgreen ok $bblue]"
+ nb_pass=$(($nb_pass + 1))
+ fi
else
if [ -r $ref ]; then
cmd_log=`$cmd $input 2> /dev/null`
- diff_log=`printf "%s\n" "$cmd_log" | diff -u $ref -`
+ diff_log=`printf "%s\n" "$cmd_log" | diff -EwB -u $ref -`
if [ "$diff_log" = "" ]; then
echo -e "$bblue[$bgreen ok $bblue]"
+ nb_pass=$(($nb_pass + 1))
else
echo -e "$bblue[$bred ko $bblue]"
+ nb_fail=$(($nb_fail + 1))
if [ $print_diff -eq 1 ]; then
echo -e -n $red
echo "$diff_log"
@@ -53,6 +68,7 @@
else
echo -e "$bblue[$byell sk $bblue]"
echo -e -n $red
+ nb_skip=$(($nb_skip + 1))
fi
fi
}
@@ -112,3 +128,13 @@
done
fi
done
+
+echo
+echo -e $bblue "Summary :"
+echo -e $bgreen " - Passed : " $nb_pass
+echo -e $byell " - Skiped : " $nb_skip
+if [ $gen_ref -ne 1 ]; then
+ echo -e $bred " - Failed : " $nb_fail
+fi
+echo -e $bblue " ---------------"
+echo -e $bblue " Total : " $(($nb_pass + $nb_skip + $nb_fail))
Index: trunk/tests/transformer/sample_4.ref
===================================================================
--- trunk/tests/transformer/sample_4.ref (revision 50)
+++ trunk/tests/transformer/sample_4.ref (revision 51)
@@ -1,7 +1,4 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
float sqrt(float arg)
{
- return std::sqrt(arg);
+ return std::sqrt(arg)
}
Index: trunk/tests/transformer/function_return_1.ref
===================================================================
--- trunk/tests/transformer/function_return_1.ref (revision 50)
+++ trunk/tests/transformer/function_return_1.ref (revision 51)
@@ -1,6 +1,3 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
int answer()
{
return 42;
Index: trunk/tests/transformer/function_return_2.ref
===================================================================
--- trunk/tests/transformer/function_return_2.ref (revision 50)
+++ trunk/tests/transformer/function_return_2.ref (revision 51)
@@ -1,6 +1,3 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
int answer(int a, bool b)
{
return 42;
Index: trunk/tests/transformer/function_return_3.ref
===================================================================
--- trunk/tests/transformer/function_return_3.ref (revision 50)
+++ trunk/tests/transformer/function_return_3.ref (revision 51)
@@ -1,6 +1,3 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
int answer()
{
return 42;
Index: trunk/tests/transformer/cons_decl_1.ref
===================================================================
--- trunk/tests/transformer/cons_decl_1.ref (revision 50)
+++ trunk/tests/transformer/cons_decl_1.ref (revision 51)
@@ -1,4 +1 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
const int i;
Index: trunk/tests/transformer/cons_decl_2.ref
===================================================================
--- trunk/tests/transformer/cons_decl_2.ref (revision 50)
+++ trunk/tests/transformer/cons_decl_2.ref (revision 51)
@@ -1,4 +1 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
const int i = 3;
Index: trunk/tests/transformer/class_decl_1.ref
===================================================================
--- trunk/tests/transformer/class_decl_1.ref (revision 50)
+++ trunk/tests/transformer/class_decl_1.ref (revision 51)
@@ -1,11 +1,6 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
// Class Foo
-template < typename T >
-class Foo_: public stc::any<stc_find_exact(Foo_, T)>
+template < typename E >
+class Foo
{
};
-
-typedef Foo_<stc::itself> Foo;
Index: trunk/tests/transformer/class_decl_2.ref
===================================================================
--- trunk/tests/transformer/class_decl_2.ref (revision 50)
+++ trunk/tests/transformer/class_decl_2.ref (revision 51)
@@ -1,10 +1,7 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
// Class point
-template < typename T >
-class point_: public stc::any<stc_find_exact(point_, T)>
+template < typename E >
+class point
{
public:
int x()
@@ -16,5 +13,3 @@
int x;
int y;
};
-
-typedef point_<stc::itself> point;
Index: trunk/tests/transformer/class_decl_3.ref
===================================================================
--- trunk/tests/transformer/class_decl_3.ref (revision 50)
+++ trunk/tests/transformer/class_decl_3.ref (revision 51)
@@ -1,10 +1,7 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
// Class point
-template < typename T >
-class point_: public stc::any<stc_find_exact(point_, T)>
+template < typename E >
+class point
{
public:
int x()
@@ -16,5 +13,3 @@
int x;
int y;
};
-
-typedef point_<stc::itself> point;
Index: trunk/tests/transformer/class_template_1.ref
===================================================================
--- trunk/tests/transformer/class_template_1.ref (revision 50)
+++ trunk/tests/transformer/class_template_1.ref (revision 51)
@@ -1,6 +1,3 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
template < class T >
class A
{
Index: trunk/tests/transformer/class_template_2.ref
===================================================================
--- trunk/tests/transformer/class_template_2.ref (revision 50)
+++ trunk/tests/transformer/class_template_2.ref (revision 51)
@@ -1,6 +1,3 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
template < class T, bool B >
class A
{
Index: trunk/tests/transformer/class_decl_inh.ref
===================================================================
--- trunk/tests/transformer/class_decl_inh.ref (revision 50)
+++ trunk/tests/transformer/class_decl_inh.ref (revision 51)
@@ -1,19 +1,12 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
// Class Bar
-template < typename T >
-class Bar_: public stc::any<stc_find_exact(Bar_, T)>
+template < typename E >
+class Bar
{
};
-
-typedef Bar_<stc::itself> Bar;
// Class Foo
-template < typename T >
-class Foo_: public Bar_<stc_find_exact(Foo_, T)>
+template < typename E >
+class Foo: public Bar<E>
{
};
-
-typedef Foo_<stc::itself> Foo;
Index: trunk/tests/transformer/function_decl_1.ref
===================================================================
--- trunk/tests/transformer/function_decl_1.ref (revision 50)
+++ trunk/tests/transformer/function_decl_1.ref (revision 51)
@@ -1,6 +1,3 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
bool f(int a, int b)
{
}
Index: trunk/tests/transformer/function_decl_3.ref
===================================================================
--- trunk/tests/transformer/function_decl_3.ref (revision 50)
+++ trunk/tests/transformer/function_decl_3.ref (revision 51)
@@ -1,4 +1 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
void foo();
Index: trunk/tests/transformer/empty.ref
===================================================================
--- trunk/tests/transformer/empty.ref (revision 50)
+++ trunk/tests/transformer/empty.ref (revision 51)
@@ -1,2 +1 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
+
Index: trunk/tests/transformer/var_decl_1.ref
===================================================================
--- trunk/tests/transformer/var_decl_1.ref (revision 50)
+++ trunk/tests/transformer/var_decl_1.ref (revision 51)
@@ -1,4 +1 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
int i;
Index: trunk/tests/transformer/function_decl_4.ref
===================================================================
--- trunk/tests/transformer/function_decl_4.ref (revision 50)
+++ trunk/tests/transformer/function_decl_4.ref (revision 51)
@@ -1,6 +1,3 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
void foo();
float foo(int arg1);
char foo(const toto& arg1, double& arg2);
Index: trunk/tests/transformer/function_decl_5.ref
===================================================================
--- trunk/tests/transformer/function_decl_5.ref (revision 50)
+++ trunk/tests/transformer/function_decl_5.ref (revision 51)
@@ -1,6 +1,3 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
bool f(int a, int& b)
{
}
Index: trunk/tests/transformer/var_decl_2.ref
===================================================================
--- trunk/tests/transformer/var_decl_2.ref (revision 50)
+++ trunk/tests/transformer/var_decl_2.ref (revision 51)
@@ -1,4 +1 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
int i = 42;
Index: trunk/tests/transformer/function_decl_6.ref
===================================================================
--- trunk/tests/transformer/function_decl_6.ref (revision 50)
+++ trunk/tests/transformer/function_decl_6.ref (revision 51)
@@ -1,6 +1,3 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
template < class T >
void f()
{
Index: trunk/tests/transformer/var_decl_3.ref
===================================================================
--- trunk/tests/transformer/var_decl_3.ref (revision 50)
+++ trunk/tests/transformer/var_decl_3.ref (revision 51)
@@ -1,6 +1,3 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
const int answer = 42;
int i;
int j = i;
Index: trunk/tests/transformer/function_decl_7.ref
===================================================================
--- trunk/tests/transformer/function_decl_7.ref (revision 50)
+++ trunk/tests/transformer/function_decl_7.ref (revision 51)
@@ -1,6 +1,3 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
template < class T >
void f(int a)
{
Index: trunk/tests/transformer/function_decl_8.ref
===================================================================
--- trunk/tests/transformer/function_decl_8.ref (revision 50)
+++ trunk/tests/transformer/function_decl_8.ref (revision 51)
@@ -1,6 +1,3 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
template < class T >
void f(int a)
{
Index: trunk/tests/transformer/command
===================================================================
--- trunk/tests/transformer/command (revision 50)
+++ trunk/tests/transformer/command (revision 51)
@@ -44,6 +44,7 @@
transformer="$base/scoolt/scoolt"
printer="$base/pp-cxx/pp-cxx"
cxxprinter="abox2text"
+exitval=0
if [ $printsrc -eq 1 ]; then
echo "----[ cat $1 ]----"
@@ -55,31 +56,43 @@
then
echo '----[' $parser ']----'
tmp=`$parser`
- if [ $? -ne 0 ]; then exit $?; fi
+ exit_val=$?
+ if [ $exit_val -ne 0 ]; then exit $exit_val; fi
printf "%s\n" "$tmp" | pp-aterm
echo
echo '----[' $transformer ']----'
tmp=`printf "%s\n" "$tmp" | $transformer`
- if [ $? -ne 0 ]; then exit $?; fi
+ exit_val=$?
+ if [ $exit_val -ne 0 ]; then exit $exit_val; fi
printf "%s\n" "$tmp" | pp-aterm
echo
echo '----[' $printer ']----'
tmp=`printf "%s\n" "$tmp" | $printer`
- if [ $? -ne 0 ]; then exit $?; fi
+ exit_val=$?
+ if [ $exit_val -ne 0 ]; then exit $exit_val; fi
printf "%s\n" "$tmp"
echo
echo '---[' $cxxprinter ']----'
tmp=`printf "%s\n" "$tmp" | $cxxprinter`
- if [ $? -ne 0 ]; then exit $?; fi
+ exit_val=$?
+ if [ $exit_val -ne 0 ]; then exit $exit_val; fi
printf "%s\n" "$tmp"
echo
else
if [ $verb -eq 1 ]; then
- printf "%s\n" "`$parser | $transformer | $printer | $cxxprinter`"
+ tmp=`$parser | $transformer | $printer | $cxxprinter`
+ exit_val=$?
+ if [ $exit_val -ne 0 ]; then exit $exit_val; fi
+ printf "%s\n" "$tmp"
else
- printf "%s\n" "`$parser 2> err-log | $transformer 2>> err-log | $printer 2>> err-log | $cxxprinter 2>> err-log`"
+ tmp=`$parser 2> err-log | $transformer 2>> err-log | $printer 2>> err-log | $cxxprinter 2>> err-log`
+ exit_val=$?
+ if [ $exit_val -ne 0 ]; then exit $exit_val; fi
+ printf "%s\n" "$tmp"
fi
fi
+
+exit $exitval
Index: trunk/tests/transformer/var_decl_5.ref
===================================================================
--- trunk/tests/transformer/var_decl_5.ref (revision 50)
+++ trunk/tests/transformer/var_decl_5.ref (revision 51)
@@ -1,4 +1 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
int a[42];
Index: trunk/tests/transformer/function_decl_9.ref
===================================================================
--- trunk/tests/transformer/function_decl_9.ref (revision 50)
+++ trunk/tests/transformer/function_decl_9.ref (revision 51)
@@ -1,6 +1,3 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
template < class T >
T f(const T& a)
{
Index: trunk/tests/transformer/var_decl_6.ref
===================================================================
--- trunk/tests/transformer/var_decl_6.ref (revision 50)
+++ trunk/tests/transformer/var_decl_6.ref (revision 51)
@@ -1,4 +1 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
std::vector<int> a;
Index: trunk/tests/transformer/function_decl_10.ref
===================================================================
--- trunk/tests/transformer/function_decl_10.ref (revision 50)
+++ trunk/tests/transformer/function_decl_10.ref (revision 51)
@@ -1,6 +1,3 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
double f(int a, double b)
{
return a + b;
Index: trunk/tests/transformer/class_decl_inh_fin.ref
===================================================================
--- trunk/tests/transformer/class_decl_inh_fin.ref (revision 50)
+++ trunk/tests/transformer/class_decl_inh_fin.ref (revision 51)
@@ -1,26 +1,17 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
// Class Animal
-template < typename T >
-class Animal_: public stc::any<stc_find_exact(Animal_, T)>
+template < typename E >
+class Animal
{
};
-
-typedef Animal_<stc::itself> Animal;
// Class Mammal
-template < typename T >
-class Mammal_: public Animal_<stc_find_exact(Mammal_, T)>
+template < typename E >
+class Mammal: public Animal<E>
{
};
-
-typedef Mammal_<stc::itself> Mammal;
// Class Monkey
-class Monkey: public Mammal_<Monkey>
+class Monkey: public Mammal<Monkey>
{
};
-
-typedef Monkey_<stc::itself> Monkey;
Index: trunk/tests/transformer/class_members_1.ref
===================================================================
--- trunk/tests/transformer/class_members_1.ref (revision 50)
+++ trunk/tests/transformer/class_members_1.ref (revision 51)
@@ -1,13 +1,8 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
// Class Student
-template < typename T >
-class Student_: public stc::any<stc_find_exact(Student_, T)>
+template < typename E >
+class Student
{
public:
int money;
};
-
-typedef Student_<stc::itself> Student;
Index: trunk/tests/transformer/sample_1.ref
===================================================================
--- trunk/tests/transformer/sample_1.ref (revision 50)
+++ trunk/tests/transformer/sample_1.ref (revision 51)
@@ -1,6 +1,3 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
void f()
{
const int16 i = 3;
Index: trunk/tests/transformer/class_predecl_inh.ref
===================================================================
--- trunk/tests/transformer/class_predecl_inh.ref (revision 50)
+++ trunk/tests/transformer/class_predecl_inh.ref (revision 51)
@@ -1,4 +1 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
class Foo: public Bar;
Index: trunk/tests/transformer/sample_3.ref
===================================================================
--- trunk/tests/transformer/sample_3.ref (revision 50)
+++ trunk/tests/transformer/sample_3.ref (revision 51)
@@ -1,6 +1,3 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
void f()
{
int i;
Index: trunk/tests/transformer/class_decl_inh_abst.ref
===================================================================
--- trunk/tests/transformer/class_decl_inh_abst.ref (revision 50)
+++ trunk/tests/transformer/class_decl_inh_abst.ref (revision 51)
@@ -1,17 +1,12 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
// Class Animal
-template < typename T >
-class Animal_: public stc::any<stc_find_exact(Animal_, T)>
+template < typename E >
+class Animal
{
};
// Class Mammal
-template < typename T >
-class Mammal_: public Animal_<stc_find_exact(Mammal_, T)>
+template < typename E >
+class Mammal: public Animal<E>
{
};
-
-typedef Mammal_<stc::itself> Mammal;
Index: trunk/tests/transformer/class_predecl.ref
===================================================================
--- trunk/tests/transformer/class_predecl.ref (revision 50)
+++ trunk/tests/transformer/class_predecl.ref (revision 51)
@@ -1,5 +1,2 @@
-#include <stc/any.hh>
-#include <stc/find_exact.hh>
-
template < typename T >
-class Foo_;
+class Foo;
--
\__/ \__/
(00) Maxime `yabo` van Noppen (00)
___) \ Epita 2009 / (___
(_____/ Président de Prologin \_____)
1
0
12 Mar '08
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
sandbox: continuing the psite/site factorization example.
* sandbox/ballas/refactorization/test/box2d.cc,
* sandbox/ballas/refactorization/test/image2d.cc,
* sandbox/ballas/refactorization/test/test.cc: tests.
* sandbox/ballas/refactorization/internal/impl.hh: New,base impl class.
* sandbox/ballas/refactorization/box2d.hh,
* sandbox/ballas/refactorization/point2d.hh,
* sandbox/ballas/refactorization/point2d_impl.hh,
* sandbox/ballas/refactorization/image2d.hh: New, add a light image2d.
* sandbox/ballas/refactorization/concept.hh:,
* sandbox/ballas/refactorization/internal/pset_base.hh:,
* sandbox/ballas/refactorization/internal/image_base.hh:,
* sandbox/ballas/refactorization/internal/piter_base.hh:,
* sandbox/ballas/refactorization/internal/psite_base.hh: Update.
box2d.hh | 246 +++++++++++++++++++++++++++++++++++++++++++++++++
concept.hh | 53 +++++++++-
image2d.hh | 97 +++++++++++++++++++
internal/image_base.hh | 3
internal/impl.hh | 16 +++
internal/piter_base.hh | 16 +--
internal/pset_base.hh | 4
internal/psite_base.hh | 4
point2d.hh | 201 ++++++++++++++++++++++++++++++++++++++++
point2d_impl.hh | 40 +++++++
test/box2d.cc | 22 ++++
test/image2d.cc | 17 +++
test/test.cc | 3
13 files changed, 706 insertions(+), 16 deletions(-)
Index: sandbox/ballas/refactorization/test/box2d.cc
--- sandbox/ballas/refactorization/test/box2d.cc (revision 0)
+++ sandbox/ballas/refactorization/test/box2d.cc (revision 0)
@@ -0,0 +1,22 @@
+#include <box2d.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ point2d<int> pmin(0, 0), pmax(5, 5);
+ std::cout << pmin << std::endl;
+ std::cout << pmax << std::endl;
+
+ box2d<int> b(pmin, pmax);
+ std::cout << b << std::endl;
+
+ box2d<int>::fwd_piter p(b);
+
+
+ for (p.start(); p.is_valid(); p.next())
+ {
+ std::cout << p.to_site() << std::endl;
+ }
+}
Index: sandbox/ballas/refactorization/test/test.cc
--- sandbox/ballas/refactorization/test/test.cc (revision 1781)
+++ sandbox/ballas/refactorization/test/test.cc (working copy)
@@ -1,7 +1,6 @@
-#include <internal/image_base.hh>
+#include <box2d.hh>
int main()
{
- return 0;
}
Index: sandbox/ballas/refactorization/test/image2d.cc
--- sandbox/ballas/refactorization/test/image2d.cc (revision 0)
+++ sandbox/ballas/refactorization/test/image2d.cc (revision 0)
@@ -0,0 +1,17 @@
+#include <image2d.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ point2d<int> pmin(0, 0), pmax(5, 5);
+ box2d<int> b(pmin, pmax);
+ image2d<int> ima(b);
+
+ ima(pmin) = 5;
+
+ image2d<int>::fwd_piter p(ima.domain());
+ for (p.start(); p.is_valid(); p.next())
+ std::cout << ima(p) << std::endl;
+}
Index: sandbox/ballas/refactorization/image2d.hh
--- sandbox/ballas/refactorization/image2d.hh (revision 0)
+++ sandbox/ballas/refactorization/image2d.hh (revision 0)
@@ -0,0 +1,97 @@
+#ifndef IMAGE2D_HH_
+# define IMAGE2D_HH_
+
+# include <internal/image_base.hh>
+
+# include <box2d.hh>
+
+namespace mln
+{
+
+ template <typename T>
+ class image2d : public internal::image_base_< box2d<int>, image2d<T> >
+ {
+ public:
+
+ typedef box2d<int> pset;
+ typedef pset::fwd_piter fwd_piter;
+ typedef pset::bkd_piter bkd_piter;
+
+
+
+ typedef T value;
+ typedef const T& rvalue;
+ typedef T& lvalue;
+
+
+ image2d(int nrows, int ncols);
+ image2d(const box2d<int>& b);
+
+ ///typedef mln::value::set<T> vset;
+ // const vset& values() const;
+ bool is_ready() const;
+
+ bool owns_(const point2d<int>& p) const;
+ const box2d<int>& domain() const;
+
+ const T& operator()(const point2d<int>& p) const;
+ T& operator()(const point2d<int>& p);
+
+
+ private:
+ T value_;
+ box2d<int> b_;
+ bool is_ready_;
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ image2d<T>::image2d(int nrows, int ncols) :
+ b_(nrows, ncols),
+ is_ready_(false)
+ {
+ }
+
+ template <typename T>
+ image2d<T>::image2d(const box2d<int>& b) :
+ b_(b),
+ is_ready_(false)
+ {
+ }
+
+ template <typename T>
+ bool
+ image2d<T>::is_ready() const
+ {
+ return is_ready_;
+ }
+
+ template <typename T>
+ const T&
+ image2d<T>::operator()(const point2d<int>&) const
+ {
+ return value_;
+ }
+
+ template <typename T>
+ T&
+ image2d<T>::operator()(const point2d<int>&)
+ {
+ is_ready_ = true;
+ return value_;
+ }
+
+ template <typename T>
+ const box2d<int>&
+ image2d<T>::domain() const
+ {
+ return this->b_;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+}
+
+
+#endif // ! IMAGE2D_HH_
Index: sandbox/ballas/refactorization/concept.hh
--- sandbox/ballas/refactorization/concept.hh (revision 1781)
+++ sandbox/ballas/refactorization/concept.hh (working copy)
@@ -24,18 +24,29 @@
/*
typedef site
typedef dsite;
-
- const psite& ref_();
*/
protected:
Site();
};
+ template <typename E>
+ struct Dsite : public Object<E>
+ {
+ /*
+ typedef dsite;
+
+ const dsite& to_dsite() const;
+ */
+ protected:
+ Dsite();
+ };
+
+
/// Psite Concept
/// Do we need a concept for representing psite?
template <typename E>
- struct Psite : public Object<E>
+ struct Psite : public Site<E>
{
/*
// Site must be different from psite,
@@ -55,6 +66,18 @@
Psite();
};
+ template <typename E>
+ struct Dpsite : public Object<E>
+ {
+ /*
+ typedef dpsite;
+
+ const dpsite& to_dpsite() const;
+ */
+ protected:
+ Dpsite();
+ };
+
/// Piter concept
/// Psite iterator
/// use template specializaion for psite == site or psite != psite
@@ -108,6 +131,7 @@
typedef values;
typedef rvalues;
typedef lvalues;
+
//typedef vset;
//const vset& destination() const;
// const vset& values() const;
@@ -120,6 +144,9 @@
bool owns_(const psite&) const;
bool has(const psite&) const;
+ typedef pset;
+ const pset& domain() const;
+
typedef fwd_piter;
typedef bkd_piter;
*/
@@ -146,6 +173,20 @@
/// FIXME
}
+ template <typename E>
+ inline
+ Dsite<E>::Dsite()
+ {
+ /// FIXME
+ }
+
+ template <typename E>
+ inline
+ Dpsite<E>::Dpsite()
+ {
+ /// FIXME
+ }
+
/// Psite
template <typename E>
inline
@@ -168,6 +209,12 @@
}
template <typename E>
+ Pset<E>::Pset()
+ {
+ /// FIXME
+ }
+
+ template <typename E>
Image<E>::Image()
{
/// FIXME
Index: sandbox/ballas/refactorization/internal/impl.hh
--- sandbox/ballas/refactorization/internal/impl.hh (revision 0)
+++ sandbox/ballas/refactorization/internal/impl.hh (revision 0)
@@ -0,0 +1,16 @@
+#ifndef IMPL_HH_
+# define IMPL_HH_
+
+namespace mln
+{
+
+ template <typename S>
+ struct impl
+ {
+ /// empty implementation
+ };
+
+}
+
+
+#endif // !IMPL_HH_
Index: sandbox/ballas/refactorization/internal/pset_base.hh
--- sandbox/ballas/refactorization/internal/pset_base.hh (revision 1781)
+++ sandbox/ballas/refactorization/internal/pset_base.hh (working copy)
@@ -2,6 +2,8 @@
# define INTERNAL_PSET_BASE_HH_
+# include <concept.hh>
+
namespace mln
{
namespace internal
@@ -11,7 +13,7 @@
/// FIXME: psite = site => Do we declare a site
/// typedef in site_base class?
template <typename P, typename E>
- struct pset_base_
+ struct pset_base_ : public Pset<E>
{
typedef typename P::site site;
typedef P psite;
Index: sandbox/ballas/refactorization/internal/image_base.hh
--- sandbox/ballas/refactorization/internal/image_base.hh (revision 1781)
+++ sandbox/ballas/refactorization/internal/image_base.hh (working copy)
@@ -19,6 +19,8 @@
typedef typename S::fwd_piter fwd_piter;
typedef typename S::bkd_piter bkd_piter;
+ bool has(const psite&) const;
+
protected:
image_base_();
};
@@ -32,6 +34,7 @@
{
}
+
# endif // ! MLN_INCLUDE_ONLY
}
}
Index: sandbox/ballas/refactorization/internal/piter_base.hh
--- sandbox/ballas/refactorization/internal/piter_base.hh (revision 1781)
+++ sandbox/ballas/refactorization/internal/piter_base.hh (working copy)
@@ -30,13 +30,13 @@
};
/// Piter base
- template <typename E>
+ template <typename E, typename Site, typename Psite>
struct piter_base_ :
public piter_base_site_cast<E,
- typename mlc_equal(typename E::site,
- typename E::psite)::eval>
+ typename mlc_equal(Site,
+ Psite)::eval>
{
- operator typename E::psite() const;
+ operator Psite () const;
protected:
piter_base_();
@@ -52,15 +52,15 @@
}
- template <typename E>
- piter_base_<E>::operator typename E::psite () const
+ template <typename E, typename Site, typename Psite>
+ piter_base_<E, Site, Psite>::operator Psite () const
{
return exact(this)->to_site();
}
- template <typename E>
- piter_base_<E>::piter_base_()
+ template <typename E, typename Site, typename Psite>
+ piter_base_<E, Site, Psite>::piter_base_()
{
}
Index: sandbox/ballas/refactorization/internal/psite_base.hh
--- sandbox/ballas/refactorization/internal/psite_base.hh (revision 1781)
+++ sandbox/ballas/refactorization/internal/psite_base.hh (working copy)
@@ -10,8 +10,8 @@
{
template <typename E>
- struct psite_base : public Psite<E>
- /// FIXME Get implementation
+ struct psite_base : public Psite<E>,
+ public impl<typename E::site>
{
operator typename E::psite () const;
Index: sandbox/ballas/refactorization/box2d.hh
--- sandbox/ballas/refactorization/box2d.hh (revision 0)
+++ sandbox/ballas/refactorization/box2d.hh (revision 0)
@@ -0,0 +1,246 @@
+#ifndef BOX2D_HH_
+# define BOX2D_HH_
+
+# include <point2d.hh>
+# include <internal/piter_base.hh>
+# include <iostream>
+
+namespace mln
+{
+
+ // fwd decl
+ template <typename P>
+ struct box2d_fwd_piter_;
+
+
+ /// FIXME Do a concept box
+ /// FIXME add implementation method
+ template <typename C>
+ struct box2d : public Pset< box2d<point2d<C> > >
+ {
+ enum { dim = 2 };
+
+ typedef point2d<C> psite;
+ typedef point2d<C> site;
+
+ typedef dpoint2d<C> dpoint;
+
+ typedef box2d_fwd_piter_<C> fwd_piter;
+ typedef box2d_fwd_piter_<C> bkd_piter; // fixme
+
+ point2d<C> pmin() const;
+ point2d<C>& pmin();
+ point2d<C> pmax() const;
+ point2d<C>& pmax();
+
+ box2d();
+ box2d(const site& pmin, const site& pmax);
+
+ bool has(const site& p) const;
+
+ protected:
+ point2d<C> pmin_, pmax_;
+ };
+
+
+ template <typename C>
+ std::ostream& operator<<(std::ostream& ostr, const box2d<C>& b);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename C>
+ inline
+ point2d<C>
+ box2d<C>::pmin() const
+ {
+ return pmin_;
+ }
+
+ template <typename C>
+ inline
+ point2d<C>&
+ box2d<C>::pmin()
+ {
+ return pmin_;
+ }
+
+ template <typename C>
+ inline
+ point2d<C>
+ box2d<C>::pmax() const
+ {
+ return pmax_;
+ }
+
+ template <typename C>
+ inline
+ point2d<C>&
+ box2d<C>::pmax()
+ {
+ return pmax_;
+ }
+
+ template <typename C>
+ inline
+ box2d<C>::box2d()
+ {
+ }
+
+ template <typename C>
+ inline
+ box2d<C>::box2d(const site& pmin, const psite& pmax)
+ : pmin_(pmin),
+ pmax_(pmax)
+ {
+ }
+
+ template <typename C>
+ inline
+ bool
+ box2d<C>::has(const site& p) const
+ {
+ for (unsigned i = 0; i < C::dim; ++i)
+ if (p[i] < pmin_[i] || p[i] > pmax_[i])
+ return false;
+ return true;
+ }
+
+ template <typename C>
+ inline
+ std::ostream& operator<<(std::ostream& ostr, const box2d<C>& b)
+ {
+ return ostr << "[" << b.pmin() << ".." << b.pmax() << ']';
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ /// fwd_piter
+ template <typename C>
+ class box2d_fwd_piter_ : public
+ internal::piter_base_< box2d_fwd_piter_<C>, point2d<C>, point2d<C> >
+ {
+ public:
+ typedef point2d<C> psite;
+ typedef point2d<C> site;
+
+
+
+ enum { dim = 2};
+
+ box2d_fwd_piter_(const box2d<C>& b);
+
+ const point2d<C>& to_site() const;
+ const point2d<C>& to_psite() const;
+
+ /// Give the i-th coordinate.
+ C operator[](unsigned i) const;
+
+ /// Test the iterator validity.
+ bool is_valid() const;
+
+ /// Invalidate the iterator.
+ void invalidate();
+
+ /// Start an iteration.
+ void start();
+
+ /// Go to the next point.
+ void next_();
+
+ private:
+ const box2d<C>& b_;
+ site p_, nop_;
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // box_fwd_piter_<P>
+
+ template <typename C>
+ inline
+ box2d_fwd_piter_<C>::box2d_fwd_piter_(const box2d<C>& b)
+ : b_(b)
+ {
+ nop_ = b_.pmax();
+ ++nop_[0];
+ invalidate();
+ }
+
+ template <typename C>
+ inline
+ const point2d<C>&
+ box2d_fwd_piter_<C>::to_site() const
+ {
+ return p_;
+ }
+
+ template <typename C>
+ inline
+ const point2d<C>&
+ box2d_fwd_piter_<C>::to_psite() const
+ {
+ return p_;
+ }
+
+ template <typename C>
+ inline
+ C
+ box2d_fwd_piter_<C>::operator[](unsigned i) const
+ {
+ assert(i < dim);
+ return p_[i];
+ }
+
+ template <typename C>
+ inline
+ bool
+ box2d_fwd_piter_<C>::is_valid() const
+ {
+ return p_ != nop_;
+ }
+
+ template <typename C>
+ inline
+ void
+ box2d_fwd_piter_<C>::invalidate()
+ {
+ p_ = nop_;
+ }
+
+ template <typename C>
+ inline
+ void
+ box2d_fwd_piter_<C>::start()
+ {
+ p_ = b_.pmin();
+ }
+
+ template <typename C>
+ inline
+ void
+ box2d_fwd_piter_<C>::next_()
+ {
+ for (int i = dim - 1; i >= 0; --i)
+ if (p_[i] == b_.pmax()[i])
+ p_[i] = b_.pmin()[i];
+ else
+ {
+ ++p_[i];
+ break;
+ }
+ if (p_ == b_.pmin())
+ p_ = nop_;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+
+#endif // !BOX2D_HH_
Index: sandbox/ballas/refactorization/point2d.hh
--- sandbox/ballas/refactorization/point2d.hh (revision 0)
+++ sandbox/ballas/refactorization/point2d.hh (revision 0)
@@ -0,0 +1,201 @@
+#ifndef POINT2D_HH_
+# define POINT2D_HH_
+
+# include <concept.hh>
+# include <vector>
+# include <point2d_impl.hh>
+# include <iostream>
+
+namespace mln
+{
+ /// fwd declaration
+ template <typename C> struct point2d;
+
+ /// Dpoint2d
+ template <typename C>
+ struct dpoint2d : public Dsite< dpoint2d<C> >
+ {
+ enum { dim = 2 };
+ typedef point2d<C> point;
+ typedef C coord;
+
+ C operator[](unsigned i) const;
+ C& operator[](unsigned i);
+
+ dpoint2d();
+ dpoint2d(C row, C col);
+
+ void set_all(C c);
+
+ protected:
+ std::vector<C> coord_;
+ };
+
+ /// Point2d
+ template <typename C>
+ struct point2d : public Site< point2d<C> >
+ {
+
+ enum { dim = 2 };
+ typedef dpoint2d<C> dpoint;
+ typedef C coord;
+
+
+ C operator[](unsigned i) const;
+ C& operator[](unsigned i);
+
+ point2d();
+ point2d(C row, C col);
+
+ void set_all(C c);
+
+ point2d<C>& operator+=(const dpoint& dp);
+ point2d<C>& operator-=(const dpoint& dp);
+
+ protected:
+ std::vector<C> coord_;
+ };
+
+ template <typename C>
+ inline
+ bool operator==(const point2d<C>& lhs_, const point2d<C>& rhs_);
+
+ template <typename C>
+ inline
+ bool operator!=(const point2d<C>& lhs, const point2d<C>& rhs);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ /// Dpoint2d
+ template <typename C>
+ C
+ dpoint2d<C>::operator[](unsigned i) const
+ {
+ assert(i < 2);
+ return coord_[i];
+ }
+
+ template <typename C>
+ C&
+ dpoint2d<C>::operator[](unsigned i)
+ {
+ assert(i < 2);
+ return coord_[i];
+ }
+
+
+ template <typename C>
+ dpoint2d<C>::dpoint2d() :
+ coord_(2, 0)
+ {
+ }
+
+ template <typename C>
+ dpoint2d<C>::dpoint2d(C row, C col) :
+ coord_(0)
+ {
+ coord_[0] = row;
+ coord_[1] = col;
+ }
+
+ template <typename C>
+ void
+ dpoint2d<C>::set_all(C c)
+ {
+ coord_[0] = c;
+ coord_[1] = c;
+ }
+
+
+ /// Point2d
+ template <typename C>
+ inline
+ C point2d<C>::operator[](unsigned i) const
+ {
+ assert(i < dim);
+ return this->coord_[i];
+ }
+
+ template <typename C>
+ inline
+ C& point2d<C>::operator[](unsigned i)
+ {
+ assert(i < dim);
+ return this->coord_[i];
+ }
+
+ // Constructors.
+ template <typename C>
+ inline
+ point2d<C>::point2d() :
+ coord_(2, 0)
+ {
+ }
+
+ template <typename C>
+ inline
+ point2d<C>::point2d(C row, C col) :
+ coord_(2)
+ {
+ coord_[0] = row;
+ coord_[1] = col;
+ }
+
+ template <typename C>
+ inline
+ void point2d<C>::set_all(C c)
+ {
+ coord_[0] = c;
+ coord_[1] = c;
+ }
+
+ template <typename C>
+ inline
+ point2d<C>&
+ point2d<C>::operator+=(const dpoint& dp)
+ {
+ for (unsigned i = 0; i < dim; ++i)
+ coord_[i] += dp[i];
+ return *this;
+ }
+
+ template <typename C>
+ inline
+ point2d<C>&
+ point2d<C>::operator-=(const dpoint& dp)
+ {
+ for (unsigned i = 0; i < dim; ++i)
+ coord_[i] -= dp[i];
+ return *this;
+ }
+
+
+ template <typename C>
+ inline
+ bool operator==(const point2d<C>& lhs, const point2d<C>& rhs)
+ {
+ for (unsigned i = 0; i < 2; ++i)
+ if (lhs[i] != rhs[i])
+ return false;
+ return true;
+ }
+
+ template <typename C>
+ inline
+ bool operator!=(const point2d<C>& lhs, const point2d<C>& rhs)
+ {
+ return !(lhs == rhs);
+ }
+
+ template <typename C>
+ std::ostream& operator<<(std::ostream& ostr, const point2d<C>& p)
+ {
+ return ostr << "(" << p[0] << "," << p[1] << ")";
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+}
+
+#endif // !POINT2D_HH_
Index: sandbox/ballas/refactorization/point2d_impl.hh
--- sandbox/ballas/refactorization/point2d_impl.hh (revision 0)
+++ sandbox/ballas/refactorization/point2d_impl.hh (revision 0)
@@ -0,0 +1,40 @@
+#ifndef POINT2D_IMPL_HH_
+# define POINT2D_IMPL_HH_
+
+# include <internal/impl.hh>
+
+
+namespace mln
+{
+
+ /// fwd declaration
+ template <typename C>
+ struct point2d;
+
+ template <typename C>
+ struct impl< point2d<C> >
+ {
+ C operator[](unsigned i) const;
+
+
+ // Non const method
+// C& operator[](unsigned i);
+// void set_all(C c);
+// point2d<C>& operator+=(const dpoint& dp);
+// point2d<C>& operator-=(const dpoint& dp);
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename C>
+ C
+ impl< point2d<C> >::operator[] (unsigned i) const
+ {
+ return this->to_site()[i];
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+}
+
+
+#endif // !POINT2D_IMPL_HH_
1
0
#88: Complete rgb type.
----------------------+-----------------------------------------------------
Reporter: duhamel | Owner: Olena Team
Type: defect | Status: closed
Priority: major | Milestone: Olena 1.0ß
Component: Milena | Version: 1.0
Resolution: fixed | Keywords:
----------------------+-----------------------------------------------------
Changes (by garrigues):
* status: new => closed
* resolution: => fixed
Comment:
The test source:/trunk/milena/tests/value/rgb_full.cc now compile. But
there is still some work
to do on rgb operator (maybe on vertorial operator?).
--
Ticket URL: <https://trac.lrde.org/olena/ticket/88#comment:2>
Olena <http://olena.lrde.epita.fr>
Olena, a generic and efficient C++ image processing library.
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Make the gaussian filter work using algebra::vec.
* mln/linear/gaussian.hh: use algebra::vec.
* mln/io/pnm/load.hh: comments.
* sandbox/jardonnet/test/Makefile: test.
* sandbox/jardonnet/test/gaussian.cc: test.
* sandbox/jardonnet/TODO: New.
* sandbox/jardonnet/icc.txt: New.
mln/binarization/thresholding.hh | 1
mln/io/pnm/load.hh | 3 +-
mln/linear/gaussian.hh | 39 +++++++++++++++++++++++++++-------
sandbox/jardonnet/TODO | 10 ++++++++
sandbox/jardonnet/icc.txt | 2 +
sandbox/jardonnet/registration/icp.hh | 13 ++++-------
sandbox/jardonnet/test/Makefile | 3 ++
sandbox/jardonnet/test/gaussian.cc | 21 ++++++++++++++++++
tests/binarization/thresholding.cc | 18 ++++++++++++---
9 files changed, 90 insertions(+), 20 deletions(-)
Index: tests/binarization/thresholding.cc
--- tests/binarization/thresholding.cc (revision 1780)
+++ tests/binarization/thresholding.cc (working copy)
@@ -38,6 +38,7 @@
#include <mln/level/all.hh>
#include <mln/io/pgm/load.hh>
+#include <mln/io/ppm/load.hh>
#include <mln/io/pbm/save.hh>
//#include "tests/data.hh"
@@ -47,10 +48,19 @@
using namespace mln;
using value::int_u8;
- typedef image2d<int_u8> I;
-
- I lena;
+ {
+ image2d<int_u8> lena;
io::pgm::load(lena, "../../img/lena.pgm");
-
io::pbm::save(binarization::thresholding(lena, argc), "out1.pgm");
}
+
+ {
+ image2d<int_u8> l;
+ image2d<int> lena;
+ io::pgm::load(l, "../../img/lena.pgm");
+
+ level::paste(l, lena);
+
+ io::pbm::save(binarization::thresholding(lena, argc), "out2.pgm");
+ }
+}
Index: mln/linear/gaussian.hh
--- mln/linear/gaussian.hh (revision 1780)
+++ mln/linear/gaussian.hh (working copy)
@@ -1,4 +1,3 @@
-
// Copyright (C) 2001, 2002, 2003, 2004 EPITA Research and Development
// Laboratory
//
@@ -41,6 +40,8 @@
# include <mln/geom/ncols.hh>
# include <mln/geom/nrows.hh>
+# include <mln/algebra/vec.hh>
+
# include <vector>
# include <cmath>
@@ -209,7 +210,7 @@
// Non causal part
- tmp2[len - 1] = 0;
+ tmp2[len - 1] = WorkType(); // FIXME : = 0, literal::zero ...?
tmp2[len - 2] =
c.nm[1] * ima(finish);
@@ -260,7 +261,7 @@
// Apply on rows.
for (unsigned j = 0; j < geom::ncols(img); ++j)
- recursivefilter_<float>(img, coef,
+ recursivefilter_< mln_value(I) >(img, coef,
make::point2d(-img.border(), j),
make::point2d(geom::nrows(img) - 1 + img.border(), j),
geom::nrows(img) + 2 * img.border(),
@@ -268,7 +269,7 @@
// Apply on columns.
for (unsigned i = 0; i < geom::nrows(img); ++i)
- recursivefilter_<float>(img, coef,
+ recursivefilter_< mln_value(I) >(img, coef,
make::point2d(i, -img.border()),
make::point2d(i, geom::ncols(img) - 1 + img.border()),
geom::ncols(img) + 2 * img.border(),
@@ -280,7 +281,8 @@
template <class I, class F, class O>
inline
void
- gaussian_common_(const Image<I>& in,
+ gaussian_common_(trait::value::nature::scalar,
+ const Image<I>& in,
const F& coef,
float sigma,
Image<O>& out)
@@ -298,6 +300,25 @@
level::paste(work_img, out);
}
+
+ template <class I, class F, class O>
+ inline
+ void
+ gaussian_common_(trait::value::nature::vectorial,
+ const Image<I>& in,
+ const F& coef,
+ float sigma,
+ Image<O>& out)
+ {
+ // typedef algebra::vec<3, float> vec3f;
+ // mln_ch_value(O, vec3f) work_img(exact(in).domain());
+ // FIXME : paste does not work (rgb8 -> vec3f).
+ level::paste(in, out);
+
+ if (sigma > 0.006)
+ gaussian_(out, coef);
+ }
+
} // end of namespace mln::linear::impl
// Facade.
@@ -306,15 +327,19 @@
inline
void
gaussian(const Image<I>& input, float sigma,
- Image<O>& output)
+ Image<O>& out)
{
+ mln_precondition(exact(input).has_data());
+ mln_precondition(exact(output).has_data());
+
impl::recursivefilter_coef_
coef(1.68f, 3.735f,
1.783f, 1.723f,
-0.6803f, -0.2598f,
0.6318f, 1.997f,
sigma);
- impl::gaussian_common_(input, coef, sigma, output);
+ impl::gaussian_common_(mln_trait_value_nature(mln_value(I))(),
+ input, coef, sigma, out);
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/binarization/thresholding.hh
--- mln/binarization/thresholding.hh (revision 1780)
+++ mln/binarization/thresholding.hh (working copy)
@@ -66,6 +66,7 @@
thresholding(const Image<I>& input, const mln_value(I) threshold)
{
trace::entering("binarization::thresholding");
+
mln_precondition(exact(input).has_data());
mlc_is(mln_trait_value_nature(mln_value(I)),
trait::value::nature::scalar)::check();
Index: mln/io/pnm/load.hh
--- mln/io/pnm/load.hh (revision 1780)
+++ mln/io/pnm/load.hh (working copy)
@@ -76,13 +76,14 @@
v.blue() = c;
}
+
//read a scalar value (sizeof(int_u8) != 1)
template <class V>
inline
void read_value(std::ifstream& file,
V& v)
{
- typedef typename V::enc E;
+ typedef typename V::enc E; // FIXME : if V = int
E c;
file.read((char*)(&c), sizeof(E));
Index: sandbox/jardonnet/test/Makefile
--- sandbox/jardonnet/test/Makefile (revision 1780)
+++ sandbox/jardonnet/test/Makefile (working copy)
@@ -10,5 +10,8 @@
gsub:
g++ gaussian_subsampling.cc $(FLAG) -o '+gsub.exe'
+gau:
+ g++ gaussian.cc $(FLAG) -o '+gau.exe'
+
run:
time ./+sub.exe . . ; time ./+gsub.exe . .
\ No newline at end of file
Index: sandbox/jardonnet/test/gaussian.cc
--- sandbox/jardonnet/test/gaussian.cc (revision 0)
+++ sandbox/jardonnet/test/gaussian.cc (revision 0)
@@ -0,0 +1,21 @@
+#include <mln/core/image2d.hh>
+
+#include <mln/io/ppm/load.hh>
+#include <mln/io/ppm/save.hh>
+
+#include <mln/linear/gaussian.hh>
+
+#include <mln/algebra/vec.hh>
+
+int main(int, char*)
+{
+ using namespace mln;
+
+ image2d< value::rgb8 > img;
+ io::ppm::load(img, "../../../img/lena.ppm");
+ image2d< value::rgb8 > out(img.domain());
+
+ linear::gaussian(img, .5, out);
+
+ io::ppm::save(out, "./+gau.ppm");
+}
Index: sandbox/jardonnet/TODO
--- sandbox/jardonnet/TODO (revision 0)
+++ sandbox/jardonnet/TODO (revision 0)
@@ -0,0 +1,10 @@
+image2d< value::rgb8 >
+
+img == out
+
+- - - - - - - - - -
+gaussian.cc: In function 'int main(int, char*)':
+gaussian.cc:22: error: no match for 'operator==' in 'img == out'
+
+
+*/*/*/*/*/*/*/*
\ No newline at end of file
Index: sandbox/jardonnet/registration/icp.hh
--- sandbox/jardonnet/registration/icp.hh (revision 1780)
+++ sandbox/jardonnet/registration/icp.hh (working copy)
@@ -46,7 +46,7 @@
*
*
*/
- template <typename I>
+ template <typename I, template J>
inline
void
icp(const Image<I>& cloud,
@@ -57,8 +57,6 @@
namespace impl
{
- //FIXME : add version for every image types.
-
template <typename I, typename J>
inline
void
@@ -74,18 +72,16 @@
quat old_qk, qk;
unsigned int k;
-
k = 0;
Pk = P;
do {
//projection
old_qk = qk;
-
//qk = match(P, mu_P, Xk, mu_Xk);
// error =
-
+ ++k;
} while (k < 3 || (qk - old_qk).sqr_norm() > epsilon);
@@ -95,6 +91,7 @@
} // end of namespace mln::registration::impl
+ // this version could convert image cloud in a vector of point?
template <typename I, typename J>
inline
void
@@ -105,13 +102,13 @@
mln_precondition(exact(cloud).has_data());
mln_precondition(exact(surface).has_data());
+
+
output = impl::icp_(exact(cloud), exact(surface));
trace::exiting("registration::icp");
}
- //cloud == image ?
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::registration
Index: sandbox/jardonnet/icc.txt
--- sandbox/jardonnet/icc.txt (revision 0)
+++ sandbox/jardonnet/icc.txt (revision 0)
@@ -0,0 +1,2 @@
+export GXX_INCLUDE=/usr/include/c++/4.1
+-D_GLIBCXX_GTHREAD_USE_WEAK=0
1
0