Update of /cvsroot/luabind/luabind/luabind/luabind
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25461
Modified Files:
Tag: daniel-refactoring
class.hpp
Added Files:
Tag: daniel-refactoring
class_fwd.hpp
Log Message:
Moved parameter deduction metacode to a separate file detail/class_aux.hpp.
--- NEW FILE: class_fwd.hpp ---
// Copyright (c) 2005 Daniel Wallin and Arvid Norberg
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
// OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef LUABIND_CLASS_FWD_051002_HPP
#define LUABIND_CLASS_FWD_051002_HPP
#include <luabind/detail/unspecified.hpp>
namespace luabind {
template<
class T
, class X1 = detail::unspecified
, class X2 = detail::unspecified
, class X3 = detail::unspecified
>
struct class_;
} // namespace luabind
#endif // LUABIND_CLASS_FWD_051002_HPP
Index: class.hpp
===================================================================
RCS file: /cvsroot/luabind/luabind/luabind/luabind/class.hpp,v
retrieving revision 1.63.2.2
retrieving revision 1.63.2.2.2.1
diff -u -d -r1.63.2.2 -r1.63.2.2.2.1
--- class.hpp 28 Jul 2005 17:52:16 -0000 1.63.2.2
+++ class.hpp 2 Oct 2005 00:19:11 -0000 1.63.2.2.2.1
@@ -76,20 +76,12 @@
#include <cassert>
#include <boost/static_assert.hpp>
-#include <boost/type_traits.hpp>
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
-#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
#include <boost/preprocessor/repetition/repeat.hpp>
#include <boost/type_traits/is_same.hpp>
-#include <boost/mpl/list.hpp>
-#include <boost/mpl/apply.hpp>
-#include <boost/mpl/lambda.hpp>
-#include <boost/mpl/logical.hpp>
-#include <boost/mpl/find_if.hpp>
#include <boost/mpl/eval_if.hpp>
-#include <boost/mpl/logical.hpp>
#include <luabind/config.hpp>
#include <luabind/scope.hpp>
@@ -114,6 +106,10 @@
#include <luabind/detail/pointee_typeid.hpp>
#include <luabind/detail/link_compatibility.hpp>
+#include <luabind/class_fwd.hpp>
+#include <luabind/detail/class_aux.hpp>
+#include <luabind/detail/unspecified.hpp>
+
// to remove the 'this' used in initialization list-warning
#ifdef _MSC_VER
#pragma warning(push)
@@ -125,16 +121,11 @@
{
namespace detail
{
- struct unspecified {};
-
template<class Derived> struct operator_;
struct you_need_to_define_a_get_const_holder_function_for_your_smart_ptr {};
}
- template<class T, class X1 = detail::unspecified, class X2 = detail::unspecified, class X3 = detail::unspecified>
- struct class_;
-
// TODO: this function will only be invoked if the user hasn't defined a correct overload
// maybe we should have a static assert in here?
inline detail::you_need_to_define_a_get_const_holder_function_for_your_smart_ptr*
@@ -145,61 +136,6 @@
namespace detail
{
- template<BOOST_PP_ENUM_PARAMS(LUABIND_MAX_BASES, class A)>
- double is_bases_helper(const bases<BOOST_PP_ENUM_PARAMS(LUABIND_MAX_BASES, A)>&);
-
-#ifndef BOOST_MSVC
- template<class T>
- char is_bases_helper(const T&);
-#else
- char is_bases_helper(...);
-#endif
-
- template<class T>
- struct is_bases
- {
- static const T& t;
-
- BOOST_STATIC_CONSTANT(bool, value = sizeof(is_bases_helper(t)) == sizeof(double));
- typedef boost::mpl::bool_<value> type;
- BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_bases,(T))
- };
-
- double is_not_unspecified_helper(const unspecified*);
- char is_not_unspecified_helper(...);
-
- template<class T>
- struct is_not_unspecified
- {
- BOOST_STATIC_CONSTANT(bool, value = sizeof(is_not_unspecified_helper(static_cast<T*>(0))) == sizeof(char));
- typedef boost::mpl::bool_<value> type;
- BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_not_unspecified,(T))
- };
-
- template<class Predicate>
- struct get_predicate
- {
- typedef typename boost::mpl::and_<
- is_not_unspecified<boost::mpl::_1>
- , Predicate
- > type;
- };
-
- template<class Parameters, class Predicate, class DefaultValue>
- struct extract_parameter
- {
- typedef typename get_predicate<Predicate>::type pred;
- typedef typename boost::mpl::find_if<Parameters, pred>::type iterator;
- typedef typename boost::mpl::eval_if<
- boost::is_same<
- iterator
- , typename boost::mpl::end<Parameters>::type
- >
- , boost::mpl::identity<DefaultValue>
- , boost::mpl::deref<iterator>
- >::type type;
- };
-
template<class Fn, class Class, class Policies>
struct mem_fn_callback
{
@@ -786,38 +722,16 @@
// registers a class in the lua environment
template<class T, class X1, class X2, class X3>
- struct class_: detail::class_base
+ struct class_ : detail::class_base
{
typedef class_<T, X1, X2, X3> self_t;
+ typedef detail::class_aux<T,X1,X2,X3> meta;
private:
-
template<class A, class B, class C, class D>
class_(const class_<A,B,C,D>&);
public:
-
- // WrappedType MUST inherit from T
- typedef typename detail::extract_parameter<
- boost::mpl::vector3<X1,X2,X3>
- , boost::is_base_and_derived<T, boost::mpl::_>
- , detail::null_type
- >::type WrappedType;
-
- typedef typename detail::extract_parameter<
- boost::mpl::list3<X1,X2,X3>
- , boost::mpl::not_<
- boost::mpl::or_<
- boost::mpl::or_<
- detail::is_bases<boost::mpl::_>
- , boost::is_base_and_derived<boost::mpl::_, T>
- >
- , boost::is_base_and_derived<T, boost::mpl::_>
- >
- >
- , detail::null_type
- >::type HeldType;
-
// this function generates conversion information
// in the given class_rep structure. It will be able
// to implicitly cast to the given template type
@@ -890,7 +804,7 @@
class_& def(constructor<BOOST_PP_ENUM_PARAMS(LUABIND_MAX_ARITY, A)> sig)
{
return this->def_constructor(
- boost::is_same<WrappedType, detail::null_type>()
+ boost::is_same<typename meta::wrapped_type, detail::null_type>()
, &sig
, detail::null_type()
);
@@ -900,7 +814,7 @@
class_& def(constructor<BOOST_PP_ENUM_PARAMS(LUABIND_MAX_ARITY, A)> sig, const Policies& policies)
{
return this->def_constructor(
- boost::is_same<WrappedType, detail::null_type>()
+ boost::is_same<typename meta::wrapped_type, detail::null_type>()
, &sig
, policies
);
@@ -1142,41 +1056,26 @@
void init()
{
set_back_reference((back_reference<T>*)0);
-
- typedef typename detail::extract_parameter<
- boost::mpl::list3<X1,X2,X3>
- , boost::mpl::or_<
- detail::is_bases<boost::mpl::_>
- , boost::is_base_and_derived<boost::mpl::_, T>
- >
- , no_bases
- >::type bases_t;
-
- typedef typename
- boost::mpl::if_<detail::is_bases<bases_t>
- , bases_t
- , bases<bases_t>
- >::type Base;
class_base::init(LUABIND_TYPEID(T)
- , detail::internal_holder_type<HeldType>::apply()
+ , detail::internal_holder_type<typename meta::held_type>::apply()
, detail::pointee_typeid(
- get_const_holder(static_cast<HeldType*>(0)))
- , detail::internal_holder_extractor<HeldType>::apply(detail::type_<T>())
- , detail::internal_const_holder_extractor<HeldType>::apply(detail::type_<T>())
- , detail::const_converter<HeldType>::apply(
- get_const_holder((HeldType*)0))
- , detail::holder_constructor<HeldType>::apply(detail::type_<T>())
- , detail::const_holder_constructor<HeldType>::apply(detail::type_<T>())
- , detail::holder_default_constructor<HeldType>::apply(detail::type_<T>())
- , detail::const_holder_default_constructor<HeldType>::apply(detail::type_<T>())
- , get_adopt_fun((WrappedType*)0) // adopt fun
- , detail::internal_holder_destructor<HeldType>::apply(detail::type_<T>())
- , detail::internal_const_holder_destructor<HeldType>::apply(detail::type_<T>())
- , detail::internal_holder_size<HeldType>::apply()
- , detail::get_holder_alignment<HeldType>::apply());
+ get_const_holder(static_cast<typename meta::held_type*>(0)))
+ , detail::internal_holder_extractor<typename meta::held_type>::apply(detail::type_<T>())
+ , detail::internal_const_holder_extractor<typename meta::held_type>::apply(detail::type_<T>())
+ , detail::const_converter<typename meta::held_type>::apply(
+ get_const_holder((typename meta::held_type*)0))
+ , detail::holder_constructor<typename meta::held_type>::apply(detail::type_<T>())
+ , detail::const_holder_constructor<typename meta::held_type>::apply(detail::type_<T>())
+ , detail::holder_default_constructor<typename meta::held_type>::apply(detail::type_<T>())
+ , detail::const_holder_default_constructor<typename meta::held_type>::apply(detail::type_<T>())
+ , get_adopt_fun((typename meta::wrapped_type*)0) // adopt fun
+ , detail::internal_holder_destructor<typename meta::held_type>::apply(detail::type_<T>())
+ , detail::internal_const_holder_destructor<typename meta::held_type>::apply(detail::type_<T>())
+ , detail::internal_holder_size<typename meta::held_type>::apply()
+ , detail::get_holder_alignment<typename meta::held_type>::apply());
- generate_baseclass_list(detail::type_<Base>());
+ generate_baseclass_list(detail::type_<typename meta::bases_type>());
}
template<class Getter, class GetPolicies>
@@ -1292,7 +1191,7 @@
o.set_constructor(
&detail::construct_wrapped_class<
T
- , WrappedType
+ , typename meta::wrapped_type
, Policies
, Signature
>::apply);
@@ -1315,7 +1214,7 @@
void set_back_reference(detail::default_back_reference*)
{
back_reference<T>::has_wrapper
- = !boost::is_same<WrappedType, detail::null_type>::value;
+ = !boost::is_same<typename meta::wrapped_type, detail::null_type>::value;
}
void set_back_reference(void*)
|