> Dear all,
> I'm new to swig so please be kind to me ;)
> I've been trying to "swig" some C++ library for Lua. The libraries
> have many
> interfaces like the following.
> namespace AAA
> class ...
> I've been wondering if it is possible to "simulate" these namespaces
> separating all this interfaces to following "separated"
> - AAA
> - AAA.B
> - AAA.C
> - AAA.D
> Any help is appreciated.
> Best regards,
> S. Effendi
I am afraid that the Swig-Lua doesn't support this kind of feature. It currently just 'ignores' namespaces completely.
Are treated as class A and class B (ie without the namespace). The internal swig wrappers use the namespaces correctly. But they don't add the namespaces to the lua side.
You could get around this by wrappering each of the namespaces as different modules, and then pulling all together in one lua file.
-- main lua script
AAA.B=AAA_B -- renaming of the script
That should work. (You will need a recent copy of SWIG, as the ability to add new entities to a module table was only added recently)
But this looks rather tedious I confess.
Do any of the other language binding have a better method to handle this?
From: William S Fulton <wsf@fu...> - 2007-03-08 21:22:32
mark gossage wrote:
> The internal swig wrappers use the namespaces correctly. But they don't add the namespaces to the lua side.
> Do any of the other language binding have a better method to handle this?
No. Manual intervention is required and each language has its own way of
dealing with this and it is all a bit labour intensive. Modularising
your code using separate invocations of swig for wrapping different
namespaces is a common approach if having lua namespaces is important
>-- main lua script
>AAA.B=AAA_B -- renaming of the script
>That should work. (You will need a recent copy of SWIG, as the ability to
>add new entities to a module table was only added recently)
Thank you Mark, I'll give this a try.
>But this looks rather tedious I confess.
Yup... but better than "no go"! ;)
Your Space. Your Friends. Your Stories. Share your world with Windows Live