2007-02-02 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr> Clean stc/doc/tiny. * doc/tiny/more_scoop_2/undefs.hh: Rename as... * doc/tiny/local/undefs.hh: ...this. * doc/tiny/a_la_scoop_1/local_scoop.hh: Rename as... * doc/tiny/a_la_scoop_1/scoopy.hh: ...this. * doc/tiny/more_scoop_2/local_scoop.hh: Rename as... * doc/tiny/local/scoop.hh: ...this. (stc::true_, stc::false_): New. (stc_prop): Update. (stc_decl_associated_type): New. * doc/tiny/a_la_scoop_2/local_scoop.hh: Remove. * doc/tiny/a_la_scoop_1/main.cc, (Current, Super): Rename as... (current, super): ...this to be coherent with SCOOP 2. * doc/tiny/a_la_scoop_1/scoopy.hh, Likewise. * doc/tiny/a_la_scoop_1/desugar.cc, Likewise. * doc/tiny/a_la_scoop_2/main.cc, * doc/tiny/a_la_scoop_2/desugar.cc, * doc/tiny/more_scoop_2/main.cc, * doc/tiny/cpp_with_virtual_types/main.cc, * doc/tiny/design/main.cc, (category): New type in array_iterator. * doc/tiny/cpp_with_concepts/main.cc, * doc/tiny/classical/main.cc, * doc/tiny/generic_programming/main.cc: Update and add copyright header. Index: doc/tiny/a_la_scoop_1/main.cc =================================================================== --- doc/tiny/a_la_scoop_1/main.cc (revision 734) +++ doc/tiny/a_la_scoop_1/main.cc (working copy) @@ -1,7 +1,39 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory. +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. -#include "local_scoop.hh" +/* \file doc/tiny/a_la_scoop_1/main.cc + \brief Tiny sample use of SCOOP 1. */ + + +#include "scoopy.hh" + + stc_equip_namespace(abc); @@ -12,19 +44,19 @@ // Iterator -# define Current Iterator<Exact> -# define Super Any<Exact> +# define current Iterator<Exact> +# define super Any<Exact> template <typename Exact> class Iterator; template <typename Exact> - struct vtypes< Current > : vtypes< Super > + struct vtypes< current > : vtypes< super > { typedef stc::abstract value; }; template <typename Exact> - class Iterator : public Super + class Iterator : public super { public: stc_typename(value); @@ -33,25 +65,25 @@ void set(const value& v) { this->exact().impl_set(v); } }; -#undef Super -#undef Current +#undef super +#undef current // array_iterator -# define Current array_iterator<T> -# define Super Iterator<Current> +# define current array_iterator<T> +# define super Iterator< current > template <typename T> class array_iterator; template <typename T> - struct vtypes< Current > : vtypes< Super > + struct vtypes< current > : vtypes< super > { typedef T value; }; template <typename T> - class array_iterator : public Super + class array_iterator : public super { public: @@ -66,8 +98,8 @@ value v_; }; -#undef Super -#undef Current +#undef super +#undef current Index: doc/tiny/a_la_scoop_1/scoopy.hh =================================================================== --- doc/tiny/a_la_scoop_1/scoopy.hh (revision 729) +++ doc/tiny/a_la_scoop_1/scoopy.hh (working copy) @@ -1,4 +1,39 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory. +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/* \file doc/tiny/a_la_scoop_1/scoopy.hh + + \brief Mini-equipment for SCOOP 1. */ + +#ifndef STC_DOC_TINY_A_LA_SCOOP_1_SCOOPY_HH +# define STC_DOC_TINY_A_LA_SCOOP_1_SCOOPY_HH + + namespace stc { @@ -14,11 +49,12 @@ } -#define stc_typename(Type) typedef typename vtypes<Exact>::Type Type -#define stc_using(Type) typedef typename Super::Type Type +# define stc_typename(Type) typedef typename vtypes<Exact>::Type Type +# define stc_using(Type) typedef typename super::Type Type -#define stc_equip_namespace(Namespace) \ + +# define stc_equip_namespace(Namespace) \ \ namespace Namespace \ { \ @@ -42,3 +78,6 @@ } \ \ struct end_with_semicolumn + + +#endif // ! STC_DOC_TINY_A_LA_SCOOP_1_SCOOPY_HH Index: doc/tiny/a_la_scoop_1/local_scoop.hh =================================================================== --- doc/tiny/a_la_scoop_1/local_scoop.hh (revision 734) +++ doc/tiny/a_la_scoop_1/local_scoop.hh (working copy) @@ -1,44 +0,0 @@ - -namespace stc -{ - - class abstract; - - template <typename Exact> - class any - { - public: - Exact& exact() { return *(Exact*)(void*)this; } - const Exact& exact() const { return *(const Exact*)(const void*)this; } - }; - -} - -#define stc_typename(Type) typedef typename vtypes<Exact>::Type Type -#define stc_using(Type) typedef typename Super::Type Type - - -#define stc_equip_namespace(Namespace) \ - \ -namespace Namespace \ -{ \ - template <typename T> struct vtypes; \ - \ - /* Any. */ \ - \ - template <typename Exact> class Any; \ - \ - template <typename Exact> \ - struct vtypes< Any<Exact> > \ - { \ - typedef Exact exact; \ - }; \ - \ - template <typename Exact> \ - class Any : public stc::any<Exact> \ - { \ - }; \ - \ -} \ - \ -struct end_with_semicolumn Index: doc/tiny/a_la_scoop_1/desugar.cc =================================================================== --- doc/tiny/a_la_scoop_1/desugar.cc (revision 734) +++ doc/tiny/a_la_scoop_1/desugar.cc (working copy) @@ -1,7 +1,39 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory. +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. -#include "local_scoop.hh" +/* \file doc/tiny/a_la_scoop_1/desugar.cc + \brief Tiny sample use of SCOOP 1 without sugar. */ + + +#include "scoopy.hh" + + stc_equip_namespace(abc); @@ -24,7 +56,7 @@ class Iterator : public Any<Exact> { public: - stc_typename(value); + typedef typename vtypes<Exact>::value value; void next() { this->exact().impl_next(); } bool is_valid() const { return this->exact().impl_is_valid(); } void set(const value& v) { this->exact().impl_set(v); } @@ -44,10 +76,10 @@ template <typename T> class array_iterator : public Iterator< array_iterator<T> > { - typedef Iterator< array_iterator<T> > Super; + typedef Iterator< array_iterator<T> > super; public: - stc_using(value); + typedef typename super::value value; void impl_next() { i_ = i_ + 1; } bool impl_is_valid() const { return i_ >= 0 and i_ < n_; } void impl_set(const value& v) { v_ = v; } Index: doc/tiny/a_la_scoop_2/undefs.hh =================================================================== --- doc/tiny/a_la_scoop_2/undefs.hh (revision 734) +++ doc/tiny/a_la_scoop_2/undefs.hh (working copy) @@ -1,5 +0,0 @@ - -#undef current -#undef super -#undef templ -#undef classname Index: doc/tiny/a_la_scoop_2/main.cc =================================================================== --- doc/tiny/a_la_scoop_2/main.cc (revision 734) +++ doc/tiny/a_la_scoop_2/main.cc (working copy) @@ -1,7 +1,39 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory. +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. -#include "local_scoop.hh" +/* \file doc/tiny/a_la_scoop_2/main.cc + \brief Tiny sample use of SCOOP 2. */ + + +#include "../local/scoop.hh" + + stc_equip_namespace(abc); @@ -10,7 +42,7 @@ { // List of associated types. - mlc_decl_typedef(value); + stc_decl_associated_type(value); // Iterator @@ -20,7 +52,6 @@ public automatic::impl<Iterator, Exact> { stc_typename(value); - void next() { this->exact().impl_next(); } bool is_valid() const { return this->exact().impl_is_valid(); } void set(const value& v) { this->exact().impl_set(v); } @@ -53,23 +84,17 @@ public: stc_using(value); - - // Impl. - void impl_next() { i_ = i_ + 1; } bool impl_is_valid() const { return i_ >= 0 and i_ < n_; } void impl_set(const value& v) { v_ = v; } - // Ctor. - array_iterator(int n) : i_(0), n_(n) {} - protected: int i_, n_; value v_; }; -# include "undefs.hh" +# include "../local/undefs.hh" Index: doc/tiny/a_la_scoop_2/local_scoop.hh =================================================================== --- doc/tiny/a_la_scoop_2/local_scoop.hh (revision 734) +++ doc/tiny/a_la_scoop_2/local_scoop.hh (working copy) @@ -1,1050 +0,0 @@ -// Copyright (C) 2005, 2006 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/scoop2.hh - - \brief Equipment for SCOOP2: notably, Virtual types (also known as - ``properties'') mechanism. -*/ - -#ifndef STC_SCOOP2_HH -# define STC_SCOOP2_HH - -# include <mlc/flags.hh> -# include <mlc/typedef.hh> -# include <mlc/ret.hh> -# include <mlc/assert.hh> -# include <mlc/abort.hh> -# include <mlc/bool.hh> -# include <mlc/pair.hh> -# include <mlc/cmp.hh> -# include <mlc/if.hh> -# include <mlc/is_a.hh> -# include <mlc/case.hh> - -# include <stc/any.hh> - - -namespace stc -{ - - struct not_delegated; - - struct abstract; - - template <typename T> - struct final; - - template < template <class> class > - struct is; - -} // end of namespace stc - - - -#define stc_super(T) typename vtypes< T >::super_type -#define stc_stm(From, Target) typename get_stm< From , Target >::ret - - - - - -# define stc_equip_namespace(SCOOPED_NAMESPACE) \ - \ - \ -namespace SCOOPED_NAMESPACE \ -{ \ - \ - mlc_decl_typedef(delegatee_type); \ - \ - \ - template <typename from_type> \ - struct vtypes \ - { \ - }; \ - \ - template <typename from_type, typename type> \ - struct single_vtype \ - { \ - typedef mlc::not_found ret; \ - }; \ - \ - \ - \ - namespace ERROR \ - { \ - \ - template < typename first_definition, \ - typename re_definition, \ - typename target > \ - struct final_vtype_redefined_; \ - \ - \ - template < typename first_definition, \ - typename declaration, \ - typename target > \ - struct vtype_declared_but_already_set_; \ - \ - \ - template < typename from, \ - typename target > \ - struct vtype_not_found; \ - \ - \ - template < typename curr, \ - typename target, \ - typename stm > \ - struct wrong_final_stm_; \ - \ - \ - template < typename target, \ - typename declaration, \ - typename from > \ - struct vtype_declared_but_not_defined; \ - \ - \ - template <typename T> \ - struct _declaration_is_in_; \ - \ - template <typename T> \ - struct _definition_is_looked_up_from_; \ - \ - \ - template <typename T> \ - struct _for_vtype_; \ - \ - \ - struct no_delegatee_declared_; \ - \ - \ - } /* end of namespace SCOOPED_NAMESPACE::ERROR */ \ - \ - \ - \ - namespace internal \ - { \ - \ - \ - /* \ - * Forward declarations. \ - */ \ - \ - \ - template <typename from, typename target> \ - struct get_stm; \ - \ - template <typename res1, typename res2> \ - struct helper_get_stm; \ - \ - template <typename from, typename target> \ - struct first_stm; \ - \ - template <typename curr, typename target, typename stm> \ - struct helper_first_stm; \ - \ - \ - template <typename from, typename target, typename curr = from> \ - struct superior_find; \ - \ - template <typename from, typename target, typename curr, typename stm> \ - struct helper_superior_find; \ - \ - template <typename from, typename target> \ - struct delegator_find; \ - \ - template <typename from, typename target, typename delegatee> \ - struct helper_delegator_find; \ - \ - template <typename from, typename target> \ - struct find; \ - \ - template <typename from, typename target, typename where, typename res> \ - struct helper_find; \ - \ - \ - \ - template <typename from, typename target> \ - struct check; \ - \ - template <typename curr, typename target, typename stm> \ - struct helper_check; \ - \ - \ - \ - /* get_stm(from, target) \ - * \ - * Returns the statement for class 'from' corresponding to 'target'. \ - * This statement is either defined in 'vtypes' or in 'single_vtype'. \ - * \ - * This routine is local; it does not recourse on superior classes. \ - * \ - */ \ - \ - template <typename res1> \ - struct helper_get_stm <res1, mlc::not_found> \ - { \ - typedef res1 ret; \ - }; \ - \ - template <typename res2> \ - struct helper_get_stm <mlc::not_found, res2> \ - { \ - typedef res2 ret; \ - }; \ - \ - template <> \ - struct helper_get_stm <mlc::not_found, mlc::not_found> \ - { \ - typedef mlc::not_found ret; \ - }; \ - \ - template <typename res1, typename res2> \ - struct helper_get_stm /* FIXME: Insert mlc::abort_<> statement here? */ \ - { \ - /* error */ \ - }; \ - \ - template <typename from, typename target> \ - struct get_stm \ - { \ - typedef SCOOPED_NAMESPACE::vtypes<from> decl1; \ - typedef typename target::template from_<decl1>::ret res1; \ - \ - typedef SCOOPED_NAMESPACE::single_vtype<from, target> decl2; \ - typedef typename decl2::ret ret2; \ - \ - typedef typename helper_get_stm<res1, ret2>::ret ret; \ - }; \ - \ - \ - \ - \ - /* -------------------- */ \ - /* Checking algorithm. */ \ - /* -------------------- */ \ - \ - /* \ - * check_no_final_inherited \ - * \ - * FIXME: ... \ - */ \ - \ - template < typename orig, typename curr, typename target, \ - typename stm = typename get_stm<curr, target>::ret > \ - struct check_no_final_inherited \ - \ - : mlc::assert_< mlc_is_not_a(stm, stc::final), \ - ERROR::final_vtype_redefined_< orig, \ - mlc::pair_<curr, stm>, \ - target > \ - >, \ - /* rec */ check_no_final_inherited<orig, stc_super(curr), target> \ - { \ - }; \ - \ - template <typename orig, typename target, typename stm> \ - struct check_no_final_inherited <orig, /* if curr == */ mlc::none, target, stm> \ - { \ - }; \ - \ - \ - /* \ - * check_no_stm_inherited \ - * \ - * FIXME: ... \ - */ \ - \ - template < typename orig, typename curr, typename target, \ - typename stm = typename get_stm<curr, target>::ret > \ - struct check_no_stm_inherited \ - \ - : mlc::assert_< mlc::is_not_found_<stm>, \ - ERROR::vtype_declared_but_already_set_< orig, \ - mlc::pair_<curr, stm>, \ - target > \ - >, \ - /* rec */ check_no_stm_inherited<orig, stc_super(curr), target> \ - { \ - }; \ - \ - template <typename orig, typename target, typename stm> \ - struct check_no_stm_inherited <orig, /* if curr == */ mlc::none, target, stm> \ - { \ - }; \ - \ - \ - /* \ - * check_delegatee_inherited \ - */ \ - \ - template <typename curr, typename target> \ - struct check_delegatee_inherited \ - : mlc::assert_< mlc::is_found_< typename first_stm<curr, \ - typedef_::delegatee_type>::ret::second_elt >, \ - ERROR::no_delegatee_declared_ > \ - { \ - }; \ - \ - \ - /* \ - * check_final_stm \ - */ \ - \ - template <typename curr, typename target, typename stm> \ - struct check_final_stm \ - {}; \ - \ - template <typename curr, typename target> \ - struct check_final_stm < curr, target, stc::abstract > \ - : mlc::abort_< ERROR::wrong_final_stm_<curr, target, stc::final<stc::abstract> > > \ - {}; \ - \ - template <typename curr, typename target, typename T> \ - struct check_final_stm < curr, target, stc::final<T> > \ - : mlc::abort_< ERROR::wrong_final_stm_<curr, target, stc::final<stc::final<T> > > > \ - {}; \ - \ - template <typename curr, typename target> \ - struct check_final_stm < curr, target, stc::not_delegated > \ - : mlc::abort_< ERROR::wrong_final_stm_<curr, target, stc::final<stc::not_delegated> > > \ - {}; \ - \ - template <typename curr, typename target> \ - struct check_final_stm < curr, target, mlc::not_found > \ - : mlc::abort_< ERROR::wrong_final_stm_<curr, target, stc::final<mlc::not_found> > > \ - {}; \ - \ - \ - \ - \ - /* \ - * check(from, target) \ - * \ - * pseudo-code: \ - * \ - * check(from, target) \ - * { \ - * if (from == mlc::none) // stop because no more class \ - * return done; \ - * else \ - * return helper_check(from, target, get_stm(from, target)); \ - * } \ - */ \ - \ - struct dummy {}; \ - \ - template <typename target> \ - struct check < /* if from == */ mlc::none, target > \ - { \ - typedef dummy ret; \ - }; \ - \ - template <typename from, typename target> \ - struct check /* otherwise */ \ - { \ - typedef typename helper_check< from, target, \ - stc_stm(from, target) >::ret ret; \ - }; \ - \ - \ - \ - \ - /* \ - * pseudo-code: \ - * \ - * helper_check(curr, target, stm) \ - * { \ - * super = super(curr); \ - * \ - * if (stm == stc::abstract) { \ - * check_no_stm_inherited(curr, super, target); \ - * return check(super, target); \ - * } \ - * if (stm == stc::final<T>) { \ - * check_final_stm(T); \ - * check_no_final_inherited((curr, T), super, target); \ - * return check(super, target); \ - * } \ - * if (stm == stc::not_delegated) { \ - * check_delegatee_inherited(curr); \ - * check_no_final_inherited((curr, stc::not_delegated), super, target); \ - * return check(super, target); \ - * } \ - * if (stm == mlc::not_found) { \ - * return check(super, target); \ - * } \ - * // otherwise, non-final stm: \ - * if (stm == T) { \ - * check_no_final_inherited((curr, T), super, target); \ - * return check(super, target); \ - * } \ - * } \ - * \ - */ \ - \ - template <typename curr, typename target> \ - struct helper_check < curr, target, \ - /* if stm == */ stc::abstract > \ - : check_no_stm_inherited< mlc::pair_<curr, stc::abstract >, \ - stc_super(curr), \ - target > \ - { \ - typedef typename check<stc_super(curr), target>::ret ret; \ - }; \ - \ - template <typename curr, typename target, typename T> \ - struct helper_check < curr, target, \ - /* if stm == */ stc::final<T> > \ - : check_no_final_inherited< mlc::pair_<curr, stc::final<T> >, \ - stc_super(curr), \ - target > \ - { \ - /* FIXME: \ - check_final_stm(T); \ - */ \ - typedef typename check<stc_super(curr), target>::ret ret; \ - }; \ - \ - template <typename curr, typename target> \ - struct helper_check < curr, target, \ - /* if stm == */ stc::not_delegated > \ - : check_no_final_inherited< mlc::pair_<curr, stc::not_delegated>, \ - stc_super(curr), \ - target > \ - { \ - /* FIXME: \ - check_delegatee_inherited(curr); \ - */ \ - typedef typename check<stc_super(curr), target>::ret ret; \ - }; \ - \ - template <typename curr, typename target> \ - struct helper_check < curr, target, \ - /* if stm == */ mlc::not_found > \ - { \ - typedef typename check<stc_super(curr), target>::ret ret; \ - }; \ - \ - template <typename curr, typename target, typename stm> \ - struct helper_check /* otherwise, non-final stm */ \ - : check_no_final_inherited< mlc::pair_<curr, stm>, \ - stc_super(curr), \ - target > \ - { \ - typedef typename check<stc_super(curr), target>::ret ret; \ - }; \ - \ - \ - \ - /* ------------------- */ \ - /* Look-up algorithm. */ \ - /* ------------------- */ \ - \ - /* \ - * first_stm(from, target) \ - * \ - * returns a pair (Where, 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. \ - * \ - * \ - * helper_first_stm(curr, target, stm) \ - * { \ - * if (stm == mlc::not_found) \ - * return first_stm(super(curr), target); \ - * else if (stm == stc::final<T>) \ - * return pair(curr, T); \ - * else \ - * return pair(curr, stm); \ - * } \ - * \ - * first_stm(from, target) \ - * { \ - * if (from == mlc::none) \ - * return pair(mlc::none, mlc::not_found); \ - * else \ - * return helper_first_stm(from, target, \ - * get_stm(from, target)); \ - * } \ - * \ - */ \ - \ - template <typename curr, typename target> \ - struct helper_first_stm < curr, target, \ - /* if stm == */ mlc::not_found > \ - { \ - typedef typename first_stm<stc_super(curr), target>::ret ret; \ - }; \ - \ - template <typename curr, typename target, typename T> \ - struct helper_first_stm < curr, target, \ - /* if stm == */ stc::final<T> > \ - { \ - typedef mlc::pair_<curr, T> ret; \ - }; \ - \ - template <typename curr, typename target, typename stm> \ - struct helper_first_stm /* otherwise */ \ - { \ - typedef mlc::pair_<curr, stm> ret; \ - }; \ - \ - template <typename target> \ - struct first_stm < /* if from == */ mlc::none, target > \ - { \ - typedef mlc::pair_<mlc::none, mlc::not_found> ret; \ - }; \ - \ - template <typename from, typename target> \ - struct first_stm /* otherwise */ \ - { \ - typedef typename helper_first_stm<from, target, \ - stc_stm(from, target)>::ret ret; \ - }; \ - \ - \ - \ - /* \ - * superior_find(from, target) \ - * \ - * returns: \ - * either mlc::not_found \ - * or a type T \ - * behavior: \ - * - the stm stc::not_delegated is ignored \ - * - error when stc::abstract is reached \ - * \ - * helper_superior_find(from, target, curr, stm) \ - * { \ - * if (stm == stc::abstract) \ - * error("<target> declared in <curr> but not defined at <from>"); \ - * else if (stm == mlc::not_found or \ - * stm == stc::not_delegated) \ - * return superior_find(from, target, super(curr)); \ - * else if (stm == stc::final<T>) \ - * return T; \ - * else \ - * return stm; \ - * } \ - * \ - * superior_find(from, target, curr = from) \ - * { \ - * if (curr == mlc::none) \ - * return mlc::not_found; \ - * else \ - * return helper_superior_find(from, target, curr, \ - * get_stm(curr, target)); \ - * } \ - */ \ - \ - template <typename from, typename target, typename curr> \ - struct helper_superior_find < from, target, curr, \ - /* if stm == */ stc::abstract > \ - { \ - /* FIXME: error("<target> declared in <curr> but not defined at <from>"); */ \ - }; \ - \ - template <typename from, typename target, typename curr> \ - struct helper_superior_find < from, target, curr, \ - /* if stm == */ mlc::not_found > \ - { \ - typedef typename superior_find< from, target, \ - stc_super(curr) >::ret ret; \ - }; \ - \ - template <typename from, typename target, typename curr> \ - struct helper_superior_find < from, target, curr, \ - /* if stm == */ stc::not_delegated > \ - { \ - typedef typename superior_find< from, target, \ - stc_super(curr) >::ret ret; \ - }; \ - \ - template <typename from, typename target, typename curr, typename T> \ - struct helper_superior_find < from, target, curr, \ - /* if stm == */ stc::final<T> > \ - { \ - typedef T ret; \ - }; \ - \ - template <typename from, typename target, typename curr, typename stm> \ - struct helper_superior_find /* otherwise */ \ - { \ - typedef stm ret; \ - }; \ - \ - template <typename from, typename target> \ - struct superior_find < from, target, /* if curr == */ mlc::none > \ - { \ - typedef mlc::not_found ret; \ - }; \ - \ - template <typename from, typename target, typename curr> \ - struct superior_find /* otherwise */ \ - { \ - typedef typename helper_superior_find<from, target, curr, \ - stc_stm(curr, target)>::ret ret; \ - }; \ - \ - \ - \ - /* \ - * delegator_find(from, target) \ - * \ - * \ - * delegator_find(from, target) \ - * { \ - * precondition(target != delegatee_type); \ - * delegatee = superior_find(from, delegatee_type); \ - * if (delegatee == mlc::not_found) \ - * return mlc::not_found; \ - * else \ - * return find(delegatee, target); \ - * } \ - */ \ - \ - template <typename from, typename target> \ - struct helper_delegator_find < from, target, \ - /* if delegatee == */ mlc::not_found > \ - { \ - typedef mlc::not_found ret; \ - }; \ - \ - template <typename from, typename target, typename delegatee> \ - struct helper_delegator_find /* otherwise */ \ - { \ - typedef typename find<delegatee, target>::ret ret; \ - }; \ - \ - template <typename from, typename target> \ - struct delegator_find \ - { \ - typedef typename superior_find<from, typedef_::delegatee_type>::ret delegatee; \ - typedef typename helper_delegator_find<from, target, delegatee>::ret ret; \ - }; \ - \ - \ - \ - /* \ - * helper_find(from, target, where, res) \ - * \ - * \ - * \ - */ \ - \ - template <typename from, typename target, typename where> \ - struct helper_find < from, target, where, \ - /* 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, \ - /* if res == */ stc::abstract > \ - { \ - typedef typename delegator_find<from, target>::ret res_d; \ - struct check_ \ - : mlc::assert_< mlc::is_found_<res_d>, \ - ERROR::vtype_declared_but_not_defined \ - < ERROR::_for_vtype_<target>, \ - ERROR::_declaration_is_in_<where>, \ - ERROR::_definition_is_looked_up_from_<from> > > \ - /* FIXME: error("<target> declared in <where> 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, \ - /* if res == */ stc::not_delegated > \ - { \ - typedef typename superior_find<from, target>::ret ret; \ - }; \ - \ - template <typename from, typename target, typename where, typename res> \ - struct helper_find /* otherwise */ \ - { \ - typedef res ret; \ - }; \ - \ - \ - \ - /* \ - * find(from, target) \ - * \ - * FIXME: ... \ - * \ - * find(from, target) \ - * { \ - * if (target == delegatee_type) \ - * return superior_find(from, delegatee_type); \ - * else \ - * return helper_find(from, target); \ - * } \ - */ \ - \ - template <typename from> \ - struct find <from, /* if target == */ typedef_::delegatee_type > \ - { \ - typedef typename superior_find<from, typedef_::delegatee_type>::ret ret; \ - }; \ - \ - template <typename from, typename target> \ - struct find /* otherwise */ \ - { \ - typedef typename first_stm<from, target>::ret stm; \ - typedef mlc_elt(stm, 1) where; \ - typedef mlc_elt(stm, 2) res; \ - typedef typename helper_find<from, target, \ - where, res>::ret ret; \ - }; \ - \ - \ - } /* end of SCOOPED_NAMESPACE::internal */ \ - \ - \ - /* \ - * find_vtype(from, target) \ - * \ - * FIXME:... \ - * \ - */ \ - \ - template <typename from, typename target> \ - struct deferred_vtype \ - { \ - typedef typename internal::find<from, target>::ret ret; \ - }; \ - \ - template <typename from, typename target> \ - struct find_vtype \ - { \ - typedef typename internal::find<from, target>::ret ret; \ - typedef typename internal::check<from, target>::ret chk; \ - }; \ - \ - 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; \ - }; \ - \ - \ - \ - mlc_case_equipment_for_namespace(internal); \ - \ - mlc_decl_typedef(tag); \ - mlc_decl_typedef(category); \ - mlc_decl_typedef(exact_type); \ - \ - \ - namespace internal \ - { \ - \ - \ - template < template <class> class abstraction, \ - unsigned num = 1 > \ - struct selector \ - { \ - protected: selector() {} \ - }; \ - \ - \ - /* fwd decl */ \ - template < template <class> class abstraction, typename E, unsigned num > \ - struct plug_node; \ - \ - template < template <class> class abstraction, \ - typename E, \ - unsigned num, \ - typename another_selector = mlc::false_ > \ - struct next_plug_node \ - { \ - /* here: no other selector */ \ - protected: next_plug_node() {} \ - }; \ - \ - template < template <class> class abstraction, \ - typename E > \ - struct next_plug_node < abstraction, E, 1, mlc::false_ > \ - : public abstraction<E> \ - { \ - protected: next_plug_node() {} \ - }; \ - \ - \ - template < template <class> class abstraction, \ - typename E, \ - unsigned num > \ - struct next_plug_node < abstraction, \ - E, \ - num, \ - mlc::true_> \ - \ - : /* plug to client selectors */ \ - public virtual switch_< selector<abstraction, num>, E >::ret, \ - \ - /* here: another selector (number is 'num + 1') */ \ - public plug_node<abstraction, E, num + 1> \ - { \ - protected: next_plug_node() {} \ - }; \ - \ - \ - template < template <class> class abstraction, \ - typename E, \ - unsigned num > \ - struct plug_node \ - : public next_plug_node< abstraction, \ - E, \ - num, \ - typename mlc::is_defined_< case_< selector<abstraction, num>, \ - E, 1 > >::eval > \ - { \ - protected: plug_node() {} \ - }; \ - \ - \ - template < template <class> class abstraction, \ - unsigned num, \ - typename E > \ - struct default_case_ < selector<abstraction, num>, \ - E > \ - { \ - typedef abstraction<E> ret; \ - }; \ - \ - \ - template < template <class> class abstraction, \ - typename E > \ - struct plug : public plug_node<abstraction, E, 1> \ - { \ - protected: plug() {} \ - }; \ - \ - template <typename abstraction, typename E> \ - struct top; \ - \ - template <template<class> class abstraction, typename E> \ - struct top < stc::is<abstraction>, E > : public plug< abstraction, E > \ - { \ - protected: top() {} \ - }; \ - \ - template <typename E> \ - struct top < mlc::not_found, E > \ - { \ - protected: top() {} \ - }; \ - \ - \ - } /* end of namespace internal */ \ - \ - \ - \ - /* top class */ \ - \ - template <typename E> struct top; \ - \ - template <typename E> \ - struct vtypes< top<E> > \ - { \ - typedef mlc::none super_type; \ - typedef stc::abstract category; \ - typedef stc::final<E> exact_type; \ - }; \ - \ - template <typename E> \ - struct top : public internal::top< stc_find_type(E, category), E > \ - { \ - protected: \ - top() {} \ - }; \ - \ - \ - \ - /* concept class */ \ - \ - template <typename E> \ - struct Concept : public stc::any<E> \ - { \ - protected: \ - Concept() {} \ - }; \ - \ - \ - namespace automatic \ - { \ - \ - template < template <class> class abstraction, typename E, typename tag = void > \ - struct impl \ - /* undefined */ ; \ - \ - template < template <class> class abstraction, typename E > \ - struct impl< abstraction, E, mlc::not_found > \ - { /* nothing */ }; \ - \ - template < template <class> class abstraction, typename E > \ - struct impl< abstraction, E, void > : impl< abstraction, E, stc_find_type(E, tag) > \ - { /* fetch impl w.r.t. tag */ }; \ - \ - } /* end of namespace automatic */ \ - \ - \ - \ -} /* end of SCOOPED_NAMESPACE */ \ - \ - \ -struct e_n_d__w_i_t_h___s_e_m_i_c_o_l_o_n; - - -/* - - -// -------------------------------------------- -// O L D B U N C H O F M A C R O S -// -------------------------------------------- - - - -# define stc_find_vtype_(Namespace, From, Target) \ - Namespace::find_vtype<From, Namespace::typedef_::Target##_type>::ret - -# define stc_find_vtype(Namespace, From, Target) \ - typename stc_find_vtype_(Namespace, From, Target) - - - -# define stc_deferred_vtype_(Namespace, From, Target) \ - Namespace::deferred_vtype<From, Namespace::typedef_::Target##_type>::ret - -# define stc_deferred_vtype(Namespace, From, Target) \ - typename stc_deferred_vtype_(Namespace, From, Target) - - - -# define stc_vtype_(Namespace, From, Target) \ - Namespace::vtype<From, Namespace::typedef_::Target##_type>::ret - -# define stc_vtype(Namespace, From, Target) \ - typename stc_vtype_(Namespace, From, Target) - - - -# define stc_find_deduce_vtype_(Namespace, From, Target1, Target2) \ - Namespace::find_vtype< Namespace::find_vtype<From, \ - Namespace::typedef_::Target1##_type>::ret, \ - Namespace::typedef_::Target2##_type>::ret - -# define stc_find_deduce_vtype(Namespace, From, Target1, Target2) \ - typename \ - Namespace::find_vtype< typename \ - Namespace::find_vtype<From, \ - Namespace::typedef_::Target1##_type>::ret, \ - Namespace::typedef_::Target2##_type>::ret - - - -# define stc_deduce_deferred_vtype(Namespace, From, Target1, Target2) \ - typename \ - Namespace::deferred_vtype< typename \ - Namespace::deferred_vtype<From, \ - Namespace::typedef_::Target1##_type>::ret, \ - Namespace::typedef_::Target2##_type>::ret \ - - - -# define stc_deduce_vtype_(Namespace, From, Target1, Target2) \ - Namespace::vtype< Namespace::vtype<From, \ - Namespace::typedef_::Target1##_type>::ret, \ - Namespace::typedef_::Target2##_type>::ret - -# define stc_deduce_vtype(Namespace, From, Target1, Target2) \ - typename \ - Namespace::vtype< typename \ - Namespace::vtype<From, \ - Namespace::typedef_::Target1##_type>::ret, \ - Namespace::typedef_::Target2##_type>::ret - - -// # define stc_vtype_is_found_(Namespace, From, Target) -// mlc::is_found_< Namespace::find_vtype<From, Namespace::typedef_::Target##_type>::ret > - - -// ---------------------------------------------------------- -// E N D O F O L D B U N C H O F M A C R O S -// ---------------------------------------------------------- - -*/ - - - - -# define stc_type_(From, Type) vtype<From, typedef_::Type>::ret -# define stc_type(From, Type) typename stc_type_(From, Type) - -# define stc_find_type(From, Type) typename find_vtype<From, typedef_::Type>::ret - - -// For concepts. -# define stc_typename(Type) typedef stc_type(Exact, Type) Type -# define stc_using(Type) typedef typename super::Type Type - - -// For impl classes. -# define stc_lookup(Type) typedef typename vtype< stc_type(current, exact_type), typedef_::Type>::ret Type - -// typedef stc_type(current, Type) Type - - - -// sugar: - -# define stc_Header \ - \ -templ class classname ; /* fwd decl */ \ - \ -templ struct vtypes< current > /* vtypes */ \ -{ \ - typedef super super_type \ - -# define stc_End } - - - -#endif // ! STC_SCOOP2_HH Index: doc/tiny/a_la_scoop_2/desugar.cc =================================================================== --- doc/tiny/a_la_scoop_2/desugar.cc (revision 734) +++ doc/tiny/a_la_scoop_2/desugar.cc (working copy) @@ -1,7 +1,39 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory. +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. -#include "local_scoop.hh" +/* \file doc/tiny/a_la_scoop_2/desugar.cc + \brief Tiny sample use of SCOOP 2 without sugar. */ + + +#include "../local/scoop.hh" + + stc_equip_namespace(abc); @@ -10,7 +42,7 @@ { // List of associated types. - mlc_decl_typedef(value); + stc_decl_associated_type(value); // Iterator Index: doc/tiny/more_scoop_2/undefs.hh =================================================================== --- doc/tiny/more_scoop_2/undefs.hh (revision 734) +++ doc/tiny/more_scoop_2/undefs.hh (working copy) @@ -1,5 +0,0 @@ - -#undef current -#undef super -#undef templ -#undef classname Index: doc/tiny/more_scoop_2/main.cc =================================================================== --- doc/tiny/more_scoop_2/main.cc (revision 734) +++ doc/tiny/more_scoop_2/main.cc (working copy) @@ -1,6 +1,37 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory. +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/* \file doc/tiny/more_scoop_2/main.cc + + \brief Extension of the tiny sample use of SCOOP 2. */ + #include <iostream> -#include "local_scoop.hh" +#include "../local/scoop.hh" stc_equip_namespace(abc); @@ -11,9 +42,9 @@ { // List of associated types. - mlc_decl_typedef(value); - mlc_decl_typedef(forward); - mlc_decl_typedef(backward); + stc_decl_associated_type(value); + stc_decl_associated_type(forward); + stc_decl_associated_type(backward); @@ -123,12 +154,11 @@ value v_; }; +# include "../local/undefs.hh" -# include "undefs.hh" - // lightweight_iterator @@ -166,7 +196,7 @@ }; -# include "undefs.hh" +# include "../local/undefs.hh" @@ -191,8 +221,8 @@ stc_Header; typedef T value; - typedef mlc::true_ forward; - typedef mlc::true_ backward; + typedef stc::true_ forward; + typedef stc::true_ backward; stc_End; @@ -213,7 +243,7 @@ int i_, n_; }; -# include "undefs.hh" +# include "../local/undefs.hh" @@ -335,7 +365,7 @@ }; -# include "undefs.hh" +# include "../local/undefs.hh" template <typename I> Index: doc/tiny/more_scoop_2/local_scoop.hh =================================================================== --- doc/tiny/more_scoop_2/local_scoop.hh (revision 734) +++ doc/tiny/more_scoop_2/local_scoop.hh (working copy) @@ -1,1054 +0,0 @@ -// Copyright (C) 2005, 2006 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/scoop2.hh - - \brief Equipment for SCOOP2: notably, Virtual types (also known as - ``properties'') mechanism. -*/ - -#ifndef STC_SCOOP2_HH -# define STC_SCOOP2_HH - -# include <mlc/flags.hh> -# include <mlc/typedef.hh> -# include <mlc/ret.hh> -# include <mlc/assert.hh> -# include <mlc/abort.hh> -# include <mlc/bool.hh> -# include <mlc/pair.hh> -# include <mlc/cmp.hh> -# include <mlc/if.hh> -# include <mlc/is_a.hh> -# include <mlc/case.hh> - -# include <stc/any.hh> - - - - -namespace stc -{ - - struct not_delegated; - - struct abstract; - - template <typename T> - struct final; - - template < template <class> class > - struct is; - -} // end of namespace stc - - - -#define stc_super(T) typename vtypes< T >::super_type -#define stc_stm(From, Target) typename get_stm< From , Target >::ret - - - - - -# define stc_equip_namespace(SCOOPED_NAMESPACE) \ - \ - \ -namespace SCOOPED_NAMESPACE \ -{ \ - \ - mlc_decl_typedef(delegatee_type); \ - \ - \ - template <typename from_type> \ - struct vtypes \ - { \ - }; \ - \ - template <typename from_type, typename type> \ - struct single_vtype \ - { \ - typedef mlc::not_found ret; \ - }; \ - \ - \ - \ - namespace ERROR \ - { \ - \ - template < typename first_definition, \ - typename re_definition, \ - typename target > \ - struct final_vtype_redefined_; \ - \ - \ - template < typename first_definition, \ - typename declaration, \ - typename target > \ - struct vtype_declared_but_already_set_; \ - \ - \ - template < typename from, \ - typename target > \ - struct vtype_not_found; \ - \ - \ - template < typename curr, \ - typename target, \ - typename stm > \ - struct wrong_final_stm_; \ - \ - \ - template < typename target, \ - typename declaration, \ - typename from > \ - struct vtype_declared_but_not_defined; \ - \ - \ - template <typename T> \ - struct _declaration_is_in_; \ - \ - template <typename T> \ - struct _definition_is_looked_up_from_; \ - \ - \ - template <typename T> \ - struct _for_vtype_; \ - \ - \ - struct no_delegatee_declared_; \ - \ - \ - } /* end of namespace SCOOPED_NAMESPACE::ERROR */ \ - \ - \ - \ - namespace internal \ - { \ - \ - \ - /* \ - * Forward declarations. \ - */ \ - \ - \ - template <typename from, typename target> \ - struct get_stm; \ - \ - template <typename res1, typename res2> \ - struct helper_get_stm; \ - \ - template <typename from, typename target> \ - struct first_stm; \ - \ - template <typename curr, typename target, typename stm> \ - struct helper_first_stm; \ - \ - \ - template <typename from, typename target, typename curr = from> \ - struct superior_find; \ - \ - template <typename from, typename target, typename curr, typename stm> \ - struct helper_superior_find; \ - \ - template <typename from, typename target> \ - struct delegator_find; \ - \ - template <typename from, typename target, typename delegatee> \ - struct helper_delegator_find; \ - \ - template <typename from, typename target> \ - struct find; \ - \ - template <typename from, typename target, typename where, typename res> \ - struct helper_find; \ - \ - \ - \ - template <typename from, typename target> \ - struct check; \ - \ - template <typename curr, typename target, typename stm> \ - struct helper_check; \ - \ - \ - \ - /* get_stm(from, target) \ - * \ - * Returns the statement for class 'from' corresponding to 'target'. \ - * This statement is either defined in 'vtypes' or in 'single_vtype'. \ - * \ - * This routine is local; it does not recourse on superior classes. \ - * \ - */ \ - \ - template <typename res1> \ - struct helper_get_stm <res1, mlc::not_found> \ - { \ - typedef res1 ret; \ - }; \ - \ - template <typename res2> \ - struct helper_get_stm <mlc::not_found, res2> \ - { \ - typedef res2 ret; \ - }; \ - \ - template <> \ - struct helper_get_stm <mlc::not_found, mlc::not_found> \ - { \ - typedef mlc::not_found ret; \ - }; \ - \ - template <typename res1, typename res2> \ - struct helper_get_stm /* FIXME: Insert mlc::abort_<> statement here? */ \ - { \ - /* error */ \ - }; \ - \ - template <typename from, typename target> \ - struct get_stm \ - { \ - typedef SCOOPED_NAMESPACE::vtypes<from> decl1; \ - typedef typename target::template from_<decl1>::ret res1; \ - \ - typedef SCOOPED_NAMESPACE::single_vtype<from, target> decl2; \ - typedef typename decl2::ret ret2; \ - \ - typedef typename helper_get_stm<res1, ret2>::ret ret; \ - }; \ - \ - \ - \ - \ - /* -------------------- */ \ - /* Checking algorithm. */ \ - /* -------------------- */ \ - \ - /* \ - * check_no_final_inherited \ - * \ - * FIXME: ... \ - */ \ - \ - template < typename orig, typename curr, typename target, \ - typename stm = typename get_stm<curr, target>::ret > \ - struct check_no_final_inherited \ - \ - : mlc::assert_< mlc_is_not_a(stm, stc::final), \ - ERROR::final_vtype_redefined_< orig, \ - mlc::pair_<curr, stm>, \ - target > \ - >, \ - /* rec */ check_no_final_inherited<orig, stc_super(curr), target> \ - { \ - }; \ - \ - template <typename orig, typename target, typename stm> \ - struct check_no_final_inherited <orig, /* if curr == */ mlc::none, target, stm> \ - { \ - }; \ - \ - \ - /* \ - * check_no_stm_inherited \ - * \ - * FIXME: ... \ - */ \ - \ - template < typename orig, typename curr, typename target, \ - typename stm = typename get_stm<curr, target>::ret > \ - struct check_no_stm_inherited \ - \ - : mlc::assert_< mlc::is_not_found_<stm>, \ - ERROR::vtype_declared_but_already_set_< orig, \ - mlc::pair_<curr, stm>, \ - target > \ - >, \ - /* rec */ check_no_stm_inherited<orig, stc_super(curr), target> \ - { \ - }; \ - \ - template <typename orig, typename target, typename stm> \ - struct check_no_stm_inherited <orig, /* if curr == */ mlc::none, target, stm> \ - { \ - }; \ - \ - \ - /* \ - * check_delegatee_inherited \ - */ \ - \ - template <typename curr, typename target> \ - struct check_delegatee_inherited \ - : mlc::assert_< mlc::is_found_< typename first_stm<curr, \ - typedef_::delegatee_type>::ret::second_elt >, \ - ERROR::no_delegatee_declared_ > \ - { \ - }; \ - \ - \ - /* \ - * check_final_stm \ - */ \ - \ - template <typename curr, typename target, typename stm> \ - struct check_final_stm \ - {}; \ - \ - template <typename curr, typename target> \ - struct check_final_stm < curr, target, stc::abstract > \ - : mlc::abort_< ERROR::wrong_final_stm_<curr, target, stc::final<stc::abstract> > > \ - {}; \ - \ - template <typename curr, typename target, typename T> \ - struct check_final_stm < curr, target, stc::final<T> > \ - : mlc::abort_< ERROR::wrong_final_stm_<curr, target, stc::final<stc::final<T> > > > \ - {}; \ - \ - template <typename curr, typename target> \ - struct check_final_stm < curr, target, stc::not_delegated > \ - : mlc::abort_< ERROR::wrong_final_stm_<curr, target, stc::final<stc::not_delegated> > > \ - {}; \ - \ - template <typename curr, typename target> \ - struct check_final_stm < curr, target, mlc::not_found > \ - : mlc::abort_< ERROR::wrong_final_stm_<curr, target, stc::final<mlc::not_found> > > \ - {}; \ - \ - \ - \ - \ - /* \ - * check(from, target) \ - * \ - * pseudo-code: \ - * \ - * check(from, target) \ - * { \ - * if (from == mlc::none) // stop because no more class \ - * return done; \ - * else \ - * return helper_check(from, target, get_stm(from, target)); \ - * } \ - */ \ - \ - struct dummy {}; \ - \ - template <typename target> \ - struct check < /* if from == */ mlc::none, target > \ - { \ - typedef dummy ret; \ - }; \ - \ - template <typename from, typename target> \ - struct check /* otherwise */ \ - { \ - typedef typename helper_check< from, target, \ - stc_stm(from, target) >::ret ret; \ - }; \ - \ - \ - \ - \ - /* \ - * pseudo-code: \ - * \ - * helper_check(curr, target, stm) \ - * { \ - * super = super(curr); \ - * \ - * if (stm == stc::abstract) { \ - * check_no_stm_inherited(curr, super, target); \ - * return check(super, target); \ - * } \ - * if (stm == stc::final<T>) { \ - * check_final_stm(T); \ - * check_no_final_inherited((curr, T), super, target); \ - * return check(super, target); \ - * } \ - * if (stm == stc::not_delegated) { \ - * check_delegatee_inherited(curr); \ - * check_no_final_inherited((curr, stc::not_delegated), super, target); \ - * return check(super, target); \ - * } \ - * if (stm == mlc::not_found) { \ - * return check(super, target); \ - * } \ - * // otherwise, non-final stm: \ - * if (stm == T) { \ - * check_no_final_inherited((curr, T), super, target); \ - * return check(super, target); \ - * } \ - * } \ - * \ - */ \ - \ - template <typename curr, typename target> \ - struct helper_check < curr, target, \ - /* if stm == */ stc::abstract > \ - : check_no_stm_inherited< mlc::pair_<curr, stc::abstract >, \ - stc_super(curr), \ - target > \ - { \ - typedef typename check<stc_super(curr), target>::ret ret; \ - }; \ - \ - template <typename curr, typename target, typename T> \ - struct helper_check < curr, target, \ - /* if stm == */ stc::final<T> > \ - : check_no_final_inherited< mlc::pair_<curr, stc::final<T> >, \ - stc_super(curr), \ - target > \ - { \ - /* FIXME: \ - check_final_stm(T); \ - */ \ - typedef typename check<stc_super(curr), target>::ret ret; \ - }; \ - \ - template <typename curr, typename target> \ - struct helper_check < curr, target, \ - /* if stm == */ stc::not_delegated > \ - : check_no_final_inherited< mlc::pair_<curr, stc::not_delegated>, \ - stc_super(curr), \ - target > \ - { \ - /* FIXME: \ - check_delegatee_inherited(curr); \ - */ \ - typedef typename check<stc_super(curr), target>::ret ret; \ - }; \ - \ - template <typename curr, typename target> \ - struct helper_check < curr, target, \ - /* if stm == */ mlc::not_found > \ - { \ - typedef typename check<stc_super(curr), target>::ret ret; \ - }; \ - \ - template <typename curr, typename target, typename stm> \ - struct helper_check /* otherwise, non-final stm */ \ - : check_no_final_inherited< mlc::pair_<curr, stm>, \ - stc_super(curr), \ - target > \ - { \ - typedef typename check<stc_super(curr), target>::ret ret; \ - }; \ - \ - \ - \ - /* ------------------- */ \ - /* Look-up algorithm. */ \ - /* ------------------- */ \ - \ - /* \ - * first_stm(from, target) \ - * \ - * returns a pair (Where, 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. \ - * \ - * \ - * helper_first_stm(curr, target, stm) \ - * { \ - * if (stm == mlc::not_found) \ - * return first_stm(super(curr), target); \ - * else if (stm == stc::final<T>) \ - * return pair(curr, T); \ - * else \ - * return pair(curr, stm); \ - * } \ - * \ - * first_stm(from, target) \ - * { \ - * if (from == mlc::none) \ - * return pair(mlc::none, mlc::not_found); \ - * else \ - * return helper_first_stm(from, target, \ - * get_stm(from, target)); \ - * } \ - * \ - */ \ - \ - template <typename curr, typename target> \ - struct helper_first_stm < curr, target, \ - /* if stm == */ mlc::not_found > \ - { \ - typedef typename first_stm<stc_super(curr), target>::ret ret; \ - }; \ - \ - template <typename curr, typename target, typename T> \ - struct helper_first_stm < curr, target, \ - /* if stm == */ stc::final<T> > \ - { \ - typedef mlc::pair_<curr, T> ret; \ - }; \ - \ - template <typename curr, typename target, typename stm> \ - struct helper_first_stm /* otherwise */ \ - { \ - typedef mlc::pair_<curr, stm> ret; \ - }; \ - \ - template <typename target> \ - struct first_stm < /* if from == */ mlc::none, target > \ - { \ - typedef mlc::pair_<mlc::none, mlc::not_found> ret; \ - }; \ - \ - template <typename from, typename target> \ - struct first_stm /* otherwise */ \ - { \ - typedef typename helper_first_stm<from, target, \ - stc_stm(from, target)>::ret ret; \ - }; \ - \ - \ - \ - /* \ - * superior_find(from, target) \ - * \ - * returns: \ - * either mlc::not_found \ - * or a type T \ - * behavior: \ - * - the stm stc::not_delegated is ignored \ - * - error when stc::abstract is reached \ - * \ - * helper_superior_find(from, target, curr, stm) \ - * { \ - * if (stm == stc::abstract) \ - * error("<target> declared in <curr> but not defined at <from>"); \ - * else if (stm == mlc::not_found or \ - * stm == stc::not_delegated) \ - * return superior_find(from, target, super(curr)); \ - * else if (stm == stc::final<T>) \ - * return T; \ - * else \ - * return stm; \ - * } \ - * \ - * superior_find(from, target, curr = from) \ - * { \ - * if (curr == mlc::none) \ - * return mlc::not_found; \ - * else \ - * return helper_superior_find(from, target, curr, \ - * get_stm(curr, target)); \ - * } \ - */ \ - \ - template <typename from, typename target, typename curr> \ - struct helper_superior_find < from, target, curr, \ - /* if stm == */ stc::abstract > \ - { \ - /* FIXME: error("<target> declared in <curr> but not defined at <from>"); */ \ - }; \ - \ - template <typename from, typename target, typename curr> \ - struct helper_superior_find < from, target, curr, \ - /* if stm == */ mlc::not_found > \ - { \ - typedef typename superior_find< from, target, \ - stc_super(curr) >::ret ret; \ - }; \ - \ - template <typename from, typename target, typename curr> \ - struct helper_superior_find < from, target, curr, \ - /* if stm == */ stc::not_delegated > \ - { \ - typedef typename superior_find< from, target, \ - stc_super(curr) >::ret ret; \ - }; \ - \ - template <typename from, typename target, typename curr, typename T> \ - struct helper_superior_find < from, target, curr, \ - /* if stm == */ stc::final<T> > \ - { \ - typedef T ret; \ - }; \ - \ - template <typename from, typename target, typename curr, typename stm> \ - struct helper_superior_find /* otherwise */ \ - { \ - typedef stm ret; \ - }; \ - \ - template <typename from, typename target> \ - struct superior_find < from, target, /* if curr == */ mlc::none > \ - { \ - typedef mlc::not_found ret; \ - }; \ - \ - template <typename from, typename target, typename curr> \ - struct superior_find /* otherwise */ \ - { \ - typedef typename helper_superior_find<from, target, curr, \ - stc_stm(curr, target)>::ret ret; \ - }; \ - \ - \ - \ - /* \ - * delegator_find(from, target) \ - * \ - * \ - * delegator_find(from, target) \ - * { \ - * precondition(target != delegatee_type); \ - * delegatee = superior_find(from, delegatee_type); \ - * if (delegatee == mlc::not_found) \ - * return mlc::not_found; \ - * else \ - * return find(delegatee, target); \ - * } \ - */ \ - \ - template <typename from, typename target> \ - struct helper_delegator_find < from, target, \ - /* if delegatee == */ mlc::not_found > \ - { \ - typedef mlc::not_found ret; \ - }; \ - \ - template <typename from, typename target, typename delegatee> \ - struct helper_delegator_find /* otherwise */ \ - { \ - typedef typename find<delegatee, target>::ret ret; \ - }; \ - \ - template <typename from, typename target> \ - struct delegator_find \ - { \ - typedef typename superior_find<from, typedef_::delegatee_type>::ret delegatee; \ - typedef typename helper_delegator_find<from, target, delegatee>::ret ret; \ - }; \ - \ - \ - \ - /* \ - * helper_find(from, target, where, res) \ - * \ - * \ - * \ - */ \ - \ - template <typename from, typename target, typename where> \ - struct helper_find < from, target, where, \ - /* 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, \ - /* if res == */ stc::abstract > \ - { \ - typedef typename delegator_find<from, target>::ret res_d; \ - struct check_ \ - : mlc::assert_< mlc::is_found_<res_d>, \ - ERROR::vtype_declared_but_not_defined \ - < ERROR::_for_vtype_<target>, \ - ERROR::_declaration_is_in_<where>, \ - ERROR::_definition_is_looked_up_from_<from> > > \ - /* FIXME: error("<target> declared in <where> 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, \ - /* if res == */ stc::not_delegated > \ - { \ - typedef typename superior_find<from, target>::ret ret; \ - }; \ - \ - template <typename from, typename target, typename where, typename res> \ - struct helper_find /* otherwise */ \ - { \ - typedef res ret; \ - }; \ - \ - \ - \ - /* \ - * find(from, target) \ - * \ - * FIXME: ... \ - * \ - * find(from, target) \ - * { \ - * if (target == delegatee_type) \ - * return superior_find(from, delegatee_type); \ - * else \ - * return helper_find(from, target); \ - * } \ - */ \ - \ - template <typename from> \ - struct find <from, /* if target == */ typedef_::delegatee_type > \ - { \ - typedef typename superior_find<from, typedef_::delegatee_type>::ret ret; \ - }; \ - \ - template <typename from, typename target> \ - struct find /* otherwise */ \ - { \ - typedef typename first_stm<from, target>::ret stm; \ - typedef mlc_elt(stm, 1) where; \ - typedef mlc_elt(stm, 2) res; \ - typedef typename helper_find<from, target, \ - where, res>::ret ret; \ - }; \ - \ - \ - } /* end of SCOOPED_NAMESPACE::internal */ \ - \ - \ - /* \ - * find_vtype(from, target) \ - * \ - * FIXME:... \ - * \ - */ \ - \ - template <typename from, typename target> \ - struct deferred_vtype \ - { \ - typedef typename internal::find<from, target>::ret ret; \ - }; \ - \ - template <typename from, typename target> \ - struct find_vtype \ - { \ - typedef typename internal::find<from, target>::ret ret; \ - typedef typename internal::check<from, target>::ret chk; \ - }; \ - \ - 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; \ - }; \ - \ - \ - \ - mlc_case_equipment_for_namespace(internal); \ - \ - mlc_decl_typedef(tag); \ - mlc_decl_typedef(category); \ - mlc_decl_typedef(exact_type); \ - \ - \ - namespace internal \ - { \ - \ - \ - template < template <class> class abstraction, \ - unsigned num = 1 > \ - struct selector \ - { \ - protected: selector() {} \ - }; \ - \ - \ - /* fwd decl */ \ - template < template <class> class abstraction, typename E, unsigned num > \ - struct plug_node; \ - \ - template < template <class> class abstraction, \ - typename E, \ - unsigned num, \ - typename another_selector = mlc::false_ > \ - struct next_plug_node \ - { \ - /* here: no other selector */ \ - protected: next_plug_node() {} \ - }; \ - \ - template < template <class> class abstraction, \ - typename E > \ - struct next_plug_node < abstraction, E, 1, mlc::false_ > \ - : public abstraction<E> \ - { \ - protected: next_plug_node() {} \ - }; \ - \ - \ - template < template <class> class abstraction, \ - typename E, \ - unsigned num > \ - struct next_plug_node < abstraction, \ - E, \ - num, \ - mlc::true_> \ - \ - : /* plug to client selectors */ \ - public virtual switch_< selector<abstraction, num>, E >::ret, \ - \ - /* here: another selector (number is 'num + 1') */ \ - public plug_node<abstraction, E, num + 1> \ - { \ - protected: next_plug_node() {} \ - }; \ - \ - \ - template < template <class> class abstraction, \ - typename E, \ - unsigned num > \ - struct plug_node \ - : public next_plug_node< abstraction, \ - E, \ - num, \ - typename mlc::is_defined_< case_< selector<abstraction, num>, \ - E, 1 > >::eval > \ - { \ - protected: plug_node() {} \ - }; \ - \ - \ - template < template <class> class abstraction, \ - unsigned num, \ - typename E > \ - struct default_case_ < selector<abstraction, num>, \ - E > \ - { \ - typedef abstraction<E> ret; \ - }; \ - \ - \ - template < template <class> class abstraction, \ - typename E > \ - struct plug : public plug_node<abstraction, E, 1> \ - { \ - protected: plug() {} \ - }; \ - \ - template <typename abstraction, typename E> \ - struct top; \ - \ - template <template<class> class abstraction, typename E> \ - struct top < stc::is<abstraction>, E > : public plug< abstraction, E > \ - { \ - protected: top() {} \ - }; \ - \ - template <typename E> \ - struct top < mlc::not_found, E > \ - { \ - protected: top() {} \ - }; \ - \ - \ - } /* end of namespace internal */ \ - \ - \ - \ - /* top class */ \ - \ - template <typename E> struct top; \ - \ - template <typename E> \ - struct vtypes< top<E> > \ - { \ - typedef mlc::none super_type; \ - typedef stc::abstract category; \ - typedef stc::final<E> exact_type; \ - }; \ - \ - template <typename E> \ - struct top : public internal::top< stc_find_type(E, category), E > \ - { \ - protected: \ - top() {} \ - }; \ - \ - \ - \ - /* concept class */ \ - \ - template <typename E> \ - struct Concept : public virtual stc::any<E> \ - { \ - protected: \ - Concept() {} \ - }; \ - \ - \ - namespace automatic \ - { \ - \ - template < template <class> class abstraction, typename E, typename tag = void > \ - struct impl \ - /* undefined */ ; \ - \ - template < template <class> class abstraction, typename E > \ - struct impl< abstraction, E, mlc::not_found > \ - { /* nothing */ }; \ - \ - template < template <class> class abstraction, typename E > \ - struct impl< abstraction, E, void > : impl< abstraction, E, stc_find_type(E, tag) > \ - { /* fetch impl w.r.t. tag */ }; \ - \ - } /* end of namespace automatic */ \ - \ - \ - \ -} /* end of SCOOPED_NAMESPACE */ \ - \ - \ -struct e_n_d__w_i_t_h___s_e_m_i_c_o_l_o_n; - - -/* - - -// -------------------------------------------- -// O L D B U N C H O F M A C R O S -// -------------------------------------------- - - - -# define stc_find_vtype_(Namespace, From, Target) \ - Namespace::find_vtype<From, Namespace::typedef_::Target##_type>::ret - -# define stc_find_vtype(Namespace, From, Target) \ - typename stc_find_vtype_(Namespace, From, Target) - - - -# define stc_deferred_vtype_(Namespace, From, Target) \ - Namespace::deferred_vtype<From, Namespace::typedef_::Target##_type>::ret - -# define stc_deferred_vtype(Namespace, From, Target) \ - typename stc_deferred_vtype_(Namespace, From, Target) - - - -# define stc_vtype_(Namespace, From, Target) \ - Namespace::vtype<From, Namespace::typedef_::Target##_type>::ret - -# define stc_vtype(Namespace, From, Target) \ - typename stc_vtype_(Namespace, From, Target) - - - -# define stc_find_deduce_vtype_(Namespace, From, Target1, Target2) \ - Namespace::find_vtype< Namespace::find_vtype<From, \ - Namespace::typedef_::Target1##_type>::ret, \ - Namespace::typedef_::Target2##_type>::ret - -# define stc_find_deduce_vtype(Namespace, From, Target1, Target2) \ - typename \ - Namespace::find_vtype< typename \ - Namespace::find_vtype<From, \ - Namespace::typedef_::Target1##_type>::ret, \ - Namespace::typedef_::Target2##_type>::ret - - - -# define stc_deduce_deferred_vtype(Namespace, From, Target1, Target2) \ - typename \ - Namespace::deferred_vtype< typename \ - Namespace::deferred_vtype<From, \ - Namespace::typedef_::Target1##_type>::ret, \ - Namespace::typedef_::Target2##_type>::ret \ - - - -# define stc_deduce_vtype_(Namespace, From, Target1, Target2) \ - Namespace::vtype< Namespace::vtype<From, \ - Namespace::typedef_::Target1##_type>::ret, \ - Namespace::typedef_::Target2##_type>::ret - -# define stc_deduce_vtype(Namespace, From, Target1, Target2) \ - typename \ - Namespace::vtype< typename \ - Namespace::vtype<From, \ - Namespace::typedef_::Target1##_type>::ret, \ - Namespace::typedef_::Target2##_type>::ret - - -// # define stc_vtype_is_found_(Namespace, From, Target) -// mlc::is_found_< Namespace::find_vtype<From, Namespace::typedef_::Target##_type>::ret > - - -// ---------------------------------------------------------- -// E N D O F O L D B U N C H O F M A C R O S -// ---------------------------------------------------------- - -*/ - - - - -# define stc_type_(From, Type) vtype<From, typedef_::Type>::ret -# define stc_type(From, Type) typename stc_type_(From, Type) - -# define stc_find_type(From, Type) typename find_vtype<From, typedef_::Type>::ret - - -// For concepts. -# define stc_typename(Type) typedef stc_type(Exact, Type) Type -# define stc_using(Type) typedef typename super::Type Type - - -// For impl classes. -# define stc_lookup(Type) typedef typename vtype< stc_type(current, exact_type), typedef_::Type>::ret Type - -// typedef stc_type(current, Type) Type - - -# define stc_prop(Name) mlc::eq_< stc_find_type(E, Name), mlc::true_ > - - -// sugar: - -# define stc_Header \ - \ -templ class classname ; /* fwd decl */ \ - \ -templ struct vtypes< current > /* vtypes */ \ -{ \ - typedef super super_type \ - -# define stc_End } - - - -#endif // ! STC_SCOOP2_HH Index: doc/tiny/cpp_with_virtual_types/main.cc =================================================================== --- doc/tiny/cpp_with_virtual_types/main.cc (revision 734) +++ doc/tiny/cpp_with_virtual_types/main.cc (working copy) @@ -1,4 +1,36 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory. +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/* \file doc/tiny/cpp_with_virtual_types/main.cc + + \brief Tiny sample use in pseudo-C++ (C++ with virtual types). */ + + namespace abc { Index: doc/tiny/design/main.cc =================================================================== --- doc/tiny/design/main.cc (revision 734) +++ doc/tiny/design/main.cc (working copy) @@ -1,4 +1,35 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory. +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/* \file doc/tiny/design/main.cc + + \brief Tiny sample use in a pseudo-language. */ + namespace abc { @@ -14,6 +45,8 @@ array_iterator : [T: type] -> class = { + category : type = Iterator; + value : type = T next : () -> void = { i_ := i_ + 1 } is_valid : const () -> bool = { return i_ >= 0 and i_ < n_ } Index: doc/tiny/local/scoop.hh =================================================================== --- doc/tiny/local/scoop.hh (revision 0) +++ doc/tiny/local/scoop.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,14 +25,12 @@ // reasons why the executable file might be covered by the GNU General // Public License. -/* \file stc/scoop2.hh +/* \file doc/tiny/local/scoop.hh - \brief Equipment for SCOOP2: notably, Virtual types (also known as - ``properties'') mechanism. -*/ + \brief Equipment for SCOOP 2 which mimics the file stc/scoop2.hh. */ -#ifndef STC_SCOOP2_HH -# define STC_SCOOP2_HH +#ifndef STC_DOC_TINY_LOCAL_SCOOP_HH +# define STC_DOC_TINY_LOCAL_SCOOP_HH # include <mlc/flags.hh> # include <mlc/typedef.hh> @@ -64,10 +62,15 @@ template < template <class> class > struct is; + typedef mlc::bexpr_<true> true_; + typedef mlc::bexpr_<false> false_; + } // end of namespace stc +#define stc_decl_associated_type mlc_decl_typedef + #define stc_super(T) typename vtypes< T >::super_type #define stc_stm(From, Target) typename get_stm< From , Target >::ret @@ -1034,7 +1037,7 @@ // typedef stc_type(current, Type) Type -# define stc_prop(Name) mlc::eq_< stc_find_type(E, Name), mlc::true_ > +# define stc_prop(Name) stc_find_type(E, Name) // sugar: @@ -1051,4 +1054,4 @@ -#endif // ! STC_SCOOP2_HH +#endif // ! STC_DOC_TINY_LOCAL_SCOOP_HH Index: doc/tiny/local/undefs.hh =================================================================== --- doc/tiny/local/undefs.hh (revision 0) +++ doc/tiny/local/undefs.hh (working copy) @@ -1,4 +1,36 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory. +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/* \file doc/tiny/local/undefs.hh + + \brief Utility file for tiny sample uses of SCOOP 2. */ + + #undef current #undef super #undef templ Index: doc/tiny/cpp_with_concepts/main.cc =================================================================== --- doc/tiny/cpp_with_concepts/main.cc (revision 734) +++ doc/tiny/cpp_with_concepts/main.cc (working copy) @@ -1,4 +1,36 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory. +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/* \file doc/tiny/cpp_with_concepts/main.cc + + \brief Tiny sample use with C++Ox; it should compile with ConceptGCC. */ + + #include <iostream> Index: doc/tiny/classical/main.cc =================================================================== --- doc/tiny/classical/main.cc (revision 734) +++ doc/tiny/classical/main.cc (working copy) @@ -1,4 +1,36 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory. +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/* \file doc/tiny/classical/main.cc + + \brief Tiny sample use in classical OOP. */ + + namespace abc { Index: doc/tiny/generic_programming/main.cc =================================================================== --- doc/tiny/generic_programming/main.cc (revision 734) +++ doc/tiny/generic_programming/main.cc (working copy) @@ -1,4 +1,35 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory. +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/* \file doc/tiny/generic_programming/main.cc + + \brief Tiny sample use in (simple) C++ generic programming. */ + namespace abc {