Subject: Re: [Boost-bugs] [Boost C++ Libraries] #1180: [boost.python] def_readwrite need a default docstring
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-06-26 20:58:39
#1180: [boost.python] def_readwrite need a default docstring
-------------------------------------------+--------------------------------
Reporter: qiaozhiqiang_at_[hidden] | Owner: dave
Type: Feature Requests | Status: new
Milestone: To Be Determined | Component: Python
Version: Boost 1.34.0 | Severity: Problem
Resolution: | Keywords: def_readwrite docstring
-------------------------------------------+--------------------------------
Old description:
> the default docstring defined by def_readwrite is null,
> can boost.python add the type name of my_s::a as the default docstring?
> like the function's "C++ signature" docstring.
>
> struct my_s
> {
> int a;
> };
>
> void export_module
> {
> class_<my_s > s_class("my_s", init< >());
> s_class.def_readwrite("a", &my_s::a);// __doc__ is empty, can
> boost.python add the type name of my_s::a as the default docstring? like
> the function's "C++ signature" docstring.
> }
>
> // I do this like this:
> // get type name of data member of class
> template<typename T, typename C>
> char const* MemberTypeName(T C::*)
> {
> char const* name = typeid(T).name();
> return name;
> }
>
> // boost::python def_readwrite no docstring
> // read write property
> #define DEF_READWRITE(n, p) \
> def_readwrite((n), (p), std::string("read write property, type is
> ") + MemberTypeName(p)).c_str())
>
>
> void export_module
> {
> class_<my_s > s_class("my_s", init< >());
> s_class.DEF_READWRITE("a", &my_s::a);// replace all auto genarated
> def_readwrite to DEF_READWRITE.
> }
New description:
the default docstring defined by def_readwrite is null,
can boost.python add the type name of my_s::a as the default docstring?
like the function's "C++ signature" docstring.
{{{
#!cpp
struct my_s
{
int a;
};
void export_module
{
class_<my_s > s_class("my_s", init< >());
s_class.def_readwrite("a", &my_s::a);// __doc__ is empty, can
boost.python add the type name of my_s::a as the default docstring? like
the function's "C++ signature" docstring.
}
// I do this like this:
// get type name of data member of class
template<typename T, typename C>
char const* MemberTypeName(T C::*)
{
char const* name = typeid(T).name();
return name;
}
// boost::python def_readwrite no docstring
// read write property
#define DEF_READWRITE(n, p) \
def_readwrite((n), (p), std::string("read write property, type is
") + MemberTypeName(p)).c_str())
void export_module
{
class_<my_s > s_class("my_s", init< >());
s_class.DEF_READWRITE("a", &my_s::a);// replace all auto genarated
def_readwrite to DEF_READWRITE.
}
}}}
Comment (by dave):
Fix formatting mess.
--
Ticket URL: <http://svn.boost.org/trac/boost/ticket/1180#comment:1>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:58 UTC