[C++-sig] Re: (return_self_policy / return_arg): Keywors
David Abrahams
dave at boost-consulting.com
Mon Jun 30 06:25:02 CEST 2003
Nikolay Mladenov <nickm at sitius.com> writes:
> This is how I use it:
Reformatting to avoid "endline layout" (google for it):
/////the.cpp////
class_<FileDialog, FileDialogPyX, boost::noncopyable>(
"FileDialog", python::no_init
)
.def(
init<
const char *
, const char *
, const char *
, const char *
, const char *
>(
args(
arg("title") = (const char *)0
, arg("prompt") = (const char *)0
, arg("extension") = (const char *)0
, arg("directory") = (const char *)0
, arg("file") = (const char *)0
)
)
)
.def(
init<
optional<
const char *
, const char *
, const char *
, const char *
, const char *
>
>()
)
/////the.py////
fd1 = FileDialog()
fd2 = FileDialog("Title")
fd2 = FileDialog(title="Title")
fd2 = FileDialog("Title", extension='.py', prompt='Select your script')
OK, I don't understand this. Isn't the 2nd constructor redundant?
Why are you using no_init? Doesn't this stuff work for regular
functions and member functions, too?
...and shouldn't we get rid of the need to write the outer
"args(...)"?
I suggest you write the documentation which would explain all this,
but posting informally is fine if you try to ensure that I don't have
to ask you lots more questions in order to understand it ;-)
>> Nit: the coding style should be made consistent with the rest of the
>> library. These don't really fit:
>>
>> > std::size_t j = nargs, k = nargs, size=PyTuple_GET_SIZE(f->m_arg_names.ptr());
>>
>> > }else ++k;
>>
>
> I will look into this. If you mean that some new line are missing,
> consider it fixed.
Also that you used commas between variable declarations, K&R braces
within functions, no spaces around '?', '<', '>', ...
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the Cplusplus-sig
mailing list