Hi,
I went ahead and implemented this as I didn't get any response from my last mail. The code is in my github repo if anyone wants it (would be great if this feature could be integrated back into the main project??)
The tests in test_subclass.py (see also subclasstest.cs) show how you can now subclass a managed type in python, instantiate that type both in python and in managed code and then call the virtual methods overridden in the subclass from managed code (as well as from python) and it will call back out to the python code.
It works by constructing new managed types on the fly using System.Reflection.Emit (see new file classderived.cs).
There are a couple of issues which aren't that important to me right now, but do cause a couple of the unit tests to fail:
-- subclass constructors can no longer take extra arguments (as the __init__ method is called from the managed subclass ctor)
-- __init__ gets called twice when instantiating sub classes from python (related to the above, it's because __init__ needs to be called when the object is instantiated from managed code); doesn't cause a test to fail but thought I'd mention it.
-- sub-classing of array types isn't working anymore
I'll probably get round to fixing these, but for now for my purposes I'm not worried about them for now. If this is useful for anyone else and someone comes up with some fixes please feel free to send me a pull request :)
One other thing that's not working is using super to call the base class method from the subclass. I've got a fix so that the base class method can be called directly (eg SubClass.x(self), where self is an instance of DerivedClass) but I've not checked that in as I'd really prefer to get super() working. If anyone has any ideas about how to get that working please let me know...
cheers,
Tony