luaplus 与官方文档慢慢扯(三)

【10. Wi-Fi 通用模组-小米 IoT 平台-如何进行硬件调试】 调试APP功能:从米家服务器缓存读取设备状态,等同于米家APP 的环境,开发者使用该调试器可模拟用户使用设备的实际情况,即调试米家 App 中的扩展程序。- 调试固件:调试器从固件读取设备状态,用于调试设备模组固件的某个单项功能,开发者使用该调试器可针对性地调试设备的某个功能。小爱语控测试工具:如果当前产品可被小爱语控,则可以使用该工具调试语控效果。调试APP功能(云端缓存) 阅读详情

以下未知  占位

 


 

 

Class: LuaStateAuto/Owner (Unmanaged Only)

LuaStateAuto is an auto pointer encapsulation for a LuaState pointer.  When the LuaStateAuto goes out of scope, LuaState::Destroy() is automatically called on the contained state.  In a Release build, LuaStateAuto's accessors are inlined, and code generation is as if the LuaStateAuto object did not even exist.

Using LuaStateAuto is illustrated below:

{
    LuaStateAuto stateOwner;  // The state is automatically set to NULL.
    stateOwner = LuaState::Create();
    stateOwner->PushNil();
    // LuaState::Destroy() is automatically called here.
}

LuaStateOwner is derived from LuaStateAuto.  LuaStateOwner can automatically create the LuaState through the function call LuaState::Create.

{
    LuaStateOwner stateOwner;  // Automatically calls LuaState::Create().
    stateOwner->PushNil();
    // LuaState::Destroy() is automatically called here.
}

Since a LuaStateAuto object merely encapsulates the LuaState pointer, it is possible to retrieve that pointer by just assigning it.

LuaState* state = stateOwner;

a

Class: LuaObject

LuaObject封装了所有lua堆栈操作 甚至让你感觉到没有在操作lua堆栈
而且它比lua capi操作堆栈效率更高
LuaObject 还有一些特殊能力 这里我就不扯了 我自己也搞不太清楚
有兴趣的自己看

LuaPlus provides an API extension over the core of Lua wrapped in the class LuaObject.  A LuaObject gives the full functionality of core Lua's stack entities, but it does so without involving the stack at all.  In general, LuaObjects tend to run a little faster than the core Lua stack equivalent.

A LuaObject should be used for all communication with LuaPlus that is external to a callback function.  LuaStackObjects, described below, are used in conjunction with callback functions, but the same functional interface is provided for consistency.

LuaObjects store a pointer to the parent LuaState.  In part, this is what makes the LuaWatchAddin work.  Most importantly, LuaObjects can just be passed around without any regard for the LuaState they came from.

It is also important to note LuaObjects are scope-driven.  So long as the LuaObject is in scope, the object is valid.  When it goes out of scope, the contents of the LuaObject will be garbage collected.  There is no need to run commands like lua_ref() to keep an object around.  Merely holding onto the LuaObject instance, be it as a member variable, global variable, or even local variable within a block of code is enough to ensure the LuaObject's existence.

A Reset() function is also provided.  It resets the LuaObject back to a default state where no Lua state is pointed to internally.

The sample code TestSuite performs an in-depth test of LuaObject and is a useful supplement to this documentation.  The sample TestScript is also used as a test bed for LuaObject concepts.


Object Type

LuaObject可以包含任意一种lua定义的类型 还有一种 wide string type 这是LuaPlus自己定义的类型

有以下几种方法检测指定类型(当然 如果是数字 用 IsString返回的会是1 因为number可以转换成string 这是lua的特性不可避免的)
  • IsNil() - Tests if the object is nil.  Mirrors lua_isnil().
  • IsTable() - Tests if the object is a table.  Mirrors lua_istable().
  • IsUserData() - Tests if the object is userdata (including light userdata).  Mirrors lua_isuserdata().
  • IsCFunction() - Tests if the object is a C function.  Mirrors lua_iscfunction().
  • IsInteger() - Tests if the exact type of the object is a number.  See IsConvertibleToNumber() for the LuaObject equivalent of lua_isnumber().
  • IsNumber() - Tests if the exact type of the object is a number.  See IsConvertibleToNumber() for the LuaObject equivalent of lua_isnumber().
  • IsString() - Tests if the exact type of the object is a string.  See IsConvertibleToString() for the LuaObject equivalent of lua_isstring().
  • IsWString() - Tests if the exact type of the object is a wide string.  See IsConvertibleToWString() for the wide string equivalent of lua_isstring().
  • IsConvertibleToInteger() - Tests if the object is convertible to a number.  The object being tested can be a number, string, or wide string.  Mirrors lua_isnumber().
  • IsConvertibleToNumber() - Tests if the object is convertible to a number.  The object being tested can be a number, string, or wide string.  Mirrors lua_isnumber().
  • IsConvertibleToString() - Tests if the object is convertible to a string.  The object being tested can be a number or a string.  Mirrors lua_isstring().
  • IsConvertibleToWString() - Tests if the object is convertible to a wide string.  The object being tested can be a number or a wide string.  Mirrors lua_iswstring(), the wide character equivalent of lua_isstring().
  • IsFunction() - Tests if the object is a function.  Mirrors lua_isfunction().
  • IsNone() - Tests if the object is out of range on the stack.  Mirrors lua_isnone().
  • IsLightUserData() - Tests if the object is specifically light user data.
  • IsBoolean() - Tests if the object is a boolean.  Mirrors lua_isboolean().

 

 

可以通过 Type()函数检查原始的真实类型
Type()的返回值是 LuaStatue类的一个枚举类型 下面是这个枚举值
可以通过 LuaObject类的函数 TypeName()  获得到类型名 有点类似 lua_typename()

取值函数

如果实际类型不可以转换你所要取的类型 
在 debug版本 都会触发assert
  • int ToInteger() - Mirrors lua_tonumber().  尝试从object对象内取出证书 即使实际类型为一个字符串
  • lua_Number ToNumber() - Mirrors lua_tonumber().  尝试从object对象内取出证书 即使实际类型为一个字符串
  • const char* ToString() - Mirrors lua_tostring().  尝试取出字符串,如果实际类型为number number将被强制转换为string
  • const lua_WChar* ToWString() - Mirrors lua_towstring().  尝试取出 宽字符串,如果实际类型为number number将被强制转换为宽字符
  • int GetInteger() - 取出整数 如果实际类型不是number将触发assert
  • float GetFloat() -同上
  • double GetDouble() - Retrieves the double the object represents.  Asserts if the object is not of a numeric type.
  • lua_Number GetNumber() - Retrieves the lua_Number the object represents.  Asserts if the object is not of a numeric type.
  • const char* GetString() - Retrieves the string the object represents.  Asserts if the object is not a single byte string type.
  • const lua_WChar* GetWString() - Retrieves the wide string the object represents.  Asserts if the object is not a double byte string type.
  • lua_CFunction GetCFunction() - Retrieves the C function pointer the object represents.  Asserts if the object is not a C function.
  • void* GetUserData() - Retrieves the userdata or light userdata the object represents.  Asserts if the object is not a userdata.
  • void* GetLightUserData() - Retrieves the light userdata the object represents.  Asserts if the object is not a light userdata.
  • bool GetBoolean() - Retrieves the boolean the object represents.  Asserts if the object is not a boolean convertible type.

如果 LuaObject 是 ANSI 或 宽字符 字符串,可以通过 StrLen() 取得字符串的长度
ToStrLen() 函数可用于获取自动转换到字符串的number类型的长度   ToStrLen () 同 lua_strlen() 

 

如果 object 类型为 table,function,userdata 或者 light userdata 那么 可以通过 GetLuaPointer() 获得储存在lua内部的指针

 

 

如何选择深度强化学习算法:MuZero/SAC/PPO/TD3/DDPG/DQN/等算法 阅读详情

相关推荐

Agentic AI上下文工程架构终极指南:全面解决智能体理解问题

在开始架构设计前,我们需要先明确两个核心概念——Agentic AI和上下文工程。Agentic AI(智能体AI)是具备自主目标、环境交互、任务分解能力的AI系统。自主性:不需要人类逐步指令,能自己规划任务(比如“帮我订机票”→自动分解为“查航班→选座位→填信息→支付”);动态性:能根据环境变化调整行为(比如订机票时发现航班延误,自动改签到下一班);连续性:能记住历史交互(比如“上次你说喜欢靠窗位,这次帮你预留了”)。

AI开发架构师 1123

【lua学习】5.栈和lua_State

1 背景2 栈(寄存器数组),虚拟机,全局状态机2.1 栈定义在lua_State结构体中2.2 global_State 全局状态机2.3 lua_newstate 主虚拟机和全局状态机的创建2.4 lua_close 关闭虚拟机2.5 lua_newthread 新建一个协程,压栈,返回这个新协程2.6 lua_atpanic 设置兜底异常处理函数(用于处理未捕获异常的函数),返回旧的兜底异常处理函数3 栈上的地址3.1 假索引3.2 根据数字索引获取栈上的地址4 基本的栈操作API4.1 lua_g.

qq_18138105的博客 4281

Windows系统3D Gaussian Splatting环境搭建全攻略:从零开始到成功运行

本文详细介绍了在Windows系统上搭建3D Gaussian Splatting环境的完整流程,包括CUDA 12.6安装、Anaconda环境配置、代码获取与依赖安装等关键步骤。针对Windows平台特有的环境配置问题,提供了实用的解决方案和常见错误排查方法,帮助开发者快速实现3D Gaussian Splatting的成功运行。

weixin_30832143的博客 462

lua 源码分析之线程对象lua_State

思路:  lua_State 中放的是 lua 虚拟机中的环境表、注册表、运行堆栈、虚拟机的上下文等数据。  从一个主线程(特指 lua 虚拟机中的线程,即 coroutine)中创建出来的新的 lua_State 会共享大部分数据,  但会拥有一个独立的运行堆栈。所以一个线程对象拥有一个lua_State。 (lua 的coroutine的使用参考: http://blog.csdn.n

陈嘉怡的专栏 1万+

linux 4.19在龙芯平台上编译出错解决方法

OS: Loongnix server 1.7 工具链为:系统自带的gcc-4.8.5 和 gcc-7.3 平台:3A3000/3A4000 源码:kernel: 4.19 编译步骤 ··· make loongson3_defconfig make -j4 ··· 出错信息: HOSTCC arch/mips/boot/compressed/calc_vmlinuz_load_addr arch/mips/boot/compressed/head.S: Assembler messages: arch/m

sense的专栏 1132

ESP32-S3 + TB6600驱动42步进电机:从基础接线到AccelStepper库平滑加减速实战

本文详细介绍了如何使用ESP32-S3开发板和TB6600驱动器控制42步进电机,从基础接线到利用AccelStepper库实现平滑加减速控制。内容涵盖硬件连接、基础驱动代码、AccelStepper库的安装与参数调优,以及高级技巧与故障排除,帮助创客实现工业级精准控制。

weixin_42632434的博客 291

lua的数据类型,lua_State,函数调用,协程

stack,stack_last],[base_ci,last_ci]分别是数据栈数组和调用栈数组,stacksize,size_ci分别是两个数组的大小,在需要的时候它们会进行增长。lua_State的top就是正在调用的函数的堆栈的位置啊。lua_call,lua_pcall都可以调lua或c函数,需要准备好函数在栈上。正在调用的函数一定存在于数据栈上,由func引用正在调用的函数对象。ci是当前正在调用的函数的运行状态,base是该函数的栈底指针。luaD_pcall,oldtop是干嘛用的。

https://gitee.com/liuyuan185442111/chest-view 1079

Win10环境借助DockerDesktop部署Open web UI集成DeepSeek

Win10环境借助DockerDesktop部署Open web UI集成DeepSeek,并借助DuckDuckGo实现联网查询

虎鲸不是鱼 1714

Lua笔记

LuaState ●LuaState封装了对lua 主要数据结构 lua_State 指针的各种堆栈操作。 ●一般对于客户端,推荐只创建一个LuaState对象。如果要使用多State需要在Unity中设置全局宏 MULTI_STATE ●LuaState.Start 需要在tolua代码加载到内存后调用。如果使用assetbunblde加载lua文件,调用Start()之前assetbundle必须加载好。 ●LuaState.DoString 执行一段lua代码,除了例子,比较少用这种方式加载代码,无法

xiao_shixiong的博客 539

将AAL图谱对应到Yeo7大网络中【原理,代码分析】

本文介绍了将AAL2图谱映射到Yeo7大功能网络的方法。通过整合皮层(Yeo2011)、小脑(Buckner2011)和纹状体(Choi2012)三个区域的功能网络图谱,采用投票机制确定每个AAL区域的网络归属。具体步骤包括:1)统计每个AAL区域体素在各网络图谱中的分布;2)选择体素数量最多的网络作为该区域的最终标签。该方法实现了从解剖结构到功能网络的映射,可获得120个AAL区域对应的7大功能网络标签。

yes666666的博客 2244

基于Gossip算法的柔性互联自治微网群分布式协调控制策略:复现代码与详细解释

摘要(149字): 本文基于Gossip算法实现了柔性互联微网群(MMG)的分布式协调控制策略仿真。研究构建了包含3个微网、10个分布式电源(DG)的MATLAB/Simulink模型,采用双层控制架构:上层通过柔性交流开关(FAS)实现微网间功率协调,下层利用Gossip算法完成DG间的边际成本一致性控制。重点开发了异步通信的Gossip算法核心函数,实现了分布式电源的自主边际成本估计与功率分配。仿真验证了系统在负荷变化和DG故障等工况下的协调控制能力,结果表明该策略能有效维持微网群的经济运行与功率平衡。

huanghm88的专栏 284

Lua的线程和状态 及协程

luaL_loadstring(L, "return coroutine.create(function() end)");   nCallResult = lua_pcall(L, 0, 1, 0); 创建一个协程和lua_newthread创建一个线程一样,不过这个创建会在线程的堆栈上压入一个上面的function() end; lua_newthread只是创建一个线程,堆栈个数为

linuxheik的专栏 3279

816华为OD机试真题 新系统 - 电池充电时间计算 (Java/Py/C/C++/Js/Go)

816华为OD机试真题 新系统 - 电池充电时间计算 (Java/Py/C/C++/Js/Go)

算法大师! 488

luaplus 与官方文档慢慢扯(六)

<br /> Calling Functions(调用lua函数)<br /> LuaObject 尝试简化Lua API 接口函数它做到了完全屏蔽掉堆栈方面的操作 一般情况下,调用Lua的函数可以在一行代码中完成Recommended Style(推荐风格)利用一些c++模板的技巧,使我们调用lua函数好像是在调用普通的c++函数LuaStateOwner state; state->DoString("function Add(x, y) return x + y end"); LuaFunctio

whitehack的专栏 2464

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

luaplus 与官方文档慢慢扯(五)

<br /> Registering Callbacks(注册lua c函数)<br />函数原型<br />int Callback(LuaState* state);  <br /> <br />作为一种替代机制 lua stack 是通过LuaStack类提供的<br />LuaPlus的回调函数使用了一种简单的函数机制  可以让全局函数 静态函数 非虚成员函数 与虚成员函数 成为回调函数<br /> <br />下面是一个示例 例子很简单就不注释了 (唯一需要注意的是  LuaStack args

whitehack的专栏 4038

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

luaplus 与官方文档慢慢扯(七)

<br /> Class: LuaTableIterator(lua table 迭代类 )<br />LuaPlus 提供了一个名为 LuaTableIterator 的类<br />他的作用是让我们在c++内遍历lua table时比使用标准lua CAPI更简单 方便 也更安全<br />(The iterator is not STL compliant in its current form.)<br />使用起来真的非常简单<br /> LuaStateOwner state; stat

whitehack的专栏 2377

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

luaplus 与官方文档慢慢扯(四)

<br /> Value Storage(值储存? 与lua交换值)<br /> <br />一般使用lua c api  push* 来把值压入堆栈<br />LuaObjects 提供了另一种实现 它不是基于堆栈的  (具体如何使用 暂时不懂 以后再回头看)<br />使用Assign*()系列函数 把值分发进LuaObject <br />下面是 Assign*系列函数<br /> AssignNil(LuaState* state)AssignBoolean(LuaState* state, boo

whitehack的专栏 2936

luaplus 与官方文档慢慢扯(一)

<br />此人文笔很烂 将就看吧<br /> <br />LuaState 是 c++版本的 Lua_State <br />大多数 lua的普通c函数 都基础在 LuaState内<br />两者效率相差不大<br /> <br /> <br />创建 LuaState 实例 <br /> <br />LuaState::Create() 静态函数用于创建一个 LuaState 实例<br />此函数有一个可选参数 <br />如果为true 则加载lua的标准库  同  luaL_openlibs(L

whitehack的专栏 3695

luaplus 与官方文档慢慢扯(二)

<br />堆栈操作相关函数<br /> GetTop() - Mirrors lua_gettop(). SetTop(int index) - Mirrors lua_settop(). PushValue(int index) - Mirrors lua_pushvalue(). PushValue(LuaStackObject& object) - Mirrors lua_pushvalue(). Remove(int index) - Mirrors lua_remove().

whitehack的专栏 2896

baidu luaplus luabind

luaplus介绍LuaPlus: 好用的Lua For C++扩展 - 沐枫小筑(C++) - C...LuaPlus是Lua的C++增强,也就是说,LuaPlus本身就是在Lua的源码上进行增强得来的。用它与C++进行合作,是比较好的一个选择。 LuaPlus目前版本为:LuaPlus for Lua 5.01 Distribution Build 1080 (February 28, 200

skyremember的专栏 6826

LuaPlus学习(三)

        从lua调用C++函数和对象        利用LuaPlus可以方便的从C++中调用lua脚本,翻过也一样。通过注册函数或类对象,lua便可以访问C++。    一、C风格函数注册    Lua提供了C风格的回调函数注册,该函数原型如下:int Callback(LuaState* state);    无论是全局函数、类非虚函数、类虚

安晓辉生涯——聚焦程序员的职业规划与成长 7068

LuaPlus上手指南

版权所有,转载请注明出处,勿用于商业用途,谢谢! 作者:    大宝天天见 Blog:    http://www.cppblog.com/singohgod 本人水平有限,有错请指出,欢迎交流,共同进步!   国内关于Lua的资料实在是太少,为了寻找一个合适的Lua的C++封装,真是如同大海捞针.在看了众多资料后锁定以下几种:LuaBind ToLua++ LuaPlu

把握自己。 4818

LuaPlus官方文档

LuaPlus for Lua 5.1 Distribution Build 1100+ (May 24, 2008) Enhancements to Core Lua Functionality http://luaplus.org/ Author: Joshua Jensen (jjensen@workspacewhiz.com) Overview The LuaPlus

优秀技术文章收录 4765

LuaPlus的使用

看大家都在研究lua,也参与大潮中。。。折腾半天没折腾好,相当的无语时候,网上找的资料都是你抄写我,我抄袭他的。。 郁闷,只要边抄袭边修改,最后测试成功,整理一个完整的资料发表下。再次感谢“雪明”与一个不知名的网友文章,不知道原作者,也就不发链接了。 如何编译 1.下载 首先到官方网站下载: http://www.luaplus.org/ 下载这个: All source code:

执着于我的执着 1539

LuaPlus学习(一)

    想在我的项目中使用Lua脚本语言。最初知道Lua是通过CEGUI,后来因为一些原因不打算使用CEGUI了,只好单独使用Lua。在网上看到LuaPlus,貌似比较简单。在此记录学习过程。    可以到这里http://luaplus.org/tiki-index.php?page=LuaPlus+Home+Page下载LuaPlus的win32二进制文件和源码包。从源码包提取头文件,从二进制

安晓辉生涯——聚焦程序员的职业规划与成长 1万+

LuaPlus学习(二)

     用lua做配置文件    可以用lua做程序的配置文件。    LuaPlus提供了读写lua脚本文件的功能,我们可以将配置信息以Table的形式存储在lua脚本中,然后利用LuaPlus进行读取和更改。    一、创建配置文件    配置文件可以用文字编辑器创建,也可以在C++代码中创建。我们先在C++中创建。利用CreateTable创建一个名为"Window"的表格,利

安晓辉生涯——聚焦程序员的职业规划与成长 4495
上一篇: LuaPlus官方文档
下一篇: luaplus 与官方文档慢慢扯(四)
whitehack
博客等级 码龄19年 67粉丝 123原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址