Re: [C++-sig] Boost.Python: How to fill a passed in buffer in Python

2012-05-01 Thread Roman Yakovenko
On Tue, May 1, 2012 at 10:53 PM, Ehsan Pi wrote: > In Python, the output of the GetAddress is a void * to the memory address: > >     >>> import MyWrapper >     >>> foo = MyWrapper.Foo(100) >     >>> address = foo.GetAddress() >     >>> print address >     >     >>> > > My question is can I fill

[C++-sig] Boost.Python: How to fill a passed in buffer in Python

2012-05-01 Thread Ehsan Pi
Hello forum, I have a buffer in C++ that I need to fill in Python. The Address of the buffer is obtained through the GetAddress method which returns a void pointer to the buffer address. #include class Foo { public: Foo(const unsigned int length) { m_b

Re: [C++-sig] Wrapping and Passing HWND with Boost.Python

2012-05-01 Thread Niall Douglas
Cython is the easiest. But using the C API for this is extremely easy. Just pull the integer and cast to size_t and then void *. Niall On 1 May 2012 at 10:21, Ehsan Pi wrote: > Thanks Niall for your response and correction on HWND. > I'm new to Python (and Boost.Python for that matter) and thou

Re: [C++-sig] Wrapping and Passing HWND with Boost.Python

2012-05-01 Thread Ehsan Pi
Thanks again. I'll give it a try as soon as I get a chance. On Tue, May 1, 2012 at 10:37 AM, Roman Yakovenko wrote: > On Tue, May 1, 2012 at 5:25 PM, Ehsan Pi wrote: > > Thanks Roman, > > > > I believe these are not specific to py++ but boost.python, correct? > > Yes > > > What I > > mean is whe

Re: [C++-sig] Wrapping and Passing HWND with Boost.Python

2012-05-01 Thread Roman Yakovenko
On Tue, May 1, 2012 at 5:25 PM, Ehsan Pi wrote: > Thanks Roman, > > I believe these are not specific to py++ but boost.python, correct? Yes > What I > mean is whether it can be automated through the py++ wrapper, or do I have > to manually alter the py++ generated cpp file? Yes. py++ supports o

Re: [C++-sig] Wrapping and Passing HWND with Boost.Python

2012-05-01 Thread Ehsan Pi
Thanks Roman, I believe these are not specific to py++ but boost.python, correct? What I mean is whether it can be automated through the py++ wrapper, or do I have to manually alter the py++ generated cpp file? Regards, Ehsan On Mon, Apr 30, 2012 at 3:00 PM, Roman Yakovenko wrote: > On Mon, Apr

Re: [C++-sig] Wrapping and Passing HWND with Boost.Python

2012-05-01 Thread Ehsan Pi
Thanks Niall for your response and correction on HWND. I'm new to Python (and Boost.Python for that matter) and thought Python was not typed. If not, how can one convert Python integers to void*? Googled but didn't find an answer. Regards, Ehsan On Tue, May 1, 2012 at 9:18 AM, Niall Douglas wrot

Re: [C++-sig] Wrapping and Passing HWND with Boost.Python

2012-05-01 Thread Niall Douglas
A HWND is always a void * i.e. an opaque pointer. Unfortunately some people using BPL think that BPL can't handle opaque pointers, so they do fun stuff like use a thunk struct type for void * instead, and wrap the lot in manual pointer casting. It's far easier just to declare it an opaque point

Re: [C++-sig] Boost::Python: inheritance + optional parameters

2012-05-01 Thread Sybren A . Stüvel
On 27 April 2012 17:17, Jim Bosch wrote: > Have you tried using the keyword argument approach to handling default > arguments? More precisely, something like this should work, I think: > > def("override", func, (arg("x"), arg("y")=0, arg("z")=false)) > > (where func is the usual wrapper override