[EMAIL PROTECTED] wrote:
> Thanks for the answer Eskil, 
> but i wish templates will be supported soon....
>   

Templates as a general concept is impossible to support in the bindings, 
since it's a static mechanism which relies on partially defining a class 
and instantiating it heterogeneously. We do, however, support mapping 
template instantiations as long as they are used as the only super class 
in any inheritance relationship.

To map the generic API from templates to Java's generic classes, you 
would create a template instantiation with Qt Jambi's JObjectWrapper 
type, which is a special type that maps to java.lang.Object, but handles 
reference counting of the object on the JNI side to avoid accidental 
garbage collection.

As an example, it would work something like the following:

template <typename T>
class TemplateClass
{
public:
    T getTemplateTypeObject();
};

typedef TemplateClass<JObjectWrapper> SpecializedTemplateClass;

and then in the type system:
<object-type name="TemplateClass" generate="no" />
<object-type name="SpecializedTemplateClass" generic-class="yes" 
java-name="TemplateClass" />

Unless I've made some typos, this should give you the equivalent API in 
Java as in C++, but with generic classes rather than templates. You can 
see the mapping of e.g. QFuture as an example of how this is done in Qt 
Jambi.

As I said, this does not work for interfaces at the moment, but maybe 
the mechanism will give you some ideas to how you best can map your API 
despite the missing support.

-- Eskil
_______________________________________________
Qt-jambi-interest mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest

Reply via email to