diff --git a/include/boost/python/def.hpp b/include/boost/python/def.hpp new file mode 100644 index 00000000..084b64a7 --- /dev/null +++ b/include/boost/python/def.hpp @@ -0,0 +1,68 @@ +// Copyright David Abrahams 2002. Permission to copy, use, +// modify, sell and distribute this software is granted provided this +// copyright notice appears in all copies. This software is provided +// "as is" without express or implied warranty, and with no claim as +// to its suitability for any purpose. +#ifndef DEF_DWA200292_HPP +# define DEF_DWA200292_HPP + +# include +# include +# include +# include +# include + +namespace boost { namespace python { + +namespace detail +{ + void BOOST_PYTHON_DECL scope_setattr_doc(char const* name, object const& obj, char const* doc); + + template + void + dispatch_def( + char const* name, + Fn fn, + CallPolicyOrDoc const& policy_or_doc, + char const* doc, + void const*) + { + typedef detail::def_helper helper; + + detail::scope_setattr_doc( + name, boost::python::make_function(fn, helper::get_policy(policy_or_doc)), + helper::get_doc(policy_or_doc, doc)); + } + + template + void + dispatch_def( + char const* name, + SigT sig, + StubsT const& stubs, + char const* doc, + detail::func_stubs_base const*) + { + // convert sig to a type_list (see detail::get_signature in signature.hpp) + // before calling detail::define_with_defaults. + scope current; + detail::define_with_defaults(name, stubs, current, detail::get_signature(sig), doc); + } +} + +template +void def(char const* name, Fn fn) +{ + detail::scope_setattr_doc(name, boost::python::make_function(fn), 0); +} + +template +void def(char const* name, Arg1T arg1, Arg2T const& arg2, char const* doc = 0) +{ + detail::dispatch_def(name, arg1, arg2, doc, &arg2); +} + + +}} // namespace boost::python + +#endif // DEF_DWA200292_HPP