Commit 93db4c3a authored by Thierry Geraud's avatar Thierry Geraud
Browse files

Fix some warnings with icpc; add is_built_in_.

- tests (svn:ignore): Add '.deps'.
- tests/case.cc: Fix warning with icpc.
- tests/gcase.cc: New file.
- mlc/abstract: New directory.
- mlc/type.hh: Rename as...
- mlc/abstract/type.hh: ...this.
- mlc/bexpr.hh (abstract::bexpr): Move to...
- mlc/abstract/bexpr.hh: ...this new file.
- mlc/flags.hh: Update include.
- mlc/value.hh: Update include.
- mlc/ret.hh: Add separators in macros to fix error with icpc.
- mlc/assert.hh: Add dtor to fix warning with icpc.
- mlc/case.hh (internal::a_get_case): New flag.
(get_case_): New class; it differs from case_ in remaining silent
when no case matches.
- mlc/cmp.hh (is_builtin_): New class with its specializations.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@453 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 47f9e9c3
2006-04-11 Thierry Geraud <theo@lrde.epita.fr>
Fix some warnings with icpc; add is_built_in_.
* tests (svn:ignore): Add '.deps'.
* tests/case.cc: Fix warning with icpc.
* tests/gcase.cc: New file.
* mlc/abstract: New directory.
* mlc/type.hh: Rename as...
* mlc/abstract/type.hh: ...this.
* mlc/bexpr.hh (abstract::bexpr): Move to...
* mlc/abstract/bexpr.hh: ...this new file.
* mlc/flags.hh: Update include.
* mlc/value.hh: Update include.
* mlc/ret.hh: Add separators in macros to fix error with icpc.
* mlc/assert.hh: Add dtor to fix warning with icpc.
* mlc/case.hh (internal::a_get_case): New flag.
(get_case_): New class; it differs from case_ in remaining silent
when no case matches.
* mlc/cmp.hh (is_builtin_): New class with its specializations.
2006-04-04 Roland Levillain <roland@lrde.epita.fr>
Add mlc::any.
......
// Copyright (C) 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, 59 Temple Place - Suite 330, Boston,
// MA 02111-1307, USA.
//
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef METALIC_ABSTRACT_BEXPR_HH
# define METALIC_ABSTRACT_BEXPR_HH
# include <mlc/abstract/type.hh>
# include <mlc/flags.hh>
namespace mlc
{
namespace abstract
{
/*! \class mlc::abstract::bexpr
**
** Abstract base class for mlc Boolean expression types.
**
** When you define a new class for a Boolean expression type, you
** should not directly derive from this class from fom its
** subclass: bexpr_<b>.
**
** \see bexpr_<b>
*/
struct bexpr : public mlc::abstract::type
{
// typedef void eval;
};
} // end of namespace mlc::abstract
} // end of namespace mlc
#endif // ! METALIC_ABSTRACT_BEXPR_HH
......@@ -25,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef METALIC_TYPE_HH
# define METALIC_TYPE_HH
#ifndef METALIC_ABSTRACT_TYPE_HH
# define METALIC_ABSTRACT_TYPE_HH
namespace mlc {
......@@ -48,8 +48,8 @@ namespace mlc {
struct type
{
private:
/// Ctor is private to prevent instantiations.
protected:
/// Ctor is protected to prevent instantiations.
type() {}
};
......@@ -58,4 +58,4 @@ namespace mlc {
} // end of namespace mlc
#endif // ! METALIC_TYPE_HH
#endif // ! METALIC_ABSTRACT_TYPE_HH
......@@ -156,6 +156,7 @@ namespace mlc
{
public:
static void check() {}
virtual ~assert_() {}
protected:
assert_() {}
};
......
......@@ -28,7 +28,7 @@
#ifndef METALIC_BEXPR_HH
# define METALIC_BEXPR_HH
# include <mlc/type.hh>
# include <mlc/abstract/bexpr.hh>
# include <mlc/flags.hh>
......@@ -46,28 +46,6 @@ namespace mlc
namespace abstract {
/*! \class mlc::abstract::bexpr
**
** Abstract base class for mlc Boolean expression types.
**
** When you define a new class for a Boolean expression type, you
** should not directly derive from this class from fom its
** subclass: bexpr_<b>.
**
** \see bexpr_<b>
*/
struct bexpr : public type
{
// typedef void eval;
};
} // end of namespace mlc::abstract
/*! \class mlc::bexpr_<b>
**
** Base class for any class of mlc Boolean expression types.
......@@ -109,6 +87,10 @@ namespace mlc
// FIXME: doc
typedef bexpr_<true> bexpr;
protected:
/// Ctor is protected to prevent instantiations.
bexpr_() {}
};
......@@ -128,6 +110,10 @@ namespace mlc
typedef mlc::false_ eval;
typedef bexpr_<false> bexpr;
protected:
/// Ctor is protected to prevent instantiations.
bexpr_() {}
};
......@@ -167,7 +153,7 @@ namespace mlc
** mlc::internal::bool_of_bexpr_<Bexpr>
*/
# define mlc_bool(Bexpr) mlc::internal::bool_of_bexpr_<Bexpr>::ret
# define mlc_bool(Bexpr) mlc::internal::bool_of_bexpr_< Bexpr >::ret
......
......@@ -64,6 +64,7 @@ namespace mlc
namespace internal
{
struct a_get_case;
struct a_simple_case;
struct a_switch_case;
......@@ -203,6 +204,22 @@ namespace NAMESPACE \
struct handle_default_case_; \
\
\
template <typename context, typename data> \
struct handle_default_case_ < mlc::internal::a_get_case, context, data > \
\
: private mlc::assert_< mlc::implies_< mlc::is_defined_< NAMESPACE::default_case_<context, data> >, \
mlc_is_not_a(mlc_comma_1(NAMESPACE::default_case_<context, data>), \
mlc::where_) >, \
mlc::ERROR::A_default_case_STATEMENT_SHOULD_NOT_DERIVE_FROM_mlc_where_ > \
{ \
typedef NAMESPACE::default_case_<context, data> case_t; \
typedef typename protected_in_<case_t>::the protected_case_t; \
\
typedef typename mlc::if_< mlc::is_found_<protected_case_t>, \
protected_case_t, \
case_t >::ret ret; \
}; \
\
\
template <typename context, typename data> \
struct handle_default_case_ < mlc::internal::a_simple_case, context, data > \
......@@ -261,7 +278,8 @@ namespace NAMESPACE \
mlc::where_) >, \
mlc::ERROR::A_case_STATEMENT_SHOULD_DERIVE_FROM_mlc_where_ >, \
\
private mlc::assert_< mlc::is_defined_< NAMESPACE::default_case_<context, data> >, \
private mlc::assert_< mlc::implies_< mlc::neq_< use, mlc::internal::a_get_case >, \
mlc::is_defined_< NAMESPACE::default_case_<context, data> > >, \
mlc::WARNING::NO_default_case_STATEMENT_HAS_BEEN_DEFINED > \
\
{ \
......@@ -380,6 +398,13 @@ namespace NAMESPACE \
\
\
template <typename context, typename data> \
struct get_case_ \
{ \
typedef typename NAMESPACE::internal::select_case_<mlc::internal::a_get_case, context, data>::ret ret; \
}; \
\
\
template <typename context, typename data> \
struct case_ <context, data, mlc::internal::unknown_case_id> \
\
: private mlc::assert_< mlc::neq_< mlc_comma_2(typename NAMESPACE::internal::select_case_<mlc::internal::a_simple_case, \
......
......@@ -50,12 +50,16 @@
# define mlc_is_found(T) mlc::is_found_<T>
# define mlc_is_not_found(T) mlc::is_not_found_<T>
// FIXME: or (?) mlc_is_not_defined below
# define mlc_is_undefined(T) mlc::is_undefined_<T>
# define mlc_is_defined(T) mlc::is_defined_<T>
# define mlc_is_ok(T) mlc::is_ok_<T>
# define mlc_is_not_ok(T) mlc::is_not_ok_<T>
# define mlc_is_builtin(T) mlc::is_builtin_<T>
# define mlc_is_not_builtin(T) mlc::is_not_builtin_<T>
/// \}
......@@ -162,6 +166,46 @@ namespace mlc
/// \}
/// Check whether a type is a builtin type.
/// \{
template <typename T>
struct is_builtin_ : public bexpr_<false>
{
};
template <typename T> struct is_builtin_ < const T > : public is_builtin_< T >::bexpr {};
template <typename T> struct is_builtin_ < T* > : public is_builtin_< T >::bexpr {};
template <typename T> struct is_builtin_ < T[] > : public is_builtin_< T >::bexpr {};
template <typename T,
unsigned n> struct is_builtin_ < T[n] > : public is_builtin_< T >::bexpr {};
template <> struct is_builtin_ < void > : public bexpr_<true> {}; // FIXME: ?
template <> struct is_builtin_ < bool > : public bexpr_<true> {};
template <> struct is_builtin_ < char > : public bexpr_<true> {};
template <> struct is_builtin_ < float > : public bexpr_<true> {};
template <> struct is_builtin_ < double > : public bexpr_<true> {};
template <> struct is_builtin_ < long double > : public bexpr_<true> {};
template <> struct is_builtin_ < unsigned char > : public bexpr_<true> {};
template <> struct is_builtin_ < signed char > : public bexpr_<true> {};
template <> struct is_builtin_ < unsigned short > : public bexpr_<true> {};
template <> struct is_builtin_ < signed short > : public bexpr_<true> {};
template <> struct is_builtin_ < unsigned int > : public bexpr_<true> {};
template <> struct is_builtin_ < signed int > : public bexpr_<true> {};
template <> struct is_builtin_ < unsigned long > : public bexpr_<true> {};
template <> struct is_builtin_ < signed long > : public bexpr_<true> {};
template <typename T>
struct is_not_builtin_ : public not_< is_builtin_<T> >::bexpr
{
};
/// \}
} // end of namespace mlc
......
......@@ -28,7 +28,7 @@
#ifndef METALIC_FLAGS_HH
# define METALIC_FLAGS_HH
# include <mlc/type.hh>
# include <mlc/abstract/type.hh>
namespace mlc {
......
......@@ -51,8 +51,8 @@ namespace mlc
/// \{
/// Macros mlc_ret and mlc_ret_.
# define mlc_ret(Type) typename mlc::typedef_::ret::from_<Type>::ret
# define mlc_ret_(Type) mlc::typedef_::ret::from_<Type>::ret
# define mlc_ret(Type) typename mlc::typedef_::ret::from_< Type >::ret
# define mlc_ret_(Type) mlc::typedef_::ret::from_< Type >::ret
/// \}
......@@ -60,7 +60,7 @@ namespace mlc
// test code
# define mlc_ret2(Type) typename mlc::typedef_::ret::from_<Type>::ret2
# define mlc_ret2(Type) typename mlc::typedef_::ret::from_< Type >::ret2
namespace mlc
......@@ -75,7 +75,7 @@ namespace mlc
} // end of namespace mlc
# define mlc_ret_found_in(T) mlc::ret_found_in_<T>
# define mlc_ret_found_in(T) mlc::ret_found_in_< T >
......
......@@ -28,7 +28,7 @@
#ifndef METALIC_VALUE_HH
# define METALIC_VALUE_HH
# include <mlc/type.hh>
# include <mlc/abstract/type.hh>
// # include <mlc/assert.hh>
// # include <mlc/is_a.hh>
......
......@@ -52,9 +52,9 @@ namespace client
template <class T>
void print()
static void print()
{
int tmp;
T tmp;
}
......
#include <mlc/is_a.hh>
#include <mlc/case.hh>
struct test;
mlc_case_equipment_for_namespace(client);
namespace client
{
template <class T>
struct case_ <test, T, 1> : public mlc::where_< mlc_is_a(T, short) >
{
};
template <class T>
struct case_ <test, T, 2> : public mlc::where_< mlc_is_a(T, int) >
{
};
} // end of namespace client
template <class T>
void print()
{
int tmp;
}
int main()
{
print< client::get_case_<test, char>::ret >();
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment