tolua and namespaces

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

tolua and namespaces

Falko Poiker
Hello,

Does ToLua handle C++ namespaces?  If not, is there a workaround?

What about Templates?

Falko

Reply | Threaded
Open this post in threaded view
|

Re: tolua and namespaces

Waldemar Celes-3
>
> Does ToLua handle C++ namespaces?  If not, is there a workaround?

tolua handles "module", a concept similar to namespace.
if you have a .pkg file with:

module modulename
{
     #define N
     extern int var;
     int func (...):
}

it is valid to write the following lua code:

print(modulename.N, modulename.var)
modulename.func(...)

>
> What about Templates?

there is no support for templates,
but you can map instances of templates.

$typedef MyList<double> NumberList;

class NumberList {
 ...
};

-- waldemar

Reply | Threaded
Open this post in threaded view
|

RE: tolua and namespaces

Falko Poiker
In reply to this post by Falko Poiker
> > Does ToLua handle C++ namespaces?  If not, is there a workaround?

> tolua handles "module", a concept similar to namespace.
> if you have a .pkg file with:
> 
> module modulename
> {
>      #define N
>      extern int var;
>      int func (...):
> }
> 
> it is valid to write the following lua code:
> 
> print(modulename.N, modulename.var)
> modulename.func(...)
Nice!  But how about if I want ToLua to create access to a variable that is
within a namespace.  For example, if my C++ code has the following:

namespace big
{
	int stuff;
	...
}


it would be accessed (if not within the namespace "big") with the line

	...
	big::stuff = 10;
	...


Can I put something like this in a .pkg file?  (Without the assignment, that
is).

> > What about Templates?

> there is no support for templates,
> but you can map instances of templates.

> $typedef MyList<double> NumberList;

> class NumberList {
>  ...
> };

Excellent!  Thanks...

Falko