luabind

Obtaining a pointer to Lua object instance in C++

I am using Luabind to expose a base class from C++ to Lua from which I can derive classes in Lua. This part works correctly and I am able to call C++ methods from my derived class in Lua. Now what I want to do is obtain a pointer to the Lua-based instance in my C++ program. C++ -> Binding class Enemy { private: std::string name; pu...

Luabind Function using std::string& Reference with pure_out_value policy not possible?

I'am trying to return a string from a function but it doesn't compile. When I replace the std::string& type with int& it compiles, however I want to return additionally to the boolean a std::string how do I do this? bool luacw_getElementContent( std::string name, std::string& content, bool fromBeginning ) { content = "test"; retur...

Lost references in Lua

Having a problem with objects, not needed any more but still having references. Result: size of allocated memory is constantly growing due to not collected objects. How to solve this sort of problem? Is there any way to find objects with only one reference, or objects with lifetime more than some value? Or any another solution? Using L...

Problem with luabind::object dereferencing (simplified)

Using C++, lua5.1, luabind 0.7 Lua code: -- allocates near 8Mb of memory function fff() local t = {} for i = 1, 300000 do table.insert(t, i) end return t end C++ code: { luaL_dostring(lua_state, "return fff()"); luabind::object obj(luabind::from_stack(ls, -1)); } lua_gc(l_, LUA_GCCOLLECT, 0); // colle...

Storing a lua class with parent in luabind::object (updated)

Using C++, lua 5.1, luabind 0.7-0.81 Trying to create a lua class with parent and store it in a luabind::object. Lua class 'TestClassParent' function TestClassParent:__init() print('parent init\n') end function TestClassParent:__finalize() print('parent finalize\n') end class 'TestClass' (TestClassParent) function TestCla...

Luabind class deriving problem (memory 'leak')

Using luabind 0.81 Simple test to illustrate the problem: 1) class 'A' function A:__init() print('A init\n') end function A:__finalize() print('A finalize\n') end do local obj = A() end collectgarbage("collect") Output: A init A finalize 2) class 'A' function A:__init() print('A init\n') end function A:__finaliz...

Access violation when exporting a C++ class to Lua using LuaBind

I'm trying to export a simple class to Lua using LuaBind. I took the code from two sites which showed roughly the same way to do it, but it's still failing. // Default headers #include <iostream> #include <string> // Lua headers extern "C" { #include "lua.h" #include "lualib.h" #include "lauxlib.h" } #include "luabind/luab...

Problem in luabind with default_converter and tables

===Edit=== The problem is actually much simpler than this, any wrapped function that takes a table is causing the problem. If I wrap a function that takes luabind::object, and call that function with a table argument, then the gc causes an invalid free(). I'm starting to think that this may be some kind of crazy compilation/linking pr...

Luabind conditionally calling Lua function

I have some code using Luabind, and I need to execute a function (from C++) if it's present in the _G table, but otherwise do nothing. How do I detect if a function is present in _G or not? ...

How do I use Luabind and C++ to create an asset managing class?

I've made countless attempts to get this working, but everything I do gives me run-time errors. I've been trying to make asset managers to manage content for my game engine, and I'm using lua and luabind for my scripting. Getting everything to compile, binding classes and variables, and getting basic variables back from lua have been no ...

Binding functions of derived class with luabind

I am currently developing a plugin-based system in C++ which provides a Lua scripting interface, for which I chose to use luabind. I'm using Lua 5 and luabind 0.9, both statically linked and compiled with MSVC++ 8. I am now having trouble binding functions with luabind when they are defined in a derived class, but not its parent class. ...

Converting Luabind to C#?

Has anybody tried converting Luabind to C#? Is such a thing even possible? I've got an application that I want to convert so that it can run in a completely managed environment, but most of the game logic relies upon Lua scripts, and the application uses Luabind to manage the back-and-forth. I'm not familiar enough with Lua or Luabind...

How to iterate through luabind class (in lua or in c++)?

How to iterate through luabind class (in lua or in c++)? class 'A' function A:__init() -- Does not work -- self is userdata, not a table for i, v in pairs(self) do end end Thanks ...

How to override luabind class __finalize method?

How to override luabind class __finalize method? Trying to do this in such way: class A function A:__init() end function A:__finalize() end local original_finalize_function = A.__finalize A.__finalize = function(...) -- some custom logic if original_finalize_function then original_finalize_function(unpack(arg)) end end local...

MSVC 10 + Luabind + std::vector == refuse to compile.

So, I have a code, that compiled on MSVC 9 and some previous (dunno how far back it goes...), GCC, MingW, GCC on Mac... But one line, does not compile on MSVC: class_< vector<unsigned int> >("LayerList") .def(constructor<>()) .def("GetCount", &vector<unsigned int>::size) .def("Get", &NumberGet) .def("Add", &vector<unsigned int>::push_...

Lua shutdown/End of the program execution callback

I am writing a module for Lua. On closing the lua interpreter it must run clean up routines even if user forgets to call shutdown routine implicitly. The module is mostly written in C. What callback in Lua C Api should I use to detect end of program execution? The only idea I have come with is using __gc metamethod on table representi...