How much classes can I bind to LUA?

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

How much classes can I bind to LUA?

"Голубев С.В."
Hello, Arvid.

I have trouble in class hierarchy registration. When i bind my classes
to LUA, program crashes with segmentation fault, when I bind many
classes. When I comments a couple of class registration code, it work
correct. What can I do to correct this trouble? I try to split my
binding code into several namespaces, but receive no result.

My target is developing RPG engine, fully based on lua scripts, so, I
must have many links from engine to LUA.

Also, how can i find link in LUA to instance of engine class? The class
also may be derived from engine class, but I bind engine classes
directly, without creation any wrapper. In code that tries to find this
link, I know only pointer to that object. Object are
dynamically-allocated by engine and when I try to use delete operator on
it, engine crashes with segfault also.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: How much classes can I bind to LUA?

Arvid Norberg-2

On Sep 26, 2006, at 17:43, Голубев С.В. wrote:

> Hello, Arvid.
>
> I have trouble in class hierarchy registration. When i bind my classes
> to LUA, program crashes with segmentation fault, when I bind many
> classes. When I comments a couple of class registration code, it work
> correct. What can I do to correct this trouble? I try to split my
> binding code into several namespaces, but receive no result.

You could try splitting it up into several compilation units (cpp  
files). Are you using msvc? iirc it has a few fixed sized buffers  
internally so it can't compile too much in a single compilation unit.  
There are examples on how to split the registration into separate  
functions in the documentation, do that and put those functions in  
separate cpp files.

> My target is developing RPG engine, fully based on lua scripts, so, I
> must have many links from engine to LUA.
>
> Also, how can i find link in LUA to instance of engine class? The  
> class
> also may be derived from engine class, but I bind engine classes
> directly, without creation any wrapper. In code that tries to find  
> this
> link, I know only pointer to that object. Object are
> dynamically-allocated by engine and when I try to use delete  
> operator on
> it, engine crashes with segfault also.

I'm not sure I understand this part. If you have problems with  
ownership of pointers, the easiest solution that I would recommend is  
to use boost::shared_ptr<> and tell luabind to use that smart pointer  
as well when holding instances of those classes.

If you don't want to do that, I guess you would have to make sure you  
have the correct adopt semantics on all your functions (or simply let  
either the lua side or the c++ side own everything).

--
Arvid Norberg



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user