Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
PyIID.cpp File Reference
#include "PyXPCOM_std.h"
#include <nsIInterfaceInfoManager.h>

Go to the source code of this file.

Functions

PyObject * PyXPCOMMethod_IID (PyObject *self, PyObject *args)

Variables

nsIID Py_nsIID_NULL = {0,0,0,{0,0,0,0,0,0,0,0}}

Function Documentation

PyObject* PyXPCOMMethod_IID ( PyObject *  self,
PyObject *  args 
)

Definition at line 57 of file PyIID.cpp.

{
       PyObject *obIID;
       PyObject *obBuf;
       if ( PyArg_ParseTuple(args, "O", &obBuf)) {
              if (PyBuffer_Check(obBuf)) {
                     PyBufferProcs *pb = NULL;
                     pb = obBuf->ob_type->tp_as_buffer;
                     void *buf = NULL;
                     int size = (*pb->bf_getreadbuffer)(obBuf, 0, &buf);
                     if (size != sizeof(nsIID) || buf==NULL) {
                            PyErr_Format(PyExc_ValueError, "A buffer object to be converted to an IID must be exactly %d bytes long", sizeof(nsIID));
                            return NULL;
                     }
                     nsIID iid;
                     unsigned char *ptr = (unsigned char *)buf;
                     iid.m0 = XPT_SWAB32(*((PRUint32 *)ptr));
                     ptr = ((unsigned char *)buf) + offsetof(nsIID, m1);
                     iid.m1 = XPT_SWAB16(*((PRUint16 *)ptr));
                     ptr = ((unsigned char *)buf) + offsetof(nsIID, m2);
                     iid.m2 = XPT_SWAB16(*((PRUint16 *)ptr));
                     ptr = ((unsigned char *)buf) + offsetof(nsIID, m3);
                     for (int i=0;i<8;i++) {
                            iid.m3[i] = *((PRUint8 *)ptr);
                            ptr += sizeof(PRUint8);
                     }
                     return new Py_nsIID(iid);
              }
       }
       PyErr_Clear();
       // @pyparm string/Unicode|iidString||A string representation of an IID, or a ContractID.
       if ( !PyArg_ParseTuple(args, "O", &obIID) )
              return NULL;

       nsIID iid;
       if (!Py_nsIID::IIDFromPyObject(obIID, &iid))
              return NULL;
       return new Py_nsIID(iid);
}

Variable Documentation

nsIID Py_nsIID_NULL = {0,0,0,{0,0,0,0,0,0,0,0}}

Definition at line 54 of file PyIID.cpp.