2
2
3
3
" TODO more loose pattern?
4
4
function ! s: get_parse_lines (lines ) abort
5
- let from = index (a: lines , ' } functions[] =' )
5
+ let from = match (a: lines , ' \vstatic\s+funcentry_T\s+global_functions\[]\s+\ =' )
6
6
if from == # -1
7
7
throw ' cannot parse functions'
8
8
endif
9
9
" find next '{'
10
10
let from = index (a: lines , ' {' , from + 1 )
11
11
let to = index (a: lines , ' };' , from + 1 )
12
- return map ( range ( from + 1 , to - 1 ), {_, i - > a: lines [ i ] })
12
+ return a: lines [ from + 1 : to - 1 ]
13
13
endfunction
14
14
15
15
function ! s: parse (evalfunc_c) abort
@@ -18,14 +18,16 @@ function! s:parse(evalfunc_c) abort
18
18
" { 'name': string, 'min_argc': integer, 'max_argc': integer }
19
19
let funcs = []
20
20
21
+ " TODO: f_retfunc, f_func (currently vim9script is unstable)
21
22
for line in s: get_parse_lines (lines )
22
- let m = matchlist (line , ' \v\{\s*"(\w+)"\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*\w+\s*\} ' )
23
+ let m = matchlist (line , ' \v\{\s*"(\w+)"\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*( \w+) ' )
23
24
if ! empty (m )
24
- let [name, min_argc, max_argc] = m [1 :3 ]
25
+ let [name, min_argc, max_argc, argtype ] = m [1 :4 ]
25
26
call add (funcs, {
26
27
\ ' name' : name,
27
28
\ ' min_argc' : min_argc + 0 ,
28
29
\ ' max_argc' : max_argc + 0 ,
30
+ \ ' argtype' : argtype,
29
31
\} )
30
32
endif
31
33
endfor
@@ -37,20 +39,16 @@ function! s:diff(existing, latest) abort
37
39
for func in a: existing
38
40
let existing_names[func .name] = v: true
39
41
endfor
40
- let new_funcs = []
41
- for func in filter (copy (a: latest ), {_, f - > ! has_key (existing_names, f .name)})
42
- let new_funcs = add (new_funcs, func )
43
- endfor
44
- return new_funcs
42
+ return filter (copy (a: latest ), {_, f - > ! has_key (existing_names, f .name)})
45
43
endfunction
46
44
47
45
function ! s: gen_viml (new_funcs) abort
48
46
let lines = []
49
47
for f in a: new_funcs
50
48
" output items in this key order
51
49
let lines = add (lines ,
52
- \ printf (' \ {'' name'' : %s, '' min_argc'' : %s, '' max_argc'' : %s},' ,
53
- \ string (f .name), string (f .min_argc), string (f .max_argc)))
50
+ \ printf (' \ {'' name'' : %s, '' min_argc'' : %s, '' max_argc'' : %s, '' argtype '' : %s },' ,
51
+ \ string (f .name), string (f .min_argc), string (f .max_argc), string ( f .argtype) ))
54
52
endfor
55
53
return join (lines , " \n " )
56
54
endfunction
0 commit comments