[Go] Change two more sites to use enum types (#5359)
Fixes #5357 (regression introduced by #5235)
This commit is contained in:
parent
fe83b68ac6
commit
c5e2d37337
|
@ -497,7 +497,7 @@ class GoGenerator : public BaseGenerator {
|
|||
std::string &code = *code_ptr;
|
||||
code += std::string(", ") + nameprefix;
|
||||
code += GoIdentity(field.name);
|
||||
code += " " + GenTypeBasic(field.value.type);
|
||||
code += " " + TypeName(field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -525,7 +525,7 @@ class GoGenerator : public BaseGenerator {
|
|||
(nameprefix + (field.name + "_")).c_str(), code_ptr);
|
||||
} else {
|
||||
code += "\tbuilder.Prepend" + GenMethod(field) + "(";
|
||||
code += nameprefix + GoIdentity(field.name) + ")\n";
|
||||
code += CastToBaseType(field.value.type, nameprefix + GoIdentity(field.name)) + ")\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -556,7 +556,7 @@ class GoGenerator : public BaseGenerator {
|
|||
if (!IsScalar(field.value.type.base_type) && (!struct_def.fixed)) {
|
||||
code += "flatbuffers.UOffsetT";
|
||||
} else {
|
||||
code += GenTypeBasic(field.value.type);
|
||||
code += TypeName(field);
|
||||
}
|
||||
code += ") {\n";
|
||||
code += "\tbuilder.Prepend";
|
||||
|
@ -567,7 +567,7 @@ class GoGenerator : public BaseGenerator {
|
|||
code += "(";
|
||||
code += GoIdentity(field.name) + ")";
|
||||
} else {
|
||||
code += GoIdentity(field.name);
|
||||
code += CastToBaseType(field.value.type, GoIdentity(field.name));
|
||||
}
|
||||
code += ", " + GenConstant(field);
|
||||
code += ")\n}\n";
|
||||
|
|
|
@ -836,11 +836,11 @@ func MonsterAddInventory(builder *flatbuffers.Builder, inventory flatbuffers.UOf
|
|||
func MonsterStartInventoryVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT {
|
||||
return builder.StartVector(1, numElems, 1)
|
||||
}
|
||||
func MonsterAddColor(builder *flatbuffers.Builder, color byte) {
|
||||
builder.PrependByteSlot(6, color, 8)
|
||||
func MonsterAddColor(builder *flatbuffers.Builder, color Color) {
|
||||
builder.PrependByteSlot(6, byte(color), 8)
|
||||
}
|
||||
func MonsterAddTestType(builder *flatbuffers.Builder, testType byte) {
|
||||
builder.PrependByteSlot(7, testType, 0)
|
||||
func MonsterAddTestType(builder *flatbuffers.Builder, testType Any) {
|
||||
builder.PrependByteSlot(7, byte(testType), 0)
|
||||
}
|
||||
func MonsterAddTest(builder *flatbuffers.Builder, test flatbuffers.UOffsetT) {
|
||||
builder.PrependUOffsetTSlot(8, flatbuffers.UOffsetT(test), 0)
|
||||
|
@ -995,14 +995,14 @@ func MonsterAddVectorOfNonOwningReferences(builder *flatbuffers.Builder, vectorO
|
|||
func MonsterStartVectorOfNonOwningReferencesVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT {
|
||||
return builder.StartVector(8, numElems, 8)
|
||||
}
|
||||
func MonsterAddAnyUniqueType(builder *flatbuffers.Builder, anyUniqueType byte) {
|
||||
builder.PrependByteSlot(43, anyUniqueType, 0)
|
||||
func MonsterAddAnyUniqueType(builder *flatbuffers.Builder, anyUniqueType AnyUniqueAliases) {
|
||||
builder.PrependByteSlot(43, byte(anyUniqueType), 0)
|
||||
}
|
||||
func MonsterAddAnyUnique(builder *flatbuffers.Builder, anyUnique flatbuffers.UOffsetT) {
|
||||
builder.PrependUOffsetTSlot(44, flatbuffers.UOffsetT(anyUnique), 0)
|
||||
}
|
||||
func MonsterAddAnyAmbiguousType(builder *flatbuffers.Builder, anyAmbiguousType byte) {
|
||||
builder.PrependByteSlot(45, anyAmbiguousType, 0)
|
||||
func MonsterAddAnyAmbiguousType(builder *flatbuffers.Builder, anyAmbiguousType AnyAmbiguousAliases) {
|
||||
builder.PrependByteSlot(45, byte(anyAmbiguousType), 0)
|
||||
}
|
||||
func MonsterAddAnyAmbiguous(builder *flatbuffers.Builder, anyAmbiguous flatbuffers.UOffsetT) {
|
||||
builder.PrependUOffsetTSlot(46, flatbuffers.UOffsetT(anyAmbiguous), 0)
|
||||
|
|
|
@ -41,8 +41,8 @@ func (rcv *TestSimpleTableWithEnum) MutateColor(n Color) bool {
|
|||
func TestSimpleTableWithEnumStart(builder *flatbuffers.Builder) {
|
||||
builder.StartObject(1)
|
||||
}
|
||||
func TestSimpleTableWithEnumAddColor(builder *flatbuffers.Builder, color byte) {
|
||||
builder.PrependByteSlot(0, color, 2)
|
||||
func TestSimpleTableWithEnumAddColor(builder *flatbuffers.Builder, color Color) {
|
||||
builder.PrependByteSlot(0, byte(color), 2)
|
||||
}
|
||||
func TestSimpleTableWithEnumEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
|
||||
return builder.EndObject()
|
||||
|
|
|
@ -62,7 +62,7 @@ func (rcv *Vec3) Test3(obj *Test) *Test {
|
|||
return obj
|
||||
}
|
||||
|
||||
func CreateVec3(builder *flatbuffers.Builder, x float32, y float32, z float32, test1 float64, test2 byte, test3_a int16, test3_b int8) flatbuffers.UOffsetT {
|
||||
func CreateVec3(builder *flatbuffers.Builder, x float32, y float32, z float32, test1 float64, test2 Color, test3_a int16, test3_b int8) flatbuffers.UOffsetT {
|
||||
builder.Prep(8, 32)
|
||||
builder.Pad(2)
|
||||
builder.Prep(2, 4)
|
||||
|
@ -70,7 +70,7 @@ func CreateVec3(builder *flatbuffers.Builder, x float32, y float32, z float32, t
|
|||
builder.PrependInt8(test3_b)
|
||||
builder.PrependInt16(test3_a)
|
||||
builder.Pad(1)
|
||||
builder.PrependByte(test2)
|
||||
builder.PrependByte(byte(test2))
|
||||
builder.PrependFloat64(test1)
|
||||
builder.Pad(4)
|
||||
builder.PrependFloat32(z)
|
||||
|
|
|
@ -1189,7 +1189,7 @@ func CheckGeneratedBuild(fail func(string, ...interface{})) ([]byte, flatbuffers
|
|||
|
||||
example.MonsterStart(b)
|
||||
|
||||
pos := example.CreateVec3(b, 1.0, 2.0, 3.0, 3.0, 2, 5, 6)
|
||||
pos := example.CreateVec3(b, 1.0, 2.0, 3.0, 3.0, example.ColorGreen, 5, 6)
|
||||
example.MonsterAddPos(b, pos)
|
||||
|
||||
example.MonsterAddHp(b, 80)
|
||||
|
@ -1479,11 +1479,12 @@ func CheckDocExample(buf []byte, off flatbuffers.UOffsetT, fail func(string, ...
|
|||
|
||||
str := builder.CreateString("MyMonster")
|
||||
example.MonsterStart(builder)
|
||||
example.MonsterAddPos(builder, example.CreateVec3(builder, 1.0, 2.0, 3.0, 3.0, 4, 5, 6))
|
||||
example.MonsterAddPos(builder, example.CreateVec3(builder, 1.0, 2.0, 3.0, 3.0, example.Color(4), 5, 6))
|
||||
example.MonsterAddHp(builder, 80)
|
||||
example.MonsterAddName(builder, str)
|
||||
example.MonsterAddInventory(builder, inv)
|
||||
example.MonsterAddTestType(builder, 1)
|
||||
example.MonsterAddColor(builder, example.ColorRed)
|
||||
// example.MonsterAddTest(builder, mon2)
|
||||
// example.MonsterAddTest4(builder, test4s)
|
||||
_ = example.MonsterEnd(builder)
|
||||
|
@ -1871,7 +1872,7 @@ func BenchmarkBuildGold(b *testing.B) {
|
|||
|
||||
example.MonsterStart(bldr)
|
||||
|
||||
pos := example.CreateVec3(bldr, 1.0, 2.0, 3.0, 3.0, 2, 5, 6)
|
||||
pos := example.CreateVec3(bldr, 1.0, 2.0, 3.0, 3.0, example.ColorGreen, 5, 6)
|
||||
example.MonsterAddPos(bldr, pos)
|
||||
|
||||
example.MonsterAddHp(bldr, 80)
|
||||
|
|
|
@ -72,8 +72,8 @@ func TableInFirstNSStart(builder *flatbuffers.Builder) {
|
|||
func TableInFirstNSAddFooTable(builder *flatbuffers.Builder, fooTable flatbuffers.UOffsetT) {
|
||||
builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(fooTable), 0)
|
||||
}
|
||||
func TableInFirstNSAddFooEnum(builder *flatbuffers.Builder, fooEnum int8) {
|
||||
builder.PrependInt8Slot(1, fooEnum, 0)
|
||||
func TableInFirstNSAddFooEnum(builder *flatbuffers.Builder, fooEnum EnumInNestedNS) {
|
||||
builder.PrependInt8Slot(1, int8(fooEnum), 0)
|
||||
}
|
||||
func TableInFirstNSAddFooStruct(builder *flatbuffers.Builder, fooStruct flatbuffers.UOffsetT) {
|
||||
builder.PrependStructSlot(2, flatbuffers.UOffsetT(fooStruct), 0)
|
||||
|
|
Loading…
Reference in New Issue