Get pyxpcom working with the recent nsXPTCStubBase changes.
Not part of the default build. git-svn-id: svn://10.0.0.236/trunk@218425 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -356,7 +356,7 @@ PyG_Base::QueryInterface(REFNSIID iid, void** ppv)
|
||||
// must say this is an 'internal' call, else we recurse QI into
|
||||
// oblivion.
|
||||
PyObject * this_interface_ob = Py_nsISupports::PyObjectFromInterface(
|
||||
(nsXPTCStubBase *)this,
|
||||
(nsIXPTCProxy *)this,
|
||||
iid, PR_FALSE, PR_TRUE);
|
||||
if ( !ob || !this_interface_ob) {
|
||||
Py_XDECREF(ob);
|
||||
|
||||
@@ -49,39 +49,29 @@
|
||||
#include "PyXPCOM_std.h"
|
||||
#include <nsIInterfaceInfoManager.h>
|
||||
|
||||
PyXPCOM_XPTStub::PyXPCOM_XPTStub(PyObject *instance, const nsIID &iid)
|
||||
: PyG_Base(instance, iid)
|
||||
{
|
||||
if (NS_FAILED(InitStub(iid)))
|
||||
NS_ERROR("InitStub must not fail!");
|
||||
}
|
||||
|
||||
void *PyXPCOM_XPTStub::ThisAsIID(const nsIID &iid)
|
||||
{
|
||||
if (iid.Equals(NS_GET_IID(nsISupports)))
|
||||
return (nsISupports *)(nsXPTCStubBase *)this;
|
||||
else if (iid.Equals(m_iid))
|
||||
return (nsISupports *)(nsXPTCStubBase *)this;
|
||||
else
|
||||
return PyG_Base::ThisAsIID(iid);
|
||||
// Not quite clear who should get nsISupports - I would
|
||||
// expect our PyG_Base, but Java gives it the stub.
|
||||
if (iid.Equals(NS_GET_IID(nsISupports)) || iid.Equals(m_iid)) {
|
||||
return mXPTCStub;
|
||||
}
|
||||
// else
|
||||
return PyG_Base::ThisAsIID(iid);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
PyXPCOM_XPTStub::GetInterfaceInfo(nsIInterfaceInfo** info)
|
||||
{
|
||||
NS_PRECONDITION(info, "NULL pointer");
|
||||
if (info==nsnull)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
// Simply get the XPCOM runtime to provide this
|
||||
// (but there must be some reason why they don't get it themselves!?)
|
||||
// Maybe because they don't know the IID?
|
||||
nsCOMPtr<nsIInterfaceInfoManager> iim(do_GetService(
|
||||
NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
|
||||
NS_ABORT_IF_FALSE(iim != nsnull, "Cant get interface from IIM!");
|
||||
if (iim==nsnull)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return iim->GetInfoForIID( &m_iid, info);
|
||||
}
|
||||
|
||||
// call this method and return result
|
||||
NS_IMETHODIMP
|
||||
PyXPCOM_XPTStub::CallMethod(PRUint16 methodIndex,
|
||||
const nsXPTMethodInfo* info,
|
||||
const XPTMethodDescriptor* info,
|
||||
nsXPTCMiniVariant* params)
|
||||
{
|
||||
nsresult rc = NS_ERROR_FAILURE;
|
||||
@@ -96,7 +86,7 @@ PyXPCOM_XPTStub::CallMethod(PRUint16 methodIndex,
|
||||
if (obMI==NULL)
|
||||
goto done;
|
||||
// base object is passed raw.
|
||||
obThisObject = PyObject_FromNSInterface((nsXPTCStubBase *)this,
|
||||
obThisObject = PyObject_FromNSInterface((nsISupports *)ThisAsIID(m_iid),
|
||||
m_iid, PR_FALSE);
|
||||
obParams = arg_helper.MakePyArgs();
|
||||
if (obParams==NULL)
|
||||
@@ -164,7 +154,7 @@ done:
|
||||
Py_XDECREF(err_result);
|
||||
PyErr_Restore(exc_typ, exc_val, exc_tb);
|
||||
if (bProcessMainError) {
|
||||
PyXPCOM_LogError("The function '%s' failed\n", info->GetName());
|
||||
PyXPCOM_LogError("The function '%s' failed\n", info->name);
|
||||
rc = PyXPCOM_SetCOMErrorFromPyException();
|
||||
}
|
||||
// else everything is already setup,
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
#include "nsStringAPI.h"
|
||||
|
||||
#include "nsCRT.h"
|
||||
#include "xptcall.h"
|
||||
#include "nsXPTCUtils.h"
|
||||
#include "xpt_xdr.h"
|
||||
|
||||
#ifdef HAVE_LONG_LONG
|
||||
@@ -483,24 +483,23 @@ protected:
|
||||
va_list va);
|
||||
};
|
||||
|
||||
class PYXPCOM_EXPORT PyXPCOM_XPTStub : public PyG_Base, public nsXPTCStubBase
|
||||
class PYXPCOM_EXPORT PyXPCOM_XPTStub : public PyG_Base, public nsAutoXPTCStub
|
||||
{
|
||||
friend class PyG_Base;
|
||||
public:
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) \
|
||||
{return PyG_Base::QueryInterface(aIID, aInstancePtr);} \
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void) {return PyG_Base::AddRef();} \
|
||||
NS_IMETHOD_(nsrefcnt) Release(void) {return PyG_Base::Release();} \
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{return PyG_Base::QueryInterface(aIID, aInstancePtr);}
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void) {return PyG_Base::AddRef();}
|
||||
NS_IMETHOD_(nsrefcnt) Release(void) {return PyG_Base::Release();}
|
||||
|
||||
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info);
|
||||
// call this method and return result
|
||||
NS_IMETHOD CallMethod(PRUint16 methodIndex,
|
||||
const nsXPTMethodInfo* info,
|
||||
const XPTMethodDescriptor* info,
|
||||
nsXPTCMiniVariant* params);
|
||||
|
||||
virtual void *ThisAsIID(const nsIID &iid);
|
||||
protected:
|
||||
PyXPCOM_XPTStub(PyObject *instance, const nsIID &iid) : PyG_Base(instance, iid) {;}
|
||||
PyXPCOM_XPTStub(PyObject *instance, const nsIID &iid);
|
||||
private:
|
||||
};
|
||||
|
||||
@@ -549,7 +548,7 @@ class PYXPCOM_EXPORT PyXPCOM_GatewayVariantHelper
|
||||
public:
|
||||
PyXPCOM_GatewayVariantHelper( PyG_Base *gateway,
|
||||
int methodIndex,
|
||||
const nsXPTMethodInfo *info,
|
||||
const XPTMethodDescriptor *info,
|
||||
nsXPTCMiniVariant* params );
|
||||
~PyXPCOM_GatewayVariantHelper();
|
||||
PyObject *MakePyArgs();
|
||||
@@ -567,7 +566,7 @@ private:
|
||||
|
||||
|
||||
nsXPTCMiniVariant* m_params;
|
||||
const nsXPTMethodInfo *m_info;
|
||||
const XPTMethodDescriptor *m_info;
|
||||
int m_method_index;
|
||||
PythonTypeDescriptor *m_python_type_desc_array;
|
||||
int m_num_type_descs;
|
||||
|
||||
@@ -1865,7 +1865,7 @@ PyObject *PyXPCOM_InterfaceVariantHelper::MakePythonResult()
|
||||
**************************************************************************
|
||||
*************************************************************************/
|
||||
|
||||
PyXPCOM_GatewayVariantHelper::PyXPCOM_GatewayVariantHelper( PyG_Base *gw, int method_index, const nsXPTMethodInfo *info, nsXPTCMiniVariant* params )
|
||||
PyXPCOM_GatewayVariantHelper::PyXPCOM_GatewayVariantHelper( PyG_Base *gw, int method_index, const XPTMethodDescriptor *info, nsXPTCMiniVariant* params )
|
||||
{
|
||||
m_params = params;
|
||||
m_info = info;
|
||||
@@ -1896,7 +1896,7 @@ PyObject *PyXPCOM_GatewayVariantHelper::MakePyArgs()
|
||||
// we pass to Python
|
||||
int i;
|
||||
for (i=0;i<m_info->num_args;i++) {
|
||||
nsXPTParamInfo *pi = (nsXPTParamInfo *)m_info->params+i;
|
||||
XPTParamDescriptor *pi = m_info->params+i;
|
||||
PythonTypeDescriptor &td = m_python_type_desc_array[i];
|
||||
td.param_flags = pi->flags;
|
||||
td.type_flags = pi->type.prefix.flags;
|
||||
@@ -2166,7 +2166,7 @@ nsresult PyXPCOM_GatewayVariantHelper::GetArrayType(PRUint8 index, PRUint8 *ret,
|
||||
if (NS_FAILED(rc))
|
||||
return rc;
|
||||
nsXPTType datumType;
|
||||
const nsXPTParamInfo& param_info = m_info->GetParam((PRUint8)index);
|
||||
const nsXPTParamInfo& param_info = m_info->params[index];
|
||||
rc = ii->GetTypeForParam(m_method_index, ¶m_info, 1, &datumType);
|
||||
if (NS_FAILED(rc))
|
||||
return rc;
|
||||
@@ -2716,7 +2716,7 @@ nsresult PyXPCOM_GatewayVariantHelper::ProcessPythonResult(PyObject *ret_ob)
|
||||
// If they havent given enough, we don't really care.
|
||||
// although a warning is probably appropriate.
|
||||
if (num_user_results != num_results) {
|
||||
const char *method_name = m_info->GetName();
|
||||
const char *method_name = m_info->name;
|
||||
PyXPCOM_LogWarning("The method '%s' has %d out params, but %d were supplied by the Python code\n",
|
||||
method_name,
|
||||
num_results,
|
||||
@@ -2732,12 +2732,12 @@ nsresult PyXPCOM_GatewayVariantHelper::ProcessPythonResult(PyObject *ret_ob)
|
||||
Py_DECREF(sub);
|
||||
this_py_index = 1;
|
||||
}
|
||||
for (i=0;NS_SUCCEEDED(rc) && i<m_info->GetParamCount();i++) {
|
||||
for (i=0;NS_SUCCEEDED(rc) && i<m_info->num_args;i++) {
|
||||
// If we've already done it, or don't need to do it!
|
||||
if (i==index_retval || m_python_type_desc_array[i].is_auto_out)
|
||||
continue;
|
||||
nsXPTParamInfo *pi = (nsXPTParamInfo *)m_info->params+i;
|
||||
if (pi->IsOut()) {
|
||||
XPTParamDescriptor *pi = m_info->params+i;
|
||||
if (XPT_PD_IS_OUT(pi->flags)) {
|
||||
PyObject *sub = PySequence_GetItem(user_result, this_py_index);
|
||||
if (sub==NULL)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@@ -435,7 +435,7 @@ static struct PyMethodDef xpcom_methods[]=
|
||||
{"GetComponentManager", PyXPCOMMethod_GetComponentManager, 1},
|
||||
{"GetComponentRegistrar", PyXPCOMMethod_GetComponentRegistrar, 1},
|
||||
{"XPTI_GetInterfaceInfoManager", PyXPCOMMethod_XPTI_GetInterfaceInfoManager, 1},
|
||||
{"NS_InvokeByIndex", PyXPCOMMethod_XPTC_InvokeByIndex, 1},
|
||||
{"NS_InvokeByIndex", PyXPCOMMethod_NS_InvokeByIndex, 1},
|
||||
{"GetServiceManager", PyXPCOMMethod_GetServiceManager, 1},
|
||||
{"IID", PyXPCOMMethod_IID, 1}, // IID is wrong - deprecated - not just IID, but CID, etc.
|
||||
{"ID", PyXPCOMMethod_IID, 1}, // This is the official name.
|
||||
|
||||
Reference in New Issue
Block a user