@@ -2,6 +2,7 @@ local ctypes = { TESTMODE = false }
22
33local inspect = require (" inspect" )
44local utility = require ' utility'
5+ local util = require ' plugins.ffi.c-parser.util'
56local typed = require (" plugins.ffi.c-parser.typed" )
67
78local equal_declarations
@@ -102,6 +103,8 @@ local convert_value = typed("TypeList, table -> CType?, string?", function (lst,
102103 local idxs = nil
103104
104105 if type (src .id ) == " table" or type (src .ids ) == " table" then
106+ src .id = util .expandSingle (src .id )
107+ src .ids = util .expandSingle (src .ids )
105108 -- FIXME multiple ids, e.g.: int *x, y, *z;
106109 local ok
107110 ok , name , ret_pointer , idxs = get_name (src .id or src .ids )
@@ -122,22 +125,6 @@ local convert_value = typed("TypeList, table -> CType?, string?", function (lst,
122125 }), nil
123126end )
124127
125- local function convert_fields (lst , field_src , fields )
126- if field_src .ids then
127- for i , id in ipairs (field_src .ids ) do
128- id .type = utility .deepCopy (field_src .type )
129- if id .type and id [1 ] then
130- for i , v in ipairs (id [1 ]) do
131- table.insert (id .type , v )
132- end
133- id [1 ] = nil
134- end
135- table.insert (fields , id )
136- end
137- return true
138- end
139- end
140-
141128-- Interpret field data from `field_src` and add it to `fields`.
142129local function add_to_fields (lst , field_src , fields )
143130 if type (field_src ) == " table" and not field_src .ids then
@@ -149,9 +136,6 @@ local function add_to_fields(lst, field_src, fields)
149136 return true
150137 end
151138
152- if convert_fields (lst , field_src , fields ) then
153- return true
154- end
155139 local field , err = convert_value (lst , field_src )
156140 if not field then
157141 return nil , err
@@ -531,14 +515,6 @@ local function to_set(array)
531515 return set
532516end
533517
534- local function need_expand (t )
535- if # t ~= 1 then
536- return false
537- end
538- local tt = t [1 ].type
539- return tt == ' struct' or tt == ' union' or tt == ' enum'
540- end
541-
542518ctypes .register_types = typed (" {Decl} -> TypeList?, string?" , function (parsed )
543519 local lst = typed .table (" TypeList" , {})
544520 for _ , item in ipairs (parsed ) do
@@ -565,9 +541,7 @@ ctypes.register_types = typed("{Decl} -> TypeList?, string?", function (parsed)
565541 return nil , err or " failed typedef"
566542 end
567543 else
568- if not item .spec .type and need_expand (item .spec ) then
569- item .spec = item .spec [1 ]
570- end
544+ item .spec = util .expandSingle (item .spec )
571545 if item .spec .type == " struct" or item .spec .type == " union" then
572546 local ok , err = register_structunion (lst , item )
573547 if not ok then
0 commit comments