mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-24 07:51:48 +00:00
Dart null safety (#6696)
* Dart null-safety - prepare migration annotations in library files * Dart null-safety - apply migration * Dart null-safety - update flatc to generate valid code * Dart null-safety - fix flatc generated code and adjust tests * Dart null-safety - update example and the generated code in the tests folder * Dart null safety - minor review changes * Dart - apply `dartfmt -w .`
This commit is contained in:
@@ -39,26 +39,26 @@ class CheckOtherLangaugesData {
|
||||
expect(mon.hp, 80);
|
||||
expect(mon.mana, 150);
|
||||
expect(mon.name, 'MyMonster');
|
||||
expect(mon.pos.x, 1.0);
|
||||
expect(mon.pos.y, 2.0);
|
||||
expect(mon.pos.z, 3.0);
|
||||
expect(mon.pos.test1, 3.0);
|
||||
expect(mon.pos.test2.value, 2.0);
|
||||
expect(mon.pos.test3.a, 5);
|
||||
expect(mon.pos.test3.b, 6);
|
||||
expect(mon.testType.value, example.AnyTypeId.Monster.value);
|
||||
expect(mon.pos!.x, 1.0);
|
||||
expect(mon.pos!.y, 2.0);
|
||||
expect(mon.pos!.z, 3.0);
|
||||
expect(mon.pos!.test1, 3.0);
|
||||
expect(mon.pos!.test2.value, 2.0);
|
||||
expect(mon.pos!.test3.a, 5);
|
||||
expect(mon.pos!.test3.b, 6);
|
||||
expect(mon.testType!.value, example.AnyTypeId.Monster.value);
|
||||
expect(mon.test is example.Monster, true);
|
||||
final monster2 = mon.test as example.Monster;
|
||||
expect(monster2.name, "Fred");
|
||||
|
||||
expect(mon.inventory.length, 5);
|
||||
expect(mon.inventory.reduce((cur, next) => cur + next), 10);
|
||||
expect(mon.test4.length, 2);
|
||||
expect(
|
||||
mon.test4[0].a + mon.test4[0].b + mon.test4[1].a + mon.test4[1].b, 100);
|
||||
expect(mon.testarrayofstring.length, 2);
|
||||
expect(mon.testarrayofstring[0], "test1");
|
||||
expect(mon.testarrayofstring[1], "test2");
|
||||
expect(mon.inventory!.length, 5);
|
||||
expect(mon.inventory!.reduce((cur, next) => cur + next), 10);
|
||||
final test4 = mon.test4!;
|
||||
expect(test4.length, 2);
|
||||
expect(test4[0].a + test4[0].b + test4[1].a + test4[1].b, 100);
|
||||
expect(mon.testarrayofstring!.length, 2);
|
||||
expect(mon.testarrayofstring![0], "test1");
|
||||
expect(mon.testarrayofstring![1], "test2");
|
||||
|
||||
// this will fail if accessing any field fails.
|
||||
expect(
|
||||
@@ -68,7 +68,7 @@ class CheckOtherLangaugesData {
|
||||
'mana: 150, hp: 80, name: MyMonster, inventory: [0, 1, 2, 3, 4], '
|
||||
'color: Color{value: 8}, testType: AnyTypeId{value: 1}, '
|
||||
'test: Monster{pos: null, mana: 150, hp: 100, name: Fred, '
|
||||
'inventory: null, color: Color{value: 8}, testType: AnyTypeId{value: 0}, '
|
||||
'inventory: null, color: Color{value: 8}, testType: null, '
|
||||
'test: null, test4: null, testarrayofstring: null, '
|
||||
'testarrayoftables: null, enemy: null, testnestedflatbuffer: null, '
|
||||
'testempty: null, testbool: false, testhashs32Fnv1: 0, '
|
||||
@@ -82,14 +82,13 @@ class CheckOtherLangaugesData {
|
||||
'vectorOfWeakReferences: null, vectorOfStrongReferrables: null, '
|
||||
'coOwningReference: 0, vectorOfCoOwningReferences: null, '
|
||||
'nonOwningReference: 0, vectorOfNonOwningReferences: null, '
|
||||
'anyUniqueType: AnyUniqueAliasesTypeId{value: 0}, anyUnique: null, '
|
||||
'anyAmbiguousType: AnyAmbiguousAliasesTypeId{value: 0}, '
|
||||
'anyUniqueType: null, anyUnique: null, anyAmbiguousType: null, '
|
||||
'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race{value: -1}, '
|
||||
'testrequirednestedflatbuffer: null, scalarKeySortedTables: null}, '
|
||||
'test4: [Test{a: 10, b: 20}, Test{a: 30, b: 40}], '
|
||||
'testarrayofstring: [test1, test2], testarrayoftables: null, '
|
||||
'enemy: Monster{pos: null, mana: 150, hp: 100, name: Fred, '
|
||||
'inventory: null, color: Color{value: 8}, testType: AnyTypeId{value: 0}, '
|
||||
'inventory: null, color: Color{value: 8}, testType: null, '
|
||||
'test: null, test4: null, testarrayofstring: null, '
|
||||
'testarrayoftables: null, enemy: null, testnestedflatbuffer: null, '
|
||||
'testempty: null, testbool: false, testhashs32Fnv1: 0, '
|
||||
@@ -103,8 +102,7 @@ class CheckOtherLangaugesData {
|
||||
'vectorOfWeakReferences: null, vectorOfStrongReferrables: null, '
|
||||
'coOwningReference: 0, vectorOfCoOwningReferences: null, '
|
||||
'nonOwningReference: 0, vectorOfNonOwningReferences: null, '
|
||||
'anyUniqueType: AnyUniqueAliasesTypeId{value: 0}, anyUnique: null, '
|
||||
'anyAmbiguousType: AnyAmbiguousAliasesTypeId{value: 0}, '
|
||||
'anyUniqueType: null, anyUnique: null, anyAmbiguousType: null, '
|
||||
'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race{value: -1}, '
|
||||
'testrequirednestedflatbuffer: null, scalarKeySortedTables: null}, '
|
||||
'testnestedflatbuffer: null, testempty: null, testbool: true, '
|
||||
@@ -126,8 +124,8 @@ class CheckOtherLangaugesData {
|
||||
'vectorOfStrongReferrables: null, coOwningReference: 0, '
|
||||
'vectorOfCoOwningReferences: null, nonOwningReference: 0, '
|
||||
'vectorOfNonOwningReferences: null, '
|
||||
'anyUniqueType: AnyUniqueAliasesTypeId{value: 0}, anyUnique: null, '
|
||||
'anyAmbiguousType: AnyAmbiguousAliasesTypeId{value: 0}, '
|
||||
'anyUniqueType: null, anyUnique: null, '
|
||||
'anyAmbiguousType: null, '
|
||||
'anyAmbiguous: null, vectorOfEnums: null, signedEnum: Race{value: -1}, '
|
||||
'testrequirednestedflatbuffer: null, scalarKeySortedTables: [Stat{id: '
|
||||
'miss, val: 0, count: 0}, Stat{id: hit, val: 10, count: 1}]}',
|
||||
@@ -137,7 +135,7 @@ class CheckOtherLangaugesData {
|
||||
|
||||
@reflectiveTest
|
||||
class BuilderTest {
|
||||
void test_monsterBuilder([Builder builder]) {
|
||||
void test_monsterBuilder([Builder? builder]) {
|
||||
final fbBuilder = builder ?? new Builder();
|
||||
final str = fbBuilder.writeString('MyMonster');
|
||||
|
||||
@@ -183,10 +181,10 @@ class BuilderTest {
|
||||
fbBuilder.finish(mon);
|
||||
}
|
||||
|
||||
void test_error_addInt32_withoutStartTable([Builder builder]) {
|
||||
void test_error_addInt32_withoutStartTable([Builder? builder]) {
|
||||
builder ??= new Builder();
|
||||
expect(() {
|
||||
builder.addInt32(0, 0);
|
||||
builder!.addInt32(0, 0);
|
||||
}, throwsStateError);
|
||||
}
|
||||
|
||||
@@ -288,7 +286,7 @@ class BuilderTest {
|
||||
20);
|
||||
}
|
||||
|
||||
void test_table_format([Builder builder]) {
|
||||
void test_table_format([Builder? builder]) {
|
||||
Uint8List byteList;
|
||||
{
|
||||
builder ??= new Builder(initialSize: 0);
|
||||
@@ -326,8 +324,8 @@ class BuilderTest {
|
||||
List<int> byteList;
|
||||
{
|
||||
Builder builder = new Builder(initialSize: 0);
|
||||
int latinStringOffset = builder.writeString(latinString);
|
||||
int unicodeStringOffset = builder.writeString(unicodeString);
|
||||
int? latinStringOffset = builder.writeString(latinString);
|
||||
int? unicodeStringOffset = builder.writeString(unicodeString);
|
||||
builder.startTable();
|
||||
builder.addOffset(0, latinStringOffset);
|
||||
builder.addOffset(1, unicodeStringOffset);
|
||||
@@ -337,17 +335,21 @@ class BuilderTest {
|
||||
// read and verify
|
||||
BufferContext buf = new BufferContext.fromBytes(byteList);
|
||||
int objectOffset = buf.derefObject(0);
|
||||
expect(const StringReader().vTableGet(buf, objectOffset, indexToField(0)),
|
||||
expect(
|
||||
const StringReader()
|
||||
.vTableGetNullable(buf, objectOffset, indexToField(0)),
|
||||
latinString);
|
||||
expect(const StringReader().vTableGet(buf, objectOffset, indexToField(1)),
|
||||
expect(
|
||||
const StringReader()
|
||||
.vTableGetNullable(buf, objectOffset, indexToField(1)),
|
||||
unicodeString);
|
||||
}
|
||||
|
||||
void test_table_types([Builder builder]) {
|
||||
void test_table_types([Builder? builder]) {
|
||||
List<int> byteList;
|
||||
{
|
||||
builder ??= new Builder(initialSize: 0);
|
||||
int stringOffset = builder.writeString('12345');
|
||||
int? stringOffset = builder.writeString('12345');
|
||||
builder.startTable();
|
||||
builder.addBool(0, true);
|
||||
builder.addInt8(1, 10);
|
||||
@@ -363,18 +365,32 @@ class BuilderTest {
|
||||
BufferContext buf = new BufferContext.fromBytes(byteList);
|
||||
int objectOffset = buf.derefObject(0);
|
||||
expect(
|
||||
const BoolReader().vTableGet(buf, objectOffset, indexToField(0)), true);
|
||||
const BoolReader()
|
||||
.vTableGetNullable(buf, objectOffset, indexToField(0)),
|
||||
true);
|
||||
expect(
|
||||
const Int8Reader().vTableGet(buf, objectOffset, indexToField(1)), 10);
|
||||
const Int8Reader()
|
||||
.vTableGetNullable(buf, objectOffset, indexToField(1)),
|
||||
10);
|
||||
expect(
|
||||
const Int32Reader().vTableGet(buf, objectOffset, indexToField(2)), 20);
|
||||
expect(const StringReader().vTableGet(buf, objectOffset, indexToField(3)),
|
||||
const Int32Reader()
|
||||
.vTableGetNullable(buf, objectOffset, indexToField(2)),
|
||||
20);
|
||||
expect(
|
||||
const StringReader()
|
||||
.vTableGetNullable(buf, objectOffset, indexToField(3)),
|
||||
'12345');
|
||||
expect(
|
||||
const Int32Reader().vTableGet(buf, objectOffset, indexToField(4)), 40);
|
||||
expect(const Uint32Reader().vTableGet(buf, objectOffset, indexToField(5)),
|
||||
const Int32Reader()
|
||||
.vTableGetNullable(buf, objectOffset, indexToField(4)),
|
||||
40);
|
||||
expect(
|
||||
const Uint32Reader()
|
||||
.vTableGetNullable(buf, objectOffset, indexToField(5)),
|
||||
0x9ABCDEF0);
|
||||
expect(const Uint8Reader().vTableGet(buf, objectOffset, indexToField(6)),
|
||||
expect(
|
||||
const Uint8Reader()
|
||||
.vTableGetNullable(buf, objectOffset, indexToField(6)),
|
||||
0x9A);
|
||||
}
|
||||
|
||||
@@ -488,7 +504,7 @@ class BuilderTest {
|
||||
}
|
||||
}
|
||||
|
||||
void test_writeList_ofObjects([Builder builder]) {
|
||||
void test_writeList_ofObjects([Builder? builder]) {
|
||||
List<int> byteList;
|
||||
{
|
||||
builder ??= new Builder(initialSize: 0);
|
||||
@@ -527,9 +543,9 @@ class BuilderTest {
|
||||
List<int> byteList;
|
||||
{
|
||||
Builder builder = new Builder(initialSize: 0);
|
||||
int str1 = builder.writeString('12345');
|
||||
int str2 = builder.writeString('ABC');
|
||||
int offset = builder.writeList([str1, str2]);
|
||||
int? str1 = builder.writeString('12345');
|
||||
int? str2 = builder.writeString('ABC');
|
||||
int offset = builder.writeList([str1!, str2!]);
|
||||
byteList = builder.finish(offset);
|
||||
}
|
||||
// read and verify
|
||||
@@ -541,12 +557,12 @@ class BuilderTest {
|
||||
expect(items, contains('ABC'));
|
||||
}
|
||||
|
||||
void test_writeList_ofStrings_inObject([Builder builder]) {
|
||||
void test_writeList_ofStrings_inObject([Builder? builder]) {
|
||||
List<int> byteList;
|
||||
{
|
||||
builder ??= new Builder(initialSize: 0);
|
||||
int listOffset = builder.writeList(
|
||||
[builder.writeString('12345'), builder.writeString('ABC')]);
|
||||
[builder.writeString('12345')!, builder.writeString('ABC')!]);
|
||||
builder.startTable();
|
||||
builder.addOffset(0, listOffset);
|
||||
int offset = builder.endTable();
|
||||
@@ -555,7 +571,7 @@ class BuilderTest {
|
||||
// read and verify
|
||||
BufferContext buf = new BufferContext.fromBytes(byteList);
|
||||
StringListWrapperImpl reader = new StringListWrapperReader().read(buf, 0);
|
||||
List<String> items = reader.items;
|
||||
List<String>? items = reader.items;
|
||||
expect(items, hasLength(2));
|
||||
expect(items, contains('12345'));
|
||||
expect(items, contains('ABC'));
|
||||
@@ -605,7 +621,7 @@ class BuilderTest {
|
||||
|
||||
void test_reset() {
|
||||
// We'll run a selection of tests , reusing the builder between them.
|
||||
final testCases = <void Function(Builder)>[
|
||||
final testCases = <void Function(Builder?)>[
|
||||
test_monsterBuilder,
|
||||
test_error_addInt32_withoutStartTable,
|
||||
test_table_format,
|
||||
@@ -624,14 +640,14 @@ class BuilderTest {
|
||||
// print the order so failures are reproducible
|
||||
printOnFailure('Running reset() test cases in order: $indexes');
|
||||
|
||||
Builder builder;
|
||||
Builder? builder;
|
||||
indexes.forEach((index) {
|
||||
if (builder == null) {
|
||||
// Initial size small enough so at least one test case increases it.
|
||||
// On the other hand, it's large enough so that some test cases don't.
|
||||
builder = Builder(initialSize: 32);
|
||||
} else {
|
||||
builder.reset();
|
||||
builder!.reset();
|
||||
}
|
||||
testCases[index](builder);
|
||||
});
|
||||
@@ -739,8 +755,8 @@ class StringListWrapperImpl {
|
||||
|
||||
StringListWrapperImpl(this.bp, this.offset);
|
||||
|
||||
List<String> get items => const ListReader<String>(const StringReader())
|
||||
.vTableGet(bp, offset, indexToField(0));
|
||||
List<String>? get items => const ListReader<String>(const StringReader())
|
||||
.vTableGetNullable(bp, offset, indexToField(0));
|
||||
}
|
||||
|
||||
class StringListWrapperReader extends TableReader<StringListWrapperImpl> {
|
||||
|
||||
@@ -58,18 +58,18 @@ void main() {
|
||||
{
|
||||
var flx = Builder();
|
||||
flx.addString('hello 😱');
|
||||
expect(flx.finish(), [10, 104, 101, 108, 108, 111, 32, 240, 159, 152, 177, 0, 11, 20, 1]);
|
||||
expect(flx.finish(),
|
||||
[10, 104, 101, 108, 108, 111, 32, 240, 159, 152, 177, 0, 11, 20, 1]);
|
||||
}
|
||||
});
|
||||
|
||||
test('build vector', (){
|
||||
test('build vector', () {
|
||||
{
|
||||
var flx = Builder()
|
||||
..startVector()
|
||||
..addInt(1)
|
||||
..addInt(2)
|
||||
..end()
|
||||
;
|
||||
..end();
|
||||
expect(flx.finish(), [1, 2, 2, 64, 1]);
|
||||
}
|
||||
{
|
||||
@@ -77,8 +77,7 @@ void main() {
|
||||
..startVector()
|
||||
..addInt(-1)
|
||||
..addInt(256)
|
||||
..end()
|
||||
;
|
||||
..end();
|
||||
expect(flx.finish(), [255, 255, 0, 1, 4, 65, 1]);
|
||||
}
|
||||
{
|
||||
@@ -86,8 +85,7 @@ void main() {
|
||||
..startVector()
|
||||
..addInt(-45)
|
||||
..addInt(256000)
|
||||
..end()
|
||||
;
|
||||
..end();
|
||||
expect(flx.finish(), [211, 255, 255, 255, 0, 232, 3, 0, 8, 66, 1]);
|
||||
}
|
||||
{
|
||||
@@ -95,9 +93,28 @@ void main() {
|
||||
..startVector()
|
||||
..addDouble(1.1)
|
||||
..addDouble(-256)
|
||||
..end()
|
||||
;
|
||||
expect(flx.finish(), [154, 153, 153, 153, 153, 153, 241, 63, 0, 0, 0, 0, 0, 0, 112, 192, 16, 75, 1]);
|
||||
..end();
|
||||
expect(flx.finish(), [
|
||||
154,
|
||||
153,
|
||||
153,
|
||||
153,
|
||||
153,
|
||||
153,
|
||||
241,
|
||||
63,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
112,
|
||||
192,
|
||||
16,
|
||||
75,
|
||||
1
|
||||
]);
|
||||
}
|
||||
{
|
||||
var flx = Builder()
|
||||
@@ -105,8 +122,7 @@ void main() {
|
||||
..addInt(1)
|
||||
..addInt(2)
|
||||
..addInt(4)
|
||||
..end()
|
||||
;
|
||||
..end();
|
||||
expect(flx.finish(), [1, 2, 4, 3, 76, 1]);
|
||||
}
|
||||
{
|
||||
@@ -115,19 +131,17 @@ void main() {
|
||||
..addInt(-1)
|
||||
..addInt(256)
|
||||
..addInt(4)
|
||||
..end()
|
||||
;
|
||||
..end();
|
||||
expect(flx.finish(), [255, 255, 0, 1, 4, 0, 6, 77, 1]);
|
||||
}
|
||||
{
|
||||
var flx = Builder()
|
||||
..startVector()
|
||||
..startVector()
|
||||
..addInt(61)
|
||||
..end()
|
||||
..addInt(64)
|
||||
..startVector()
|
||||
..addInt(61)
|
||||
..end()
|
||||
;
|
||||
..addInt(64)
|
||||
..end();
|
||||
expect(flx.finish(), [1, 61, 2, 2, 64, 44, 4, 4, 40, 1]);
|
||||
}
|
||||
{
|
||||
@@ -136,9 +150,31 @@ void main() {
|
||||
..addString('foo')
|
||||
..addString('bar')
|
||||
..addString('baz')
|
||||
..end()
|
||||
;
|
||||
expect(flx.finish(), [3, 102, 111, 111, 0, 3, 98, 97, 114, 0, 3, 98, 97, 122, 0, 3, 15, 11, 7, 3, 60, 1]);
|
||||
..end();
|
||||
expect(flx.finish(), [
|
||||
3,
|
||||
102,
|
||||
111,
|
||||
111,
|
||||
0,
|
||||
3,
|
||||
98,
|
||||
97,
|
||||
114,
|
||||
0,
|
||||
3,
|
||||
98,
|
||||
97,
|
||||
122,
|
||||
0,
|
||||
3,
|
||||
15,
|
||||
11,
|
||||
7,
|
||||
3,
|
||||
60,
|
||||
1
|
||||
]);
|
||||
}
|
||||
{
|
||||
var flx = Builder()
|
||||
@@ -149,9 +185,34 @@ void main() {
|
||||
..addString('foo')
|
||||
..addString('bar')
|
||||
..addString('baz')
|
||||
..end()
|
||||
;
|
||||
expect(flx.finish(), [3, 102, 111, 111, 0, 3, 98, 97, 114, 0, 3, 98, 97, 122, 0, 6, 15, 11, 7, 18, 14, 10, 6, 60, 1]);
|
||||
..end();
|
||||
expect(flx.finish(), [
|
||||
3,
|
||||
102,
|
||||
111,
|
||||
111,
|
||||
0,
|
||||
3,
|
||||
98,
|
||||
97,
|
||||
114,
|
||||
0,
|
||||
3,
|
||||
98,
|
||||
97,
|
||||
122,
|
||||
0,
|
||||
6,
|
||||
15,
|
||||
11,
|
||||
7,
|
||||
18,
|
||||
14,
|
||||
10,
|
||||
6,
|
||||
60,
|
||||
1
|
||||
]);
|
||||
}
|
||||
{
|
||||
var flx = Builder()
|
||||
@@ -159,8 +220,7 @@ void main() {
|
||||
..addBool(true)
|
||||
..addBool(false)
|
||||
..addBool(true)
|
||||
..end()
|
||||
;
|
||||
..end();
|
||||
expect(flx.finish(), [3, 1, 0, 1, 3, 144, 1]);
|
||||
}
|
||||
{
|
||||
@@ -171,29 +231,83 @@ void main() {
|
||||
..addInt(-5)
|
||||
..addDouble(1.3)
|
||||
..addBool(true)
|
||||
..end()
|
||||
;
|
||||
..end();
|
||||
expect(flx.finish(), [
|
||||
3, 102, 111, 111, 0, 0, 0, 0,
|
||||
5, 0, 0, 0, 0, 0, 0, 0,
|
||||
15, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 0, 0, 0, 0, 0, 0, 0,
|
||||
251, 255, 255, 255, 255, 255, 255, 255,
|
||||
205, 204, 204, 204, 204, 204, 244, 63,
|
||||
1, 0, 0, 0, 0, 0, 0, 0,
|
||||
20, 4, 4, 15, 104, 45, 43, 1]);
|
||||
3,
|
||||
102,
|
||||
111,
|
||||
111,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
5,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
15,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
251,
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
205,
|
||||
204,
|
||||
204,
|
||||
204,
|
||||
204,
|
||||
204,
|
||||
244,
|
||||
63,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
20,
|
||||
4,
|
||||
4,
|
||||
15,
|
||||
104,
|
||||
45,
|
||||
43,
|
||||
1
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
test('build map', ()
|
||||
{
|
||||
test('build map', () {
|
||||
{
|
||||
var flx = Builder()
|
||||
..startMap()
|
||||
..addKey('a')
|
||||
..addInt(12)
|
||||
..end()
|
||||
;
|
||||
..end();
|
||||
expect(flx.finish(), [97, 0, 1, 3, 1, 1, 1, 12, 4, 2, 36, 1]);
|
||||
}
|
||||
{
|
||||
@@ -203,105 +317,270 @@ void main() {
|
||||
..addInt(12)
|
||||
..addKey('')
|
||||
..addInt(45)
|
||||
..end()
|
||||
;
|
||||
expect(flx.finish(), [97, 0, 0, 2, 2, 5, 2, 1, 2, 45, 12, 4, 4, 4, 36, 1]);
|
||||
..end();
|
||||
expect(
|
||||
flx.finish(), [97, 0, 0, 2, 2, 5, 2, 1, 2, 45, 12, 4, 4, 4, 36, 1]);
|
||||
}
|
||||
{
|
||||
var flx = Builder()
|
||||
..startVector()
|
||||
..startMap()
|
||||
..addKey('something')
|
||||
..addInt(12)
|
||||
..end()
|
||||
..startMap()
|
||||
..addKey('something')
|
||||
..addInt(45)
|
||||
..end()
|
||||
..startMap()
|
||||
..addKey('something')
|
||||
..addInt(12)
|
||||
..end()
|
||||
;
|
||||
expect(flx.finish(), [115, 111, 109, 101, 116, 104, 105, 110, 103, 0,
|
||||
1, 11, 1, 1, 1, 12, 4, 6, 1, 1, 45, 4, 2, 8, 4, 36, 36, 4, 40, 1]);
|
||||
..startMap()
|
||||
..addKey('something')
|
||||
..addInt(45)
|
||||
..end()
|
||||
..end();
|
||||
expect(flx.finish(), [
|
||||
115,
|
||||
111,
|
||||
109,
|
||||
101,
|
||||
116,
|
||||
104,
|
||||
105,
|
||||
110,
|
||||
103,
|
||||
0,
|
||||
1,
|
||||
11,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
12,
|
||||
4,
|
||||
6,
|
||||
1,
|
||||
1,
|
||||
45,
|
||||
4,
|
||||
2,
|
||||
8,
|
||||
4,
|
||||
36,
|
||||
36,
|
||||
4,
|
||||
40,
|
||||
1
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
test('build blob', ()
|
||||
{
|
||||
test('build blob', () {
|
||||
{
|
||||
var flx = Builder()
|
||||
..addBlob(Uint8List.fromList([1, 2, 3]).buffer)
|
||||
;
|
||||
var flx = Builder()..addBlob(Uint8List.fromList([1, 2, 3]).buffer);
|
||||
expect(flx.finish(), [3, 1, 2, 3, 3, 100, 1]);
|
||||
}
|
||||
});
|
||||
|
||||
test('build from object', (){
|
||||
expect(Builder.buildFromObject(Uint8List.fromList([1, 2, 3]).buffer).asUint8List(), [3, 1, 2, 3, 3, 100, 1]);
|
||||
test('build from object', () {
|
||||
expect(
|
||||
Builder.buildFromObject(Uint8List.fromList([1, 2, 3]).buffer)
|
||||
.asUint8List(),
|
||||
[3, 1, 2, 3, 3, 100, 1]);
|
||||
expect(Builder.buildFromObject(null).asUint8List(), [0, 0, 1]);
|
||||
expect(Builder.buildFromObject(true).asUint8List(), [1, 104, 1]);
|
||||
expect(Builder.buildFromObject(false).asUint8List(), [0, 104, 1]);
|
||||
expect(Builder.buildFromObject(25).asUint8List(), [25, 4, 1]);
|
||||
expect(Builder.buildFromObject(-250).asUint8List(), [6, 255, 5, 2]);
|
||||
expect(Builder.buildFromObject(-2.50).asUint8List(), [0, 0, 32, 192, 14, 4]);
|
||||
expect(Builder.buildFromObject('Maxim').asUint8List(), [5, 77, 97, 120, 105, 109, 0, 6, 20, 1]);
|
||||
expect(Builder.buildFromObject([1, 3.3, 'max', true, null, false]).asUint8List(), [
|
||||
3, 109, 97, 120, 0, 0, 0, 0,
|
||||
6, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 0, 0, 0, 0, 0, 0, 0,
|
||||
102, 102, 102, 102, 102, 102, 10, 64,
|
||||
31, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
4, 15, 20, 104, 0, 104, 54, 43, 1
|
||||
]);
|
||||
expect(Builder.buildFromObject([{'something':12}, {'something': 45}]).asUint8List(), [
|
||||
115, 111, 109, 101, 116, 104, 105, 110, 103, 0,
|
||||
1, 11, 1, 1, 1, 12, 4, 6, 1, 1, 45, 4, 2, 8, 4, 36, 36, 4, 40, 1
|
||||
]);
|
||||
expect(
|
||||
Builder.buildFromObject(-2.50).asUint8List(), [0, 0, 32, 192, 14, 4]);
|
||||
expect(Builder.buildFromObject('Maxim').asUint8List(),
|
||||
[5, 77, 97, 120, 105, 109, 0, 6, 20, 1]);
|
||||
expect(
|
||||
Builder.buildFromObject([1, 3.3, 'max', true, null, false])
|
||||
.asUint8List(),
|
||||
[
|
||||
3,
|
||||
109,
|
||||
97,
|
||||
120,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
6,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
102,
|
||||
102,
|
||||
102,
|
||||
102,
|
||||
102,
|
||||
102,
|
||||
10,
|
||||
64,
|
||||
31,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
4,
|
||||
15,
|
||||
20,
|
||||
104,
|
||||
0,
|
||||
104,
|
||||
54,
|
||||
43,
|
||||
1
|
||||
]);
|
||||
expect(
|
||||
Builder.buildFromObject([
|
||||
{'something': 12},
|
||||
{'something': 45}
|
||||
]).asUint8List(),
|
||||
[
|
||||
115,
|
||||
111,
|
||||
109,
|
||||
101,
|
||||
116,
|
||||
104,
|
||||
105,
|
||||
110,
|
||||
103,
|
||||
0,
|
||||
1,
|
||||
11,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
12,
|
||||
4,
|
||||
6,
|
||||
1,
|
||||
1,
|
||||
45,
|
||||
4,
|
||||
2,
|
||||
8,
|
||||
4,
|
||||
36,
|
||||
36,
|
||||
4,
|
||||
40,
|
||||
1
|
||||
]);
|
||||
});
|
||||
|
||||
test('add double indirectly', (){
|
||||
var flx = Builder()
|
||||
..addDoubleIndirectly(0.1)
|
||||
;
|
||||
test('add double indirectly', () {
|
||||
var flx = Builder()..addDoubleIndirectly(0.1);
|
||||
expect(flx.finish(), [154, 153, 153, 153, 153, 153, 185, 63, 8, 35, 1]);
|
||||
});
|
||||
|
||||
test('add double indirectly to vector with cache', (){
|
||||
test('add double indirectly to vector with cache', () {
|
||||
var flx = Builder()
|
||||
..startVector()
|
||||
..addDoubleIndirectly(0.1, cache: true)
|
||||
..addDoubleIndirectly(0.1, cache: true)
|
||||
..addDoubleIndirectly(0.1, cache: true)
|
||||
..addDoubleIndirectly(0.1, cache: true)
|
||||
..end()
|
||||
;
|
||||
expect(flx.finish(), [154, 153, 153, 153, 153, 153, 185, 63,
|
||||
4, 9, 10, 11, 12, 35, 35, 35, 35, 8, 40, 1]);
|
||||
..end();
|
||||
expect(flx.finish(), [
|
||||
154,
|
||||
153,
|
||||
153,
|
||||
153,
|
||||
153,
|
||||
153,
|
||||
185,
|
||||
63,
|
||||
4,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
35,
|
||||
35,
|
||||
35,
|
||||
35,
|
||||
8,
|
||||
40,
|
||||
1
|
||||
]);
|
||||
});
|
||||
|
||||
test('add int indirectly', (){
|
||||
var flx = Builder()
|
||||
..addIntIndirectly(2345234523452345)
|
||||
;
|
||||
test('add int indirectly', () {
|
||||
var flx = Builder()..addIntIndirectly(2345234523452345);
|
||||
expect(flx.finish(), [185, 115, 175, 118, 250, 84, 8, 0, 8, 27, 1]);
|
||||
});
|
||||
|
||||
test('add int indirectly to vector with cache', (){
|
||||
test('add int indirectly to vector with cache', () {
|
||||
var flx = Builder()
|
||||
..startVector()
|
||||
..addIntIndirectly(2345234523452345, cache: true)
|
||||
..addIntIndirectly(2345234523452345, cache: true)
|
||||
..addIntIndirectly(2345234523452345, cache: true)
|
||||
..addIntIndirectly(2345234523452345, cache: true)
|
||||
..end()
|
||||
;
|
||||
expect(flx.finish(), [185, 115, 175, 118, 250, 84, 8, 0,
|
||||
4, 9, 10, 11, 12, 27, 27, 27, 27, 8, 40, 1]);
|
||||
..end();
|
||||
expect(flx.finish(), [
|
||||
185,
|
||||
115,
|
||||
175,
|
||||
118,
|
||||
250,
|
||||
84,
|
||||
8,
|
||||
0,
|
||||
4,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
27,
|
||||
27,
|
||||
27,
|
||||
27,
|
||||
8,
|
||||
40,
|
||||
1
|
||||
]);
|
||||
});
|
||||
|
||||
test('snapshot', (){
|
||||
test('snapshot', () {
|
||||
var flx = Builder();
|
||||
flx.startVector();
|
||||
flx.addInt(12);
|
||||
@@ -312,4 +591,3 @@ void main() {
|
||||
expect(flx.snapshot().asUint8List(), [12, 24, 45, 3, 76, 1]);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -48,69 +48,116 @@ void main() {
|
||||
expect(ValueTypeUtils.isFixedTypedVector(ValueType.VectorInt), isFalse);
|
||||
});
|
||||
test('to typed vector', () {
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.Int,0), equals(ValueType.VectorInt));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.UInt,0), equals(ValueType.VectorUInt));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.Bool,0), equals(ValueType.VectorBool));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.Float,0), equals(ValueType.VectorFloat));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.Key,0), equals(ValueType.VectorKey));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.String,0), equals(ValueType.VectorString));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.Int, 0),
|
||||
equals(ValueType.VectorInt));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.UInt, 0),
|
||||
equals(ValueType.VectorUInt));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.Bool, 0),
|
||||
equals(ValueType.VectorBool));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.Float, 0),
|
||||
equals(ValueType.VectorFloat));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.Key, 0),
|
||||
equals(ValueType.VectorKey));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.String, 0),
|
||||
equals(ValueType.VectorString));
|
||||
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.Int,2), equals(ValueType.VectorInt2));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.UInt,2), equals(ValueType.VectorUInt2));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.Float,2), equals(ValueType.VectorFloat2));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.Int, 2),
|
||||
equals(ValueType.VectorInt2));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.UInt, 2),
|
||||
equals(ValueType.VectorUInt2));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.Float, 2),
|
||||
equals(ValueType.VectorFloat2));
|
||||
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.Int,3), equals(ValueType.VectorInt3));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.UInt,3), equals(ValueType.VectorUInt3));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.Float,3), equals(ValueType.VectorFloat3));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.Int, 3),
|
||||
equals(ValueType.VectorInt3));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.UInt, 3),
|
||||
equals(ValueType.VectorUInt3));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.Float, 3),
|
||||
equals(ValueType.VectorFloat3));
|
||||
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.Int,4), equals(ValueType.VectorInt4));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.UInt,4), equals(ValueType.VectorUInt4));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.Float,4), equals(ValueType.VectorFloat4));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.Int, 4),
|
||||
equals(ValueType.VectorInt4));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.UInt, 4),
|
||||
equals(ValueType.VectorUInt4));
|
||||
expect(ValueTypeUtils.toTypedVector(ValueType.Float, 4),
|
||||
equals(ValueType.VectorFloat4));
|
||||
});
|
||||
test('typed vector element type', () {
|
||||
expect(ValueTypeUtils.typedVectorElementType(ValueType.VectorInt), equals(ValueType.Int));
|
||||
expect(ValueTypeUtils.typedVectorElementType(ValueType.VectorUInt), equals(ValueType.UInt));
|
||||
expect(ValueTypeUtils.typedVectorElementType(ValueType.VectorFloat), equals(ValueType.Float));
|
||||
expect(ValueTypeUtils.typedVectorElementType(ValueType.VectorString), equals(ValueType.String));
|
||||
expect(ValueTypeUtils.typedVectorElementType(ValueType.VectorKey), equals(ValueType.Key));
|
||||
expect(ValueTypeUtils.typedVectorElementType(ValueType.VectorBool), equals(ValueType.Bool));
|
||||
expect(ValueTypeUtils.typedVectorElementType(ValueType.VectorInt),
|
||||
equals(ValueType.Int));
|
||||
expect(ValueTypeUtils.typedVectorElementType(ValueType.VectorUInt),
|
||||
equals(ValueType.UInt));
|
||||
expect(ValueTypeUtils.typedVectorElementType(ValueType.VectorFloat),
|
||||
equals(ValueType.Float));
|
||||
expect(ValueTypeUtils.typedVectorElementType(ValueType.VectorString),
|
||||
equals(ValueType.String));
|
||||
expect(ValueTypeUtils.typedVectorElementType(ValueType.VectorKey),
|
||||
equals(ValueType.Key));
|
||||
expect(ValueTypeUtils.typedVectorElementType(ValueType.VectorBool),
|
||||
equals(ValueType.Bool));
|
||||
});
|
||||
test('fixed typed vector element type', () {
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementType(ValueType.VectorInt2), equals(ValueType.Int));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementType(ValueType.VectorInt3), equals(ValueType.Int));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementType(ValueType.VectorInt4), equals(ValueType.Int));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementType(ValueType.VectorInt2),
|
||||
equals(ValueType.Int));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementType(ValueType.VectorInt3),
|
||||
equals(ValueType.Int));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementType(ValueType.VectorInt4),
|
||||
equals(ValueType.Int));
|
||||
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementType(ValueType.VectorUInt2), equals(ValueType.UInt));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementType(ValueType.VectorUInt3), equals(ValueType.UInt));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementType(ValueType.VectorUInt4), equals(ValueType.UInt));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementType(ValueType.VectorUInt2),
|
||||
equals(ValueType.UInt));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementType(ValueType.VectorUInt3),
|
||||
equals(ValueType.UInt));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementType(ValueType.VectorUInt4),
|
||||
equals(ValueType.UInt));
|
||||
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementType(ValueType.VectorFloat2), equals(ValueType.Float));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementType(ValueType.VectorFloat3), equals(ValueType.Float));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementType(ValueType.VectorFloat4), equals(ValueType.Float));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementType(ValueType.VectorFloat2),
|
||||
equals(ValueType.Float));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementType(ValueType.VectorFloat3),
|
||||
equals(ValueType.Float));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementType(ValueType.VectorFloat4),
|
||||
equals(ValueType.Float));
|
||||
});
|
||||
test('fixed typed vector element size', () {
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementSize(ValueType.VectorInt2), equals(2));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementSize(ValueType.VectorInt3), equals(3));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementSize(ValueType.VectorInt4), equals(4));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementSize(ValueType.VectorInt2),
|
||||
equals(2));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementSize(ValueType.VectorInt3),
|
||||
equals(3));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementSize(ValueType.VectorInt4),
|
||||
equals(4));
|
||||
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementSize(ValueType.VectorUInt2), equals(2));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementSize(ValueType.VectorUInt3), equals(3));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementSize(ValueType.VectorUInt4), equals(4));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementSize(ValueType.VectorUInt2),
|
||||
equals(2));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementSize(ValueType.VectorUInt3),
|
||||
equals(3));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementSize(ValueType.VectorUInt4),
|
||||
equals(4));
|
||||
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementSize(ValueType.VectorFloat2), equals(2));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementSize(ValueType.VectorFloat3), equals(3));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementSize(ValueType.VectorFloat4), equals(4));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementSize(ValueType.VectorFloat2),
|
||||
equals(2));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementSize(ValueType.VectorFloat3),
|
||||
equals(3));
|
||||
expect(ValueTypeUtils.fixedTypedVectorElementSize(ValueType.VectorFloat4),
|
||||
equals(4));
|
||||
});
|
||||
test('packed type', () {
|
||||
expect(ValueTypeUtils.packedType(ValueType.Null, BitWidth.width8), equals(0));
|
||||
expect(ValueTypeUtils.packedType(ValueType.Null, BitWidth.width16), equals(1));
|
||||
expect(ValueTypeUtils.packedType(ValueType.Null, BitWidth.width32), equals(2));
|
||||
expect(ValueTypeUtils.packedType(ValueType.Null, BitWidth.width64), equals(3));
|
||||
expect(
|
||||
ValueTypeUtils.packedType(ValueType.Null, BitWidth.width8), equals(0));
|
||||
expect(
|
||||
ValueTypeUtils.packedType(ValueType.Null, BitWidth.width16), equals(1));
|
||||
expect(
|
||||
ValueTypeUtils.packedType(ValueType.Null, BitWidth.width32), equals(2));
|
||||
expect(
|
||||
ValueTypeUtils.packedType(ValueType.Null, BitWidth.width64), equals(3));
|
||||
|
||||
expect(ValueTypeUtils.packedType(ValueType.Int, BitWidth.width8), equals(4));
|
||||
expect(ValueTypeUtils.packedType(ValueType.Int, BitWidth.width16), equals(5));
|
||||
expect(ValueTypeUtils.packedType(ValueType.Int, BitWidth.width32), equals(6));
|
||||
expect(ValueTypeUtils.packedType(ValueType.Int, BitWidth.width64), equals(7));
|
||||
expect(
|
||||
ValueTypeUtils.packedType(ValueType.Int, BitWidth.width8), equals(4));
|
||||
expect(
|
||||
ValueTypeUtils.packedType(ValueType.Int, BitWidth.width16), equals(5));
|
||||
expect(
|
||||
ValueTypeUtils.packedType(ValueType.Int, BitWidth.width32), equals(6));
|
||||
expect(
|
||||
ValueTypeUtils.packedType(ValueType.Int, BitWidth.width64), equals(7));
|
||||
});
|
||||
test('bit width', () {
|
||||
expect(BitWidthUtil.width(0), BitWidth.width8);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// ignore_for_file: unused_import, unused_field, unused_local_variable
|
||||
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
|
||||
|
||||
library my_game.example2;
|
||||
|
||||
@@ -29,7 +29,7 @@ class Monster {
|
||||
|
||||
MonsterT unpack() => MonsterT();
|
||||
|
||||
static int pack(fb.Builder fbBuilder, MonsterT object) {
|
||||
static int pack(fb.Builder fbBuilder, MonsterT? object) {
|
||||
if (object == null) return 0;
|
||||
return object.pack(fbBuilder);
|
||||
}
|
||||
@@ -37,8 +37,6 @@ class Monster {
|
||||
|
||||
class MonsterT {
|
||||
int pack(fb.Builder fbBuilder) {
|
||||
assert(fbBuilder != null);
|
||||
|
||||
fbBuilder.startTable();
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
@@ -63,17 +61,14 @@ class MonsterObjectBuilder extends fb.ObjectBuilder {
|
||||
|
||||
/// Finish building, and store into the [fbBuilder].
|
||||
@override
|
||||
int finish(
|
||||
fb.Builder fbBuilder) {
|
||||
assert(fbBuilder != null);
|
||||
|
||||
int finish(fb.Builder fbBuilder) {
|
||||
fbBuilder.startTable();
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
|
||||
/// Convenience method to serialize to byte list.
|
||||
@override
|
||||
Uint8List toBytes([String fileIdentifier]) {
|
||||
Uint8List toBytes([String? fileIdentifier]) {
|
||||
fb.Builder fbBuilder = new fb.Builder();
|
||||
int offset = finish(fbBuilder);
|
||||
return fbBuilder.finish(offset, fileIdentifier);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// ignore_for_file: unused_import, unused_field, unused_local_variable
|
||||
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
|
||||
|
||||
library my_game;
|
||||
|
||||
@@ -29,7 +29,7 @@ class InParentNamespace {
|
||||
|
||||
InParentNamespaceT unpack() => InParentNamespaceT();
|
||||
|
||||
static int pack(fb.Builder fbBuilder, InParentNamespaceT object) {
|
||||
static int pack(fb.Builder fbBuilder, InParentNamespaceT? object) {
|
||||
if (object == null) return 0;
|
||||
return object.pack(fbBuilder);
|
||||
}
|
||||
@@ -37,8 +37,6 @@ class InParentNamespace {
|
||||
|
||||
class InParentNamespaceT {
|
||||
int pack(fb.Builder fbBuilder) {
|
||||
assert(fbBuilder != null);
|
||||
|
||||
fbBuilder.startTable();
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
@@ -63,17 +61,14 @@ class InParentNamespaceObjectBuilder extends fb.ObjectBuilder {
|
||||
|
||||
/// Finish building, and store into the [fbBuilder].
|
||||
@override
|
||||
int finish(
|
||||
fb.Builder fbBuilder) {
|
||||
assert(fbBuilder != null);
|
||||
|
||||
int finish(fb.Builder fbBuilder) {
|
||||
fbBuilder.startTable();
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
|
||||
/// Convenience method to serialize to byte list.
|
||||
@override
|
||||
Uint8List toBytes([String fileIdentifier]) {
|
||||
Uint8List toBytes([String? fileIdentifier]) {
|
||||
fb.Builder fbBuilder = new fb.Builder();
|
||||
int offset = finish(fbBuilder);
|
||||
return fbBuilder.finish(offset, fileIdentifier);
|
||||
|
||||
Reference in New Issue
Block a user