[Kde-bindings] XPath is my friend

Richard Dale Richard_Dale at tipitina.demon.co.uk
Sun Jun 19 20:29:13 UTC 2005


On Saturday 18 June 2005 21:32, Ashley Winters wrote:
> --- Richard Dale <Richard_Dale at tipitina.demon.co.uk> wrote:
> > How will the C# bindings work - are you intending to divert all the
> > calls
> > through Proxy.Invoke() like I was going to do when I last tried? Or
> > if you
> > were going to do something more conventional, where each C# method
> > calls the
> > corresponding C++ method. There doesn't seem to be the need to use
> > Smoke
> > introspection, and mainly it would just need virtual method callbacks
>
> Depends on what you mean by introspection. Here's a C# function:
>
>     void setName(string name) {
>         my_proxy.Invoke(SMOKE_ID_OF_setName, name);
>     }
Sorry I meant if it didn't use proxies it wouldn't need introspection.

> How does the proxy know whether to serialize the 'name' parameter to a
> QString, a QCString, or a const char*? Either the proxy.invoke needs to
> have that information.
>
>     [SmokeCoercion(Signature = "...")]    // via attribute?
>     // passed to Invoke?
>     my_proxy.Invoke(ID, "const QString&", name);
>
> or it can use the id to grab the XML node efficiently and lookup the
> coercions that way. Either way is fine. They need benchmarking, though.
Yes, I think it's best to start with the simplest possible solution. You have 
the method name, and the arg types and they need matching against the C++ 
methods with the same name via xpath introspection.

> > presumably via the new scheme using slots/signals.
> >
> > "I expect to create an XSL stylesheet for the C++/moc4 Smoke binding,
> > another
> > one for the O'Caml binding, and yet another one for the C# binding."
> >
> > Does the XSL stylesheet for C# just generate C# code, which in turn
> > uses the
> > C++/moc4 Smoke bindings? Or does it generate both C# and C++ code?
>
> The former. The stylesheet just generates all the Proxy.Invoke calls.
> And the O'Caml binding does the same, but differently.
I see, but I wonder if a stylesheet is powerful enough to generate the C# 
code, as it needs some pretty major transformations for multiple inheritance 
for instance, where all but one of the C++ superclasses become C# interfaces, 
and the methods to implement the interfaces are copied into the current 
class. Or if there are two C++ methods foobar(QString) and foobar(QCString), 
you need to drop one of them. 

I would rather write it in ruby, but then I don't know much about stylesheets 
and they might be more suitable than I thought. The code generation can be 
modeled on the '-fkimono' option in kalyptus anyway, I've certainly worked 
out how to model a C# api in proxies quite well.

-- Richard



More information about the Kde-bindings mailing list