diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2014-10-30 14:32:03 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-10-30 14:32:03 -0400 |
commit | 4b0f8f2a4d8f1f1db1900079061cad2098bf0ac0 (patch) | |
tree | c40070af63e73c8248e4d6a71cd5ba2b7693aa93 | |
parent | 34ec5a9f81b797381136e0ecc192c5a2ca7595f6 (diff) | |
parent | 972fc305997e6499e346b22d713cd1ad02823463 (diff) | |
download | rneovim-4b0f8f2a4d8f1f1db1900079061cad2098bf0ac0.tar.gz rneovim-4b0f8f2a4d8f1f1db1900079061cad2098bf0ac0.tar.bz2 rneovim-4b0f8f2a4d8f1f1db1900079061cad2098bf0ac0.zip |
Merge pull request #1349 from stefan991/fix-cimport-pragma-pack
Fix handling of `#pragma pack` in `cimport` lua helper
-rw-r--r-- | test/unit/helpers.lua | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/test/unit/helpers.lua b/test/unit/helpers.lua index 3f1984f6de..544a53fa10 100644 --- a/test/unit/helpers.lua +++ b/test/unit/helpers.lua @@ -25,6 +25,10 @@ if imported == nil then imported = Set:new() end +if pragma_pack_id == nil then + pragma_pack_id = 1 +end + -- some things are just too complex for the LuaJIT C parser to digest. We -- usually don't need them anyway. local function filter_complex_blocks(body) @@ -62,7 +66,7 @@ local function cimport(...) end local body = nil - for i=1, 3 do + for i=1, 10 do local stream = Preprocess.preprocess_stream(unpack(paths)) body = stream:read("*a") stream:close() @@ -81,7 +85,16 @@ local function cimport(...) -- add the formatted lines to a set local new_cdefs = Set:new() for line in body:gmatch("[^\r\n]+") do - new_cdefs:add(trim(line)) + line = trim(line) + -- give each #pragma pack an unique id, so that they don't get removed + -- if they are inserted into the set + -- (they are needed in the right order with the struct definitions, + -- otherwise luajit has wrong memory layouts for the sturcts) + if line:match("#pragma%s+pack") then + line = line .. " // " .. pragma_pack_id + pragma_pack_id = pragma_pack_id + 1 + end + new_cdefs:add(line) end -- subtract the lines we've already imported from the new lines, then add |