Fix bug 347865 (PyXPCOM fails to build on alpha) on trunk.
Not part of the default build. git-svn-id: svn://10.0.0.236/trunk@206970 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
a6a536f245
commit
12cadc12fc
@ -603,101 +603,6 @@ nsresult PyG_Base::InvokeNativeViaPolicy(
|
|||||||
return nr == NS_OK ? NS_OK : HandleNativeGatewayError(szMethodName);
|
return nr == NS_OK ? NS_OK : HandleNativeGatewayError(szMethodName);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult PyG_Base::InvokeNativeGetViaPolicy(
|
|
||||||
const char *szPropertyName,
|
|
||||||
PyObject **ppResult /* = NULL */
|
|
||||||
)
|
|
||||||
{
|
|
||||||
PyObject *ob_ret = NULL;
|
|
||||||
nsresult ret = NS_OK;
|
|
||||||
PyObject *real_ob = NULL;
|
|
||||||
if ( m_pPyObject == NULL || szPropertyName == NULL )
|
|
||||||
return NS_ERROR_NULL_POINTER;
|
|
||||||
// First see if we have a method of that name.
|
|
||||||
char buf[256];
|
|
||||||
strcpy(buf, "get_");
|
|
||||||
strncat(buf, szPropertyName, sizeof(buf)*sizeof(buf[0])-strlen(buf)-1);
|
|
||||||
buf[sizeof(buf)/sizeof(buf[0])-1] = '\0';
|
|
||||||
ret = InvokeNativeViaPolicyInternal(buf, ppResult, nsnull, nsnull);
|
|
||||||
if (ret == NS_PYXPCOM_NO_SUCH_METHOD) {
|
|
||||||
// No method of that name - just try a property.
|
|
||||||
// Bit to a hack here to maintain the use of a policy.
|
|
||||||
// We actually get the policies underlying object
|
|
||||||
// to make the call on.
|
|
||||||
real_ob = PyObject_GetAttrString(m_pPyObject, "_obj_");
|
|
||||||
if (real_ob == NULL) {
|
|
||||||
PyErr_Format(PyExc_AttributeError, "The policy object does not have an '_obj_' attribute.");
|
|
||||||
ret = HandleNativeGatewayError(szPropertyName);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
ob_ret = PyObject_GetAttrString(real_ob, (char *)szPropertyName);
|
|
||||||
if (ob_ret==NULL) {
|
|
||||||
PyErr_Format(PyExc_AttributeError,
|
|
||||||
"The object does not have a 'get_%s' function, or a '%s attribute.",
|
|
||||||
szPropertyName, szPropertyName);
|
|
||||||
} else {
|
|
||||||
ret = NS_OK;
|
|
||||||
if (ppResult)
|
|
||||||
*ppResult = ob_ret;
|
|
||||||
else
|
|
||||||
Py_XDECREF(ob_ret);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ret != NS_OK)
|
|
||||||
ret = HandleNativeGatewayError(szPropertyName);
|
|
||||||
|
|
||||||
done:
|
|
||||||
Py_XDECREF(real_ob);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult PyG_Base::InvokeNativeSetViaPolicy(
|
|
||||||
const char *szPropertyName,
|
|
||||||
...
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if ( m_pPyObject == NULL || szPropertyName == NULL )
|
|
||||||
return NS_ERROR_NULL_POINTER;
|
|
||||||
nsresult ret = NS_OK;
|
|
||||||
PyObject *real_ob = NULL;
|
|
||||||
char buf[256];
|
|
||||||
strcpy(buf, "set_");
|
|
||||||
strncat(buf, szPropertyName, sizeof(buf)*sizeof(buf[0])-strlen(buf)-1);
|
|
||||||
buf[sizeof(buf)/sizeof(buf[0])-1] = '\0';
|
|
||||||
va_list va;
|
|
||||||
va_start(va, szPropertyName);
|
|
||||||
ret = InvokeNativeViaPolicyInternal(buf, NULL, "O", va);
|
|
||||||
va_end(va);
|
|
||||||
if (ret == NS_PYXPCOM_NO_SUCH_METHOD) {
|
|
||||||
// No method of that name - just try a property.
|
|
||||||
// Bit to a hack here to maintain the use of a policy.
|
|
||||||
// We actually get the policies underlying object
|
|
||||||
// to make the call on.
|
|
||||||
real_ob = PyObject_GetAttrString(m_pPyObject, "_obj_");
|
|
||||||
if (real_ob == NULL) {
|
|
||||||
PyErr_Format(PyExc_AttributeError, "The policy object does not have an '_obj_' attribute.");
|
|
||||||
ret = HandleNativeGatewayError(szPropertyName);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
va_list va2;
|
|
||||||
va_start(va2, szPropertyName);
|
|
||||||
PyObject *arg = va_arg( va2, PyObject *);
|
|
||||||
va_end(va2);
|
|
||||||
if (PyObject_SetAttrString(real_ob, (char *)szPropertyName, arg) == 0)
|
|
||||||
ret = NS_OK;
|
|
||||||
else {
|
|
||||||
PyErr_Format(PyExc_AttributeError,
|
|
||||||
"The object does not have a 'set_%s' function, or a '%s attribute.",
|
|
||||||
szPropertyName, szPropertyName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ret != NS_OK)
|
|
||||||
ret = HandleNativeGatewayError(szPropertyName);
|
|
||||||
done:
|
|
||||||
Py_XDECREF(real_ob);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get at the underlying Python object.
|
// Get at the underlying Python object.
|
||||||
PyObject *PyG_Base::UnwrapPythonObject(void)
|
PyObject *PyG_Base::UnwrapPythonObject(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -478,11 +478,6 @@ protected:
|
|||||||
PyObject **ppResult,
|
PyObject **ppResult,
|
||||||
const char *szFormat,
|
const char *szFormat,
|
||||||
va_list va);
|
va_list va);
|
||||||
nsresult InvokeNativeGetViaPolicy(const char *szPropertyName,
|
|
||||||
PyObject **ppResult = NULL
|
|
||||||
);
|
|
||||||
nsresult InvokeNativeSetViaPolicy(const char *szPropertyName,
|
|
||||||
...);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PYXPCOM_EXPORT PyXPCOM_XPTStub : public PyG_Base, public nsXPTCStubBase
|
class PYXPCOM_EXPORT PyXPCOM_XPTStub : public PyG_Base, public nsXPTCStubBase
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user