diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-09-26 18:36:47 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-12-14 11:00:25 +0100 |
commit | c22ad857bcd2f567d22f3239d91fa65720718713 (patch) | |
tree | 165407be42745a190672ff64fe27503074380735 /controller | |
parent | 7f5a4ef3053eaac5c3f936b6294087d3d2b72c38 (diff) |
lua2c completely operationnal
- Retrieve args from lua call correctly
- Correctly push and set function pointer into plugin
symbols
Change-Id: I12d03e1101c458a042887a67a35a08082bd98f4c
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'controller')
-rw-r--r-- | controller/ctl-lua.c | 4 | ||||
-rw-r--r-- | controller/ctl-lua.h | 10 | ||||
-rw-r--r-- | controller/ctl-plugin.c | 3 |
3 files changed, 8 insertions, 9 deletions
diff --git a/controller/ctl-lua.c b/controller/ctl-lua.c index 518ff85..f694e58 100644 --- a/controller/ctl-lua.c +++ b/controller/ctl-lua.c @@ -610,9 +610,9 @@ STATIC int LuaAfbEventMake(lua_State* luaState) { } // Function call from LUA when lua2c plugin L2C is used -int Lua2cWrapper(lua_State* luaState, char *funcname, Lua2cFunctionT callback) { +int Lua2cWrapper(lua_State* luaState, const char *funcname, Lua2cFunctionT callback) { - json_object *argsJ= LuaPopArgs(luaState, LUA_FIST_ARG+1); + json_object *argsJ = LuaPopArgs(luaState, LUA_FIST_ARG); int response = (*callback) (funcname, argsJ); // push response to LUA diff --git a/controller/ctl-lua.h b/controller/ctl-lua.h index d41c6a5..0b8de45 100644 --- a/controller/ctl-lua.h +++ b/controller/ctl-lua.h @@ -59,13 +59,13 @@ extern "C" { int LuaLibInit (); -typedef int (*Lua2cFunctionT)(char *funcname, json_object *argsJ); -typedef int (*Lua2cWrapperT) (lua_State* luaState, char *funcname, Lua2cFunctionT callback); +typedef int (*Lua2cFunctionT)(const char *funcname, json_object *argsJ); +typedef int (*Lua2cWrapperT) (lua_State* luaState, const char *funcname, Lua2cFunctionT callback); #define CTLP_LUALOAD Lua2cWrapperT Lua2cWrap; -#define CTLP_LUA2C(FuncName, label,argsJ) static int FuncName(char*label,json_object*argsJ);\ +#define CTLP_LUA2C(FuncName, label, argsJ) static int FuncName(const char*label,json_object*argsJ);\ int lua2c_ ## FuncName(lua_State* luaState){return((*Lua2cWrap)(luaState, MACRO_STR_VALUE(FuncName), FuncName));};\ - static int FuncName(char* label, json_object* argsJ) + static int FuncName(const char* label, json_object* argsJ) typedef enum { LUA_DOCALL, @@ -76,7 +76,7 @@ typedef enum { int LuaConfigLoad(); int LuaConfigExec(); void LuaL2cNewLib(const char *label, luaL_Reg *l2cFunc, int count); -int Lua2cWrapper(lua_State* luaState, char *funcname, Lua2cFunctionT callback); +int Lua2cWrapper(lua_State* luaState, const char *funcname, Lua2cFunctionT callback); int LuaCallFunc (CtlActionT *action, json_object *queryJ) ; void ctlapi_lua_docall (afb_req request); void ctlapi_lua_dostring (afb_req request); diff --git a/controller/ctl-plugin.c b/controller/ctl-plugin.c index 1be97d4..9e4e419 100644 --- a/controller/ctl-plugin.c +++ b/controller/ctl-plugin.c @@ -65,11 +65,10 @@ int PluginGetCB (CtlActionT *action , json_object *callbackJ) { OnErrorExit: return 1; - } // Wrapper to Lua2c plugin command add context and delegate to LuaWrapper -STATIC int DispatchOneL2c(lua_State* luaState, char *funcname, Lua2cFunctionT callback) { +STATIC int DispatchOneL2c(lua_State* luaState, const char *funcname, Lua2cFunctionT callback) { #ifndef CONTROL_SUPPORT_LUA AFB_ERROR("CTL-ONE-L2C: LUA support not selected (cf:CONTROL_SUPPORT_LUA) in config.cmake"); return 1; |