Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
PyIVariant.cpp File Reference
#include "PyXPCOM_std.h"
#include "nsIVariant.h"

Go to the source code of this file.

Defines

#define GET_SIMPLE(Type, FuncGet, FuncConvert)
#define GET_ALLOCATED(Type, FuncGet, FuncConvert, FuncFree)
#define GET_ALLOCATED_SIZE(Type, FuncGet, FuncConvert, FuncFree)

Functions

static nsIVariantGetI (PyObject *self)
static PyObject * MyBool (PRBool v)
static PyObject * MyChar (char c)
static PyObject * MyUChar (PRUnichar c)
static PyObject * MyUnicode (PRUnichar *p)
static PyObject * MyISupports (nsISupports *p)
static PyObject * GetAsInterface (PyObject *self, PyObject *args)
PyObject * PyObject_FromVariantArray (nsIVariant *v)
static PyObject * GetAsArray (PyObject *self, PyObject *args)

Define Documentation

#define GET_ALLOCATED (   Type,
  FuncGet,
  FuncConvert,
  FuncFree 
)
Value:
static PyObject *FuncGet(PyObject *self, PyObject *args) { \
	nsIVariant *pI = GetI(self); \
       if (pI==NULL) return NULL; \
       if (!PyArg_ParseTuple(args, ":" #FuncGet)) return NULL; \
       Type t; \
       nsresult nr = pI->FuncGet(&t); \
       if (NS_FAILED(nr)) return PyXPCOM_BuildPyException(nr); \
       PyObject *ret = FuncConvert(t); \
       FuncFree(t); \
       return ret; \
}

Definition at line 87 of file PyIVariant.cpp.

#define GET_ALLOCATED_SIZE (   Type,
  FuncGet,
  FuncConvert,
  FuncFree 
)
Value:
static PyObject *FuncGet(PyObject *self, PyObject *args) { \
	nsIVariant *pI = GetI(self); \
       if (pI==NULL) return NULL; \
       if (!PyArg_ParseTuple(args, ":" #FuncGet)) return NULL; \
       Type t; PRUint32 size; \
       nsresult nr = pI->FuncGet(&size, &t); \
       if (NS_FAILED(nr)) return PyXPCOM_BuildPyException(nr); \
       PyObject *ret = FuncConvert(t, size); \
       FuncFree(t); \
       return ret; \
}

Definition at line 100 of file PyIVariant.cpp.

#define GET_SIMPLE (   Type,
  FuncGet,
  FuncConvert 
)
Value:
static PyObject *FuncGet(PyObject *self, PyObject *args) { \
	nsIVariant *pI = GetI(self); \
       if (pI==NULL) return NULL; \
       if (!PyArg_ParseTuple(args, ":" #FuncGet)) return NULL; \
       Type t; \
       nsresult nr = pI->FuncGet(&t); \
       if (NS_FAILED(nr)) return PyXPCOM_BuildPyException(nr); \
       return FuncConvert(t); \
}

Definition at line 76 of file PyIVariant.cpp.


Function Documentation

static PyObject* GetAsArray ( PyObject *  self,
PyObject *  args 
) [static]

Definition at line 147 of file PyIVariant.cpp.

                                                            {
       nsIVariant *pI = GetI(self);
       if (pI==NULL) return NULL;
       if (!PyArg_ParseTuple(args, ":GetAsArray")) return NULL;
       return PyObject_FromVariantArray(pI);
}

Here is the call graph for this function:

static PyObject* GetAsInterface ( PyObject *  self,
PyObject *  args 
) [static]

Definition at line 134 of file PyIVariant.cpp.

                                                                {
       nsIVariant *pI = GetI(self);
       if (pI==NULL) return NULL;
       if (!PyArg_ParseTuple(args, ":GetAsInterface")) return NULL;
       nsISupports *p;
       nsIID *iid;
       nsresult nr = pI->GetAsInterface(&iid, (void **)&p);
       if (NS_FAILED(nr)) return PyXPCOM_BuildPyException(nr);
       return Py_nsISupports::PyObjectFromInterface(p, *iid, PR_FALSE);
}

Here is the call graph for this function:

static nsIVariant* GetI ( PyObject *  self) [static]

Definition at line 48 of file PyIVariant.cpp.

                                        {
       nsIID iid = NS_GET_IID(nsIVariant);

       if (!Py_nsISupports::Check(self, iid)) {
              PyErr_SetString(PyExc_TypeError, "This object is not the correct interface");
              return NULL;
       }
       return (nsIVariant *)Py_nsISupports::GetI(self);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* MyBool ( PRBool  v) [static]

Definition at line 58 of file PyIVariant.cpp.

                                   {
       PyObject *ret = v ? Py_True : Py_False;
       Py_INCREF(ret);
       return ret;
}
static PyObject* MyChar ( char  c) [static]

Definition at line 63 of file PyIVariant.cpp.

                                 {
       return PyString_FromStringAndSize(&c, 1);
}
static PyObject* MyISupports ( nsISupports *  p) [static]

Definition at line 72 of file PyIVariant.cpp.

                                              {
       return Py_nsISupports::PyObjectFromInterface(p, NS_GET_IID(nsISupports), PR_FALSE);
}
static PyObject* MyUChar ( PRUnichar  c) [static]

Definition at line 66 of file PyIVariant.cpp.

                                       {
       return PyUnicode_FromPRUnichar(&c, 1);
}
static PyObject* MyUnicode ( PRUnichar p) [static]

Definition at line 69 of file PyIVariant.cpp.

                                          {
       return PyUnicode_FromPRUnichar(p, nsCRT::strlen(p));
}

Definition at line 718 of file VariantUtils.cpp.

{
       nsresult nr;
       NS_PRECONDITION(v, "NULL variant!");
       if (!v)
              return PyXPCOM_BuildPyException(NS_ERROR_INVALID_POINTER);
#ifdef NS_DEBUG
       PRUint16 dt;
       nr = v->GetDataType(&dt);
       NS_ABORT_IF_FALSE(dt == nsIDataType::VTYPE_ARRAY, "expected an array variant");
#endif
       nsIID iid;
       void *p;
       PRUint16 type;
       PRUint32 count;
       nr = v->GetAsArray(&type, &iid, &count, &p);
       if (NS_FAILED(nr)) return PyXPCOM_BuildPyException(nr);
       PyObject *ret = UnpackSingleArray(p, count, (PRUint8)type, &iid);
       FreeSingleArray(p, count, (PRUint8)type);
       nsMemory::Free(p);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function: