Questions about luabind::object
Jason McKesson <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
I have a question about the interaction with the stack for luabind::object instances and lifetimes. OK, so I have a lua chunk. I have loaded it with lua_load. Therefore, it is on the stack at index -1. So if I do: luabind::object TheChunk(luabind::from_stack(pState, -1)) The variable "TheChunk" will hold this function. So question 1: Is the function still on the stack? It looks like it is from the documentation, as it says that "This will create the object o and copy the value from the top of the lua stack." Question 2: If it is still on the stack, what happens to the object if I pop it off of the stack? Is the object in danger of being garbage collected after popping it, or is the object lifetime now controlled by the lifetime of "TheChunk"? Question 3: If the object holds a copy, exactly where is this copy? If the copy is considered a valid Lua reference (thus making it ineligible for garbage collection), how exactly does that work? How does Luabind accomplish this? ------------------------------------------------------------------------------ Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev