aboutsummaryrefslogtreecommitdiff
path: root/scripts/gendispatch.lua
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2016-06-18 12:06:50 +0200
committerBjörn Linse <bjorn.linse@gmail.com>2016-08-31 21:40:20 +0200
commit3bd3b3b76859b3eef80fa4969147efa881b60f40 (patch)
tree0e70b42651dd91ccb1a16fe4a2222b0e92e9a3d2 /scripts/gendispatch.lua
parentde3a515123fa417ecce61efebe4bc117b010c657 (diff)
downloadrneovim-3bd3b3b76859b3eef80fa4969147efa881b60f40.tar.gz
rneovim-3bd3b3b76859b3eef80fa4969147efa881b60f40.tar.bz2
rneovim-3bd3b3b76859b3eef80fa4969147efa881b60f40.zip
api: auto generate api function wrappers for viml
Diffstat (limited to 'scripts/gendispatch.lua')
-rw-r--r--scripts/gendispatch.lua18
1 files changed, 12 insertions, 6 deletions
diff --git a/scripts/gendispatch.lua b/scripts/gendispatch.lua
index 54bfdab45b..ce1d8be222 100644
--- a/scripts/gendispatch.lua
+++ b/scripts/gendispatch.lua
@@ -41,18 +41,20 @@ c_proto = Ct(
)
grammar = Ct((c_proto + c_comment + c_preproc + ws) ^ 1)
--- we need at least 2 arguments since the last one is the output file
-assert(#arg >= 1)
+-- we need at least 3 arguments since the last two are output files
+assert(#arg >= 2)
functions = {}
-- names of all headers relative to the source root (for inclusion in the
-- generated file)
headers = {}
--- output file(dispatch function + metadata serialized with msgpack)
-outputf = arg[#arg]
+-- output c file(dispatch function + metadata serialized with msgpack)
+outputf = arg[#arg-1]
+-- output mpack file (metadata)
+mpack_outputf = arg[#arg]
-- read each input file, parse and append to the api metadata
-for i = 1, #arg - 1 do
+for i = 1, #arg - 2 do
local full_path = arg[i]
local parts = {}
for part in string.gmatch(full_path, '[^/]+') do
@@ -165,7 +167,7 @@ for i = 1, #functions do
local fn = functions[i]
local args = {}
- output:write('static Object handle_'..fn.name..'(uint64_t channel_id, uint64_t request_id, Array args, Error *error)')
+ output:write('Object handle_'..fn.name..'(uint64_t channel_id, uint64_t request_id, Array args, Error *error)')
output:write('\n{')
output:write('\n Object ret = NIL;')
-- Declare/initialize variables that will hold converted arguments
@@ -311,3 +313,7 @@ MsgpackRpcRequestHandler msgpack_rpc_get_handler_for(const char *name,
]])
output:close()
+
+mpack_output = io.open(mpack_outputf, 'wb')
+mpack_output:write(packed)
+mpack_output:close()