-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TS] Fix generation of struct members in object api (#7148)
* Fix C/C++ Create<Type>Direct with sorted vectors If a struct has a key the vector has to be sorted. To sort the vector you can't use "const". * Changes due to code review * Improve code readability * Add generate of JSON schema to string to lib * option indent_step is supported * Remove unused variables * Fix break in test * Fix style to be consistent with rest of the code * [TS] Fix reserved words as arguments (#6955) * [TS] Fix generation of reserved words in object api (#7106) * [TS] Fix generation of object api * [TS] Fix MakeCamel -> ConvertCase * [TS] Add test for struct of struct of struct * Update generated files * Add missing files * [TS] Fix query of null/undefined fields in object api
- Loading branch information
Showing
27 changed files
with
1,490 additions
and
344 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// <auto-generated> | ||
// automatically generated by the FlatBuffers compiler, do not modify | ||
// </auto-generated> | ||
|
||
namespace MyGame.Example | ||
{ | ||
|
||
using global::System; | ||
using global::System.Collections.Generic; | ||
using global::FlatBuffers; | ||
|
||
public struct StructOfStructsOfStructs : IFlatbufferObject | ||
{ | ||
private Struct __p; | ||
public ByteBuffer ByteBuffer { get { return __p.bb; } } | ||
public void __init(int _i, ByteBuffer _bb) { __p = new Struct(_i, _bb); } | ||
public StructOfStructsOfStructs __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } | ||
|
||
public MyGame.Example.StructOfStructs A { get { return (new MyGame.Example.StructOfStructs()).__assign(__p.bb_pos + 0, __p.bb); } } | ||
|
||
public static Offset<MyGame.Example.StructOfStructsOfStructs> CreateStructOfStructsOfStructs(FlatBufferBuilder builder, uint a_a_Id, uint a_a_Distance, short a_b_A, sbyte a_b_B, uint a_c_Id, uint a_c_Distance) { | ||
builder.Prep(4, 20); | ||
builder.Prep(4, 20); | ||
builder.Prep(4, 8); | ||
builder.PutUint(a_c_Distance); | ||
builder.PutUint(a_c_Id); | ||
builder.Prep(2, 4); | ||
builder.Pad(1); | ||
builder.PutSbyte(a_b_B); | ||
builder.PutShort(a_b_A); | ||
builder.Prep(4, 8); | ||
builder.PutUint(a_a_Distance); | ||
builder.PutUint(a_a_Id); | ||
return new Offset<MyGame.Example.StructOfStructsOfStructs>(builder.Offset); | ||
} | ||
public StructOfStructsOfStructsT UnPack() { | ||
var _o = new StructOfStructsOfStructsT(); | ||
this.UnPackTo(_o); | ||
return _o; | ||
} | ||
public void UnPackTo(StructOfStructsOfStructsT _o) { | ||
_o.A = this.A.UnPack(); | ||
} | ||
public static Offset<MyGame.Example.StructOfStructsOfStructs> Pack(FlatBufferBuilder builder, StructOfStructsOfStructsT _o) { | ||
if (_o == null) return default(Offset<MyGame.Example.StructOfStructsOfStructs>); | ||
var _a_a_id = _o.A.A.Id; | ||
var _a_a_distance = _o.A.A.Distance; | ||
var _a_b_a = _o.A.B.A; | ||
var _a_b_b = _o.A.B.B; | ||
var _a_c_id = _o.A.C.Id; | ||
var _a_c_distance = _o.A.C.Distance; | ||
return CreateStructOfStructsOfStructs( | ||
builder, | ||
_a_a_id, | ||
_a_a_distance, | ||
_a_b_a, | ||
_a_b_b, | ||
_a_c_id, | ||
_a_c_distance); | ||
} | ||
} | ||
|
||
public class StructOfStructsOfStructsT | ||
{ | ||
[Newtonsoft.Json.JsonProperty("a")] | ||
public MyGame.Example.StructOfStructsT A { get; set; } | ||
|
||
public StructOfStructsOfStructsT() { | ||
this.A = new MyGame.Example.StructOfStructsT(); | ||
} | ||
} | ||
|
||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// automatically generated by the FlatBuffers compiler, do not modify | ||
|
||
package MyGame.Example; | ||
|
||
import java.nio.*; | ||
import java.lang.*; | ||
import java.util.*; | ||
import com.google.flatbuffers.*; | ||
|
||
@SuppressWarnings("unused") | ||
public final class StructOfStructsOfStructs extends Struct { | ||
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); } | ||
public StructOfStructsOfStructs __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } | ||
|
||
public MyGame.Example.StructOfStructs a() { return a(new MyGame.Example.StructOfStructs()); } | ||
public MyGame.Example.StructOfStructs a(MyGame.Example.StructOfStructs obj) { return obj.__assign(bb_pos + 0, bb); } | ||
|
||
public static int createStructOfStructsOfStructs(FlatBufferBuilder builder, long a_a_id, long a_a_distance, short a_b_a, byte a_b_b, long a_c_id, long a_c_distance) { | ||
builder.prep(4, 20); | ||
builder.prep(4, 20); | ||
builder.prep(4, 8); | ||
builder.putInt((int) a_c_distance); | ||
builder.putInt((int) a_c_id); | ||
builder.prep(2, 4); | ||
builder.pad(1); | ||
builder.putByte(a_b_b); | ||
builder.putShort(a_b_a); | ||
builder.prep(4, 8); | ||
builder.putInt((int) a_a_distance); | ||
builder.putInt((int) a_a_id); | ||
return builder.offset(); | ||
} | ||
|
||
public static final class Vector extends BaseVector { | ||
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; } | ||
|
||
public StructOfStructsOfStructs get(int j) { return get(new StructOfStructsOfStructs(), j); } | ||
public StructOfStructsOfStructs get(StructOfStructsOfStructs obj, int j) { return obj.__assign(__element(j), bb); } | ||
} | ||
public StructOfStructsOfStructsT unpack() { | ||
StructOfStructsOfStructsT _o = new StructOfStructsOfStructsT(); | ||
unpackTo(_o); | ||
return _o; | ||
} | ||
public void unpackTo(StructOfStructsOfStructsT _o) { | ||
a().unpackTo(_o.getA()); | ||
} | ||
public static int pack(FlatBufferBuilder builder, StructOfStructsOfStructsT _o) { | ||
if (_o == null) return 0; | ||
int _a_a_id = _o.getA().getA().getId(); | ||
int _a_a_distance = _o.getA().getA().getDistance(); | ||
short _a_b_a = _o.getA().getB().getA(); | ||
byte _a_b_b = _o.getA().getB().getB(); | ||
int _a_c_id = _o.getA().getC().getId(); | ||
int _a_c_distance = _o.getA().getC().getDistance(); | ||
return createStructOfStructsOfStructs( | ||
builder, | ||
_a_a_id, | ||
_a_a_distance, | ||
_a_b_a, | ||
_a_b_b, | ||
_a_c_id, | ||
_a_c_distance); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// automatically generated by the FlatBuffers compiler, do not modify | ||
|
||
package MyGame.Example | ||
|
||
import java.nio.* | ||
import kotlin.math.sign | ||
import com.google.flatbuffers.* | ||
|
||
@Suppress("unused") | ||
class StructOfStructsOfStructs : Struct() { | ||
|
||
fun __init(_i: Int, _bb: ByteBuffer) { | ||
__reset(_i, _bb) | ||
} | ||
fun __assign(_i: Int, _bb: ByteBuffer) : StructOfStructsOfStructs { | ||
__init(_i, _bb) | ||
return this | ||
} | ||
val a : MyGame.Example.StructOfStructs? get() = a(MyGame.Example.StructOfStructs()) | ||
fun a(obj: MyGame.Example.StructOfStructs) : MyGame.Example.StructOfStructs? = obj.__assign(bb_pos + 0, bb) | ||
companion object { | ||
fun createStructOfStructsOfStructs(builder: FlatBufferBuilder, a_a_id: UInt, a_a_distance: UInt, a_b_a: Short, a_b_b: Byte, a_c_id: UInt, a_c_distance: UInt) : Int { | ||
builder.prep(4, 20) | ||
builder.prep(4, 20) | ||
builder.prep(4, 8) | ||
builder.putInt(a_c_distance.toInt()) | ||
builder.putInt(a_c_id.toInt()) | ||
builder.prep(2, 4) | ||
builder.pad(1) | ||
builder.putByte(a_b_b) | ||
builder.putShort(a_b_a) | ||
builder.prep(4, 8) | ||
builder.putInt(a_a_distance.toInt()) | ||
builder.putInt(a_a_id.toInt()) | ||
return builder.offset() | ||
} | ||
} | ||
} |
Oops, something went wrong.