mirror of
https://github.com/boostorg/python.git
synced 2026-01-23 05:42:30 +00:00
first attempt to implement docstrings with nice signatures
[SVN r22674]
This commit is contained in:
@@ -27,6 +27,9 @@
|
||||
# include <boost/python/object/add_to_namespace.hpp>
|
||||
# include <boost/python/object/class_converters.hpp>
|
||||
|
||||
# include <boost/python/converter/python_type.hpp>
|
||||
|
||||
|
||||
# include <boost/python/detail/overloads_fwd.hpp>
|
||||
# include <boost/python/detail/operator_id.hpp>
|
||||
# include <boost/python/detail/def_helper.hpp>
|
||||
@@ -638,6 +641,7 @@ inline void class_<T,X1,X2,X3>::register_() const
|
||||
mpl::bool_<is_copyable>()
|
||||
, select_holder()
|
||||
);
|
||||
converter::python_class<T>::register_();
|
||||
}
|
||||
|
||||
template <class T, class X1, class X2, class X3>
|
||||
|
||||
@@ -24,8 +24,14 @@ namespace boost { namespace python { namespace detail {
|
||||
|
||||
struct signature_element
|
||||
{
|
||||
char const* basename;
|
||||
char const* basename() const{return tid.name();}
|
||||
type_info tid;
|
||||
bool lvalue;
|
||||
signature_element( type_info t, bool l)
|
||||
: tid(t)
|
||||
, lvalue(l)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template <unsigned> struct signature_arity;
|
||||
@@ -70,14 +76,14 @@ struct signature_arity<N>
|
||||
static signature_element const result[N+2] = {
|
||||
|
||||
# define BOOST_PP_LOCAL_MACRO(i) \
|
||||
{ \
|
||||
type_id<BOOST_DEDUCED_TYPENAME mpl::at_c<Sig,i>::type>().name() \
|
||||
signature_element( \
|
||||
type_id<BOOST_DEDUCED_TYPENAME mpl::at_c<Sig,i>::type>() \
|
||||
, is_reference_to_non_const<BOOST_DEDUCED_TYPENAME mpl::at_c<Sig,i>::type>::value \
|
||||
},
|
||||
),
|
||||
|
||||
# define BOOST_PP_LOCAL_LIMITS (0, N)
|
||||
# include BOOST_PP_LOCAL_ITERATE()
|
||||
{0,0}
|
||||
signature_element(type_info(), 0)
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -39,10 +39,12 @@ struct BOOST_PYTHON_DECL function : PyObject
|
||||
void doc(object const& x);
|
||||
|
||||
object const& name() const;
|
||||
object pretty_signature(bool cpp_types = false, size_t n_optional_trailing_args=0)const;
|
||||
|
||||
private: // helper functions
|
||||
void argument_error(PyObject* args, PyObject* keywords) const;
|
||||
void add_overload(handle<function> const&);
|
||||
function const * overloads() const ;
|
||||
|
||||
private: // data members
|
||||
py_function m_fn;
|
||||
@@ -52,6 +54,7 @@ struct BOOST_PYTHON_DECL function : PyObject
|
||||
object m_doc;
|
||||
object m_arg_names;
|
||||
unsigned m_nkeyword_values;
|
||||
friend class function_signature_generator;
|
||||
};
|
||||
|
||||
//
|
||||
@@ -71,7 +74,7 @@ inline object const& function::name() const
|
||||
{
|
||||
return this->m_name;
|
||||
}
|
||||
|
||||
|
||||
}}} // namespace boost::python::objects
|
||||
|
||||
#endif // FUNCTION_DWA20011214_HPP
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
|
||||
# include <boost/python/object/instance.hpp>
|
||||
|
||||
# include <boost/python/converter/registry.hpp>
|
||||
# include <boost/python/converter/python_type.hpp>
|
||||
|
||||
# include <boost/python/object/forward.hpp>
|
||||
# include <boost/python/detail/preprocessor.hpp>
|
||||
|
||||
@@ -75,7 +78,7 @@ struct make_holder<N>
|
||||
# endif
|
||||
|
||||
static void execute(
|
||||
PyObject* p
|
||||
converter::python_class<Holder::value_type> *p
|
||||
BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(1, N, t, a))
|
||||
{
|
||||
typedef instance<Holder> instance_t;
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
# include <boost/python/object/instance.hpp>
|
||||
# include <boost/python/detail/force_instantiate.hpp>
|
||||
|
||||
# include <boost/python/converter/python_type.hpp>
|
||||
|
||||
# include <boost/type.hpp>
|
||||
|
||||
# include <boost/mpl/bool.hpp>
|
||||
@@ -111,7 +113,10 @@ namespace detail
|
||||
|
||||
typedef Held held_type;
|
||||
|
||||
static inline void register_() {}
|
||||
static inline void register_()
|
||||
{
|
||||
converter::detail::strip_type_info::insert(python::type_id<T>(), python::type_id<Held>());
|
||||
}
|
||||
|
||||
static type* get() { return 0; }
|
||||
};
|
||||
@@ -143,6 +148,7 @@ namespace detail
|
||||
static inline void register_()
|
||||
{
|
||||
select_pointer_holder::register_(use_back_ref());
|
||||
converter::detail::strip_type_info::insert(python::type_id<T>(), python::type_id<Ptr>());
|
||||
}
|
||||
|
||||
static type* get() { return 0; }
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <boost/python/pointee.hpp>
|
||||
#include <boost/python/object.hpp>
|
||||
#include <boost/python/object/class_wrapper.hpp>
|
||||
#include <boost/python/converter/python_type.hpp>
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
@@ -23,6 +24,7 @@ void register_ptr_to_python(BOOST_EXPLICIT_TEMPLATE_TYPE(P))
|
||||
, objects::pointer_holder<P,X>
|
||||
>
|
||||
>();
|
||||
converter::detail::strip_type_info::insert(type_id<X>(), type_id<P>());
|
||||
}
|
||||
|
||||
}} // namespace boost::python
|
||||
|
||||
Reference in New Issue
Block a user