简体   繁体   English

C ++和LuaJIT,作用域脚本环境

[英]C++ and LuaJIT, Scoped script environment

I've been using LuaJIT for some times now. 我已经使用LuaJIT已有一段时间了。 The tip of the iceberg was enought for my needs until now, but my recent project require me to dig a little deeper. 到目前为止,冰山一角还无法满足我的需求,但是我最近的项目要求我进行更深入的研究。

My actual knowledge of LuaJIT is making function available from C++ to Lua and from Lua to C++. 我对LuaJIT的实际了解是使函数从C ++到Lua以及从Lua到C ++都可用。 That include passing parameters, tables and retrieving return values. 其中包括传递参数,表和检索返回值。

This is the model I am used to: 这是我习惯的模型:

这是我习惯的模型。

I tried to search around for "scoped environement luajit" and multiple variation of the query, but unfortunately I did not find anything relevant. 我试图搜索“作用域环境”和查询的多个变体,但是不幸的是,我没有找到任何相关内容。 I might not use the right words? 我可能不会使用正确的词?

This is the model I want to achieve : 这是我要实现的模型:

这是我要实现的模型。

I want to make a "global script environment" that I will share the C++ functions with then make it available to the "scoped script environments". 我想创建一个“全局脚本环境”,与之共享C ++函数,然后将其提供给“作用域脚本环境”。

//push arguments
luaScopedEnvironment1->call("doSomething");

I just want a starting point, help for the terminology and maybe some pointers to related documentation :) 我只是想要一个起点,术语的帮助以及可能指向相关文档的一些指针:)

Thanks you for taking time to read me. 感谢您抽出宝贵的时间阅读我的内容。

I dont think Lua or LuaJIT supports such a thing but if I'm not mistaken, what you are after is called "sandboxing". 我不认为Lua或LuaJIT支持这样的事情,但是如果我没记错的话,您追求的是“沙盒”。

It creates a new environment with which you can strip out or add functionality to. 它创建了一个新环境,您可以在其中删除或添加功能。 Its handy for removing IO and OS functionality. 方便删除IO和OS功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM