|
| static bool | isnumber (lua_State *L) |
| | 检查Lua栈顶元素是否为数字类型
|
| static void | pushnumber (lua_State *L, double adata) |
| | 将double值压入Lua栈
|
| static bool | popnumber (lua_State *L, double &adata, bool apop=true) |
| | 从Lua栈顶弹出double值
|
| static bool | isnil (lua_State *L) |
| | 检查Lua栈顶元素是否为nil
|
| static void | pushnil (lua_State *L) |
| | 将nil值压入Lua栈
|
| static bool | popnil (lua_State *L, bool apop=true) |
| | 从Lua栈顶弹出nil值
|
| static bool | isinteger (lua_State *L) |
| | 检查Lua栈顶元素是否为整数类型
|
| static void | pushinteger (lua_State *L, int64_t aval) |
| | 将int64_t值压入Lua栈
|
| static bool | popinteger (lua_State *L, int64_t &aval, bool apop=true) |
| | 从Lua栈顶弹出int64_t值
|
| static bool | isstring (lua_State *L) |
| | 检查Lua栈顶元素是否为字符串类型
|
| static const char * | pushstring (lua_State *L, const char *astr) |
| | 将C字符串压入Lua栈
|
| static const char * | pushstring (lua_State *L, const std::string &astr) |
| | 将std::string压入Lua栈
|
| static bool | popstring (lua_State *L, std::string &aval, bool apop=true) |
| | 从Lua栈顶弹出字符串到std::string
|
| static bool | popstring (lua_State *L, const char *&aval, bool apop=true) |
| | 从Lua栈顶弹出字符串到C字符串指针
|
| static bool | isboolean (lua_State *L) |
| | 检查Lua栈顶元素是否为布尔类型
|
| static void | pushboolean (lua_State *L, bool aval) |
| | 将布尔值压入Lua栈
|
| static bool | popboolean (lua_State *L, bool &aval, bool apop=true) |
| | 从Lua栈顶弹出布尔值
|
| static void | register_func (lua_State *L, const char *afuncname, lua_CFunction fn) |
| | 注册C函数到Lua全局环境
|
| static void | add_package_path (lua_State *L, const char *apath) |
| | 添加Lua包搜索路径
|
◆ add_package_path()
| void ngl::luaapi::add_package_path |
( |
lua_State * | L, |
|
|
const char * | apath ) |
|
static |
添加Lua包搜索路径
- Parameters
-
| L | Lua状态机指针 |
| apath | 要添加的路径,应以'/'结尾 |
扩展package.path,使require函数能在指定目录查找Lua模块 路径格式: "path/?.lua",其中?会被模块名替换
- Note
- 用于项目自定义Lua脚本目录的加载
◆ isboolean()
| bool ngl::luaapi::isboolean |
( |
lua_State * | L | ) |
|
|
static |
检查Lua栈顶元素是否为布尔类型
- Parameters
-
- Returns
- 如果栈顶元素是布尔值返回true,否则返回false
- Note
- Lua中布尔值是独立类型,不参与自动转换
◆ isinteger()
| bool ngl::luaapi::isinteger |
( |
lua_State * | L | ) |
|
|
static |
检查Lua栈顶元素是否为整数类型
- Parameters
-
- Returns
- 如果栈顶元素是整数返回true,否则返回false
- Note
- Lua 5.3+区分整数和浮点数类型
◆ isnil()
| bool ngl::luaapi::isnil |
( |
lua_State * | L | ) |
|
|
static |
检查Lua栈顶元素是否为nil
- Parameters
-
- Returns
- 如果栈顶元素是nil返回true,否则返回false
- Note
- nil在Lua中表示"无值"状态
◆ isnumber()
| bool ngl::luaapi::isnumber |
( |
lua_State * | L | ) |
|
|
static |
检查Lua栈顶元素是否为数字类型
- Parameters
-
- Returns
- 如果栈顶元素是数字返回true,否则返回false
- Note
- 这是一个轻量级检查,不会修改栈内容
◆ isstring()
| bool ngl::luaapi::isstring |
( |
lua_State * | L | ) |
|
|
static |
检查Lua栈顶元素是否为字符串类型
- Parameters
-
- Returns
- 如果栈顶元素是字符串返回true,否则返回false
- Note
- Lua会自动将数字转换为字符串,因此数字也会返回true
◆ popboolean()
| bool ngl::luaapi::popboolean |
( |
lua_State * | L, |
|
|
bool & | aval, |
|
|
bool | apop = true ) |
|
static |
从Lua栈顶弹出布尔值
- Parameters
-
| L | Lua状态机指针 |
| aval | [out] 存储弹出的布尔值 |
| apop | 是否从栈中弹出元素,默认为true |
- Returns
- 成功获取布尔值返回true,失败返回false
- Note
- 如果栈顶不是布尔类型,操作失败
◆ popinteger()
| bool ngl::luaapi::popinteger |
( |
lua_State * | L, |
|
|
int64_t & | aval, |
|
|
bool | apop = true ) |
|
static |
从Lua栈顶弹出int64_t值
- Parameters
-
| L | Lua状态机指针 |
| aval | [out] 存储弹出的int64_t值 |
| apop | 是否从栈中弹出元素,默认为true |
- Returns
- 成功获取整数返回true,失败返回false
- Note
- 如果栈顶不是整数类型,操作失败
◆ popnil()
| bool ngl::luaapi::popnil |
( |
lua_State * | L, |
|
|
bool | apop = true ) |
|
static |
从Lua栈顶弹出nil值
- Parameters
-
| L | Lua状态机指针 |
| apop | 是否从栈中弹出元素,默认为true |
- Returns
- 成功获取nil返回true,失败返回false
- Note
- 如果栈顶不是nil,操作失败
◆ popnumber()
| bool ngl::luaapi::popnumber |
( |
lua_State * | L, |
|
|
double & | adata, |
|
|
bool | apop = true ) |
|
static |
从Lua栈顶弹出double值
- Parameters
-
| L | Lua状态机指针 |
| adata | [out] 存储弹出的double值 |
| apop | 是否从栈中弹出元素,默认为true |
- Returns
- 成功获取数字返回true,失败返回false
- Note
- 如果apop为false,元素将保留在栈顶
◆ popstring() [1/2]
| bool ngl::luaapi::popstring |
( |
lua_State * | L, |
|
|
const char *& | aval, |
|
|
bool | apop = true ) |
|
static |
从Lua栈顶弹出字符串到C字符串指针
- Parameters
-
| L | Lua状态机指针 |
| aval | [out] 存储弹出的字符串指针 |
| apop | 是否从栈中弹出元素,默认为true |
- Returns
- 成功获取字符串返回true,失败返回false
- Warning
- 返回的指针指向Lua内部内存,在Lua垃圾回收前有效
◆ popstring() [2/2]
| bool ngl::luaapi::popstring |
( |
lua_State * | L, |
|
|
std::string & | aval, |
|
|
bool | apop = true ) |
|
static |
从Lua栈顶弹出字符串到std::string
- Parameters
-
| L | Lua状态机指针 |
| aval | [out] 存储弹出的字符串 |
| apop | 是否从栈中弹出元素,默认为true |
- Returns
- 成功获取字符串返回true,失败返回false
- Note
- 如果栈顶元素无法转换为字符串,操作失败
◆ pushboolean()
| void ngl::luaapi::pushboolean |
( |
lua_State * | L, |
|
|
bool | aval ) |
|
static |
将布尔值压入Lua栈
- Parameters
-
- Note
- 在Lua中,false和nil为假,其他值为真
◆ pushinteger()
| void ngl::luaapi::pushinteger |
( |
lua_State * | L, |
|
|
int64_t | aval ) |
|
static |
将int64_t值压入Lua栈
- Parameters
-
| L | Lua状态机指针 |
| aval | 要压入的int64_t值 |
- Note
- 使用Lua整数类型,避免浮点精度损失
◆ pushnil()
| void ngl::luaapi::pushnil |
( |
lua_State * | L | ) |
|
|
static |
将nil值压入Lua栈
- Parameters
-
- Note
- nil是Lua的特殊值,表示变量未定义或无值
◆ pushnumber()
| void ngl::luaapi::pushnumber |
( |
lua_State * | L, |
|
|
double | adata ) |
|
static |
将double值压入Lua栈
- Parameters
-
| L | Lua状态机指针 |
| adata | 要压入的double值 |
- Note
- 压入后栈顶元素变为该数字
◆ pushstring() [1/2]
| const char * ngl::luaapi::pushstring |
( |
lua_State * | L, |
|
|
const char * | astr ) |
|
static |
将C字符串压入Lua栈
- Parameters
-
- Returns
- 返回Lua内部字符串指针
- Note
- Lua会复制字符串内容,调用者可以释放原字符串
◆ pushstring() [2/2]
| const char * ngl::luaapi::pushstring |
( |
lua_State * | L, |
|
|
const std::string & | astr ) |
|
static |
将std::string压入Lua栈
- Parameters
-
| L | Lua状态机指针 |
| astr | 要压入的std::string引用 |
- Returns
- 返回Lua内部字符串指针
- Note
- 重载版本,方便与STL字符串交互
◆ register_func()
| void ngl::luaapi::register_func |
( |
lua_State * | L, |
|
|
const char * | afuncname, |
|
|
lua_CFunction | fn ) |
|
static |
注册C函数到Lua全局环境
- Parameters
-
| L | Lua状态机指针 |
| afuncname | 在Lua中使用的函数名 |
| fn | C函数指针 |
- Note
- 注册后可在Lua中直接调用该函数名
The documentation for this class was generated from the following files: