On Wed, Oct 22, 2008 at 3:33 PM, klaas.holwerda <[EMAIL PROTECTED]> wrote:
> John,
>
> You told that templates are not possible, and i understand that.
> But i still need to find a solutions, since all my lists are STL/STD
> template based.
> Like my main a2dList class is a pure std::list, with some extra members
> that return an iterator.
> All the other list are derived from that or they are template
> instantiations of it.
>
> template<class T>
> class a2dlist: public std::list< T, std::allocator<T> >
>
> Has a member like:
>
> typename a2dlist<T>::iterator item(size_t index)    {.....}

I would make separate bindings for each type T that you expect to have.

First, give them a normal name that the binder can handle.

typedef a2dlist<int> a2dlist_int;
typedef a2dlist<double> a2dlist_double;

Then add all the functions that might be useful in Lua, you might not
have to add all of them to simplify your life and also make the
generated code smaller. For example, maybe only have == and not !=,
etc.

Finally add the a2dlist_int::iterator class. There's an example of a
member class: wxFileType::MessageParameters.

> The smart pointer list is also a2dlist / std::list based.
>
> template<class T>
> class a2dSmrtPtrList: public a2dlist< a2dSmrtPtr< T > >
>
> And of those i have many instantiations like this:
>
> class  a2dVertexList : public  a2dSmrtPtrList< a2dLineSegment >
>
> class  a2dCanvasObjectList: public a2dSmrtPtrList<a2dCanvasObject>

Again, you just have to define all of these.

> So do you have any idea how i best approach this?
> Should i for instance best write lua code to generate the template
> instantiation in *.i lines code??

Probably just copy and paste. Once you get one working, you just have
to change the parameters, boring, but it shouldn't take too long.

> Its the iterators that worry  me the most :-( What i saw in wxLua looks
> like its based on wxList "old fashion" use, where wxNode is not typed.
> But my iterator are typed i am afraid.
> Is there a sample demo-ing wxList usage?? I think it is weird to use
> lists in lua, should be a table. But my data in the document/C++, is all
> stored in the type of lists is showed above, and i like to iterate
> through them. Maybe i should just make a GetFirst() GetNext() kind of
> iteration inside list classes ??

I left the wxList in wxLua since I didn't want to create a table
duplicating what may be a very large list.

> I am very bad in writing lua code, but this will change :-). But for the
> moment this makes it a bit difficult to see through all this :-(.

I tried to keep all the C++ side very much like C++ to reuse the
wxWidgets docs and I think this makes sense for your stuff too.

-John

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to