-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
URL:
https://svn.lrde.epita.fr/svn/oln/trunk/static
ChangeLog:
2007-02-06 Thomas Moulard <thomas.moulard(a)lrde.epita.fr>
Fix misc mistakes.
* samples/mini-oln/README: Add newline.
* samples/mini-oln/mini-oln.cc: Fix misc mistakes
(name resolution, SCOOP paradigm, typo).
mini-oln.cc | 317 ++++++++++++++++++++++++++++++------------------------------
1 file changed, 159 insertions(+), 158 deletions(-)
Index: samples/mini-oln/mini-oln.cc
===================================================================
- --- samples/mini-oln/mini-oln.cc (revision 737)
+++ samples/mini-oln/mini-oln.cc (working copy)
@@ -37,7 +37,7 @@
// Helper macros.
#define oln_type_of_(FromType, Alias) \
- - oln::find_vtype<FromType, oln::typedef_:: Alias##_type>::ret
+ find_vtype<FromType, oln::typedef_:: Alias##_type>::ret
#define oln_type_of(FromType, Alias) \
typename oln_type_of_(FromType, Alias)
@@ -67,6 +67,16 @@
mlc_decl_typedef(nbh_type);
}
+// --------------------- //
+// Forward declarations. //
+// --------------------- //
+
+namespace oln
+{
+ struct point2d;
+ struct point3d;
+}
+
// ------- //
// Point. //
// ------- //
@@ -77,19 +87,6 @@
struct Point : public stc::any<E>
{
};
- -
- - struct point2d : public Point<point2d>
- - {
- - int row;
- - int col;
- - };
- -
- - struct point3d : public Point<point2d>
- - {
- - int row;
- - int col;
- - int sli;
- - };
}
@@ -103,21 +100,9 @@
struct Iterator;
template<typename E>
- - struct set_super_type<Iterator<E> >
- - {
- - typedef mlc::none ret;
- - };
- -
- - template <typename E>
- - struct vtypes<Iterator<E> >
- - {
- - typedef mlc::undefined point_type;
- - };
- -
- - template <typename E>
struct Iterator : public stc::any<E>
{
- - typedef oln_type_of(Iterator, point) point_t;
+ typedef oln_type_of(E, point) point_t;
void start()
{
@@ -132,85 +117,16 @@
bool is_valid() const
{
return this->exact().impl_is_valid();
- - };
+ }
// auto
- - operator point_t()
+ operator point_t() const
{
return this->exact().impl_op_point_type();
}
};
}
- -// ------------ //
- -// iterator2d. //
- -// ------------ //
- -
- -namespace oln
- -{
- - struct iterator2d;
- -
- - template <typename T>
- - struct image2d;
- -
- - template<>
- - struct set_super_type<iterator2d>
- - {
- - typedef Iterator<iterator2d> ret;
- - };
- -
- - template <>
- - struct vtypes<iterator2d>
- - {
- - typedef point2d point_type;
- - };
- -
- - struct iterator2d : public Iterator<iterator2d>
- - {
- - typedef oln_type_of_(iterator2d, point) point_t;
- -
- - template <typename T>
- - iterator2d(image2d<T>& ima) :
- - nrows (ima.nrows_get()),
- - ncols (ima.ncols_get())
- - {
- - }
- -
- - void impl_start()
- - {
- - p.row = 0;
- - p.col = 0;
- - }
- -
- - void impl_next()
- - {
- - p.col = p.col + 1;
- -
- - if (p.col == ncols)
- - {
- - p.col = 0;
- - p.row = p.row + 1;
- - }
- - }
- -
- - bool impl_is_valid() const
- - {
- - return p.row < nrows;
- - }
- -
- - point_t& impl_op_point_t()
- - {
- - return p;
- - }
- -
- - protected:
- - int nrows;
- - int ncols;
- - point_t p;
- - };
- -}
- -
- -
// ------- //
// Image. //
@@ -224,12 +140,15 @@
template <typename E>
struct Image : public stc::any<E>
{
- - typename E::value_t& operator ()(typename E::point_t& p)
+ typedef oln_type_of(E, point) point_t;
+ typedef oln_type_of(E, value) value_t;
+
+ value_t& operator ()(point_t& p)
{
return this->exact().impl_op_paren(p);
}
- - bool has(const typename E::point_t& p) const
+ bool has(const point_t& p) const
{
return this->exact().impl_has(p);
}
@@ -244,10 +163,13 @@
namespace oln
{
template <typename E>
- - struct Image2d : public Image<Image2d<E> >
+ struct Image2d : public Image<E>
{
+ typedef oln_type_of(E, point) point_t;
+ typedef oln_type_of(E, value) value_t;
+
//FIXME: delete?
- - typename E::value_t& operator ()(typename E::point_t& p)
+ value_t& operator ()(point_t& p)
{
return this->exact().impl_op_paren(p);
}
@@ -272,10 +194,13 @@
namespace oln
{
template <typename E>
- - struct Image3d : public Image<Image3d<E> >
+ struct Image3d : public Image<E>
{
+ typedef oln_type_of(E, point) point_t;
+ typedef oln_type_of(E, value) value_t;
+
//FIXME: delete?
- - typename E::value_t& operator ()(typename E::point_t& p)
+ value_t& operator ()(point_t& p)
{
return this->exact().impl_operator_paren(p);
}
@@ -298,25 +223,6 @@
}
- -// ------------------------- //
- -// Image with neighborhood. //
- -// ------------------------- //
- -
- -namespace oln
- -{
- - template <typename E>
- - struct Image_with_nbh : public Image<Image_with_nbh<E> >
- - {
- - // FIXME: Implement.
- -#if 0
- - nbh_t nbh() const
- - {
- - }
- -#endif
- - };
- -}
- -
- -
// -------- //
// Switch. //
// -------- //
@@ -327,14 +233,14 @@
template <typename E>
struct case_<switch_image_base, E, 1> :
- - public mlc::where_ < mlc::eq_ <E, point2d> >
+ public mlc::where_ < mlc::eq_ <oln_type_of(E, point), point2d> >
{
typedef Image2d<E> ret;
};
template <typename E>
struct case_<switch_image_base, E, 2> :
- - public mlc::where_ < mlc::eq_ <E, point3d> >
+ public mlc::where_ < mlc::eq_ <oln_type_of(E, point), point3d> >
{
typedef Image3d<E> ret;
};
@@ -374,7 +280,7 @@
};
template <typename E>
- - struct image_base : public oln::switch_<switch_image_base, E>::ret
+ struct image_base : public switch_<switch_image_base, E>::ret
{
image_base()
{
@@ -383,6 +289,93 @@
}
+// ------- //
+// points. //
+// ------- //
+
+namespace oln
+{
+ struct point2d : public Point<point2d>
+ {
+ int row;
+ int col;
+ };
+
+ struct point3d : public Point<point2d>
+ {
+ int row;
+ int col;
+ int sli;
+ };
+}
+
+// ------------ //
+// iterator2d. //
+// ------------ //
+
+namespace oln
+{
+ struct iterator2d;
+
+ template <typename T>
+ struct image2d;
+
+ template<>
+ struct set_super_type<iterator2d>
+ {
+ typedef mlc::none ret;
+ };
+
+ template <>
+ struct vtypes<iterator2d>
+ {
+ typedef point2d point_type;
+ };
+
+ struct iterator2d : public Iterator<iterator2d>
+ {
+ typedef oln_type_of_(iterator2d, point) point_t;
+
+ template <typename T>
+ iterator2d(image2d<T>& ima) :
+ nrows (ima.nrows_get()),
+ ncols (ima.ncols_get())
+ {
+ }
+
+ void impl_start()
+ {
+ p.row = 0;
+ p.col = 0;
+ }
+
+ void impl_next()
+ {
+ p.col = p.col + 1;
+
+ if (p.col == ncols)
+ {
+ p.col = 0;
+ p.row = p.row + 1;
+ }
+ }
+
+ bool impl_is_valid() const
+ {
+ return p.row < nrows;
+ }
+
+ point_t& impl_op_point_t()
+ {
+ return p;
+ }
+
+ protected:
+ int nrows;
+ int ncols;
+ point_t p;
+ };
+}
// --------- //
@@ -451,37 +444,38 @@
};
}
+
// ---------------- //
// image_with_nbh. //
// ---------------- //
- -// namespace oln
- -// {
- -// struct image_with_nbh;
- -
- -// template<>
- -// struct set_super_type<image_with_nbh>
- -// {
- -// typedef image_base<image_with_nbh> ret;
- -// };
- -
- -// template <>
- -// struct vtypes<image_with_nbh>
- -// {
- -// typedef mlc::undefined niter_type;
- -// typedef mlc::undefined nbh_type;
- -// };
- -
- -// struct image_with_nbh : public image_base< image_with_nbh >
- -// {
- -// typedef oln_type_of_(image_with_nbh, nbh) niter_t;
- -// typedef oln_type_of_(image_with_nbh, niter) nbh_t;
- -
- -// image_with_nbh()
- -// {
- -// }
- -// };
- -// }
+namespace oln
+{
+ struct image_with_nbh;
+
+ template<>
+ struct set_super_type<image_with_nbh>
+ {
+ typedef image_base<image_with_nbh> ret;
+ };
+
+ template <>
+ struct vtypes<image_with_nbh>
+ {
+ typedef mlc::undefined niter_type;
+ typedef mlc::undefined nbh_type;
+ };
+
+ struct image_with_nbh : public image_base< image_with_nbh >
+ {
+ typedef oln_type_of_(image_with_nbh, nbh) niter_t;
+ typedef oln_type_of_(image_with_nbh, niter) nbh_t;
+
+ image_with_nbh()
+ {
+ }
+ };
+}
// --------------- //
// image_morpher. //
@@ -501,7 +495,7 @@
template <typename E>
struct vtypes< image_morpher<E> >
{
- - typedef mlc::undefined delegatee_t;
+ typedef mlc::undefined delegatee_type;
};
template <typename E>
@@ -542,7 +536,7 @@
template <typename I, typename N>
struct vtypes< plus<I, N> >
{
- - typedef I delegatee_t;
+ typedef I delegatee_type;
};
template <typename I, typename N>
@@ -576,15 +570,22 @@
{
using namespace oln;
- - // typedef plus<image2d<int>, image_with_nbh> my_ima;
+ typedef plus<image2d<int>, image_with_nbh> my_ima;
point2d p2d;
point3d p3d;
image2d<int> ima(10, 10);
- - // image_with_nbh ima_nb;
+ image_with_nbh ima_nb;
- - // iterator2d it2d(ima);
+ iterator2d it2d(ima);
// my_ima p = ima + ima_nb;
}
+
+
+
+
+
+
+
Index: samples/mini-oln/README
===================================================================
- --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFFyLHI8QvmnUS5oeMRAvUsAJ9n2jayVaSkvCIuz6QSn8Jbr82xsgCgxR0N
6Ol1duxlimW9tTr+exX1irM=
=AGFT
-----END PGP SIGNATURE-----