logo       

method returning a string insted of a pointer: msg#00105

programming.swig

Subject: method returning a string insted of a pointer

Hi,
I've some problems converting with Swig (from C to Python) a function that returns a structure.

The structure that "readSignedDocWrap" returns is "SignedDoc":

typedef struct SignedDoc_st {
char* szFormat; // data format name
char* szFormatVer; // data format version
int nDataFiles;
DataFile** pDataFiles;
int nSignatures;
SignatureInfo** pSignatures;
int nNotaries;
NotaryInfo** pNotaries;
} SignedDoc;

The function "readSignedDocWrap" is:

%inline %{
SignedDoc* readSignedDocWrap(const char* szFileName)
{
SignedDoc *pSignedDoc;
readSignedDoc(&pSignedDoc, szFileName);
....
return pSignedDoc;
}
%}

The problem is that running this Python example:

**example.py:
python_object = mylib.readSignedDocWrap("hello.ddoc", 0)
print python_object.nDataFiles ## works well
print type(python_object.pDataFiles) ## says that pDataFiles is a "string" !!!!

The second print says that "pDataFiles" is a string and not a pointer.
How can I get, in the python example, the structure pointed by pDataFiles?
The problem is the same with the field "pNotaries" and "pSignatures".

Any ideas?
thank you very much

claudio





_______________________________________________
Swig maillist - Swig@xxxxxxxxxxxxxxx
http://mailman.cs.uchicago.edu/mailman/listinfo/swig



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise