<br><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>Message: 2<br>Date: Sat, 28 Apr 2007 09:33:24 +0100<br>From: Richard Dale <<a href="mailto:rdale@foton.es">
rdale@foton.es</a>><br>Subject: Re: [Kde-bindings] question of c++ template class<br>To: KDE bindings for other programming languages<br>        <<a href="mailto:kde-bindings@kde.org">kde-bindings@kde.org</a>><br>
Message-ID: <<a href="mailto:200704280933.25574.rdale@foton.es">200704280933.25574.rdale@foton.es</a>><br>Content-Type: text/plain;  charset="utf-8"<br><br>On Friday 27 April 2007, Dongxu Ma wrote:<br>> > > Hi Richard, CC: all,
<br>> > ><br>> > > I am recently thinking about how to deal with c++ template class in<br>> ><br>> > QT/KDE<br>> ><br>> > > bindings.<br>> > > Inside QT4 I found three places where templates get involved:
<br>> > > 1) typedef<br>> ><br>> > You need to be able to marshaller each typedef'd variant of the template<br>><br>> yes, the disadvantage is to collect all involved ones priorly. ?I am<br>
> working on a<br>> script to build the list.<br>OK, I think you could generate some marshallers along with the bindings, but<br>not all of them. The bindings that use the smoke lib have a hash of strings<br>for the various types as keys, with a values as function pointer of the
<br>corresponding marshaller</blockquote><div><br>Definitely. QHash  is the hardest one. Such  pre-built  type dictionary could not <br>easily cover all available ones. The way of smoke makes sense.<br> </div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
> > 2) function parameter, return type<br>> > A lot of the template types are lists or hashes, and the solution that<br>> > qtruby/qyoto uses is to have marshallers <--> bindings language as<br>> > templated
<br>> > code. This means you only write the marshalling code once, and then have<br>> > a different template type for each the the C++ template types with a<br>> > macro to<br>> > invoke it. See the code in 
handlers.cpp of either the QtRuby or Qyoto<br>> > projects for a example. For instance, this line:<br>> ><br>> > DEF_VALUELIST_MARSHALLER( QUrlList, QList<QUrl>, QUrl )<br>> ><br>> > The DEF_VALUELIST_MARSHALLER() will define a new template based
<br>> > marshaller for<br>> > QLists of QUrls.<br>> ><br>> > > 3) QT signal, slot<br>> ><br>> > You can't have have commas in signal and slot types, but you can have<br>> > simple
<br>> > template types. The template types are mostly lists which have to be<br>> > marshalled as Arrays or Lists in the bindings language.<br>><br>> yes, noticed that. Just 4 or 5 found in my current QT4 headers.
<br>I think there are more than that.</blockquote><div><br>;-) <br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">> > It is a little bit hard to support template class inside scripting
<br>> ><br>> > > language, how do you<br>> > > make it available for qtruby (or not) ? This was not mentioned on<br>> > > kdebindings ruby<br>> > > page. Sorry I am totally new to ruby.
<br>> > ><br>> > > Idea in my mind is:<br>> > > 1) get all template declarations from source;<br>> > > 2) introduce a base template in perl for those types which share the<br>> ><br>
> > same<br>> ><br>> > > base template<br>> > > ? ? like QList<Q3DockWindow *>, QList<Q3ToolBar *> we create QList.<br>> > > ? ? such base template can create a specific namespace for demanded
<br>> > > type runtimely, say<br>> > > ? ? QList_Q3DockWindow_Ptr (cached in future), and push all available<br>> > > methods into it.<br>> > > ? ? Inside QList c++ code holds a function dictionary to cast generic
<br>> > > pointer from vm to<br>> > > ? ? template type instance (possibly by interpret_cast or static_cast);<br>> ><br>> > Yes, that sounds similar to the code in handlers.cpp that I describe
<br>> > above.<br>> ><br>> > > Could you pls explain something you've done in qtbudy or your ideas?<br>> > > From my personal point of view, that'll be nice if we can setup a<br>> >
<br>> > generic<br>> ><br>> > > solution, across<br>> > > different scripting languages.<br>> ><br>> > Well, yes that is the idea of the Smoke library. And it allows the code<br>> > for
<br>> > the QtRuby bindings (derived from PerlQt), and the Qyoto C# bindings to<br>> > be very similar.<br>><br>> The way to keep instance pointer differ in various languages. That'll be<br>> nice
<br>> to define marshall layer plugin for each one and plug to use.<br>><br>> Note that I think someone is working on a Qt4 version of the Smoke based<br>><br>> > PerlQt, and you need to be a bit careful about naming your project
<br>> > something<br>> > different from just 'PerlQt' to avoid confusion.<br>><br>> namespace is ok. ?I'd like to know him/her. Is him/her on the maillist?<br>Yes, there is a mailing list <a href="mailto:kde-perl@kde.org">
kde-perl@kde.org</a></blockquote><div><br>thanks for the information. I'll make a subscription later.<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
-- Richard<br><br></blockquote></div><br><br clear="all"><br>-- <br>cheers,<br>-dongxu<br>__END__<br><a href="http://search.cpan.org/~dongxu">http://search.cpan.org/~dongxu</a>