From: Jeff C. B. <jc...@it...> - 2006-05-02 16:35:59
|
Hi John, Unfortunately, the interface is provided by a 3rd party. I agree that the interface seems a little odd. Since, I only need one instance, I have wrapped the interface with a simpler one that does not even pass the handle. The new interface works for now. Thanks, Jeff -----Original Message----- From: John Pye [mailto:joh...@st...]=20 Sent: Friday, April 28, 2006 1:17 AM To: Jeff C. Britton Cc: swi...@li... Subject: Re: [Swig-user] Need help writing interface to a function. Hi Jeff Out of curiosity, with this line: BOOL P9050_Open (P9050_HANDLE *phPlx, DWORD dwVendorID, DWORD dwDeviceID, DWORD nCardNum, DWORD options); I would have expected to see the handle type, not a pointer to a handle. But it depends on your intended usage. Why not return a pointer that can be NULL in the case of failure, instead of a separate BOOL return value? Perhaps this would wrap more easily, too: P9050_HANDLE P9050_Open (DWORD dwVendorID, DWORD dwDeviceID, DWORD nCardNum, DWORD options); In the manual I came upon INPUT, OUTPUT and INOUT stuff in SWIG that is supposed to help you to know what the outputs of methods like this are. Perhaps you need to read up on that stuff, if it's relevant? See section 20.7.1 of the documentation. Cheers JP Jeff C. Britton wrote: > I have a pointer to pointer interface that I don't know how to wrap. > =20 > The 'C' interface is as follows: > =20 > In P9050.h > =20 > typedef unsigned long DWORD; > typedef struct P9050_STRUCT *P9050_HANDLE; BOOL P9050_Open=20 > (P9050_HANDLE *phPlx, DWORD dwVendorID, DWORD dwDeviceID, DWORD=20 > nCardNum, DWORD options); > =20 > In P9050.c > =20 > #include "p9050_lib.h" > typedef struct P9050_STRUCT > { > HANDLE hWD; > WD_CARD cardLock; > WD_PCI_SLOT pciSlot; > WD_CARD_REGISTER cardReg; > P9050_ADDR_DESC addrDesc[AD_PCI_BARS]; > P9050_INTERRUPT Int; > } P9050_STRUCT; > =20 > =20 > =20 > I am hoping that the details of P9050_STRUCT do not require wrapping. > This structure is hidden from the user of the P9050 library. > =20 > If the details are required, I'll have to post back with all the=20 > missing types, such as, HANDLE, WD_CARD, WD_PCI_SLOT. > =20 > I am new to SWIG and this mailing list. > =20 > Thanks. -- John Pye School of Mechanical and Manufacturing Engineering The University of New South Wales Sydney NSW 2052 Australia t +61 2 9385 5127 f +61 2 9663 1222 mailto:john.pye_AT_student_DOT_unsw.edu.au http://pye.dyndns.org/ |