[Kde-bindings] Blowin' smoke your way

Richard Dale Richard_Dale at tipitina.demon.co.uk
Thu Sep 11 11:35:10 UTC 2003


On Wednesday 10 September 2003 20:41, Ashley Winters wrote:
> --- Adam Treat <manyoso at yahoo.com> wrote:
> > Have you given thought to a unified way of dealing with Qt <-->
> > binding
> > inheritance?  I ran into a pretty fundamental barrier with the Qt#
> > bindings
> > where I could not reliably inherit and override Qt/C++ virtual
> > functions in
> > C#.  The collective marshalling, redirections and method prototypes
> > was just
> > to much for the binding to handle.  I have been lurking and watching
> > you and
> > Richard waiting for some breakthrough bindings technology...  let me
> > know if
> > you have anything interesting in the way of handling Qt virtual
> > functions and
> > inheritance for bindings.
> >
> > > [ libqt-mt.so ]   target library
> > > [   mirror    ]   low level interface  =>  JavaQt
No, implementing QtJava using java proxies will mean I don't need the low 
level interface. Using a low level interface would involve generating lots of 
JNI which is horrible and something I want to get away from. As long as that 
'pass a method selector URI as first arg' optimisation trick is fast, it will 
work very well. Java has reflection to tell if an instance 'respondsTo' a 
message for virtual method callbacks.

I think Smoke v1 already has the problem solved for java via the high level 
api, and I think .net RealProxies would also work well used in the same way. 
Marcus thought they might be ineffecient as they were intended for remoting, 
but from reading the docs, it looks to me as though they are intended to be 
used as local proxies too. I would be interested in a benchmark of a C# 
RealProxy call vs. and ordinary method call to a C function. When we did that 
for java we found that with the latest jdk 1.4, proxy calls were half as fast 
as straight JNI, which is pretty good.
> > > [    smoke    ]   high level interface =>  PerlQt and RubyQt
> > >
> > > The mirror library provides access to library functions using the
> >
> > URIs,
> >
> > > and not much more.
>
> Adam, you brought up the other thing mirror does. :)
>
> The mirror library will handle virtual functions thusly:
>
> 1. It will override every virtual function in every class, like always.
> Even though I have stripped enough information to completely abuse the
> GCC virtual function table ABI, I'm not going to (although the
> interface I'm defining WILL allow it, without changing the binding
> source-code).
>
> 2. It will allow the allocation of a "new" virtual function table for
> each class.
>
> 3. It will allow that "new" virtual function table to be assigned to
> any object at any time, and it can be modified by changing the delegate
> function being called by that function at any time (mostly to allow
> runtime initialization of the vtbl pointer in a 'private static'
> variable).
>
> // Think of this as a stub constructor function in an anonymous
> language
>
> // Mirror will use PLACEMENT new; it will NEVER ALLOCATE MEMORY except
> // by calling ::new(size_t) explicitly.
>
> // Accordingly, it will NEVER DELETE MEMORY except by ::delete(void*)
> // If you *really* want to call a destructor from a Java/C# finalizer,
> // go for it. Mirror will provide an interface to the this->~QFoo()
> // destructor method.
>
> // Therefore, each language binding needs to somehow allocate
> // enough memory for the object using some mechanism.
> // The mirror library will give a proper sizeof() for the object
> // Qt will allocate its own memory as usual, of course.
> pointer = call_function("&smoke;new(size_t)",
>                         smoke_sizeof("&qt;QWidget"));
>
> // like a normal function call, except returns an object -- somehow?
> object = call_constructor("&qt;QWidget/QWidget(...)", pointer);
>
> // allocate a new virtual table for your custom class
> vtbl = new_vtbl("&qt;QWidget");
>
> // make the new object a member of that custom class
> assign_vtbl(object, vtbl);
>
> // generic virtual function override thingy -- alters all objects
> // which use vtbl as their virtual function table. Assume &className
> // is an appropriate delegate pointer.
> override(vtbl, "&qt;QWidget/className()", &className);
>
> The high-level Smoke interface for Perl/Ruby/etc will do
> argument-marshalling for the virtual functions and will automatically
> generate vtables for dynamic languages using the underlying Mirror
> interface.
>
> That's about it,
> Ashley Winters
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
> _______________________________________________
> Kde-bindings mailing list
> Kde-bindings at mail.kde.org
> http://mail.kde.org/mailman/listinfo/kde-bindings


More information about the Kde-bindings mailing list