Skip to content

Commit

Permalink
Remove the offset table
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzicheng1987 committed Jan 19, 2025
1 parent 88421cb commit 0dd56d0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
9 changes: 1 addition & 8 deletions include/rfl/flatbuf/schema/Type.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef RFL_FLATBUF_SCHEMA_TYPE_HPP_
#define RFL_FLATBUF_SCHEMA_TYPE_HPP_

#include <flatbuffers/flatbuffers.h>

#include <iostream>
#include <map>
#include <memory>
Expand Down Expand Up @@ -67,13 +65,8 @@ struct Type {
};

struct Table {
struct Field {
std::string name;
rfl::Ref<Type> type;
flatbuffers::uoffset_t offset;
};
std::string name;
std::vector<Field> fields;
std::vector<std::pair<std::string, Type>> fields;
};

struct Union {
Expand Down
2 changes: 1 addition & 1 deletion src/rfl/flatbuf/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 3 additions & 5 deletions src/rfl/flatbuf/schema/internal_schema_to_flatbuf_schema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Type>::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};
Expand Down

0 comments on commit 0dd56d0

Please sign in to comment.