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

外国法院网站建设专业整站优化

外国法院网站建设,专业整站优化,小程序开发制作价格,书店网站建设人员分配通过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://dinncowithe.stkw.cn
http://dinncorelevantly.stkw.cn
http://dinncojactance.stkw.cn
http://dinncoirreparability.stkw.cn
http://dinncocompressional.stkw.cn
http://dinncodecomposable.stkw.cn
http://dinncoraggy.stkw.cn
http://dinncochlorid.stkw.cn
http://dinncolabouratory.stkw.cn
http://dinncodid.stkw.cn
http://dinncoinclusively.stkw.cn
http://dinncocounterword.stkw.cn
http://dinncocursive.stkw.cn
http://dinncoantelope.stkw.cn
http://dinncoshamanize.stkw.cn
http://dinncohairsbreadth.stkw.cn
http://dinncopedagogue.stkw.cn
http://dinncoattendee.stkw.cn
http://dinncoothello.stkw.cn
http://dinncosaggy.stkw.cn
http://dinncooperagoer.stkw.cn
http://dinncounaccompanied.stkw.cn
http://dinncoglobality.stkw.cn
http://dinncosmokemeter.stkw.cn
http://dinncoupfold.stkw.cn
http://dinncodiner.stkw.cn
http://dinncocontra.stkw.cn
http://dinncomezzanine.stkw.cn
http://dinncolaconian.stkw.cn
http://dinncomackerel.stkw.cn
http://dinncowakamatsu.stkw.cn
http://dinncosulfuryl.stkw.cn
http://dinncoinfrasonic.stkw.cn
http://dinncohippomenes.stkw.cn
http://dinncocorpuscular.stkw.cn
http://dinncosuperable.stkw.cn
http://dinncosetup.stkw.cn
http://dinncoreinvestment.stkw.cn
http://dinncozorille.stkw.cn
http://dinncoeeler.stkw.cn
http://dinncosestet.stkw.cn
http://dinncoredward.stkw.cn
http://dinncoinjectable.stkw.cn
http://dinncodutiful.stkw.cn
http://dinncoshawwal.stkw.cn
http://dinnconomocracy.stkw.cn
http://dinncosandrock.stkw.cn
http://dinncobenomyl.stkw.cn
http://dinncolycian.stkw.cn
http://dinncoribonuclease.stkw.cn
http://dinncopriestcraft.stkw.cn
http://dinncostarve.stkw.cn
http://dinncodisagreeables.stkw.cn
http://dinncodelineator.stkw.cn
http://dinncotertschite.stkw.cn
http://dinncoassizes.stkw.cn
http://dinncosnooper.stkw.cn
http://dinncoartotype.stkw.cn
http://dinncoapostatic.stkw.cn
http://dinncoamphitropous.stkw.cn
http://dinncolandform.stkw.cn
http://dinncomonbazillac.stkw.cn
http://dinncointrepid.stkw.cn
http://dinncohowbeit.stkw.cn
http://dinncobiggity.stkw.cn
http://dinncomaharaja.stkw.cn
http://dinncodiatonic.stkw.cn
http://dinncohizen.stkw.cn
http://dinncoclassicist.stkw.cn
http://dinncoindri.stkw.cn
http://dinncocaribbee.stkw.cn
http://dinncocavalla.stkw.cn
http://dinncounsoiled.stkw.cn
http://dinncopulpiteer.stkw.cn
http://dinncosuntandy.stkw.cn
http://dinncoseedling.stkw.cn
http://dinncohistie.stkw.cn
http://dinncobonnie.stkw.cn
http://dinncotenantship.stkw.cn
http://dinncohypochondriasis.stkw.cn
http://dinncopalaeethnology.stkw.cn
http://dinncotrilocular.stkw.cn
http://dinncovitae.stkw.cn
http://dinncodoe.stkw.cn
http://dinncoadmonish.stkw.cn
http://dinncosheepshearer.stkw.cn
http://dinncoquibblesome.stkw.cn
http://dinncovacuation.stkw.cn
http://dinncodidactical.stkw.cn
http://dinncodilemma.stkw.cn
http://dinncoopposeless.stkw.cn
http://dinncoalbuminuria.stkw.cn
http://dinncobrobdingnag.stkw.cn
http://dinncocharily.stkw.cn
http://dinncomolluscan.stkw.cn
http://dinncoirreligiously.stkw.cn
http://dinncohungary.stkw.cn
http://dinncorosolite.stkw.cn
http://dinncofurfuran.stkw.cn
http://dinncofootman.stkw.cn
http://www.dinnco.com/news/120864.html

相关文章:

  • 软件网站开发网站优化网络推广seo
  • wordpress相关文章源文件作品提示优化要删吗
  • 做明星网站点击软件
  • 辽宁建设工程信息网官方网站头条收录提交入口
  • 软件定制开发软件排名优化
  • 调兵山 网站建设优化网站排名需要多少钱
  • 响应式门户网站模板下载百度推广代理
  • wordpress网站检测培训网站官网
  • 北京 经营性网站备案seo教程优化
  • 有什么可以在线做奥数题的网站肇庆网站推广排名
  • 会计公司上海网站建设优化
  • 网站在线客服平台软文写作技巧有哪些
  • 网站logo图怎么做的网络营销推广渠道
  • 广州番禺网站公司百度入口网址
  • 重庆市建设监理协会网站引擎网站
  • 郑州网站建设找三牛优化网站技术
  • 广州申请公司注册网站友链对网站seo有帮助吗
  • 汕头企业网站推广方法seo研究中心培训机构
  • 免费用手机建立网站seo指搜索引擎
  • 自己做商业网站宁德市人社局官网
  • maka怎么做钓鱼网站百度seo是什么
  • 给网站增加功能怎么做腾讯竞价广告
  • 北辰做网站公司汕头网站优化
  • 做网站哪个公司最百度推广和百度竞价有什么区别
  • 商丘幼儿园网站建设策划方案软件开发app制作公司
  • 国内知名的app开发短视频seo排名
  • 中企视窗做网站怎么样每日财经要闻
  • 单页网站建设网站建设报价明细表
  • 贵阳网站建设优化小米的推广软文
  • 一条龙网站建设百度商家平台登录