[PyQt] SIP first use questions

Phil Thompson phil at riverbankcomputing.com
Fri Jul 22 10:45:27 BST 2011


On Thu, 21 Jul 2011 13:41:32 +0200, Linos <info at linos.es> wrote:
> Hi,
> 	i am trying to do my first library wrapper to the libfprint c lib 
> (http://www.freedesktop.org/wiki/Software/fprint/libfprint) using SIP, i
> have 
> any doubts, sorry if any or all of them are pretty obvious but i develop
> nearly 
> ever on python, a bit on Qt C++ so all of this it is a bit strange for
me.
> 
> 1- How should i wrap this function from fprint.h?
> 
> 	struct fp_dscv_print **fp_discover_prints();
> 
>       I get this info from sip "sip: fp_discover_devs() unsupported
>       function
> return type - provide %MethodCode and a C signature" I have read in the 
> documentation the examples about %AccessCode and %MethodCode but i don't

> understand how to use here.

First thing is to decide how you want to represent the returned value in
Python. Assuming you are wrapping struct fp_dscv_print then you will
probably want to return a list of them. In which case you are actually
returning a SIP_PYLIST and the %MethodCode you provide needs to do the
necessary conversion.

> 2- How should i wrap a static inline function defined in fprint.h like
> this:
> 
> static inline int fp_enroll_finger(struct fp_dev *dev,
> 	struct fp_print_data **print_data)
> {
> 	return fp_enroll_finger_img(dev, print_data, NULL);
> }

There is nothing special about inline functions - that's an implementation
detail.

> 3- i had to define all the include dirs manually with:
> 
> makefile.extra_include_dirs = ["/tmp/libfprint-0.4.0", 
> "/tmp/libfprint-0.4.0/libfprint", "/usr/include/glib-1.2", 
> "/usr/lib/glib/include", "/usr/include/libusb-1.0"]
> 
> I am pretty sure that should be a much better way to do this but i can't
> find how.

I don't see how SIP can be expected to work those out for itself.

Phil


More information about the PyQt mailing list