Clean up the Lua API, make it luajit-only, no C
This removes the libcough which was a temporary layer atop
the libpneum to make it synchronous. Now Lua API only requres
luajit, and has no dependencies on compiling any C.
Also comment out a couple of debug print functions.
Change-Id: I35fd1c8088c6fd1b10b9e4d903ad241ab32fd91a
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
diff --git a/vpp-api/lua/vpp-lapi.lua b/vpp-api/lua/vpp-lapi.lua
index 4f2e3f5..c88b456 100644
--- a/vpp-api/lua/vpp-lapi.lua
+++ b/vpp-api/lua/vpp-lapi.lua
@@ -273,33 +273,17 @@
function vpp.init(vpp, args)
local pneum_api = args.pneum_api or [[
int cough_pneum_attach(char *pneum_path, char *cough_path);
- int pneum_connect(char *name, char *chroot_prefix);
- int pneum_connect_sync(char *name, char *chroot_prefix);
+ int pneum_connect(char *name, char *chroot_prefix, void *cb);
int pneum_disconnect(void);
int pneum_read(char **data, int *l);
int pneum_write(char *data, int len);
-
-void pneum_data_free(char *data);
+ void pneum_free(char *data);
]]
vpp.pneum_path = args.pneum_path
ffi.cdef(pneum_api)
local init_res = 0
- if pcall(function()
- vpp.cough_path = args.cough_path or "./libcough.so"
- vpp.cough = ffi.load(vpp.cough_path)
- end) then
- pcall(function()
- if(vpp.cough.cough_pneum_attach) then
- vpp.pneum_is_cough = true
- print("libcough detected\n")
- init_res = vpp.cough.cough_pneum_attach(vpp.c_str(vpp.pneum_path), vpp.c_str(vpp.cough_path))
- vpp.pneum = vpp.cough
- end
- end)
- else
- vpp.pneum = ffi.load(vpp.pneum_path)
- end
+ vpp.pneum = ffi.load(vpp.pneum_path)
if (init_res < 0) then
return nil
end
@@ -463,9 +447,9 @@
local len = 0
local val = nil
if field.array and (type(v) == "table") then
- print("NTFY: field " .. tostring(k) .. " in message " .. tostring(c_type) .. " is an array")
+ -- print("NTFY: field " .. tostring(k) .. " in message " .. tostring(c_type) .. " is an array")
for field_i, field_v in ipairs(v) do
- print("NTFY: setting member#" .. tostring(field_i) .. " to value " .. vpp.dump(field_v))
+ -- print("NTFY: setting member#" .. tostring(field_i) .. " to value " .. vpp.dump(field_v))
local field_len, field_val = lua2c(field.c_type, field_v, dst[k][field_i-1])
len = len + field_len
end
@@ -544,7 +528,7 @@
if client_name then
name = client_name
end
- local ret = vpp.pneum.pneum_connect_sync(vpp.c_str(client_name), nil)
+ local ret = vpp.pneum.pneum_connect(vpp.c_str(client_name), nil, nil)
if tonumber(ret) == 0 then
vpp.is_connected = true
end
@@ -712,7 +696,7 @@
out["luaapi_message_name"] = reply_msg_name
end
- vpp.pneum.pneum_data_free(ffi.cast('void *',rep[0]))
+ vpp.pneum.pneum_free(ffi.cast('void *',rep[0]))
return reply_msg_name, out
end