« Return to Thread: using cdata in python

Re: using cdata in python

by Jose Luna-2 :: Rate this Message:

Reply to Author | View in Thread

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

-------------------------------------------------------------------------
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

 « Return to Thread: using cdata in python

LightInTheBox - Buy quality products at wholesale price