[
https://issues.apache.org/jira/browse/PYLUCENE-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16062324#comment-16062324
]
Andi Vajda commented on PYLUCENE-37:
------------------------------------
I've been working on this bug for a while now and I'm wondering how far a fix
can get and what it achieves. I am about to check-in a large body of changes
that makes a fix possible by switching Python type construction to use
PyType_FromSpecWithBases() which can create a type with multiple base types.
This is Python 3 only and this is fine. Python 2 support is in maintenance mode
only.
What would fixing this bug achieve ?
- wrappers would be correct with regards to their super types and
side-casting interfaces would work
- wrappers would inherit static fields and methods declared on interfaces
beyond the first one)
Other than that, all is already working. For a non abstract java class to
implement multiple interfaces, it has to have local implementations of all
their methods (or inherit some from a parent class with local implementations)
- thus I don't see any functional inheritance losses at the moment (beyond the
static ones).
Also, Python has, to say the least, some strange layout requirements when
constructing a type from multiple bases - they all have to have the same
tp_basicsize. This is not the case with the JCC t_type, the types used with
Python (their sizeof() is tp_basicsize), that wrap the C++/Java bridge types as
they may have an array of type parameter of variable size (depending on the
number of type parameters) when the java type being wrapped is generic. At the
moment, I'm not even sure how much Python can support JCC types with multiple
base types - maybe the t_type layout can be modified a bit to fix the size of
type parameters by moving to an array pointer.
All that being said, it would be very nice if multiple inheritance could be
properly supported:
- it would better model 'class foo extends bar implements baz, ..."
- it would better model the interface tree you proposed in the test
The new code now has a lot of stuff in place for supporting multiple
inheritance but it is not enabled:
- placeholder for virtual inheritance
- support for multiple parents everywhere
- Python type construction supports multiple bases
The code doesn't have the change in logic yet to properly track 'extends foo
implements bar' and the code still suffers from the bug reported here, only the
first interface is used as parent for a sub-interface.
I'm going to continue working on this on and off as it's an interesting
problem...
> Extended interfaces beyond first are ignored
> --------------------------------------------
>
> Key: PYLUCENE-37
> URL: https://issues.apache.org/jira/browse/PYLUCENE-37
> Project: PyLucene
> Issue Type: Bug
> Reporter: Jesper Mattsson
> Attachments: jcc.multiple.inheritance.patch, Test.zip
>
>
> When generating wrapper for a Java interface that extends more than one other
> interface, then only the first extended interface is used when generating the
> C++ class.
> In cpp.header(), the code snippets:
> {code}
> if cls.isInterface():
> if interfaces:
> superCls = interfaces.pop(0)
> {code}
> and:
> {code}
> line(out, indent, 'class %s%s : public %s {',
> _dll_export, cppname(names[-1]), absname(cppnames(superNames)))
> {code}
> are likely responsible.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)