luabind

LuaBind and package.loadlib

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 14:49:05
I'm trying to go through the tutorial with luabind here, http://www.rasterbar.com/products/luabind/docs.html , however i'm having trouble loading the library. I'm currently using version 5.1 of lua, so I believe I would use package.loadlib instead of loadlib. I made a simple dll which is this: #include <iostream> #include <luabind\luabind.hpp> void greet() { std::cout << "Hello world!\n"; } extern "C" int init(lua_State* L) { luabind::open(L); luabind::module(L) [ luabind::def("greet", &greet) ]; return 0; } This builds just fine. However I get an error in lua when I try to run this code:

How to reference .cpp files without including them into the solution in Visual Studio?

£可爱£侵袭症+ 提交于 2019-12-04 05:17:18
问题 I'm trying to compile this code: extern "C" { #include <lua.h> #include <lualib.h> #include <lauxlib.h> } #include <luabind/luabind.hpp> #include<iostream> int main(){ lua_State*pL=lua_open(); luabind::open(pL); lua_close(pL); return 0; } But I don't have a .lib of luabind , so I use the source with the .h/.cpp files. The way I do it is by adding the directories to include, but I get a link error. The only way I can compile is by adding the .cpp files as existing elements, but the solution

Calling C++ member function from Luabind causes “No matching overload found”

狂风中的少年 提交于 2019-12-03 21:36:23
I've got some classes exported to Luabind in a DLL, and everything is working fine for those 2 classes (LuaScriptManager, EventManager). I can call their functions from Lua and all is well, but now I'm trying to setup some new class in my client executable which links with the DLL and so far no luck at all. Here's the error message I get for every function that I call: "No matching overload found, candidates: void loadResource(ResourceManager&, std::string const&)" The class binding is from http://www.nuclex.org/articles/5-cxx/1-quick-introduction-to-luabind : struct Manager { Manager() : m

How to reference .cpp files without including them into the solution in Visual Studio?

陌路散爱 提交于 2019-12-02 03:08:12
I'm trying to compile this code: extern "C" { #include <lua.h> #include <lualib.h> #include <lauxlib.h> } #include <luabind/luabind.hpp> #include<iostream> int main(){ lua_State*pL=lua_open(); luabind::open(pL); lua_close(pL); return 0; } But I don't have a .lib of luabind , so I use the source with the .h/.cpp files. The way I do it is by adding the directories to include, but I get a link error. The only way I can compile is by adding the .cpp files as existing elements, but the solution tree gets messy with the additional files. Can somebody tell me if there's a way to add the directory of

Lua shutdown/End of the program execution callback

落爺英雄遲暮 提交于 2019-12-01 21:06:29
问题 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 representing my module. Any ideas? 回答1: From a C module, the simple thing to do is to create a full userdata with a metatable with a __gc metamethod. Store it in a field

Storing a lua class with parent in luabind::object

☆樱花仙子☆ 提交于 2019-12-01 20:29:09
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 TestClass:__init() print('init\n') TestClassParent.__init(self) end function TestClass:__finalize() print('finalize\n') end C++ { luabind::object obj = luabind::call_function<luabind::object>(lua_state, "TestClass"); } printf("before GC\n"); lua_gc(lua, LUA_GCCOLLECT, 0); printf(

Lua shutdown/End of the program execution callback

主宰稳场 提交于 2019-12-01 20:06:29
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 representing my module. Any ideas? From a C module, the simple thing to do is to create a full userdata with a metatable with a __gc metamethod. Store it in a field in the module's environment so it isn't collected by the GC until the module is unloaded. According to the

C++ class member function pointer to function pointer

≡放荡痞女 提交于 2019-11-28 04:21:51
问题 I am using luabind as my lua to C++ wrapper. Luabind offers a method to use my own callback function to handle exceptions thrown by lua, set_pcall_callback(). So I paraphrased an example from the documentation, the changes being the logger->log() function and putting the function in a class called 'Engine', so instead of it being a regular global function it is now a member function, which is where my problem seems to be. Here are the relevant code snips: class Engine //Whole class not shown

Why can't I catch a luabind::error exception when my lua code throws an error?

吃可爱长大的小学妹 提交于 2019-11-28 04:19:43
问题 When you call a LUA function from c++ and there is a runtime error LuaBind throws a luabind::error exception that you can catch and then read the stack to see what the error was. My debugger definitely catches this exception but when I let the debugger continue, instead of the exception being caught in my code the program immediately terminates. The exception is thrown in "call_member.hpp" in the LuaBind include files from the destructor ~proxy_member_void_caller(). The problem occurs with