all.h

来自「一个symbian 冒险游戏代码」· C头文件 代码 · 共 75 行

H
75
字号
#ifndef _LUA_ALL_H
#define _LUA_ALL_H


/**
 * @defgroup lua Lua C++ wrapper for scripting support
 *
 * Very simple to use Lua wrapper for C++ integration.
 * Provides support for one-line C++ method registration
 * and one-line Lua function call. For usage example 
 * see source/lua/test.cpp (=unit test of Lua library).
 * For brief introduction to Lua, see docs/lua.pdf document.
 *
 * Minimal usage example:
 * 
\verbatim 

In myclass.lua ---------------------------

function f( x )
    print( "x+x=" .. add(x,x) )
end


In MyClass.cpp ---------------------------
  
#include <lua/LuaState.h>
#include <lua/LuaObject.h>

class MyClass : public lua::LuaObject
{
public:
    float add( float a, float b )
    {
        return a+b;
    }

    MyClass( LuaState* luastate ) :
        LuaObject( luastate )
    {
        // after this call, add(a,b) can be used from Lua script:
        registerMethod( "add", this, &MyClass::add );
    }
};

int main()
{
    P(LuaState) luastate = new LuaState;
    P(MyClass) myobj = new MyClass( luastate );

    FileInputStream in( "myclass.lua" );
    luastate->compile( &in, in.available(), in.toString(), myobj );

    // executes the function in Lua script:
    myobj->call( "f", 3.f );
}

\endverbatim
 *
 *
 * @{
 */

#include <lua/LuaException.h>
#include <lua/LuaStackRestore.h>
#include <lua/LuaState.h>
#include <lua/LuaTable.h>

/** @} */


#endif // _LUA_ALL_H


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?