Skip to content

Commit 86e2d58

Browse files
authored
Merge pull request #2120 from fesily/fix-warnning
fix warnning
2 parents 8691625 + 17f3577 commit 86e2d58

File tree

3 files changed

+13
-21
lines changed

3 files changed

+13
-21
lines changed

script/plugins/ffi/c-parser/cpp.lua

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,18 @@
1-
21
local cpp = {}
32

43
local typed = require("plugins.ffi.c-parser.typed")
54
local c99 = require("plugins.ffi.c-parser.c99")
65

76
local SEP = package.config:sub(1,1)
87

9-
local shl, shr
10-
if jit then
11-
shl = function(a, b)
12-
return bit.lshift(a, b)
13-
end
14-
shr = function(a, b)
15-
return bit.rshift(a, b)
16-
end
17-
else
18-
shl, shr = load([[
19-
local function shl(a, b)
20-
return a << b
21-
end
22-
local function shr(a, b)
23-
return a >> b
24-
end
25-
return shl, shr
26-
]])()
8+
local function shl(a, b)
9+
return a << b
10+
end
11+
local function shr(a, b)
12+
return a >> b
2713
end
2814

29-
local function debug() end
15+
local function debug(...) end
3016
--[[
3117
local inspect = require("inspect")
3218
local function debug(...)
@@ -623,6 +609,7 @@ cpp.parse_file = typed("string, FILE*?, Ctx? -> Ctx?, string?", function(filenam
623609
ctx = {
624610
incdirs = cpp_include_paths(),
625611
defines = gcc_default_defines(),
612+
---@type any[]
626613
ifmode = { true },
627614
output = {},
628615
current_dir = {}
@@ -785,7 +772,7 @@ cpp.parse_context = typed("string, FILE*?, Ctx? -> Ctx?, string?", function(cont
785772
for cur, lineitem in ipairs(linelist) do
786773
local line = lineitem.line
787774
local tk = lineitem.tk
788-
debug(filename, cur, ifmode[#ifmode], #ifmode, line)
775+
debug(cur, ifmode[#ifmode], #ifmode, line)
789776

790777
if #ifmode == 1 and (tk.directive == "elif" or tk.directive == "else" or tk.directive == "endif") then
791778
return nil, "unexpected directive " .. tk.directive
@@ -812,6 +799,7 @@ cpp.parse_context = typed("string, FILE*?, Ctx? -> Ctx?, string?", function(cont
812799
elseif tk.directive == "if" then
813800
table.insert(ifmode, run_expression(ctx, tk.exp))
814801
elseif tk.directive == "elif" then
802+
---@diagnostic disable-next-line: assign-type-mismatch
815803
ifmode[#ifmode] = "skip"
816804
elseif tk.directive == "else" then
817805
ifmode[#ifmode] = not ifmode[#ifmode]

script/plugins/ffi/c-parser/ctypes.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ local convert_value = typed("TypeList, table -> CType?, string?", function (lst,
107107
src.ids = util.expandSingle(src.ids)
108108
-- FIXME multiple ids, e.g.: int *x, y, *z;
109109
local ok
110+
---@diagnostic disable-next-line: cast-local-type
110111
ok, name, ret_pointer, idxs = get_name(src.id or src.ids)
111112
if not ok then
112113
return nil, name

script/plugins/ffi/searchCode.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ local vm = require 'vm'
33
local function getLiterals(arg)
44
local literals = vm.getLiterals(arg)
55
local res = {}
6+
if not literals then
7+
return res
8+
end
69
for k, v in pairs(literals) do
710
if type(k) == 'string' then
811
res[#res+1] = k

0 commit comments

Comments
 (0)