
https://svn.lrde.epita.fr/svn/oln/trunk/static Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Adjust samples to the new interface of Static. * samples/mini-std/cpp/equipment.hh: No longer use stc_scoop_equipment_for_namespace. Include stc/scoop.hxx instead. Rename template parameters `E' to `Exact'. (stc_using, stc_using_from): Remove macros. * samples/mini-std/cpp/impl.hh: (morpher_container, primary_container): Adjust callers of stc_using_from. (morpher_container::delegatee): Rename methods as... (morpher_container::delegatee_): ...these. Adjust callers. * samples/mini-std/cpp/stack.hh, * samples/mini-std/cpp/value_cast.hh (impl_delegatee): Rename methods as... (impl_delegatee_): ...these. * samples/mini-std/cpp/concepts.hh, * samples/mini-std/cpp/impl.hh, * samples/mini-std/cpp/list.hh, * samples/mini-std/cpp/vector.hh, * samples/mini-std/cpp/deque.hh, * samples/mini-std/cpp/stack.hh, * samples/mini-std/cpp/value_cast.hh, * samples/mini-std/cpp/identity.hh, * samples/mini-std/cpp/fwddecls.hh Remove the `_type' suffix from all virtual types. Remove virtual types named `super_type' and replace them with a `super_trait_' class. Rename template parameters `E' to `Exact'. * samples/mini-oln/mini-oln.cc: Likewise. s/set_super_type/super_trait_/. * samples/mini-std/cpp2/mini-std.cc (LOGGER_BEGIN, LOGMETHODVOID, LOGMETHODARG, LOGGER_END): Wrap long lines in macros. (LOGMETHOD): Likewise. Add a space after the printed location. * samples/mini-std/Makefile.am, * samples/mini-std/cpp/Makefile.am: New. * samples/mini-std/cpp2/Makefile: Rename as... * samples/mini-std/cpp2/Makefile.am: ...this. (CPPFLAGS, .PHONY): Remove variables. (all, mini-std): Remove targets. (AM_CPPFLAGS, TESTS_CXXFLAGS, AM_CXXFLAGS) (check_PROGRAMS, mini_std_SOURCES, TESTS): New variables. * samples/Makefile.am (SUBDIRS): Add mini-std. Makefile.am | 2 mini-oln/mini-oln.cc | 214 +++++++++++++++++++++++---------------------- mini-std/Makefile.am | 5 + mini-std/README | 2 mini-std/cpp/Makefile.am | 22 ++++ mini-std/cpp/concepts.hh | 104 ++++++++++----------- mini-std/cpp/deque.hh | 11 +- mini-std/cpp/equipment.hh | 31 +++--- mini-std/cpp/fwddecls.hh | 42 ++++---- mini-std/cpp/identity.hh | 92 +++++++++---------- mini-std/cpp/impl.hh | 129 +++++++++++++++------------ mini-std/cpp/list.hh | 9 + mini-std/cpp/stack.hh | 18 ++- mini-std/cpp/value_cast.hh | 17 ++- mini-std/cpp/vector.hh | 9 + mini-std/cpp2/Makefile.am | 19 +++ 16 files changed, 405 insertions(+), 321 deletions(-) Index: samples/mini-oln/mini-oln.cc --- samples/mini-oln/mini-oln.cc (revision 1031) +++ samples/mini-oln/mini-oln.cc (working copy) @@ -41,26 +41,25 @@ // Helper macros. #define oln_type_of_(FromType, Alias) \ - find_vtype<FromType, oln::typedef_:: Alias##_type>::ret + find_vtype<FromType, oln::typedef_:: Alias>::ret #define oln_type_of(FromType, Alias) \ typename oln_type_of_(FromType, Alias) -// Add equipment -stc_scoop_equipment_for_namespace(oln) +// Add equipment. mlc_case_equipment_for_namespace(oln); // Virtual types declaration. namespace oln { - mlc_decl_typedef(point_type); - mlc_decl_typedef(iter_type); - mlc_decl_typedef(value_type); - mlc_decl_typedef(rvalue_type); - mlc_decl_typedef(lvalue_type); + mlc_decl_typedef(point); + mlc_decl_typedef(iter); + mlc_decl_typedef(value); + mlc_decl_typedef(rvalue); + mlc_decl_typedef(lvalue); - mlc_decl_typedef(nbh_type); - mlc_decl_typedef(niter_type); + mlc_decl_typedef(nbh); + mlc_decl_typedef(niter); } @@ -70,12 +69,20 @@ namespace oln { + + // --------------------- // + // Namespace equipment. // + // --------------------- // + +#include <stc/scoop.hxx> + + // ------- // // Point. // // ------- // - template <typename E> - struct Point : public stc::any<E> + template <typename Exact> + struct Point : public stc::any<Exact> { }; @@ -84,10 +91,10 @@ // Iterator. // // ---------- // - template <typename E> - struct Iterator : public stc::any<E> + template <typename Exact> + struct Iterator : public stc::any<Exact> { - typedef oln_type_of(E, point) point_t; + typedef oln_type_of(Exact, point) point_t; void start() { @@ -116,11 +123,11 @@ // Image. // // ------- // - template <typename E> - struct Image : public stc::any<E> + template <typename Exact> + struct Image : public stc::any<Exact> { - typedef oln_type_of(E, point) point_t; - typedef oln_type_of(E, rvalue) rvalue_t; + typedef oln_type_of(Exact, point) point_t; + typedef oln_type_of(Exact, rvalue) rvalue_t; rvalue_t operator ()(point_t& p) const { @@ -138,14 +145,14 @@ // Image2d. // // --------- // - template <typename E> - struct Image2d : public virtual Image<E> + template <typename Exact> + struct Image2d : public virtual Image<Exact> { - typedef oln_type_of(E, point) point_t; + typedef oln_type_of(Exact, point) point_t; // inherited from Image - // typedef oln_type_of(E, rvalue) rvalue_t; + // typedef oln_type_of(Exact, rvalue) rvalue_t; // rvalue_t& operator ()(point_t& p) // { @@ -168,14 +175,14 @@ // Image3d. // // --------- // - template <typename E> - struct Image3d : public virtual Image<E> + template <typename Exact> + struct Image3d : public virtual Image<Exact> { - typedef oln_type_of(E, point) point_t; + typedef oln_type_of(Exact, point) point_t; // inherited from Image - // typedef oln_type_of(E, rvalue) rvalue_t; + // typedef oln_type_of(Exact, rvalue) rvalue_t; // rvalue_t& operator ()(point_t& p) // { @@ -203,11 +210,11 @@ // Mutable_Image // // ------------- // - template <typename E> - struct Mutable_Image : public virtual Image<E> + template <typename Exact> + struct Mutable_Image : public virtual Image<Exact> { - typedef oln_type_of(E, point) point_t; - typedef oln_type_of(E, lvalue) lvalue_t; + typedef oln_type_of(Exact, point) point_t; + typedef oln_type_of(Exact, lvalue) lvalue_t; lvalue_t operator ()(point_t& p) { @@ -220,11 +227,11 @@ // Image_with_neighborhood. // // ------------------------- // - template <typename E> - struct Image_with_neighborhood : public virtual Image<E> + template <typename Exact> + struct Image_with_neighborhood : public virtual Image<Exact> { - typedef oln_type_of(E, nbh) nbh_t; - typedef oln_type_of(E, niter) niter_t; + typedef oln_type_of(Exact, nbh) nbh_t; + typedef oln_type_of(Exact, niter) niter_t; nbh_t nbh() const { @@ -252,24 +259,24 @@ struct point2d; struct point3d; - template <typename E> - struct case_<switch_image_base, E, 1> : - public mlc::where_ < mlc::eq_ <oln_type_of(E, point), point2d> > + template <typename Exact> + struct case_<switch_image_base, Exact, 1> : + public mlc::where_ < mlc::eq_ <oln_type_of(Exact, point), point2d> > { - typedef Image2d<E> ret; + typedef Image2d<Exact> ret; }; - template <typename E> - struct case_<switch_image_base, E, 2> : - public mlc::where_ < mlc::eq_ <oln_type_of(E, point), point3d> > + template <typename Exact> + struct case_<switch_image_base, Exact, 2> : + public mlc::where_ < mlc::eq_ <oln_type_of(Exact, point), point3d> > { - typedef Image3d<E> ret; + typedef Image3d<Exact> ret; }; - template <typename E> - struct default_case_<switch_image_base, E> + template <typename Exact> + struct default_case_<switch_image_base, Exact> { - typedef Image<E> ret; + typedef Image<Exact> ret; }; // ----------------- // @@ -279,17 +286,17 @@ // Tag. struct switch_image_base_mutable; - template <typename E> - struct case_<switch_image_base_mutable, E, 1> : - public mlc::where_ < mlc::is_found_< stc_vtype(oln, E, lvalue) > > + template <typename Exact> + struct case_<switch_image_base_mutable, Exact, 1> : + public mlc::where_ < stc_type_is_found(lvalue) > { - typedef Mutable_Image<E> ret; + typedef Mutable_Image<Exact> ret; }; - template <typename E> - struct default_case_<switch_image_base_mutable, E> + template <typename Exact> + struct default_case_<switch_image_base_mutable, Exact> { - typedef Image<E> ret; + typedef Image<Exact> ret; }; // ------------ // @@ -297,30 +304,31 @@ // ------------ // // Forward declaration. - template <typename E> struct image_base; + template <typename Exact> struct image_base; - template<typename E> - struct set_super_type< image_base<E> > + template<typename Exact> + struct super_trait_< image_base<Exact> > { typedef mlc::none ret; }; - template <typename E> - struct vtypes< image_base<E> > + template <typename Exact> + struct vtypes< image_base<Exact> > { - typedef stc::abstract point_type; - typedef stc::abstract iter_type; - typedef stc::abstract value_type; - typedef stc::abstract rvalue_type; - typedef stc::abstract lvalue_type; - - typedef mlc::none niter_type; - typedef mlc::none nbh_type; - }; - - template <typename E> - struct image_base : public virtual switch_<switch_image_base, E>::ret, - public virtual switch_<switch_image_base_mutable, E>::ret + typedef stc::abstract point; + typedef stc::abstract iter; + typedef stc::abstract value; + typedef stc::abstract rvalue; + typedef stc::abstract lvalue; + + typedef mlc::none niter; + typedef mlc::none nbh; + }; + + template <typename Exact> + struct image_base : + public virtual switch_<switch_image_base, Exact>::ret, + public virtual switch_<switch_image_base_mutable, Exact>::ret { image_base() { @@ -363,7 +371,7 @@ template <typename T> struct image2d; template<> - struct set_super_type<iterator2d> + struct super_trait_<iterator2d> { typedef mlc::none ret; }; @@ -371,7 +379,7 @@ template <> struct vtypes<iterator2d> { - typedef point2d point_type; + typedef point2d point; }; struct iterator2d : public Iterator<iterator2d> @@ -427,7 +435,7 @@ template <typename T> struct image2d; template<typename T> - struct set_super_type< image2d<T> > + struct super_trait_< image2d<T> > { typedef image_base< image2d<T> > ret; }; @@ -435,11 +443,11 @@ template <typename T> struct vtypes< image2d<T> > { - typedef point2d point_type; - typedef iterator2d iter_type; - typedef T value_type; - typedef value_type rvalue_type; - typedef value_type& lvalue_type; + typedef point2d point; + typedef iterator2d iter; + typedef T value; + typedef value rvalue; + typedef value& lvalue; }; template <typename T> @@ -499,7 +507,7 @@ struct neighborhood2d { - typedef niter2d niter_type; + typedef niter2d niter; }; @@ -512,7 +520,7 @@ template <typename T> struct image3d; template<> - struct set_super_type<iterator3d> + struct super_trait_<iterator3d> { typedef mlc::none ret; }; @@ -520,7 +528,7 @@ template <> struct vtypes<iterator3d> { - typedef point3d point_type; + typedef point3d point; }; struct iterator3d : public Iterator<iterator3d> @@ -584,7 +592,7 @@ template <typename T> struct image3d; template<typename T> - struct set_super_type< image3d<T> > + struct super_trait_< image3d<T> > { typedef image_base< image3d<T> > ret; }; @@ -592,11 +600,11 @@ template <typename T> struct vtypes< image3d<T> > { - typedef point3d point_type; - typedef iterator3d iter_type; - typedef T value_type; - typedef value_type rvalue_type; - typedef value_type& lvalue_type; + typedef point3d point; + typedef iterator3d iter; + typedef T value; + typedef value rvalue; + typedef value& lvalue; }; template <typename T> @@ -665,7 +673,7 @@ struct neighborhood3d { - typedef niter3d niter_type; + typedef niter3d niter; }; @@ -674,24 +682,24 @@ // --------------- // // Forward declaration. - template <typename E> struct image_morpher; + template <typename Exact> struct image_morpher; - template<typename E> - struct set_super_type< image_morpher<E> > + template<typename Exact> + struct super_trait_< image_morpher<Exact> > { - typedef image_base<E> ret; + typedef image_base<Exact> ret; }; - template <typename E> - struct vtypes< image_morpher<E> > + template <typename Exact> + struct vtypes< image_morpher<Exact> > { - typedef stc::abstract delegatee_type; + typedef stc::abstract delegatee; }; - template <typename E> - struct image_morpher : public image_base<E> + template <typename Exact> + struct image_morpher : public image_base<Exact> { - typedef oln_type_of(E, delegatee) delegatee_t; + typedef oln_type_of(Exact, delegatee) delegatee_t; image_morpher(delegatee_t& ref_ima) : ref_ima (ref_ima) @@ -715,7 +723,7 @@ template <typename I, typename N> struct plus; template <typename I, typename N> - struct set_super_type< plus<I, N> > + struct super_trait_< plus<I, N> > { typedef image_morpher< plus <I, N> > ret; }; @@ -723,12 +731,12 @@ template <typename I, typename N> struct vtypes< plus<I, N> > { - typedef I delegatee_type; - typedef N nbh_type; + typedef I delegatee; + typedef N nbh; // For the sake of simplicity, the niter type is obtained directly // from the neighborhood type itself (without using a virtual // type). - typedef typename N::niter_type niter_type; + typedef typename N::niter niter; }; template <typename I, typename N> Index: samples/mini-std/cpp/impl.hh --- samples/mini-std/cpp/impl.hh (revision 1031) +++ samples/mini-std/cpp/impl.hh (working copy) @@ -14,25 +14,25 @@ { // 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> {}; + template <typename b, typename Exact> struct front_insertion_sequence; + template <typename Exact> struct front_insertion_sequence <mlc::true_, Exact> : virtual Front_Insertion_Sequence<Exact> {}; + template <typename Exact> struct front_insertion_sequence <mlc::false_, Exact> : virtual Sequence<Exact> {}; // 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> {}; + template <typename b, typename Exact> struct back_insertion_sequence; + template <typename Exact> struct back_insertion_sequence <mlc::true_, Exact> : virtual Back_Insertion_Sequence<Exact> {}; + template <typename Exact> struct back_insertion_sequence <mlc::false_, Exact> : virtual Sequence<Exact> {}; // 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 b, typename Exact> struct random_access_container; + template <typename Exact> struct random_access_container <mlc::true_, Exact> : virtual Random_Access_Container<Exact> {}; + template <typename Exact> struct random_access_container <mlc::false_, Exact> : virtual Container<Exact> {}; - template <typename E> + template <typename Exact> 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 > + : front_insertion_sequence< abc_vtype(Exact, has_front_insertion), Exact >, + back_insertion_sequence < abc_vtype(Exact, has_back_insertion), Exact >, + random_access_container < abc_vtype(Exact, has_random_access), Exact > { protected: container_switch() {} @@ -55,15 +55,19 @@ - // Class container_base<E>. + // Class container_base<Exact>. - template <typename E> class container_base; + template <typename Exact> class container_base; - template <typename E> - struct vtypes< container_base<E> > + template <typename Exact> + struct super_trait_< container_base<Exact> > { - typedef mlc::none super_type; + typedef mlc::none ret; + }; + template <typename Exact> + struct vtypes< container_base<Exact> > + { typedef stc::abstract value_type; typedef stc::abstract iterator; typedef stc::abstract const_iterator; @@ -78,39 +82,48 @@ typedef stc::abstract tag; }; - template <typename E> - class container_base : public internal::container_switch<E> + template <typename Exact> + class container_base : public internal::container_switch<Exact> { public: // FIXME: remove below. - typedef typename Back_Insertion_Sequence<E>::reference reference; - typedef typename Back_Insertion_Sequence<E>::const_reference const_reference; + typedef typename Back_Insertion_Sequence<Exact>::reference reference; + typedef typename Back_Insertion_Sequence<Exact>::const_reference const_reference; protected: container_base() {} }; - // Class morpher_container<E>. + // Class morpher_container<Exact>. + + template <typename Exact> class morpher_container; - template <typename E> class morpher_container; - template <typename E> - struct vtypes< morpher_container<E> > + template <typename Exact> + struct super_trait_< morpher_container<Exact> > + { + typedef container_base<Exact> ret; + }; + + template <typename Exact> + struct vtypes< morpher_container<Exact> > { - typedef container_base<E> super_type; - typedef stc::abstract delegatee_type; + typedef stc::abstract delegatee; }; - template <typename E> - class morpher_container : public container_base<E> + template <typename Exact> + class morpher_container : public container_base<Exact> { public: - stc_using_from(Container<E>, value_type); - abc_typename(delegatee_type); + stc_using_from(Container, value_type); + abc_typename(delegatee); - const delegatee_type& delegatee() const { return this->exact().impl_delegatee(); } - delegatee_type& delegatee() { return this->exact().impl_delegatee(); } + // FIXME: `delegatee_' and `impl_delegatee_' are not elegant + // names, but we cannot use `delegatee' (since it is a typedef in + // this class). Find better names. + const delegatee& delegatee_() const { return this->exact().impl_delegatee_(); } + delegatee& delegatee_() { return this->exact().impl_delegatee_(); } protected: morpher_container() {} @@ -118,36 +131,46 @@ - // Class primary_container<E>. + // Class primary_container<Exact>. - template <typename E> class primary_container; + template <typename Exact> class primary_container; - template <typename E> - struct vtypes< primary_container<E> > + template <typename Exact> + struct super_trait_< primary_container<Exact> > + { + typedef container_base<Exact> ret; + }; + + template <typename Exact> + struct vtypes< primary_container<Exact> > { - typedef container_base<E> super_type; typedef mlc::none tag; }; - template <typename E> - class primary_container : public container_base<E> + template <typename Exact> + class primary_container : public container_base<Exact> { public: - stc_using_from(Container<E>, value_type); + stc_using_from(Container, value_type); protected: primary_container() {} }; - // Class primary_std_container<E>. + // Class primary_std_container<Exact>. - template <typename E> class primary_std_container; + template <typename Exact> class primary_std_container; + + template <typename Exact> + struct super_trait_< primary_std_container<Exact> > + { + typedef primary_container<Exact> ret; + }; - template <typename E> - struct vtypes< primary_std_container<E> > + template <typename Exact> + struct vtypes< primary_std_container<Exact> > { - typedef primary_container<E> super_type; typedef stc::abstract std_type; typedef stc_defer(std_type) container_t; @@ -159,11 +182,11 @@ typedef stc::final<typename container_t::size_type> size_type; }; - template <typename E> - class primary_std_container : public primary_container<E> + template <typename Exact> + class primary_std_container : public primary_container<Exact> { public: - typedef primary_container<E> super; + typedef primary_container<Exact> super; stc_using(iterator); stc_using(const_iterator); @@ -179,8 +202,8 @@ 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_; } + bool impl_equal(const Exact& rhs) const { return data_ == rhs.data_; } + bool impl_less (const Exact& rhs) const { return data_ < rhs.data_; } protected: @@ -189,7 +212,7 @@ 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_; + abc_vtype(Exact, std_type) data_; }; Index: samples/mini-std/cpp/vector.hh --- samples/mini-std/cpp/vector.hh (revision 1031) +++ samples/mini-std/cpp/vector.hh (working copy) @@ -11,13 +11,16 @@ template <typename T> class vector; + template <typename T> + struct super_trait_< vector<T> > + { + typedef vector<T> self__; + typedef primary_std_container<self__> ret; + }; 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: Index: samples/mini-std/cpp/deque.hh --- samples/mini-std/cpp/deque.hh (revision 1031) +++ samples/mini-std/cpp/deque.hh (working copy) @@ -8,17 +8,18 @@ namespace abc { - template <typename T> class deque; - + typename <template T> + struct super_trait_< deque<T> > + { + typedef deque<T> self__; + typedef primary_std_container<self__> ret; + }; 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: Index: samples/mini-std/cpp/stack.hh --- samples/mini-std/cpp/stack.hh (revision 1031) +++ samples/mini-std/cpp/stack.hh (working copy) @@ -10,15 +10,17 @@ template <typename T, typename S> class stack; - + template <typename T, S> + struct super_trait_< list<T, S> > + { + typedef stack<T, S> self__; + typedef morpher_container<self__> ret; + }; 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; + typedef S delegatee; // Properties. typedef mlc::false_ has_front_insertion; @@ -39,7 +41,7 @@ stc_using(reference); stc_using(value_type); - stc_using(delegatee_type); + stc_using(delegatee); // Renaming. reference top() @@ -57,8 +59,8 @@ this->pop_back(); } - const delegatee_type& impl_delegatee() const { return this->seq_; } - delegatee_type& impl_delegatee() { return this->seq_; } + const delegatee& impl_delegatee_() const { return this->seq_; } + delegatee& impl_delegatee_() { return this->seq_; } protected: S seq_; Index: samples/mini-std/cpp/value_cast.hh --- samples/mini-std/cpp/value_cast.hh (revision 1031) +++ samples/mini-std/cpp/value_cast.hh (working copy) @@ -11,14 +11,17 @@ template <typename T, typename C> class value_cast_; + template <typename T, C> + struct super_trait_< value_cast_<T, C> > + { + typedef value_cast_<T, C> self__; + typedef morpher_container<self__> super_type; + }; 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 C delegatee; typedef T value_type; typedef T& reference; @@ -36,15 +39,15 @@ typedef value_cast_<T,C> self_type; typedef morpher_container<self_type> super; - stc_using(delegatee_type); + stc_using(delegatee); value_cast_(Container<C>& con) : con_(con.exact()) { } - const delegatee_type& impl_delegatee() const { return this->con_; } - delegatee_type& impl_delegatee() { return this->con_; } + const delegatee& impl_delegatee_() const { return this->con_; } + delegatee& impl_delegatee_() { return this->con_; } protected: C& con_; Index: samples/mini-std/cpp/equipment.hh --- samples/mini-std/cpp/equipment.hh (revision 1031) +++ samples/mini-std/cpp/equipment.hh (working copy) @@ -6,33 +6,32 @@ # 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 abc_typename(Vtype) typedef abc_vtype(Exact, 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_defer(Target) \ + typename abc::deferred_vtype<Exact, abc::typedef_::Target>::ret # define stc_introducing(Vtype) typedef abc_vtype(self_type, Vtype) Vtype -// stc_deferred_vtype(test, E, dim) +// stc_deferred_vtype(test, Exact, dim) namespace abc { - /// \{ +// Namespace equipment. +#include <stc/scoop.hxx> + + /// Typedef declarations. + /// \{ // From std. mlc_decl_typedef(value_type); @@ -64,17 +63,19 @@ namespace automatic { - template < template <class> class abstraction, typename E, typename tag = void > + template < template <class> class abstraction, + typename Exact, typename tag = void > struct impl; - template < template <class> class abstraction, typename E > - struct impl< abstraction, E, mlc::none > + template < template <class> class abstraction, typename Exact > + struct impl< abstraction, Exact, mlc::none > { // none means nothing! }; - template < template <class> class abstraction, typename E > - struct impl< abstraction, E, void > : impl< abstraction, E, abc_vtype(E, tag) > + template < template <class> class abstraction, typename Exact > + struct impl< abstraction, Exact, void > + : impl< abstraction, Exact, abc_vtype(Exact, tag) > { // fetch impl w.r.t. tag }; Index: samples/mini-std/cpp/identity.hh --- samples/mini-std/cpp/identity.hh (revision 1031) +++ samples/mini-std/cpp/identity.hh (working copy) @@ -19,8 +19,8 @@ // FIXME: Hack! (to be removed) - template < template <class> class abstraction, typename E > - struct impl< abstraction, E, tag::identity > + template < template <class> class abstraction, typename Exact > + struct impl< abstraction, Exact, tag::identity > { // ... }; @@ -29,10 +29,10 @@ // Container - template <typename E> - class impl< Container, E, tag::identity > + template <typename Exact> + class impl< Container, Exact, tag::identity > : - public virtual stc::any__simple<E> + public virtual stc::any__simple<Exact> { protected: abc_typename(value_type); @@ -40,117 +40,117 @@ 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(); } + 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 > + template <typename Exact> + class impl< Forward_Container, Exact, tag::identity > : - public virtual stc::any__simple<E> + public virtual stc::any__simple<Exact> { protected: - typedef Forward_Container<E> self_type; + typedef Forward_Container<Exact> 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); } + 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 > + template <typename Exact> + class impl< Reversible_Container, Exact, tag::identity > : - public virtual stc::any__simple<E> + public virtual stc::any__simple<Exact> { 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(); } + 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 > + template <typename Exact> + class impl< Random_Access_Container, Exact, tag::identity > : - public virtual stc::any__simple<E> + public virtual stc::any__simple<Exact> { 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]; } + 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 > + template <typename Exact> + class impl< Sequence, Exact, tag::identity > : - public virtual stc::any__simple<E> + public virtual stc::any__simple<Exact> { 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); } + 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 > + template <typename Exact> + class impl< Front_Insertion_Sequence, Exact, tag::identity > : - public virtual stc::any__simple<E> + public virtual stc::any__simple<Exact> { 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(); } + 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 > + template <typename Exact> + class impl< Back_Insertion_Sequence, Exact, tag::identity > : - public virtual stc::any__simple<E> + public virtual stc::any__simple<Exact> { 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(); } + 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(); } }; Index: samples/mini-std/cpp/fwddecls.hh --- samples/mini-std/cpp/fwddecls.hh (revision 1031) +++ samples/mini-std/cpp/fwddecls.hh (working copy) @@ -16,10 +16,10 @@ // | +-- 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; + template <typename Exact> class Container; + template <typename Exact> class Forward_Container; + template <typename Exact> class Reversible_Container; + template <typename Exact> class Random_Access_Container; // | // +-- Sequence @@ -29,9 +29,9 @@ // | +-- Back_Insertion_Sequence // | - template <typename E> class Sequence; - template <typename E> class Front_Insertion_Sequence; - template <typename E> class Back_Insertion_Sequence; + template <typename Exact> class Sequence; + template <typename Exact> class Front_Insertion_Sequence; + template <typename Exact> class Back_Insertion_Sequence; // | // +-- Associative_Container @@ -45,13 +45,13 @@ // +-- 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; + template <typename Exact> class Associative_Container; + template <typename Exact> class Simple_Associative_Container; + template <typename Exact> class Pair_Associative_Container; + template <typename Exact> class Sorted_Associative_Container; + template <typename Exact> class Hashed_Associative_Container; + template <typename Exact> class Unique_Associative_Container; + template <typename Exact> class Multiple_Associative_Container; @@ -69,13 +69,13 @@ // | // +-- 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; + template <typename Exact> class Iterator; + template <typename Exact> class Trivial_Iterator; + template <typename Exact> class Input_Iterator; + template <typename Exact> class Output_Iterator; + template <typename Exact> class Forward_Iterator; + template <typename Exact> class Bidirectional_Iterator; + template <typename Exact> class Random_Access_Iterator; } // end of namespace abc Index: samples/mini-std/cpp/list.hh --- samples/mini-std/cpp/list.hh (revision 1031) +++ samples/mini-std/cpp/list.hh (working copy) @@ -11,13 +11,16 @@ template <typename T> class list; + typename <template T> + struct super_trait_< list<T> > + { + typedef list<T> self__; + typedef primary_std_container<self__> ret; + }; 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: Index: samples/mini-std/cpp/Makefile.am --- samples/mini-std/cpp/Makefile.am (revision 0) +++ samples/mini-std/cpp/Makefile.am (revision 0) @@ -0,0 +1,22 @@ +## 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) + + +noinst_HEADERS = \ + algorithm.hh concepts.hh deque.hh equipment.hh fwddecls.hh \ + identity.hh impl.hh list.hh stack.hh value_cast.hh vector.hh + +check_PROGRAMS = test +test_SOURCES = main.cc + +TESTS = $(check_PROGRAMS) Index: samples/mini-std/cpp/concepts.hh --- samples/mini-std/cpp/concepts.hh (revision 1031) +++ samples/mini-std/cpp/concepts.hh (working copy) @@ -9,9 +9,9 @@ // Container - template <typename E> - class Container : public virtual stc::any__simple<E>, - public automatic::impl<Container, E> + template <typename Exact> + class Container : public virtual stc::any__simple<Exact>, + public automatic::impl<Container, Exact> { public: @@ -39,13 +39,13 @@ // Forward_Container - template <typename E> - class Forward_Container : public virtual Container<E>, - public automatic::impl<Forward_Container, E> + template <typename Exact> + class Forward_Container : public virtual Container<Exact>, + public automatic::impl<Forward_Container, Exact> { public: - typedef Forward_Container<E> self_type; + typedef Forward_Container<Exact> self_type; // Methods. bool operator==(const self_type& rhs) const { return this->exact().impl_equal(rhs.exact()); } @@ -65,9 +65,9 @@ // Reversible_Container - template <typename E> - class Reversible_Container : public virtual Forward_Container<E>, - public automatic::impl<Reversible_Container, E> + template <typename Exact> + class Reversible_Container : public virtual Forward_Container<Exact>, + public automatic::impl<Reversible_Container, Exact> { public: @@ -89,13 +89,13 @@ // Random_Access_Container - template <typename E> - class Random_Access_Container : public virtual Reversible_Container<E>, - public automatic::impl<Random_Access_Container, E> + template <typename Exact> + class Random_Access_Container : public virtual Reversible_Container<Exact>, + public automatic::impl<Random_Access_Container, Exact> { public: - typedef Reversible_Container<E> super; + typedef Reversible_Container<Exact> super; stc_using(reference); stc_using(const_reference); stc_using(size_type); @@ -113,13 +113,13 @@ // Sequence - template <typename E> - class Sequence : public virtual Forward_Container<E>, - public automatic::impl<Sequence, E> + template <typename Exact> + class Sequence : public virtual Forward_Container<Exact>, + public automatic::impl<Sequence, Exact> { public: - typedef Forward_Container<E> super; + typedef Forward_Container<Exact> super; stc_using(iterator); stc_using(value_type); stc_using(reference); @@ -155,13 +155,13 @@ // Front_Insertion_Sequence - template <typename E> - class Front_Insertion_Sequence : public virtual Sequence<E>, - public automatic::impl<Front_Insertion_Sequence, E> + template <typename Exact> + class Front_Insertion_Sequence : public virtual Sequence<Exact>, + public automatic::impl<Front_Insertion_Sequence, Exact> { public: - typedef Sequence<E> super; + typedef Sequence<Exact> super; stc_using(value_type); // Concrete. @@ -183,13 +183,13 @@ // Back_Insertion_Sequence - template <typename E> - class Back_Insertion_Sequence : public virtual Sequence<E>, - public automatic::impl<Back_Insertion_Sequence, E> + template <typename Exact> + class Back_Insertion_Sequence : public virtual Sequence<Exact>, + public automatic::impl<Back_Insertion_Sequence, Exact> { public: - typedef Sequence<E> super; + typedef Sequence<Exact> super; stc_using(reference); stc_using(value_type); @@ -216,9 +216,9 @@ // Iterator - template <typename E> - class Iterator : public virtual stc::any__simple<E>, - public automatic::impl<Iterator, E> + template <typename Exact> + class Iterator : public virtual stc::any__simple<Exact>, + public automatic::impl<Iterator, Exact> { public: @@ -232,13 +232,13 @@ // Trivial_Iterator - template <typename E> - class Trivial_Iterator : public virtual Iterator<E>, - public automatic::impl<Trivial_Iterator, E> + template <typename Exact> + class Trivial_Iterator : public virtual Iterator<Exact>, + public automatic::impl<Trivial_Iterator, Exact> { public: - typedef Trivial_Iterator<E> self_type; + typedef Trivial_Iterator<Exact> self_type; // Typedef. abc_typename(value_type); @@ -262,9 +262,9 @@ // Input_Iterator - template <typename E> - class Input_Iterator : public virtual Trivial_Iterator<E>, - public automatic::impl<Input_Iterator, E> + template <typename Exact> + class Input_Iterator : public virtual Trivial_Iterator<Exact>, + public automatic::impl<Input_Iterator, Exact> { public: @@ -272,12 +272,12 @@ abc_typename(distance_type); // Method. - E& operator++() { return this->exact().impl_preinc(); } + Exact& operator++() { return this->exact().impl_preinc(); } // Concrete. - E operator++(int) const + Exact operator++(int) const { - E cpy(*this); + Exact cpy(*this); ++(*this); return cpy; } @@ -290,13 +290,13 @@ // Output_Iterator - template <typename E> - class Output_Iterator : public virtual Trivial_Iterator<E>, - public automatic::impl<Output_Iterator, E> + template <typename Exact> + class Output_Iterator : public virtual Trivial_Iterator<Exact>, + public automatic::impl<Output_Iterator, Exact> { public: - typedef Trivial_Iterator<E> super; + typedef Trivial_Iterator<Exact> super; stc_using(value_type); using super::operator*; @@ -314,9 +314,9 @@ // Forward_Iterator - template <typename E> - class Forward_Iterator : public virtual Input_Iterator<E>, public virtual Output_Iterator<E>, - public automatic::impl<Forward_Iterator, E> + template <typename Exact> + class Forward_Iterator : public virtual Input_Iterator<Exact>, public virtual Output_Iterator<Exact>, + public automatic::impl<Forward_Iterator, Exact> { public: // nothing @@ -328,19 +328,19 @@ // Bidirectional_Iterator - template <typename E> - class Bidirectional_Iterator : public virtual Forward_Iterator<E>, - public automatic::impl<Bidirectional_Iterator, E> + template <typename Exact> + class Bidirectional_Iterator : public virtual Forward_Iterator<Exact>, + public automatic::impl<Bidirectional_Iterator, Exact> { public: // Method. - E& operator--() { return this->exact().impl_predec(); } + Exact& operator--() { return this->exact().impl_predec(); } // Concrete. - E operator--(int) const + Exact operator--(int) const { - E cpy(*this); + Exact cpy(*this); --(*this); return cpy; } Index: samples/mini-std/cpp2/mini-std.cc Index: samples/mini-std/cpp2/Makefile.am --- samples/mini-std/cpp2/Makefile.am (revision 1019) +++ samples/mini-std/cpp2/Makefile.am (working copy) @@ -1,7 +1,18 @@ -CPPFLAGS = -I../../../../olena/oln -I../../../../metalic +## Process this file through Automake to create Makefile.in -*- Makefile -*- -.PHONY: all +AM_CPPFLAGS = -I$(top_srcdir)/static -I$(top_srcdir)/metalic -all: mini-std +# 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) -mini-std: mini-std.cc \ No newline at end of file + +check_PROGRAMS = mini-std +mini_std_SOURCES = mini-std.cc + +TESTS = $(check_PROGRAMS) Index: samples/mini-std/Makefile.am --- samples/mini-std/Makefile.am (revision 0) +++ samples/mini-std/Makefile.am (revision 0) @@ -0,0 +1,5 @@ +## Process this file through Automake to create Makefile.in -*- Makefile -*- + +SUBDIRS = cpp cpp2 + +EXTRA_DIST = README design.hh Index: samples/mini-std/README --- samples/mini-std/README (revision 1031) +++ samples/mini-std/README (working copy) @@ -5,6 +5,8 @@ cd cpp g++ -I../../.. -I../../../../metalic -Wall -ansi -pedantic main.cc +or just use `make' + * contents ** utility files Index: samples/Makefile.am --- samples/Makefile.am (revision 1031) +++ samples/Makefile.am (working copy) @@ -1,3 +1,3 @@ ## Process this file through Automake to create Makefile.in -*- Makefile -*- -SUBDIRS = mini-oln +SUBDIRS = mini-std mini-oln