From 0dd56d098725a31c3c87d56a43b52c26ebf5997b Mon Sep 17 00:00:00 2001 From: "Dr. Patrick Urbanke" Date: Sun, 19 Jan 2025 20:13:29 +0100 Subject: [PATCH] Remove the offset table --- include/rfl/flatbuf/schema/Type.hpp | 9 +-------- src/rfl/flatbuf/Type.cpp | 2 +- .../flatbuf/schema/internal_schema_to_flatbuf_schema.cpp | 8 +++----- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/include/rfl/flatbuf/schema/Type.hpp b/include/rfl/flatbuf/schema/Type.hpp index 79279512..4bf4a272 100644 --- a/include/rfl/flatbuf/schema/Type.hpp +++ b/include/rfl/flatbuf/schema/Type.hpp @@ -1,8 +1,6 @@ #ifndef RFL_FLATBUF_SCHEMA_TYPE_HPP_ #define RFL_FLATBUF_SCHEMA_TYPE_HPP_ -#include - #include #include #include @@ -67,13 +65,8 @@ struct Type { }; struct Table { - struct Field { - std::string name; - rfl::Ref type; - flatbuffers::uoffset_t offset; - }; std::string name; - std::vector fields; + std::vector> fields; }; struct Union { diff --git a/src/rfl/flatbuf/Type.cpp b/src/rfl/flatbuf/Type.cpp index 38707f35..7ead2168 100644 --- a/src/rfl/flatbuf/Type.cpp +++ b/src/rfl/flatbuf/Type.cpp @@ -126,7 +126,7 @@ std::ostream& operator<<(std::ostream& _os, const Type::Table& _t) { _os << "table " << internal::strings::to_pascal_case(_t.name) << " {" << std::endl; for (const auto& f : _t.fields) { - _os << " " << f.name << ":" << *f.type << ";" << std::endl; + _os << " " << f.first << ":" << f.second << ";" << std::endl; } return _os << "}" << std::endl; } diff --git a/src/rfl/flatbuf/schema/internal_schema_to_flatbuf_schema.cpp b/src/rfl/flatbuf/schema/internal_schema_to_flatbuf_schema.cpp index a4e7408f..4c5dc804 100644 --- a/src/rfl/flatbuf/schema/internal_schema_to_flatbuf_schema.cpp +++ b/src/rfl/flatbuf/schema/internal_schema_to_flatbuf_schema.cpp @@ -107,11 +107,9 @@ Type object_to_flatbuf_schema_type( const bool _is_top_level, FlatbufTypes* _flatbuf_types) { Type::Table table_schema; for (const auto& [k, v] : _obj.types_) { - table_schema.fields.push_back(Type::Table::Field{ - .name = k, - .type = rfl::Ref::make(type_to_flatbuf_schema_type( - v, _definitions, false, _flatbuf_types)), - .offset = 0 /* TODO*/}); + table_schema.fields.push_back(std::make_pair( + k, + type_to_flatbuf_schema_type(v, _definitions, false, _flatbuf_types))); } if (_is_top_level) { return Type{.value = table_schema};