本文整理匯總了Golang中github.com/google/flatbuffers/go.Builder.Pad方法的典型用法代碼示例。如果您正苦於以下問題:Golang Builder.Pad方法的具體用法?Golang Builder.Pad怎麽用?Golang Builder.Pad使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/google/flatbuffers/go.Builder
的用法示例。
在下文中一共展示了Builder.Pad方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: CreateTest
func CreateTest(builder *flatbuffers.Builder, a int16, b int8) flatbuffers.UOffsetT {
builder.Prep(2, 4)
builder.Pad(1)
builder.PrependInt8(b)
builder.PrependInt16(a)
return builder.Offset()
}
示例2: CreateVec3
func CreateVec3(builder *flatbuffers.Builder, x float32, y float32, z float32, test1 float64, test2 int8, test3_a int16, test3_b int8) flatbuffers.UOffsetT {
builder.Prep(16, 32)
builder.Pad(2)
builder.Prep(2, 4)
builder.Pad(1)
builder.PrependInt8(test3_b)
builder.PrependInt16(test3_a)
builder.Pad(1)
builder.PrependInt8(test2)
builder.PrependFloat64(test1)
builder.Pad(4)
builder.PrependFloat32(z)
builder.PrependFloat32(y)
builder.PrependFloat32(x)
return builder.Offset()
}
示例3: CheckByteLayout
//.........這裏部分代碼省略.........
0, 0, 0, 0, // length of vector (not in struct)
})
// test 13: vtable with 1 int16 and 2-vector of int16
b = flatbuffers.NewBuilder(0)
b.StartVector(flatbuffers.SizeInt16, 2, 1)
b.PrependInt16(0x1234)
b.PrependInt16(0x5678)
vecend = b.EndVector(2)
b.StartObject(2)
b.PrependUOffsetTSlot(1, vecend, 0)
b.PrependInt16Slot(0, 55, 0)
b.EndObject()
check([]byte{
8, 0, // vtable bytes
12, 0, // length of object
6, 0, // start of value 0 from end of vtable
8, 0, // start of value 1 from end of buffer
8, 0, 0, 0, // offset for start of vtable (int32)
0, 0, // padding
55, 0, // value 0
4, 0, 0, 0, // vector position from here
2, 0, 0, 0, // length of vector (uint32)
0x78, 0x56, // vector value 1
0x34, 0x12, // vector value 0
})
// test 14: vtable with 1 struct of 1 int8, 1 int16, 1 int32
b = flatbuffers.NewBuilder(0)
b.StartObject(1)
b.Prep(4+4+4, 0)
b.PrependInt8(55)
b.Pad(3)
b.PrependInt16(0x1234)
b.Pad(2)
b.PrependInt32(0x12345678)
structStart := b.Offset()
b.PrependStructSlot(0, structStart, 0)
b.EndObject()
check([]byte{
6, 0, // vtable bytes
16, 0, // end of object from here
4, 0, // start of struct from here
6, 0, 0, 0, // offset for start of vtable (int32)
0x78, 0x56, 0x34, 0x12, // value 2
0, 0, // padding
0x34, 0x12, // value 1
0, 0, 0, // padding
55, // value 0
})
// test 15: vtable with 1 vector of 2 struct of 2 int8
b = flatbuffers.NewBuilder(0)
b.StartVector(flatbuffers.SizeInt8*2, 2, 1)
b.PrependInt8(33)
b.PrependInt8(44)
b.PrependInt8(55)
b.PrependInt8(66)
vecend = b.EndVector(2)
b.StartObject(1)
b.PrependUOffsetTSlot(0, vecend, 0)
b.EndObject()
check([]byte{
6, 0, // vtable bytes
8, 0,