mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-22 20:08:51 +00:00
Sync from upstream
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright 2014 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -107,6 +107,14 @@ namespace FlatBuffers.Test
|
||||
}
|
||||
}
|
||||
|
||||
public static void IsFalse(bool value)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
throw new AssertFailedException(false, value);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Throws<T>(Action action) where T : Exception
|
||||
{
|
||||
var caught = false;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright 2014 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
249
tests/FlatBuffers.Test/FlatBufferBuilderTests.cs
Normal file
249
tests/FlatBuffers.Test/FlatBufferBuilderTests.cs
Normal file
@@ -0,0 +1,249 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
namespace FlatBuffers.Test
|
||||
{
|
||||
[FlatBuffersTestClass]
|
||||
public class FlatBufferBuilderTests
|
||||
{
|
||||
private FlatBufferBuilder CreateBuffer(bool forceDefaults = true)
|
||||
{
|
||||
var fbb = new FlatBufferBuilder(16) {ForceDefaults = forceDefaults};
|
||||
fbb.StartObject(1);
|
||||
return fbb;
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
public void FlatBufferBuilder_WithForceDefaults_WhenAddBool_AndDefaultValue_OffsetIncreasesBySize()
|
||||
{
|
||||
var fbb = CreateBuffer();
|
||||
var storedOffset = fbb.Offset;
|
||||
fbb.AddBool(0, false, false);
|
||||
var endOffset = fbb.Offset;
|
||||
Assert.AreEqual(sizeof(bool), endOffset-storedOffset);
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
public void FlatBufferBuilder_WithForceDefaults_WhenAddSByte_AndDefaultValue_OffsetIncreasesBySize()
|
||||
{
|
||||
var fbb = CreateBuffer();
|
||||
var storedOffset = fbb.Offset;
|
||||
fbb.AddSbyte(0, 0, 0);
|
||||
var endOffset = fbb.Offset;
|
||||
Assert.AreEqual(sizeof(sbyte), endOffset - storedOffset);
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
public void FlatBufferBuilder_WithForceDefaults_WhenAddByte_AndDefaultValue_OffsetIncreasesBySize()
|
||||
{
|
||||
var fbb = CreateBuffer();
|
||||
var storedOffset = fbb.Offset;
|
||||
fbb.AddByte(0, 0, 0);
|
||||
var endOffset = fbb.Offset;
|
||||
Assert.AreEqual(sizeof(byte), endOffset - storedOffset);
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
public void FlatBufferBuilder_WithForceDefaults_WhenAddShort_AndDefaultValue_OffsetIncreasesBySize()
|
||||
{
|
||||
var fbb = CreateBuffer();
|
||||
var storedOffset = fbb.Offset;
|
||||
fbb.AddShort(0, 0, 0);
|
||||
var endOffset = fbb.Offset;
|
||||
Assert.AreEqual(sizeof(short), endOffset - storedOffset);
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
public void FlatBufferBuilder_WithForceDefaults_WhenAddUShort_AndDefaultValue_OffsetIncreasesBySize()
|
||||
{
|
||||
var fbb = CreateBuffer();
|
||||
var storedOffset = fbb.Offset;
|
||||
fbb.AddUshort(0, 0, 0);
|
||||
var endOffset = fbb.Offset;
|
||||
Assert.AreEqual(sizeof(ushort), endOffset - storedOffset);
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
public void FlatBufferBuilder_WithForceDefaults_WhenAddInt_AndDefaultValue_OffsetIncreasesBySize()
|
||||
{
|
||||
var fbb = CreateBuffer();
|
||||
var storedOffset = fbb.Offset;
|
||||
fbb.AddInt(0, 0, 0);
|
||||
var endOffset = fbb.Offset;
|
||||
Assert.AreEqual(sizeof(int), endOffset - storedOffset);
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
public void FlatBufferBuilder_WithForceDefaults_WhenAddUInt_AndDefaultValue_OffsetIncreasesBySize()
|
||||
{
|
||||
var fbb = CreateBuffer();
|
||||
var storedOffset = fbb.Offset;
|
||||
fbb.AddUint(0, 0, 0);
|
||||
var endOffset = fbb.Offset;
|
||||
Assert.AreEqual(sizeof(uint), endOffset - storedOffset);
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
public void FlatBufferBuilder_WithForceDefaults_WhenAddLong_AndDefaultValue_OffsetIncreasesBySize()
|
||||
{
|
||||
var fbb = CreateBuffer();
|
||||
var storedOffset = fbb.Offset;
|
||||
fbb.AddLong(0, 0, 0);
|
||||
var endOffset = fbb.Offset;
|
||||
Assert.AreEqual(sizeof(long), endOffset - storedOffset);
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
public void FlatBufferBuilder_WithForceDefaults_WhenAddULong_AndDefaultValue_OffsetIncreasesBySize()
|
||||
{
|
||||
var fbb = CreateBuffer();
|
||||
var storedOffset = fbb.Offset;
|
||||
fbb.AddUlong(0, 0, 0);
|
||||
var endOffset = fbb.Offset;
|
||||
Assert.AreEqual(sizeof(ulong), endOffset - storedOffset);
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
public void FlatBufferBuilder_WithForceDefaults_WhenAddFloat_AndDefaultValue_OffsetIncreasesBySize()
|
||||
{
|
||||
var fbb = CreateBuffer();
|
||||
var storedOffset = fbb.Offset;
|
||||
fbb.AddFloat(0, 0, 0);
|
||||
var endOffset = fbb.Offset;
|
||||
Assert.AreEqual(sizeof(float), endOffset - storedOffset);
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
public void FlatBufferBuilder_WithForceDefaults_WhenAddDouble_AndDefaultValue_OffsetIncreasesBySize()
|
||||
{
|
||||
var fbb = CreateBuffer();
|
||||
var storedOffset = fbb.Offset;
|
||||
fbb.AddDouble(0, 0, 0);
|
||||
var endOffset = fbb.Offset;
|
||||
Assert.AreEqual(sizeof(double), endOffset - storedOffset);
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
public void FlatBufferBuilder_WhenAddBool_AndDefaultValue_OffsetIsUnchanged()
|
||||
{
|
||||
var fbb = CreateBuffer(false);
|
||||
var storedOffset = fbb.Offset;
|
||||
fbb.AddBool(0, false, false);
|
||||
var endOffset = fbb.Offset;
|
||||
Assert.AreEqual(endOffset, storedOffset);
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
public void FlatBufferBuilder_WhenAddSByte_AndDefaultValue_OffsetIsUnchanged()
|
||||
{
|
||||
var fbb = CreateBuffer(false);
|
||||
var storedOffset = fbb.Offset;
|
||||
fbb.AddSbyte(0, 0, 0);
|
||||
var endOffset = fbb.Offset;
|
||||
Assert.AreEqual(endOffset, storedOffset);
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
public void FlatBufferBuilder_WhenAddByte_AndDefaultValue_OffsetIsUnchanged()
|
||||
{
|
||||
var fbb = CreateBuffer(false);
|
||||
var storedOffset = fbb.Offset;
|
||||
fbb.AddByte(0, 0, 0);
|
||||
var endOffset = fbb.Offset;
|
||||
Assert.AreEqual(endOffset, storedOffset);
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
public void FlatBufferBuilder_WhenAddShort_AndDefaultValue_OffsetIsUnchanged()
|
||||
{
|
||||
var fbb = CreateBuffer(false);
|
||||
var storedOffset = fbb.Offset;
|
||||
fbb.AddShort(0, 0, 0);
|
||||
var endOffset = fbb.Offset;
|
||||
Assert.AreEqual(endOffset, storedOffset);
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
public void FlatBufferBuilder_WhenAddUShort_AndDefaultValue_OffsetIsUnchanged()
|
||||
{
|
||||
var fbb = CreateBuffer(false);
|
||||
var storedOffset = fbb.Offset;
|
||||
fbb.AddUshort(0, 0, 0);
|
||||
var endOffset = fbb.Offset;
|
||||
Assert.AreEqual(endOffset, storedOffset);
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
public void FlatBufferBuilder_WhenAddInt_AndDefaultValue_OffsetIsUnchanged()
|
||||
{
|
||||
var fbb = CreateBuffer(false);
|
||||
var storedOffset = fbb.Offset;
|
||||
fbb.AddInt(0, 0, 0);
|
||||
var endOffset = fbb.Offset;
|
||||
Assert.AreEqual(endOffset, storedOffset);
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
public void FlatBufferBuilder_WhenAddUInt_AndDefaultValue_OffsetIsUnchanged()
|
||||
{
|
||||
var fbb = CreateBuffer(false);
|
||||
var storedOffset = fbb.Offset;
|
||||
fbb.AddUint(0, 0, 0);
|
||||
var endOffset = fbb.Offset;
|
||||
Assert.AreEqual(endOffset, storedOffset);
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
public void FlatBufferBuilder_WhenAddLong_AndDefaultValue_OffsetIsUnchanged()
|
||||
{
|
||||
var fbb = CreateBuffer(false);
|
||||
var storedOffset = fbb.Offset;
|
||||
fbb.AddLong(0, 0, 0);
|
||||
var endOffset = fbb.Offset;
|
||||
Assert.AreEqual(endOffset, storedOffset);
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
public void FlatBufferBuilder_WhenAddULong_AndDefaultValue_OffsetIsUnchanged()
|
||||
{
|
||||
var fbb = CreateBuffer(false);
|
||||
var storedOffset = fbb.Offset;
|
||||
fbb.AddUlong(0, 0, 0);
|
||||
var endOffset = fbb.Offset;
|
||||
Assert.AreEqual(endOffset, storedOffset);
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
public void FlatBufferBuilder_WhenAddFloat_AndDefaultValue_OffsetIsUnchanged()
|
||||
{
|
||||
var fbb = CreateBuffer(false);
|
||||
var storedOffset = fbb.Offset;
|
||||
fbb.AddFloat(0, 0, 0);
|
||||
var endOffset = fbb.Offset;
|
||||
Assert.AreEqual(endOffset, storedOffset);
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
public void FlatBufferBuilder_WhenAddDouble_AndDefaultValue_OffsetIsUnchanged()
|
||||
{
|
||||
var fbb = CreateBuffer(false);
|
||||
var storedOffset = fbb.Offset;
|
||||
fbb.AddDouble(0, 0, 0);
|
||||
var endOffset = fbb.Offset;
|
||||
Assert.AreEqual(endOffset, storedOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -77,8 +77,21 @@
|
||||
<Compile Include="..\MyGame\Example\Vec3.cs">
|
||||
<Link>MyGame\Example\Vec3.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\namespace_test\NamespaceA\NamespaceB\EnumInNestedNS.cs">
|
||||
<Link>NamespaceA\NamespaceB\EnumInNestedNS.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\namespace_test\NamespaceA\NamespaceB\StructInNestedNS.cs">
|
||||
<Link>NamespaceA\NamespaceB\StructInNestedNS.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\namespace_test\NamespaceA\NamespaceB\TableInNestedNS.cs">
|
||||
<Link>NamespaceA\NamespaceB\TableInNestedNS.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\namespace_test\NamespaceA\TableInFirstNS.cs">
|
||||
<Link>NamespaceA\TableInFirstNS.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Assert.cs" />
|
||||
<Compile Include="ByteBufferTests.cs" />
|
||||
<Compile Include="FlatBufferBuilderTests.cs" />
|
||||
<Compile Include="FlatBuffersFuzzTests.cs" />
|
||||
<Compile Include="FlatBuffersTestClassAttribute.cs" />
|
||||
<Compile Include="FlatBuffersTestMethodAttribute.cs" />
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using MyGame.Example;
|
||||
|
||||
namespace FlatBuffers.Test
|
||||
@@ -184,6 +185,18 @@ namespace FlatBuffers.Test
|
||||
Assert.AreEqual("test2", monster.GetTestarrayofstring(1));
|
||||
|
||||
Assert.AreEqual(false, monster.Testbool);
|
||||
|
||||
var nameBytes = monster.GetNameBytes().Value;
|
||||
Assert.AreEqual("MyMonster", Encoding.UTF8.GetString(nameBytes.Array, nameBytes.Offset, nameBytes.Count));
|
||||
|
||||
if (0 == monster.TestarrayofboolsLength)
|
||||
{
|
||||
Assert.IsFalse(monster.GetTestarrayofboolsBytes().HasValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.IsTrue(monster.GetTestarrayofboolsBytes().HasValue);
|
||||
}
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
@@ -202,5 +215,44 @@ namespace FlatBuffers.Test
|
||||
Assert.AreEqual("NONE", Any.NONE.ToString());
|
||||
Assert.AreEqual("Monster", Any.Monster.ToString());
|
||||
}
|
||||
|
||||
[FlatBuffersTestMethod]
|
||||
public void TestNestedFlatBuffer()
|
||||
{
|
||||
const string nestedMonsterName = "NestedMonsterName";
|
||||
const short nestedMonsterHp = 600;
|
||||
const short nestedMonsterMana = 1024;
|
||||
// Create nested buffer as a Monster type
|
||||
var fbb1 = new FlatBufferBuilder(16);
|
||||
var str1 = fbb1.CreateString(nestedMonsterName);
|
||||
Monster.StartMonster(fbb1);
|
||||
Monster.AddName(fbb1, str1);
|
||||
Monster.AddHp(fbb1, nestedMonsterHp);
|
||||
Monster.AddMana(fbb1, nestedMonsterMana);
|
||||
var monster1 = Monster.EndMonster(fbb1);
|
||||
Monster.FinishMonsterBuffer(fbb1, monster1);
|
||||
var fbb1Bytes = fbb1.SizedByteArray();
|
||||
fbb1 = null;
|
||||
|
||||
// Create a Monster which has the first buffer as a nested buffer
|
||||
var fbb2 = new FlatBufferBuilder(16);
|
||||
var str2 = fbb2.CreateString("My Monster");
|
||||
var nestedBuffer = Monster.CreateTestnestedflatbufferVector(fbb2, fbb1Bytes);
|
||||
Monster.StartMonster(fbb2);
|
||||
Monster.AddName(fbb2, str2);
|
||||
Monster.AddHp(fbb2, 50);
|
||||
Monster.AddMana(fbb2, 32);
|
||||
Monster.AddTestnestedflatbuffer(fbb2, nestedBuffer);
|
||||
var monster = Monster.EndMonster(fbb2);
|
||||
Monster.FinishMonsterBuffer(fbb2, monster);
|
||||
|
||||
// Now test the data extracted from the nested buffer
|
||||
var mons = Monster.GetRootAsMonster(fbb2.DataBuffer);
|
||||
var nestedMonster = mons.TestnestedflatbufferAsMonster();
|
||||
|
||||
Assert.AreEqual(nestedMonsterMana, nestedMonster.Mana);
|
||||
Assert.AreEqual(nestedMonsterHp, nestedMonster.Hp);
|
||||
Assert.AreEqual(nestedMonsterName, nestedMonster.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright 2015 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -124,13 +124,13 @@ namespace FlatBuffers.Test
|
||||
builder.CreateString("moop");
|
||||
Assert.ArrayEqual(new byte[]
|
||||
{
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0, // Padding to 32 bytes
|
||||
4, 0, 0, 0,
|
||||
4, 0, 0, 0,
|
||||
(byte)'m', (byte)'o', (byte)'o', (byte)'p',
|
||||
0, 0, 0, 0, // zero terminator with 3 byte pad
|
||||
3, 0, 0, 0,
|
||||
3, 0, 0, 0,
|
||||
(byte)'f', (byte)'o', (byte)'o', 0
|
||||
}, builder.DataBuffer.Data);
|
||||
}
|
||||
@@ -142,19 +142,19 @@ namespace FlatBuffers.Test
|
||||
builder.CreateString("\x01\x02\x03");
|
||||
Assert.ArrayEqual(new byte[]
|
||||
{
|
||||
3, 0, 0, 0,
|
||||
3, 0, 0, 0,
|
||||
0x01, 0x02, 0x03, 0
|
||||
}, builder.DataBuffer.Data); // No padding
|
||||
builder.CreateString("\x04\x05\x06\x07");
|
||||
Assert.ArrayEqual(new byte[]
|
||||
{
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0, // Padding to 32 bytes
|
||||
4, 0, 0, 0,
|
||||
4, 0, 0, 0,
|
||||
0x04, 0x05, 0x06, 0x07,
|
||||
0, 0, 0, 0, // zero terminator with 3 byte pad
|
||||
3, 0, 0, 0,
|
||||
3, 0, 0, 0,
|
||||
0x01, 0x02, 0x03, 0
|
||||
}, builder.DataBuffer.Data); // No padding
|
||||
}
|
||||
@@ -168,9 +168,9 @@ namespace FlatBuffers.Test
|
||||
builder.EndObject();
|
||||
Assert.ArrayEqual(new byte[]
|
||||
{
|
||||
4, 0, 4, 0,
|
||||
4, 0, 4, 0,
|
||||
4, 0, 0, 0
|
||||
},
|
||||
},
|
||||
builder.DataBuffer.Data);
|
||||
}
|
||||
|
||||
@@ -287,20 +287,20 @@ namespace FlatBuffers.Test
|
||||
var vecEnd = builder.EndVector();
|
||||
|
||||
builder.StartObject(1);
|
||||
|
||||
|
||||
builder.AddOffset(0, vecEnd.Value, 0);
|
||||
builder.EndObject();
|
||||
Assert.ArrayEqual(new byte[]
|
||||
{
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, // Padding to 32 bytes
|
||||
6, 0, // vtable bytes
|
||||
8, 0, // object length inc vtable offset
|
||||
4, 0, // start of vector offset value 0
|
||||
6, 0, 0, 0, // int32 offset for start of vtable
|
||||
4, 0, 0, 0,
|
||||
4, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
},
|
||||
builder.DataBuffer.Data);
|
||||
@@ -320,7 +320,7 @@ namespace FlatBuffers.Test
|
||||
Assert.ArrayEqual(new byte[]
|
||||
{
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0, // Padding to 32 bytes
|
||||
0, 0, 0, 0, // Padding to 32 bytes
|
||||
8, 0, // vtable bytes
|
||||
12, 0, // object length inc vtable offset
|
||||
10, 0, // offset to int16 value 0
|
||||
@@ -349,9 +349,9 @@ namespace FlatBuffers.Test
|
||||
builder.EndObject();
|
||||
Assert.ArrayEqual(new byte[]
|
||||
{
|
||||
0, 0, 0, 0, // Padding to 32 bytes
|
||||
0, 0, 0, 0, // Padding to 32 bytes
|
||||
8, 0, // vtable bytes
|
||||
12, 0, // object length
|
||||
12, 0, // object length
|
||||
6, 0, // start of value 0 from end of vtable
|
||||
8, 0, // start of value 1 from end of buffer
|
||||
8, 0, 0, 0, // int32 offset for start of vtable
|
||||
@@ -382,9 +382,9 @@ namespace FlatBuffers.Test
|
||||
{
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, // Padding to 32 bytes
|
||||
0, 0, // Padding to 32 bytes
|
||||
6, 0, // vtable bytes
|
||||
16, 0, // object length
|
||||
16, 0, // object length
|
||||
4, 0, // start of struct from here
|
||||
6, 0, 0, 0, // int32 offset for start of vtable
|
||||
0x78, 0x56, 0x34, 0x12, // struct value 2
|
||||
@@ -413,9 +413,9 @@ namespace FlatBuffers.Test
|
||||
{
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, // Padding to 32 bytes
|
||||
0, 0, // Padding to 32 bytes
|
||||
6, 0, // vtable bytes
|
||||
8, 0, // object length
|
||||
8, 0, // object length
|
||||
4, 0, // offset of vector offset
|
||||
6, 0, 0, 0, // int32 offset for start of vtable
|
||||
4, 0, 0, 0, // Vector start offset
|
||||
@@ -442,16 +442,16 @@ namespace FlatBuffers.Test
|
||||
{
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0, //Padding to 32 bytes
|
||||
12, 0, 0, 0, // root of table, pointing to vtable offset
|
||||
0, 0, 0, 0, //Padding to 32 bytes
|
||||
12, 0, 0, 0, // root of table, pointing to vtable offset
|
||||
8, 0, // vtable bytes
|
||||
8, 0, // object length
|
||||
8, 0, // object length
|
||||
7, 0, // start of value 0
|
||||
4, 0, // start of value 1
|
||||
8, 0, 0, 0, // int32 offset for start of vtable
|
||||
66, 0, // value 1
|
||||
0, 33, // value 0
|
||||
|
||||
|
||||
},
|
||||
builder.DataBuffer.Data);
|
||||
}
|
||||
@@ -480,23 +480,23 @@ namespace FlatBuffers.Test
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0, // padding to 64 bytes
|
||||
16, 0, 0, 0, // root of table, pointing to vtable offset (obj1)
|
||||
16, 0, 0, 0, // root of table, pointing to vtable offset (obj1)
|
||||
0, 0, // padding
|
||||
|
||||
10, 0, // vtable bytes
|
||||
8, 0, // object length
|
||||
8, 0, // object length
|
||||
7, 0, // start of value 0
|
||||
6, 0, // start of value 1
|
||||
5, 0, // start of value 2
|
||||
10, 0, 0, 0, // int32 offset for start of vtable
|
||||
0, // pad
|
||||
77, // values 2, 1, 0
|
||||
66,
|
||||
66,
|
||||
55,
|
||||
|
||||
12, 0, 0, 0, // root of table, pointing to vtable offset (obj0)
|
||||
8, 0, // vtable bytes
|
||||
8, 0, // object length
|
||||
8, 0, // object length
|
||||
7, 0, // start of value 0
|
||||
6, 0, // start of value 1
|
||||
8, 0, 0, 0, // int32 offset for start of vtable
|
||||
@@ -531,7 +531,7 @@ namespace FlatBuffers.Test
|
||||
|
||||
24, 0, 0, 0, // root of table, pointing to vtable offset (obj0)
|
||||
20, 0, // vtable bytes
|
||||
12, 0, // object length
|
||||
12, 0, // object length
|
||||
11, 0, // start of value 0
|
||||
10, 0, // start of value 1
|
||||
9, 0, // start of value 2
|
||||
@@ -542,10 +542,10 @@ namespace FlatBuffers.Test
|
||||
4, 0, // start of value 7
|
||||
|
||||
20, 0, 0, 0, // int32 offset for start of vtable
|
||||
|
||||
|
||||
1, 1, 1, 1, // values
|
||||
1, 1, 1, 1,
|
||||
|
||||
|
||||
},
|
||||
builder.DataBuffer.Data);
|
||||
}
|
||||
@@ -557,17 +557,17 @@ namespace FlatBuffers.Test
|
||||
builder.StartObject(1);
|
||||
builder.AddFloat(0, 1, 0);
|
||||
builder.EndObject();
|
||||
|
||||
|
||||
|
||||
Assert.ArrayEqual(new byte[]
|
||||
{
|
||||
0, 0,
|
||||
6, 0, // vtable bytes
|
||||
8, 0, // object length
|
||||
8, 0, // object length
|
||||
4, 0, // start of value 0
|
||||
6, 0, 0, 0, // int32 offset for start of vtable
|
||||
0, 0, 128, 63, // value
|
||||
|
||||
|
||||
},
|
||||
builder.DataBuffer.Data);
|
||||
}
|
||||
@@ -660,7 +660,7 @@ namespace FlatBuffers.Test
|
||||
}
|
||||
|
||||
_lcg.Reset();
|
||||
|
||||
|
||||
// Test all objects are readable and return expected values...
|
||||
for (var i = 0; i < objectCount; ++i)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,20 @@
|
||||
using System;
|
||||
/*
|
||||
* Copyright 2016 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
@@ -1,4 +1,20 @@
|
||||
using System;
|
||||
/*
|
||||
* Copyright 2016 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace FlatBuffers.Test
|
||||
{
|
||||
|
||||
@@ -1,4 +1,20 @@
|
||||
using System;
|
||||
/*
|
||||
* Copyright 2016 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace FlatBuffers.Test
|
||||
{
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
namespace FlatBuffers.Test
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright 2014 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright 2014 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -26,7 +26,7 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("FlatBuffers.Test")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014 Google Inc")]
|
||||
[assembly: AssemblyCopyright("Copyright (c) 2014 Google Inc")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
|
||||
BIN
tests/FlatBuffers.Test/Resources/monsterdata_test.mon
Normal file
BIN
tests/FlatBuffers.Test/Resources/monsterdata_test.mon
Normal file
Binary file not shown.
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
namespace FlatBuffers.Test
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/bin/bash -eu
|
||||
#
|
||||
# Copyright 2014 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
@@ -67,6 +67,7 @@ function main() {
|
||||
// Test it:
|
||||
testBuffer(fbb.dataBuffer());
|
||||
|
||||
test64bit();
|
||||
testUnicode();
|
||||
fuzzTest1();
|
||||
|
||||
@@ -105,6 +106,13 @@ function testBuffer(bb) {
|
||||
}
|
||||
assert.strictEqual(invsum, 10);
|
||||
|
||||
var invsum2 = 0;
|
||||
var invArr = monster.inventoryArray();
|
||||
for (var i = 0; i < invArr.length; i++) {
|
||||
invsum2 += invArr[i];
|
||||
}
|
||||
assert.strictEqual(invsum2, 10);
|
||||
|
||||
var test_0 = monster.test4(0);
|
||||
var test_1 = monster.test4(1);
|
||||
assert.strictEqual(monster.test4Length(), 2);
|
||||
@@ -117,26 +125,74 @@ function testBuffer(bb) {
|
||||
assert.strictEqual(monster.testbool(), false);
|
||||
}
|
||||
|
||||
function test64bit() {
|
||||
var fbb = new flatbuffers.Builder();
|
||||
var required = fbb.createString('required');
|
||||
|
||||
MyGame.Example.Stat.startStat(fbb);
|
||||
var stat2 = MyGame.Example.Stat.endStat(fbb);
|
||||
|
||||
MyGame.Example.Monster.startMonster(fbb);
|
||||
MyGame.Example.Monster.addName(fbb, required);
|
||||
MyGame.Example.Monster.addTestempty(fbb, stat2);
|
||||
var mon2 = MyGame.Example.Monster.endMonster(fbb);
|
||||
|
||||
MyGame.Example.Stat.startStat(fbb);
|
||||
MyGame.Example.Stat.addVal(fbb, new flatbuffers.Long(0x12345678, 0x23456789));
|
||||
var stat = MyGame.Example.Stat.endStat(fbb);
|
||||
|
||||
MyGame.Example.Monster.startMonster(fbb);
|
||||
MyGame.Example.Monster.addName(fbb, required);
|
||||
MyGame.Example.Monster.addEnemy(fbb, mon2);
|
||||
MyGame.Example.Monster.addTestempty(fbb, stat);
|
||||
var mon = MyGame.Example.Monster.endMonster(fbb);
|
||||
|
||||
MyGame.Example.Monster.finishMonsterBuffer(fbb, mon);
|
||||
var bytes = fbb.asUint8Array();
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
var bb = new flatbuffers.ByteBuffer(bytes);
|
||||
assert.ok(MyGame.Example.Monster.bufferHasIdentifier(bb));
|
||||
var mon = MyGame.Example.Monster.getRootAsMonster(bb);
|
||||
|
||||
var stat = mon.testempty();
|
||||
assert.strictEqual(stat != null, true);
|
||||
assert.strictEqual(stat.val() != null, true);
|
||||
assert.strictEqual(stat.val().low, 0x12345678);
|
||||
assert.strictEqual(stat.val().high, 0x23456789);
|
||||
|
||||
var mon2 = mon.enemy();
|
||||
assert.strictEqual(mon2 != null, true);
|
||||
stat = mon2.testempty();
|
||||
assert.strictEqual(stat != null, true);
|
||||
assert.strictEqual(stat.val() != null, true);
|
||||
assert.strictEqual(stat.val().low, 0); // default value
|
||||
assert.strictEqual(stat.val().high, 0);
|
||||
}
|
||||
|
||||
function testUnicode() {
|
||||
var correct = fs.readFileSync('unicode_test.mon');
|
||||
var json = JSON.parse(fs.readFileSync('unicode_test.json', 'utf8'));
|
||||
|
||||
// Test reading
|
||||
var bb = new flatbuffers.ByteBuffer(new Uint8Array(correct));
|
||||
var monster = MyGame.Example.Monster.getRootAsMonster(bb);
|
||||
assert.strictEqual(monster.name(), json.name);
|
||||
assert.deepEqual(new Buffer(monster.name(flatbuffers.Encoding.UTF8_BYTES)), new Buffer(json.name));
|
||||
assert.strictEqual(monster.testarrayoftablesLength(), json.testarrayoftables.length);
|
||||
json.testarrayoftables.forEach(function(table, i) {
|
||||
var value = monster.testarrayoftables(i);
|
||||
assert.strictEqual(value.name(), table.name);
|
||||
assert.deepEqual(new Buffer(value.name(flatbuffers.Encoding.UTF8_BYTES)), new Buffer(table.name));
|
||||
});
|
||||
assert.strictEqual(monster.testarrayofstringLength(), json.testarrayofstring.length);
|
||||
json.testarrayofstring.forEach(function(string, i) {
|
||||
assert.strictEqual(monster.testarrayofstring(i), string);
|
||||
assert.deepEqual(new Buffer(monster.testarrayofstring(i, flatbuffers.Encoding.UTF8_BYTES)), new Buffer(string));
|
||||
});
|
||||
function testReadingUnicode(bb) {
|
||||
var monster = MyGame.Example.Monster.getRootAsMonster(bb);
|
||||
assert.strictEqual(monster.name(), json.name);
|
||||
assert.deepEqual(new Buffer(monster.name(flatbuffers.Encoding.UTF8_BYTES)), new Buffer(json.name));
|
||||
assert.strictEqual(monster.testarrayoftablesLength(), json.testarrayoftables.length);
|
||||
json.testarrayoftables.forEach(function(table, i) {
|
||||
var value = monster.testarrayoftables(i);
|
||||
assert.strictEqual(value.name(), table.name);
|
||||
assert.deepEqual(new Buffer(value.name(flatbuffers.Encoding.UTF8_BYTES)), new Buffer(table.name));
|
||||
});
|
||||
assert.strictEqual(monster.testarrayofstringLength(), json.testarrayofstring.length);
|
||||
json.testarrayofstring.forEach(function(string, i) {
|
||||
assert.strictEqual(monster.testarrayofstring(i), string);
|
||||
assert.deepEqual(new Buffer(monster.testarrayofstring(i, flatbuffers.Encoding.UTF8_BYTES)), new Buffer(string));
|
||||
});
|
||||
}
|
||||
testReadingUnicode(new flatbuffers.ByteBuffer(new Uint8Array(correct)));
|
||||
|
||||
// Test writing
|
||||
var fbb = new flatbuffers.Builder();
|
||||
@@ -156,7 +212,7 @@ function testUnicode() {
|
||||
MyGame.Example.Monster.addTestarrayoftables(fbb, testarrayoftablesOffset);
|
||||
MyGame.Example.Monster.addName(fbb, name);
|
||||
MyGame.Example.Monster.finishMonsterBuffer(fbb, MyGame.Example.Monster.endMonster(fbb));
|
||||
assert.deepEqual(new Buffer(fbb.asUint8Array()), correct);
|
||||
testReadingUnicode(new flatbuffers.ByteBuffer(fbb.asUint8Array()));
|
||||
}
|
||||
|
||||
var __imul = Math.imul ? Math.imul : function(a, b) {
|
||||
|
||||
@@ -1,4 +1,18 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright 2016 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
pushd "$(dirname $0)" >/dev/null
|
||||
../flatc -b monster_test.fbs unicode_test.json
|
||||
|
||||
@@ -17,5 +17,5 @@ rem Compile then run the Java test.
|
||||
|
||||
set batch_file_dir=%~d0%~p0
|
||||
|
||||
javac -g -classpath %batch_file_dir%\..\java;%batch_file_dir% JavaTest.java
|
||||
java -classpath %batch_file_dir%\..\java;%batch_file_dir% JavaTest
|
||||
javac -g -classpath %batch_file_dir%\..\java;%batch_file_dir%;%batch_file_dir%\namespace_test JavaTest.java
|
||||
java -classpath %batch_file_dir%\..\java;%batch_file_dir%;%batch_file_dir%\namespace_test JavaTest
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
import java.io.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import MyGame.Example.*;
|
||||
import NamespaceA.*;
|
||||
import NamespaceA.NamespaceB.*;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
|
||||
class JavaTest {
|
||||
@@ -155,6 +157,10 @@ class JavaTest {
|
||||
|
||||
TestExtendedBuffer(fbb.dataBuffer().asReadOnlyBuffer());
|
||||
|
||||
TestNamespaceNesting();
|
||||
|
||||
TestNestedFlatBuffer();
|
||||
|
||||
System.out.println("FlatBuffers test: completed successfully");
|
||||
}
|
||||
|
||||
@@ -225,6 +231,55 @@ class JavaTest {
|
||||
|
||||
TestEq(monster.testhashu32Fnv1(), Integer.MAX_VALUE + 1L);
|
||||
}
|
||||
|
||||
static void TestNamespaceNesting() {
|
||||
// reference / manipulate these to verify compilation
|
||||
FlatBufferBuilder fbb = new FlatBufferBuilder(1);
|
||||
|
||||
TableInNestedNS.startTableInNestedNS(fbb);
|
||||
TableInNestedNS.addFoo(fbb, 1234);
|
||||
int nestedTableOff = TableInNestedNS.endTableInNestedNS(fbb);
|
||||
|
||||
TableInFirstNS.startTableInFirstNS(fbb);
|
||||
TableInFirstNS.addFooTable(fbb, nestedTableOff);
|
||||
int off = TableInFirstNS.endTableInFirstNS(fbb);
|
||||
}
|
||||
|
||||
static void TestNestedFlatBuffer() {
|
||||
final String nestedMonsterName = "NestedMonsterName";
|
||||
final short nestedMonsterHp = 600;
|
||||
final short nestedMonsterMana = 1024;
|
||||
|
||||
FlatBufferBuilder fbb1 = new FlatBufferBuilder(16);
|
||||
int str1 = fbb1.createString(nestedMonsterName);
|
||||
Monster.startMonster(fbb1);
|
||||
Monster.addName(fbb1, str1);
|
||||
Monster.addHp(fbb1, nestedMonsterHp);
|
||||
Monster.addMana(fbb1, nestedMonsterMana);
|
||||
int monster1 = Monster.endMonster(fbb1);
|
||||
Monster.finishMonsterBuffer(fbb1, monster1);
|
||||
byte[] fbb1Bytes = fbb1.sizedByteArray();
|
||||
fbb1 = null;
|
||||
|
||||
FlatBufferBuilder fbb2 = new FlatBufferBuilder(16);
|
||||
int str2 = fbb2.createString("My Monster");
|
||||
int nestedBuffer = Monster.createTestnestedflatbufferVector(fbb2, fbb1Bytes);
|
||||
Monster.startMonster(fbb2);
|
||||
Monster.addName(fbb2, str2);
|
||||
Monster.addHp(fbb2, (short)50);
|
||||
Monster.addMana(fbb2, (short)32);
|
||||
Monster.addTestnestedflatbuffer(fbb2, nestedBuffer);
|
||||
int monster = Monster.endMonster(fbb2);
|
||||
Monster.finishMonsterBuffer(fbb2, monster);
|
||||
|
||||
// Now test the data extracted from the nested buffer
|
||||
Monster mons = Monster.getRootAsMonster(fbb2.dataBuffer());
|
||||
Monster nestedMonster = mons.testnestedflatbufferAsMonster();
|
||||
|
||||
TestEq(nestedMonsterMana, nestedMonster.mana());
|
||||
TestEq(nestedMonsterHp, nestedMonster.hp());
|
||||
TestEq(nestedMonsterName, nestedMonster.name());
|
||||
}
|
||||
|
||||
static <T> void TestEq(T a, T b) {
|
||||
if (!a.equals(b)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2014 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -25,5 +25,5 @@ if [[ "$testdir" != "$thisdir" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
javac -classpath ${testdir}/../java:${testdir} JavaTest.java
|
||||
java -classpath ${testdir}/../java:${testdir} JavaTest
|
||||
javac -classpath ${testdir}/../java:${testdir}:${testdir}/namespace_test JavaTest.java
|
||||
java -classpath ${testdir}/../java:${testdir}:${testdir}/namespace_test JavaTest
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace MyGame.Example
|
||||
{
|
||||
@@ -8,6 +8,7 @@ public enum Any : byte
|
||||
NONE = 0,
|
||||
Monster = 1,
|
||||
TestSimpleTableWithEnum = 2,
|
||||
MyGame_Example2_Monster = 3,
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package Example
|
||||
|
||||
@@ -6,4 +6,5 @@ const (
|
||||
AnyNONE = 0
|
||||
AnyMonster = 1
|
||||
AnyTestSimpleTableWithEnum = 2
|
||||
AnyMyGame_Example2_Monster = 3
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package MyGame.Example;
|
||||
|
||||
@@ -7,8 +7,9 @@ public final class Any {
|
||||
public static final byte NONE = 0;
|
||||
public static final byte Monster = 1;
|
||||
public static final byte TestSimpleTableWithEnum = 2;
|
||||
public static final byte MyGame_Example2_Monster = 3;
|
||||
|
||||
private static final String[] names = { "NONE", "Monster", "TestSimpleTableWithEnum", };
|
||||
private static final String[] names = { "NONE", "Monster", "TestSimpleTableWithEnum", "MyGame_Example2_Monster", };
|
||||
|
||||
public static String name(int e) { return names[e]; }
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace MyGame\Example;
|
||||
|
||||
@@ -8,11 +8,13 @@ class Any
|
||||
const NONE = 0;
|
||||
const Monster = 1;
|
||||
const TestSimpleTableWithEnum = 2;
|
||||
const MyGame_Example2_Monster = 3;
|
||||
|
||||
private static $names = array(
|
||||
"NONE",
|
||||
"Monster",
|
||||
"TestSimpleTableWithEnum",
|
||||
"MyGame_Example2_Monster",
|
||||
);
|
||||
|
||||
public static function Name($e)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# automatically generated, do not modify
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: Example
|
||||
|
||||
@@ -6,4 +6,5 @@ class Any(object):
|
||||
NONE = 0
|
||||
Monster = 1
|
||||
TestSimpleTableWithEnum = 2
|
||||
MyGame_Example2_Monster = 3
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace MyGame.Example
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package Example
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package MyGame.Example;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace MyGame\Example;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# automatically generated, do not modify
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: Example
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace MyGame.Example
|
||||
{
|
||||
|
||||
using System;
|
||||
using FlatBuffers;
|
||||
|
||||
/// an example documentation comment: monster object
|
||||
@@ -19,8 +20,10 @@ public sealed class Monster : Table {
|
||||
public short Hp { get { int o = __offset(8); return o != 0 ? bb.GetShort(o + bb_pos) : (short)100; } }
|
||||
public bool MutateHp(short hp) { int o = __offset(8); if (o != 0) { bb.PutShort(o + bb_pos, hp); return true; } else { return false; } }
|
||||
public string Name { get { int o = __offset(10); return o != 0 ? __string(o + bb_pos) : null; } }
|
||||
public ArraySegment<byte>? GetNameBytes() { return __vector_as_arraysegment(10); }
|
||||
public byte GetInventory(int j) { int o = __offset(14); return o != 0 ? bb.Get(__vector(o) + j * 1) : (byte)0; }
|
||||
public int InventoryLength { get { int o = __offset(14); return o != 0 ? __vector_len(o) : 0; } }
|
||||
public ArraySegment<byte>? GetInventoryBytes() { return __vector_as_arraysegment(14); }
|
||||
public bool MutateInventory(int j, byte inventory) { int o = __offset(14); if (o != 0) { bb.Put(__vector(o) + j * 1, inventory); return true; } else { return false; } }
|
||||
public Color Color { get { int o = __offset(16); return o != 0 ? (Color)bb.GetSbyte(o + bb_pos) : Color.Blue; } }
|
||||
public bool MutateColor(Color color) { int o = __offset(16); if (o != 0) { bb.PutSbyte(o + bb_pos, (sbyte)color); return true; } else { return false; } }
|
||||
@@ -41,6 +44,9 @@ public sealed class Monster : Table {
|
||||
public Monster GetEnemy(Monster obj) { int o = __offset(28); return o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null; }
|
||||
public byte GetTestnestedflatbuffer(int j) { int o = __offset(30); return o != 0 ? bb.Get(__vector(o) + j * 1) : (byte)0; }
|
||||
public int TestnestedflatbufferLength { get { int o = __offset(30); return o != 0 ? __vector_len(o) : 0; } }
|
||||
public ArraySegment<byte>? GetTestnestedflatbufferBytes() { return __vector_as_arraysegment(30); }
|
||||
public Monster TestnestedflatbufferAsMonster() { return GetTestnestedflatbufferAsMonster(new Monster()); }
|
||||
public Monster GetTestnestedflatbufferAsMonster(Monster obj) { int o = __offset(30); return o != 0 ? obj.__init(__indirect(__vector(o)), bb) : null; }
|
||||
public bool MutateTestnestedflatbuffer(int j, byte testnestedflatbuffer) { int o = __offset(30); if (o != 0) { bb.Put(__vector(o) + j * 1, testnestedflatbuffer); return true; } else { return false; } }
|
||||
public Stat Testempty { get { return GetTestempty(new Stat()); } }
|
||||
public Stat GetTestempty(Stat obj) { int o = __offset(32); return o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null; }
|
||||
@@ -64,9 +70,18 @@ public sealed class Monster : Table {
|
||||
public bool MutateTesthashu64Fnv1a(ulong testhashu64_fnv1a) { int o = __offset(50); if (o != 0) { bb.PutUlong(o + bb_pos, testhashu64_fnv1a); return true; } else { return false; } }
|
||||
public bool GetTestarrayofbools(int j) { int o = __offset(52); return o != 0 ? 0!=bb.Get(__vector(o) + j * 1) : false; }
|
||||
public int TestarrayofboolsLength { get { int o = __offset(52); return o != 0 ? __vector_len(o) : 0; } }
|
||||
public ArraySegment<byte>? GetTestarrayofboolsBytes() { return __vector_as_arraysegment(52); }
|
||||
public bool MutateTestarrayofbools(int j, bool testarrayofbools) { int o = __offset(52); if (o != 0) { bb.Put(__vector(o) + j * 1, (byte)(testarrayofbools ? 1 : 0)); return true; } else { return false; } }
|
||||
public float Testf { get { int o = __offset(54); return o != 0 ? bb.GetFloat(o + bb_pos) : (float)3.14159f; } }
|
||||
public bool MutateTestf(float testf) { int o = __offset(54); if (o != 0) { bb.PutFloat(o + bb_pos, testf); return true; } else { return false; } }
|
||||
public float Testf2 { get { int o = __offset(56); return o != 0 ? bb.GetFloat(o + bb_pos) : (float)3.0f; } }
|
||||
public bool MutateTestf2(float testf2) { int o = __offset(56); if (o != 0) { bb.PutFloat(o + bb_pos, testf2); return true; } else { return false; } }
|
||||
public float Testf3 { get { int o = __offset(58); return o != 0 ? bb.GetFloat(o + bb_pos) : (float)0.0f; } }
|
||||
public bool MutateTestf3(float testf3) { int o = __offset(58); if (o != 0) { bb.PutFloat(o + bb_pos, testf3); return true; } else { return false; } }
|
||||
public string GetTestarrayofstring2(int j) { int o = __offset(60); return o != 0 ? __string(__vector(o) + j * 4) : null; }
|
||||
public int Testarrayofstring2Length { get { int o = __offset(60); return o != 0 ? __vector_len(o) : 0; } }
|
||||
|
||||
public static void StartMonster(FlatBufferBuilder builder) { builder.StartObject(25); }
|
||||
public static void StartMonster(FlatBufferBuilder builder) { builder.StartObject(29); }
|
||||
public static void AddPos(FlatBufferBuilder builder, Offset<Vec3> posOffset) { builder.AddStruct(0, posOffset.Value, 0); }
|
||||
public static void AddMana(FlatBufferBuilder builder, short mana) { builder.AddShort(1, mana, 150); }
|
||||
public static void AddHp(FlatBufferBuilder builder, short hp) { builder.AddShort(2, hp, 100); }
|
||||
@@ -102,6 +117,12 @@ public sealed class Monster : Table {
|
||||
public static void AddTestarrayofbools(FlatBufferBuilder builder, VectorOffset testarrayofboolsOffset) { builder.AddOffset(24, testarrayofboolsOffset.Value, 0); }
|
||||
public static VectorOffset CreateTestarrayofboolsVector(FlatBufferBuilder builder, bool[] data) { builder.StartVector(1, data.Length, 1); for (int i = data.Length - 1; i >= 0; i--) builder.AddBool(data[i]); return builder.EndVector(); }
|
||||
public static void StartTestarrayofboolsVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(1, numElems, 1); }
|
||||
public static void AddTestf(FlatBufferBuilder builder, float testf) { builder.AddFloat(25, testf, 3.14159f); }
|
||||
public static void AddTestf2(FlatBufferBuilder builder, float testf2) { builder.AddFloat(26, testf2, 3.0f); }
|
||||
public static void AddTestf3(FlatBufferBuilder builder, float testf3) { builder.AddFloat(27, testf3, 0.0f); }
|
||||
public static void AddTestarrayofstring2(FlatBufferBuilder builder, VectorOffset testarrayofstring2Offset) { builder.AddOffset(28, testarrayofstring2Offset.Value, 0); }
|
||||
public static VectorOffset CreateTestarrayofstring2Vector(FlatBufferBuilder builder, StringOffset[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i].Value); return builder.EndVector(); }
|
||||
public static void StartTestarrayofstring2Vector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
|
||||
public static Offset<Monster> EndMonster(FlatBufferBuilder builder) {
|
||||
int o = builder.EndObject();
|
||||
builder.Required(o, 10); // name
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package Example
|
||||
|
||||
@@ -313,7 +313,48 @@ func (rcv *Monster) TestarrayofboolsLength() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func MonsterStart(builder *flatbuffers.Builder) { builder.StartObject(25) }
|
||||
func (rcv *Monster) Testf() float32 {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(54))
|
||||
if o != 0 {
|
||||
return rcv._tab.GetFloat32(o + rcv._tab.Pos)
|
||||
}
|
||||
return 3.14159
|
||||
}
|
||||
|
||||
func (rcv *Monster) Testf2() float32 {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(56))
|
||||
if o != 0 {
|
||||
return rcv._tab.GetFloat32(o + rcv._tab.Pos)
|
||||
}
|
||||
return 3.0
|
||||
}
|
||||
|
||||
func (rcv *Monster) Testf3() float32 {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(58))
|
||||
if o != 0 {
|
||||
return rcv._tab.GetFloat32(o + rcv._tab.Pos)
|
||||
}
|
||||
return 0.0
|
||||
}
|
||||
|
||||
func (rcv *Monster) Testarrayofstring2(j int) []byte {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(60))
|
||||
if o != 0 {
|
||||
a := rcv._tab.Vector(o)
|
||||
return rcv._tab.ByteVector(a + flatbuffers.UOffsetT(j * 4))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rcv *Monster) Testarrayofstring2Length() int {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(60))
|
||||
if o != 0 {
|
||||
return rcv._tab.VectorLen(o)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func MonsterStart(builder *flatbuffers.Builder) { builder.StartObject(29) }
|
||||
func MonsterAddPos(builder *flatbuffers.Builder, pos flatbuffers.UOffsetT) { builder.PrependStructSlot(0, flatbuffers.UOffsetT(pos), 0) }
|
||||
func MonsterAddMana(builder *flatbuffers.Builder, mana int16) { builder.PrependInt16Slot(1, mana, 150) }
|
||||
func MonsterAddHp(builder *flatbuffers.Builder, hp int16) { builder.PrependInt16Slot(2, hp, 100) }
|
||||
@@ -350,4 +391,10 @@ func MonsterAddTesthashu64Fnv1a(builder *flatbuffers.Builder, testhashu64Fnv1a u
|
||||
func MonsterAddTestarrayofbools(builder *flatbuffers.Builder, testarrayofbools flatbuffers.UOffsetT) { builder.PrependUOffsetTSlot(24, flatbuffers.UOffsetT(testarrayofbools), 0) }
|
||||
func MonsterStartTestarrayofboolsVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { return builder.StartVector(1, numElems, 1)
|
||||
}
|
||||
func MonsterAddTestf(builder *flatbuffers.Builder, testf float32) { builder.PrependFloat32Slot(25, testf, 3.14159) }
|
||||
func MonsterAddTestf2(builder *flatbuffers.Builder, testf2 float32) { builder.PrependFloat32Slot(26, testf2, 3.0) }
|
||||
func MonsterAddTestf3(builder *flatbuffers.Builder, testf3 float32) { builder.PrependFloat32Slot(27, testf3, 0.0) }
|
||||
func MonsterAddTestarrayofstring2(builder *flatbuffers.Builder, testarrayofstring2 flatbuffers.UOffsetT) { builder.PrependUOffsetTSlot(28, flatbuffers.UOffsetT(testarrayofstring2), 0) }
|
||||
func MonsterStartTestarrayofstring2Vector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { return builder.StartVector(4, numElems, 4)
|
||||
}
|
||||
func MonsterEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package MyGame.Example;
|
||||
|
||||
@@ -51,6 +51,8 @@ public final class Monster extends Table {
|
||||
public int testnestedflatbuffer(int j) { int o = __offset(30); return o != 0 ? bb.get(__vector(o) + j * 1) & 0xFF : 0; }
|
||||
public int testnestedflatbufferLength() { int o = __offset(30); return o != 0 ? __vector_len(o) : 0; }
|
||||
public ByteBuffer testnestedflatbufferAsByteBuffer() { return __vector_as_bytebuffer(30, 1); }
|
||||
public Monster testnestedflatbufferAsMonster() { return testnestedflatbufferAsMonster(new Monster()); }
|
||||
public Monster testnestedflatbufferAsMonster(Monster obj) { int o = __offset(30); return o != 0 ? obj.__init(__indirect(__vector(o)), bb) : null; }
|
||||
public boolean mutateTestnestedflatbuffer(int j, int testnestedflatbuffer) { int o = __offset(30); if (o != 0) { bb.put(__vector(o) + j * 1, (byte)testnestedflatbuffer); return true; } else { return false; } }
|
||||
public Stat testempty() { return testempty(new Stat()); }
|
||||
public Stat testempty(Stat obj) { int o = __offset(32); return o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null; }
|
||||
@@ -76,8 +78,16 @@ public final class Monster extends Table {
|
||||
public int testarrayofboolsLength() { int o = __offset(52); return o != 0 ? __vector_len(o) : 0; }
|
||||
public ByteBuffer testarrayofboolsAsByteBuffer() { return __vector_as_bytebuffer(52, 1); }
|
||||
public boolean mutateTestarrayofbools(int j, boolean testarrayofbools) { int o = __offset(52); if (o != 0) { bb.put(__vector(o) + j * 1, (byte)(testarrayofbools ? 1 : 0)); return true; } else { return false; } }
|
||||
public float testf() { int o = __offset(54); return o != 0 ? bb.getFloat(o + bb_pos) : 3.14159f; }
|
||||
public boolean mutateTestf(float testf) { int o = __offset(54); if (o != 0) { bb.putFloat(o + bb_pos, testf); return true; } else { return false; } }
|
||||
public float testf2() { int o = __offset(56); return o != 0 ? bb.getFloat(o + bb_pos) : 3.0f; }
|
||||
public boolean mutateTestf2(float testf2) { int o = __offset(56); if (o != 0) { bb.putFloat(o + bb_pos, testf2); return true; } else { return false; } }
|
||||
public float testf3() { int o = __offset(58); return o != 0 ? bb.getFloat(o + bb_pos) : 0.0f; }
|
||||
public boolean mutateTestf3(float testf3) { int o = __offset(58); if (o != 0) { bb.putFloat(o + bb_pos, testf3); return true; } else { return false; } }
|
||||
public String testarrayofstring2(int j) { int o = __offset(60); return o != 0 ? __string(__vector(o) + j * 4) : null; }
|
||||
public int testarrayofstring2Length() { int o = __offset(60); return o != 0 ? __vector_len(o) : 0; }
|
||||
|
||||
public static void startMonster(FlatBufferBuilder builder) { builder.startObject(25); }
|
||||
public static void startMonster(FlatBufferBuilder builder) { builder.startObject(29); }
|
||||
public static void addPos(FlatBufferBuilder builder, int posOffset) { builder.addStruct(0, posOffset, 0); }
|
||||
public static void addMana(FlatBufferBuilder builder, short mana) { builder.addShort(1, mana, 150); }
|
||||
public static void addHp(FlatBufferBuilder builder, short hp) { builder.addShort(2, hp, 100); }
|
||||
@@ -113,6 +123,12 @@ public final class Monster extends Table {
|
||||
public static void addTestarrayofbools(FlatBufferBuilder builder, int testarrayofboolsOffset) { builder.addOffset(24, testarrayofboolsOffset, 0); }
|
||||
public static int createTestarrayofboolsVector(FlatBufferBuilder builder, boolean[] data) { builder.startVector(1, data.length, 1); for (int i = data.length - 1; i >= 0; i--) builder.addBoolean(data[i]); return builder.endVector(); }
|
||||
public static void startTestarrayofboolsVector(FlatBufferBuilder builder, int numElems) { builder.startVector(1, numElems, 1); }
|
||||
public static void addTestf(FlatBufferBuilder builder, float testf) { builder.addFloat(25, testf, 3.14159f); }
|
||||
public static void addTestf2(FlatBufferBuilder builder, float testf2) { builder.addFloat(26, testf2, 3.0f); }
|
||||
public static void addTestf3(FlatBufferBuilder builder, float testf3) { builder.addFloat(27, testf3, 0.0f); }
|
||||
public static void addTestarrayofstring2(FlatBufferBuilder builder, int testarrayofstring2Offset) { builder.addOffset(28, testarrayofstring2Offset, 0); }
|
||||
public static int createTestarrayofstring2Vector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startTestarrayofstring2Vector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static int endMonster(FlatBufferBuilder builder) {
|
||||
int o = builder.endObject();
|
||||
builder.required(o, 10); // name
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace MyGame\Example;
|
||||
|
||||
@@ -98,6 +98,14 @@ class Monster extends Table
|
||||
return $o != 0 ? $this->__vector_len($o) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getInventoryBytes()
|
||||
{
|
||||
return $this->__vector_as_bytes(14);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return sbyte
|
||||
*/
|
||||
@@ -188,7 +196,7 @@ class Monster extends Table
|
||||
{
|
||||
$obj = new Monster();
|
||||
$o = $this->__offset(28);
|
||||
return $o != 0 ? $obj->init($o + $this->bb_pos, $this->bb) : 0;
|
||||
return $o != 0 ? $obj->init($this->__indirect($o + $this->bb_pos), $this->bb) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,11 +218,19 @@ class Monster extends Table
|
||||
return $o != 0 ? $this->__vector_len($o) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTestnestedflatbufferBytes()
|
||||
{
|
||||
return $this->__vector_as_bytes(30);
|
||||
}
|
||||
|
||||
public function getTestempty()
|
||||
{
|
||||
$obj = new Stat();
|
||||
$o = $this->__offset(32);
|
||||
return $o != 0 ? $obj->init($o + $this->bb_pos, $this->bb) : 0;
|
||||
return $o != 0 ? $obj->init($this->__indirect($o + $this->bb_pos), $this->bb) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -317,22 +333,68 @@ class Monster extends Table
|
||||
return $o != 0 ? $this->__vector_len($o) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getTestf()
|
||||
{
|
||||
$o = $this->__offset(54);
|
||||
return $o != 0 ? $this->bb->getFloat($o + $this->bb_pos) : 3.14159;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getTestf2()
|
||||
{
|
||||
$o = $this->__offset(56);
|
||||
return $o != 0 ? $this->bb->getFloat($o + $this->bb_pos) : 3.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getTestf3()
|
||||
{
|
||||
$o = $this->__offset(58);
|
||||
return $o != 0 ? $this->bb->getFloat($o + $this->bb_pos) : 0.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int offset
|
||||
* @return string
|
||||
*/
|
||||
public function getTestarrayofstring2($j)
|
||||
{
|
||||
$o = $this->__offset(60);
|
||||
return $o != 0 ? $this->__string($this->__vector($o) + $j * 4) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTestarrayofstring2Length()
|
||||
{
|
||||
$o = $this->__offset(60);
|
||||
return $o != 0 ? $this->__vector_len($o) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @return void
|
||||
*/
|
||||
public static function startMonster(FlatBufferBuilder $builder)
|
||||
{
|
||||
$builder->StartObject(25);
|
||||
$builder->StartObject(29);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @return Monster
|
||||
*/
|
||||
public static function createMonster(FlatBufferBuilder $builder, $pos, $mana, $hp, $name, $inventory, $color, $test_type, $test, $test4, $testarrayofstring, $testarrayoftables, $enemy, $testnestedflatbuffer, $testempty, $testbool, $testhashs32_fnv1, $testhashu32_fnv1, $testhashs64_fnv1, $testhashu64_fnv1, $testhashs32_fnv1a, $testhashu32_fnv1a, $testhashs64_fnv1a, $testhashu64_fnv1a, $testarrayofbools)
|
||||
public static function createMonster(FlatBufferBuilder $builder, $pos, $mana, $hp, $name, $inventory, $color, $test_type, $test, $test4, $testarrayofstring, $testarrayoftables, $enemy, $testnestedflatbuffer, $testempty, $testbool, $testhashs32_fnv1, $testhashu32_fnv1, $testhashs64_fnv1, $testhashu64_fnv1, $testhashs32_fnv1a, $testhashu32_fnv1a, $testhashs64_fnv1a, $testhashu64_fnv1a, $testarrayofbools, $testf, $testf2, $testf3, $testarrayofstring2)
|
||||
{
|
||||
$builder->startObject(25);
|
||||
$builder->startObject(29);
|
||||
self::addPos($builder, $pos);
|
||||
self::addMana($builder, $mana);
|
||||
self::addHp($builder, $hp);
|
||||
@@ -357,6 +419,10 @@ class Monster extends Table
|
||||
self::addTesthashs64Fnv1a($builder, $testhashs64_fnv1a);
|
||||
self::addTesthashu64Fnv1a($builder, $testhashu64_fnv1a);
|
||||
self::addTestarrayofbools($builder, $testarrayofbools);
|
||||
self::addTestf($builder, $testf);
|
||||
self::addTestf2($builder, $testf2);
|
||||
self::addTestf3($builder, $testf3);
|
||||
self::addTestarrayofstring2($builder, $testarrayofstring2);
|
||||
$o = $builder->endObject();
|
||||
$builder->required($o, 10); // name
|
||||
return $o;
|
||||
@@ -741,6 +807,70 @@ class Monster extends Table
|
||||
$builder->startVector(1, $numElems, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @param float
|
||||
* @return void
|
||||
*/
|
||||
public static function addTestf(FlatBufferBuilder $builder, $testf)
|
||||
{
|
||||
$builder->addFloatX(25, $testf, 3.14159);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @param float
|
||||
* @return void
|
||||
*/
|
||||
public static function addTestf2(FlatBufferBuilder $builder, $testf2)
|
||||
{
|
||||
$builder->addFloatX(26, $testf2, 3.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @param float
|
||||
* @return void
|
||||
*/
|
||||
public static function addTestf3(FlatBufferBuilder $builder, $testf3)
|
||||
{
|
||||
$builder->addFloatX(27, $testf3, 0.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @param VectorOffset
|
||||
* @return void
|
||||
*/
|
||||
public static function addTestarrayofstring2(FlatBufferBuilder $builder, $testarrayofstring2)
|
||||
{
|
||||
$builder->addOffsetX(28, $testarrayofstring2, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @param array offset array
|
||||
* @return int vector offset
|
||||
*/
|
||||
public static function createTestarrayofstring2Vector(FlatBufferBuilder $builder, array $data)
|
||||
{
|
||||
$builder->startVector(4, count($data), 4);
|
||||
for ($i = count($data) - 1; $i >= 0; $i--) {
|
||||
$builder->addOffset($data[$i]);
|
||||
}
|
||||
return $builder->endVector();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @param int $numElems
|
||||
* @return void
|
||||
*/
|
||||
public static function startTestarrayofstring2Vector(FlatBufferBuilder $builder, $numElems)
|
||||
{
|
||||
$builder->startVector(4, $numElems, 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @return int table offset
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# automatically generated, do not modify
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: Example
|
||||
|
||||
@@ -262,7 +262,43 @@ class Monster(object):
|
||||
return self._tab.VectorLen(o)
|
||||
return 0
|
||||
|
||||
def MonsterStart(builder): builder.StartObject(25)
|
||||
# Monster
|
||||
def Testf(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(54))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos)
|
||||
return 3.14159
|
||||
|
||||
# Monster
|
||||
def Testf2(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(56))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos)
|
||||
return 3.0
|
||||
|
||||
# Monster
|
||||
def Testf3(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(58))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos)
|
||||
return 0.0
|
||||
|
||||
# Monster
|
||||
def Testarrayofstring2(self, j):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(60))
|
||||
if o != 0:
|
||||
a = self._tab.Vector(o)
|
||||
return self._tab.String(a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4))
|
||||
return ""
|
||||
|
||||
# Monster
|
||||
def Testarrayofstring2Length(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(60))
|
||||
if o != 0:
|
||||
return self._tab.VectorLen(o)
|
||||
return 0
|
||||
|
||||
def MonsterStart(builder): builder.StartObject(29)
|
||||
def MonsterAddPos(builder, pos): builder.PrependStructSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(pos), 0)
|
||||
def MonsterAddMana(builder, mana): builder.PrependInt16Slot(1, mana, 150)
|
||||
def MonsterAddHp(builder, hp): builder.PrependInt16Slot(2, hp, 100)
|
||||
@@ -293,4 +329,9 @@ def MonsterAddTesthashs64Fnv1a(builder, testhashs64Fnv1a): builder.PrependInt64S
|
||||
def MonsterAddTesthashu64Fnv1a(builder, testhashu64Fnv1a): builder.PrependUint64Slot(23, testhashu64Fnv1a, 0)
|
||||
def MonsterAddTestarrayofbools(builder, testarrayofbools): builder.PrependUOffsetTRelativeSlot(24, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayofbools), 0)
|
||||
def MonsterStartTestarrayofboolsVector(builder, numElems): return builder.StartVector(1, numElems, 1)
|
||||
def MonsterAddTestf(builder, testf): builder.PrependFloat32Slot(25, testf, 3.14159)
|
||||
def MonsterAddTestf2(builder, testf2): builder.PrependFloat32Slot(26, testf2, 3.0)
|
||||
def MonsterAddTestf3(builder, testf3): builder.PrependFloat32Slot(27, testf3, 0.0)
|
||||
def MonsterAddTestarrayofstring2(builder, testarrayofstring2): builder.PrependUOffsetTRelativeSlot(28, flatbuffers.number_types.UOffsetTFlags.py_type(testarrayofstring2), 0)
|
||||
def MonsterStartTestarrayofstring2Vector(builder, numElems): return builder.StartVector(4, numElems, 4)
|
||||
def MonsterEnd(builder): return builder.EndObject()
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace MyGame.Example
|
||||
{
|
||||
|
||||
using System;
|
||||
using FlatBuffers;
|
||||
|
||||
public sealed class Stat : Table {
|
||||
@@ -11,6 +12,7 @@ public sealed class Stat : Table {
|
||||
public Stat __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
|
||||
|
||||
public string Id { get { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; } }
|
||||
public ArraySegment<byte>? GetIdBytes() { return __vector_as_arraysegment(4); }
|
||||
public long Val { get { int o = __offset(6); return o != 0 ? bb.GetLong(o + bb_pos) : (long)0; } }
|
||||
public bool MutateVal(long val) { int o = __offset(6); if (o != 0) { bb.PutLong(o + bb_pos, val); return true; } else { return false; } }
|
||||
public ushort Count { get { int o = __offset(8); return o != 0 ? bb.GetUshort(o + bb_pos) : (ushort)0; } }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package Example
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package MyGame.Example;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace MyGame\Example;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# automatically generated, do not modify
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: Example
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace MyGame.Example
|
||||
{
|
||||
|
||||
using System;
|
||||
using FlatBuffers;
|
||||
|
||||
public sealed class Test : Struct {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package Example
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package MyGame.Example;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace MyGame\Example;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# automatically generated, do not modify
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: Example
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace MyGame.Example
|
||||
{
|
||||
|
||||
using System;
|
||||
using FlatBuffers;
|
||||
|
||||
public sealed class TestSimpleTableWithEnum : Table {
|
||||
public partial class TestSimpleTableWithEnum : Table {
|
||||
public static TestSimpleTableWithEnum GetRootAsTestSimpleTableWithEnum(ByteBuffer _bb) { return GetRootAsTestSimpleTableWithEnum(_bb, new TestSimpleTableWithEnum()); }
|
||||
public static TestSimpleTableWithEnum GetRootAsTestSimpleTableWithEnum(ByteBuffer _bb, TestSimpleTableWithEnum obj) { return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
|
||||
public TestSimpleTableWithEnum __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package Example
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package MyGame.Example;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace MyGame\Example;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# automatically generated, do not modify
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: Example
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace MyGame.Example
|
||||
{
|
||||
|
||||
using System;
|
||||
using FlatBuffers;
|
||||
|
||||
public sealed class Vec3 : Struct {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package Example
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package MyGame.Example;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// automatically generated, do not modify
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace MyGame\Example;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# automatically generated, do not modify
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: Example
|
||||
|
||||
|
||||
23
tests/MyGame/Example2/Monster.cs
Normal file
23
tests/MyGame/Example2/Monster.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace MyGame.Example2
|
||||
{
|
||||
|
||||
using System;
|
||||
using FlatBuffers;
|
||||
|
||||
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)); }
|
||||
public Monster __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
|
||||
|
||||
|
||||
public static void StartMonster(FlatBufferBuilder builder) { builder.StartObject(0); }
|
||||
public static Offset<MyGame.Example2.Monster> EndMonster(FlatBufferBuilder builder) {
|
||||
int o = builder.EndObject();
|
||||
return new Offset<MyGame.Example2.Monster>(o);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
18
tests/MyGame/Example2/Monster.go
Normal file
18
tests/MyGame/Example2/Monster.go
Normal file
@@ -0,0 +1,18 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package Example2
|
||||
|
||||
import (
|
||||
flatbuffers "github.com/google/flatbuffers/go"
|
||||
)
|
||||
type Monster struct {
|
||||
_tab flatbuffers.Table
|
||||
}
|
||||
|
||||
func (rcv *Monster) Init(buf []byte, i flatbuffers.UOffsetT) {
|
||||
rcv._tab.Bytes = buf
|
||||
rcv._tab.Pos = i
|
||||
}
|
||||
|
||||
func MonsterStart(builder *flatbuffers.Builder) { builder.StartObject(0) }
|
||||
func MonsterEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() }
|
||||
23
tests/MyGame/Example2/Monster.java
Normal file
23
tests/MyGame/Example2/Monster.java
Normal file
@@ -0,0 +1,23 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package MyGame.Example2;
|
||||
|
||||
import java.nio.*;
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import com.google.flatbuffers.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
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)); }
|
||||
public Monster __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
|
||||
|
||||
|
||||
public static void startMonster(FlatBufferBuilder builder) { builder.startObject(0); }
|
||||
public static int endMonster(FlatBufferBuilder builder) {
|
||||
int o = builder.endObject();
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
79
tests/MyGame/Example2/Monster.php
Normal file
79
tests/MyGame/Example2/Monster.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace MyGame\Example2;
|
||||
|
||||
use \Google\FlatBuffers\Struct;
|
||||
use \Google\FlatBuffers\Table;
|
||||
use \Google\FlatBuffers\ByteBuffer;
|
||||
use \Google\FlatBuffers\FlatBufferBuilder;
|
||||
|
||||
class Monster extends Table
|
||||
{
|
||||
/**
|
||||
* @param ByteBuffer $bb
|
||||
* @return Monster
|
||||
*/
|
||||
public static function getRootAsMonster(ByteBuffer $bb)
|
||||
{
|
||||
$obj = new Monster();
|
||||
return ($obj->init($bb->getInt($bb->getPosition()) + $bb->getPosition(), $bb));
|
||||
}
|
||||
|
||||
public static function MonsterIdentifier()
|
||||
{
|
||||
return "MONS";
|
||||
}
|
||||
|
||||
public static function MonsterBufferHasIdentifier(ByteBuffer $buf)
|
||||
{
|
||||
return self::__has_identifier($buf, self::MonsterIdentifier());
|
||||
}
|
||||
|
||||
public static function MonsterExtension()
|
||||
{
|
||||
return "mon";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $_i offset
|
||||
* @param ByteBuffer $_bb
|
||||
* @return Monster
|
||||
**/
|
||||
public function init($_i, ByteBuffer $_bb)
|
||||
{
|
||||
$this->bb_pos = $_i;
|
||||
$this->bb = $_bb;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @return void
|
||||
*/
|
||||
public static function startMonster(FlatBufferBuilder $builder)
|
||||
{
|
||||
$builder->StartObject(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @return Monster
|
||||
*/
|
||||
public static function createMonster(FlatBufferBuilder $builder, )
|
||||
{
|
||||
$builder->startObject(0);
|
||||
$o = $builder->endObject();
|
||||
return $o;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @return int table offset
|
||||
*/
|
||||
public static function endMonster(FlatBufferBuilder $builder)
|
||||
{
|
||||
$o = $builder->endObject();
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
15
tests/MyGame/Example2/Monster.py
Normal file
15
tests/MyGame/Example2/Monster.py
Normal file
@@ -0,0 +1,15 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: Example2
|
||||
|
||||
import flatbuffers
|
||||
|
||||
class Monster(object):
|
||||
__slots__ = ['_tab']
|
||||
|
||||
# Monster
|
||||
def Init(self, buf, pos):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
def MonsterStart(builder): builder.StartObject(0)
|
||||
def MonsterEnd(builder): return builder.EndObject()
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/bin/bash -eu
|
||||
#
|
||||
# Copyright 2014 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
20
tests/fuzzer/build_fuzzer.sh
Normal file
20
tests/fuzzer/build_fuzzer.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2015 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
git clone https://chromium.googlesource.com/chromium/llvm-project/llvm/lib/Fuzzer
|
||||
clang++ -c -g -O2 -std=c++11 Fuzzer/*.cpp -IFuzzer
|
||||
ar ruv libFuzzer.a Fuzzer*.o
|
||||
rm -rf Fuzzer *.o
|
||||
20
tests/fuzzer/build_run_parser_test.sh
Normal file
20
tests/fuzzer/build_run_parser_test.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2015 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
clang++ -fsanitize-coverage=edge -fsanitize=address -std=c++11 -stdlib=libstdc++ -I.. -I../../include flatbuffers_parser_fuzzer.cc ../../src/idl_parser.cpp ../../src/util.cpp libFuzzer.a -o fuzz_parser
|
||||
mkdir -p parser_corpus
|
||||
cp ../*.json ../*.fbs parser_corpus
|
||||
./fuzz_parser parser_corpus
|
||||
20
tests/fuzzer/build_run_verifier_test.sh
Normal file
20
tests/fuzzer/build_run_verifier_test.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2015 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
clang++ -fsanitize-coverage=edge -fsanitize=address -std=c++11 -stdlib=libstdc++ -I.. -I../../include flatbuffers_verifier_fuzzer.cc libFuzzer.a -o fuzz_verifier
|
||||
mkdir -p verifier_corpus
|
||||
cp ../*.mon verifier_corpus
|
||||
./fuzz_verifier verifier_corpus
|
||||
16
tests/fuzzer/flatbuffers_parser_fuzzer.cc
Normal file
16
tests/fuzzer/flatbuffers_parser_fuzzer.cc
Normal file
@@ -0,0 +1,16 @@
|
||||
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
#include "flatbuffers/idl.h"
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
flatbuffers::Parser parser;
|
||||
// Guarantee 0-termination.
|
||||
std::string s(reinterpret_cast<const char *>(data), size);
|
||||
parser.Parse(s.c_str());
|
||||
return 0;
|
||||
}
|
||||
14
tests/fuzzer/flatbuffers_verifier_fuzzer.cc
Normal file
14
tests/fuzzer/flatbuffers_verifier_fuzzer.cc
Normal file
@@ -0,0 +1,14 @@
|
||||
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
#include "monster_test_generated.h"
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
flatbuffers::Verifier verifier(data, size);
|
||||
MyGame::Example::VerifyMonsterBuffer(verifier);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,2 +1,17 @@
|
||||
..\flatc.exe -c -j -n -g -b -p --php -s --gen-mutable --no-includes monster_test.fbs monsterdata_test.json
|
||||
..\flatc.exe -b --schema monster_test.fbs
|
||||
:: Copyright 2015 Google Inc. All rights reserved.
|
||||
::
|
||||
:: Licensed under the Apache License, Version 2.0 (the "License");
|
||||
:: you may not use this file except in compliance with the License.
|
||||
:: You may obtain a copy of the License at
|
||||
::
|
||||
:: http://www.apache.org/licenses/LICENSE-2.0
|
||||
::
|
||||
:: Unless required by applicable law or agreed to in writing, software
|
||||
:: distributed under the License is distributed on an "AS IS" BASIS,
|
||||
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
:: See the License for the specific language governing permissions and
|
||||
:: limitations under the License.
|
||||
|
||||
..\flatc.exe --cpp --java --csharp --go --binary --python --js --php --grpc --gen-mutable --no-includes monster_test.fbs monsterdata_test.json
|
||||
..\flatc.exe --cpp --java --csharp --go --binary --python --js --php --gen-mutable -o namespace_test namespace_test\namespace_test1.fbs namespace_test\namespace_test2.fbs
|
||||
..\flatc.exe --binary --schema monster_test.fbs
|
||||
|
||||
@@ -1,2 +1,25 @@
|
||||
<<<<<<< HEAD
|
||||
../flatc --cpp --java --csharp --go --binary --python --js --php --gen-mutable --no-includes monster_test.fbs monsterdata_test.json
|
||||
../flatc --binary --schema monster_test.fbs
|
||||
=======
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2015 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
../flatc --cpp --java --csharp --go --binary --python --js --php --grpc --gen-mutable --no-includes monster_test.fbs monsterdata_test.json
|
||||
../flatc --cpp --java --csharp --go --binary --python --js --php --gen-mutable -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs
|
||||
../flatc --binary --schema monster_test.fbs
|
||||
|
||||
>>>>>>> 48f37f9e0a04f2b60046dda7fef20a8b0ebc1a70
|
||||
|
||||
@@ -2,17 +2,21 @@
|
||||
|
||||
include "include_test1.fbs";
|
||||
|
||||
namespace MyGame.Example2;
|
||||
|
||||
table Monster {} // Test having same name as below, but in different namespace.
|
||||
|
||||
namespace MyGame.Example;
|
||||
|
||||
attribute "priority";
|
||||
|
||||
enum Color:byte (bit_flags) { Red = 0, Green, Blue = 3, }
|
||||
|
||||
union Any { Monster, TestSimpleTableWithEnum } // TODO: add more elements
|
||||
union Any { Monster, TestSimpleTableWithEnum, MyGame.Example2.Monster }
|
||||
|
||||
struct Test { a:short; b:byte; }
|
||||
|
||||
table TestSimpleTableWithEnum {
|
||||
table TestSimpleTableWithEnum (csharp_partial) {
|
||||
color: Color = Green;
|
||||
}
|
||||
|
||||
@@ -44,6 +48,7 @@ table Monster {
|
||||
/// multiline too
|
||||
testarrayoftables:[Monster] (id: 11);
|
||||
testarrayofstring:[string] (id: 10);
|
||||
testarrayofstring2:[string] (id: 28);
|
||||
testarrayofbools:[bool] (id: 24);
|
||||
enemy:MyGame.Example.Monster (id:12); // Test referring by full namespace.
|
||||
test:Any (id: 8);
|
||||
@@ -59,6 +64,14 @@ table Monster {
|
||||
testhashu32_fnv1a:uint (id:21, hash:"fnv1a_32");
|
||||
testhashs64_fnv1a:long (id:22, hash:"fnv1a_64");
|
||||
testhashu64_fnv1a:ulong (id:23, hash:"fnv1a_64");
|
||||
testf:float = 3.14159 (id:25);
|
||||
testf2:float = 3 (id:26);
|
||||
testf3:float (id:27);
|
||||
}
|
||||
|
||||
rpc_service MonsterStorage {
|
||||
Store(Monster):Stat (streaming: "none");
|
||||
Retrieve(Stat):Monster (idempotent);
|
||||
}
|
||||
|
||||
root_type Monster;
|
||||
|
||||
85
tests/monster_test.grpc.fb.cc
Normal file
85
tests/monster_test.grpc.fb.cc
Normal file
@@ -0,0 +1,85 @@
|
||||
// Generated by the gRPC protobuf plugin.
|
||||
// If you make any local change, they will be lost.
|
||||
// source: monster_test
|
||||
|
||||
#include "monster_test_generated.h"
|
||||
#include "monster_test.grpc.fb.h"
|
||||
#include "flatbuffers/grpc.h"
|
||||
|
||||
#include <grpc++/impl/codegen/async_stream.h>
|
||||
#include <grpc++/impl/codegen/async_unary_call.h>
|
||||
#include <grpc++/impl/codegen/channel_interface.h>
|
||||
#include <grpc++/impl/codegen/client_unary_call.h>
|
||||
#include <grpc++/impl/codegen/method_handler_impl.h>
|
||||
#include <grpc++/impl/codegen/rpc_service_method.h>
|
||||
#include <grpc++/impl/codegen/service_type.h>
|
||||
#include <grpc++/impl/codegen/sync_stream.h>
|
||||
namespace MyGame {
|
||||
namespace Example {
|
||||
|
||||
static const char* MonsterStorage_method_names[] = {
|
||||
"/MyGame.Example..MonsterStorage/Store",
|
||||
"/MyGame.Example..MonsterStorage/Retrieve",
|
||||
};
|
||||
|
||||
std::unique_ptr< MonsterStorage::Stub> MonsterStorage::NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options) {
|
||||
std::unique_ptr< MonsterStorage::Stub> stub(new MonsterStorage::Stub(channel));
|
||||
return stub;
|
||||
}
|
||||
|
||||
MonsterStorage::Stub::Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel)
|
||||
: channel_(channel) , rpcmethod_Store_(MonsterStorage_method_names[0], ::grpc::RpcMethod::NORMAL_RPC, channel)
|
||||
, rpcmethod_Retrieve_(MonsterStorage_method_names[1], ::grpc::RpcMethod::NORMAL_RPC, channel)
|
||||
{}
|
||||
|
||||
::grpc::Status MonsterStorage::Stub::Store(::grpc::ClientContext* context, const flatbuffers::BufferRef<Monster>& request, flatbuffers::BufferRef<Stat>* response) {
|
||||
return ::grpc::BlockingUnaryCall(channel_.get(), rpcmethod_Store_, context, request, response);
|
||||
}
|
||||
|
||||
::grpc::ClientAsyncResponseReader< flatbuffers::BufferRef<Stat>>* MonsterStorage::Stub::AsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::BufferRef<Monster>& request, ::grpc::CompletionQueue* cq) {
|
||||
return new ::grpc::ClientAsyncResponseReader< flatbuffers::BufferRef<Stat>>(channel_.get(), cq, rpcmethod_Store_, context, request);
|
||||
}
|
||||
|
||||
::grpc::Status MonsterStorage::Stub::Retrieve(::grpc::ClientContext* context, const flatbuffers::BufferRef<Stat>& request, flatbuffers::BufferRef<Monster>* response) {
|
||||
return ::grpc::BlockingUnaryCall(channel_.get(), rpcmethod_Retrieve_, context, request, response);
|
||||
}
|
||||
|
||||
::grpc::ClientAsyncResponseReader< flatbuffers::BufferRef<Monster>>* MonsterStorage::Stub::AsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::BufferRef<Stat>& request, ::grpc::CompletionQueue* cq) {
|
||||
return new ::grpc::ClientAsyncResponseReader< flatbuffers::BufferRef<Monster>>(channel_.get(), cq, rpcmethod_Retrieve_, context, request);
|
||||
}
|
||||
|
||||
MonsterStorage::Service::Service() {
|
||||
(void)MonsterStorage_method_names;
|
||||
AddMethod(new ::grpc::RpcServiceMethod(
|
||||
MonsterStorage_method_names[0],
|
||||
::grpc::RpcMethod::NORMAL_RPC,
|
||||
new ::grpc::RpcMethodHandler< MonsterStorage::Service, flatbuffers::BufferRef<Monster>, flatbuffers::BufferRef<Stat>>(
|
||||
std::mem_fn(&MonsterStorage::Service::Store), this)));
|
||||
AddMethod(new ::grpc::RpcServiceMethod(
|
||||
MonsterStorage_method_names[1],
|
||||
::grpc::RpcMethod::NORMAL_RPC,
|
||||
new ::grpc::RpcMethodHandler< MonsterStorage::Service, flatbuffers::BufferRef<Stat>, flatbuffers::BufferRef<Monster>>(
|
||||
std::mem_fn(&MonsterStorage::Service::Retrieve), this)));
|
||||
}
|
||||
|
||||
MonsterStorage::Service::~Service() {
|
||||
}
|
||||
|
||||
::grpc::Status MonsterStorage::Service::Store(::grpc::ServerContext* context, const flatbuffers::BufferRef<Monster>* request, flatbuffers::BufferRef<Stat>* response) {
|
||||
(void) context;
|
||||
(void) request;
|
||||
(void) response;
|
||||
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
|
||||
}
|
||||
|
||||
::grpc::Status MonsterStorage::Service::Retrieve(::grpc::ServerContext* context, const flatbuffers::BufferRef<Stat>* request, flatbuffers::BufferRef<Monster>* response) {
|
||||
(void) context;
|
||||
(void) request;
|
||||
(void) response;
|
||||
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
|
||||
}
|
||||
|
||||
|
||||
} // namespace MyGame
|
||||
} // namespace Example
|
||||
|
||||
155
tests/monster_test.grpc.fb.h
Normal file
155
tests/monster_test.grpc.fb.h
Normal file
@@ -0,0 +1,155 @@
|
||||
// Generated by the gRPC protobuf plugin.
|
||||
// If you make any local change, they will be lost.
|
||||
// source: monster_test
|
||||
#ifndef GRPC_monster_5ftest__INCLUDED
|
||||
#define GRPC_monster_5ftest__INCLUDED
|
||||
|
||||
#include "monster_test_generated.h"
|
||||
|
||||
#include <grpc++/impl/codegen/async_stream.h>
|
||||
#include <grpc++/impl/codegen/async_unary_call.h>
|
||||
#include <grpc++/impl/codegen/proto_utils.h>
|
||||
#include <grpc++/impl/codegen/rpc_method.h>
|
||||
#include <grpc++/impl/codegen/service_type.h>
|
||||
#include <grpc++/impl/codegen/status.h>
|
||||
#include <grpc++/impl/codegen/stub_options.h>
|
||||
#include <grpc++/impl/codegen/sync_stream.h>
|
||||
|
||||
namespace grpc {
|
||||
class CompletionQueue;
|
||||
class Channel;
|
||||
class RpcService;
|
||||
class ServerCompletionQueue;
|
||||
class ServerContext;
|
||||
} // namespace grpc
|
||||
|
||||
namespace MyGame {
|
||||
namespace Example {
|
||||
|
||||
class MonsterStorage GRPC_FINAL {
|
||||
public:
|
||||
class StubInterface {
|
||||
public:
|
||||
virtual ~StubInterface() {}
|
||||
virtual ::grpc::Status Store(::grpc::ClientContext* context, const flatbuffers::BufferRef<Monster>& request, flatbuffers::BufferRef<Stat>* response) = 0;
|
||||
std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::BufferRef<Stat>>> AsyncStore(::grpc::ClientContext* context, const flatbuffers::BufferRef<Monster>& request, ::grpc::CompletionQueue* cq) {
|
||||
return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::BufferRef<Stat>>>(AsyncStoreRaw(context, request, cq));
|
||||
}
|
||||
virtual ::grpc::Status Retrieve(::grpc::ClientContext* context, const flatbuffers::BufferRef<Stat>& request, flatbuffers::BufferRef<Monster>* response) = 0;
|
||||
std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::BufferRef<Monster>>> AsyncRetrieve(::grpc::ClientContext* context, const flatbuffers::BufferRef<Stat>& request, ::grpc::CompletionQueue* cq) {
|
||||
return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::BufferRef<Monster>>>(AsyncRetrieveRaw(context, request, cq));
|
||||
}
|
||||
private:
|
||||
virtual ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::BufferRef<Stat>>* AsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::BufferRef<Monster>& request, ::grpc::CompletionQueue* cq) = 0;
|
||||
virtual ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::BufferRef<Monster>>* AsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::BufferRef<Stat>& request, ::grpc::CompletionQueue* cq) = 0;
|
||||
};
|
||||
class Stub GRPC_FINAL : public StubInterface {
|
||||
public:
|
||||
Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel);
|
||||
::grpc::Status Store(::grpc::ClientContext* context, const flatbuffers::BufferRef<Monster>& request, flatbuffers::BufferRef<Stat>* response) GRPC_OVERRIDE;
|
||||
std::unique_ptr< ::grpc::ClientAsyncResponseReader< flatbuffers::BufferRef<Stat>>> AsyncStore(::grpc::ClientContext* context, const flatbuffers::BufferRef<Monster>& request, ::grpc::CompletionQueue* cq) {
|
||||
return std::unique_ptr< ::grpc::ClientAsyncResponseReader< flatbuffers::BufferRef<Stat>>>(AsyncStoreRaw(context, request, cq));
|
||||
}
|
||||
::grpc::Status Retrieve(::grpc::ClientContext* context, const flatbuffers::BufferRef<Stat>& request, flatbuffers::BufferRef<Monster>* response) GRPC_OVERRIDE;
|
||||
std::unique_ptr< ::grpc::ClientAsyncResponseReader< flatbuffers::BufferRef<Monster>>> AsyncRetrieve(::grpc::ClientContext* context, const flatbuffers::BufferRef<Stat>& request, ::grpc::CompletionQueue* cq) {
|
||||
return std::unique_ptr< ::grpc::ClientAsyncResponseReader< flatbuffers::BufferRef<Monster>>>(AsyncRetrieveRaw(context, request, cq));
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr< ::grpc::ChannelInterface> channel_;
|
||||
::grpc::ClientAsyncResponseReader< flatbuffers::BufferRef<Stat>>* AsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::BufferRef<Monster>& request, ::grpc::CompletionQueue* cq) GRPC_OVERRIDE;
|
||||
::grpc::ClientAsyncResponseReader< flatbuffers::BufferRef<Monster>>* AsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::BufferRef<Stat>& request, ::grpc::CompletionQueue* cq) GRPC_OVERRIDE;
|
||||
const ::grpc::RpcMethod rpcmethod_Store_;
|
||||
const ::grpc::RpcMethod rpcmethod_Retrieve_;
|
||||
};
|
||||
static std::unique_ptr<Stub> NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options = ::grpc::StubOptions());
|
||||
|
||||
class Service : public ::grpc::Service {
|
||||
public:
|
||||
Service();
|
||||
virtual ~Service();
|
||||
virtual ::grpc::Status Store(::grpc::ServerContext* context, const flatbuffers::BufferRef<Monster>* request, flatbuffers::BufferRef<Stat>* response);
|
||||
virtual ::grpc::Status Retrieve(::grpc::ServerContext* context, const flatbuffers::BufferRef<Stat>* request, flatbuffers::BufferRef<Monster>* response);
|
||||
};
|
||||
template <class BaseClass>
|
||||
class WithAsyncMethod_Store : public BaseClass {
|
||||
private:
|
||||
void BaseClassMustBeDerivedFromService(const Service *service) {}
|
||||
public:
|
||||
WithAsyncMethod_Store() {
|
||||
::grpc::Service::MarkMethodAsync(0);
|
||||
}
|
||||
~WithAsyncMethod_Store() GRPC_OVERRIDE {
|
||||
BaseClassMustBeDerivedFromService(this);
|
||||
}
|
||||
// disable synchronous version of this method
|
||||
::grpc::Status Store(::grpc::ServerContext* context, const flatbuffers::BufferRef<Monster>* request, flatbuffers::BufferRef<Stat>* response) GRPC_FINAL GRPC_OVERRIDE {
|
||||
abort();
|
||||
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
|
||||
}
|
||||
void RequestStore(::grpc::ServerContext* context, flatbuffers::BufferRef<Monster>* request, ::grpc::ServerAsyncResponseWriter< flatbuffers::BufferRef<Stat>>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
|
||||
::grpc::Service::RequestAsyncUnary(0, context, request, response, new_call_cq, notification_cq, tag);
|
||||
}
|
||||
};
|
||||
template <class BaseClass>
|
||||
class WithAsyncMethod_Retrieve : public BaseClass {
|
||||
private:
|
||||
void BaseClassMustBeDerivedFromService(const Service *service) {}
|
||||
public:
|
||||
WithAsyncMethod_Retrieve() {
|
||||
::grpc::Service::MarkMethodAsync(1);
|
||||
}
|
||||
~WithAsyncMethod_Retrieve() GRPC_OVERRIDE {
|
||||
BaseClassMustBeDerivedFromService(this);
|
||||
}
|
||||
// disable synchronous version of this method
|
||||
::grpc::Status Retrieve(::grpc::ServerContext* context, const flatbuffers::BufferRef<Stat>* request, flatbuffers::BufferRef<Monster>* response) GRPC_FINAL GRPC_OVERRIDE {
|
||||
abort();
|
||||
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
|
||||
}
|
||||
void RequestRetrieve(::grpc::ServerContext* context, flatbuffers::BufferRef<Stat>* request, ::grpc::ServerAsyncResponseWriter< flatbuffers::BufferRef<Monster>>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
|
||||
::grpc::Service::RequestAsyncUnary(1, context, request, response, new_call_cq, notification_cq, tag);
|
||||
}
|
||||
};
|
||||
typedef WithAsyncMethod_Store< WithAsyncMethod_Retrieve< Service > > AsyncService;
|
||||
template <class BaseClass>
|
||||
class WithGenericMethod_Store : public BaseClass {
|
||||
private:
|
||||
void BaseClassMustBeDerivedFromService(const Service *service) {}
|
||||
public:
|
||||
WithGenericMethod_Store() {
|
||||
::grpc::Service::MarkMethodGeneric(0);
|
||||
}
|
||||
~WithGenericMethod_Store() GRPC_OVERRIDE {
|
||||
BaseClassMustBeDerivedFromService(this);
|
||||
}
|
||||
// disable synchronous version of this method
|
||||
::grpc::Status Store(::grpc::ServerContext* context, const flatbuffers::BufferRef<Monster>* request, flatbuffers::BufferRef<Stat>* response) GRPC_FINAL GRPC_OVERRIDE {
|
||||
abort();
|
||||
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
|
||||
}
|
||||
};
|
||||
template <class BaseClass>
|
||||
class WithGenericMethod_Retrieve : public BaseClass {
|
||||
private:
|
||||
void BaseClassMustBeDerivedFromService(const Service *service) {}
|
||||
public:
|
||||
WithGenericMethod_Retrieve() {
|
||||
::grpc::Service::MarkMethodGeneric(1);
|
||||
}
|
||||
~WithGenericMethod_Retrieve() GRPC_OVERRIDE {
|
||||
BaseClassMustBeDerivedFromService(this);
|
||||
}
|
||||
// disable synchronous version of this method
|
||||
::grpc::Status Retrieve(::grpc::ServerContext* context, const flatbuffers::BufferRef<Stat>* request, flatbuffers::BufferRef<Monster>* response) GRPC_FINAL GRPC_OVERRIDE {
|
||||
abort();
|
||||
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace Example
|
||||
} // namespace MyGame
|
||||
|
||||
|
||||
#endif // GRPC_monster_5ftest__INCLUDED
|
||||
@@ -6,24 +6,30 @@
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
|
||||
namespace MyGame {
|
||||
namespace OtherNameSpace {
|
||||
struct Unused;
|
||||
} // namespace OtherNameSpace
|
||||
} // namespace MyGame
|
||||
namespace Example2 {
|
||||
|
||||
struct Monster;
|
||||
|
||||
} // namespace Example2
|
||||
|
||||
namespace MyGame {
|
||||
namespace Example {
|
||||
|
||||
struct Test;
|
||||
|
||||
struct TestSimpleTableWithEnum;
|
||||
|
||||
struct Vec3;
|
||||
|
||||
struct Stat;
|
||||
|
||||
struct Monster;
|
||||
|
||||
enum Color {
|
||||
Color_Red = 1,
|
||||
Color_Green = 2,
|
||||
Color_Blue = 8
|
||||
Color_Blue = 8,
|
||||
Color_NONE = 0,
|
||||
Color_ANY = 11
|
||||
};
|
||||
|
||||
inline const char **EnumNamesColor() {
|
||||
@@ -36,11 +42,14 @@ inline const char *EnumNameColor(Color e) { return EnumNamesColor()[static_cast<
|
||||
enum Any {
|
||||
Any_NONE = 0,
|
||||
Any_Monster = 1,
|
||||
Any_TestSimpleTableWithEnum = 2
|
||||
Any_TestSimpleTableWithEnum = 2,
|
||||
Any_MyGame_Example2_Monster = 3,
|
||||
Any_MIN = Any_NONE,
|
||||
Any_MAX = Any_MyGame_Example2_Monster
|
||||
};
|
||||
|
||||
inline const char **EnumNamesAny() {
|
||||
static const char *names[] = { "NONE", "Monster", "TestSimpleTableWithEnum", nullptr };
|
||||
static const char *names[] = { "NONE", "Monster", "TestSimpleTableWithEnum", "MyGame_Example2_Monster", nullptr };
|
||||
return names;
|
||||
}
|
||||
|
||||
@@ -96,9 +105,44 @@ MANUALLY_ALIGNED_STRUCT(16) Vec3 FLATBUFFERS_FINAL_CLASS {
|
||||
};
|
||||
STRUCT_END(Vec3, 32);
|
||||
|
||||
} // namespace Example
|
||||
|
||||
namespace Example2 {
|
||||
|
||||
struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct MonsterBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
MonsterBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
MonsterBuilder &operator=(const MonsterBuilder &);
|
||||
flatbuffers::Offset<Monster> Finish() {
|
||||
auto o = flatbuffers::Offset<Monster>(fbb_.EndTable(start_, 0));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder &_fbb) {
|
||||
MonsterBuilder builder_(_fbb);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
} // namespace Example2
|
||||
|
||||
namespace Example {
|
||||
|
||||
struct TestSimpleTableWithEnum FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
enum {
|
||||
<<<<<<< HEAD
|
||||
VT_COLOR = 4,
|
||||
=======
|
||||
VT_COLOR = 4
|
||||
>>>>>>> 48f37f9e0a04f2b60046dda7fef20a8b0ebc1a70
|
||||
};
|
||||
Color color() const { return static_cast<Color>(GetField<int8_t>(VT_COLOR, 2)); }
|
||||
bool mutate_color(Color _color) { return SetField(VT_COLOR, static_cast<int8_t>(_color)); }
|
||||
@@ -132,7 +176,11 @@ struct Stat FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
enum {
|
||||
VT_ID = 4,
|
||||
VT_VAL = 6,
|
||||
<<<<<<< HEAD
|
||||
VT_COUNT = 8,
|
||||
=======
|
||||
VT_COUNT = 8
|
||||
>>>>>>> 48f37f9e0a04f2b60046dda7fef20a8b0ebc1a70
|
||||
};
|
||||
const flatbuffers::String *id() const { return GetPointer<const flatbuffers::String *>(VT_ID); }
|
||||
flatbuffers::String *mutable_id() { return GetPointer<flatbuffers::String *>(VT_ID); }
|
||||
@@ -202,6 +250,13 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
VT_TESTHASHS64_FNV1A = 48,
|
||||
VT_TESTHASHU64_FNV1A = 50,
|
||||
VT_TESTARRAYOFBOOLS = 52,
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
VT_TESTF = 54,
|
||||
VT_TESTF2 = 56,
|
||||
VT_TESTF3 = 58,
|
||||
VT_TESTARRAYOFSTRING2 = 60
|
||||
>>>>>>> 48f37f9e0a04f2b60046dda7fef20a8b0ebc1a70
|
||||
};
|
||||
const Vec3 *pos() const { return GetStruct<const Vec3 *>(VT_POS); }
|
||||
Vec3 *mutable_pos() { return GetStruct<Vec3 *>(VT_POS); }
|
||||
@@ -236,7 +291,11 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
const MyGame::Example::Monster *testnestedflatbuffer_nested_root() const { return flatbuffers::GetRoot<MyGame::Example::Monster>(testnestedflatbuffer()->Data()); }
|
||||
const Stat *testempty() const { return GetPointer<const Stat *>(VT_TESTEMPTY); }
|
||||
Stat *mutable_testempty() { return GetPointer<Stat *>(VT_TESTEMPTY); }
|
||||
<<<<<<< HEAD
|
||||
bool testbool() const { return static_cast<bool>(GetField<uint8_t>(VT_TESTBOOL, 0)); }
|
||||
=======
|
||||
bool testbool() const { return GetField<uint8_t>(VT_TESTBOOL, 0) != 0; }
|
||||
>>>>>>> 48f37f9e0a04f2b60046dda7fef20a8b0ebc1a70
|
||||
bool mutate_testbool(bool _testbool) { return SetField(VT_TESTBOOL, static_cast<uint8_t>(_testbool)); }
|
||||
int32_t testhashs32_fnv1() const { return GetField<int32_t>(VT_TESTHASHS32_FNV1, 0); }
|
||||
bool mutate_testhashs32_fnv1(int32_t _testhashs32_fnv1) { return SetField(VT_TESTHASHS32_FNV1, _testhashs32_fnv1); }
|
||||
@@ -256,6 +315,17 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
bool mutate_testhashu64_fnv1a(uint64_t _testhashu64_fnv1a) { return SetField(VT_TESTHASHU64_FNV1A, _testhashu64_fnv1a); }
|
||||
const flatbuffers::Vector<uint8_t> *testarrayofbools() const { return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_TESTARRAYOFBOOLS); }
|
||||
flatbuffers::Vector<uint8_t> *mutable_testarrayofbools() { return GetPointer<flatbuffers::Vector<uint8_t> *>(VT_TESTARRAYOFBOOLS); }
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
float testf() const { return GetField<float>(VT_TESTF, 3.14159f); }
|
||||
bool mutate_testf(float _testf) { return SetField(VT_TESTF, _testf); }
|
||||
float testf2() const { return GetField<float>(VT_TESTF2, 3.0f); }
|
||||
bool mutate_testf2(float _testf2) { return SetField(VT_TESTF2, _testf2); }
|
||||
float testf3() const { return GetField<float>(VT_TESTF3, 0.0f); }
|
||||
bool mutate_testf3(float _testf3) { return SetField(VT_TESTF3, _testf3); }
|
||||
const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *testarrayofstring2() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_TESTARRAYOFSTRING2); }
|
||||
flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *mutable_testarrayofstring2() { return GetPointer<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(VT_TESTARRAYOFSTRING2); }
|
||||
>>>>>>> 48f37f9e0a04f2b60046dda7fef20a8b0ebc1a70
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<Vec3>(verifier, VT_POS) &&
|
||||
@@ -294,6 +364,12 @@ struct Monster FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
VerifyField<uint64_t>(verifier, VT_TESTHASHU64_FNV1A) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, VT_TESTARRAYOFBOOLS) &&
|
||||
verifier.Verify(testarrayofbools()) &&
|
||||
VerifyField<float>(verifier, VT_TESTF) &&
|
||||
VerifyField<float>(verifier, VT_TESTF2) &&
|
||||
VerifyField<float>(verifier, VT_TESTF3) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, VT_TESTARRAYOFSTRING2) &&
|
||||
verifier.Verify(testarrayofstring2()) &&
|
||||
verifier.VerifyVectorOfStrings(testarrayofstring2()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
@@ -325,10 +401,21 @@ struct MonsterBuilder {
|
||||
void add_testhashs64_fnv1a(int64_t testhashs64_fnv1a) { fbb_.AddElement<int64_t>(Monster::VT_TESTHASHS64_FNV1A, testhashs64_fnv1a, 0); }
|
||||
void add_testhashu64_fnv1a(uint64_t testhashu64_fnv1a) { fbb_.AddElement<uint64_t>(Monster::VT_TESTHASHU64_FNV1A, testhashu64_fnv1a, 0); }
|
||||
void add_testarrayofbools(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testarrayofbools) { fbb_.AddOffset(Monster::VT_TESTARRAYOFBOOLS, testarrayofbools); }
|
||||
<<<<<<< HEAD
|
||||
MonsterBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
MonsterBuilder &operator=(const MonsterBuilder &);
|
||||
flatbuffers::Offset<Monster> Finish() {
|
||||
auto o = flatbuffers::Offset<Monster>(fbb_.EndTable(start_, 25));
|
||||
=======
|
||||
void add_testf(float testf) { fbb_.AddElement<float>(Monster::VT_TESTF, testf, 3.14159f); }
|
||||
void add_testf2(float testf2) { fbb_.AddElement<float>(Monster::VT_TESTF2, testf2, 3.0f); }
|
||||
void add_testf3(float testf3) { fbb_.AddElement<float>(Monster::VT_TESTF3, testf3, 0.0f); }
|
||||
void add_testarrayofstring2(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> testarrayofstring2) { fbb_.AddOffset(Monster::VT_TESTARRAYOFSTRING2, testarrayofstring2); }
|
||||
MonsterBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
MonsterBuilder &operator=(const MonsterBuilder &);
|
||||
flatbuffers::Offset<Monster> Finish() {
|
||||
auto o = flatbuffers::Offset<Monster>(fbb_.EndTable(start_, 29));
|
||||
>>>>>>> 48f37f9e0a04f2b60046dda7fef20a8b0ebc1a70
|
||||
fbb_.Required(o, Monster::VT_NAME); // name
|
||||
return o;
|
||||
}
|
||||
@@ -358,12 +445,20 @@ inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder
|
||||
uint32_t testhashu32_fnv1a = 0,
|
||||
int64_t testhashs64_fnv1a = 0,
|
||||
uint64_t testhashu64_fnv1a = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testarrayofbools = 0) {
|
||||
flatbuffers::Offset<flatbuffers::Vector<uint8_t>> testarrayofbools = 0,
|
||||
float testf = 3.14159f,
|
||||
float testf2 = 3.0f,
|
||||
float testf3 = 0.0f,
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> testarrayofstring2 = 0) {
|
||||
MonsterBuilder builder_(_fbb);
|
||||
builder_.add_testhashu64_fnv1a(testhashu64_fnv1a);
|
||||
builder_.add_testhashs64_fnv1a(testhashs64_fnv1a);
|
||||
builder_.add_testhashu64_fnv1(testhashu64_fnv1);
|
||||
builder_.add_testhashs64_fnv1(testhashs64_fnv1);
|
||||
builder_.add_testarrayofstring2(testarrayofstring2);
|
||||
builder_.add_testf3(testf3);
|
||||
builder_.add_testf2(testf2);
|
||||
builder_.add_testf(testf);
|
||||
builder_.add_testarrayofbools(testarrayofbools);
|
||||
builder_.add_testhashu32_fnv1a(testhashu32_fnv1a);
|
||||
builder_.add_testhashs32_fnv1a(testhashs32_fnv1a);
|
||||
@@ -392,6 +487,7 @@ inline bool VerifyAny(flatbuffers::Verifier &verifier, const void *union_obj, An
|
||||
case Any_NONE: return true;
|
||||
case Any_Monster: return verifier.VerifyTable(reinterpret_cast<const Monster *>(union_obj));
|
||||
case Any_TestSimpleTableWithEnum: return verifier.VerifyTable(reinterpret_cast<const TestSimpleTableWithEnum *>(union_obj));
|
||||
case Any_MyGame_Example2_Monster: return verifier.VerifyTable(reinterpret_cast<const MyGame::Example2::Monster *>(union_obj));
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,11 @@ var MyGame = MyGame || {};
|
||||
*/
|
||||
MyGame.Example = MyGame.Example || {};
|
||||
|
||||
/**
|
||||
* @const
|
||||
*/
|
||||
MyGame.Example2 = MyGame.Example2 || {};
|
||||
|
||||
/**
|
||||
* @const
|
||||
*/
|
||||
@@ -30,7 +35,59 @@ MyGame.Example.Color = {
|
||||
MyGame.Example.Any = {
|
||||
NONE: 0,
|
||||
Monster: 1,
|
||||
TestSimpleTableWithEnum: 2
|
||||
TestSimpleTableWithEnum: 2,
|
||||
MyGame_Example2_Monster: 3
|
||||
};
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
MyGame.Example2.Monster = function() {
|
||||
/**
|
||||
* @type {flatbuffers.ByteBuffer}
|
||||
*/
|
||||
this.bb = null;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.bb_pos = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} i
|
||||
* @param {flatbuffers.ByteBuffer} bb
|
||||
* @returns {MyGame.Example2.Monster}
|
||||
*/
|
||||
MyGame.Example2.Monster.prototype.__init = function(i, bb) {
|
||||
this.bb_pos = i;
|
||||
this.bb = bb;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.ByteBuffer} bb
|
||||
* @param {MyGame.Example2.Monster=} obj
|
||||
* @returns {MyGame.Example2.Monster}
|
||||
*/
|
||||
MyGame.Example2.Monster.getRootAsMonster = function(bb, obj) {
|
||||
return (obj || new MyGame.Example2.Monster).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
*/
|
||||
MyGame.Example2.Monster.startMonster = function(builder) {
|
||||
builder.startObject(0);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @returns {flatbuffers.Offset}
|
||||
*/
|
||||
MyGame.Example2.Monster.endMonster = function(builder) {
|
||||
var offset = builder.endObject();
|
||||
return offset;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -300,7 +357,7 @@ MyGame.Example.Stat.prototype.id = function(optionalEncoding) {
|
||||
*/
|
||||
MyGame.Example.Stat.prototype.val = function() {
|
||||
var offset = this.bb.__offset(this.bb_pos, 6);
|
||||
return offset ? this.bb.readInt64(this.bb_pos + offset) : flatbuffers.Long.ZERO;
|
||||
return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -331,7 +388,7 @@ MyGame.Example.Stat.addId = function(builder, idOffset) {
|
||||
* @param {flatbuffers.Long} val
|
||||
*/
|
||||
MyGame.Example.Stat.addVal = function(builder, val) {
|
||||
builder.addFieldInt64(1, val, flatbuffers.Long.ZERO);
|
||||
builder.addFieldInt64(1, val, builder.createLong(0, 0));
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -447,6 +504,14 @@ MyGame.Example.Monster.prototype.inventoryLength = function() {
|
||||
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
MyGame.Example.Monster.prototype.inventoryArray = function() {
|
||||
var offset = this.bb.__offset(this.bb_pos, 14);
|
||||
return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {MyGame.Example.Color}
|
||||
*/
|
||||
@@ -555,6 +620,14 @@ MyGame.Example.Monster.prototype.testnestedflatbufferLength = function() {
|
||||
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
MyGame.Example.Monster.prototype.testnestedflatbufferArray = function() {
|
||||
var offset = this.bb.__offset(this.bb_pos, 30);
|
||||
return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {MyGame.Example.Stat=} obj
|
||||
* @returns {MyGame.Example.Stat}
|
||||
@@ -593,7 +666,7 @@ MyGame.Example.Monster.prototype.testhashu32Fnv1 = function() {
|
||||
*/
|
||||
MyGame.Example.Monster.prototype.testhashs64Fnv1 = function() {
|
||||
var offset = this.bb.__offset(this.bb_pos, 40);
|
||||
return offset ? this.bb.readInt64(this.bb_pos + offset) : flatbuffers.Long.ZERO;
|
||||
return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -601,7 +674,7 @@ MyGame.Example.Monster.prototype.testhashs64Fnv1 = function() {
|
||||
*/
|
||||
MyGame.Example.Monster.prototype.testhashu64Fnv1 = function() {
|
||||
var offset = this.bb.__offset(this.bb_pos, 42);
|
||||
return offset ? this.bb.readUint64(this.bb_pos + offset) : flatbuffers.Long.ZERO;
|
||||
return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -625,7 +698,7 @@ MyGame.Example.Monster.prototype.testhashu32Fnv1a = function() {
|
||||
*/
|
||||
MyGame.Example.Monster.prototype.testhashs64Fnv1a = function() {
|
||||
var offset = this.bb.__offset(this.bb_pos, 48);
|
||||
return offset ? this.bb.readInt64(this.bb_pos + offset) : flatbuffers.Long.ZERO;
|
||||
return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -633,7 +706,7 @@ MyGame.Example.Monster.prototype.testhashs64Fnv1a = function() {
|
||||
*/
|
||||
MyGame.Example.Monster.prototype.testhashu64Fnv1a = function() {
|
||||
var offset = this.bb.__offset(this.bb_pos, 50);
|
||||
return offset ? this.bb.readUint64(this.bb_pos + offset) : flatbuffers.Long.ZERO;
|
||||
return offset ? this.bb.readUint64(this.bb_pos + offset) : this.bb.createLong(0, 0);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -653,11 +726,61 @@ MyGame.Example.Monster.prototype.testarrayofboolsLength = function() {
|
||||
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {Int8Array}
|
||||
*/
|
||||
MyGame.Example.Monster.prototype.testarrayofboolsArray = function() {
|
||||
var offset = this.bb.__offset(this.bb_pos, 52);
|
||||
return offset ? new Int8Array(this.bb.bytes().buffer, this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {number}
|
||||
*/
|
||||
MyGame.Example.Monster.prototype.testf = function() {
|
||||
var offset = this.bb.__offset(this.bb_pos, 54);
|
||||
return offset ? this.bb.readFloat32(this.bb_pos + offset) : 3.14159;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {number}
|
||||
*/
|
||||
MyGame.Example.Monster.prototype.testf2 = function() {
|
||||
var offset = this.bb.__offset(this.bb_pos, 56);
|
||||
return offset ? this.bb.readFloat32(this.bb_pos + offset) : 3.0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {number}
|
||||
*/
|
||||
MyGame.Example.Monster.prototype.testf3 = function() {
|
||||
var offset = this.bb.__offset(this.bb_pos, 58);
|
||||
return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} index
|
||||
* @param {flatbuffers.Encoding=} optionalEncoding
|
||||
* @returns {string|Uint8Array}
|
||||
*/
|
||||
MyGame.Example.Monster.prototype.testarrayofstring2 = function(index, optionalEncoding) {
|
||||
var offset = this.bb.__offset(this.bb_pos, 60);
|
||||
return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {number}
|
||||
*/
|
||||
MyGame.Example.Monster.prototype.testarrayofstring2Length = function() {
|
||||
var offset = this.bb.__offset(this.bb_pos, 60);
|
||||
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
*/
|
||||
MyGame.Example.Monster.startMonster = function(builder) {
|
||||
builder.startObject(25);
|
||||
builder.startObject(29);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -893,7 +1016,7 @@ MyGame.Example.Monster.addTesthashu32Fnv1 = function(builder, testhashu32Fnv1) {
|
||||
* @param {flatbuffers.Long} testhashs64Fnv1
|
||||
*/
|
||||
MyGame.Example.Monster.addTesthashs64Fnv1 = function(builder, testhashs64Fnv1) {
|
||||
builder.addFieldInt64(18, testhashs64Fnv1, flatbuffers.Long.ZERO);
|
||||
builder.addFieldInt64(18, testhashs64Fnv1, builder.createLong(0, 0));
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -901,7 +1024,7 @@ MyGame.Example.Monster.addTesthashs64Fnv1 = function(builder, testhashs64Fnv1) {
|
||||
* @param {flatbuffers.Long} testhashu64Fnv1
|
||||
*/
|
||||
MyGame.Example.Monster.addTesthashu64Fnv1 = function(builder, testhashu64Fnv1) {
|
||||
builder.addFieldInt64(19, testhashu64Fnv1, flatbuffers.Long.ZERO);
|
||||
builder.addFieldInt64(19, testhashu64Fnv1, builder.createLong(0, 0));
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -925,7 +1048,7 @@ MyGame.Example.Monster.addTesthashu32Fnv1a = function(builder, testhashu32Fnv1a)
|
||||
* @param {flatbuffers.Long} testhashs64Fnv1a
|
||||
*/
|
||||
MyGame.Example.Monster.addTesthashs64Fnv1a = function(builder, testhashs64Fnv1a) {
|
||||
builder.addFieldInt64(22, testhashs64Fnv1a, flatbuffers.Long.ZERO);
|
||||
builder.addFieldInt64(22, testhashs64Fnv1a, builder.createLong(0, 0));
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -933,7 +1056,7 @@ MyGame.Example.Monster.addTesthashs64Fnv1a = function(builder, testhashs64Fnv1a)
|
||||
* @param {flatbuffers.Long} testhashu64Fnv1a
|
||||
*/
|
||||
MyGame.Example.Monster.addTesthashu64Fnv1a = function(builder, testhashu64Fnv1a) {
|
||||
builder.addFieldInt64(23, testhashu64Fnv1a, flatbuffers.Long.ZERO);
|
||||
builder.addFieldInt64(23, testhashu64Fnv1a, builder.createLong(0, 0));
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -965,6 +1088,59 @@ MyGame.Example.Monster.startTestarrayofboolsVector = function(builder, numElems)
|
||||
builder.startVector(1, numElems, 1);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {number} testf
|
||||
*/
|
||||
MyGame.Example.Monster.addTestf = function(builder, testf) {
|
||||
builder.addFieldFloat32(25, testf, 3.14159);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {number} testf2
|
||||
*/
|
||||
MyGame.Example.Monster.addTestf2 = function(builder, testf2) {
|
||||
builder.addFieldFloat32(26, testf2, 3.0);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {number} testf3
|
||||
*/
|
||||
MyGame.Example.Monster.addTestf3 = function(builder, testf3) {
|
||||
builder.addFieldFloat32(27, testf3, 0.0);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {flatbuffers.Offset} testarrayofstring2Offset
|
||||
*/
|
||||
MyGame.Example.Monster.addTestarrayofstring2 = function(builder, testarrayofstring2Offset) {
|
||||
builder.addFieldOffset(28, testarrayofstring2Offset, 0);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {Array.<flatbuffers.Offset>} data
|
||||
* @returns {flatbuffers.Offset}
|
||||
*/
|
||||
MyGame.Example.Monster.createTestarrayofstring2Vector = function(builder, data) {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (var i = data.length - 1; i >= 0; i--) {
|
||||
builder.addOffset(data[i]);
|
||||
}
|
||||
return builder.endVector();
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @param {number} numElems
|
||||
*/
|
||||
MyGame.Example.Monster.startTestarrayofstring2Vector = function(builder, numElems) {
|
||||
builder.startVector(4, numElems, 4);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {flatbuffers.Builder} builder
|
||||
* @returns {flatbuffers.Offset}
|
||||
|
||||
Binary file not shown.
@@ -1,7 +1,7 @@
|
||||
{
|
||||
pos: {
|
||||
x: 1,
|
||||
y: 2,
|
||||
y: "2",
|
||||
z: 3,
|
||||
test1: 3,
|
||||
test2: Green,
|
||||
@@ -21,7 +21,8 @@
|
||||
],
|
||||
test_type: Monster,
|
||||
test: {
|
||||
name: "Fred"
|
||||
name: "Fred",
|
||||
pos: null
|
||||
},
|
||||
test4: [
|
||||
{
|
||||
@@ -29,7 +30,7 @@
|
||||
b: 20
|
||||
},
|
||||
{
|
||||
b: 40,
|
||||
b: "40",
|
||||
a: 30
|
||||
}
|
||||
],
|
||||
@@ -37,6 +38,9 @@
|
||||
"test1",
|
||||
"test2"
|
||||
],
|
||||
enemy: {
|
||||
name: "Fred"
|
||||
},
|
||||
testarrayofbools:[
|
||||
true, false, true
|
||||
],
|
||||
|
||||
Binary file not shown.
14
tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.cs
Normal file
14
tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace NamespaceA.NamespaceB
|
||||
{
|
||||
|
||||
public enum EnumInNestedNS : sbyte
|
||||
{
|
||||
A = 0,
|
||||
B = 1,
|
||||
C = 2,
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package NamespaceB
|
||||
|
||||
const (
|
||||
EnumInNestedNSA = 0
|
||||
EnumInNestedNSB = 1
|
||||
EnumInNestedNSC = 2
|
||||
)
|
||||
@@ -0,0 +1,15 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package NamespaceA.NamespaceB;
|
||||
|
||||
public final class EnumInNestedNS {
|
||||
private EnumInNestedNS() { }
|
||||
public static final byte A = 0;
|
||||
public static final byte B = 1;
|
||||
public static final byte C = 2;
|
||||
|
||||
private static final String[] names = { "A", "B", "C", };
|
||||
|
||||
public static String name(int e) { return names[e]; }
|
||||
};
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace NamespaceA\NamespaceB;
|
||||
|
||||
class EnumInNestedNS
|
||||
{
|
||||
const A = 0;
|
||||
const B = 1;
|
||||
const C = 2;
|
||||
|
||||
private static $names = array(
|
||||
"A",
|
||||
"B",
|
||||
"C",
|
||||
);
|
||||
|
||||
public static function Name($e)
|
||||
{
|
||||
if (!isset(self::$names[$e])) {
|
||||
throw new \Exception();
|
||||
}
|
||||
return self::$names[$e];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: NamespaceB
|
||||
|
||||
class EnumInNestedNS(object):
|
||||
A = 0
|
||||
B = 1
|
||||
C = 2
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace NamespaceA.NamespaceB
|
||||
{
|
||||
|
||||
using System;
|
||||
using FlatBuffers;
|
||||
|
||||
public sealed class StructInNestedNS : Struct {
|
||||
public StructInNestedNS __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
|
||||
|
||||
public int A { get { return bb.GetInt(bb_pos + 0); } }
|
||||
public void MutateA(int a) { bb.PutInt(bb_pos + 0, a); }
|
||||
public int B { get { return bb.GetInt(bb_pos + 4); } }
|
||||
public void MutateB(int b) { bb.PutInt(bb_pos + 4, b); }
|
||||
|
||||
public static Offset<StructInNestedNS> CreateStructInNestedNS(FlatBufferBuilder builder, int A, int B) {
|
||||
builder.Prep(4, 8);
|
||||
builder.PutInt(B);
|
||||
builder.PutInt(A);
|
||||
return new Offset<StructInNestedNS>(builder.Offset);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package NamespaceB
|
||||
|
||||
import (
|
||||
flatbuffers "github.com/google/flatbuffers/go"
|
||||
)
|
||||
type StructInNestedNS struct {
|
||||
_tab flatbuffers.Struct
|
||||
}
|
||||
|
||||
func (rcv *StructInNestedNS) Init(buf []byte, i flatbuffers.UOffsetT) {
|
||||
rcv._tab.Bytes = buf
|
||||
rcv._tab.Pos = i
|
||||
}
|
||||
|
||||
func (rcv *StructInNestedNS) A() int32 { return rcv._tab.GetInt32(rcv._tab.Pos + flatbuffers.UOffsetT(0)) }
|
||||
func (rcv *StructInNestedNS) B() int32 { return rcv._tab.GetInt32(rcv._tab.Pos + flatbuffers.UOffsetT(4)) }
|
||||
|
||||
func CreateStructInNestedNS(builder *flatbuffers.Builder, a int32, b int32) flatbuffers.UOffsetT {
|
||||
builder.Prep(4, 8)
|
||||
builder.PrependInt32(b)
|
||||
builder.PrependInt32(a)
|
||||
return builder.Offset()
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package NamespaceA.NamespaceB;
|
||||
|
||||
import java.nio.*;
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import com.google.flatbuffers.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class StructInNestedNS extends Struct {
|
||||
public StructInNestedNS __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
|
||||
|
||||
public int a() { return bb.getInt(bb_pos + 0); }
|
||||
public void mutateA(int a) { bb.putInt(bb_pos + 0, a); }
|
||||
public int b() { return bb.getInt(bb_pos + 4); }
|
||||
public void mutateB(int b) { bb.putInt(bb_pos + 4, b); }
|
||||
|
||||
public static int createStructInNestedNS(FlatBufferBuilder builder, int a, int b) {
|
||||
builder.prep(4, 8);
|
||||
builder.putInt(b);
|
||||
builder.putInt(a);
|
||||
return builder.offset();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace NamespaceA\NamespaceB;
|
||||
|
||||
use \Google\FlatBuffers\Struct;
|
||||
use \Google\FlatBuffers\Table;
|
||||
use \Google\FlatBuffers\ByteBuffer;
|
||||
use \Google\FlatBuffers\FlatBufferBuilder;
|
||||
|
||||
class StructInNestedNS extends Struct
|
||||
{
|
||||
/**
|
||||
* @param int $_i offset
|
||||
* @param ByteBuffer $_bb
|
||||
* @return StructInNestedNS
|
||||
**/
|
||||
public function init($_i, ByteBuffer $_bb)
|
||||
{
|
||||
$this->bb_pos = $_i;
|
||||
$this->bb = $_bb;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function GetA()
|
||||
{
|
||||
return $this->bb->getInt($this->bb_pos + 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function GetB()
|
||||
{
|
||||
return $this->bb->getInt($this->bb_pos + 4);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return int offset
|
||||
*/
|
||||
public static function createStructInNestedNS(FlatBufferBuilder $builder, $a, $b)
|
||||
{
|
||||
$builder->prep(4, 8);
|
||||
$builder->putInt($b);
|
||||
$builder->putInt($a);
|
||||
return $builder->offset();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: NamespaceB
|
||||
|
||||
import flatbuffers
|
||||
|
||||
class StructInNestedNS(object):
|
||||
__slots__ = ['_tab']
|
||||
|
||||
# StructInNestedNS
|
||||
def Init(self, buf, pos):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
# StructInNestedNS
|
||||
def A(self): return self._tab.Get(flatbuffers.number_types.Int32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(0))
|
||||
# StructInNestedNS
|
||||
def B(self): return self._tab.Get(flatbuffers.number_types.Int32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(4))
|
||||
|
||||
def CreateStructInNestedNS(builder, a, b):
|
||||
builder.Prep(4, 8)
|
||||
builder.PrependInt32(b)
|
||||
builder.PrependInt32(a)
|
||||
return builder.Offset()
|
||||
@@ -0,0 +1,33 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace NamespaceA.NamespaceB
|
||||
{
|
||||
|
||||
using System;
|
||||
using FlatBuffers;
|
||||
|
||||
public sealed class TableInNestedNS : Table {
|
||||
public static TableInNestedNS GetRootAsTableInNestedNS(ByteBuffer _bb) { return GetRootAsTableInNestedNS(_bb, new TableInNestedNS()); }
|
||||
public static TableInNestedNS GetRootAsTableInNestedNS(ByteBuffer _bb, TableInNestedNS obj) { return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
|
||||
public TableInNestedNS __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
|
||||
|
||||
public int Foo { get { int o = __offset(4); return o != 0 ? bb.GetInt(o + bb_pos) : (int)0; } }
|
||||
public bool MutateFoo(int foo) { int o = __offset(4); if (o != 0) { bb.PutInt(o + bb_pos, foo); return true; } else { return false; } }
|
||||
|
||||
public static Offset<TableInNestedNS> CreateTableInNestedNS(FlatBufferBuilder builder,
|
||||
int foo = 0) {
|
||||
builder.StartObject(1);
|
||||
TableInNestedNS.AddFoo(builder, foo);
|
||||
return TableInNestedNS.EndTableInNestedNS(builder);
|
||||
}
|
||||
|
||||
public static void StartTableInNestedNS(FlatBufferBuilder builder) { builder.StartObject(1); }
|
||||
public static void AddFoo(FlatBufferBuilder builder, int foo) { builder.AddInt(0, foo, 0); }
|
||||
public static Offset<TableInNestedNS> EndTableInNestedNS(FlatBufferBuilder builder) {
|
||||
int o = builder.EndObject();
|
||||
return new Offset<TableInNestedNS>(o);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package NamespaceB
|
||||
|
||||
import (
|
||||
flatbuffers "github.com/google/flatbuffers/go"
|
||||
)
|
||||
type TableInNestedNS struct {
|
||||
_tab flatbuffers.Table
|
||||
}
|
||||
|
||||
func (rcv *TableInNestedNS) Init(buf []byte, i flatbuffers.UOffsetT) {
|
||||
rcv._tab.Bytes = buf
|
||||
rcv._tab.Pos = i
|
||||
}
|
||||
|
||||
func (rcv *TableInNestedNS) Foo() int32 {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
|
||||
if o != 0 {
|
||||
return rcv._tab.GetInt32(o + rcv._tab.Pos)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func TableInNestedNSStart(builder *flatbuffers.Builder) { builder.StartObject(1) }
|
||||
func TableInNestedNSAddFoo(builder *flatbuffers.Builder, foo int32) { builder.PrependInt32Slot(0, foo, 0) }
|
||||
func TableInNestedNSEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() }
|
||||
@@ -0,0 +1,33 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package NamespaceA.NamespaceB;
|
||||
|
||||
import java.nio.*;
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import com.google.flatbuffers.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class TableInNestedNS extends Table {
|
||||
public static TableInNestedNS getRootAsTableInNestedNS(ByteBuffer _bb) { return getRootAsTableInNestedNS(_bb, new TableInNestedNS()); }
|
||||
public static TableInNestedNS getRootAsTableInNestedNS(ByteBuffer _bb, TableInNestedNS obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__init(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public TableInNestedNS __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
|
||||
|
||||
public int foo() { int o = __offset(4); return o != 0 ? bb.getInt(o + bb_pos) : 0; }
|
||||
public boolean mutateFoo(int foo) { int o = __offset(4); if (o != 0) { bb.putInt(o + bb_pos, foo); return true; } else { return false; } }
|
||||
|
||||
public static int createTableInNestedNS(FlatBufferBuilder builder,
|
||||
int foo) {
|
||||
builder.startObject(1);
|
||||
TableInNestedNS.addFoo(builder, foo);
|
||||
return TableInNestedNS.endTableInNestedNS(builder);
|
||||
}
|
||||
|
||||
public static void startTableInNestedNS(FlatBufferBuilder builder) { builder.startObject(1); }
|
||||
public static void addFoo(FlatBufferBuilder builder, int foo) { builder.addInt(0, foo, 0); }
|
||||
public static int endTableInNestedNS(FlatBufferBuilder builder) {
|
||||
int o = builder.endObject();
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace NamespaceA\NamespaceB;
|
||||
|
||||
use \Google\FlatBuffers\Struct;
|
||||
use \Google\FlatBuffers\Table;
|
||||
use \Google\FlatBuffers\ByteBuffer;
|
||||
use \Google\FlatBuffers\FlatBufferBuilder;
|
||||
|
||||
class TableInNestedNS extends Table
|
||||
{
|
||||
/**
|
||||
* @param ByteBuffer $bb
|
||||
* @return TableInNestedNS
|
||||
*/
|
||||
public static function getRootAsTableInNestedNS(ByteBuffer $bb)
|
||||
{
|
||||
$obj = new TableInNestedNS();
|
||||
return ($obj->init($bb->getInt($bb->getPosition()) + $bb->getPosition(), $bb));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $_i offset
|
||||
* @param ByteBuffer $_bb
|
||||
* @return TableInNestedNS
|
||||
**/
|
||||
public function init($_i, ByteBuffer $_bb)
|
||||
{
|
||||
$this->bb_pos = $_i;
|
||||
$this->bb = $_bb;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getFoo()
|
||||
{
|
||||
$o = $this->__offset(4);
|
||||
return $o != 0 ? $this->bb->getInt($o + $this->bb_pos) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @return void
|
||||
*/
|
||||
public static function startTableInNestedNS(FlatBufferBuilder $builder)
|
||||
{
|
||||
$builder->StartObject(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @return TableInNestedNS
|
||||
*/
|
||||
public static function createTableInNestedNS(FlatBufferBuilder $builder, $foo)
|
||||
{
|
||||
$builder->startObject(1);
|
||||
self::addFoo($builder, $foo);
|
||||
$o = $builder->endObject();
|
||||
return $o;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @param int
|
||||
* @return void
|
||||
*/
|
||||
public static function addFoo(FlatBufferBuilder $builder, $foo)
|
||||
{
|
||||
$builder->addIntX(0, $foo, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @return int table offset
|
||||
*/
|
||||
public static function endTableInNestedNS(FlatBufferBuilder $builder)
|
||||
{
|
||||
$o = $builder->endObject();
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: NamespaceB
|
||||
|
||||
import flatbuffers
|
||||
|
||||
class TableInNestedNS(object):
|
||||
__slots__ = ['_tab']
|
||||
|
||||
# TableInNestedNS
|
||||
def Init(self, buf, pos):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
# TableInNestedNS
|
||||
def Foo(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
|
||||
if o != 0:
|
||||
return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
|
||||
return 0
|
||||
|
||||
def TableInNestedNSStart(builder): builder.StartObject(1)
|
||||
def TableInNestedNSAddFoo(builder, foo): builder.PrependInt32Slot(0, foo, 0)
|
||||
def TableInNestedNSEnd(builder): return builder.EndObject()
|
||||
33
tests/namespace_test/NamespaceA/SecondTableInA.cs
Normal file
33
tests/namespace_test/NamespaceA/SecondTableInA.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace NamespaceA
|
||||
{
|
||||
|
||||
using System;
|
||||
using FlatBuffers;
|
||||
|
||||
public sealed class SecondTableInA : Table {
|
||||
public static SecondTableInA GetRootAsSecondTableInA(ByteBuffer _bb) { return GetRootAsSecondTableInA(_bb, new SecondTableInA()); }
|
||||
public static SecondTableInA GetRootAsSecondTableInA(ByteBuffer _bb, SecondTableInA obj) { return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
|
||||
public SecondTableInA __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
|
||||
|
||||
public NamespaceC.TableInC ReferToC { get { return GetReferToC(new NamespaceC.TableInC()); } }
|
||||
public NamespaceC.TableInC GetReferToC(NamespaceC.TableInC obj) { int o = __offset(4); return o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null; }
|
||||
|
||||
public static Offset<SecondTableInA> CreateSecondTableInA(FlatBufferBuilder builder,
|
||||
Offset<NamespaceC.TableInC> refer_to_cOffset = default(Offset<NamespaceC.TableInC>)) {
|
||||
builder.StartObject(1);
|
||||
SecondTableInA.AddReferToC(builder, refer_to_cOffset);
|
||||
return SecondTableInA.EndSecondTableInA(builder);
|
||||
}
|
||||
|
||||
public static void StartSecondTableInA(FlatBufferBuilder builder) { builder.StartObject(1); }
|
||||
public static void AddReferToC(FlatBufferBuilder builder, Offset<NamespaceC.TableInC> referToCOffset) { builder.AddOffset(0, referToCOffset.Value, 0); }
|
||||
public static Offset<SecondTableInA> EndSecondTableInA(FlatBufferBuilder builder) {
|
||||
int o = builder.EndObject();
|
||||
return new Offset<SecondTableInA>(o);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
32
tests/namespace_test/NamespaceA/SecondTableInA.go
Normal file
32
tests/namespace_test/NamespaceA/SecondTableInA.go
Normal file
@@ -0,0 +1,32 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package NamespaceA
|
||||
|
||||
import (
|
||||
flatbuffers "github.com/google/flatbuffers/go"
|
||||
)
|
||||
type SecondTableInA struct {
|
||||
_tab flatbuffers.Table
|
||||
}
|
||||
|
||||
func (rcv *SecondTableInA) Init(buf []byte, i flatbuffers.UOffsetT) {
|
||||
rcv._tab.Bytes = buf
|
||||
rcv._tab.Pos = i
|
||||
}
|
||||
|
||||
func (rcv *SecondTableInA) ReferToC(obj *TableInC) *TableInC {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
|
||||
if o != 0 {
|
||||
x := rcv._tab.Indirect(o + rcv._tab.Pos)
|
||||
if obj == nil {
|
||||
obj = new(TableInC)
|
||||
}
|
||||
obj.Init(rcv._tab.Bytes, x)
|
||||
return obj
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func SecondTableInAStart(builder *flatbuffers.Builder) { builder.StartObject(1) }
|
||||
func SecondTableInAAddReferToC(builder *flatbuffers.Builder, referToC flatbuffers.UOffsetT) { builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(referToC), 0) }
|
||||
func SecondTableInAEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() }
|
||||
33
tests/namespace_test/NamespaceA/SecondTableInA.java
Normal file
33
tests/namespace_test/NamespaceA/SecondTableInA.java
Normal file
@@ -0,0 +1,33 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package NamespaceA;
|
||||
|
||||
import java.nio.*;
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import com.google.flatbuffers.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class SecondTableInA extends Table {
|
||||
public static SecondTableInA getRootAsSecondTableInA(ByteBuffer _bb) { return getRootAsSecondTableInA(_bb, new SecondTableInA()); }
|
||||
public static SecondTableInA getRootAsSecondTableInA(ByteBuffer _bb, SecondTableInA obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__init(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public SecondTableInA __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
|
||||
|
||||
public NamespaceC.TableInC referToC() { return referToC(new NamespaceC.TableInC()); }
|
||||
public NamespaceC.TableInC referToC(NamespaceC.TableInC obj) { int o = __offset(4); return o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null; }
|
||||
|
||||
public static int createSecondTableInA(FlatBufferBuilder builder,
|
||||
int refer_to_cOffset) {
|
||||
builder.startObject(1);
|
||||
SecondTableInA.addReferToC(builder, refer_to_cOffset);
|
||||
return SecondTableInA.endSecondTableInA(builder);
|
||||
}
|
||||
|
||||
public static void startSecondTableInA(FlatBufferBuilder builder) { builder.startObject(1); }
|
||||
public static void addReferToC(FlatBufferBuilder builder, int referToCOffset) { builder.addOffset(0, referToCOffset, 0); }
|
||||
public static int endSecondTableInA(FlatBufferBuilder builder) {
|
||||
int o = builder.endObject();
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
82
tests/namespace_test/NamespaceA/SecondTableInA.php
Normal file
82
tests/namespace_test/NamespaceA/SecondTableInA.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace NamespaceA;
|
||||
|
||||
use \Google\FlatBuffers\Struct;
|
||||
use \Google\FlatBuffers\Table;
|
||||
use \Google\FlatBuffers\ByteBuffer;
|
||||
use \Google\FlatBuffers\FlatBufferBuilder;
|
||||
|
||||
class SecondTableInA extends Table
|
||||
{
|
||||
/**
|
||||
* @param ByteBuffer $bb
|
||||
* @return SecondTableInA
|
||||
*/
|
||||
public static function getRootAsSecondTableInA(ByteBuffer $bb)
|
||||
{
|
||||
$obj = new SecondTableInA();
|
||||
return ($obj->init($bb->getInt($bb->getPosition()) + $bb->getPosition(), $bb));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $_i offset
|
||||
* @param ByteBuffer $_bb
|
||||
* @return SecondTableInA
|
||||
**/
|
||||
public function init($_i, ByteBuffer $_bb)
|
||||
{
|
||||
$this->bb_pos = $_i;
|
||||
$this->bb = $_bb;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getReferToC()
|
||||
{
|
||||
$obj = new TableInC();
|
||||
$o = $this->__offset(4);
|
||||
return $o != 0 ? $obj->init($this->__indirect($o + $this->bb_pos), $this->bb) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @return void
|
||||
*/
|
||||
public static function startSecondTableInA(FlatBufferBuilder $builder)
|
||||
{
|
||||
$builder->StartObject(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @return SecondTableInA
|
||||
*/
|
||||
public static function createSecondTableInA(FlatBufferBuilder $builder, $refer_to_c)
|
||||
{
|
||||
$builder->startObject(1);
|
||||
self::addReferToC($builder, $refer_to_c);
|
||||
$o = $builder->endObject();
|
||||
return $o;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @param int
|
||||
* @return void
|
||||
*/
|
||||
public static function addReferToC(FlatBufferBuilder $builder, $referToC)
|
||||
{
|
||||
$builder->addOffsetX(0, $referToC, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FlatBufferBuilder $builder
|
||||
* @return int table offset
|
||||
*/
|
||||
public static function endSecondTableInA(FlatBufferBuilder $builder)
|
||||
{
|
||||
$o = $builder->endObject();
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
27
tests/namespace_test/NamespaceA/SecondTableInA.py
Normal file
27
tests/namespace_test/NamespaceA/SecondTableInA.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
# namespace: NamespaceA
|
||||
|
||||
import flatbuffers
|
||||
|
||||
class SecondTableInA(object):
|
||||
__slots__ = ['_tab']
|
||||
|
||||
# SecondTableInA
|
||||
def Init(self, buf, pos):
|
||||
self._tab = flatbuffers.table.Table(buf, pos)
|
||||
|
||||
# SecondTableInA
|
||||
def ReferToC(self):
|
||||
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
|
||||
if o != 0:
|
||||
x = self._tab.Indirect(o + self._tab.Pos)
|
||||
from .TableInC import TableInC
|
||||
obj = TableInC()
|
||||
obj.Init(self._tab.Bytes, x)
|
||||
return obj
|
||||
return None
|
||||
|
||||
def SecondTableInAStart(builder): builder.StartObject(1)
|
||||
def SecondTableInAAddReferToC(builder, referToC): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(referToC), 0)
|
||||
def SecondTableInAEnd(builder): return builder.EndObject()
|
||||
38
tests/namespace_test/NamespaceA/TableInC.cs
Normal file
38
tests/namespace_test/NamespaceA/TableInC.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
namespace NamespaceA
|
||||
{
|
||||
|
||||
using System;
|
||||
using FlatBuffers;
|
||||
|
||||
public sealed class TableInC : Table {
|
||||
public static TableInC GetRootAsTableInC(ByteBuffer _bb) { return GetRootAsTableInC(_bb, new TableInC()); }
|
||||
public static TableInC GetRootAsTableInC(ByteBuffer _bb, TableInC obj) { return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
|
||||
public TableInC __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
|
||||
|
||||
public NamespaceA.TableInFirstNS ReferToA1 { get { return GetReferToA1(new NamespaceA.TableInFirstNS()); } }
|
||||
public NamespaceA.TableInFirstNS GetReferToA1(NamespaceA.TableInFirstNS obj) { int o = __offset(4); return o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null; }
|
||||
public SecondTableInA ReferToA2 { get { return GetReferToA2(new SecondTableInA()); } }
|
||||
public SecondTableInA GetReferToA2(SecondTableInA obj) { int o = __offset(6); return o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null; }
|
||||
|
||||
public static Offset<NamespaceC.TableInC> CreateTableInC(FlatBufferBuilder builder,
|
||||
Offset<NamespaceA.TableInFirstNS> refer_to_a1Offset = default(Offset<NamespaceA.TableInFirstNS>),
|
||||
Offset<SecondTableInA> refer_to_a2Offset = default(Offset<SecondTableInA>)) {
|
||||
builder.StartObject(2);
|
||||
TableInC.AddReferToA2(builder, refer_to_a2Offset);
|
||||
TableInC.AddReferToA1(builder, refer_to_a1Offset);
|
||||
return TableInC.EndTableInC(builder);
|
||||
}
|
||||
|
||||
public static void StartTableInC(FlatBufferBuilder builder) { builder.StartObject(2); }
|
||||
public static void AddReferToA1(FlatBufferBuilder builder, Offset<NamespaceA.TableInFirstNS> referToA1Offset) { builder.AddOffset(0, referToA1Offset.Value, 0); }
|
||||
public static void AddReferToA2(FlatBufferBuilder builder, Offset<SecondTableInA> referToA2Offset) { builder.AddOffset(1, referToA2Offset.Value, 0); }
|
||||
public static Offset<NamespaceC.TableInC> EndTableInC(FlatBufferBuilder builder) {
|
||||
int o = builder.EndObject();
|
||||
return new Offset<NamespaceC.TableInC>(o);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
46
tests/namespace_test/NamespaceA/TableInC.go
Normal file
46
tests/namespace_test/NamespaceA/TableInC.go
Normal file
@@ -0,0 +1,46 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package NamespaceA
|
||||
|
||||
import (
|
||||
flatbuffers "github.com/google/flatbuffers/go"
|
||||
)
|
||||
type TableInC struct {
|
||||
_tab flatbuffers.Table
|
||||
}
|
||||
|
||||
func (rcv *TableInC) Init(buf []byte, i flatbuffers.UOffsetT) {
|
||||
rcv._tab.Bytes = buf
|
||||
rcv._tab.Pos = i
|
||||
}
|
||||
|
||||
func (rcv *TableInC) ReferToA1(obj *TableInFirstNS) *TableInFirstNS {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
|
||||
if o != 0 {
|
||||
x := rcv._tab.Indirect(o + rcv._tab.Pos)
|
||||
if obj == nil {
|
||||
obj = new(TableInFirstNS)
|
||||
}
|
||||
obj.Init(rcv._tab.Bytes, x)
|
||||
return obj
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rcv *TableInC) ReferToA2(obj *SecondTableInA) *SecondTableInA {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(6))
|
||||
if o != 0 {
|
||||
x := rcv._tab.Indirect(o + rcv._tab.Pos)
|
||||
if obj == nil {
|
||||
obj = new(SecondTableInA)
|
||||
}
|
||||
obj.Init(rcv._tab.Bytes, x)
|
||||
return obj
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func TableInCStart(builder *flatbuffers.Builder) { builder.StartObject(2) }
|
||||
func TableInCAddReferToA1(builder *flatbuffers.Builder, referToA1 flatbuffers.UOffsetT) { builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(referToA1), 0) }
|
||||
func TableInCAddReferToA2(builder *flatbuffers.Builder, referToA2 flatbuffers.UOffsetT) { builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(referToA2), 0) }
|
||||
func TableInCEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() }
|
||||
38
tests/namespace_test/NamespaceA/TableInC.java
Normal file
38
tests/namespace_test/NamespaceA/TableInC.java
Normal file
@@ -0,0 +1,38 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package NamespaceA;
|
||||
|
||||
import java.nio.*;
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import com.google.flatbuffers.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class TableInC extends Table {
|
||||
public static TableInC getRootAsTableInC(ByteBuffer _bb) { return getRootAsTableInC(_bb, new TableInC()); }
|
||||
public static TableInC getRootAsTableInC(ByteBuffer _bb, TableInC obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__init(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public TableInC __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
|
||||
|
||||
public NamespaceA.TableInFirstNS referToA1() { return referToA1(new NamespaceA.TableInFirstNS()); }
|
||||
public NamespaceA.TableInFirstNS referToA1(NamespaceA.TableInFirstNS obj) { int o = __offset(4); return o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null; }
|
||||
public SecondTableInA referToA2() { return referToA2(new SecondTableInA()); }
|
||||
public SecondTableInA referToA2(SecondTableInA obj) { int o = __offset(6); return o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null; }
|
||||
|
||||
public static int createTableInC(FlatBufferBuilder builder,
|
||||
int refer_to_a1Offset,
|
||||
int refer_to_a2Offset) {
|
||||
builder.startObject(2);
|
||||
TableInC.addReferToA2(builder, refer_to_a2Offset);
|
||||
TableInC.addReferToA1(builder, refer_to_a1Offset);
|
||||
return TableInC.endTableInC(builder);
|
||||
}
|
||||
|
||||
public static void startTableInC(FlatBufferBuilder builder) { builder.startObject(2); }
|
||||
public static void addReferToA1(FlatBufferBuilder builder, int referToA1Offset) { builder.addOffset(0, referToA1Offset, 0); }
|
||||
public static void addReferToA2(FlatBufferBuilder builder, int referToA2Offset) { builder.addOffset(1, referToA2Offset, 0); }
|
||||
public static int endTableInC(FlatBufferBuilder builder) {
|
||||
int o = builder.endObject();
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user