Add support for nsIVariant, and fix a number of other bugs. Replace

nsAllocator with nsMemory.

Not part of the build; using global "a=" for this part of the tree.


git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_0_BRANCH@120173 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mhammond%skippinet.com.au
2002-04-29 05:32:45 +00:00
parent 509866e746
commit 50d2799bf8
28 changed files with 968 additions and 273 deletions

View File

@@ -82,6 +82,7 @@ CPPSRCS= \
PyIInterfaceInfoManager.cpp \
PyISimpleEnumerator.cpp \
PyISupports.cpp \
PyIVariant.cpp \
Pyxpt_info.cpp \
TypeObject.cpp \
VariantUtils.cpp \

View File

@@ -13,7 +13,7 @@
* Portions created by ActiveState Tool Corp. are Copyright (C) 2000, 2001
* ActiveState Tool Corp. All Rights Reserved.
*
* Contributor(s): Mark Hammond <MarkH@ActiveState.com> (original author)
* Contributor(s): Mark Hammond <mhammond@skippinet.com.au> (original author)
*
*/
@@ -115,7 +115,7 @@ PyG_Base::PyG_Base(PyObject *instance, const nsIID &iid)
PyObject *real_repr = PyObject_Repr(real_instance);
PYXPCOM_LOG_DEBUG("PyG_Base created at %p\n instance_repr=%s\n IID=%s\n", this, PyString_AsString(real_repr), iid_repr);
nsAllocator::Free(iid_repr);
nsMemory::Free(iid_repr);
Py_XDECREF(real_instance);
Py_XDECREF(real_repr);
}
@@ -281,9 +281,11 @@ done:
}
Py_XDECREF(obIID);
Py_XDECREF(obParamDesc);
if (result==NULL) // we had an error.
if (result==NULL) { // we had an error.
PyErr_Clear(); // but are not reporting it back to Python itself!
// return our obISupports. If NULL, we are really hosed and nothing we can do.
return obISupports;
}
// Dont need to return this - we have a better result.
Py_XDECREF(obISupports);
return result;

View File

@@ -13,7 +13,7 @@
* Portions created by ActiveState Tool Corp. are Copyright (C) 2000, 2001
* ActiveState Tool Corp. All Rights Reserved.
*
* Contributor(s): Mark Hammond <MarkH@ActiveState.com> (original author)
* Contributor(s): Mark Hammond <mhammond@skippinet.com.au> (original author)
*
*/
@@ -65,7 +65,7 @@ PyG_nsIModule::GetClassObject(nsIComponentManager *aCompMgr,
NS_PRECONDITION(r_classObj, "null pointer");
*r_classObj = nsnull;
CEnterLeavePython _celp;
PyObject *cm = MakeInterfaceParam(aCompMgr, &NS_GET_IID(nsIComponentManagerObsolete));
PyObject *cm = Py_nsISupports::PyObjectFromInterface(aCompMgr, NS_GET_IID(nsIComponentManagerObsolete), PR_TRUE);
PyObject *iid = Py_nsIID::PyObjectFromIID(aIID);
PyObject *clsid = Py_nsIID::PyObjectFromIID(aClass);
const char *methodName = "getClassObject";
@@ -95,8 +95,8 @@ PyG_nsIModule::RegisterSelf(nsIComponentManager *aCompMgr,
NS_PRECONDITION(aCompMgr, "null pointer");
NS_PRECONDITION(aPath, "null pointer");
CEnterLeavePython _celp;
PyObject *cm = MakeInterfaceParam(aCompMgr, &NS_GET_IID(nsIComponentManagerObsolete));
PyObject *path = MakeInterfaceParam(aPath, &NS_GET_IID(nsIFile));
PyObject *cm = Py_nsISupports::PyObjectFromInterface(aCompMgr, NS_GET_IID(nsIComponentManagerObsolete), PR_TRUE);
PyObject *path = Py_nsISupports::PyObjectFromInterface(aPath, NS_GET_IID(nsIFile), PR_TRUE);
const char *methodName = "registerSelf";
nsresult nr = InvokeNativeViaPolicy(methodName, NULL, "OOzz", cm, path, registryLocation, componentType);
Py_XDECREF(cm);
@@ -112,8 +112,8 @@ PyG_nsIModule::UnregisterSelf(nsIComponentManager* aCompMgr,
NS_PRECONDITION(aCompMgr, "null pointer");
NS_PRECONDITION(aPath, "null pointer");
CEnterLeavePython _celp;
PyObject *cm = MakeInterfaceParam(aCompMgr, &NS_GET_IID(nsIComponentManagerObsolete));
PyObject *path = MakeInterfaceParam(aPath, &NS_GET_IID(nsIFile));
PyObject *cm = Py_nsISupports::PyObjectFromInterface(aCompMgr, NS_GET_IID(nsIComponentManagerObsolete), PR_TRUE);
PyObject *path = Py_nsISupports::PyObjectFromInterface(aPath, NS_GET_IID(nsIFile), PR_TRUE);
const char *methodName = "unregisterSelf";
nsresult nr = InvokeNativeViaPolicy(methodName, NULL, "OOz", cm, path, registryLocation);
Py_XDECREF(cm);
@@ -127,7 +127,8 @@ PyG_nsIModule::CanUnload(nsIComponentManager *aCompMgr, PRBool *okToUnload)
NS_PRECONDITION(aCompMgr, "null pointer");
NS_PRECONDITION(okToUnload, "null pointer");
CEnterLeavePython _celp;
PyObject *cm = MakeInterfaceParam(aCompMgr, &NS_GET_IID(nsIComponentManagerObsolete));
// we are shutting down - don't ask for a nice wrapped object.
PyObject *cm = Py_nsISupports::PyObjectFromInterface(aCompMgr, NS_GET_IID(nsIComponentManagerObsolete), PR_TRUE, PR_FALSE);
const char *methodName = "canUnload";
PyObject *ret = NULL;
nsresult nr = InvokeNativeViaPolicy(methodName, &ret, "O", cm);
@@ -183,8 +184,8 @@ NS_IMETHODIMP PyG_nsIComponentLoader::Init(nsIComponentManager *aCompMgr, nsISup
{
CEnterLeavePython _celp;
const char *methodName = "init";
PyObject *c = MakeInterfaceParam(aCompMgr, &NS_GET_IID(nsIComponentManagerObsolete));
PyObject *r = MakeInterfaceParam(aRegistry, &NS_GET_IID(nsISupports));
PyObject *c = Py_nsISupports::PyObjectFromInterface(aCompMgr, NS_GET_IID(nsIComponentManagerObsolete), PR_TRUE);
PyObject *r = Py_nsISupports::PyObjectFromInterface(aRegistry, NS_GET_IID(nsISupports), PR_TRUE);
nsresult nr = InvokeNativeViaPolicy(methodName, NULL, "OO", c, r);
Py_XDECREF(c);
Py_XDECREF(r);
@@ -214,7 +215,7 @@ NS_IMETHODIMP PyG_nsIComponentLoader::AutoRegisterComponents(PRInt32 aWhen, nsIF
{
CEnterLeavePython _celp;
const char *methodName = "autoRegisterComponents";
PyObject *c = MakeInterfaceParam(aDirectory, &NS_GET_IID(nsIFile));
PyObject *c = Py_nsISupports::PyObjectFromInterface(aDirectory, NS_GET_IID(nsIFile), PR_TRUE);
nsresult nr = InvokeNativeViaPolicy(methodName, NULL, "iO", aWhen, c);
Py_XDECREF(c);
return nr;
@@ -226,7 +227,7 @@ NS_IMETHODIMP PyG_nsIComponentLoader::AutoRegisterComponent(PRInt32 aWhen, nsIFi
CEnterLeavePython _celp;
const char *methodName = "autoRegisterComponent";
PyObject *ret = NULL;
PyObject *c = MakeInterfaceParam(aComponent, &NS_GET_IID(nsIFile));
PyObject *c = Py_nsISupports::PyObjectFromInterface(aComponent, NS_GET_IID(nsIFile), PR_TRUE);
nsresult nr = InvokeNativeViaPolicy(methodName, &ret, "iO", aWhen, c);
Py_XDECREF(c);
if (NS_SUCCEEDED(nr)) {
@@ -244,7 +245,7 @@ NS_IMETHODIMP PyG_nsIComponentLoader::AutoUnregisterComponent(PRInt32 aWhen, nsI
CEnterLeavePython _celp;
const char *methodName = "autoUnregisterComponent";
PyObject *ret = NULL;
PyObject *c = MakeInterfaceParam(aComponent, &NS_GET_IID(nsIFile));
PyObject *c = Py_nsISupports::PyObjectFromInterface(aComponent, NS_GET_IID(nsIFile), PR_TRUE);
nsresult nr = InvokeNativeViaPolicy(methodName, &ret, "iO", aWhen, c);
Py_XDECREF(c);
if (NS_SUCCEEDED(nr)) {

View File

@@ -13,7 +13,7 @@
* Portions created by ActiveState Tool Corp. are Copyright (C) 2000, 2001
* ActiveState Tool Corp. All Rights Reserved.
*
* Contributor(s): Mark Hammond <MarkH@ActiveState.com> (original author)
* Contributor(s): Mark Hammond <mhammond@skippinet.com.au> (original author)
*
*/
@@ -99,7 +99,7 @@ done:
// good error reporting is critical for users to know WTF
// is going on - especially with TypeErrors etc in their
// return values (ie, after the Python code has successfully
// existed, but we encountered errors unpacking their
// exited, but we encountered errors unpacking the
// result values for the COM caller - there is literally no
// way to catch these exceptions from Python code, as their
// is no Python function on the call-stack)

View File

@@ -13,7 +13,7 @@
* Portions created by ActiveState Tool Corp. are Copyright (C) 2001
* ActiveState Tool Corp. All Rights Reserved.
*
* Contributor(s): Mark Hammond <MarkH@ActiveState.com> (original author)
* Contributor(s): Mark Hammond <mhammond@skippinet.com.au> (original author)
*
*/
@@ -111,7 +111,7 @@ Py_nsIClassInfo::getattr(const char *name)
Py_END_ALLOW_THREADS;
GETATTR_CHECK_RESULT(nr);
ret = MakeStringOrNone(str_ret);
nsAllocator::Free(str_ret);
nsMemory::Free(str_ret);
} else if (strcmp(name, "classDescription")==0) {
char *str_ret;
Py_BEGIN_ALLOW_THREADS;
@@ -119,7 +119,7 @@ Py_nsIClassInfo::getattr(const char *name)
Py_END_ALLOW_THREADS;
GETATTR_CHECK_RESULT(nr);
ret = MakeStringOrNone(str_ret);
nsAllocator::Free(str_ret);
nsMemory::Free(str_ret);
} else if (strcmp(name, "classID")==0) {
nsIID *iid;
Py_BEGIN_ALLOW_THREADS;
@@ -127,7 +127,7 @@ Py_nsIClassInfo::getattr(const char *name)
Py_END_ALLOW_THREADS;
GETATTR_CHECK_RESULT(nr);
ret = Py_nsIID::PyObjectFromIID(*iid);
nsAllocator::Free(iid);
nsMemory::Free(iid);
} else if (strcmp(name, "implementationLanguage")==0) {
PRUint32 i;
Py_BEGIN_ALLOW_THREADS;

View File

@@ -13,7 +13,7 @@
* Portions created by ActiveState Tool Corp. are Copyright (C) 2000, 2001
* ActiveState Tool Corp. All Rights Reserved.
*
* Contributor(s): Mark Hammond <MarkH@ActiveState.com> (original author)
* Contributor(s): Mark Hammond <mhammond@skippinet.com.au> (original author)
*
*/
@@ -118,8 +118,8 @@ static PyObject *PyCLSIDToContractID(PyObject *self, PyObject *args)
PyObject *ob_pid = PyString_FromString(ret_pid);
PyObject *ob_class = PyString_FromString(ret_class);
PyObject *ret = Py_BuildValue("OO", ob_pid, ob_class);
nsAllocator::Free(ret_pid);
nsAllocator::Free(ret_class);
nsMemory::Free(ret_pid);
nsMemory::Free(ret_class);
Py_XDECREF(ob_pid);
Py_XDECREF(ob_class);
return ret;

View File

@@ -13,7 +13,7 @@
* Portions created by ActiveState Tool Corp. are Copyright (C) 2000, 2001
* ActiveState Tool Corp. All Rights Reserved.
*
* Contributor(s): Mark Hammond <MarkH@ActiveState.com> (original author)
* Contributor(s): Mark Hammond <mhammond@skippinet.com.au> (original author)
*
*/
@@ -81,7 +81,7 @@ Py_nsIID::IIDFromPyObject(PyObject *ob, nsIID *pRet) {
PRBool ok = PR_TRUE;
nsIID iid;
if (ob==NULL) {
PyErr_SetString(PyExc_RuntimeError, "The object is invalid!");
PyErr_SetString(PyExc_RuntimeError, "The IID object is invalid!");
return PR_FALSE;
}
if (PyString_Check(ob)) {
@@ -161,7 +161,7 @@ Py_nsIID::PyTypeMethod_getattr(PyObject *self, char *name)
PyObject *ret;
if (iid_repr != nsnull) {
ret = PyString_FromString(iid_repr);
nsAllocator::Free(iid_repr);
nsMemory::Free(iid_repr);
} else
ret = PyString_FromString("<cant get IID info!>");
return ret;
@@ -184,7 +184,7 @@ Py_nsIID::PyTypeMethod_repr(PyObject *self)
char buf[256];
char *sziid = s_iid->m_iid.ToString();
sprintf(buf, "_xpcom.IID('%s')", sziid);
nsAllocator::Free(sziid);
nsMemory::Free(sziid);
return PyString_FromString(buf);
}
@@ -194,7 +194,7 @@ Py_nsIID::PyTypeMethod_str(PyObject *self)
Py_nsIID *s_iid = (Py_nsIID *)self;
char *sziid = s_iid->m_iid.ToString();
PyObject *ret = PyString_FromString(sziid);
nsAllocator::Free(sziid);
nsMemory::Free(sziid);
return ret;
}

View File

@@ -13,7 +13,7 @@
* Portions created by ActiveState Tool Corp. are Copyright (C) 2000, 2001
* ActiveState Tool Corp. All Rights Reserved.
*
* Contributor(s): Mark Hammond <MarkH@ActiveState.com> (original author)
* Contributor(s): Mark Hammond <mhammond@skippinet.com.au> (original author)
*
*/
@@ -80,7 +80,7 @@ static PyObject *DoPyRead_Size(nsIInputStream *pI, PRUint32 n)
if (NS_FAILED(r))
return PyXPCOM_BuildPyException(r);
}
char *buf = (char *)nsAllocator::Alloc(n);
char *buf = (char *)nsMemory::Alloc(n);
if (buf==NULL) {
PyErr_NoMemory();
return NULL;
@@ -108,7 +108,7 @@ static PyObject *DoPyRead_Size(nsIInputStream *pI, PRUint32 n)
}
} else
PyXPCOM_BuildPyException(r);
nsAllocator::Free(buf);
nsMemory::Free(buf);
return rc;
}

View File

@@ -13,7 +13,7 @@
* Portions created by ActiveState Tool Corp. are Copyright (C) 2000, 2001
* ActiveState Tool Corp. All Rights Reserved.
*
* Contributor(s): Mark Hammond <MarkH@ActiveState.com> (original author)
* Contributor(s): Mark Hammond <mhammond@skippinet.com.au> (original author)
*
*/
@@ -57,7 +57,7 @@ static PyObject *PyGetName(PyObject *self, PyObject *args)
if ( NS_FAILED(r) )
return PyXPCOM_BuildPyException(r);
PyObject *ret = PyString_FromString(name);
nsAllocator::Free(name);
nsMemory::Free(name);
return ret;
}
@@ -78,7 +78,7 @@ static PyObject *PyGetIID(PyObject *self, PyObject *args)
if ( NS_FAILED(r) )
return PyXPCOM_BuildPyException(r);
PyObject *ret = Py_nsIID::PyObjectFromIID(*iid_ret);
nsAllocator::Free(iid_ret);
nsMemory::Free(iid_ret);
return ret;
}

View File

@@ -13,7 +13,7 @@
* Portions created by ActiveState Tool Corp. are Copyright (C) 2000, 2001
* ActiveState Tool Corp. All Rights Reserved.
*
* Contributor(s): Mark Hammond <MarkH@ActiveState.com> (original author)
* Contributor(s): Mark Hammond <mhammond@skippinet.com.au> (original author)
*
*/
@@ -117,7 +117,7 @@ static PyObject *PyGetNameForIID(PyObject *self, PyObject *args)
return PyXPCOM_BuildPyException(r);
PyObject *ret = PyString_FromString(ret_name);
nsAllocator::Free(ret_name);
nsMemory::Free(ret_name);
return ret;
}
@@ -140,7 +140,7 @@ static PyObject *PyGetIIDForName(PyObject *self, PyObject *args)
return PyXPCOM_BuildPyException(r);
PyObject *ret = Py_nsIID::PyObjectFromIID(*iid_ret);
nsAllocator::Free(iid_ret);
nsMemory::Free(iid_ret);
return ret;
}

View File

@@ -13,7 +13,7 @@
* Portions created by ActiveState Tool Corp. are Copyright (C) 2000, 2001
* ActiveState Tool Corp. All Rights Reserved.
*
* Contributor(s): Mark Hammond <MarkH@ActiveState.com> (original author)
* Contributor(s): Mark Hammond <mhammond@skippinet.com.au> (original author)
*
*/
@@ -120,51 +120,11 @@ Py_nsISupports::Constructor(nsISupports *pInitObj, const nsIID &iid)
type);
}
/*static*/PRBool
Py_nsISupports::InterfaceFromPyObject(PyObject *ob,
const nsIID &iid,
nsISupports **ppv,
PRBool bNoneOK,
PRBool bTryAutoWrap /* = PR_TRUE */)
PRBool
Py_nsISupports::InterfaceFromPyISupports(PyObject *ob,
const nsIID &iid,
nsISupports **ppv)
{
if ( ob == NULL )
{
// don't overwrite an error message
if ( !PyErr_Occurred() )
PyErr_SetString(PyExc_TypeError, "The Python object is invalid");
return PR_FALSE;
}
if ( ob == Py_None )
{
if ( bNoneOK )
{
*ppv = NULL;
return PR_TRUE;
}
else
{
PyErr_SetString(PyExc_TypeError, "None is not a invalid interface object in this context");
return PR_FALSE;
}
}
if (PyInstance_Check(ob)) {
// Get the _comobj_ attribute
PyObject *use_ob = PyObject_GetAttrString(ob, "_comobj_");
if (use_ob==NULL) {
PyErr_Clear();
if (bTryAutoWrap)
// Try and auto-wrap it - errors will leave Py exception set,
return PyXPCOM_XPTStub::AutoWrapPythonInstance(ob, iid, ppv);
PyErr_SetString(PyExc_TypeError, "The Python instance can not be converted to an XP COM object");
return PR_FALSE;
} else
ob = use_ob;
} else {
Py_XINCREF(ob);
}
nsISupports *pis;
PRBool rc = PR_FALSE;
if ( !Check(ob) )
@@ -204,13 +164,82 @@ Py_nsISupports::InterfaceFromPyObject(PyObject *ob,
/* note: the QI added a ref for the return value */
}
}
rc = PR_TRUE;
done:
Py_XDECREF(ob);
return rc;
}
PRBool
Py_nsISupports::InterfaceFromPyObject(PyObject *ob,
const nsIID &iid,
nsISupports **ppv,
PRBool bNoneOK,
PRBool bTryAutoWrap /* = PR_TRUE */)
{
if ( ob == NULL )
{
// don't overwrite an error message
if ( !PyErr_Occurred() )
PyErr_SetString(PyExc_TypeError, "The Python object is invalid");
return PR_FALSE;
}
if ( ob == Py_None )
{
if ( bNoneOK )
{
*ppv = NULL;
return PR_TRUE;
}
else
{
PyErr_SetString(PyExc_TypeError, "None is not a invalid interface object in this context");
return PR_FALSE;
}
}
// support nsIVariant
if (iid.Equals(NS_GET_IID(nsIVariant)) || iid.Equals(NS_GET_IID(nsIWritableVariant))) {
// Check it is not already nsIVariant
if (PyInstance_Check(ob)) {
PyObject *sub_ob = PyObject_GetAttrString(ob, "_comobj_");
if (sub_ob==NULL) {
PyErr_Clear();
} else {
if (InterfaceFromPyISupports(sub_ob, iid, ppv)) {
Py_DECREF(sub_ob);
return PR_TRUE;
}
PyErr_Clear();
Py_DECREF(sub_ob);
}
}
*ppv = PyObject_AsVariant(ob);
return *ppv != NULL;
}
// end of variant support.
if (PyInstance_Check(ob)) {
// Get the _comobj_ attribute
PyObject *use_ob = PyObject_GetAttrString(ob, "_comobj_");
if (use_ob==NULL) {
PyErr_Clear();
if (bTryAutoWrap)
// Try and auto-wrap it - errors will leave Py exception set,
return PyXPCOM_XPTStub::AutoWrapPythonInstance(ob, iid, ppv);
PyErr_SetString(PyExc_TypeError, "The Python instance can not be converted to an XPCOM object");
return PR_FALSE;
} else
ob = use_ob;
} else {
Py_INCREF(ob);
}
PRBool rc = InterfaceFromPyISupports(ob, iid, ppv);
Py_DECREF(ob);
return rc;
}
// Interface conversions
/*static*/void
Py_nsISupports::RegisterInterface( const nsIID &iid, PyTypeObject *t)
@@ -226,6 +255,28 @@ Py_nsISupports::RegisterInterface( const nsIID &iid, PyTypeObject *t)
}
}
/*static */PyObject *
Py_nsISupports::PyObjectFromInterfaceOrVariant(nsISupports *pis,
const nsIID &riid,
PRBool bAddRef,
PRBool bMakeNicePyObject /* = PR_TRUE */)
{
// Quick exit.
if (pis==NULL) {
Py_INCREF(Py_None);
return Py_None;
}
if (riid.Equals(NS_GET_IID(nsIVariant))) {
PyObject *ret = PyObject_FromVariant((nsIVariant *)pis);
// If we were asked not to add a reference, then there
// will be a spare reference on pis() - remove it.
if (!bAddRef)
pis->Release();
return ret;
}
return PyObjectFromInterface(pis, riid, bAddRef, bMakeNicePyObject);
}
/*static */PyObject *
Py_nsISupports::PyObjectFromInterface(nsISupports *pis,
const nsIID &riid,
@@ -241,7 +292,6 @@ Py_nsISupports::PyObjectFromInterface(nsISupports *pis,
// If the IID is for nsISupports, dont bother with
// a map lookup as we know the type!
if (!riid.Equals(NS_GET_IID(nsISupports))) {
// Look up the map
PyObject *obiid = Py_nsIID::PyObjectFromIID(riid);
if (!obiid) return NULL;

View File

@@ -13,7 +13,7 @@
* Portions created by ActiveState Tool Corp. are Copyright (C) 2000, 2001
* ActiveState Tool Corp. All Rights Reserved.
*
* Contributor(s): Mark Hammond <MarkH@ActiveState.com> (original author)
* Contributor(s): Mark Hammond <mhammond@skippinet.com.au> (original author)
*
*/
@@ -176,9 +176,14 @@ public:
// see the correct xpcom.client.Interface object even when calling
// xpcom function directly.
static PyObject *PyObjectFromInterface(nsISupports *ps,
const nsIID &iid,
PRBool bAddRef,
PRBool bMakeNicePyObject = PR_TRUE);
const nsIID &iid,
PRBool bAddRef,
PRBool bMakeNicePyObject = PR_TRUE);
static PyObject *PyObjectFromInterfaceOrVariant(nsISupports *ps,
const nsIID &iid,
PRBool bAddRef,
PRBool bMakeNicePyObject = PR_TRUE);
// Given a Python object that is a registered COM type, return a given
// interface pointer on its underlying object, with a NEW REFERENCE ADDED.
@@ -187,6 +192,8 @@ public:
// provided to stop accidental recursion should the object returned by
// the wrap process itself be in instance (where it should already be
// a COM object.
// If |iid|==nsIVariant, then arbitary Python objects will be wrapped
// in an nsIVariant.
static PRBool InterfaceFromPyObject(
PyObject *ob,
const nsIID &iid,
@@ -194,6 +201,13 @@ public:
PRBool bNoneOK,
PRBool bTryAutoWrap = PR_TRUE);
// Given a Py_nsISupports, return an interface.
// Object *must* be Py_nsISupports - there is no
// "autowrap", no "None" support, etc
static PRBool InterfaceFromPyISupports(PyObject *ob,
const nsIID &iid,
nsISupports **ppv);
static Py_nsISupports *Constructor(nsISupports *pInitObj, const nsIID &iid);
// The Python methods
static PyObject *QueryInterface(PyObject *self, PyObject *args);
@@ -459,6 +473,7 @@ private:
PRUint32 GetSizeIs( int var_index, PRBool is_arg1);
PRBool SetSizeIs( int var_index, PRBool is_arg1, PRUint32 new_size);
PRBool CanSetSizeIs( int var_index, PRBool is_arg1 );
nsIInterfaceInfo *GetInterfaceInfo(); // NOTE: no ref count on result.
nsXPTCMiniVariant* m_params;
@@ -466,7 +481,7 @@ private:
int m_method_index;
PythonTypeDescriptor *m_python_type_desc_array;
int m_num_type_descs;
nsCOMPtr<nsIInterfaceInfo> m_interface_info;
};
// Misc converters.
@@ -478,6 +493,8 @@ PyObject *PyObject_FromXPTParamDescriptor( const XPTParamDescriptor *d);
PyObject *PyObject_FromXPTMethodDescriptor( const XPTMethodDescriptor *d);
PyObject *PyObject_FromXPTConstant( const XPTConstDescriptor *d);
nsIVariant *PyObject_AsVariant( PyObject *ob);
PyObject *PyObject_FromVariant( nsIVariant *v);
// DLL reference counting functions.
// Although we maintain the count, we never actually
@@ -669,5 +686,6 @@ PyXPCOM_INTERFACE_DECLARE(Py_nsIInterfaceInfo, nsIInterfaceInfo, PyMethods_IInte
PyXPCOM_INTERFACE_DECLARE(Py_nsIServiceManager, nsIServiceManager, PyMethods_IServiceManager)
PyXPCOM_INTERFACE_DECLARE(Py_nsIInputStream, nsIInputStream, PyMethods_IInputStream)
PyXPCOM_ATTR_INTERFACE_DECLARE(Py_nsIClassInfo, nsIClassInfo, PyMethods_IClassInfo)
PyXPCOM_ATTR_INTERFACE_DECLARE(Py_nsIVariant, nsIVariant, PyMethods_IVariant)
#endif // __PYXPCOM_H__

View File

@@ -13,7 +13,7 @@
* Portions created by ActiveState Tool Corp. are Copyright (C) 2000, 2001
* ActiveState Tool Corp. All Rights Reserved.
*
* Contributor(s): Mark Hammond <MarkH@ActiveState.com> (original author)
* Contributor(s): Mark Hammond <mhammond@skippinet.com.au> (original author)
*
*/
@@ -38,6 +38,7 @@
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsIInputStream.h"
#include "nsIVariant.h"
#include "nsXPIDLString.h"

View File

@@ -13,7 +13,7 @@
* Portions created by ActiveState Tool Corp. are Copyright (C) 2000, 2001
* ActiveState Tool Corp. All Rights Reserved.
*
* Contributor(s): Mark Hammond <MarkH@ActiveState.com> (original author)
* Contributor(s): Mark Hammond <mhammond@skippinet.com.au> (original author)
*
*/
@@ -131,7 +131,7 @@ PyXPCOM_TypeObject::Py_repr(PyObject *self)
// XXX - need some sort of buffer overflow.
char buf[512];
sprintf(buf, "<XPCOM object (%s) at 0x%p/0x%p>", iid_repr, self, pis->m_obj);
nsAllocator::Free(iid_repr);
nsMemory::Free(iid_repr);
return PyString_FromString(buf);
}
@@ -153,7 +153,7 @@ PyXPCOM_TypeObject::Py_str(PyObject *self)
ret = Py_repr(self);
else
ret = PyString_FromString(val);
if (val) nsAllocator::Free(val);
if (val) nsMemory::Free(val);
return ret;
}

File diff suppressed because it is too large Load Diff

View File

@@ -13,7 +13,7 @@
* Portions created by ActiveState Tool Corp. are Copyright (C) 2000, 2001
* ActiveState Tool Corp. All Rights Reserved.
*
* Contributor(s): Mark Hammond <MarkH@ActiveState.com> (original author)
* Contributor(s): Mark Hammond <mhammond@skippinet.com.au> (original author)
*
*/
@@ -86,7 +86,7 @@ PRBool PyXPCOM_ThreadState_Ensure()
if (PyXPCOM_InterpreterState==NULL) {
Py_FatalError("Can not setup thread state, as have no interpreter state");
}
pData = (ThreadData *)nsAllocator::Alloc(sizeof(ThreadData));
pData = (ThreadData *)nsMemory::Alloc(sizeof(ThreadData));
if (!pData)
Py_FatalError("Out of memory allocating thread state.");
memset(pData, 0, sizeof(*pData));
@@ -128,7 +128,7 @@ void PyXPCOM_ThreadState_Free()
PyThreadState *thisThreadState = pData->ts;
PyThreadState_Delete(thisThreadState);
PR_SetThreadPrivate(tlsIndex, NULL);
nsAllocator::Free(pData);
nsMemory::Free(pData);
}
void PyXPCOM_ThreadState_Clear()

View File

@@ -15,7 +15,7 @@
# Portions created by ActiveState are Copyright (C) 2000 ActiveState.
# All Rights Reserved.
#
# Contributor(s): Mark Hammond <MarkH@ActiveState.com>
# Contributor(s): Mark Hammond <mhammond@skippinet.com.au>
#
DIRS = \
@@ -52,6 +52,7 @@ CPP_OBJS= \
.\$(OBJDIR)\PyIInterfaceInfoManager.obj \
.\$(OBJDIR)\PyISimpleEnumerator.obj \
.\$(OBJDIR)\PyISupports.obj \
.\$(OBJDIR)\PyIVariant.obj \
.\$(OBJDIR)\Pyxpt_info.obj \
.\$(OBJDIR)\TypeObject.obj \
.\$(OBJDIR)\VariantUtils.obj \

View File

@@ -13,7 +13,7 @@
* Portions created by ActiveState Tool Corp. are Copyright (C) 2000, 2001
* ActiveState Tool Corp. All Rights Reserved.
*
* Contributor(s): Mark Hammond <MarkH@ActiveState.com> (original author)
* Contributor(s): Mark Hammond <mhammond@skippinet.com.au> (original author)
*
*/
@@ -63,6 +63,7 @@ PyXPCOM_INTERFACE_DEFINE(Py_nsISimpleEnumerator, nsISimpleEnumerator, PyMethods_
PyXPCOM_INTERFACE_DEFINE(Py_nsIInterfaceInfo, nsIInterfaceInfo, PyMethods_IInterfaceInfo)
PyXPCOM_INTERFACE_DEFINE(Py_nsIInputStream, nsIInputStream, PyMethods_IInputStream)
PyXPCOM_INTERFACE_DEFINE(Py_nsIClassInfo, nsIClassInfo, PyMethods_IClassInfo)
PyXPCOM_INTERFACE_DEFINE(Py_nsIVariant, nsIVariant, PyMethods_IVariant)
////////////////////////////////////////////////////////////
// This is the main entry point called by the Python component
@@ -594,6 +595,7 @@ init_xpcom() {
Py_nsIInterfaceInfo::InitType(dict);
Py_nsIInputStream::InitType(dict);
Py_nsIClassInfo::InitType(dict);
Py_nsIVariant::InitType(dict);
// yet another
{ // temp scope nsIComponentManagerObsolete hack :(