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
- 9625 discussions
https://svn.lrde.epita.fr/svn/oln/trunk/static
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Automate the compilation of mini-oln.
* samples/mini-oln/mini-oln.cc: Remove compilation
usage in comment.
(oln::Iterator::is_valid, oln::Image::has)
(oln::Image2d::nrows_get, oln::Image2d::ncols_get)
(oln::Image3d::nrows_get, oln::Image3d::ncols_get)
(oln::Image3d::nslis_get, oln::image_base::has): Add missing
return keywords.
(oln::image_with_nbh::nbh): Disable method.
* Makefile.am (SUBDIRS): Add samples.
* samples/mini-oln/concept-c++/mini-oln.cc: Likewise.
* samples/Makefile.am,
* samples/mini-oln/Makefile.am,
* samples/mini-oln/concept-c++/Makefile.am: New.
Makefile.am | 2 +-
samples/Makefile.am | 3 +++
samples/mini-oln/Makefile.am | 25 +++++++++++++++++++++++++
samples/mini-oln/concept-c++/Makefile.am | 21 +++++++++++++++++++++
samples/mini-oln/concept-c++/mini-oln.cc | 27 ++++++++++++---------------
samples/mini-oln/mini-oln.cc | 27 ++++++++++++---------------
6 files changed, 74 insertions(+), 31 deletions(-)
Index: samples/mini-oln/concept-c++/mini-oln.cc
--- samples/mini-oln/concept-c++/mini-oln.cc (revision 732)
+++ samples/mini-oln/concept-c++/mini-oln.cc (working copy)
@@ -27,12 +27,7 @@
/* \file samples/mini-oln/mini-oln.cc
\brief A proof of concept of Static using a mini-version of Olena, using
- concepts from C++0x.
-
- Compile with:
-
- conceptg++ -I../../../../{metalic,static,extended,olena} mini-oln.cc
-*/
+ concepts from C++0x. */
#include <vector>
#include <iostream>
@@ -191,7 +186,7 @@
bool is_valid() const
{
- this->exact().is_valid();
+ return this->exact().is_valid();
};
// auto
@@ -237,7 +232,7 @@
bool has(const point_t& p) const
{
- this->exact().has(p);
+ return this->exact().has(p);
}
};
}
@@ -270,12 +265,12 @@
int nrows_get() const
{
- this->exact().nrows_get();
+ return this->exact().nrows_get();
}
int ncols_get() const
{
- this->exact().ncols_get();
+ return this->exact().ncols_get();
}
};
}
@@ -308,17 +303,17 @@
int nrows_get() const
{
- this->exact().nrows_get();
+ return this->exact().nrows_get();
}
int ncols_get() const
{
- this->exact().ncols_get();
+ return this->exact().ncols_get();
}
int nslis_get() const
{
- this->exact().nslis_get();
+ return this->exact().nslis_get();
}
};
}
@@ -353,10 +348,12 @@
typedef oln_type_of_(image_with_nbh, niter) niter_t;
typedef oln_type_of_(image_with_nbh, nbh) nbh_t;
+ // FIXME: Implement.
+#if 0
nbh_t nbh() const
{
- // FIXME.
}
+#endif
};
}
@@ -442,7 +439,7 @@
bool has(const point_t& p) const
{
- this->exact().has(p);
+ return this->exact().has(p);
}
};
}
Index: samples/mini-oln/concept-c++/Makefile.am
--- samples/mini-oln/concept-c++/Makefile.am (revision 0)
+++ samples/mini-oln/concept-c++/Makefile.am (revision 0)
@@ -0,0 +1,21 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+AM_CPPFLAGS = -I$(top_srcdir)/static -I$(top_srcdir)/metalic
+
+# FIXME: Add
+#
+# AM_CXXFLAGS = $(CXXFLAGS_STRICT) $(CXXFLAGS_DEBUG)
+#
+# when oln.m4 is available in the distribution, instead of using the
+# set-by-hand TESTS_CXXFLAGS.
+TESTS_CXXFLAGS = @TESTS_CXXFLAGS@
+AM_CXXFLAGS = $(TESTS_CXXFLAGS)
+
+# Hacky.
+CXX = @CONCEPTCXX@
+
+check_PROGRAMS = mini-oln
+
+mini_oln_SOURCES = mini-oln.cc
+
+TESTS = $(check_PROGRAMS)
Index: samples/mini-oln/mini-oln.cc
--- samples/mini-oln/mini-oln.cc (revision 732)
+++ samples/mini-oln/mini-oln.cc (working copy)
@@ -26,12 +26,7 @@
// Public License.
/* \file samples/mini-oln/mini-oln.cc
- \brief A proof of concept of Static using a mini-version of Olena.
-
- Compile with:
-
- g++ -I../../../{metalic,static,extended,olena} mini-oln.cc
-*/
+ \brief A proof of concept of Static using a mini-version of Olena. */
#include <vector>
@@ -117,7 +112,7 @@
bool is_valid() const
{
- this->exact().is_valid();
+ return this->exact().is_valid();
};
// auto
@@ -163,7 +158,7 @@
bool has(const point_t& p) const
{
- this->exact().has(p);
+ return this->exact().has(p);
}
};
}
@@ -196,12 +191,12 @@
int nrows_get() const
{
- this->exact().nrows_get();
+ return this->exact().nrows_get();
}
int ncols_get() const
{
- this->exact().ncols_get();
+ return this->exact().ncols_get();
}
};
}
@@ -234,17 +229,17 @@
int nrows_get() const
{
- this->exact().nrows_get();
+ return this->exact().nrows_get();
}
int ncols_get() const
{
- this->exact().ncols_get();
+ return this->exact().ncols_get();
}
int nslis_get() const
{
- this->exact().nslis_get();
+ return this->exact().nslis_get();
}
};
}
@@ -279,10 +274,12 @@
typedef oln_type_of_(image_with_nbh, niter) niter_t;
typedef oln_type_of_(image_with_nbh, nbh) nbh_t;
+ // FIXME: Implement.
+#if 0
nbh_t nbh() const
{
- // FIXME.
}
+#endif
};
}
@@ -359,7 +356,7 @@
bool has(const point_t& p) const
{
- this->exact().has(p);
+ return this->exact().has(p);
}
};
}
Index: samples/mini-oln/Makefile.am
--- samples/mini-oln/Makefile.am (revision 0)
+++ samples/mini-oln/Makefile.am (revision 0)
@@ -0,0 +1,25 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+SUBDIRS = . concept-c++
+
+
+AM_CPPFLAGS = -I$(top_srcdir)/static -I$(top_srcdir)/metalic
+
+# FIXME: Add
+#
+# AM_CXXFLAGS = $(CXXFLAGS_STRICT) $(CXXFLAGS_DEBUG)
+#
+# when oln.m4 is available in the distribution, instead of using the
+# set-by-hand TESTS_CXXFLAGS.
+TESTS_CXXFLAGS = @TESTS_CXXFLAGS@
+AM_CXXFLAGS = $(TESTS_CXXFLAGS)
+
+
+check_PROGRAMS = mini-oln
+
+mini_oln_SOURCES = mini-oln.cc
+
+TESTS = $(check_PROGRAMS)
+
+
+EXTRA_DIST = README
Index: samples/Makefile.am
--- samples/Makefile.am (revision 0)
+++ samples/Makefile.am (revision 0)
@@ -0,0 +1,3 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+SUBDIRS = mini-oln
Index: Makefile.am
--- Makefile.am (revision 732)
+++ Makefile.am (working copy)
@@ -1,3 +1,3 @@
## Process this file through Automake to create Makefile.in -*- Makefile -*-
-SUBDIRS = stc tests
+SUBDIRS = stc tests samples
1
0
02 Feb '07
https://svn.lrde.epita.fr/svn/oln/trunk/static
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Improve the Point2d and Point3d concepts in mini-oln.
* samples/mini-oln/concept-c++/mini-oln.cc
(concepts::Point2d, concepts::Point3d): Enrich them.
(concept_map Point2d<oln::point2d>)
(concept_map Point3d<oln::point3d>): Adjust.
(oln::point2d::coord_type, oln::point3d::coord_type): New
typedefs.
(oln::point2d::row, oln::point2d::col)
(oln::point3d::row, oln::point3d::col, oln::point3d::sli): Use it.
mini-oln.cc | 46 +++++++++++++++++++++++++++++++++++++---------
1 file changed, 37 insertions(+), 9 deletions(-)
Index: samples/mini-oln/concept-c++/mini-oln.cc
--- samples/mini-oln/concept-c++/mini-oln.cc (revision 731)
+++ samples/mini-oln/concept-c++/mini-oln.cc (working copy)
@@ -61,8 +61,27 @@
namespace concepts
{
- concept Point2d<typename P> {};
- concept Point3d<typename P> {};
+ // These concepts are not automatic (i.e., prefixed with `auto'),
+ // since we cannot rely on type signatures for them. For instance,
+ // using only structural conformance, oln::point3d could be a model
+ // of concepts::Point2d!
+ concept Point2d<typename P>
+ {
+ typename coord_type;
+ // For simplicity purpose, the canonical model of
+ // concepts::Point2d -- oln::point2d -- does not expose its
+ // interface through methods (that's bad OO software engineering
+ // practice, but hey, we're just prototyping here). Therefore we
+ // cannot express sigatures on row and col accesses, since C++0x
+ // concepts forbid attribute (member) signatures.
+ };
+
+ concept Point3d<typename P>
+ {
+ typename coord_type;
+ // Same remark as above for concepts::Point2d regarding member
+ // signatures.
+ };
auto concept Image<typename I>
{
@@ -110,22 +129,31 @@
struct point2d : public Point<point2d>
{
- int row;
- int col;
+ typedef int coord_type;
+ coord_type row;
+ coord_type col;
};
struct point3d : public Point<point2d>
{
- int row;
- int col;
- int sli;
+ typedef int coord_type;
+ coord_type row;
+ coord_type col;
+ coord_type sli;
};
}
namespace concepts
{
- concept_map Point2d<oln::point2d> {};
- concept_map Point3d<oln::point3d> {};
+ concept_map Point2d<oln::point2d>
+ {
+ typedef oln::point2d::coord_type coord_type;
+ };
+
+ concept_map Point3d<oln::point3d>
+ {
+ typedef oln::point2d::coord_type coord_type;
+ };
}
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/static
This version of mini-oln needs g++ from ConceptGCC. You can find it there:
/lrde/dev/linux-x86/unstable/conceptgcc-4.1.1-alpha-5/bin/conceptg++
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Add a first C++0x concept-based version of mini-oln.
* samples/mini-oln/concept-c++/mini-oln.cc: New.
mini-oln.cc | 95 +++++++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 75 insertions(+), 20 deletions(-)
Index: samples/mini-oln/concept-c++/mini-oln.cc
--- samples/mini-oln/concept-c++/mini-oln.cc (revision 0)
+++ samples/mini-oln/concept-c++/mini-oln.cc (working copy)
@@ -26,14 +26,16 @@
// Public License.
/* \file samples/mini-oln/mini-oln.cc
- \brief A proof of concept of Static using a mini-version of Olena.
+ \brief A proof of concept of Static using a mini-version of Olena, using
+ concepts from C++0x.
Compile with:
- g++ -I../../../{metalic,static,extended,olena} mini-oln.cc
+ conceptg++ -I../../../../{metalic,static,extended,olena} mini-oln.cc
*/
#include <vector>
+#include <iostream>
#include <mlc/case.hh>
#include <stc/any.hh>
@@ -53,6 +55,44 @@
+/*-----------.
+| Concepts. |
+`-----------*/
+
+namespace concepts
+{
+ concept Point2d<typename P> {};
+ concept Point3d<typename P> {};
+
+ auto concept Image<typename I>
+ {
+ typename point_t;
+ typename iter_t;
+ typename value_t;
+
+ // ConceptGCC doesn't support operator signatures yet.
+#if 0
+ value_t& I::operator ()(point_t&);
+#endif
+ bool I::has(const point_t&) const;
+ };
+
+ auto concept Image2d<typename I> : Image<I>
+ {
+ int I::nrows_get() const;
+ int I::ncols_get() const;
+ };
+
+ auto concept Image3d<typename I> : Image<I>
+ {
+ int I::nrows_get() const;
+ int I::ncols_get() const;
+ int I::nslis_get() const;
+ };
+}
+
+
+
/*-------------.
| Mini-Olena. |
`-------------*/
@@ -82,6 +122,12 @@
};
}
+namespace concepts
+{
+ concept_map Point2d<oln::point2d> {};
+ concept_map Point3d<oln::point3d> {};
+}
+
// ---------- //
// Iterator. //
@@ -293,31 +339,40 @@
namespace oln
{
- struct switch_image_base;
+ // Fwd. decl.
+ template <typename E>
+ class image_dimension_switch;
- namespace error
+ // Default version, abort.
+ template <typename E>
+ class image_dimension_switch : mlc::abort_<E>
{
- struct ERROR_image_base;
};
- template <typename I>
- struct case_<switch_image_base, I, 1> :
- public mlc::where_ < mlc::eq_ <I, point2d> >
+ // Concept-based overloading for Image2d.
+ template <typename E> where concepts::Point2d< oln_type_of(E, point) >
+ class image_dimension_switch<E> : public oln::Image2d
{
- typedef Image2d ret;
- };
-
- template <typename I>
- struct case_<switch_image_base, I, 2> :
- public mlc::where_ < mlc::eq_ <I, point3d> >
+ public:
+ image_dimension_switch()
{
- typedef Image3d ret;
+ std::cout << "image_dimension_switch<E> "
+ << "where concepts::Point2d<oln_type_of(E, point)>"
+ << std::endl;
+ }
};
- template <typename I>
- struct default_case_<switch_image_base, I>
+ // Concept-based overloading for Image3d.
+ template <typename E> where concepts::Point3d< oln_type_of(E, point) >
+ class image_dimension_switch<E> : public oln::Image3d
+ {
+ public:
+ image_dimension_switch()
{
- typedef mlc::undefined ret;
+ std::cout << "image_dimension_switch<E> "
+ << "where concepts::Point3d<oln_type_of(E, point)>"
+ << std::endl;
+ }
};
}
@@ -334,7 +389,7 @@
template<typename E>
struct set_super_type< image_base<E> >
{
- typedef typename oln::switch_<switch_image_base, E>::ret ret;
+ typedef typename oln::image_dimension_switch<E> ret;
};
template <typename E>
@@ -346,7 +401,7 @@
};
template <typename E>
- struct image_base : public oln::switch_<switch_image_base, E>::ret
+ struct image_base : public oln::image_dimension_switch<E>
{
typedef oln_type_of(image_base, point) point_t;
typedef oln_type_of(image_base, iter) iter_t;
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/static
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Fix mini-oln.
* samples/mini-oln/mini-oln.cc: Move all Olena classes into the
namespace `oln'.
(main): Adjust.
(oln::image2d::has): Make it const.
Remove semicolons following the closing parenthesis of a
namespace.
Aesthetic changes.
* stc/scoop.hh: Replace every occurrence of `where' (as a template
parameter) with `location', to comply with the upcoming C++0x
standard.
samples/mini-oln/mini-oln.cc | 162 ++++++++++++++++++++++++++++++-------------
stc/scoop.hh | 30 +++----
2 files changed, 131 insertions(+), 61 deletions(-)
Index: samples/mini-oln/mini-oln.cc
--- samples/mini-oln/mini-oln.cc (revision 729)
+++ samples/mini-oln/mini-oln.cc (working copy)
@@ -25,6 +25,14 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
+/* \file samples/mini-oln/mini-oln.cc
+ \brief A proof of concept of Static using a mini-version of Olena.
+
+ Compile with:
+
+ g++ -I../../../{metalic,static,extended,olena} mini-oln.cc
+*/
+
#include <vector>
#include <mlc/case.hh>
@@ -44,7 +52,17 @@
mlc_case_equipment_for_namespace(oln);
-// Point
+
+/*-------------.
+| Mini-Olena. |
+`-------------*/
+
+// ------- //
+// Point. //
+// ------- //
+
+namespace oln
+{
template <typename E>
struct Point : public stc::any<E>
{
@@ -62,13 +80,18 @@
int col;
int sli;
};
+}
-// Iterator
-template <typename E>
-struct Iterator;
+
+// ---------- //
+// Iterator. //
+// ---------- //
namespace oln
{
+ template <typename E>
+ struct Iterator;
+
mlc_decl_typedef(point_type);
template <typename E>
@@ -76,7 +99,6 @@
{
typedef mlc::undefined point_type;
};
-};
template <typename E>
struct Iterator : public stc::any<E>
@@ -104,13 +126,18 @@
return this->exact().operator point_t();
}
};
+}
-// Image
-template <typename E>
-struct Image;
+
+// ------- //
+// Image. //
+// ------- //
namespace oln
{
+ template <typename E>
+ struct Image;
+
mlc_decl_typedef(iter_type);
mlc_decl_typedef(value_type);
@@ -121,7 +148,6 @@
typedef mlc::undefined iter_type;
typedef mlc::undefined value_type;
};
-};
template <typename E>
struct Image : public stc::any<E>
@@ -139,8 +165,13 @@
{
this->exact().has(p);
}
-
};
+}
+
+
+// --------- //
+// Image2d. //
+// --------- //
namespace oln
{
@@ -151,7 +182,6 @@
{
typedef Image<Image2d> ret;
};
-};
struct Image2d : public Image<Image2d>
{
@@ -174,6 +204,12 @@
this->exact().ncols_get();
}
};
+}
+
+
+// ---------- //
+// Image 3d. //
+// ---------- //
namespace oln
{
@@ -184,7 +220,6 @@
{
typedef Image<Image3d> ret;
};
-};
struct Image3d : public Image<Image3d>
{
@@ -212,12 +247,17 @@
this->exact().nslis_get();
}
};
+}
-// Image with neighborhood
-struct image_with_nbh;
+
+// ------------------------- //
+// Image with neighborhood. //
+// ------------------------- //
namespace oln
{
+ struct image_with_nbh;
+
mlc_decl_typedef(niter_type);
mlc_decl_typedef(nbh_type);
@@ -233,7 +273,6 @@
typedef mlc::undefined niter_type;
typedef mlc::undefined nbh_type;
};
-};
struct image_with_nbh : public Image<image_with_nbh>
{
@@ -242,28 +281,35 @@
nbh_t nbh() const
{
- //FIXME
+ // FIXME.
}
};
+}
-// Switch
-struct switch_image_base;
+
+// -------- //
+// Switch. //
+// -------- //
namespace oln
{
+ struct switch_image_base;
+
namespace error
{
struct ERROR_image_base;
};
template <typename I>
- struct case_<switch_image_base, I, 1> : public mlc::where_ < mlc::eq_ <I, point2d> >
+ struct case_<switch_image_base, I, 1> :
+ public mlc::where_ < mlc::eq_ <I, point2d> >
{
typedef Image2d ret;
};
template <typename I>
- struct case_<switch_image_base, I, 2> : public mlc::where_ < mlc::eq_ <I, point3d> >
+ struct case_<switch_image_base, I, 2> :
+ public mlc::where_ < mlc::eq_ <I, point3d> >
{
typedef Image3d ret;
};
@@ -273,17 +319,18 @@
{
typedef mlc::undefined ret;
};
-};
-
+}
+// ------------ //
+// Image base. //
+// ------------ //
-// Image base
+namespace oln
+{
template <typename E>
struct image_base;
-namespace oln
-{
template<typename E>
struct set_super_type<image_base<E> >
{
@@ -297,7 +344,6 @@
typedef mlc::undefined iter_type;
typedef mlc::undefined value_type;
};
-};
template <typename E>
struct image_base : public oln::switch_<switch_image_base, E>::ret
@@ -316,15 +362,20 @@
this->exact().has(p);
}
};
+}
+
-// Iterator 2d
+// ------------ //
+// iterator2d. //
+// ------------ //
+
+namespace oln
+{
struct iterator2d;
template <typename T>
struct image2d;
-namespace oln
-{
template<>
struct set_super_type<iterator2d>
{
@@ -336,7 +387,6 @@
{
typedef point2d point_type;
};
-};
struct iterator2d : public Iterator<iterator2d>
{
@@ -381,14 +431,19 @@
int ncols;
point_t p;
};
+}
-// image2d
-template <typename T>
-struct image2d;
+
+// --------- //
+// image2d. //
+// --------- //
namespace oln
{
template<typename T>
+ struct image2d;
+
+ template<typename T>
struct set_super_type<image2d<T> >
{
typedef image_base<image2d<T> > ret;
@@ -397,10 +452,9 @@
template <typename T>
struct vtypes<image2d<T> >
{
- typedef point2d point_t;
- typedef iterator2d iter_t;
- typedef T value_t;
- };
+ typedef point2d point_type;
+ typedef iterator2d iter_type;
+ typedef T value_type;
};
template <typename T>
@@ -433,7 +487,7 @@
return ncols;
}
- bool has(point_t& p)
+ bool has(point_t& p) const
{
assert(!!data);
return p.row >= 0 && p.row < nrows && p.col >= 0 && p.col < ncols;
@@ -444,14 +498,19 @@
int nrows;
int ncols;
};
+}
-// image_morpher
-template <typename E>
-struct image_morpher;
+
+// --------------- //
+// image_morpher. //
+// --------------- //
namespace oln
{
template<typename E>
+ struct image_morpher;
+
+ template<typename E>
struct set_super_type<image_morpher<E> >
{
typedef image_base<image_morpher<E> > ret;
@@ -462,7 +521,6 @@
{
typedef mlc::undefined delegatee_t;
};
-};
template <typename E>
struct image_morpher : public image_base<image_morpher<E> >
@@ -481,14 +539,19 @@
protected:
delegatee_t& ref_ima;
};
+}
-//image_plus_neighborhood
-template <typename I, typename N>
-struct plus;
+
+// ------ //
+// plus. //
+// ------ //
namespace oln
{
template <typename I, typename N>
+ struct plus;
+
+ template <typename I, typename N>
struct set_super_type<image_morpher<plus<I, N> > >
{
typedef image_morpher<plus <I, N> > ret;
@@ -499,7 +562,6 @@
{
typedef I delegatee_t;
};
-};
template <typename I, typename N>
struct plus : public image_morpher<plus<I, N> >
@@ -513,17 +575,25 @@
N& nbh;
};
+ // Helper.
template <typename I, typename N>
plus<I, N> operator +(I& lhs, N& rhs)
{
plus<I, N> res(lhs, rhs);
return res;
}
+}
+/*--------------.
+| Client code. |
+`--------------*/
+
int main()
{
+ using namespace oln;
+
typedef plus<image2d<int>, image_with_nbh> my_ima;
point2d p2d;
Index: stc/scoop.hh
--- stc/scoop.hh (revision 729)
+++ stc/scoop.hh (working copy)
@@ -185,7 +185,7 @@
template <typename from, typename target> \
struct find; \
\
- template <typename from, typename target, typename where, typename res> \
+ template <typename from, typename target, typename location, typename res> \
struct helper_find; \
\
\
@@ -470,12 +470,12 @@
/* \
* first_stm(from, target) \
* \
- * returns a pair (Where, Value) with Value being: \
+ * returns a pair (Location, Value) with Value being: \
* - stc::abstract \
* - stc::not_delegated \
* - mlc::not_found \
* - a type T \
- * and Where being the class where the stm is found. \
+ * and Location being the class where the stm is found. \
* \
* \
* helper_first_stm(curr, target, stm) \
@@ -656,21 +656,21 @@
\
\
/* \
- * helper_find(from, target, where, res) \
+ * helper_find(from, target, location, res) \
* \
* \
* \
*/ \
\
- template <typename from, typename target, typename where> \
- struct helper_find < from, target, where, \
+ template <typename from, typename target, typename location> \
+ struct helper_find < from, target, location, \
/* if res == */ mlc::not_found > \
{ \
typedef typename delegator_find<from, target>::ret ret; \
}; \
\
- template <typename from, typename target, typename where> \
- struct helper_find < from, target, where, \
+ template <typename from, typename target, typename location> \
+ struct helper_find < from, target, location, \
/* if res == */ stc::abstract > \
{ \
typedef typename delegator_find<from, target>::ret res_d; \
@@ -678,23 +678,23 @@
: mlc::assert_< mlc::is_found_<res_d>, \
ERROR::vtype_declared_but_not_defined \
< ERROR::_for_vtype_<target>, \
- ERROR::_declaration_is_in_<where>, \
+ ERROR::_declaration_is_in_<location>, \
ERROR::_definition_is_looked_up_from_<from> > > \
- /* FIXME: error("<target> declared in <where> but not defined at <from>"); */ \
+ /* FIXME: error("<target> declared in <location> but not defined at <from>"); */ \
{ \
typedef res_d ret; \
}; \
typedef typename check_::ret ret; \
}; \
\
- template <typename from, typename target, typename where> \
- struct helper_find < from, target, where, \
+ template <typename from, typename target, typename location> \
+ struct helper_find < from, target, location, \
/* if res == */ stc::not_delegated > \
{ \
typedef typename superior_find<from, target>::ret ret; \
}; \
\
- template <typename from, typename target, typename where, typename res> \
+ template <typename from, typename target, typename location, typename res> \
struct helper_find /* otherwise */ \
{ \
typedef res ret; \
@@ -726,10 +726,10 @@
struct find /* otherwise */ \
{ \
typedef typename first_stm<from, target>::ret stm; \
- typedef mlc_elt(stm, 1) where; \
+ typedef mlc_elt(stm, 1) location; \
typedef mlc_elt(stm, 2) res; \
typedef typename helper_find<from, target, \
- where, res>::ret ret; \
+ location, res>::ret ret; \
}; \
\
\
1
0
2007-02-01 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* mlc/case.hh (mlc_case_equipment_for_namespace):
Rename NAMESPACE::internal into NAMESPACE::mlc_case_internal.
* mlc/cmp.hh (is_not_value, is_not_bexpr): Shorten.
Index: mlc/case.hh
===================================================================
--- mlc/case.hh (revision 720)
+++ mlc/case.hh (working copy)
@@ -191,7 +191,7 @@
\
\
\
- namespace internal \
+ namespace mlc_case_internal \
{ \
\
template <typename use, \
@@ -393,33 +393,33 @@
template <typename context, typename data> \
struct get_case_ \
{ \
- typedef typename NAMESPACE::internal::select_case_<mlc::internal::a_get_case, context, data>::ret ret; \
+ typedef typename NAMESPACE::mlc_case_internal::select_case_<mlc::internal::a_get_case, context, data>::ret ret; \
}; \
\
\
template <typename context, typename data> \
struct case_ <context, data, mlc::internal::unknown_case_id> \
\
- : private mlc::assert_< mlc::neq_< mlc_comma_2(typename NAMESPACE::internal::select_case_<mlc::internal::a_simple_case, \
+ : private mlc::assert_< mlc::neq_< mlc_comma_2(typename NAMESPACE::mlc_case_internal::select_case_<mlc::internal::a_simple_case, \
context, data>::ret), \
mlc::none >, \
mlc::ERROR::NO_case_STATEMENT_CAN_BE_SELECTED > \
\
{ \
- typedef typename NAMESPACE::internal::select_case_<mlc::internal::a_simple_case, context, data>::ret ret; \
+ typedef typename NAMESPACE::mlc_case_internal::select_case_<mlc::internal::a_simple_case, context, data>::ret ret; \
}; \
\
\
template <typename context, typename data> \
struct switch_ \
\
- : private mlc::assert_< mlc::neq_< mlc_comma_2(typename NAMESPACE::internal::select_case_<mlc::internal::a_switch_case, \
+ : private mlc::assert_< mlc::neq_< mlc_comma_2(typename NAMESPACE::mlc_case_internal::select_case_<mlc::internal::a_switch_case, \
context, data>::ret), \
mlc::none >, \
mlc::ERROR::NO_case_STATEMENT_CAN_BE_SELECTED > \
\
{ \
- typedef typename NAMESPACE::internal::select_case_<mlc::internal::a_switch_case, context, data>::ret case_t; \
+ typedef typename NAMESPACE::mlc_case_internal::select_case_<mlc::internal::a_switch_case, context, data>::ret case_t; \
typedef typename case_t::ret ret; \
}; \
\
Index: mlc/cmp.hh
===================================================================
--- mlc/cmp.hh (revision 720)
+++ mlc/cmp.hh (working copy)
@@ -83,7 +83,7 @@
/// Check whether \a T is not a mlc::abstract::value.
template <typename T>
- struct is_not_value : public not_<mlc_is_a(T, mlc::abstract::value)>::bexpr
+ struct is_not_value : public mlc_is_not_a(T, mlc::abstract::value)::bexpr
{
};
@@ -96,7 +96,7 @@
/// Check whether \a T is not a mlc::abstract::bexpr.
template <typename T>
- struct is_not_bexpr : public not_<mlc_is_a(T, mlc::abstract::bexpr)>::bexpr
+ struct is_not_bexpr : public mlc_is_not_a(T, mlc::abstract::bexpr)::bexpr
{
};
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Catch up with Static.
* oln/core/typedefs.hh: Catch up with stc/scoop-alt.hh.
* oln/core/abstract/image/bbox/hierarchy.hh,
* oln/core/abstract/image/dimension/hierarchy.hh,
* oln/core/abstract/image/hybrid/classical.hh,
* oln/core/abstract/image/mutability/hierarchy.hh,
* oln/core/abstract/image/neighborhood/hierarchy.hh,
* oln/core/abstract/image/value_wise_accessibility/hierarchy.hh,
* oln/core/abstract/iterator_on_points.hh,
* oln/core/abstract/point.hh,
* oln/core/internal/dpoint_nd.hh,
* oln/core/image_entry.hh:
s/OLENA_USE_NEW_SCOOP2/OLENA_USE_SCOOP_ALT/g.
abstract/image/bbox/hierarchy.hh | 4 ++--
abstract/image/dimension/hierarchy.hh | 12 ++++++------
abstract/image/hybrid/classical.hh | 16 ++++++++--------
abstract/image/mutability/hierarchy.hh | 4 ++--
abstract/image/neighborhood/hierarchy.hh | 4 ++--
abstract/image/value_wise_accessibility/hierarchy.hh | 8 ++++----
abstract/iterator_on_points.hh | 8 ++++----
abstract/point.hh | 12 ++++++------
image_entry.hh | 8 ++++----
internal/dpoint_nd.hh | 8 ++++----
typedefs.hh | 8 +++-----
11 files changed, 45 insertions(+), 47 deletions(-)
Index: oln/core/typedefs.hh
--- oln/core/typedefs.hh (revision 726)
+++ oln/core/typedefs.hh (working copy)
@@ -41,11 +41,11 @@
# include <stc/any.hh>
# include <stc/exact.hh>
-# ifdef OLENA_USE_NEW_SCOOP2
-# include <stc/scoop2.hh>
+# ifdef OLENA_USE_SCOOP_ALT
+# include <stc/scoop-alt.hh>
# else
# include <stc/scoop.hh>
-# endif // OLENA_USE_NEW_SCOOP2
+# endif // OLENA_USE_SCOOP_ALT
# include <oln/core/type.hh>
// FIXME: Move to oln/core.
@@ -56,11 +56,9 @@
| Namespace equipment. |
`----------------------*/
-# ifndef OLENA_USE_NEW_SCOOP2
// The virtual types facility is inserted here because it also
// triggers Metalic's typedef introspection equipment.
stc_scoop_equipment_for_namespace(oln);
-# endif // !OLENA_USE_NEW_SCOOP2
namespace oln
Index: oln/core/image_entry.hh
--- oln/core/image_entry.hh (revision 726)
+++ oln/core/image_entry.hh (working copy)
@@ -71,9 +71,9 @@
// FIXME: default definitions:
typedef oln_point(E) psite_type;
-# ifndef OLENA_USE_NEW_SCOOP2
+# ifndef OLENA_USE_SCOOP_ALT
typedef oln_value(E) rvalue_type;
-# endif // !OLENA_USE_NEW_SCOOP2
+# endif // !OLENA_USE_SCOOP_ALT
/// \brief Morpher type.
///
@@ -81,13 +81,13 @@
typedef mlc::none morpher_type;
};
-# ifdef OLENA_USE_NEW_SCOOP2
+# ifdef OLENA_USE_SCOOP_ALT
template <typename E>
struct single_vtype< image_entry<E>, typedef_::rvalue_type >
{
typedef oln_value(E) ret;
};
-# endif // OLENA_USE_NEW_SCOOP2
+# endif // OLENA_USE_SCOOP_ALT
/// Entry class for point sets: image_entry<E> is an alias for
Index: oln/core/abstract/iterator_on_points.hh
--- oln/core/abstract/iterator_on_points.hh (revision 726)
+++ oln/core/abstract/iterator_on_points.hh (working copy)
@@ -54,19 +54,19 @@
struct vtypes< abstract::iterator_on_points<E> >
{
typedef stc::abstract point_type;
-# ifndef OLENA_USE_NEW_SCOOP2
+# ifndef OLENA_USE_SCOOP_ALT
typedef oln_deduce_deferred_vtype(E, point, coord) coord_type;
-# endif // !OLENA_USE_NEW_SCOOP2
+# endif // !OLENA_USE_SCOOP_ALT
};
-# ifdef OLENA_USE_NEW_SCOOP2
+# ifdef OLENA_USE_SCOOP_ALT
template <typename E>
struct single_vtype< abstract::iterator_on_points<E>,
typedef_::coord_type >
{
typedef oln_deduce_deferred_vtype(E, point, coord) ret;
};
-# endif // OLENA_USE_NEW_SCOOP2
+# endif // OLENA_USE_SCOOP_ALT
namespace abstract
Index: oln/core/abstract/image/hybrid/classical.hh
--- oln/core/abstract/image/hybrid/classical.hh (revision 726)
+++ oln/core/abstract/image/hybrid/classical.hh (working copy)
@@ -178,11 +178,11 @@
mlc::eq_< oln_vtype(E, grid), oln::grid1d >,
mlc::eq_< oln_deduce_vtype(E, topo, is_random_accessible), mlc::true_ >,
// FIXME: Shouldn't we use stc::is_found (resp. mlc::is_found) here?
-# ifdef OLENA_USE_NEW_SCOOP2
+# ifdef OLENA_USE_SCOOP_ALT
mlc::neq_< oln_deduce_vtype(E, topo, bbox), stc::not_found >
# else
mlc::neq_< oln_deduce_vtype(E, topo, bbox), mlc::not_found >
-# endif // OLENA_USE_NEW_SCOOP2
+# endif // OLENA_USE_SCOOP_ALT
> >
{
typedef abstract::classical_1d_image<E> ret;
@@ -196,11 +196,11 @@
mlc::eq_< oln_vtype(E, grid), oln::grid2d >,
mlc::eq_< oln_deduce_vtype(E, topo, is_random_accessible), mlc::true_ >,
// FIXME: Shouldn't we use stc::is_found (resp. mlc::is_found) here?
-# ifdef OLENA_USE_NEW_SCOOP2
+# ifdef OLENA_USE_SCOOP_ALT
mlc::neq_< oln_deduce_vtype(E, topo, bbox), stc::not_found >
# else
mlc::neq_< oln_deduce_vtype(E, topo, bbox), mlc::not_found >
-# endif // OLENA_USE_NEW_SCOOP2
+# endif // OLENA_USE_SCOOP_ALT
> >
{
typedef abstract::classical_2d_image<E> ret;
@@ -214,11 +214,11 @@
mlc::eq_< oln_vtype(E, grid), oln::grid3d >,
mlc::eq_< oln_deduce_vtype(E, topo, is_random_accessible), mlc::true_ >,
// FIXME: Shouldn't we use stc::is_found (resp. mlc::is_found) here?
-# ifdef OLENA_USE_NEW_SCOOP2
+# ifdef OLENA_USE_SCOOP_ALT
mlc::neq_< oln_deduce_vtype(E, topo, bbox), stc::not_found >
# else
mlc::neq_< oln_deduce_vtype(E, topo, bbox), mlc::not_found >
-# endif // OLENA_USE_NEW_SCOOP2
+# endif // OLENA_USE_SCOOP_ALT
> >
{
typedef abstract::classical_3d_image<E> ret;
@@ -231,11 +231,11 @@
where_< mlc::and_<
mlc::eq_< oln_deduce_vtype(E, topo, is_random_accessible), mlc::true_ >,
// FIXME: Shouldn't we use stc::is_found (resp. mlc::is_found) here?
-# ifdef OLENA_USE_NEW_SCOOP2
+# ifdef OLENA_USE_SCOOP_ALT
mlc::neq_< oln_deduce_vtype(E, topo, bbox), stc::not_found >
# else
mlc::neq_< oln_deduce_vtype(E, topo, bbox), mlc::not_found >
-# endif // OLENA_USE_NEW_SCOOP2
+# endif // OLENA_USE_SCOOP_ALT
> >
{
typedef abstract::classical_image<E> ret;
Index: oln/core/abstract/image/mutability/hierarchy.hh
--- oln/core/abstract/image/mutability/hierarchy.hh (revision 726)
+++ oln/core/abstract/image/mutability/hierarchy.hh (working copy)
@@ -108,11 +108,11 @@
/// With mutability.
template <typename E>
struct case_< image_hierarchy_wrt_mutability, E, 1 > :
-# ifdef OLENA_USE_NEW_SCOOP2
+# ifdef OLENA_USE_SCOOP_ALT
where_< stc::is_found_< oln_find_vtype(E, lvalue) > >
# else
where_< mlc::is_found_< oln_find_vtype(E, lvalue) > >
-# endif // OLENA_USE_NEW_SCOOP2
+# endif // OLENA_USE_SCOOP_ALT
{
typedef abstract::mutable_image<E> ret;
};
Index: oln/core/abstract/image/dimension/hierarchy.hh
--- oln/core/abstract/image/dimension/hierarchy.hh (revision 726)
+++ oln/core/abstract/image/dimension/hierarchy.hh (working copy)
@@ -98,11 +98,11 @@
struct case_< image_hierarchy_wrt_dimension, E, 1 > :
where_< mlc::and_<
mlc::eq_< oln_grid(E), oln::grid1d >,
-# ifdef OLENA_USE_NEW_SCOOP2
+# ifdef OLENA_USE_SCOOP_ALT
stc::is_found_< oln_find_vtype(E, lvalue) >
# else
mlc::is_found_< oln_find_vtype(E, lvalue) >
-# endif // OLENA_USE_NEW_SCOOP2
+# endif // OLENA_USE_SCOOP_ALT
> >
{
typedef abstract::mutable_image1d<E> ret;
@@ -121,11 +121,11 @@
struct case_< image_hierarchy_wrt_dimension, E, 3 > :
where_< mlc::and_<
mlc::eq_< oln_grid(E), oln::grid2d >,
-# ifdef OLENA_USE_NEW_SCOOP2
+# ifdef OLENA_USE_SCOOP_ALT
stc::is_found_< oln_find_vtype(E, lvalue) >
# else
mlc::is_found_< oln_find_vtype(E, lvalue) >
-# endif // OLENA_USE_NEW_SCOOP2
+# endif // OLENA_USE_SCOOP_ALT
> >
{
typedef abstract::mutable_image2d<E> ret;
@@ -144,11 +144,11 @@
struct case_< image_hierarchy_wrt_dimension, E, 5 > :
where_< mlc::and_<
mlc::eq_< oln_grid(E), oln::grid3d >,
-# ifdef OLENA_USE_NEW_SCOOP2
+# ifdef OLENA_USE_SCOOP_ALT
stc::is_found_< oln_find_vtype(E, lvalue) >
# else
mlc::is_found_< oln_find_vtype(E, lvalue) >
-# endif // OLENA_USE_NEW_SCOOP2
+# endif // OLENA_USE_SCOOP_ALT
> >
{
typedef abstract::mutable_image3d<E> ret;
Index: oln/core/abstract/image/neighborhood/hierarchy.hh
--- oln/core/abstract/image/neighborhood/hierarchy.hh (revision 726)
+++ oln/core/abstract/image/neighborhood/hierarchy.hh (working copy)
@@ -107,11 +107,11 @@
template <typename E>
struct case_< image_hierarchy_wrt_neighborhood, E, 1 > :
// FIXME: Shouldn't we use stc::is_found (resp. mlc::is_found) here?
-# ifdef OLENA_USE_NEW_SCOOP2
+# ifdef OLENA_USE_SCOOP_ALT
where_< mlc::neq_< oln_find_vtype(E, neighborhood), stc::not_found > >
# else
where_< mlc::neq_< oln_find_vtype(E, neighborhood), mlc::not_found > >
-# endif // OLENA_USE_NEW_SCOOP2
+# endif // OLENA_USE_SCOOP_ALT
{
typedef abstract::image_having_neighborhood<E> ret;
};
Index: oln/core/abstract/image/bbox/hierarchy.hh
--- oln/core/abstract/image/bbox/hierarchy.hh (revision 726)
+++ oln/core/abstract/image/bbox/hierarchy.hh (working copy)
@@ -136,11 +136,11 @@
template <typename E>
struct case_< image_hierarchy_wrt_bbox, E, 1 > :
// FIXME: Shouldn't we use stc::is_found (resp. mlc::is_found) here?
-# ifdef OLENA_USE_NEW_SCOOP2
+# ifdef OLENA_USE_SCOOP_ALT
where_< mlc::neq_< oln_deduce_vtype(E, topo, bbox), stc::not_found > >
# else
where_< mlc::neq_< oln_deduce_vtype(E, topo, bbox), mlc::not_found > >
-# endif // OLENA_USE_NEW_SCOOP2
+# endif // OLENA_USE_SCOOP_ALT
{
typedef abstract::image_having_bbox<E> ret;
};
Index: oln/core/abstract/image/value_wise_accessibility/hierarchy.hh
--- oln/core/abstract/image/value_wise_accessibility/hierarchy.hh (revision 726)
+++ oln/core/abstract/image/value_wise_accessibility/hierarchy.hh (working copy)
@@ -133,7 +133,7 @@
/// With mutable value-wise random accessibility.
template <typename E>
struct case_< image_hierarchy_wrt_value_wise_accessibility, E, 1 > :
-# ifdef OLENA_USE_NEW_SCOOP2
+# ifdef OLENA_USE_SCOOP_ALT
where_<
mlc_and( stc::is_found_< oln_find_vtype(E, fwd_viter) >,
stc::is_found_< oln_find_vtype(E, mutable_value_proxy) > )
@@ -143,7 +143,7 @@
mlc_and( mlc::is_found_< oln_find_vtype(E, fwd_viter) >,
mlc::is_found_< oln_find_vtype(E, mutable_value_proxy) > )
>
-# endif // OLENA_USE_NEW_SCOOP2
+# endif // OLENA_USE_SCOOP_ALT
{
typedef abstract::mutable_image_being_value_wise_random_accessible<E> ret;
};
@@ -151,11 +151,11 @@
/// With (constant) value-wise random accessibility.
template <typename E>
struct case_< image_hierarchy_wrt_value_wise_accessibility, E, 2 > :
-# ifdef OLENA_USE_NEW_SCOOP2
+# ifdef OLENA_USE_SCOOP_ALT
where_< stc::is_found_< oln_find_vtype(E, fwd_viter) > >
# else
where_< mlc::is_found_< oln_find_vtype(E, fwd_viter) > >
-# endif // OLENA_USE_NEW_SCOOP2
+# endif // OLENA_USE_SCOOP_ALT
{
typedef abstract::image_being_value_wise_random_accessible<E> ret;
};
Index: oln/core/abstract/point.hh
--- oln/core/abstract/point.hh (revision 726)
+++ oln/core/abstract/point.hh (working copy)
@@ -69,18 +69,18 @@
// FIXME: Prefer to use final<deduce..> when possible.
typedef stc::abstract grid_type;
typedef stc::abstract dpoint_type;
-# ifndef OLENA_USE_NEW_SCOOP2
+# ifndef OLENA_USE_SCOOP_ALT
typedef oln_deduce_deferred_vtype(E, dpoint, coord) coord_type;
-# endif // !OLENA_USE_NEW_SCOOP2
+# endif // !OLENA_USE_SCOOP_ALT
typedef stc::abstract dim_type;
-# ifndef OLENA_USE_NEW_SCOOP2
+# ifndef OLENA_USE_SCOOP_ALT
typedef oln_dim(E) dim_t;
typedef xtd::vec<mlc_value(dim_t), coord_type> vec_type;
-# endif // !OLENA_USE_NEW_SCOOP2
+# endif // !OLENA_USE_SCOOP_ALT
};
-# ifdef OLENA_USE_NEW_SCOOP2
+# ifdef OLENA_USE_SCOOP_ALT
template <typename E>
struct single_vtype< abstract::point<E>, typedef_::coord_type>
{
@@ -96,7 +96,7 @@
public:
typedef xtd::vec<mlc_value(dim_t), coord_t> ret;
};
-# endif // OLENA_USE_NEW_SCOOP2
+# endif // OLENA_USE_SCOOP_ALT
namespace abstract
Index: oln/core/internal/dpoint_nd.hh
--- oln/core/internal/dpoint_nd.hh (revision 726)
+++ oln/core/internal/dpoint_nd.hh (working copy)
@@ -54,16 +54,16 @@
template <typename E>
struct vtypes< internal::dpoint_nd<E> >
{
-# ifndef OLENA_USE_NEW_SCOOP2
+# ifndef OLENA_USE_SCOOP_ALT
private:
typedef oln_deferred_vtype(E, dim) dim_t;
typedef oln_deferred_vtype(E, coord) coord_t;
public:
typedef xtd::vec<mlc_value(dim_t), coord_t> vec_type;
-# endif // !OLENA_USE_NEW_SCOOP2
+# endif // !OLENA_USE_SCOOP_ALT
};
-# ifdef OLENA_USE_NEW_SCOOP2
+# ifdef OLENA_USE_SCOOP_ALT
template <typename E>
struct single_vtype< internal::dpoint_nd<E>, typedef_::vec_type >
{
@@ -73,7 +73,7 @@
public:
typedef xtd::vec<mlc_value(dim_t), coord_t> ret;
};
-# endif // OLENA_USE_NEW_SCOOP2
+# endif // OLENA_USE_SCOOP_ALT
namespace internal
{
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/static
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Rename stc/scoop2.hh as stc/scoop-alt.hh.
Encapsulate the contents of SCOOPED_NAMESPACE in
stc_scoop_equipment_for_namespace.
* stc/scoop2.hh: Rename as...
* stc/scoop-alt.hh: ...this.
Adjust header guards.
(ERROR::IN_find__VIRTUAL_TYPE_IS_ABSTRACT)
(ERROR::IN_find_local__VIRTUAL_TYPE_MULTIPLY_DEFINED)
(ERROR::IN_merge2__FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT)
(ERROR::IN_merge2__FINAL_VIRTUAL_TYPE_REDEFINED_FINAL)
(ERROR::IN_merge2__FINAL_VIRTUAL_TYPE_REDEFINED)
(ERROR::IN_merge2__VIRTUAL_TYPE_REDEFINED_ABSTRACT)
(ERROR::IN_merge3__FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT)
(ERROR::IN_merge3__VIRTUAL_TYPE_REDEFINED_ABSTRACT)
(ERROR::IN_merge3__LOCAL_DECLARATION_OF_NOT_DELEGATED_AND_ABSTRACT)
(ERROR::IN_merge3__FINAL_VIRTUAL_TYPE_REDEFINED_FINAL)
(ERROR::IN_merge3__FINAL_VIRTUAL_TYPE_REDEFINED): Rename as...
(ERROR::IN_find_VIRTUAL_TYPE_IS_ABSTRACT)
(ERROR::IN_find_local_VIRTUAL_TYPE_MULTIPLY_DEFINED)
(ERROR::IN_merge2_FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT)
(ERROR::IN_merge2_FINAL_VIRTUAL_TYPE_REDEFINED_FINAL)
(ERROR::IN_merge2_FINAL_VIRTUAL_TYPE_REDEFINED)
(ERROR::IN_merge2_VIRTUAL_TYPE_REDEFINED_ABSTRACT)
(ERROR::IN_merge3_FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT)
(ERROR::IN_merge3_VIRTUAL_TYPE_REDEFINED_ABSTRACT)
(ERROR::IN_merge3_LOCAL_DECLARATION_OF_NOT_DELEGATED_AND_ABSTRACT)
(ERROR::IN_merge3_FINAL_VIRTUAL_TYPE_REDEFINED_FINAL)
(ERROR::IN_merge3_FINAL_VIRTUAL_TYPE_REDEFINED): ...these.
(SCOOPED_NAMESPACE): Remove macro.
(stc_scoop_equipment_for_namespace): New macro.
Encapsulate the contents of SCOOPED_NAMESPACE within this macro.
(stc_match_pair_0p_with, stc_match_pair_1p_with)
(stc_match_pair_2p_with, stc_match_pair_1p_with_error)
(stc_match_pair_2p_with_error)
(stc_match_triple_0p_with, stc_match_triple_1p_with)
(stc_match_triple_2p_with, stc_match_triple_3p_with)
(stc_match_triple_2p_with_error, stc_match_triple_3p_with_error):
Move and rename these macros as..
* stc/internal/match-with.hh (stc_internal_match_pair_0p_with)
(stc_internal_match_pair_1p_with, stc_internal_match_pair_2p_with)
(stc_internal_match_pair_1p_with_error)
(stc_internal_match_pair_2p_with_error)
(stc_internal_match_triple_0p_with)
(stc_internal_match_triple_1p_with)
(stc_internal_match_triple_2p_with)
(stc_internal_match_triple_3p_with)
(stc_internal_match_triple_2p_with_error)
(stc_internal_match_triple_3p_with_error): ...these (new file).
* stc/Makefile (nobase_stc_HEADERS): Remove scoop2.hh.
Add scoop-alt.hh and internal/match-with.hh.
* tests/scoop2.cc: Rename as...
* tests/scoop-alt.cc: ...this.
Adjust.
(stc_scoop_equipment_for_namespace): Invoke it.
* tests/super.cc (my::set_pseudosuper_type<C>): Remove.
(my::vtypes<C>::delegatee_type): New.
* tests/Makefile.am (nobase_stc_HEADERS): Add
internal/match-with.hh.
(scoop2_SOURCES): Remove.
(scoop_alt_SOURCES): New.
stc/Makefile.am | 4
stc/internal/match-with.hh | 128 ++++
stc/scoop-alt.hh | 1199 +++++++++++++++++++++------------------------
tests/Makefile.am | 4
tests/scoop-alt.cc | 7
tests/super.cc | 6
6 files changed, 699 insertions(+), 649 deletions(-)
Index: tests/super.cc
--- tests/super.cc (revision 725)
+++ tests/super.cc (working copy)
@@ -80,11 +80,11 @@
simple test, but it doesn't matter: we are only checking the
super relationship here. */
- /// Link to B (``pseudo'' inheritance).
+ /// Delegation to B (used to be called ``pseudo'' inheritance).
template<>
- struct set_pseudosuper_type<C>
+ struct vtypes<C>
{
- typedef B ret;
+ typedef B delegatee_type;
};
struct C // no inheritance
Index: tests/scoop-alt.cc
--- tests/scoop-alt.cc (revision 724)
+++ tests/scoop-alt.cc (working copy)
@@ -35,14 +35,11 @@
#include <mlc/cmp.hh>
#include <mlc/assert.hh>
-#include <stc/scoop2.hh>
+#include <stc/scoop-alt.hh>
-/* FIXME: To be enabled later, when the contents of stc/scoop2.hh is
- enclosed in a macro. */
-#if 0
// Namespace equipment.
stc_scoop_equipment_for_namespace(my);
-#endif
+
// FIXME: Check single_vtype, too.
Index: tests/Makefile.am
--- tests/Makefile.am (revision 725)
+++ tests/Makefile.am (working copy)
@@ -23,7 +23,7 @@
\
tour \
\
- scoop2
+ scoop-alt
any_SOURCES = any.cc
@@ -36,7 +36,7 @@
tour_SOURCES = tour.cc
-scoop2_SOURCES = scoop2.cc
+scoop_alt_SOURCES = scoop-alt.cc
# Old tests.
EXTRA_DIST = multiple-supers.cc vtypes-multiple-supers.cc
Index: stc/scoop-alt.hh
--- stc/scoop-alt.hh (revision 724)
+++ stc/scoop-alt.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2005, 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2005, 2006, 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
@@ -25,23 +25,28 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/* \file stc/vtypes.hh
- \brief Equipment for SCOOP 2 (in particular, virtual types). */
+/* \file stc/scoop-alt.hh
-#ifndef STC_SCOOP2_HH
-# define STC_SCOOP2_HH
+ \brief Alternative equipment for SCOOP 2 (in particular, virtual
+ types). */
+
+
+#ifndef STC_SCOOP_ALT_HH
+# define STC_SCOOP_ALT_HH
# include <mlc/flags.hh>
# include <mlc/typedef.hh>
# include <mlc/abort.hh>
+# include <stc/internal/match-with.hh>
+
namespace stc
{
/* FIXME: Define a real stc::none, instead of making it an alias of
mlc::none. For compatibility purpose with the current
- implementation of the SCOOP 2 paradigme (see stc/scoop.hh), we
+ implementation of the SCOOP 2 paradigm (see stc/scoop.hh), we
need to have stc::none be equal to mlc::none. */
#if 0
struct none {};
@@ -73,20 +78,20 @@
namespace ERROR
{
- struct IN_find__VIRTUAL_TYPE_IS_ABSTRACT;
+ struct IN_find_VIRTUAL_TYPE_IS_ABSTRACT;
- struct IN_find_local__VIRTUAL_TYPE_MULTIPLY_DEFINED;
+ struct IN_find_local_VIRTUAL_TYPE_MULTIPLY_DEFINED;
- struct IN_merge2__FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT;
- struct IN_merge2__FINAL_VIRTUAL_TYPE_REDEFINED_FINAL;
- struct IN_merge2__FINAL_VIRTUAL_TYPE_REDEFINED;
- struct IN_merge2__VIRTUAL_TYPE_REDEFINED_ABSTRACT;
-
- struct IN_merge3__FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT;
- struct IN_merge3__VIRTUAL_TYPE_REDEFINED_ABSTRACT;
- struct IN_merge3__LOCAL_DECLARATION_OF_NOT_DELEGATED_AND_ABSTRACT;
- struct IN_merge3__FINAL_VIRTUAL_TYPE_REDEFINED_FINAL;
- struct IN_merge3__FINAL_VIRTUAL_TYPE_REDEFINED;
+ struct IN_merge2_FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT;
+ struct IN_merge2_FINAL_VIRTUAL_TYPE_REDEFINED_FINAL;
+ struct IN_merge2_FINAL_VIRTUAL_TYPE_REDEFINED;
+ struct IN_merge2_VIRTUAL_TYPE_REDEFINED_ABSTRACT;
+
+ struct IN_merge3_FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT;
+ struct IN_merge3_VIRTUAL_TYPE_REDEFINED_ABSTRACT;
+ struct IN_merge3_LOCAL_DECLARATION_OF_NOT_DELEGATED_AND_ABSTRACT;
+ struct IN_merge3_FINAL_VIRTUAL_TYPE_REDEFINED_FINAL;
+ struct IN_merge3_FINAL_VIRTUAL_TYPE_REDEFINED;
} // end of namespace ERROR
@@ -97,631 +102,551 @@
// Based on doc/algorithm.ml.
-// FIXME: Temp. hack. The contents of SCOOPED_NAMESPACE will be
-// available later as a macro, as in stc/scoop.hh. Currently, it's
-// easier to work without this macro equipment.
-#define SCOOPED_NAMESPACE oln
-
-
-// ------------------------------------------------------------ find_local.
-
-// Highly inspired from Th�o's get_stm!
-
-namespace SCOOPED_NAMESPACE
-{
-
- // Declare delegatee_type.
- mlc_decl_typedef(delegatee_type);
-
-
- template <typename class_name>
- struct set_super_type
- {
- };
-
- template <typename class_name>
- struct vtypes
- {
- };
-
- template <typename class_name, typename type_name>
- struct single_vtype
- {
- typedef mlc::not_found ret;
- };
-
- namespace find_local_
- {
- // Forward declaration.
- template <typename T, typename U> struct match_with;
-
- template <typename T>
- struct match_with <T, mlc::not_found>
- {
- typedef T ret;
- };
-
- template <typename U>
- struct match_with <mlc::not_found, U>
- {
- typedef U ret;
- };
-
- template <>
- struct match_with <mlc::not_found, mlc::not_found>
- {
- typedef stc::not_found ret;
- };
-
- template <typename T, typename U>
- struct match_with :
- mlc::abort_<T, stc::ERROR::IN_find_local__VIRTUAL_TYPE_MULTIPLY_DEFINED>
- {
- };
-
- } // end of namespace find_local_
-
- template <typename source, typename target>
- struct find_local
- {
- typedef SCOOPED_NAMESPACE::vtypes<source> decl1;
- typedef typename target::template from_<decl1>::ret res1;
-
- typedef SCOOPED_NAMESPACE::single_vtype<source, target> decl2;
- typedef typename decl2::ret ret2;
- // Result.
- typedef typename find_local_::match_with<res1, ret2>::ret ret;
- };
-
-
- // -------------------------------------------------------------- merge2.
-
-// Shortcuts macros.
-#define stc_match_pair_0p_with(Local, Super, Res) \
+#define stc_scoop_equipment_for_namespace(SCOOPED_NAMESPACE) \
+ \
+namespace SCOOPED_NAMESPACE \
+{ \
+ \
+ /* Declare delegatee_type. */ \
+ mlc_decl_typedef(delegatee_type); \
+ \
+ \
+ template <typename class_name> \
+ struct set_super_type \
+ { \
+ }; \
+ \
+ template <typename class_name> \
+ struct vtypes \
+ { \
+ }; \
+ \
+ template <typename class_name, typename type_name> \
+ struct single_vtype \
+ { \
+ typedef mlc::not_found ret; \
+ }; \
+ \
+ /* ----------------------------------------------------- find_local. */ \
+ \
+ /* Highly inspired from Th�o's get_stm! */ \
+ \
+ namespace find_local_ \
+ { \
+ /* Forward declaration. */ \
+ template <typename T, typename U> struct match_with; \
+ \
+ template <typename T> \
+ struct match_with <T, mlc::not_found> \
+ { \
+ typedef T ret; \
+ }; \
+ \
+ template <typename U> \
+ struct match_with <mlc::not_found, U> \
+ { \
+ typedef U ret; \
+ }; \
+ \
template <> \
- struct match_with< Local, Super > \
- { \
- typedef Res ret; \
- }
-
-#define stc_match_pair_1p_with(T1, Local, Super, Res) \
- template < typename T1 > \
- struct match_with< Local, Super > \
- { \
- typedef Res ret; \
- }
-
-#define stc_match_pair_2p_with(T1, T2, Local, Super, Res) \
- template < typename T1, typename T2 > \
- struct match_with< Local, Super > \
- { \
- typedef Res ret; \
- }
-
-// Erroneous cases.
-#define stc_match_pair_1p_with_error(T1, Local, Super, Msg) \
- template < typename T1 > \
- struct match_with< Local, Super > : \
- mlc::abort_< T1, Msg > \
- { \
- }
-
-#define stc_match_pair_2p_with_error(T1, T2, Local, Super, Msg) \
- template < typename T1, typename T2 > \
- struct match_with< Local, Super > : \
- mlc::abort_< T2, Msg > \
+ struct match_with <mlc::not_found, mlc::not_found> \
{ \
- }
-
-
- namespace merge2_
- {
- // Forward declaration.
- template <typename T, typename U> struct match_with;
-
-
- /*------------------------------.
- | local_res == stc::not_found. |
- `------------------------------*/
-
- stc_match_pair_0p_with(stc::not_found, stc::not_found,
- stc::not_found);
-
- stc_match_pair_0p_with(stc::not_found, stc::abstract,
- stc::not_found);
-
- stc_match_pair_1p_with(U,
- stc::not_found, stc::final<U>,
- stc::final<U>);
-
- stc_match_pair_1p_with(U,
- stc::not_found, U,
- U);
-
-
- /*-----------------------------.
- | local_res == stc::abstract. |
- `-----------------------------*/
-
- stc_match_pair_0p_with(stc::abstract, stc::not_found,
- stc::abstract);
-
- stc_match_pair_0p_with(stc::abstract, stc::abstract,
- stc::abstract);
-
- stc_match_pair_1p_with_error(U,
- stc::abstract, stc::final<U>,
- stc::ERROR::IN_merge2__FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT);
-
- stc_match_pair_1p_with_error(U,
- stc::abstract, U,
- stc::ERROR::IN_merge2__VIRTUAL_TYPE_REDEFINED_ABSTRACT);
-
-
- /*-----------------------------.
- | local_res == stc::final<T>. |
- `-----------------------------*/
-
- stc_match_pair_1p_with(T,
- stc::final<T>, stc::not_found,
- stc::final<T>);
-
- stc_match_pair_1p_with(T,
- stc::final<T>, stc::abstract,
- stc::final<T>);
-
- stc_match_pair_2p_with_error(T, U,
- stc::final<T>, stc::final<U>,
- stc::ERROR::IN_merge2__FINAL_VIRTUAL_TYPE_REDEFINED_FINAL);
-
- stc_match_pair_2p_with(T, U,
- stc::final<T>, U,
- stc::final<T>);
-
-
- /*-----------------.
- | local_res == T. |
- `-----------------*/
-
- stc_match_pair_1p_with(T,
- T, stc::not_found,
- T);
-
- stc_match_pair_1p_with(T,
- T, stc::abstract,
- T);
-
- stc_match_pair_2p_with_error(T, U,
- T, stc::final<U>,
- stc::ERROR::IN_merge2__FINAL_VIRTUAL_TYPE_REDEFINED);
-
- template <typename T, typename U>
- struct match_with
- {
- typedef T ret;
- };
-
- } // end of namespace merge2_
-
-#undef stc_match_pair_2p_with_error
-#undef stc_match_pair_1p_with_error
-#undef stc_match_pair_2p_with
-#undef stc_match_pair_1p_with
-#undef stc_match_pair_0p_with
-
- template <typename local_res, typename super_res>
- struct merge2
- {
- // Result.
- typedef typename merge2_::match_with<local_res, super_res>::ret ret;
- };
-
-
- // -------------------------------------------------------------- merge3.
-
-// Shortcuts macros.
-#define stc_match_triple_0p_with(Local, Super, Deleg, Res) \
+ typedef stc::not_found ret; \
+ }; \
+ \
+ template <typename T, typename U> \
+ struct match_with : \
+ mlc::abort_<T, \
+ stc::ERROR::IN_find_local_VIRTUAL_TYPE_MULTIPLY_DEFINED> \
+ { \
+ }; \
+ \
+ } /* end of namespace find_local_ */ \
+ \
+ template <typename source, typename target> \
+ struct find_local \
+ { \
+ typedef SCOOPED_NAMESPACE::vtypes<source> decl1; \
+ typedef typename target::template from_<decl1>::ret res1; \
+ \
+ typedef SCOOPED_NAMESPACE::single_vtype<source, target> decl2; \
+ typedef typename decl2::ret ret2; \
+ \
+ \
+ /* Result. */ \
+ typedef typename find_local_::match_with<res1, ret2>::ret ret; \
+ }; \
+ \
+ \
+ /* --------------------------------------------------------- merge2. */ \
+ \
+ \
+ namespace merge2_ \
+ { \
+ /* Forward declaration. */ \
+ template <typename T, typename U> struct match_with; \
+ \
+ \
+ /* ----------------------------- */ \
+ /* local_res == stc::not_found. */ \
+ /* ----------------------------- */ \
+ \
+ stc_internal_match_pair_0p_with(stc::not_found, stc::not_found, \
+ stc::not_found); \
+ \
+ stc_internal_match_pair_0p_with(stc::not_found, stc::abstract, \
+ stc::not_found); \
+ \
+ stc_internal_match_pair_1p_with(U, \
+ stc::not_found, stc::final<U>, \
+ stc::final<U>); \
+ \
+ stc_internal_match_pair_1p_with(U, \
+ stc::not_found, U, \
+ U); \
+ \
+ \
+ /* ---------------------------- */ \
+ /* local_res == stc::abstract. */ \
+ /* ---------------------------- */ \
+ \
+ stc_internal_match_pair_0p_with(stc::abstract, stc::not_found, \
+ stc::abstract); \
+ \
+ stc_internal_match_pair_0p_with(stc::abstract, stc::abstract, \
+ stc::abstract); \
+ \
+ stc_internal_match_pair_1p_with_error(U, \
+ stc::abstract, stc::final<U>, \
+ stc::ERROR::IN_merge2_FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT); \
+ \
+ stc_internal_match_pair_1p_with_error(U, \
+ stc::abstract, U, \
+ stc::ERROR::IN_merge2_VIRTUAL_TYPE_REDEFINED_ABSTRACT); \
+ \
+ \
+ /* ---------------------------- */ \
+ /* local_res == stc::final<T>. */ \
+ /* ---------------------------- */ \
+ \
+ stc_internal_match_pair_1p_with(T, \
+ stc::final<T>, stc::not_found, \
+ stc::final<T>); \
+ \
+ stc_internal_match_pair_1p_with(T, \
+ stc::final<T>, stc::abstract, \
+ stc::final<T>); \
+ \
+ stc_internal_match_pair_2p_with_error(T, U, \
+ stc::final<T>, stc::final<U>, \
+ stc::ERROR::IN_merge2_FINAL_VIRTUAL_TYPE_REDEFINED_FINAL); \
+ \
+ stc_internal_match_pair_2p_with(T, U, \
+ stc::final<T>, U, \
+ stc::final<T>); \
+ \
+ \
+ /* ---------------- */ \
+ /* local_res == T. */ \
+ /* ---------------- */ \
+ \
+ stc_internal_match_pair_1p_with(T, \
+ T, stc::not_found, \
+ T); \
+ \
+ stc_internal_match_pair_1p_with(T, \
+ T, stc::abstract, \
+ T); \
+ \
+ stc_internal_match_pair_2p_with_error(T, U, \
+ T, stc::final<U>, \
+ stc::ERROR::IN_merge2_FINAL_VIRTUAL_TYPE_REDEFINED); \
+ \
+ template <typename T, typename U> \
+ struct match_with \
+ { \
+ typedef T ret; \
+ }; \
+ \
+ } /* end of namespace merge2_ */ \
+ \
+ template <typename local_res, typename super_res> \
+ struct merge2 \
+ { \
+ /* Result. */ \
+ typedef typename merge2_::match_with<local_res, super_res>::ret ret; \
+ }; \
+ \
+ \
+ /* --------------------------------------------------------- merge3. */ \
+ \
+ \
+ namespace merge3_ \
+ { \
+ /* Forward declaration. */ \
+ template <typename T, typename U, typename V> struct match_with; \
+ \
+ \
+ /* ----------------------------- */ \
+ /* local_res == stc::not_found. */ \
+ /* ----------------------------- */ \
+ \
+ /* super_res == stc::not_found. */ \
+ stc_internal_match_triple_0p_with( \
+ stc::not_found, stc::not_found, stc::not_found, \
+ stc::not_found); \
+ \
+ stc_internal_match_triple_0p_with( \
+ stc::not_found, stc::not_found, stc::abstract, \
+ stc::not_found); \
+ \
+ stc_internal_match_triple_1p_with(V, \
+ stc::not_found, stc::not_found, stc::final<V>, \
+ stc::final<V>); \
+ \
+ stc_internal_match_triple_1p_with(V, \
+ stc::not_found, stc::not_found, V, \
+ V); \
+ \
+ /* super_res == stc::abstract. */ \
+ stc_internal_match_triple_0p_with( \
+ stc::not_found, stc::abstract, stc::not_found, \
+ stc::not_found); \
+ \
+ stc_internal_match_triple_0p_with( \
+ stc::not_found, stc::abstract, stc::abstract, \
+ stc::abstract); \
+ \
+ stc_internal_match_triple_1p_with(V, \
+ stc::not_found, stc::abstract, stc::final<V>, \
+ stc::final<V>); \
+ \
+ stc_internal_match_triple_1p_with(V, \
+ stc::not_found, stc::abstract, V, \
+ V); \
+ \
+ /* super_res is a concrete type. */ \
+ stc_internal_match_triple_2p_with(U, V, \
+ stc::not_found, stc::final<U>, V, \
+ stc::final<U>); \
+ \
+ stc_internal_match_triple_2p_with(U, V, \
+ stc::not_found, U, V, \
+ U); \
+ \
+ \
+ /* ---------------------------- */ \
+ /* local_res == stc::abstract. */ \
+ /* ---------------------------- */ \
+ \
+ /* super_res == stc::not_found. */ \
+ stc_internal_match_triple_0p_with( \
+ stc::abstract, stc::not_found, stc::not_found, \
+ stc::abstract); \
+ \
+ stc_internal_match_triple_0p_with( \
+ stc::abstract, stc::not_found, stc::abstract, \
+ stc::abstract); \
+ \
+ stc_internal_match_triple_1p_with(V, \
+ stc::abstract, stc::not_found, stc::final<V>, \
+ stc::final<V>); \
+ \
+ stc_internal_match_triple_1p_with(V, \
+ stc::abstract, stc::not_found, V, \
+ V); \
+ \
+ \
+ /* super_res == stc::abstract. */ \
+ stc_internal_match_triple_0p_with( \
+ stc::abstract, stc::abstract, stc::not_found, \
+ stc::abstract); \
+ \
+ stc_internal_match_triple_0p_with( \
+ stc::abstract, stc::abstract, stc::abstract, \
+ stc::abstract); \
+ \
+ stc_internal_match_triple_1p_with(V, \
+ stc::abstract, stc::abstract, stc::final<V>, \
+ stc::final<V>); \
+ \
+ stc_internal_match_triple_1p_with(V, \
+ stc::abstract, stc::abstract, V, \
+ V); \
+ \
+ \
+ /* super_res == stc::not_delegated_abstract. */ \
+ stc_internal_match_triple_1p_with(V, \
+ stc::abstract, stc::not_delegated_abstract, V, \
+ stc::not_delegated_abstract); \
+ \
+ stc_internal_match_triple_1p_with(V, \
+ stc::abstract, stc::not_delegated, V, \
+ stc::not_delegated_abstract); \
+ \
+ \
+ /* super_res is a concrete type. */ \
+ stc_internal_match_triple_2p_with_error(U, V, \
+ stc::abstract, stc::final<U>, V, \
+ stc::ERROR::IN_merge3_FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT); \
+ \
+ stc_internal_match_triple_2p_with_error(U, V, \
+ stc::abstract, U, V, \
+ stc::ERROR::IN_merge3_VIRTUAL_TYPE_REDEFINED_ABSTRACT); \
+ \
+ \
+ /* --------------------------------- */ \
+ /* local_res == stc::not_delegated. */ \
+ /* --------------------------------- */ \
+ \
+ stc_internal_match_triple_1p_with(V, \
+ stc::not_delegated, stc::not_found, V, \
+ stc::not_delegated); \
+ \
+ stc_internal_match_triple_1p_with(V, \
+ stc::not_delegated, stc::abstract, V, \
+ stc::not_delegated_abstract); \
+ \
+ stc_internal_match_triple_1p_with(V, \
+ stc::not_delegated, stc::not_delegated_abstract, V, \
+ stc::not_delegated_abstract); \
+ \
+ \
+ /* ------------------------------------------ */ \
+ /* local_res == stc::not_delegated_abstract. */ \
+ /* ------------------------------------------ */ \
+ \
+ /* FIXME: Shouldn't we introduce a means to tag a vtype both as */ \
+ /* abstract *and* not delegated? (Currently, the rule below */ \
+ /* prevents this). */ \
+ stc_internal_match_triple_2p_with_error(U, V, \
+ stc::not_delegated_abstract, U, V, \
+ stc::ERROR::IN_merge3_LOCAL_DECLARATION_OF_NOT_DELEGATED_AND_ABSTRACT); \
+ \
+ \
+ /* ---------------------------- */ \
+ /* local_res == stc::final<T>. */ \
+ /* ---------------------------- */ \
+ \
+ stc_internal_match_triple_3p_with_error(T, U, V, \
+ stc::final<T>, stc::final<U>, V, \
+ stc::ERROR::IN_merge3_FINAL_VIRTUAL_TYPE_REDEFINED_FINAL); \
+ \
+ stc_internal_match_triple_3p_with(T, U, V, \
+ stc::final<T>, U, V, \
+ stc::final<T>); \
+ \
+ \
+ /* ---------------- */ \
+ /* local_res == T. */ \
+ /* ---------------- */ \
+ \
+ stc_internal_match_triple_3p_with_error(T, U, V, \
+ T, stc::final<U>, V, \
+ stc::ERROR::IN_merge3_FINAL_VIRTUAL_TYPE_REDEFINED); \
+ \
+ template <typename T, typename U, typename V> \
+ struct match_with \
+ { \
+ typedef T ret; \
+ }; \
+ \
+ } /* end of namespace merge3_ */ \
+ \
+ \
+ template <typename local_res, typename super_res, typename delegatee_res> \
+ struct merge3 \
+ { \
+ /* Result. */ \
+ typedef typename \
+ merge3_::match_with<local_res, super_res, delegatee_res>::ret ret; \
+ }; \
+ \
+ \
+ /* ------------------------------------------------------ find_rec. */ \
+ \
+ /* Forward declarations. */ \
+ template <typename source, typename target> struct find_rec; \
+ template <typename source, typename target> struct find_rec_in_supers; \
+ \
+ \
+ namespace find_rec_ \
+ { \
+ \
+ namespace find_delegatee_res_ \
+ { \
+ /* Forward declaration. */ \
+ template <typename delegatee, typename target> struct match_with; \
+ \
+ template <typename target> \
+ struct match_with<stc::not_found, target> \
+ { \
+ typedef stc::not_found ret; \
+ }; \
+ \
+ template <typename target> \
+ struct match_with<stc::abstract, target> \
+ { \
+ typedef stc::not_found ret; \
+ }; \
+ \
+ template <typename delegatee, typename target> \
+ struct match_with \
+ { \
+ typedef typename find_rec<delegatee, target>::ret ret; \
+ }; \
+ \
+ } /* end of namespace find_delegatee_res_ */ \
+ \
+ \
+ /* Forward declaration. */ \
+ template <typename source, typename target> struct match_with; \
+ \
+ template <typename target> \
+ struct match_with<stc::none, target> \
+ { \
+ typedef stc::not_found ret; \
+ }; \
+ \
+ template <typename source, typename target> \
+ struct match_with \
+ { \
+ typedef typename find_local<source, target>::ret local_res; \
+ typedef typename find_rec<stc_super(source), target>::ret super_res; \
+ /* delegatee_type is the name of the (optional) virtual type */ \
+ /* containing the (type of the) delgatee. */ \
+ typedef typename \
+ find_rec_in_supers<source, typedef_::delegatee_type>::ret delegatee; \
+ \
+ typedef typename \
+ find_delegatee_res_::match_with<delegatee, target>::ret delegatee_res; \
+ typedef typename \
+ merge3<local_res, super_res, delegatee_res>::ret ret; \
+ }; \
+ \
+ } /* end of namespace find_rec_ */ \
+ \
+ template <typename source, typename target> \
+ struct find_rec \
+ { \
+ /* Result. */ \
+ typedef typename find_rec_::match_with<source, target>::ret ret; \
+ }; \
+ \
+ \
+ /* --------------------------------------------- find_rec_in_supers. */ \
+ \
+ namespace find_rec_in_supers_ \
+ { \
+ /* Forward declaration. */ \
+ template <typename source, typename target> struct match_with; \
+ \
+ template <typename target> \
+ struct match_with<stc::none, target> \
+ { \
+ typedef stc::none ret; \
+ }; \
+ \
+ template <typename source, typename target> \
+ struct match_with \
+ { \
+ typedef typename find_local<source, target>::ret local_res; \
+ typedef typename find_rec<stc_super(source), target>::ret super_res; \
+ typedef typename merge2<local_res, super_res>::ret ret; \
+ }; \
+ \
+ } /* end of namespace find_rec_in_supers_ */ \
+ \
+ template <typename source, typename target> \
+ struct find_rec_in_supers \
+ { \
+ /* Result. */ \
+ typedef typename \
+ find_rec_in_supers_::match_with<source, target>::ret ret; \
+ }; \
+ \
+ \
+ /* ----------------------------------------------------------- find. */ \
+ \
+ namespace find_ \
+ { \
+ /* Forward declaration. */ \
+ template <typename T> struct match_with; \
+ \
+ /* FIXME: We'd like to add a static abort here, but we can't, */ \
+ /* since stc::abstract is not a free parameter (enabling this */ \
+ /* abort statement would prevent any compilation). */ \
template <> \
- struct match_with< Local, Super, Deleg > \
- { \
- typedef Res ret; \
- }
-
-#define stc_match_triple_1p_with(T1, Local, Super, Deleg, Res) \
- template < typename T1 > \
- struct match_with< Local, Super, Deleg > \
- { \
- typedef Res ret; \
- }
-
-#define stc_match_triple_2p_with(T1, T2, Local, Super, Deleg, Res) \
- template < typename T1, typename T2 > \
- struct match_with< Local, Super, Deleg > \
- { \
- typedef Res ret; \
- }
-
-#define stc_match_triple_3p_with(T1, T2, T3, Local, Super, Deleg, Res) \
- template < typename T1, typename T2, typename T3 > \
- struct match_with< Local, Super, Deleg > \
- { \
- typedef Res ret; \
- }
-
-// Erroneous cases.
-#define stc_match_triple_2p_with_error(T1, T2, Local, Super, Deleg, Msg) \
- template < typename T1, typename T2 > \
- struct match_with< Local, Super, Deleg > : \
- mlc::abort_< T2, Msg > \
+ struct match_with<stc::abstract> \
+ /* : mlc::abort_<stc::abstract, \
+ stc::ERROR::IN_find_VIRTUAL_TYPE_IS_ABSTRACT> */ \
+ { \
+ }; \
+ \
+ /* FIXME: We'd like to add a static abort here, but we can't, */ \
+ /* since stc::not_delegated_abstract is not a free parameter */ \
+ /* (enabling this abort statement would prevent any */ \
+ /* compilation). */ \
+ template <> \
+ struct match_with<stc::not_delegated_abstract> \
+ /* : mlc::abort_<stc::not_delegated_abstract, */ \
+ /* stc::ERROR::IN_find_VIRTUAL_TYPE_IS_ABSTRACT> */ \
{ \
- }
-
-#define stc_match_triple_3p_with_error(T1, T2, T3, Local, Super, Deleg, Msg) \
- template < typename T1, typename T2, typename T3 > \
- struct match_with< Local, Super, Deleg > : \
- mlc::abort_< T3, Msg > \
+ }; \
+ \
+ template <> \
+ struct match_with<stc::not_delegated> \
{ \
- }
-
-
- namespace merge3_
- {
- // Forward declaration.
- template <typename T, typename U, typename V> struct match_with;
-
-
- /*------------------------------.
- | local_res == stc::not_found. |
- `------------------------------*/
-
- // super_res == stc::not_found.
- stc_match_triple_0p_with(stc::not_found, stc::not_found, stc::not_found,
- stc::not_found);
-
- stc_match_triple_0p_with(stc::not_found, stc::not_found, stc::abstract,
- stc::not_found);
-
- stc_match_triple_1p_with(V,
- stc::not_found, stc::not_found, stc::final<V>,
- stc::final<V>);
-
- stc_match_triple_1p_with(V,
- stc::not_found, stc::not_found, V,
- V);
-
- // super_res == stc::abstract.
- stc_match_triple_0p_with(stc::not_found, stc::abstract, stc::not_found,
- stc::not_found);
-
- stc_match_triple_0p_with(stc::not_found, stc::abstract, stc::abstract,
- stc::abstract);
-
- stc_match_triple_1p_with(V,
- stc::not_found, stc::abstract, stc::final<V>,
- stc::final<V>);
-
- stc_match_triple_1p_with(V,
- stc::not_found, stc::abstract, V,
- V);
-
- // super_res is a concrete type.
- stc_match_triple_2p_with(U, V,
- stc::not_found, stc::final<U>, V,
- stc::final<U>);
-
- stc_match_triple_2p_with(U, V,
- stc::not_found, U, V,
- U);
-
-
- /*-----------------------------.
- | local_res == stc::abstract. |
- `-----------------------------*/
-
- // super_res == stc::not_found.
- stc_match_triple_0p_with(stc::abstract, stc::not_found, stc::not_found,
- stc::abstract);
-
- stc_match_triple_0p_with(stc::abstract, stc::not_found, stc::abstract,
- stc::abstract);
-
- stc_match_triple_1p_with(V,
- stc::abstract, stc::not_found, stc::final<V>,
- stc::final<V>);
-
- stc_match_triple_1p_with(V,
- stc::abstract, stc::not_found, V,
- V);
-
-
- // super_res == stc::abstract.
- stc_match_triple_0p_with(stc::abstract, stc::abstract, stc::not_found,
- stc::abstract);
-
- stc_match_triple_0p_with(stc::abstract, stc::abstract, stc::abstract,
- stc::abstract);
-
- stc_match_triple_1p_with(V,
- stc::abstract, stc::abstract, stc::final<V>,
- stc::final<V>);
-
- stc_match_triple_1p_with(V,
- stc::abstract, stc::abstract, V,
- V);
-
-
- // super_res == stc::not_delegated_abstract.
- stc_match_triple_1p_with(V,
- stc::abstract, stc::not_delegated_abstract, V,
- stc::not_delegated_abstract);
-
- stc_match_triple_1p_with(V,
- stc::abstract, stc::not_delegated, V,
- stc::not_delegated_abstract);
-
-
- // super_res is a concrete type.
- stc_match_triple_2p_with_error(U, V,
- stc::abstract, stc::final<U>, V,
- stc::ERROR::IN_merge3__FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT);
-
- stc_match_triple_2p_with_error(U, V,
- stc::abstract, U, V,
- stc::ERROR::IN_merge3__VIRTUAL_TYPE_REDEFINED_ABSTRACT);
-
-
- /*----------------------------------.
- | local_res == stc::not_delegated. |
- `----------------------------------*/
-
- stc_match_triple_1p_with(V,
- stc::not_delegated, stc::not_found, V,
- stc::not_delegated);
-
- stc_match_triple_1p_with(V,
- stc::not_delegated, stc::abstract, V,
- stc::not_delegated_abstract);
-
- stc_match_triple_1p_with(V,
- stc::not_delegated, stc::not_delegated_abstract, V,
- stc::not_delegated_abstract);
-
-
- /*----------------------------------------------.
- | local_res == stc::not_delegated_abstract. *) |
- `----------------------------------------------*/
-
- /* FIXME: Shouldn't we introduce a means to tag a vtype both
- as abstract *and* not delegated? (Currently, the rule below
- prevents this). */
- stc_match_triple_2p_with_error(U, V,
- stc::not_delegated_abstract, U, V,
- stc::ERROR::IN_merge3__LOCAL_DECLARATION_OF_NOT_DELEGATED_AND_ABSTRACT);
-
-
- /*-----------------------------.
- | local_res == stc::final<T>. |
- `-----------------------------*/
-
- stc_match_triple_3p_with_error(T, U, V,
- stc::final<T>, stc::final<U>, V,
- stc::ERROR::IN_merge3__FINAL_VIRTUAL_TYPE_REDEFINED_FINAL);
-
- stc_match_triple_3p_with(T, U, V,
- stc::final<T>, U, V,
- stc::final<T>);
-
-
- /*-----------------.
- | local_res == T. |
- `-----------------*/
-
- stc_match_triple_3p_with_error(T, U, V,
- T, stc::final<U>, V,
- stc::ERROR::IN_merge3__FINAL_VIRTUAL_TYPE_REDEFINED);
-
- template <typename T, typename U, typename V>
- struct match_with
- {
- typedef T ret;
- };
-
- } // end of namespace merge3_
-
-
-#undef stc_match_triple_3p_with_error
-#undef stc_match_triple_2p_with_error
-#undef stc_match_triple_3p_with
-#undef stc_match_triple_2p_with
-#undef stc_match_triple_1p_with
-#undef stc_match_triple_0p_with
-
-
- template <typename local_res, typename super_res, typename delegatee_res>
- struct merge3
- {
- // Result.
- typedef typename merge3_::match_with<local_res, super_res, delegatee_res>::ret ret;
- };
-
-
- // ----------------------------------------------------------- find_rec.
-
- // Forward declarations.
- template <typename source, typename target> struct find_rec;
- template <typename source, typename target> struct find_rec_in_supers;
-
-
- namespace find_rec_
- {
-
- namespace find_delegatee_res_
- {
- // Forward declaration.
- template <typename delegatee, typename target> struct match_with;
-
- template <typename target>
- struct match_with<stc::not_found, target>
- {
- typedef stc::not_found ret;
- };
-
- template <typename target>
- struct match_with<stc::abstract, target>
- {
- typedef stc::not_found ret;
- };
-
- template <typename delegatee, typename target>
- struct match_with
- {
- typedef typename find_rec<delegatee, target>::ret ret;
- };
-
- } // end of namespace find_delegatee_res_
-
-
- // Forward declaration.
- template <typename source, typename target> struct match_with;
-
- template <typename target>
- struct match_with<stc::none, target>
- {
- typedef stc::not_found ret;
- };
-
- template <typename source, typename target>
- struct match_with
- {
- typedef typename find_local<source, target>::ret local_res;
- typedef typename find_rec<stc_super(source), target>::ret super_res;
- // delegatee_type is the name of the (optional) virtual type
- // containing the (type of the) delgatee.
- typedef typename find_rec_in_supers<source, typedef_::delegatee_type>::ret delegatee;
-
- typedef typename find_delegatee_res_::match_with<delegatee, target>::ret delegatee_res;
- typedef typename merge3<local_res, super_res, delegatee_res>::ret ret;
- };
-
- } // end of namespace find_rec_
-
- template <typename source, typename target>
- struct find_rec
- {
- // Result.
- typedef typename find_rec_::match_with<source, target>::ret ret;
- };
-
-
- // -------------------------------------------------- find_rec_in_supers.
-
- namespace find_rec_in_supers_
- {
- // Forward declaration.
- template <typename source, typename target> struct match_with;
-
- template <typename target>
- struct match_with<stc::none, target>
- {
- typedef stc::none ret;
- };
-
- template <typename source, typename target>
- struct match_with
- {
- typedef typename find_local<source, target>::ret local_res;
- typedef typename find_rec<stc_super(source), target>::ret super_res;
- typedef typename merge2<local_res, super_res>::ret ret;
- };
-
- } // end of namespace find_rec_in_supers_
-
- template <typename source, typename target>
- struct find_rec_in_supers
- {
- // Result.
- typedef typename find_rec_in_supers_::match_with<source, target>::ret ret;
- };
-
-
- // ---------------------------------------------------------------- find.
-
- namespace find_
- {
- // Forward declaration.
- template <typename T> struct match_with;
-
- template <>
- struct match_with<stc::abstract>
-/* FIXME: We'd like to add a static abort here, but we can't, since
- stc::abstract is not a free parameter (enabling this abort statement
- would prevent any compilation). */
-#if 0
- : mlc::abort_<stc::abstract,
- stc::ERROR::IN_find__VIRTUAL_TYPE_IS_ABSTRACT>
-#endif
- {
- };
-
- template <>
- struct match_with<stc::not_delegated_abstract>
-/* FIXME: We'd like to add a static abort here, but we can't, since
- stc::not_delegated_abstract is not a free parameter (enabling this
- abort statement would prevent any compilation). */
-#if 0
- : mlc::abort_<stc::not_delegated_abstract,
- stc::ERROR::IN_find__VIRTUAL_TYPE_IS_ABSTRACT>
-#endif
- {
- };
-
- template <>
- struct match_with<stc::not_delegated>
- {
- typedef stc::not_found ret;
- };
-
- template <typename T>
- struct match_with< stc::final<T> >
- {
- typedef T ret;
- };
-
- template <typename T>
- struct match_with
- {
- typedef T ret;
- };
-
- } // end of namespace find_
-
-
- /// Find a virtual type.
- template <typename source, typename target>
- struct find_vtype
- {
- typedef typename find_rec<source, target>::ret res;
- // Result.
- typedef typename find_::match_with<res>::ret ret;
- };
-
-
- /// Find a virtual type, and ensure it is found.
- template <typename from, typename target>
- struct vtype
- {
- typedef typename find_vtype<from, target>::ret res;
- struct check_ : mlc::assert_< mlc::is_found_<res> >
- {
- typedef res ret;
- };
- typedef typename check_::ret ret;
- };
-
-} /* end of SCOOPED_NAMESPACE */
-
+ typedef stc::not_found ret; \
+ }; \
+ \
+ template <typename T> \
+ struct match_with< stc::final<T> > \
+ { \
+ typedef T ret; \
+ }; \
+ \
+ template <typename T> \
+ struct match_with \
+ { \
+ typedef T ret; \
+ }; \
+ \
+ } /* end of namespace find_ */ \
+ \
+ \
+ /** Find a virtual type. */ \
+ template <typename source, typename target> \
+ struct find_vtype \
+ { \
+ typedef typename find_rec<source, target>::ret res; \
+ /* Result. */ \
+ typedef typename find_::match_with<res>::ret ret; \
+ }; \
+ \
+ \
+ /** Find a virtual type, and ensure it is found. */ \
+ template <typename from, typename target> \
+ struct vtype \
+ { \
+ typedef typename find_vtype<from, target>::ret res; \
+ struct check_ : mlc::assert_< mlc::is_found_<res> > \
+ { \
+ typedef res ret; \
+ }; \
+ typedef typename check_::ret ret; \
+ }; \
+ \
+} /* end of SCOOPED_NAMESPACE */ \
+ \
+struct e_n_d___w_i_t_h___s_e_m_i_c_o_l_o_n;
+
+
+/*------------------.
+| Shortcuts macro. |
+`------------------*/
// FIXME: Document all these macros.
@@ -782,4 +707,4 @@
>::ret
-#endif // ! STC_SCOOP2_HH
+#endif // ! STC_SCOOP_ALT_HH
Index: stc/Makefile.am
--- stc/Makefile.am (revision 725)
+++ stc/Makefile.am (working copy)
@@ -7,11 +7,11 @@
exact.hh \
find_exact.hh \
scoop.hh \
+ scoop-alt.hh \
valist_aggregator.hh \
\
internal/extract_vtype_from_list.hh \
- \
- scoop2.hh
+ internal/match-with.hh
# Old code.
EXTRA_DIST = was.scoop.hh
Index: stc/internal/match-with.hh
--- stc/internal/match-with.hh (revision 0)
+++ stc/internal/match-with.hh (revision 0)
@@ -0,0 +1,128 @@
+// Copyright (C) 2005, 2006, 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.
+
+
+/* \file stc/match-with.hh
+ \brief Internal helpers for stc/scoop-alt.hh.
+
+ This file contains helpers that mimic a ``match-with'' (pattern
+ matching) construct from many functional languages. */
+
+
+#ifndef STC_INTERNAL_MATCH_WITH_HH
+# define STC_INTERNAL_MATCH_WITH_HH
+
+/*-----------------.
+| merge2 helpers. |
+`-----------------*/
+
+/* Shortcuts macros. */
+#define stc_internal_match_pair_0p_with(Local, Super, Res) \
+ template <> \
+ struct match_with< Local, Super > \
+ { \
+ typedef Res ret; \
+ }
+
+#define stc_internal_match_pair_1p_with(T1, Local, Super, Res) \
+ template < typename T1 > \
+ struct match_with< Local, Super > \
+ { \
+ typedef Res ret; \
+ }
+
+#define stc_internal_match_pair_2p_with(T1, T2, Local, Super, Res) \
+ template < typename T1, typename T2 > \
+ struct match_with< Local, Super > \
+ { \
+ typedef Res ret; \
+ }
+
+/* Erroneous cases. */
+#define stc_internal_match_pair_1p_with_error(T1, Local, Super, Msg) \
+ template < typename T1 > \
+ struct match_with< Local, Super > : \
+ mlc::abort_< T1, Msg > \
+ { \
+ }
+
+#define stc_internal_match_pair_2p_with_error(T1, T2, Local, Super, Msg) \
+ template < typename T1, typename T2 > \
+ struct match_with< Local, Super > : \
+ mlc::abort_< T2, Msg > \
+ { \
+ }
+
+/*-----------------.
+| merge3 helpers. |
+`-----------------*/
+
+/* Shortcuts macros. */
+#define stc_internal_match_triple_0p_with(Local, Super, Deleg, Res) \
+ template <> \
+ struct match_with< Local, Super, Deleg > \
+ { \
+ typedef Res ret; \
+ }
+
+#define stc_internal_match_triple_1p_with(T1, Local, Super, Deleg, Res) \
+ template < typename T1 > \
+ struct match_with< Local, Super, Deleg > \
+ { \
+ typedef Res ret; \
+ }
+
+#define stc_internal_match_triple_2p_with(T1, T2, Local, Super, Deleg, Res) \
+ template < typename T1, typename T2 > \
+ struct match_with< Local, Super, Deleg > \
+ { \
+ typedef Res ret; \
+ }
+
+#define stc_internal_match_triple_3p_with(T1, T2, T3, Local, Super, Deleg, Res) \
+ template < typename T1, typename T2, typename T3 > \
+ struct match_with< Local, Super, Deleg > \
+ { \
+ typedef Res ret; \
+ }
+
+/* Erroneous cases. */
+#define stc_internal_match_triple_2p_with_error(T1, T2, Local, Super, Deleg, Msg) \
+ template < typename T1, typename T2 > \
+ struct match_with< Local, Super, Deleg > : \
+ mlc::abort_< T2, Msg > \
+ { \
+ }
+
+#define stc_internal_match_triple_3p_with_error(T1, T2, T3, Local, Super, Deleg, Msg) \
+ template < typename T1, typename T2, typename T3 > \
+ struct match_with< Local, Super, Deleg > : \
+ mlc::abort_< T3, Msg > \
+ { \
+ }
+
+#endif // ! STC_INTERNAL_MATCH_WITH_HH
1
0
On 2007-01-30, Roland Levillain <roland(a)lrde.epita.fr> wrote:
> Thomas Moulard <thomas.moulard(a)lrde.epita.fr> writes:
>
>> URL: https://svn.lrde.epita.fr/svn/oln/trunk/static
>>
>> ChangeLog:
>> 2007-01-11 Thomas Moulard <thomas.moulard(a)lrde.epita.fr>
>>
>> Fix some tests.
>> * tests/vtypes-and-exact.cc: Fix macro.
>> * tests/vtypes.cc: Fix macro.
>>
>> vtypes-and-exact.cc | 2 +-
>> vtypes.cc | 2 +-
>> 2 files changed, 2 insertions(+), 2 deletions(-)
>>
>>
>> Property changes on: .
>> ___________________________________________________________________
>> Name: mailto
>> + olena-patches(a)lrde.epita.fr
>
> I suppose `mailto' is a Subversion property used by svn-wrapper to
> store the address of a mailing-list. In that case, I suggest using a
> prefix, to avoid name clashes, as Subversion does for its own
> properties (e.g. svn:externals). What about `svn-wrapper:mailto' or
> even `svn-wrap:mailto'?
>
>
or even svnw:mailto ?
I don't know, properties are so rarely used that I thought that a pain
`mailto' would be easier to use. Have you ever set a property whose
name didn't start with `svn:'?
--
SIGOURE Benoit aka Tsuna (SUSv3 compliant)
_____ "On a long enough timeline, the survival rate
/EPITA\ Promo 2008.CSI/ACU/YAKA for everyone drops to zero" -- Jack.
2
1
2007-01-30 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add mini-std.
* samples/mini-std: New.
* samples/mini-oln/design.hh: New.
Index: samples/mini-oln/design.hh
===================================================================
--- samples/mini-oln/design.hh (revision 0)
+++ samples/mini-oln/design.hh (revision 0)
@@ -0,0 +1,461 @@
+
+// Point
+
+Point : class =
+{
+}
+
+point2d : class < Point =
+{
+ row : int;
+ col : int;
+}
+
+point3d : class < Point =
+{
+ row : int;
+ col : int;
+ sli : int;
+}
+
+
+// Iterator
+
+Iterator : class =
+{
+ point_t : typedef < Point;
+
+ start : () -> void;
+ next : () -> void;
+ is_valid : const () -> bool;
+
+ auto : -> point_t;
+}
+
+
+
+// Image
+
+Image : class =
+{
+ {
+ point_t < Point;
+ iter_t < Iterator;
+ value_t;
+ }
+ : typedef;
+
+ "()" : const (p : point_t const&) -> value_t;
+ has : const (p : point_t const&) -> bool;
+}
+
+
+// Image = Image_2D | Image_3D
+
+Image_2D : class < Image =
+{
+ "()" : const (row : int, col : int) -> value_t;
+ nrows : const () -> int;
+ ncols : const () -> int;
+}
+
+Image_3D : class < Image =
+{
+ "()" : const (row : int, col : int, sli : int) -> value_t;
+ nrows : const () -> int;
+ ncols : const () -> int;
+ nslis : const () -> int;
+}
+
+
+// Image = Image_with_Nbh | not
+
+Image_with_Nbh : class < Image
+{
+ {
+ niter_t < Iterator;
+ nbh_t < Neighborhood;
+ }
+ : typedef;
+ nbh : const () -> nbh_t;
+}
+
+
+
+// plugs !
+
+image_dim_plug : [I : type] -> type = {
+ switch (I.point_t) {
+ case point2d: return Image_2D;
+ case point3d: return Image_3D;
+ }
+}
+
+image_nbh_plug : [I : type] -> type = {
+ if (I.nbh_t)
+ return Image_with_Nbh;
+ else
+ return Image;
+}
+
+
+
+// image_entry
+
+image_base : class < image_dim_plug[@],
+ image_nbh_plug[@] =
+{
+ {
+ point_t;
+ iter_t;
+ value_t;
+ }
+ : typedef;
+
+ "()" : const (p : point_t const&) -> value_t;
+ has : const (p : point_t const&) -> bool;
+}
+
+
+
+// iterator2d
+
+iterator2d : class < Iterator =
+{
+ point_t : typedef := point2d;
+
+ make : (ima : Image_2D) = {
+ nrows := ima.nrows;
+ ncols := ima.ncols;
+ }
+
+ start : () -> void = {
+ p.row := 0;
+ p.col := 0;
+ }
+
+ next : () -> void = {
+ p.col := p.col + 1;
+ if (p.col = ncols) {
+ p.col := 0;
+ p.row := p.row + 1;
+ }
+ }
+
+ is_valid : const () -> bool = {
+ return p.row < p.nrows;
+ }
+
+ auto : -> point_t =
+ {
+ return p;
+ }
+
+ protected {
+ nrows : int;
+ ncols : int;
+ p : point_t;
+ }
+}
+
+
+
+// image2d[T]
+
+image2d : [T : class] -> class < image_base =
+{
+ {
+ point_t := point2d;
+ iter_t := iterator2d;
+ value_t := T;
+ }
+ : typedef;
+
+ make : (nrows : int, ncols : int) =
+ {
+ data.make(nrows * ncols);
+ }
+
+ "()" : const (p : point_t const&) -> value_t =
+ {
+ precondition { has(p) = true }
+ return data.element(p.row * ncols + p.col);
+ }
+
+ "()" : const (row : int, col : int) -> value_t =
+ {
+ p : point2d;
+ p.make(row, col);
+ return @[p];
+ }
+
+ has : const (p : point_t const&) -> bool =
+ {
+ precondition { data != 0 }
+ return p.row >= 0 and p.row < nrows and p.col >= 0 and p.col < ncols;
+ }
+
+ data : vector[T];
+ nrows : int;
+ ncols : int;
+}
+
+
+
+// image_morpher
+
+image_morpher : class < image_base =
+{
+ delegatee_t : typedef;
+}
+
+
+
+// fun
+
+fun_ : [I : class < Image, F : type] where (F.arg_t = I.value_t) -> class =
+{
+ {
+ delegatee_t := I;
+ value_t := F.res_t;
+ }
+ : typedef;
+
+ ima : I;
+ f : F;
+
+ "()" : const (p : point_t const&) -> value_t =
+ {
+ precondition { has(p) = true }
+ return f(ima(p));
+ }
+}
+
+fun1 : class =
+{
+ {
+ arg_t;
+ res_t;
+ }
+ : typedef;
+
+ "()" : (ima : I < Image) -> fun_[I,@] =
+ {
+ fun_[I,@] tmp; // '@' is exact type
+ tmp.make(ima, @); // here '@' is *this
+ return tmp;
+ }
+}
+
+pow : class < fun1 =
+{
+ n : unsigned;
+
+ {
+ arg_t := double;
+ res_t := double;
+ }
+ : typedef;
+
+ "()" : (x : double) -> double =
+ {
+ return std::pow(x, n);
+ }
+}
+
+
+// stack
+
+vec : [n : unsigned, T : type] -> class =
+{
+ data : T[n];
+
+ "[]" : (i : unsigned) -> T =
+ {
+ precondition { i < n }
+ return data[i];
+ }
+}
+
+stack_ : [n : unsigned, I : class < Image] -> class =
+{
+ {
+ delegatee_t := I;
+ value_t := vec[n, I.value_t];
+ }
+ : typedef;
+
+ ima : vec[n,I];
+
+ "()" : const (p : point_t const&) -> value_t =
+ {
+ precondition { has(p) = true }
+ value_t tmp;
+ for (unsigned i := 0; i < n; ++i)
+ tmp[i] := ima[i](p);
+ return tmp;
+ }
+}
+
+stack : [I : class < Image] (ima_0 : I const&, ima_1 : I const&) -> stack_[2,I] =
+{
+ stack_[2,I] tmp;
+ tmp.ima[0] := ima_0;
+ tmp.ima[1] := ima_1;
+ return tmp;
+}
+
+
+
+// "image + neighborhood"
+
+plus : [I : class < Image, N : type] where N < Neighborhood
+-> class < image_morpher =
+{
+ {
+ delegatee_t := I;
+ }
+ : typedef;
+
+ ima : I;
+ nbh : N;
+}
+
+
+// operator plus
+
+"+" : [I : class < Image, N : class < Neighborhood] (ima : I, nbh : N) -> plus[I, N] =
+{
+ plus[I, N] tmp;
+ return tmp.make(ima, nbh);
+}
+
+
+
+
+// ----------------------------------------------------------------------
+
+
+
+
+// "image + neighborhood"
+
+plus : [I : class < Image, N : type] where N < Neighborhood
+-> class < image_morpher =
+{
+ {
+ delegatee_t := I;
+ }
+ : typedef;
+
+ ima : I;
+ nbh : N;
+}
+
+
+// operator plus
+
+"+" : [I : class < Image,
+ T : type] (lhs : I, rhs : T) -> plus[I, T] =
+{
+ plus[I, T] ima;
+ return ima.make(lhs, rhs);
+}
+
+
+
+
+// unsub
+
+unsubset : (ima : Image_with_Subset) = { FIXME }
+
+
+
+// predicate
+
+predicate : [I : class < Image] -> type = {
+ return (I.point_t const &) -> I.value_t;
+}
+
+
+
+// sub[I,P]
+
+sub : [I, P] where I < Iterator and P = predicate[I]
+-> class < Iterator =
+{
+ point_t : typedef := I.point_t;
+
+ iter : I;
+ pred : P;
+ p : point_t const&;
+
+ make : (ima : Image) {
+ iter.make(unsubset(ima));
+ pred := ima.pred();
+ p := iter.p;
+ }
+
+ invariant {
+ iter.is_valid() => pred(p);
+ }
+
+ start : () -> void = {
+ iter.start();
+ while (iter.is_valid() and not pred(p))
+ iter.next();
+ }
+
+ next : () -> void = {
+ iter.next();
+ while (iter.is_valid() and not pred(p))
+ iter.next();
+ }
+
+ is_valid : const () -> bool = {
+ return iter.is_valid();
+ }
+
+ auto : -> point_t =
+ {
+ return p;
+ }
+}
+
+
+
+// 'pipe' is "image | predicate -> sub-image"
+
+pipe : [I : class < Image, P : type] where P = predicate[I]
+-> class < image_morpher =
+{
+ {
+ delegatee_t := I;
+ iter_t : sub[I.iter_t, P];
+ }
+ : typedef;
+
+ pred : P;
+
+ unsubset : () -> I =
+ {
+ return ref_ima;
+ }
+
+ has : const (p : point_t const&) -> bool =
+ {
+ return ref_ima.has(p) and pred(p);
+ }
+
+}
+
+
+
+// operator pipe
+
+"|" : [I : class < Image,
+ T : type] (lhs : I, rhs : T) -> pipe[I, T] =
+{
+ pipe[I, T] ima;
+ return ima.make(lhs, rhs);
+}
Index: samples/mini-std/cpp/impl.hh
===================================================================
--- samples/mini-std/cpp/impl.hh (revision 0)
+++ samples/mini-std/cpp/impl.hh (revision 0)
@@ -0,0 +1,199 @@
+#ifndef MINI_STD_IMPL_HH
+# define MINI_STD_IMPL_HH
+
+# include "concepts.hh"
+
+
+namespace abc
+{
+
+
+ // container SWITCH-CASE
+
+ namespace internal
+ {
+
+ // front insertion
+ template <typename b, typename E> struct front_insertion_sequence;
+ template <typename E> struct front_insertion_sequence <mlc::true_, E> : virtual Front_Insertion_Sequence<E> {};
+ template <typename E> struct front_insertion_sequence <mlc::false_, E> : virtual Sequence<E> {};
+
+ // back insertion
+ template <typename b, typename E> struct back_insertion_sequence;
+ template <typename E> struct back_insertion_sequence <mlc::true_, E> : virtual Back_Insertion_Sequence<E> {};
+ template <typename E> struct back_insertion_sequence <mlc::false_, E> : virtual Sequence<E> {};
+
+ // random access
+ template <typename b, typename E> struct random_access_container;
+ template <typename E> struct random_access_container <mlc::true_, E> : virtual Random_Access_Container<E> {};
+ template <typename E> struct random_access_container <mlc::false_, E> : virtual Container<E> {};
+
+ template <typename E>
+ struct container_switch
+ : front_insertion_sequence< abc_vtype(E, has_front_insertion), E >,
+ back_insertion_sequence < abc_vtype(E, has_back_insertion), E >,
+ random_access_container < abc_vtype(E, has_random_access), E >
+ {
+ protected:
+ container_switch() {}
+ };
+
+
+ } // end of abc::internal
+
+
+
+
+// container_base
+// |
+// +-- morpher_container
+// |
+// +-- primary_container
+// |
+// +-- primary_std_container
+
+
+
+
+ // Class container_base<E>.
+
+ template <typename E> class container_base;
+
+ template <typename E>
+ struct vtypes< container_base<E> >
+ {
+ typedef mlc::none super_type;
+
+ typedef stc::abstract value_type;
+ typedef stc::abstract iterator;
+ typedef stc::abstract const_iterator;
+ typedef stc::abstract reference; // FIXME: or stc::final<value_type&>?
+ typedef stc::abstract const_reference; // FIXME: or stc::final<const value_type&>?
+ typedef stc::abstract size_type;
+
+ typedef stc::abstract has_random_access;
+ typedef stc::abstract has_front_insertion;
+ typedef stc::abstract has_back_insertion;
+
+ typedef stc::abstract tag;
+ };
+
+ template <typename E>
+ class container_base : public internal::container_switch<E>
+ {
+ public:
+ // FIXME: remove below.
+ typedef typename Back_Insertion_Sequence<E>::reference reference;
+ typedef typename Back_Insertion_Sequence<E>::const_reference const_reference;
+ protected:
+ container_base() {}
+ };
+
+
+
+ // Class morpher_container<E>.
+
+ template <typename E> class morpher_container;
+
+ template <typename E>
+ struct vtypes< morpher_container<E> >
+ {
+ typedef container_base<E> super_type;
+ typedef stc::abstract delegatee_type;
+ };
+
+ template <typename E>
+ class morpher_container : public container_base<E>
+ {
+ public:
+ stc_using_from(Container<E>, value_type);
+ abc_typename(delegatee_type);
+
+ const delegatee_type& delegatee() const { return this->exact().impl_delegatee(); }
+ delegatee_type& delegatee() { return this->exact().impl_delegatee(); }
+
+ protected:
+ morpher_container() {}
+ };
+
+
+
+ // Class primary_container<E>.
+
+ template <typename E> class primary_container;
+
+ template <typename E>
+ struct vtypes< primary_container<E> >
+ {
+ typedef container_base<E> super_type;
+ typedef mlc::none tag;
+ };
+
+ template <typename E>
+ class primary_container : public container_base<E>
+ {
+ public:
+ stc_using_from(Container<E>, value_type);
+ protected:
+ primary_container() {}
+ };
+
+
+
+ // Class primary_std_container<E>.
+
+ template <typename E> class primary_std_container;
+
+ template <typename E>
+ struct vtypes< primary_std_container<E> >
+ {
+ typedef primary_container<E> super_type;
+ typedef stc::abstract std_type;
+
+ typedef stc_defer(std_type) container_t;
+ typedef stc::final<typename container_t::value_type> value_type;
+ typedef stc::final<typename container_t::iterator> iterator;
+ typedef stc::final<typename container_t::const_iterator> const_iterator;
+ typedef stc::final<typename container_t::reference> reference;
+ typedef stc::final<typename container_t::const_reference> const_reference;
+ typedef stc::final<typename container_t::size_type> size_type;
+ };
+
+ template <typename E>
+ class primary_std_container : public primary_container<E>
+ {
+ public:
+ typedef primary_container<E> super;
+
+ stc_using(iterator);
+ stc_using(const_iterator);
+ stc_using(size_type);
+ stc_using(value_type);
+
+ // Container.
+ iterator impl_begin() { return data_.begin(); }
+ const_iterator impl_begin() const { return data_.begin(); }
+ iterator impl_end() { return data_.end(); }
+ const_iterator impl_end() const { return data_.end(); }
+ size_type impl_size() const { return data_.size(); }
+ bool impl_empty() const { return data_.empty(); }
+
+ // Forward_Container.
+ bool impl_equal(const E& rhs) const { return data_ == rhs.data_; }
+ bool impl_less (const E& rhs) const { return data_ < rhs.data_; }
+
+ protected:
+
+ primary_std_container() {}
+ primary_std_container(size_type n) : data_(n) {}
+ primary_std_container(size_type n, const value_type& t) : data_(n, t) {}
+ primary_std_container(const primary_std_container& rhs) : data_(rhs.data_) {}
+
+ abc_vtype(E, std_type) data_;
+ };
+
+
+} // end of namespace abc
+
+
+#endif // ! MINI_STD_IMPL_HH
Index: samples/mini-std/cpp/vector.hh
===================================================================
--- samples/mini-std/cpp/vector.hh (revision 0)
+++ samples/mini-std/cpp/vector.hh (revision 0)
@@ -0,0 +1,85 @@
+#ifndef MINI_STD_VECTOR_HH
+# define MINI_STD_VECTOR_HH
+
+# include <vector>
+# include "impl.hh"
+
+
+namespace abc
+{
+
+
+ template <typename T> class vector;
+
+
+ template <typename T>
+ struct vtypes< vector<T> >
+ {
+ typedef vector<T> E;
+ typedef primary_std_container<E> super_type;
+
+ typedef std::vector<T> std_type;
+
+ // As Reversible_Container:
+ typedef typename std::vector<T>::reverse_iterator reverse_iterator;
+ typedef typename std::vector<T>::const_reverse_iterator const_reverse_iterator;
+
+ // Properties.
+ typedef mlc::true_ has_random_access;
+ typedef mlc::false_ has_front_insertion;
+ typedef mlc::true_ has_back_insertion;
+ };
+
+
+
+ template <typename T>
+ class vector : public primary_std_container< vector<T> >
+ {
+ public:
+
+ typedef vector<T> self_type;
+ typedef primary_std_container<self_type> super;
+
+ stc_using(iterator);
+ stc_using(const_iterator);
+ stc_using(reverse_iterator);
+ stc_using(const_reverse_iterator);
+ stc_using(size_type);
+ stc_using(reference);
+ stc_using(const_reference);
+ stc_using(value_type);
+
+ using super::data_;
+
+ // Constructors:
+ vector() {}
+ vector(size_type n) : super(n) {}
+ vector(size_type n, const T& t) : super(n, t) {}
+ vector(const vector& rhs) : super(rhs) {}
+
+ vector& operator=(const vector& rhs) { data_ = rhs.data_; return *this; }
+ void reserve(size_t n) { data_.reserve(n); }
+
+ // FIXME: swap, resize
+
+ // As Reversible_Container:
+ reverse_iterator impl_rbegin() { return data_.rbegin(); }
+ const_reverse_iterator impl_rbegin() const { return data_.rbegin(); }
+ reverse_iterator impl_rend() { return data_.rend(); }
+ const_reverse_iterator impl_rend() const { return data_.rend(); }
+
+ // As Random_Access_Container:
+ reference impl_brackets(size_type n) { return data_[n]; }
+ const_reference impl_brackets(size_type n) const { return data_[n]; }
+
+ // As Sequence:
+ iterator impl_insert(iterator p, value_type t) { return data_.insert(p, t); }
+ iterator impl_erase(iterator p) { return data_.erase(p); }
+ iterator impl_erase(iterator p, iterator q) { return data_.erase(p, q); }
+ };
+
+
+} // end of namespace abc
+
+
+#endif // ! MINI_STD_VECTOR_HH
Index: samples/mini-std/cpp/deque.hh
===================================================================
--- samples/mini-std/cpp/deque.hh (revision 0)
+++ samples/mini-std/cpp/deque.hh (revision 0)
@@ -0,0 +1,81 @@
+#ifndef MINI_STD_DEQUE_HH
+# define MINI_STD_DEQUE_HH
+
+# include <deque>
+# include "impl.hh"
+
+
+namespace abc
+{
+
+
+ template <typename T> class deque;
+
+
+
+ template <typename T>
+ struct vtypes< deque<T> >
+ {
+ typedef deque<T> E;
+ typedef primary_std_container<E> super_type;
+
+ typedef std::deque<T> std_type;
+
+ // As Reversible_Container:
+ typedef typename std::deque<T>::reverse_iterator reverse_iterator;
+ typedef typename std::deque<T>::const_reverse_iterator const_reverse_iterator;
+
+ // Properties.
+ typedef mlc::true_ has_random_access;
+ typedef mlc::true_ has_front_insertion;
+ typedef mlc::true_ has_back_insertion;
+ };
+
+
+
+ template <typename T>
+ class deque : public primary_std_container< deque<T> >
+ {
+ public:
+
+ typedef deque<T> self_type;
+ typedef primary_std_container<self_type> super;
+
+ stc_using(iterator);
+ stc_using(const_iterator);
+ stc_using(reverse_iterator);
+ stc_using(const_reverse_iterator);
+ stc_using(size_type);
+ stc_using(reference);
+ stc_using(const_reference);
+ stc_using(value_type);
+
+ using super::data_;
+
+ // Constructors:
+ deque() {}
+ deque(size_type n) : super(n) {}
+ deque(size_type n, const T& t) : super(n, t) {}
+ deque(const deque& rhs) : super(rhs) {}
+
+ deque& operator=(const deque& rhs) { data_ = rhs.data_; return *this; }
+
+ // FIXME: swap, resize
+
+ // As Reversible_Container:
+ reverse_iterator impl_rbegin() { return data_.rbegin(); }
+ const_reverse_iterator impl_rbegin() const { return data_.rbegin(); }
+ reverse_iterator impl_rend() { return data_.rend(); }
+ const_reverse_iterator impl_rend() const { return data_.rend(); }
+
+ // As Sequence:
+ iterator impl_insert(iterator p, value_type t) { return data_.insert(p, t); }
+ iterator impl_erase(iterator p) { return data_.erase(p); }
+ iterator impl_erase(iterator p, iterator q) { return data_.erase(p, q); }
+ };
+
+
+} // end of namespace abc
+
+
+#endif // ! MINI_STD_DEQUE_HH
Index: samples/mini-std/cpp/stack.hh
===================================================================
--- samples/mini-std/cpp/stack.hh (revision 0)
+++ samples/mini-std/cpp/stack.hh (revision 0)
@@ -0,0 +1,71 @@
+#ifndef MINI_STD_CONTAINERS_HH
+# define MINI_STD_CONTAINERS_HH
+
+# include "impl.hh"
+
+
+namespace abc
+{
+
+
+ template <typename T, typename S> class stack;
+
+
+
+ template <typename T, typename S>
+ struct vtypes< stack<T,S> >
+ {
+ typedef stack<T,S> E;
+ typedef morpher_container<E> super_type;
+
+ typedef S delegatee_type;
+
+ // Properties.
+ typedef mlc::false_ has_front_insertion;
+ typedef mlc::true_ has_back_insertion;
+
+ typedef tag::identity tag;
+ };
+
+
+
+ template <typename T, typename S>
+ class stack : public morpher_container< stack<T,S> >
+ {
+ public:
+
+ typedef stack<T,S> self_type;
+ typedef morpher_container<self_type> super;
+
+ stc_using(reference);
+ stc_using(value_type);
+ stc_using(delegatee_type);
+
+ // Renaming.
+ reference top()
+ {
+ assert(not this->empty());
+ return this->back();
+ }
+ void push(value_type t)
+ {
+ this->push_back(t);
+ }
+ void pop()
+ {
+ assert(not this->empty());
+ this->pop_back();
+ }
+
+ const delegatee_type& impl_delegatee() const { return this->seq_; }
+ delegatee_type& impl_delegatee() { return this->seq_; }
+
+ protected:
+ S seq_;
+ };
+
+
+} // end of namespace abc
+
+
+#endif // ! MINI_STD_CONTAINERS_HH
Index: samples/mini-std/cpp/algorithm.hh
===================================================================
--- samples/mini-std/cpp/algorithm.hh (revision 0)
+++ samples/mini-std/cpp/algorithm.hh (revision 0)
@@ -0,0 +1,64 @@
+#ifndef MINI_STD_ALGORITHM_HH
+# define MINI_STD_ALGORITHM_HH
+
+# include <algorithm>
+# include "concepts.hh"
+
+
+namespace abc
+{
+
+ /// \{
+ /// Facades.
+
+ template <typename C>
+ void sort(Container<C>& c);
+
+ template <typename C, typename I>
+ void copy(const Container<C>& c, I iter);
+
+ /// \}
+
+
+
+ /// \{
+ /// sort
+
+ namespace impl
+ {
+
+ template <typename C>
+ void sort(Random_Access_Container<C>& c)
+ {
+ std::sort(c.begin(), c.end());
+ }
+
+ } // impl
+
+ template <typename C>
+ void sort(Container<C>& c)
+ {
+ impl::sort(c.exact());
+ }
+
+ /// \}
+
+
+
+ /// \{
+ /// copy
+
+ template <typename C, typename I>
+ void copy(const Container<C>& c, I iter)
+ {
+ std::copy(c.begin(), c.end(), iter);
+ }
+
+ /// \}
+
+
+
+} // end of namespace abc
+
+
+#endif // ! MINI_STD_ALGORITHM_HH
Index: samples/mini-std/cpp/value_cast.hh
===================================================================
--- samples/mini-std/cpp/value_cast.hh (revision 0)
+++ samples/mini-std/cpp/value_cast.hh (revision 0)
@@ -0,0 +1,65 @@
+#ifndef MINI_STD_VALUE_CAST_HH
+# define MINI_STD_VALUE_CAST_HH
+
+# include "impl.hh"
+# include "identity.hh"
+
+
+namespace abc
+{
+
+
+ template <typename T, typename C> class value_cast_;
+
+
+ template <typename T, typename C>
+ struct vtypes< value_cast_<T,C> >
+ {
+ typedef value_cast_<T,C> E;
+ typedef morpher_container<E> super_type;
+
+ typedef C delegatee_type;
+
+ typedef T value_type;
+ typedef T& reference;
+ typedef const T& const_reference;
+
+ typedef tag::identity tag;
+ };
+
+
+ template <typename T, typename C>
+ class value_cast_ : public morpher_container< value_cast_<T,C> >
+ {
+ public:
+
+ typedef value_cast_<T,C> self_type;
+ typedef morpher_container<self_type> super;
+
+ stc_using(delegatee_type);
+
+ value_cast_(Container<C>& con)
+ : con_(con.exact())
+ {
+ }
+
+ const delegatee_type& impl_delegatee() const { return this->con_; }
+ delegatee_type& impl_delegatee() { return this->con_; }
+
+ protected:
+ C& con_;
+ };
+
+
+ template <typename T, typename C>
+ value_cast_<T, C> value_cast(Container<C>& c)
+ {
+ value_cast_<T, C> tmp(c);
+ return tmp;
+ }
+
+
+} // end of namespace abc
+
+
+#endif // ! MINI_STD_VALUE_CAST_HH
Index: samples/mini-std/cpp/equipment.hh
===================================================================
--- samples/mini-std/cpp/equipment.hh (revision 0)
+++ samples/mini-std/cpp/equipment.hh (revision 0)
@@ -0,0 +1,89 @@
+#ifndef MINI_STD_EQUIPMENT_HH
+# define MINI_STD_EQUIPMENT_HH
+
+# include <cassert>
+# include <stc/any.hh>
+# include <stc/scoop.hh>
+
+
+stc_scoop_equipment_for_namespace(abc);
+
+
+
+// Patch.
+
+# define abc_vtype_(From, Target) abc::vtype<From, abc::typedef_::Target>::ret
+# define abc_vtype(From, Target) typename abc_vtype_(From, Target)
+
+# define abc_typename(Vtype) typedef abc_vtype(E, Vtype) Vtype
+
+# define stc_defer(Target) typename abc::deferred_vtype<E, abc::typedef_::Target>::ret
+
+# define stc_using(Vtype) typedef typename super::Vtype Vtype
+# define stc_using_from(From, Vtype) typedef typename From::Vtype Vtype
+
+# define stc_introducing(Vtype) typedef abc_vtype(self_type, Vtype) Vtype
+
+// stc_deferred_vtype(test, E, dim)
+
+
+
+namespace abc
+{
+
+ /// \{
+ /// Typedef declarations.
+
+ // From std.
+ mlc_decl_typedef(value_type);
+ mlc_decl_typedef(value_compare);
+ mlc_decl_typedef(reference);
+ mlc_decl_typedef(const_reference);
+ mlc_decl_typedef(data_type);
+ mlc_decl_typedef(size_type);
+ mlc_decl_typedef(distance_type);
+ mlc_decl_typedef(iterator);
+ mlc_decl_typedef(const_iterator);
+ mlc_decl_typedef(reverse_iterator);
+ mlc_decl_typedef(const_reverse_iterator);
+ mlc_decl_typedef(key_type);
+ mlc_decl_typedef(key_compare);
+ mlc_decl_typedef(std_type);
+
+ // Properties.
+ mlc_decl_typedef(has_random_access);
+ mlc_decl_typedef(has_front_insertion);
+ mlc_decl_typedef(has_back_insertion);
+
+ mlc_decl_typedef(tag);
+
+ /// \}
+
+
+
+ namespace automatic
+ {
+
+ template < template <class> class abstraction, typename E, typename tag = void >
+ struct impl;
+
+ template < template <class> class abstraction, typename E >
+ struct impl< abstraction, E, mlc::none >
+ {
+ // none means nothing!
+ };
+
+ template < template <class> class abstraction, typename E >
+ struct impl< abstraction, E, void > : impl< abstraction, E, abc_vtype(E, tag) >
+ {
+ // fetch impl w.r.t. tag
+ };
+
+ } // end of namespace abc::automatic
+
+
+
+} // end of namespace abc
+
+
+#endif // ! MINI_STD_EQUIPMENT_HH
Index: samples/mini-std/cpp/identity.hh
===================================================================
--- samples/mini-std/cpp/identity.hh (revision 0)
+++ samples/mini-std/cpp/identity.hh (revision 0)
@@ -0,0 +1,164 @@
+#ifndef MINI_STD_IDENTITY_HH
+# define MINI_STD_IDENTITY_HH
+
+# include "equipment.hh"
+# include "fwddecls.hh"
+
+
+
+namespace abc
+{
+
+ // tag::identity.
+
+ namespace tag { struct identity; }
+
+
+ namespace automatic
+ {
+
+ // FIXME: Hack! (to be removed)
+
+ template < template <class> class abstraction, typename E >
+ struct impl< abstraction, E, tag::identity >
+ {
+ // ...
+ };
+
+
+
+ // Container
+
+ template <typename E>
+ class impl< Container, E, tag::identity >
+ :
+ public virtual stc::any__simple<E>
+ {
+ protected:
+ abc_typename(value_type);
+ abc_typename(iterator);
+ abc_typename(const_iterator);
+ abc_typename(size_type);
+ public:
+ iterator impl_begin() { return this->exact().delegatee().begin(); }
+ const_iterator impl_begin() const { return this->exact().delegatee().begin(); }
+ iterator impl_end() { return this->exact().delegatee().end(); }
+ const_iterator impl_end() const { return this->exact().delegatee().end(); }
+ size_type impl_size() const { return this->exact().delegatee().size(); }
+ bool impl_empty() const { return this->exact().delegatee().empty(); }
+ };
+
+
+
+ // Forward_Container
+
+ template <typename E>
+ class impl< Forward_Container, E, tag::identity >
+ :
+ public virtual stc::any__simple<E>
+ {
+ protected:
+ typedef Forward_Container<E> self_type;
+ public:
+ bool impl_equal(const self_type& rhs) const { return this->exact().delegatee().operator==(rhs); }
+ bool impl_less (const self_type& rhs) const { return this->exact().delegatee().operator< (rhs); }
+ };
+
+
+
+ // Reversible_Container
+
+ template <typename E>
+ class impl< Reversible_Container, E, tag::identity >
+ :
+ public virtual stc::any__simple<E>
+ {
+ protected:
+ abc_typename(reverse_iterator);
+ abc_typename(const_reverse_iterator);
+ public:
+ reverse_iterator impl_rbegin() { return this->exact().delegatee().rbegin(); }
+ const_reverse_iterator impl_rbegin() const { return this->exact().delegatee().rbegin(); }
+ reverse_iterator impl_rend() { return this->exact().delegatee().rend(); }
+ const_reverse_iterator impl_rend() const { return this->exact().delegatee().rend(); }
+ };
+
+
+
+ // Random_Access_Container
+
+ template <typename E>
+ class impl< Random_Access_Container, E, tag::identity >
+ :
+ public virtual stc::any__simple<E>
+ {
+ protected:
+ abc_typename(reference);
+ abc_typename(const_reference);
+ abc_typename(size_type);
+ public:
+ reference impl_brackets(size_type n) { return this->exact().delegatee()[n]; }
+ const_reference impl_brackets(size_type n) const { return this->exact().delegatee()[n]; }
+ };
+
+
+
+ // Sequence
+
+ template <typename E>
+ class impl< Sequence, E, tag::identity >
+ :
+ public virtual stc::any__simple<E>
+ {
+ protected:
+ abc_typename(value_type);
+ abc_typename(iterator);
+ public:
+ iterator impl_insert(iterator p, value_type t) { return this->exact().delegatee().insert(p, t); }
+ iterator impl_erase(iterator p) { return this->exact().delegatee().erase(p); }
+ iterator impl_erase(iterator p, iterator q) { return this->exact().delegatee().erase(p, q); }
+ };
+
+
+
+ // Front_Insertion_Sequence
+
+ template <typename E>
+ class impl< Front_Insertion_Sequence, E, tag::identity >
+ :
+ public virtual stc::any__simple<E>
+ {
+ protected:
+ abc_typename(value_type);
+ public:
+ void impl_push_front(value_type t) { this->exact().delegatee().push_front(t); }
+ void impl_pop_front() { this->exact().delegatee().pop_front(); }
+ };
+
+
+
+ // Back_Insertion_Sequence
+
+ template <typename E>
+ class impl< Back_Insertion_Sequence, E, tag::identity >
+ :
+ public virtual stc::any__simple<E>
+ {
+ protected:
+ abc_typename(value_type);
+ abc_typename(reference);
+ public:
+ reference impl_back() { this->exact().delegatee().back(); }
+ void impl_push_back(value_type t) { this->exact().delegatee().push_back(t); }
+ void impl_pop_back() { this->exact().delegatee().pop_back(); }
+ };
+
+
+
+ } // end of namespace abc::automatic
+
+
+} // end of namespace abc
+
+
+#endif // ! MINI_STD_IDENTITY_HH
Index: samples/mini-std/cpp/main.cc
===================================================================
--- samples/mini-std/cpp/main.cc (revision 0)
+++ samples/mini-std/cpp/main.cc (revision 0)
@@ -0,0 +1,19 @@
+
+#include <iostream>
+#include <iterator>
+
+#include "vector.hh"
+#include "algorithm.hh"
+
+
+
+int main()
+{
+ abc::vector<int> v;
+ v.push_back(3);
+ v.push_back(1);
+ v.push_back(4);
+
+ abc::sort(v);
+ abc::copy(v, std::ostream_iterator<int>(std::cout, "\n"));
+}
Index: samples/mini-std/cpp/fwddecls.hh
===================================================================
--- samples/mini-std/cpp/fwddecls.hh (revision 0)
+++ samples/mini-std/cpp/fwddecls.hh (revision 0)
@@ -0,0 +1,84 @@
+#ifndef MINI_STD_FWDDECLS_HH
+# define MINI_STD_FWDDECLS_HH
+
+
+namespace abc
+{
+
+
+ // Container
+ // |
+ // +-- Forward_Container
+ // |
+ // |
+ // +-- Reversible_Container
+ // | |
+ // | +-- Random_Access_Container
+ // |
+
+ template <typename E> class Container;
+ template <typename E> class Forward_Container;
+ template <typename E> class Reversible_Container;
+ template <typename E> class Random_Access_Container;
+
+ // |
+ // +-- Sequence
+ // | |
+ // | +-- Front_Insertion_Sequence
+ // | |
+ // | +-- Back_Insertion_Sequence
+ // |
+
+ template <typename E> class Sequence;
+ template <typename E> class Front_Insertion_Sequence;
+ template <typename E> class Back_Insertion_Sequence;
+
+ // |
+ // +-- Associative_Container
+ // |
+ // +-- Simple_Associative_Container
+ // +-- Pair_Associative_Container
+ // |
+ // +-- Sorted_Associative_Container
+ // +-- Hashed_Associative_Container
+ // |
+ // +-- Unique_Associative_Container
+ // +-- Multiple_Associative_Container
+
+ template <typename E> class Associative_Container;
+ template <typename E> class Simple_Associative_Container;
+ template <typename E> class Pair_Associative_Container;
+ template <typename E> class Sorted_Associative_Container;
+ template <typename E> class Hashed_Associative_Container;
+ template <typename E> class Unique_Associative_Container;
+ template <typename E> class Multiple_Associative_Container;
+
+
+
+ // Iterator
+ // |
+ // +-- Trivial_Iterator
+ // | |
+ // | +-- Input_Iterator
+ // | |
+ // +-- Output_Iterator |
+ // | |
+ // +---------+-- Forward_Iterator
+ // |
+ // +-- Bidirectional_Iterator
+ // |
+ // +-- Random_Access_Iterator
+
+ template <typename E> class Iterator;
+ template <typename E> class Trivial_Iterator;
+ template <typename E> class Input_Iterator;
+ template <typename E> class Output_Iterator;
+ template <typename E> class Forward_Iterator;
+ template <typename E> class Bidirectional_Iterator;
+ template <typename E> class Random_Access_Iterator;
+
+
+} // end of namespace abc
+
+
+#endif // ! MINI_STD_FWDDECLS_HH
Index: samples/mini-std/cpp/list.hh
===================================================================
--- samples/mini-std/cpp/list.hh (revision 0)
+++ samples/mini-std/cpp/list.hh (revision 0)
@@ -0,0 +1,83 @@
+#ifndef MINI_STD_LIST_HH
+# define MINI_STD_LIST_HH
+
+# include <list>
+# include "impl.hh"
+
+
+namespace abc
+{
+
+
+ template <typename T> class list;
+
+
+ template <typename T>
+ struct vtypes< list<T> >
+ {
+ typedef list<T> E;
+ typedef primary_std_container<E> super_type;
+
+ typedef std::list<T> std_type;
+
+ // As Reversible_Container:
+ typedef typename std::list<T>::reverse_iterator reverse_iterator;
+ typedef typename std::list<T>::const_reverse_iterator const_reverse_iterator;
+
+ // Properties.
+ typedef mlc::false_ has_random_access;
+ typedef mlc::true_ has_front_insertion;
+ typedef mlc::true_ has_back_insertion;
+ };
+
+
+
+ template <typename T>
+ class list : public primary_std_container< list<T> >
+ {
+ public:
+
+ typedef list<T> self_type;
+ typedef primary_std_container<self_type> super;
+
+ stc_using(iterator);
+ stc_using(const_iterator);
+ stc_using(size_type);
+ stc_using(reference);
+ stc_using(const_reference);
+ stc_using(value_type);
+
+ stc_introducing(reverse_iterator);
+ stc_introducing(const_reverse_iterator);
+
+ using super::data_;
+
+ // Constructors:
+ list() {}
+ list(size_type n) : super(n) {}
+ list(size_type n, const T& t) : super(n, t) {}
+ list(const list& rhs) : super(rhs) {}
+
+ list& operator=(const list& rhs) { data_ = rhs.data_; return *this; }
+
+ void sort() { data_.sort(); }
+
+ // FIXME: swap, resize
+
+ // As Reversible_Container:
+ reverse_iterator impl_rbegin() { return data_.rbegin(); }
+ const_reverse_iterator impl_rbegin() const { return data_.rbegin(); }
+ reverse_iterator impl_rend() { return data_.rend(); }
+ const_reverse_iterator impl_rend() const { return data_.rend(); }
+
+ // As Sequence:
+ iterator impl_insert(iterator p, value_type t) { return data_.insert(p, t); }
+ iterator impl_erase(iterator p) { return data_.erase(p); }
+ iterator impl_erase(iterator p, iterator q) { return data_.erase(p, q); }
+ };
+
+
+} // end of namespace abc
+
+
+#endif // ! MINI_STD_LIST_HH
Index: samples/mini-std/cpp/concepts.hh
===================================================================
--- samples/mini-std/cpp/concepts.hh (revision 0)
+++ samples/mini-std/cpp/concepts.hh (revision 0)
@@ -0,0 +1,356 @@
+#ifndef MINI_STD_CONCEPTS_HH
+# define MINI_STD_CONCEPTS_HH
+
+# include "equipment.hh"
+
+
+namespace abc
+{
+
+ // Container
+
+ template <typename E>
+ class Container : public virtual stc::any__simple<E>,
+ public automatic::impl<Container, E>
+ {
+ public:
+
+ // Typedefs.
+ abc_typename(value_type);
+ abc_typename(iterator);
+ abc_typename(const_iterator);
+ abc_typename(reference);
+ abc_typename(const_reference);
+ abc_typename(size_type);
+
+ // Methods.
+ iterator begin() { return this->exact().impl_begin(); }
+ const_iterator begin() const { return this->exact().impl_begin(); }
+ iterator end() { return this->exact().impl_end(); }
+ const_iterator end() const { return this->exact().impl_end(); }
+ size_type size() const { return this->exact().impl_size(); }
+ bool empty() const { return this->exact().impl_empty(); }
+
+ protected:
+ Container() {}
+ };
+
+
+
+ // Forward_Container
+
+ template <typename E>
+ class Forward_Container : public virtual Container<E>,
+ public automatic::impl<Forward_Container, E>
+ {
+ public:
+
+ typedef Forward_Container<E> self_type;
+
+ // Methods.
+ bool operator==(const self_type& rhs) const { return this->exact().impl_equal(rhs.exact()); }
+ bool operator< (const self_type& rhs) const { return this->exact().impl_less(rhs.exact()); }
+
+ // Concrete. // FIXME: Use the default impl mechanism so that the user can override.
+ bool operator!=(const self_type& rhs) const { return not (*this == rhs); }
+ bool operator> (const self_type& rhs) const { return rhs < *this; }
+ bool operator<=(const self_type& rhs) const { return not (*this > rhs); }
+ bool operator>=(const self_type& rhs) const { return not (*this < rhs); }
+
+ protected:
+ Forward_Container() {}
+ };
+
+
+
+ // Reversible_Container
+
+ template <typename E>
+ class Reversible_Container : public virtual Forward_Container<E>,
+ public automatic::impl<Reversible_Container, E>
+ {
+ public:
+
+ // Typedefs.
+ abc_typename(reverse_iterator);
+ abc_typename(const_reverse_iterator);
+
+ // Methods.
+ reverse_iterator rbegin() { return this->exact().impl_rbegin(); }
+ const_reverse_iterator rbegin() const { return this->exact().impl_rbegin(); }
+ reverse_iterator rend() { return this->exact().impl_rend(); }
+ const_reverse_iterator rend() const { return this->exact().impl_rend(); }
+
+ protected:
+ Reversible_Container() {}
+ };
+
+
+
+ // Random_Access_Container
+
+ template <typename E>
+ class Random_Access_Container : public virtual Reversible_Container<E>,
+ public automatic::impl<Random_Access_Container, E>
+ {
+ public:
+
+ typedef Reversible_Container<E> super;
+ stc_using(reference);
+ stc_using(const_reference);
+ stc_using(size_type);
+
+ // Methods.
+ reference operator[](size_type n) { assert(0 <= n and n <= this->size());
+ return this->exact().impl_brackets(n); }
+ const_reference operator[](size_type n) const { assert(0 <= n and n <= this->size());
+ return this->exact().impl_brackets(n); }
+ protected:
+ Random_Access_Container() {}
+ };
+
+
+
+ // Sequence
+
+ template <typename E>
+ class Sequence : public virtual Forward_Container<E>,
+ public automatic::impl<Sequence, E>
+ {
+ public:
+
+ typedef Forward_Container<E> super;
+ stc_using(iterator);
+ stc_using(value_type);
+ stc_using(reference);
+ stc_using(const_reference);
+
+ // Methods.
+ iterator insert(iterator p, value_type t) { return this->exact().impl_insert(p, t); }
+ iterator erase(iterator p) { return this->exact().impl_erase(p); }
+ iterator erase(iterator p, iterator q) { return this->exact().impl_erase(p, q); }
+
+ // Concrete.
+ reference front()
+ {
+ assert(not this->empty());
+ return *(this->first());
+ }
+ const_reference front() const
+ {
+ assert(not this->empty());
+ return *(this->first());
+ }
+ void clear()
+ {
+ this->erase(this->begin(), this->end());
+ }
+
+ protected:
+ Sequence() {}
+ };
+
+
+
+
+ // Front_Insertion_Sequence
+
+ template <typename E>
+ class Front_Insertion_Sequence : public virtual Sequence<E>,
+ public automatic::impl<Front_Insertion_Sequence, E>
+ {
+ public:
+
+ typedef Sequence<E> super;
+ stc_using(value_type);
+
+ // Concrete.
+ void push_front(value_type t)
+ {
+ this->insert(this->begin(), t);
+ }
+ void pop_front()
+ {
+ assert(not this->empty());
+ this->erase(this->begin());
+ }
+
+ protected:
+ Front_Insertion_Sequence() {}
+ };
+
+
+
+ // Back_Insertion_Sequence
+
+ template <typename E>
+ class Back_Insertion_Sequence : public virtual Sequence<E>,
+ public automatic::impl<Back_Insertion_Sequence, E>
+ {
+ public:
+
+ typedef Sequence<E> super;
+ stc_using(reference);
+ stc_using(value_type);
+
+ // Concrete.
+ reference back()
+ {
+ assert(not this->empty());
+ return *(--this->end());
+ }
+ void push_back(value_type t)
+ {
+ this->insert(this->end(), t);
+ }
+ void pop_back()
+ {
+ assert(not this->empty());
+ this->erase(--this->end());
+ }
+ protected:
+ Back_Insertion_Sequence() {}
+ };
+
+
+
+ // Iterator
+
+ template <typename E>
+ class Iterator : public virtual stc::any__simple<E>,
+ public automatic::impl<Iterator, E>
+ {
+ public:
+
+ // FIXME
+
+ protected:
+ Iterator() {}
+ };
+
+
+
+ // Trivial_Iterator
+
+ template <typename E>
+ class Trivial_Iterator : public virtual Iterator<E>,
+ public automatic::impl<Trivial_Iterator, E>
+ {
+ public:
+
+ typedef Trivial_Iterator<E> self_type;
+
+ // Typedef.
+ abc_typename(value_type);
+
+ // Methods.
+ value_type operator*() const { return this->exact().impl_star(); }
+ const value_type& operator->() const { return this->exact().impl_arrow(); }
+ bool operator==(const self_type& rhs) const { return this->exact().impl_equal(rhs.exact()); }
+
+ // Concrete.
+ bool operator!=(const self_type& rhs) const
+ {
+ return not (*this == rhs);
+ }
+
+ protected:
+ Trivial_Iterator() {}
+ };
+
+
+
+ // Input_Iterator
+
+ template <typename E>
+ class Input_Iterator : public virtual Trivial_Iterator<E>,
+ public automatic::impl<Input_Iterator, E>
+ {
+ public:
+
+ // Typedef.
+ abc_typename(distance_type);
+
+ // Method.
+ E& operator++() { return this->exact().impl_preinc(); }
+
+ // Concrete.
+ E operator++(int) const
+ {
+ E cpy(*this);
+ ++(*this);
+ return cpy;
+ }
+
+ protected:
+ Input_Iterator() {}
+ };
+
+
+
+ // Output_Iterator
+
+ template <typename E>
+ class Output_Iterator : public virtual Trivial_Iterator<E>,
+ public automatic::impl<Output_Iterator, E>
+ {
+ public:
+
+ typedef Trivial_Iterator<E> super;
+ stc_using(value_type);
+
+ using super::operator*;
+ using super::operator->;
+
+ // Methods.
+ value_type& operator*() { return this->exact().impl_star(); }
+ value_type& operator->() { return this->exact().impl_arrow(); }
+
+ protected:
+ Output_Iterator() {}
+ };
+
+
+
+ // Forward_Iterator
+
+ template <typename E>
+ class Forward_Iterator : public virtual Input_Iterator<E>, public virtual Output_Iterator<E>,
+ public automatic::impl<Forward_Iterator, E>
+ {
+ public:
+ // nothing
+ protected:
+ Forward_Iterator() {}
+ };
+
+
+
+ // Bidirectional_Iterator
+
+ template <typename E>
+ class Bidirectional_Iterator : public virtual Forward_Iterator<E>,
+ public automatic::impl<Bidirectional_Iterator, E>
+ {
+ public:
+
+ // Method.
+ E& operator--() { return this->exact().impl_predec(); }
+
+ // Concrete.
+ E operator--(int) const
+ {
+ E cpy(*this);
+ --(*this);
+ return cpy;
+ }
+
+ protected:
+ Bidirectional_Iterator() {}
+ };
+
+
+} // end of namespace abc
+
+
+#endif // ! MINI_STD_CONCEPTS_HH
Index: samples/mini-std/design.hh
===================================================================
--- samples/mini-std/design.hh (revision 0)
+++ samples/mini-std/design.hh (revision 0)
@@ -0,0 +1,248 @@
+
+// Container
+
+Container : class =
+{
+ value_type : type;
+
+ iterator : type;
+ const_iterator : type;
+
+ reference : type;
+ const_reference : type;
+
+ size_type : type;
+
+ begin : () -> iterator;
+ begin : const () -> const_iterator;
+
+ end : () -> iterator;
+ end : const () -> const_iterator;
+
+ size : const () -> size_type;
+ empty : const () -> bool;
+}
+
+
+// Forward_Container
+
+Forward_Container : class < Container =
+{
+ "=" : const (rhs : @type) -> bool;
+ "!=" : const (rhs : @type) -> bool;
+ "<" : const (rhs : @type) -> bool;
+ ">" : const (rhs : @type) -> bool;
+ "<=" : const (rhs : @type) -> bool;
+ ">=" : const (rhs : @type) -> bool;
+}
+
+
+// Reversible_Container
+
+Reversible_Container : class < Forward_Container =
+{
+ reverse_iterator : type;
+ const_reverse_iterator : type;
+
+ rbegin : () -> reverse_iterator;
+ rbegin : const () -> const_reverse_iterator;
+
+ rend : () -> reverse_iterator;
+ rend : const () -> const_reverse_iterator;
+
+ /* Models: vector, list, deque */
+}
+
+
+// Random_Access_Container
+
+Random_Access_Container : class < Reversible_Container =
+{
+ "[]" : (n : size_type) -> reference {
+ precondition { 0 <= n and n <= @size() }
+ }
+ "[]" : const (n : size_type) -> const_reference {
+ precondition { 0 <= n and n <= @size() }
+ }
+}
+
+
+
+// Sequence
+
+Sequence : class < Forward_Container =
+{
+ make : (n : size_type, t : value_type) {
+ precondition { n >= 0 }
+ postcondition { @size() = n } // FIXME: and...
+ }
+
+ // FIXME: some ctors are missing.
+
+ front : () -> reference =
+ {
+ precondition { not @empty() }
+ return *(@first());
+ }
+ front : const () -> const_reference =
+ {
+ precondition { not @empty() }
+ return *(@first());
+ }
+
+ insert : (p : iterator, t : value_type) -> iterator;
+
+ erase : (p : iterator) -> iterator;
+ erase : (p : iterator, q : iterator) -> iterator;
+
+ clear : () -> void =
+ {
+ @erase(@begin(), @end());
+ }
+
+ /* Models: vector, deque, list */
+}
+
+
+
+// Front_Insertion_Sequence
+
+Front_Insertion_Sequence : class < Sequence =
+{
+ push_front : (t : value_type) -> void =
+ {
+ @insert(@begin(), t);
+ }
+ pop_front : () -> void =
+ {
+ precondition { not @empty() }
+ @erase(@begin());
+ }
+ /* Models: deque, list */
+}
+
+
+// Back_Insertion_Sequence
+
+Back_Insertion_Sequence : class < Sequence =
+{
+ back : () -> reference =
+ {
+ precondition { not @empty() }
+ return *(--@end());
+ }
+ push_back : (t : value_type) -> void =
+ {
+ @insert(@end(), t);
+ }
+ pop_back : () -> void =
+ {
+ precondition { not @empty() }
+ @erase(--@end());
+ }
+ /* Models: vector, deque, list */
+}
+
+
+
+// vector[T]
+
+vector : [T : type] -> class < Back_Insertion_Sequence, Random_Access_Container =
+{
+ // FIXME: impl
+}
+
+
+// Associative_Container
+
+Associative_Container : class < Forward_Container =
+{
+ key_type : type;
+
+ erase : (k : key_type) -> size_type;
+ erase : (p : iterator) -> void;
+ erase : (p : iterator, q : iterator) -> void;
+
+ clear : () -> void =
+ {
+ @erase(@begin(), @end());
+ }
+
+ find : (k : key_type) -> iterator;
+ find : const (k : key_type) -> const_iterator;
+
+ count : (k : key_type) -> size_type;
+
+ // FIXME: equal_range
+
+ /* Models: set, multiset, map, multimap */
+}
+
+
+// Simple_Associative_Container
+
+Simple_Associative_Container : class < Associative_Container =
+{
+ check {
+ key_type = value_type and iterator = const_iterator
+ }
+ /* Models: set, multiset */
+}
+
+
+// Pair_Associative_Container
+
+Pair_Associative_Container : class < Associative_Container =
+{
+ data_type : type;
+ value_type : type = pair[key_type const, data_type];
+ /* Models: map, multimap */
+}
+
+
+
+// Sorted_Associative_Container
+
+Sorted_Associative_Container : class < Associative_Container =
+{
+ key_compare : type < Strict_Weak_Ordering;
+ value_compare : type < Strict_Weak_Ordering;
+
+ // FIXME: ctors, key_comp, value_compare, lower_bound, upper_bound, equal_range
+}
+
+
+
+// FIXME: Hashed_Associative_Container
+// FIXME: Unique_Associative_Container
+// FIXME: Multiple_Associative_Container
+
+
+
+// Trivial_Iterator
+
+Trivial_Iterator : class =
+{
+ value_type : type;
+ "*" : const () : value_type const&;
+ "->" : const () : value_type const&;
+ "=" : const (rhs : @type const&) : bool;
+}
+
+// Input_Iterator
+
+Input_Iterator : class < Trivial_Iterator =
+{
+ "++@" : () -> @type &; // pre
+ "@++" : () -> @type &; // post
+}
+
+
+
+// Output_Iterator
+
+Output_Iterator : class < Trivial_Iterator =
+{
+ "*" : () : value_type &;
+ "->" : () : value_type &;
+}
Index: samples/mini-std/README
===================================================================
--- samples/mini-std/README (revision 0)
+++ samples/mini-std/README (revision 0)
@@ -0,0 +1,29 @@
+ -*- outline -*-
+
+* compilation
+
+cd cpp
+g++ -I../../.. -I../../../../metalic -Wall -ansi -pedantic main.cc
+
+* contents
+
+** utility files
+
+concepts.hh
+equipment.hh
+fwddecls.hh
+identity.hh
+impl.hh
+
+** based on existing std tools
+
+deque.hh
+list.hh
+stack.hh
+vector.hh
+
+algorithm.hh
+
+** morphers
+
+value_cast.hh
1
0
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
URL: https://svn.lrde.epita.fr/svn/oln/trunk/static
ChangeLog:
2007-01-11 Thomas Moulard <thomas.moulard(a)lrde.epita.fr>
Fix some tests.
* tests/vtypes-and-exact.cc: Fix macro.
* tests/vtypes.cc: Fix macro.
vtypes-and-exact.cc | 2 +-
vtypes.cc | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
Property changes on: .
___________________________________________________________________
Name: mailto
+ olena-patches(a)lrde.epita.fr
Index: tests/vtypes-and-exact.cc
===================================================================
- --- tests/vtypes-and-exact.cc (revision 718)
+++ tests/vtypes-and-exact.cc (working copy)
@@ -40,7 +40,7 @@
// Helper macros.
#define my_type_of_(FromType, Alias) \
- - my::direct_type_of_<FromType, my::typedef_:: Alias##_type>::ret
+ my::find_vtype<FromType, my::typedef_:: Alias##_type>::ret
#define my_type_of(FromType, Alias) \
typename my_type_of_(FromType, Alias)
Index: tests/vtypes.cc
===================================================================
- --- tests/vtypes.cc (revision 718)
+++ tests/vtypes.cc (working copy)
@@ -37,7 +37,7 @@
// Helper macros.
#define my_type_of_(FromType, Alias) \
- - my::direct_type_of_<FromType, my::typedef_:: Alias##_type>::ret
+ my::find_vtype<FromType, my::typedef_:: Alias##_type>::ret
#define my_type_of(FromType, Alias) \
typename my_type_of_(FromType, Alias)
- --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
iD8DBQFFpmPq8QvmnUS5oeMRAr2HAKCXyklCwcRaUHXhG7jkLogf8248yQCfQiyv
XHz2zTG6ywb7d0CNQa13pNc=
=ev6W
-----END PGP SIGNATURE-----
2
2