class.hpp.svn-base

来自「本人找过多个在linux下c++的lua5.1封装库,但很少.luabind已经」· SVN-BASE 代码 · 共 1,342 行 · 第 1/3 页

SVN-BASE
1,342
字号
		}		template<BOOST_PP_ENUM_PARAMS(LUABIND_MAX_ARITY, class A), class Policies>		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>()			  , &sig			  , policies			);		}		template<class Getter>		class_& property(const char* name, Getter g)		{			add_getter(name, boost::bind<int>(detail::get_caller<T, Getter, detail::null_type>(), _1, _2, g));			return *this;		}		template<class Getter, class MaybeSetter>		class_& property(const char* name, Getter g, MaybeSetter s)		{			return property_impl(name, g, s, boost::mpl::bool_<detail::is_policy_cons<MaybeSetter>::value>());		}		template<class Getter, class Setter, class GetPolicies>		class_& property(const char* name, Getter g, Setter s, const GetPolicies& get_policies)		{			add_getter(name, boost::bind<int>(detail::get_caller<T, Getter, GetPolicies>(get_policies), _1, _2, g));#ifndef LUABIND_NO_ERROR_CHECKING			add_setter(				name				, boost::bind<int>(detail::set_caller<T, Setter, detail::null_type>(), _1, _2, s)				, detail::gen_set_matcher((Setter)0, (detail::null_type*)0)				, &detail::get_member_signature<Setter>::apply);#else			add_setter(				name				, boost::bind<int>(detail::set_caller<T, Setter, detail::null_type>(), _1, _2, s));#endif			return *this;		}		template<class Getter, class Setter, class GetPolicies, class SetPolicies>		class_& property(const char* name									, Getter g, Setter s									, const GetPolicies& get_policies									, const SetPolicies& set_policies)		{			add_getter(name, boost::bind<int>(detail::get_caller<T, Getter, GetPolicies>(get_policies), _1, _2, g));#ifndef LUABIND_NO_ERROR_CHECKING			add_setter(				name				, boost::bind<int>(detail::set_caller<T, Setter, SetPolicies>(), _1, _2, s)				, detail::gen_set_matcher((Setter)0, (SetPolicies*)0)				, &detail::get_member_signature<Setter>::apply);#else			add_setter(name, boost::bind<int>(detail::set_caller<T, Setter, SetPolicies>(set_policies), _1, _2, s));#endif			return *this;		}		template<class D>		class_& def_readonly(const char* name, D T::*member_ptr)		{			add_getter(name, boost::bind<int>(detail::auto_get<T,D,detail::null_type>(), _1, _2, member_ptr));			return *this;		}		template<class D, class Policies>		class_& def_readonly(const char* name, D T::*member_ptr, const Policies& policies)		{			add_getter(name, boost::bind<int>(detail::auto_get<T,D,Policies>(policies), _1, _2, member_ptr));			return *this;		}		template<class D>		class_& def_readwrite(const char* name, D T::*member_ptr)		{			add_getter(name, boost::bind<int>(detail::auto_get<T,D,detail::null_type>(), _1, _2, member_ptr));#ifndef LUABIND_NO_ERROR_CHECKING			add_setter(				name				, boost::bind<int>(detail::auto_set<T,D,detail::null_type>(), _1, _2, member_ptr)				, &detail::set_matcher<D, detail::null_type>::apply				, &detail::get_setter_signature<D>::apply);#else			add_setter(name, boost::bind<int>(detail::auto_set<T,D,detail::null_type>(), _1, _2, member_ptr));#endif			return *this;		}		template<class D, class GetPolicies>		class_& def_readwrite(const char* name, D T::*member_ptr, const GetPolicies& get_policies)		{			add_getter(name, boost::bind<int>(detail::auto_get<T,D,GetPolicies>(get_policies), _1, _2, member_ptr));#ifndef LUABIND_NO_ERROR_CHECKING			add_setter(				name				, boost::bind<int>(detail::auto_set<T,D,detail::null_type>(), _1, _2, member_ptr)				, &detail::set_matcher<D, detail::null_type>::apply				, &detail::get_setter_signature<D>::apply);#else			add_setter(name, boost::bind<int>(detail::auto_set<T,D,detail::null_type>(), _1, _2, member_ptr));#endif			return *this;		}		template<class D, class GetPolicies, class SetPolicies>		class_& def_readwrite(const char* name, D T::*member_ptr, const GetPolicies& get_policies, const SetPolicies& set_policies)		{			add_getter(name, boost::bind<int>(detail::auto_get<T,D,GetPolicies>(get_policies), _1, _2, member_ptr));#ifndef LUABIND_NO_ERROR_CHECKING			add_setter(				name				, boost::bind<int>(detail::auto_set<T,D,SetPolicies>(), _1, _2, member_ptr)				, &detail::set_matcher<D, SetPolicies>::apply				, &detail::get_setter_signature<D>::apply);#else			add_setter(name, boost::bind<int>(detail::auto_set<T,D,SetPolicies>(set_policies), _1, _2, member_ptr));#endif			return *this;		}		template<class Derived, class Policies>		class_& def(detail::operator_<Derived>, Policies const& policies)		{			return this->def(				Derived::name()			  , &Derived::template apply<T, Policies>::execute			  , raw(_1) + policies			);		}		template<class Derived>		class_& def(detail::operator_<Derived>)		{			return this->def(				Derived::name()			  , &Derived::template apply<T, detail::null_type>::execute			  , raw(_1)			);		}/*		template<class op_id, class Left, class Right, class Policies>		class_& def(detail::operator_<op_id, Left, Right>, const Policies& policies)		{			typedef typename detail::operator_unwrapper<Policies, op_id, T, Left, Right> op_type;#ifndef LUABIND_NO_ERROR_CHECKING			add_operator(op_type::get_id()									, &op_type::execute									, &op_type::match									, &detail::get_signature<constructor<typename op_type::left_t, typename op_type::right_t> >::apply									, detail::is_unary(op_type::get_id()) ? 1 : 2);#else			add_operator(op_type::get_id()									, &op_type::execute									, &op_type::match									, detail::is_unary(op_type::get_id()) ? 1 : 2);#endif			return *this;		}		template<class op_id, class Left, class Right>		class_& def(detail::operator_<op_id, Left, Right>)		{			typedef typename detail::operator_unwrapper<detail::null_type, op_id, T, Left, Right> op_type;#ifndef LUABIND_NO_ERROR_CHECKING			add_operator(op_type::get_id()									, &op_type::execute									, &op_type::match									, &detail::get_signature<constructor<LUABIND_MSVC_TYPENAME op_type::left_t, LUABIND_MSVC_TYPENAME op_type::right_t> >::apply									, detail::is_unary(op_type::get_id()) ? 1 : 2);#else			add_operator(op_type::get_id()									, &op_type::execute									, &op_type::match									, detail::is_unary(op_type::get_id()) ? 1 : 2);#endif			return *this;		}		template<class Signature, bool Constant>		class_& def(detail::application_operator<Signature, Constant>*)		{			typedef detail::application_operator<Signature, Constant, detail::null_type> op_t;			int arity = detail::calc_arity<Signature::arity>::apply(				Signature(), static_cast<detail::null_type*>(0));#ifndef LUABIND_NO_ERROR_CHECKING			add_operator(				detail::op_call				, &op_t::template apply<T>::execute				, &op_t::match				, &detail::get_signature<Signature>::apply				, arity + 1);#else			add_operator(				detail::op_call				, &op_t::template apply<T>::execute				, &op_t::match				, arity + 1);#endif			return *this;		}		template<class Signature, bool Constant, class Policies>		class_& def(detail::application_operator<Signature, Constant>*, const Policies& policies)		{			typedef detail::application_operator<Signature, Constant, Policies> op_t;			int arity = detail::calc_arity<Signature::arity>::apply(Signature(), static_cast<Policies*>(0));#ifndef LUABIND_NO_ERROR_CHECKING			add_operator(				detail::op_call				, &op_t::template apply<T>::execute				, &op_t::match				, &detail::get_signature<Signature>::apply				, arity + 1);#else			add_operator(				detail::op_call				, &op_t::template apply<T>::execute				, &op_t::match				, arity + 1);#endif			return *this;		}*/		detail::enum_maker<self_t> enum_(const char*)		{			return detail::enum_maker<self_t>(*this);		}				detail::static_scope<self_t> scope;			private:		void operator=(class_ const&);		void init()		{			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::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());			generate_baseclass_list(detail::type_<Base>());		}		template<class Getter, class GetPolicies>		class_& property_impl(const char* name,									 Getter g,									 GetPolicies policies,									 boost::mpl::bool_<true>)		{			add_getter(name, boost::bind<int>(detail::get_caller<T,Getter,GetPolicies>(policies), _1, _2, g));			return *this;		}		template<class Getter, class Setter>		class_& property_impl(const char* name,									 Getter g,									 Setter s,									 boost::mpl::bool_<false>)		{			add_getter(name, boost::bind<int>(detail::get_caller<T,Getter,detail::null_type>(), _1, _2, g));#ifndef LUABIND_NO_ERROR_CHECKING			add_setter(				name				, boost::bind<int>(detail::set_caller<T, Setter, detail::null_type>(), _1, _2, s)				, detail::gen_set_matcher((Setter)0, (detail::null_type*)0)				, &detail::get_member_signature<Setter>::apply);#else			add_setter(name, boost::bind<int>(detail::set_caller<T,Setter,detail::null_type>(), _1, _2, s));#endif			return *this;		}		// these handle default implementation of virtual functions		template<class F, class Policies>		class_& virtual_def(char const* name, F const& fn			, Policies const&, detail::null_type, boost::mpl::true_)		{			// normal def() call			detail::overload_rep o(fn, static_cast<Policies*>(0));			o.set_match_fun(detail::mem_fn_matcher<F, T, Policies>(fn));			o.set_fun(detail::mem_fn_callback<F, T, Policies>(fn));#ifndef LUABIND_NO_ERROR_CHECKING			o.set_sig_fun(&detail::get_member_signature<F>::apply);#endif			this->add_method(name, o);			return *this;		}		template<class F, class Default, class Policies>		class_& virtual_def(char const* name, F const& fn			, Default const& default_, Policies const&, boost::mpl::false_)		{			// default_ is a default implementation			// policies is either null_type or a policy list			// normal def() call			detail::overload_rep o(fn, (Policies*)0);			o.set_match_fun(detail::mem_fn_matcher<F, T, Policies>(fn));			o.set_fun(detail::mem_fn_callback<F, T, Policies>(fn));			o.set_fun_static(				detail::mem_fn_callback<Default, T, Policies>(default_));#ifndef LUABIND_NO_ERROR_CHECKING			o.set_sig_fun(&detail::get_member_signature<F>::apply);#endif			this->add_method(name, o);			// register virtual function			return *this;		}        template<class Signature, class Policies>		class_& def_constructor(			boost::mpl::true_ /* HasWrapper */          , Signature*          , Policies const&)        {				detail::construct_rep::overload_t o;			o.set_constructor(				&detail::construct_class<					T				  , Policies				  , Signature				>::apply);			o.set_match_fun(				&detail::constructor_match<				    Signature			      , 2			      , Policies			    >::apply);#ifndef LUABIND_NO_ERROR_CHECKING			o.set_sig_fun(&detail::get_signature<Signature>::apply);#endif			o.set_arity(detail::calc_arity<Signature::arity>::apply(Signature(), (Policies*)0));			this->add_constructor(o);            return *this;        }        template<class Signature, class Policies>		class_& def_constructor(			boost::mpl::false_ /* !HasWrapper */          , Signature*          , Policies const&)		{			detail::construct_rep::overload_t o;			o.set_constructor(				&detail::construct_wrapped_class<					T				  , WrappedType				  , Policies				  , Signature				>::apply);			o.set_match_fun(				&detail::constructor_match<				    Signature			      , 2			      , Policies			    >::apply);#ifndef LUABIND_NO_ERROR_CHECKING			o.set_sig_fun(&detail::get_signature<Signature>::apply);#endif			o.set_arity(detail::calc_arity<Signature::arity>::apply(Signature(), (Policies*)0));			this->add_constructor(o);            return *this;        }		typedef void(*adopt_fun_t)(void*);		template<class W>		adopt_fun_t get_adopt_fun(W*)		{            return &detail::adopt_function<T, W>::execute;		}		adopt_fun_t get_adopt_fun(detail::null_type*)		{			return 0;		}	};	namespace 	{		LUABIND_ANONYMOUS_FIX detail::policy_cons<			detail::pure_virtual_tag		  , detail::null_type		> pure_virtual;	}}#ifdef _MSC_VER#pragma warning(pop)#endif#endif // LUABIND_CLASS_HPP_INCLUDED

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?