[C++-sig] Wrapping out parameter for python access
Roman Yakovenko
roman.yakovenko at gmail.com
Sun Oct 28 20:51:30 CET 2007
On 10/22/07, Chang Chen <Chang_Chen at sonic.com> wrote:
>
> Hi all
>
> This is a classical issue in boost python. I.e. removeing an argument
> from the function definition and adding the "returned", by the original
> function, value to the return statement of the function-wrapper
>
> For example :
>
> The original function is:
>
> inline void hello_world( std::string& hw ){
> hw = "hello world!";
> }
>
> And the wrapper is:
>
> inline std::string hello_world_wrapper()
> {
> std:string temp;
> ::hello_world(temp);
> Return temp;
> }
>
> Py++ can help us to generate such wrapper, see
> http://language-binding.net/pyplusplus/documentation/functions/transform
> ation/built_in/output.html
>
> But in this thread
> (http://mail.python.org/pipermail/c++-sig/2005-June/009097.html ), Dave
> provided a start to write a wrapping template.
>
> In My case, only last parameter is out parameter and whether function
> parameter count does not matter. The function signature looks like:
>
> Return function (T1 t1, T2 t2, TOUT& out);
>
> How to write a template for such function and integrate into def?
>
> Any suggestion?
I attach the complete solution to the problem including build script and
unittest.
The key for solution is to use boost::bind library.
P.S. anyone with good knowledge of MPL & PPL, and some free time :-), is
welcome to improve the code
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20071028/ce05c284/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: reducer.zip
Type: application/zip
Size: 1471 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20071028/ce05c284/attachment.zip>
More information about the Cplusplus-sig
mailing list