diff options
Diffstat (limited to 'tools/dump_cinit.lua')
-rw-r--r-- | tools/dump_cinit.lua | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/tools/dump_cinit.lua b/tools/dump_cinit.lua index 17be8d9..e01e150 100644 --- a/tools/dump_cinit.lua +++ b/tools/dump_cinit.lua @@ -292,8 +292,12 @@ local function gettables(def) end end -local function emit_file_warning(append) - append('/* This file was generated by upbc (the upb compiler).\n') +local function emit_file_warning(filedef, append) + append('/* This file was generated by upbc (the upb compiler) from the input\n') + append(' * file:\n') + append(' *\n') + append(' * %s\n', filedef:name()) + append(' *\n') append(' * Do not edit -- your changes will be discarded when the file is\n') append(' * regenerated. */\n\n') end @@ -402,7 +406,7 @@ local function dump_defs_c(filedef, append) end -- Emit forward declarations. - emit_file_warning(append) + emit_file_warning(filedef, append) append('#include <assert.h>\n\n') append('#include "upb/def.h"\n') append('#include "upb/structdefs.int.h"\n\n') @@ -432,13 +436,15 @@ local function dump_defs_c(filedef, append) local tables = gettables(m) -- UPB_MSGDEF_INIT(name, selector_count, submsg_field_count, itof, ntof, -- refs, ref2s) - append(' UPB_MSGDEF_INIT("%s", %d, %d, %s, %s,' .. - '&reftables[%d], &reftables[%d]),\n', + append(' UPB_MSGDEF_INIT("%s", %d, %d, %s, %s, %s, %s,' .. + ' &reftables[%d], &reftables[%d]),\n', m:full_name(), upbtable.msgdef_selector_count(m), upbtable.msgdef_submsg_field_count(m), dumper:inttable(tables.int), dumper:strtable(tables.str), + boolstr(m:_map_entry()), + const(m, "syntax"), reftable, reftable + 1) reftable = reftable + 2 end @@ -627,17 +633,17 @@ local print_classes local function print_message(def, map, indent, append) append("\n") - append("%sclass %s : public upb::reffed_ptr<const upb::MessageDef> {\n", + append("%sclass %s : public ::upb::reffed_ptr<const ::upb::MessageDef> {\n", indent, def:name()) append("%s public:\n", indent) - append("%s %s(const upb::MessageDef* m, const void *ref_donor = NULL)\n", + append("%s %s(const ::upb::MessageDef* m, const void *ref_donor = NULL)\n", indent, def:name()) append("%s : reffed_ptr(m, ref_donor) {\n", indent) append("%s assert(upbdefs_%s_is(m));\n", indent, to_cident(def:full_name())) append("%s }\n", indent) append("\n") append("%s static %s get() {\n", indent, def:name()) - append("%s const upb::MessageDef* m = upbdefs_%s_get(&m);\n", indent, to_cident(def:full_name())) + append("%s const ::upb::MessageDef* m = upbdefs_%s_get(&m);\n", indent, to_cident(def:full_name())) append("%s return %s(m, &m);\n", indent, def:name()) append("%s }\n", indent) -- TODO(haberman): add fields @@ -647,16 +653,16 @@ end local function print_enum(def, indent, append) append("\n") - append("%sclass %s : public upb::reffed_ptr<const upb::EnumDef> {\n", + append("%sclass %s : public ::upb::reffed_ptr<const ::upb::EnumDef> {\n", indent, def:name()) append("%s public:\n", indent) - append("%s %s(const upb::EnumDef* e, const void *ref_donor = NULL)\n", + append("%s %s(const ::upb::EnumDef* e, const void *ref_donor = NULL)\n", indent, def:name()) append("%s : reffed_ptr(e, ref_donor) {\n", indent) append("%s assert(upbdefs_%s_is(e));\n", indent, to_cident(def:full_name())) append("%s }\n", indent) append("%s static %s get() {\n", indent, def:name()) - append("%s const upb::EnumDef* e = upbdefs_%s_get(&e);\n", indent, to_cident(def:full_name())) + append("%s const ::upb::EnumDef* e = upbdefs_%s_get(&e);\n", indent, to_cident(def:full_name())) append("%s return %s(e, &e);\n", indent, def:name()) append("%s }\n", indent) append("%s};\n", indent) @@ -686,7 +692,7 @@ local function dump_defs_h(file, append, linktab) append(" * actually storing protobufs. It only contains *defs* which\n") append(" * let you reflect over a protobuf *schema*.\n") append(" */\n") - emit_file_warning(append) + emit_file_warning(file, append) append('#ifndef %s_UPB_H_\n', basename_preproc) append('#define %s_UPB_H_\n\n', basename_preproc) append('#include "upb/def.h"\n\n') |