Hi Jose,
Here is what I tried:
%extend gdcm::Image
{
%cstring_output_allocate_size(char **buffer, unsigned int *size, free(*$1) );
void my_get_data(char **buffer, unsigned int *size) {
*size = self->GetBufferLength();
*buffer = (char*)malloc(*size);
self->GetBuffer(*buffer);
}
When I call it from my python shell I am getting:
>>> i=r.GetImage()
>>> i.my_get_data()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "gdcm.py", line 1138, in my_get_data
def my_get_data(*args): return _gdcm.Image_my_get_data(*args)
TypeError: Image_my_get_data() takes exactly 3 arguments (1 given)
>>>
What I am doing wrong ?
Thanks again
-Mathieu
On Sun, May 4, 2008 at 7:46 PM, Jose Luna <
j-luna@...> wrote:
> See: %cstring_output_allocate_size(parm, szparm, release)
>
> Here:
http://www.swig.org/Doc1.3/Library.html#Library_nn12>
> This worked will for me (in python) when I needed to return binary data as a string.
>
> JLuna
>
>
>
> ----- Original Message ----
> From: Mathieu Malaterre <
mathieu.malaterre@...>
> To:
swig-user@...
> Sent: Sunday, May 4, 2008 11:44:58 AM
> Subject: [Swig-user] using cdata in python
>
> Hi there,
>
> I cannot understand how to use cdata to do this simple task. Let say
> I have this class:
>
> class A
> {
> public:
> unsigned int GetLength();
> void GetBuffer(char *strout);
> };
>
> In C++ you would use it this way:
>
> A a;
> char *buffer = new char[a.GetLength()];
> a.GetBuffer(buffer);
>
> I would like that it behave juste like python: readlines() function.
> It should return the properly allocated string as a PyString (may
> contains NULL character).
>
> Thanks a bunch !
>
> --
> Mathieu
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save $100.
> Use priority code J8TL2D2.
>
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone> _______________________________________________
> Swig-user mailing list
>
Swig-user@...
>
https://lists.sourceforge.net/lists/listinfo/swig-user>
>
>
>
>
> ____________________________________________________________________________________
> Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile. Try it now.
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ>
--
Mathieu
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user