Problem to derive a base class in C++ or in Lua
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <7299901.101849.1249731234429.JavaMail.www@wwinf8215> |
Hello Everyone
I'm writing to you because i've just tryied to use LuaBind, and i get a few basic things working : binding a function, binding a basic class. But i can't derive a class. To be more precise I can't derive in Lua a class defined in C++ ; and I can't even derive in Lua a class defined also in Lua. My C++ and Lua code is below
As I'm a complete beginner with LuaBind, I suppose my mistake is obvious, but I don't see it.
I'm using MSVC++ 9.0 on windows Vista. I've put in my project folder the lua and luabind include file. I've also put luabind source file. I link with lua51.dll.
Thanks in advance for your help
my C++ code is :
extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}
#include "luabind/luabind.hpp"
#include
using namespace luabind;
using namespace std;
int main() {
lua_State *myLuaState = lua_open();
luaL_openlibs(myLuaState);
open(myLuaState);
int retLua = luaL_dofile(myLuaState,".\\Test.lua");
if (retLua !=0) {
cout << "erreur dans l'éxécution LUA :"<< retLua << endl;
}
lua_close(myLuaState);
return 0;
}
my Lua code is :
class 'lua_testclass'
function lua_testclass:__init(name)
self.name = name
end
function lua_testclass:print()
print(self.name)
end
a = lua_testclass('example')
a:print()
class 'derived' (lua_testclass)
function derived:__init() super('derived name')
end
function derived:print()
print('Derived:print() -> ')
lua_testclass.print(self)
end
b = derived('derived example')
b:print()
In this code, if b is a lua_testclass, there is no error.
Créez votre adresse électronique [email protected]
1 Go d'espace de stockage, anti-spam et anti-virus intégrés.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
luabind-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/luabind-user