1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/python/object/function.hpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,78 @@
1.4 +// Copyright David Abrahams 2001.
1.5 +// Distributed under the Boost Software License, Version 1.0. (See
1.6 +// accompanying file LICENSE_1_0.txt or copy at
1.7 +// http://www.boost.org/LICENSE_1_0.txt)
1.8 +#ifndef FUNCTION_DWA20011214_HPP
1.9 +# define FUNCTION_DWA20011214_HPP
1.10 +
1.11 +# include <boost/python/detail/prefix.hpp>
1.12 +# include <boost/python/args_fwd.hpp>
1.13 +# include <boost/python/handle.hpp>
1.14 +# include <boost/function/function2.hpp>
1.15 +# include <boost/python/object_core.hpp>
1.16 +# include <boost/python/object/py_function.hpp>
1.17 +
1.18 +namespace boost { namespace python { namespace objects {
1.19 +
1.20 +struct BOOST_PYTHON_DECL function : PyObject
1.21 +{
1.22 + function(
1.23 + py_function const&
1.24 + , python::detail::keyword const* names_and_defaults
1.25 + , unsigned num_keywords);
1.26 +
1.27 + ~function();
1.28 +
1.29 + PyObject* call(PyObject*, PyObject*) const;
1.30 +
1.31 + // Add an attribute to the name_space with the given name. If it is
1.32 + // a function object (this class), and an existing function is
1.33 + // already there, add it as an overload.
1.34 + static void add_to_namespace(
1.35 + object const& name_space, char const* name, object const& attribute);
1.36 +
1.37 + static void add_to_namespace(
1.38 + object const& name_space, char const* name, object const& attribute, char const* doc);
1.39 +
1.40 + object const& doc() const;
1.41 + void doc(object const& x);
1.42 +
1.43 + object const& name() const;
1.44 +
1.45 + private: // helper functions
1.46 + object signature(bool show_return_type=false) const;
1.47 + object signatures(bool show_return_type=false) const;
1.48 + void argument_error(PyObject* args, PyObject* keywords) const;
1.49 + void add_overload(handle<function> const&);
1.50 +
1.51 + private: // data members
1.52 + py_function m_fn;
1.53 + handle<function> m_overloads;
1.54 + object m_name;
1.55 + object m_namespace;
1.56 + object m_doc;
1.57 + object m_arg_names;
1.58 + unsigned m_nkeyword_values;
1.59 +};
1.60 +
1.61 +//
1.62 +// implementations
1.63 +//
1.64 +inline object const& function::doc() const
1.65 +{
1.66 + return this->m_doc;
1.67 +}
1.68 +
1.69 +inline void function::doc(object const& x)
1.70 +{
1.71 + this->m_doc = x;
1.72 +}
1.73 +
1.74 +inline object const& function::name() const
1.75 +{
1.76 + return this->m_name;
1.77 +}
1.78 +
1.79 +}}} // namespace boost::python::objects
1.80 +
1.81 +#endif // FUNCTION_DWA20011214_HPP