From 806ffc1d2053f1c02167c7965b39abc997d12ad6 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Tue, 18 Jul 2017 11:48:29 +0200 Subject: Responded to PR comments. --- tools/make_c_api.lua | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'tools') 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, -- cgit v1.2.3