Lua cpp expose
Exposition to Lua runtime mechanism proposition.
The user has to create an object that is LuaScriptAbleObject
, make it inherit the CRTPLuaScriptObject
class and voila.
For example, a simple FooBar examples might be:
// Default sample exposer for lua scripts
script_class (SampleObject) {
LUA_SCRIPTABLE_CLASS(SampleObject)
SampleObject() noexcept { fprintf(stderr, "CREATE SampleObject\n"); }
~SampleObject() noexcept { fprintf(stderr, "DESTROY SampleObject\n"); }
static int foo(lua_State *L) noexcept
{
SampleObject *obj = CHECK(L, 1);
double bar = luaL_checknumber(L, 2);
return 0;
}
static constexpr inline auto metaMethods = { luaRegDefaultGC, LUA_DECL_CREATE(SampleObject) };
static constexpr inline auto methods = { LUA_DECL_METHOD(SampleObject, foo) };
};
A sample file for a script can be found at utils/lua/sample-spec.lua
, this is just a proposition.
Modification effectuée par Kubat
Rapports de requête de fusion
Activité
requested review from @Elliu
assigned to @martin2018
added 1 commit
- 01d09552 - [WIP] SCRIPT: Try to simplify the declaration of Lua script-able classes
added 1 commit
- d7ba5a19 - [WIP] SCRIPT: Only expose the LuaContext object outside of the scripting parts of Vivy
added 1 commit
- 42aadbca - FIX: The lua interpreter need to be linked against the math lib on UNIX
added scripting label
added 34 commits
-
42aadbca...c42f6eb7 - 29 commits from branch
master
- a2ce3086 - [WIP] SCRIPT: Try to expose an object to Lua...
- aa8349d2 - [WIP] SCRIPT: Compiling but not tested objects used to expose things to the Lua runtime
- d5d70a34 - [WIP] SCRIPT: Try to simplify the declaration of Lua script-able classes
- 38111901 - [WIP] SCRIPT: Only expose the LuaContext object outside of the scripting parts of Vivy
- 8671ee95 - FIX: The lua interpreter need to be linked against the math lib on UNIX
Afficher/masquer la liste des validations-
42aadbca...c42f6eb7 - 29 commits from branch
added suggestion label
added 1 commit
- cbbd7161 - LUA: Add a sample lua script, a proposition of how to create a script
added 41 commits
-
cbbd7161...ce6944d7 - 34 commits from branch
master
- a11880c0 - [WIP] SCRIPT: Try to expose an object to Lua...
- 3b78e64e - [WIP] SCRIPT: Compiling but not tested objects used to expose things to the Lua runtime
- b249b674 - [WIP] SCRIPT: Try to simplify the declaration of Lua script-able classes
- bbfcb2bc - [WIP] SCRIPT: Only expose the LuaContext object outside of the scripting parts of Vivy
- 1f99b421 - FIX: The lua interpreter need to be linked against the math lib on UNIX
- 95dca532 - DOC: Update the lib dependencies
- 7d64c0a5 - LUA: Add a sample lua script, a proposition of how to create a script
Afficher/masquer la liste des validations-
cbbd7161...ce6944d7 - 34 commits from branch
added 1 commit
- a0f77353 - LUA: Add a sample lua script, a proposition of how to create a script
added 1 commit
- b8be649c - SCRIPT: Lua get last error + fix API usage (to many luaL_pop) + oupsi add some left over icons...
Veuillez vous inscrire ou vous connecter pour répondre