Skip to content

Commit ca0eac4

Browse files
committed
Adding source FlatBuffers C# Files
1 parent ac9cc86 commit ca0eac4

31 files changed

+2373
-0
lines changed

FlatBuffersCSharp/ByteBuffer.cs

Lines changed: 445 additions & 0 deletions
Large diffs are not rendered by default.

FlatBuffersCSharp/FlatBufferBuilder.cs

Lines changed: 638 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2014 Google Inc. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
using System;
18+
using System.Collections.Generic;
19+
using System.Linq;
20+
using System.Text;
21+
22+
namespace FlatBuffers
23+
{
24+
public static class FlatBufferConstants
25+
{
26+
public const int FileIdentifierLength = 4;
27+
}
28+
}

FlatBuffersCSharp/Offset.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright 2014 Google Inc. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
namespace FlatBuffers
18+
{
19+
/// <summary>
20+
/// Offset class for typesafe assignments.
21+
/// </summary>
22+
public struct Offset<T> where T : class
23+
{
24+
public int Value;
25+
public Offset(int value)
26+
{
27+
Value = value;
28+
}
29+
}
30+
31+
public struct StringOffset
32+
{
33+
public int Value;
34+
public StringOffset(int value)
35+
{
36+
Value = value;
37+
}
38+
}
39+
40+
public struct VectorOffset
41+
{
42+
public int Value;
43+
public VectorOffset(int value)
44+
{
45+
Value = value;
46+
}
47+
}
48+
}

FlatBuffersCSharp/Struct.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2014 Google Inc. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
namespace FlatBuffers
18+
{
19+
/// <summary>
20+
/// All structs in the generated code derive from this class, and add their own accessors.
21+
/// </summary>
22+
public abstract class Struct
23+
{
24+
protected int bb_pos;
25+
protected ByteBuffer bb;
26+
}
27+
}

FlatBuffersCSharp/Table.cs

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
* Copyright 2014 Google Inc. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
using System;
18+
using System.Text;
19+
20+
namespace FlatBuffers
21+
{
22+
/// <summary>
23+
/// All tables in the generated code derive from this class, and add their own accessors.
24+
/// </summary>
25+
public abstract class Table
26+
{
27+
protected int bb_pos;
28+
protected ByteBuffer bb;
29+
30+
public ByteBuffer ByteBuffer { get { return bb; } }
31+
32+
// Look up a field in the vtable, return an offset into the object, or 0 if the field is not
33+
// present.
34+
protected int __offset(int vtableOffset)
35+
{
36+
int vtable = bb_pos - bb.GetInt(bb_pos);
37+
return vtableOffset < bb.GetShort(vtable) ? (int)bb.GetShort(vtable + vtableOffset) : 0;
38+
}
39+
40+
// Retrieve the relative offset stored at "offset"
41+
protected int __indirect(int offset)
42+
{
43+
return offset + bb.GetInt(offset);
44+
}
45+
46+
// Create a .NET String from UTF-8 data stored inside the flatbuffer.
47+
protected string __string(int offset)
48+
{
49+
offset += bb.GetInt(offset);
50+
var len = bb.GetInt(offset);
51+
var startPos = offset + sizeof(int);
52+
return Encoding.UTF8.GetString(bb.Data, startPos , len);
53+
}
54+
55+
// Get the length of a vector whose offset is stored at "offset" in this object.
56+
protected int __vector_len(int offset)
57+
{
58+
offset += bb_pos;
59+
offset += bb.GetInt(offset);
60+
return bb.GetInt(offset);
61+
}
62+
63+
// Get the start of data of a vector whose offset is stored at "offset" in this object.
64+
protected int __vector(int offset)
65+
{
66+
offset += bb_pos;
67+
return offset + bb.GetInt(offset) + sizeof(int); // data starts after the length
68+
}
69+
70+
// Get the data of a vector whoses offset is stored at "offset" in this object as an
71+
// ArraySegment&lt;byte&gt;. If the vector is not present in the ByteBuffer,
72+
// then a null value will be returned.
73+
protected ArraySegment<byte>? __vector_as_arraysegment(int offset) {
74+
var o = this.__offset(offset);
75+
if (0 == o)
76+
{
77+
return null;
78+
}
79+
80+
var pos = this.__vector(o);
81+
var len = this.__vector_len(o);
82+
return new ArraySegment<byte>(this.bb.Data, pos, len);
83+
}
84+
85+
// Initialize any Table-derived type to point to the union at the given offset.
86+
protected TTable __union<TTable>(TTable t, int offset) where TTable : Table
87+
{
88+
offset += bb_pos;
89+
t.bb_pos = offset + bb.GetInt(offset);
90+
t.bb = bb;
91+
return t;
92+
}
93+
94+
protected static bool __has_identifier(ByteBuffer bb, string ident)
95+
{
96+
if (ident.Length != FlatBufferConstants.FileIdentifierLength)
97+
throw new ArgumentException("FlatBuffers: file identifier must be length " + FlatBufferConstants.FileIdentifierLength, "ident");
98+
99+
for (var i = 0; i < FlatBufferConstants.FileIdentifierLength; i++)
100+
{
101+
if (ident[i] != (char)bb.Get(bb.Position + sizeof(int) + i)) return false;
102+
}
103+
104+
return true;
105+
}
106+
107+
108+
}
109+
}

FlatBuffersCSharp/anchorPointData.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// automatically generated, do not modify
2+
3+
namespace CreatureFlatData
4+
{
5+
6+
using FlatBuffers;
7+
8+
public sealed class anchorPointData : Table {
9+
public static anchorPointData GetRootAsanchorPointData(ByteBuffer _bb) { return GetRootAsanchorPointData(_bb, new anchorPointData()); }
10+
public static anchorPointData GetRootAsanchorPointData(ByteBuffer _bb, anchorPointData obj) { return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
11+
public anchorPointData __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
12+
13+
public float GetPoint(int j) { int o = __offset(4); return o != 0 ? bb.GetFloat(__vector(o) + j * 4) : (float)0; }
14+
public int PointLength { get { int o = __offset(4); return o != 0 ? __vector_len(o) : 0; } }
15+
public string AnimClipName { get { int o = __offset(6); return o != 0 ? __string(o + bb_pos) : null; } }
16+
17+
public static Offset<anchorPointData> CreateanchorPointData(FlatBufferBuilder builder,
18+
VectorOffset point = default(VectorOffset),
19+
StringOffset anim_clip_name = default(StringOffset)) {
20+
builder.StartObject(2);
21+
anchorPointData.AddAnimClipName(builder, anim_clip_name);
22+
anchorPointData.AddPoint(builder, point);
23+
return anchorPointData.EndanchorPointData(builder);
24+
}
25+
26+
public static void StartanchorPointData(FlatBufferBuilder builder) { builder.StartObject(2); }
27+
public static void AddPoint(FlatBufferBuilder builder, VectorOffset pointOffset) { builder.AddOffset(0, pointOffset.Value, 0); }
28+
public static VectorOffset CreatePointVector(FlatBufferBuilder builder, float[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddFloat(data[i]); return builder.EndVector(); }
29+
public static void StartPointVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
30+
public static void AddAnimClipName(FlatBufferBuilder builder, StringOffset animClipNameOffset) { builder.AddOffset(1, animClipNameOffset.Value, 0); }
31+
public static Offset<anchorPointData> EndanchorPointData(FlatBufferBuilder builder) {
32+
int o = builder.EndObject();
33+
return new Offset<anchorPointData>(o);
34+
}
35+
};
36+
37+
38+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// automatically generated, do not modify
2+
3+
namespace CreatureFlatData
4+
{
5+
6+
using FlatBuffers;
7+
8+
public sealed class anchorPointsHolder : Table {
9+
public static anchorPointsHolder GetRootAsanchorPointsHolder(ByteBuffer _bb) { return GetRootAsanchorPointsHolder(_bb, new anchorPointsHolder()); }
10+
public static anchorPointsHolder GetRootAsanchorPointsHolder(ByteBuffer _bb, anchorPointsHolder obj) { return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
11+
public anchorPointsHolder __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
12+
13+
public anchorPointData GetAnchorPoints(int j) { return GetAnchorPoints(new anchorPointData(), j); }
14+
public anchorPointData GetAnchorPoints(anchorPointData obj, int j) { int o = __offset(4); return o != 0 ? obj.__init(__indirect(__vector(o) + j * 4), bb) : null; }
15+
public int AnchorPointsLength { get { int o = __offset(4); return o != 0 ? __vector_len(o) : 0; } }
16+
17+
public static Offset<anchorPointsHolder> CreateanchorPointsHolder(FlatBufferBuilder builder,
18+
VectorOffset anchorPoints = default(VectorOffset)) {
19+
builder.StartObject(1);
20+
anchorPointsHolder.AddAnchorPoints(builder, anchorPoints);
21+
return anchorPointsHolder.EndanchorPointsHolder(builder);
22+
}
23+
24+
public static void StartanchorPointsHolder(FlatBufferBuilder builder) { builder.StartObject(1); }
25+
public static void AddAnchorPoints(FlatBufferBuilder builder, VectorOffset anchorPointsOffset) { builder.AddOffset(0, anchorPointsOffset.Value, 0); }
26+
public static VectorOffset CreateAnchorPointsVector(FlatBufferBuilder builder, Offset<anchorPointData>[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i].Value); return builder.EndVector(); }
27+
public static void StartAnchorPointsVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
28+
public static Offset<anchorPointsHolder> EndanchorPointsHolder(FlatBufferBuilder builder) {
29+
int o = builder.EndObject();
30+
return new Offset<anchorPointsHolder>(o);
31+
}
32+
};
33+
34+
35+
}

FlatBuffersCSharp/animation.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// automatically generated, do not modify
2+
3+
namespace CreatureFlatData
4+
{
5+
6+
using FlatBuffers;
7+
8+
public sealed class animation : Table {
9+
public static animation GetRootAsanimation(ByteBuffer _bb) { return GetRootAsanimation(_bb, new animation()); }
10+
public static animation GetRootAsanimation(ByteBuffer _bb, animation obj) { return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
11+
public animation __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
12+
13+
public animationClip GetClips(int j) { return GetClips(new animationClip(), j); }
14+
public animationClip GetClips(animationClip obj, int j) { int o = __offset(4); return o != 0 ? obj.__init(__indirect(__vector(o) + j * 4), bb) : null; }
15+
public int ClipsLength { get { int o = __offset(4); return o != 0 ? __vector_len(o) : 0; } }
16+
17+
public static Offset<animation> Createanimation(FlatBufferBuilder builder,
18+
VectorOffset clips = default(VectorOffset)) {
19+
builder.StartObject(1);
20+
animation.AddClips(builder, clips);
21+
return animation.Endanimation(builder);
22+
}
23+
24+
public static void Startanimation(FlatBufferBuilder builder) { builder.StartObject(1); }
25+
public static void AddClips(FlatBufferBuilder builder, VectorOffset clipsOffset) { builder.AddOffset(0, clipsOffset.Value, 0); }
26+
public static VectorOffset CreateClipsVector(FlatBufferBuilder builder, Offset<animationClip>[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i].Value); return builder.EndVector(); }
27+
public static void StartClipsVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
28+
public static Offset<animation> Endanimation(FlatBufferBuilder builder) {
29+
int o = builder.EndObject();
30+
return new Offset<animation>(o);
31+
}
32+
};
33+
34+
35+
}

FlatBuffersCSharp/animationBone.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// automatically generated, do not modify
2+
3+
namespace CreatureFlatData
4+
{
5+
6+
using FlatBuffers;
7+
8+
public sealed class animationBone : Table {
9+
public static animationBone GetRootAsanimationBone(ByteBuffer _bb) { return GetRootAsanimationBone(_bb, new animationBone()); }
10+
public static animationBone GetRootAsanimationBone(ByteBuffer _bb, animationBone obj) { return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
11+
public animationBone __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
12+
13+
public string Name { get { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; } }
14+
public float GetStartPt(int j) { int o = __offset(6); return o != 0 ? bb.GetFloat(__vector(o) + j * 4) : (float)0; }
15+
public int StartPtLength { get { int o = __offset(6); return o != 0 ? __vector_len(o) : 0; } }
16+
public float GetEndPt(int j) { int o = __offset(8); return o != 0 ? bb.GetFloat(__vector(o) + j * 4) : (float)0; }
17+
public int EndPtLength { get { int o = __offset(8); return o != 0 ? __vector_len(o) : 0; } }
18+
19+
public static Offset<animationBone> CreateanimationBone(FlatBufferBuilder builder,
20+
StringOffset name = default(StringOffset),
21+
VectorOffset start_pt = default(VectorOffset),
22+
VectorOffset end_pt = default(VectorOffset)) {
23+
builder.StartObject(3);
24+
animationBone.AddEndPt(builder, end_pt);
25+
animationBone.AddStartPt(builder, start_pt);
26+
animationBone.AddName(builder, name);
27+
return animationBone.EndanimationBone(builder);
28+
}
29+
30+
public static void StartanimationBone(FlatBufferBuilder builder) { builder.StartObject(3); }
31+
public static void AddName(FlatBufferBuilder builder, StringOffset nameOffset) { builder.AddOffset(0, nameOffset.Value, 0); }
32+
public static void AddStartPt(FlatBufferBuilder builder, VectorOffset startPtOffset) { builder.AddOffset(1, startPtOffset.Value, 0); }
33+
public static VectorOffset CreateStartPtVector(FlatBufferBuilder builder, float[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddFloat(data[i]); return builder.EndVector(); }
34+
public static void StartStartPtVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
35+
public static void AddEndPt(FlatBufferBuilder builder, VectorOffset endPtOffset) { builder.AddOffset(2, endPtOffset.Value, 0); }
36+
public static VectorOffset CreateEndPtVector(FlatBufferBuilder builder, float[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddFloat(data[i]); return builder.EndVector(); }
37+
public static void StartEndPtVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
38+
public static Offset<animationBone> EndanimationBone(FlatBufferBuilder builder) {
39+
int o = builder.EndObject();
40+
return new Offset<animationBone>(o);
41+
}
42+
};
43+
44+
45+
}

0 commit comments

Comments
 (0)