mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-18 02:46:32 +00:00
Allow structs to be parsed in JSON with out of order fields.
Also simplified the code and made it faster. Change-Id: I1d83b1165a4a9a4380d1bfb5538769c012d2d367 Tested: on Linux.
This commit is contained in:
@@ -5,6 +5,7 @@ namespace MyGame.Example
|
||||
|
||||
using FlatBuffers;
|
||||
|
||||
/// an example documentation comment: monster object
|
||||
public sealed class Monster : Table {
|
||||
public static Monster GetRootAsMonster(ByteBuffer _bb) { return GetRootAsMonster(_bb, new Monster()); }
|
||||
public static Monster GetRootAsMonster(ByteBuffer _bb, Monster obj) { return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
|
||||
|
||||
@@ -5,6 +5,7 @@ package Example
|
||||
import (
|
||||
flatbuffers "github.com/google/flatbuffers/go"
|
||||
)
|
||||
/// an example documentation comment: monster object
|
||||
type Monster struct {
|
||||
_tab flatbuffers.Table
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@ import java.util.*;
|
||||
import com.google.flatbuffers.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
/**
|
||||
* an example documentation comment: monster object
|
||||
*/
|
||||
public final class Monster extends Table {
|
||||
public static Monster getRootAsMonster(ByteBuffer _bb) { return getRootAsMonster(_bb, new Monster()); }
|
||||
public static Monster getRootAsMonster(ByteBuffer _bb, Monster obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__init(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
import flatbuffers
|
||||
|
||||
# /// an example documentation comment: monster object
|
||||
class Monster(object):
|
||||
__slots__ = ['_tab']
|
||||
|
||||
|
||||
@@ -167,6 +167,7 @@ inline flatbuffers::Offset<Stat> CreateStat(flatbuffers::FlatBufferBuilder &_fbb
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
/// an example documentation comment: monster object
|
||||
struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
const Vec3 *pos() const { return GetStruct<const Vec3 *>(4); }
|
||||
Vec3 *mutable_pos() { return GetStruct<Vec3 *>(4); }
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
b: 20
|
||||
},
|
||||
{
|
||||
a: 30,
|
||||
b: 40
|
||||
b: 40,
|
||||
a: 30
|
||||
}
|
||||
],
|
||||
testarrayofstring: [
|
||||
|
||||
Binary file not shown.
@@ -738,7 +738,7 @@ void ErrorTest() {
|
||||
TestError("table X { Y:int; } root_type X; { \"Y\":1, }", "string constant",
|
||||
true);
|
||||
TestError("struct X { Y:int; Z:int; } table W { V:X; } root_type W; "
|
||||
"{ V:{ Y:1 } }", "incomplete");
|
||||
"{ V:{ Y:1 } }", "wrong number");
|
||||
TestError("enum E:byte { A } table X { Y:E; } root_type X; { Y:U }",
|
||||
"unknown enum value");
|
||||
TestError("table X { Y:byte; } root_type X; { Y:; }", "starting");
|
||||
|
||||
Reference in New Issue
Block a user