renaming table names

30 views
Skip to first unread message

Goran Saric

unread,
Oct 20, 2016, 11:23:33 AM10/20/16
to FlatBuffers
Hi guys! 

Started to use FlatBuffers for my save game system in my current Unity project. I'm actually super satisfied, there's just one thing that I don't really understand. 
I sometimes need to rename some tables or schemas, because refactoring is quite a task in the beginning of a project. 
It's actually not that hard to rename created classes (I am working with C# and VisualStudio) and than recreate the classes with flatc. 

The only ugly thing is, that the class name is also represented in almost all method / function declerations. For example:

Monster.GetRoosAsMonster(xy)

Is this by design? Or why couldn't it just be Moster.GetRoot(xy)? 

Cheers

mikkelfj

unread,
Oct 20, 2016, 12:48:16 PM10/20/16
to FlatBuffers


On Thursday, October 20, 2016 at 5:23:33 PM UTC+2, Goran Saric wrote:

Monster.GetRoosAsMonster(xy)

Is this by design? Or why couldn't it just be Moster.GetRoot(xy)? 

Historically flatbuffers only had one root because the flatc JSON parser needed a root type to parse from.
But in real life any table is suitable as a root. So you need to tell which table you expect to be the root of the buffer which is the GetRootAsMonster part of the name.
The "Monster." part of the name is a namespace as you probably already are aware of.
That said, there could be a default get root as you suggest, and I don't know if there is since I'm not familar with the C# interface.

It may also be worth noting that it is possible to use binary buffers created with wrong/old names from an old schema version as long as the names have the same table types and semantic meaning and there are no new table members inserted before the end to change the member id values.
 
Cheers

Goran Saric

unread,
Oct 24, 2016, 3:13:21 AM10/24/16
to FlatBuffers
I see and understand the design right now, thanks. 

But since we have to declare a root anyways in the schema
root_type Monster;

it would be convenient to have a GetRoot(), StartRoot() EndRoot(), FinishRootBuffer() method for the declared default table.
Reply all
Reply to author
Forward
0 new messages