On Wednesday 04 July 2007 8:37 pm, Doyon, Jean-Francois wrote:
> Hello,
>
> I've been using SIP to wrap a closed source binary SDK for Linux I have,
> with quite a bit of success considering I don't know much of C++ (Kudos to
> the SIP team!).
>
> Now I have a slight problem that I'm not sure to address so I'm wondring if
> someone could point me in the right direction.
>
> I have the following signature:
>
> LT_STATUS getDataByIndex(lt_uint32 index, const LTIMetadataRecord*& record)
> const;
>
> Everything here is fine, except for that *& notation which I haven't come
> across before.

For SIP you need to add the /Out/ annotation to the record argument. Current 
versions of SIP will then complain about using /Out/ with const arguments. 
That will be fixed in tonight's snapshot.

> The example C++ code does something like this to use this method:
>
>    for (i=0; i<numRecs; i++)
>    {
>       const LTIMetadataRecord* rec = NULL;
>       sts = db.getDataByIndex(i, rec);
>       ASSERT(LT_SUCCESS(sts));
>
>       dumpRecord(*rec);
>    }

If it's important that rec is initialised to NULL before calling 
getDataByIndex() then you will have to do this with some %MethodCode.

> The problem for me is that LTIMetadataRecord does NOT have constructors. 
> So I'm not sure what to pass getDataByIndex() for the second parameter.
>
> I tried something like:
>
> record = None
> db.getDataByIndex(index, record)
> print record

You will then use it like this...

sts, record = db.getDataByIndex(index)

> But "record" remains unchanged.  Of course, I can't create an instance of
> LTIMetadataRecord, so I'm not sure how else to go about this.
>
> Any have an idea, or ideally, a recipe? (Or maybe there's an example of
> something like this in PyQT/PyKDE?)
>
> Any help would be much appreciated!

The other thing to note is that C++ owns the record, ie. it will not be 
destroyed when the Python object is garbage collected. Use one of the 
transfer annotations if you want to change that.

Phil
_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to