游戏开发论坛

 找回密码
 立即注册
搜索
查看: 12497|回复: 5

关于lua的封装luawrapper-luabind-cpplua-tolua心得

[复制链接]

29

主题

421

帖子

436

积分

中级会员

Rank: 3Rank: 3

积分
436
发表于 2005-7-7 05:15:00 | 显示全部楼层 |阅读模式
CppLua,跨平台,用法简单,缺点是接口多,且不能向lua注册类。代码质量一般
tolua,跨平台,说是automatically bindC/C++ code to Lua,感觉还是说手动比较恰当,接口繁多。
luawrapper,基于魔板,需要boost支持,功能强大,略有瑕疵(例如函数参数个数不能大于9,当然一般情况下,如果函数参数超过5个,恐怕嘿嘿嘿),代码质量上乘且代码量最少(少得可怜,个人认为还可以废除1个不太可能用到的类),接口最少,跨平台,目前只支持VC7.0编译器。但略懂魔板编程的话,非常容易修改为其他编译器支持。[注:国产]
luabind,基于魔板,需要boost支持,功能最强大,是所有封装程序中最好的一个,代码质量上乘(太多大师级别的boost调用,看着好晕),说是跨平台,目前只VC7.0编译器,尝试修改,可惜个人水平过次,没有成功。

个人推荐luawrapper

8

主题

71

帖子

71

积分

注册会员

Rank: 2

积分
71
发表于 2005-7-7 07:05:00 | 显示全部楼层

Re:关于lua的封装luawrapper-luabind-cpplua-tolua心得

顶下金大大,
下载地址
CPPlua http://sourceforge.net/projects/cpplua/
tolua http://www.tecgraf.puc-rio.br/~celes/tolua/
tolua++ http://www.codenix.com/~tolua/
luawrapper http://www.d2-life.com/LBS/blogview.asp?logID=41
luabind http://luabind.sourceforge.net/


11

主题

102

帖子

102

积分

注册会员

Rank: 2

积分
102
发表于 2006-3-15 18:01:00 | 显示全部楼层

Re:关于lua的封装luawrapper-luabind-cpplua-tolua心得

Lua 5.1
http://www.lua.org/
(使用LuaBinaries所提供?先??好的?成的 .h ? .lib?n)
http://luabinaries.luaforge.net/

LuaWrapper
http://www.d2-life.com/LBS/blogview.asp?logID=41

boost 1.33.1 (LuaWrapper必?)
www.boost.org

使用VC++.Net 2003 ?一??MFC的?υ?框AP?0
可是LuaWrapper的部份, ??不起?

LuaWrapper\LuaWrap.h(48) : error C3861: 'lua_baselibopen': 找不到??e?,即使是使用?引?迪嚓P的查?也一?
LuaWrapper\LuaWrap.h(49) : error C3861: 'lua_tablibopen': 找不到??e?,即使是使用?引?迪嚓P的查?也一?
LuaWrapper\LuaWrap.h(50) : error C3861: 'lua_iolibopen': 找不到??e?,即使是使用?引?迪嚓P的查?也一?
LuaWrapper\LuaWrap.h(51) : error C3861: 'lua_strlibopen': 找不到??e?,即使是使用?引?迪嚓P的查?也一?
LuaWrapper\LuaWrap.h(52) : error C3861: 'lua_mathlibopen': 找不到??e?,即使是使用?引?迪嚓P的查?也一?
LuaWrapper\LuaWrap.h(53) : error C3861: 'lua_dblibopen': 找不到??e?,即使是使用?引?迪嚓P的查?也一?
LuaWrapper\LuaWrap.h(64) : error C3861: 'lua_dofile': 找不到??e?,即使是使用?引?迪嚓P的查?也一?
LuaWrapper\LuaWrap.h(72) : error C3861: 'lua_dobuffer': 找不到??e?,即使是使用?引?迪嚓P的查?也一?

有人有解答??

11

主题

102

帖子

102

积分

注册会员

Rank: 2

积分
102
发表于 2006-3-15 19:04:00 | 显示全部楼层

Re:关于lua的封装luawrapper-luabind-cpplua-tolua心得

//LuaWrapper.h?面改成??幽?

#define _Use_Lua_5_1 true

class LuaWrap
        : public luaStack
{
public:
        LuaWrap()
                : luaStack(lua_open())
        {
                // initialize lua standard library functions
               
                #ifdef _Use_Lua_5_1
                        //Lua 5.1初始化
                        luaopen_base(m_pluaVM);
                        luaopen_table(m_pluaVM);
                        luaopen_io(m_pluaVM);
                        luaopen_string(m_pluaVM);
                        luaopen_math(m_pluaVM);
                        luaopen_debug(m_pluaVM);

                        luaopen_os(m_pluaVM);        //?
                        luaopen_package(m_pluaVM);        //?
                #else
                        //Lua?版初始化
                        lua_baselibopen(m_pluaVM);
                        lua_tablibopen(m_pluaVM);
                        lua_iolibopen(m_pluaVM);
                        lua_strlibopen(m_pluaVM);
                        lua_mathlibopen(m_pluaVM);
                        lua_dblibopen(m_pluaVM);
                #endif
        }

        ~LuaWrap()
        {
                if(m_pluaVM)
                        lua_close(m_pluaVM);
        }
public:
        bool LoadFile(const char* filename)
        {
                #ifdef _Use_Lua_5_1
                        return luaL_loadfile(m_pluaVM, filename) == 0;
                #else
                        return lua_dofile(m_pluaVM, filename) == 0;
                #endif
        }
        bool LoadString(const char* buffer)
        {
                return LoadBuffer(buffer, strlen(buffer));
        }
        bool LoadBuffer(const char* buffer, size_t size)
        {
                #ifdef _Use_Lua_5_1
                        return luaL_loadbuffer(m_pluaVM, buffer, size, "LuaWrap") == 0;
                #else
                        return lua_dobuffer(m_pluaVM, buffer, size, "LuaWrap") == 0;
                #endif
        }

        void Register(const char* func, lua_CFunction f)
        {
                lua_register(m_pluaVM, func, f);
        }

        template<class LUATYPE>
        void Register()
        {
                LUATYPE:uaOpenLibMember(m_pluaVM);
                LUATYPE::LuaOpenLib(m_pluaVM);
        }

        //operator lua_State* ()
        //{
        //        return m_pluaVM;
        //}
};

11

主题

102

帖子

102

积分

注册会员

Rank: 2

积分
102
发表于 2006-3-15 20:41:00 | 显示全部楼层

Re:关于lua的封装luawrapper-luabind-cpplua-tolua心得

?死中....
?是??不起??

正在??...
LIBC.lib(crt0dat.obj) : error LNK2005: _exit 已?定?於 msvcrt.lib(MSVCR71.dll)
LIBC.lib(crt0dat.obj) : error LNK2005: __exit 已?定?於 msvcrt.lib(MSVCR71.dll)
LIBC.lib(crt0dat.obj) : error LNK2005: __cexit 已?定?於 msvcrt.lib(MSVCR71.dll)
LIBC.lib(crt0dat.obj) : error LNK2005: __c_exit 已?定?於 msvcrt.lib(MSVCR71.dll)
LIBC.lib(crt0init.obj) : error LNK2005: ___xc_z 已?定?於 msvcrt.lib(cinitexe.obj)
LIBC.lib(crt0init.obj) : error LNK2005: ___xc_a 已?定?於 msvcrt.lib(cinitexe.obj)
LIBC.lib(crt0init.obj) : error LNK2005: ___xi_z 已?定?於 msvcrt.lib(cinitexe.obj)
LIBC.lib(crt0init.obj) : error LNK2005: ___xi_a 已?定?於 msvcrt.lib(cinitexe.obj)
LINK : warning LNK4098: ??的程式? 'msvcrt.lib' ?其他使用的程式?煨n突; ?使用 /NODEFAULTLIB:library
LINK : warning LNK4098: ??的程式? 'LIBC' ?其他使用的程式?煨n突; ?使用 /NODEFAULTLIB:library

1

主题

15

帖子

21

积分

注册会员

Rank: 2

积分
21
发表于 2008-10-17 18:20:00 | 显示全部楼层

Re:关于lua的封装luawrapper-luabind-cpplua-tolua心得

2006的版本啊,现在变化如何?
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-21 02:23

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表