[PyKDE] How to pass structure as a parameter to function

jim j jim_jack79 at yahoo.co.in
Wed May 25 11:09:35 BST 2005


hi,
       i'm encountering a problem while passing a
structure variable as a function parameter from
python. We have already generated the corresponding
wrapper code using SIP for my C library. In this
function one of the parameter is a structure pointer.
So python application has to pass a structure variable
to the function wrapper. My funtion is this:
                    
       ///////////////////
mymodule.h///////////////////////////////

typedef struct _drvObject
{
    unsigned long   drvHandle;
    TCHAR           msgQName[20];
    unsigned long   msgQId;
    unsigned long   protMsgQId;
    unsigned long   respMsgQId;
}DRVOBJECT, *P_DRVOBJECT;



                    OpenDriver(P_DRVOBJECT pDrvObject,
BOOL bSubscribeToDrvMsgs);



My wrapper code looks like this:


///////////////////////////////////sipmymodulemodule.c//////////////////////////////////////////////////
        `        static PyObject
*func_OpenDriver(PyObject *,PyObject *sipArgs)
{
 int sipArgsParsed = 0;

 {
  struct _drvObject * a0;
  int a1;

  if
(sipParseArgs(&sipArgsParsed,sipArgs,"vi",&a0,&a1))
  {
   APPDRV_STATUS sipRes;

   sipRes = OpenDriver(a0,a1);

   return
sipConvertFromNamedEnum(sipRes,sipEnum_APP_STATUS);
  }
 }

 /* Raise an exception if the arguments couldn't be
parsed. */

sipNoFunction(sipArgsParsed,sipNm_AppToDrvInterface_OpenDriver);

 return NULL;
}


i'm importing my module in python and calling this
function like below:
>>>import Mymodule
>>>Mymodule.OpenDriver(DRVOBJECT ,1)   /// Here i am
facing problem, i don't know how to pass the address
of structure variable to that library generated by sip
tool



                                                      
                                                      
                      hope somebody can help me in
solving this problem
                                                      
                                                      
                                              thanks
and regards
                                                      
                                                      
                jim

________________________________________________________________________
Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony




More information about the PyQt mailing list