Improve PyUNO_cmp
...for cases where one operand is a PyUNO Adapter of the other (i.e., one
operand is a Python object that got passed out and back in again, and the other
operand is that same Python object). This fixes the second "TODO" from
1e2e9a20a4 "More exhaustive testing of PyUNO type
mapping based on embindtest".
Change-Id: I0fc938db5c464ed56adee3b428537925fff0fc81
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195392
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
This commit is contained in:
@@ -226,7 +226,7 @@ class Test(unohelper.Base, XTest):
|
||||
return uno.Any('org.libreoffice.embindtest.XTest', self)
|
||||
|
||||
def isAnyInterface(self, value):
|
||||
return value == self #TODO: this doesn't work as intended
|
||||
return value == self
|
||||
|
||||
def getEnum(self):
|
||||
return E_2
|
||||
|
||||
@@ -1518,6 +1518,22 @@ static PyObject* PyUNO_cmp( PyObject *self, PyObject *that, int op )
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (PyObject_IsInstance(
|
||||
that, getClass(u"com.sun.star.uno.XInterface"_ustr, runtime).get()))
|
||||
{
|
||||
// `self` could be an Adapter of `that`:
|
||||
if (css::uno::Reference<css::lang::XUnoTunnel> tunnel;
|
||||
reinterpret_cast<PyUNO *>(self)->members->wrappedObject >>= tunnel)
|
||||
{
|
||||
if (auto const adapter = comphelper::getFromUnoTunnel<Adapter>(tunnel)) {
|
||||
if (adapter->getWrappedObject().get() == that) {
|
||||
result = (op == Py_EQ ? Py_True : Py_False);
|
||||
Py_INCREF(result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( const css::uno::RuntimeException & e)
|
||||
{
|
||||
|
||||
@@ -450,11 +450,7 @@ void doExecuteTest(css::uno::Reference<org::libreoffice::embindtest::XTest> cons
|
||||
auto const val = test->getAnyInterface();
|
||||
verify(checkAnyInterface(val, test));
|
||||
bool const ok = test->isAnyInterface(val);
|
||||
//TODO: Test.isAnyInterface in pyuno/qa/pytests/embindtest.py doesn't work as intended:
|
||||
if (ok)
|
||||
{
|
||||
verify(ok);
|
||||
}
|
||||
verify(ok);
|
||||
}
|
||||
{
|
||||
auto const val = test->getSequenceBoolean();
|
||||
|
||||
Reference in New Issue
Block a user