summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2017-07-18 11:48:29 +0200
committerJoshua Haberman <jhaberman@gmail.com>2017-07-18 11:48:29 +0200
commit806ffc1d2053f1c02167c7965b39abc997d12ad6 (patch)
tree3f0943a888e0f164997c344c1763ef82a619844b /tools
parent15308afff2d0d288b73c1b4278bd28f926ce02b8 (diff)
Responded to PR comments.
Diffstat (limited to 'tools')
-rw-r--r--tools/make_c_api.lua8
1 files changed, 3 insertions, 5 deletions
diff --git a/tools/make_c_api.lua b/tools/make_c_api.lua
index cfcf38d..552e861 100644
--- a/tools/make_c_api.lua
+++ b/tools/make_c_api.lua
@@ -155,6 +155,8 @@ local function field_layout_rank(field)
-- 1. padding alignment is (nearly) minimized.
-- 2. fields that might have defaults (1-4) are segregated
-- from fields that are always zero-initialized (5-7).
+ --
+ -- We skip oneof fields, because they are emitted in a separate pass.
local rank
if field:containing_oneof() then
rank = 100 -- These go last (actually we skip them).
@@ -347,7 +349,7 @@ local function write_c_file(filedef, hfilename, append)
end
if field:containing_oneof() then
- -- Do nothing now
+ -- Handled below.
else
if has_hasbit(field) then
hasbit_indexes[field] = hasbit_count
@@ -358,14 +360,11 @@ local function write_c_file(filedef, hfilename, append)
end
end
- local oneof_last_fields = {}
-- Oneof fields.
for oneof in msg:oneofs() do
local fullname = to_cident(oneof:containing_type():full_name() .. "." .. oneof:name())
append(' union {\n')
- oneof_last_fields[oneof] = ""
for field in oneof:fields() do
- oneof_last_fields[oneof] = field:name()
append(' %s %s;\n', ctype(field), field:name())
end
append(' } %s;\n', oneof:name())
@@ -425,7 +424,6 @@ local function write_c_file(filedef, hfilename, append)
if field:containing_oneof() then
oneof_index = oneof_indexes[field:containing_oneof()]
end
- -- TODO(haberman): oneofs.
append(' {%s, offsetof(%s, %s), %s, %s, %s, %s, %s},\n',
field:number(),
msgname,
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback