ngl_server 1.0
基于 Actor 模型的 C++ 服务器框架
ngl::luafunction Class Reference

Lua函数绑定辅助类。 More...

#include <luafunction.h>

Public Member Functions

 luafunction (lua_State *aL, const char *ascriptpath, const char *afunction)
 构造函数。
template<typename ... TARGS>
bool set_call (const TARGS &... args)
 设置调用参数。
template<typename ... TARGS>
bool set_return (TARGS &... args)
 设置返回值处理。
bool call ()
 执行Lua函数调用。

Detailed Description

Lua函数绑定辅助类。

封装Lua函数调用,提供类型安全的参数传递和返回值处理。 简化C++与Lua脚本之间的交互。

Note
使用模板参数包支持可变参数。
自动处理Lua栈的清理和错误处理。

Constructor & Destructor Documentation

◆ luafunction()

ngl::luafunction::luafunction ( lua_State * aL,
const char * ascriptpath,
const char * afunction )
inline

构造函数。

Parameters
aLLua状态机指针
ascriptpath脚本文件路径
afunction函数名称

Member Function Documentation

◆ call()

bool ngl::luafunction::call ( )
inline

执行Lua函数调用。

调用Lua函数并处理返回值。包括:

  • 执行lua_pcall调用函数
  • 检查返回值数量
  • 调用返回值处理函数
Returns
调用成功返回true,否则返回false

◆ set_call()

template<typename ... TARGS>
bool ngl::luafunction::set_call ( const TARGS &... args)
inline

设置调用参数。

将C++参数推送到Lua栈中,并设置调用参数数量。

Template Parameters
TARGS参数类型包
Parameters
args参数值
Returns
设置成功返回true,否则返回false

◆ set_return()

template<typename ... TARGS>
bool ngl::luafunction::set_return ( TARGS &... args)
inline

设置返回值处理。

设置返回值数量和返回值处理函数。

Template Parameters
TARGS返回值类型包
Parameters
args返回值引用
Returns
设置成功返回true

The documentation for this class was generated from the following file: