当前位置: 首页 > news >正文

郑州seo哪家公司最强宁波做seo推广企业

郑州seo哪家公司最强,宁波做seo推广企业,阜阳做网站有吗,建设一个网站费用通过c调用lua接口将数据存储到虚拟栈中,就可以在lua脚本在虚拟栈中取得数据 c调用lua库,加载lua文件, lua_State* L;//定义一个全局变量***************************L luaL_newstate();luaL_openlibs(L);//打开Lua脚本文件std::string pat…

通过c++调用lua接口将数据存储到虚拟栈中,就可以在lua脚本在虚拟栈中取得数据

c++调用lua库,加载lua文件,

lua_State* L;//定义一个全局变量***************************L = luaL_newstate();luaL_openlibs(L);//打开Lua脚本文件std::string path = SysContext::instance()->_env["WORKSPACE"] + "test.lua";luaL_dofile(L, path.c_str());lua_getglobal(L, "output");  //加载lua文件中的output函数pushLua(ObjsData(数据));int iRet = lua_pcall(L, 1, 1, 0);if (iRet)  // 调用出错{const char* pErrorMsg = lua_tostring(L, -1);lua_pop(L, 1);lua_close(L);return 1;}if (lua_isnumber(L, -1))  //取值输出{int fValue = lua_tonumber(L, -1);printf("fValue:%f\n", fValue);//do something}if (lua_isstring(L, -1))  //取值输出{std::string s = lua_tostring(L, -1);// do something}lua_close(L);

以下为c++调用lua接口存储数据

 其中 lua_settable(L, -3);

就是把表在lua堆栈中的值弹出来,index 是table 在堆栈中的位置,假如 table 在 -3, 则key 应该是 -2,value 是 -1

结构:最外层table=count+objs,count和objs都是一个table,objs内部又包含很多个table

void pushLua(ObjsData* obj) {int ntop = lua_gettop(L);lua_newtable(L);lua_pushstring(L, "count");  //这里需要output多一个输入lua_pushnumber(L, obj->count);lua_settable(L, -3);lua_pushstring(L, "objs");  //整体输入一个大的 tablefor (int i = 0; i < obj->count; i++) {const SingleObj* p = (const SingleObj*)&obj[1];lua_newtable(L);lua_pushnumber(L, i);lua_newtable(L);lua_pushstring(L, "x");lua_pushnumber(L, p->x);lua_settable(L, -3);lua_pushstring(L, "y");lua_pushnumber(L, p->y);lua_settable(L, -3);lua_pushstring(L, "z");lua_pushnumber(L, p->z);lua_settable(L, -3);lua_pushstring(L, "Volume");lua_pushnumber(L, p->volume);lua_settable(L, -3);lua_settable(L, -3);}lua_settable(L, -3);
}

lua脚本如下:

注意:table(键值对结构)嵌套,在取值的时候采用中括号取值,如objs[0]["x"],若key值是字符串,可以写成objs[0].x,但是数字应该只能写中括号的形式

str = "test" 
function output(x)print(x.objs[0].x)res= "count="..tostring(x.count)..",x="..tostring(x.objs[0].x)..",y="..tostring(x.objs[0].y).."\n"return res
end

参考:[Resolved] How to create nested Lua tables using the C API

http://www.hkea.cn/news/171776/

相关文章:

  • 刷会员网站怎么做外贸如何推广
  • 专做女装的网站网站备案是什么意思
  • 没有网站可以做seo排名吗小学生简短小新闻摘抄
  • 做程序网站需要什么代码宁波seo搜索排名优化
  • 网站建设开发语言新冠病毒最新消息
  • 怎么做1688网站网页制作工具有哪些
  • 一个网站的主题和设计风格最好用的免费建站平台
  • 网站开发主页手机优化游戏性能的软件
  • 怎么做属于自己的域名网站网络策划方案
  • destoon做的网站百度商务合作联系
  • 金山区网站制作网络营销策划书1500字
  • 厦门网站建设制作工具熊猫关键词挖掘工具
  • 徐州网站建设 网站推广百度首页快速排名系统
  • 在线转格式网站怎么做拼多多seo 优化软件
  • 成都理工疫情最新消息贵港seo
  • 网站如何防止攻击怎么自己做一个小程序
  • 企业网站建设英文百度收录
  • wordpress查版本sem和seo的区别
  • 网站设计说明书怎么写网站建设平台官网
  • 有建网站的软件阿里云域名注册万网
  • 站长工具排名分析怎么创建公司网站
  • 网站建设标书四川seo哪里有
  • 接网站开发做多少钱建一个外贸独立站大约多少钱
  • wordpress表单录入seo报告
  • python做网站显示表格星巴克seo网络推广
  • 一个com的网站多少钱管理微信软件
  • 蒙阴网站建设软文代写网
  • 用python做一旅游网站南昌seo计费管理
  • 湖北省建设厅win10优化软件哪个好
  • 湖南企业建站系统平台软文有哪些发布平台