On Tuesday 08 February 2011 07:20:55 Sylvain Meunier wrote: > Le 07/02/2011 22:20, Hugo Parente Lima a écrit : > > On Monday 07 February 2011 07:07:42 Sylvain Meunier wrote: > >> Le 04/02/2011 11:43, Sylvain Meunier a écrit : > >>> Le 03/02/2011 19:44, Hugo Parente Lima a écrit : > >>>> On Thursday 03 February 2011 16:29:59 Anderson Lizardo wrote: > >>>>> On Thu, Feb 3, 2011 at 12:13 PM, Hugo Parente Lima > >>>>> > >>>>> <hugo.l...@openbossa.org> wrote: > >>>>>> On Thursday 03 February 2011 12:54:50 Sylvain Meunier wrote: > >>>>>>> Hello, > >>>>>>> > >>>>>>> What is the usual way for binding method templates ? > >>>>>> > >>>>>> There's no simple way, sometimes it's possible some times not > >>>>>> because we can't instantiate those template methods at runtime. So > >>>>>> you need to analyze the semantics of the method and write some kind > >>>>>> of code injection to do the hard task of connect the world of > >>>>>> compile time stuff (C++ templates) to the world of run time stuff > >>>>>> (Python). > >>>>>> > >>>>>> As an example you could see our implementation of > >>>>>> qmlRegisterType<T>[1] or QObject::findChildren to have an idea. > >>>>> > >>>>> I wonder if this could be made automatic by extending apiextractor to > >>>>> parse templates as well? or does it already parse templates and one > >>>>> could extend the generator? > >>>>> > >>>>> Of course, it would not work in 100% cases, but it would be nice if > >>>>> we could have some typesystem support for simple templates which > >>>>> would not require manual inject code. > >>>> > >>>> It isn't a parser problem, it's a "can't generate C++ code at runtime > >>>> problem" > >>>> > >>>> :-P > >>>> > >>>> C++ knows everything at compile time, but when we are generating the > >>>> bindings we don't know what types the python user will use to call > >>>> Foo::bar<T> method. > >>>> > >>>> For some cases we can do workarounds like creating a C++ type and > >>>> using it in the function call every time the python user calls the > >>>> bar function with a Python type, for other cases it is a bit harder, > >>>> btw you can take as hard example the qRegisterMetaType function that > >>>> isn't binded yet in PySide because it requires a non trivial > >>>> workaround. > >>>> > >>>>> My two BRL cents :) > >>> > >>> I follow Anderson Lizardo on this point. Instantiating some templates > >>> adding one line in a type system could be really helpful. > >> > >> For illustrating my previous point, a very mechanical code injection for > >> binding this method template : > >> > >> [snip] > >> > >> There is no runtime problem in this case, all the required types are > >> available at compilation time. > > > > What if I want to create my own property manager in Python? > > > > e.g.: > > > > class GeoCoordsPropManager(object): > > # ... > > > > ? > > > > How do I use them with your binding for the template-function? > > My binding doesn't consider this case.
This is the problem, if the binding doesn't consider this case it's incomplete because template functions are made to be used in this case. :-/ > But handling template instantiations (and other simple cases) and > keeping code injection for harder cases (some Qt parts) doesn't seem > bad. Code injection is really error-prone and requires a lot of low > level knowledges on Shiboken binding model and Python libraries. You are right, the worst part is the requirement of low level knowledge of Shiboken besides Python C API. -- Hugo Parente Lima INdT - Instituto Nokia de Tecnologia
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ PySide mailing list PySide@lists.openbossa.org http://lists.openbossa.org/listinfo/pyside