Dart 2.0 release prep (#6759)

* Dart - pubspec.yaml shouldn't contain authors section anymore - it's unused

* Dart - update CHANGELOG.md

* Dart - update test and publish scripts
This commit is contained in:
Ivan Dlugos 2021-08-02 22:31:36 +02:00 committed by GitHub
parent e012054667
commit 97d9527f6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 185 additions and 26 deletions

View File

@ -1,4 +1,21 @@
# CHANGELOG
## 2.0.0
- switch to null safety (#6696)
- add Object APIs (pack/unpack) (#6682, #6723)
- add custom builder buffer allocator support (#6711)
- add Builder.size() - finished buffer size (#6403)
- make `writeString()` argument non-nullable (#6737)
- make tables fixed size (expect the number of fields when creating) (#6735)
- make table deduplication optional (param `deduplicateTables`) (#6734)
- change Builder.reset() to reuse an existing buffer (#6661)
- change table building to assert() instead of exceptions (#6754)
- optimize `writeString()` for ASCII (param `asciiOptimization`) (#6736)
- change `StringReader` to make ASCII optimization optional (param `asciiOptimization`) (#6758)
- rename `lowFinish()` to `buffer` getter (#6712)
- fix Builder._writeString() - always write trailing zero byte (#6390)
- fix Builder.reset() - clear vTables (#6386)
- make sure added padding is zeroed, same as in C++ (#6716)
- many performance improvements (#6755)
## 1.9.2

View File

@ -21,17 +21,12 @@ set -e
command -v dart >/dev/null 2>&1 || { echo >&2 "Require `dart` but it's not installed. Aborting."; exit 1; }
cp ../samples/monster.fbs example/
cp ../tests/monster_test.fbs test/
cp -r ../tests/include_test/*.fbs test/
cp -r ../tests/include_test/sub test/
pushd example
../../flatc --dart ./monster.fbs
pushd ../tests
./DartTest.sh
popd
pushd test
../../flatc --dart ./monster_test.fbs
pushd ../samples
./dart_sample.sh
popd
dart pub publish

View File

@ -1,15 +1,11 @@
name: flat_buffers
version: 2.0.0
description: >
FlatBuffers reading and writing library for Dart. Use the flatc compiler to
FlatBuffers reading and writing library for Dart. Use the flatc compiler to
generate Dart classes for a FlatBuffers schema, and this library to assist with
reading and writing the binary format.
Based on original work by Konstantin Scheglov and Paul Berry of the Dart SDK team.
authors:
- Dan Field <dfield@gmail.com>
- Konstantin Scheglov
- Paul Berry
homepage: https://github.com/google/flatbuffers
documentation: https://google.github.io/flatbuffers/index.html
dev_dependencies:

154
dart/test/monster_test.fbs Normal file
View File

@ -0,0 +1,154 @@
// test schema file
include "include_test1.fbs";
namespace MyGame;
table InParentNamespace {}
namespace MyGame.Example2;
table Monster {} // Test having same name as below, but in different namespace.
namespace MyGame.Example;
attribute "priority";
/// Composite components of Monster color.
enum Color:ubyte (bit_flags) {
Red = 0, // color Red = (1u << 0)
/// \brief color Green
/// Green is bit_flag with value (1u << 1)
Green,
/// \brief color Blue (1u << 3)
Blue = 3,
}
enum Race:byte {
None = -1,
Human = 0,
Dwarf,
Elf,
}
union Any { Monster, TestSimpleTableWithEnum, MyGame.Example2.Monster }
union AnyUniqueAliases { M: Monster, TS: TestSimpleTableWithEnum, M2: MyGame.Example2.Monster }
union AnyAmbiguousAliases { M1: Monster, M2: Monster, M3: Monster }
struct Test { a:short; b:byte; }
table TestSimpleTableWithEnum (csharp_partial, private) {
color: Color = Green;
}
struct Vec3 (force_align: 8) {
x:float;
y:float;
z:float;
test1:double;
test2:Color;
test3:Test;
}
struct Ability {
id:uint(key);
distance:uint;
}
struct StructOfStructs {
a: Ability;
b: Test;
c: Ability;
}
table Stat {
id:string;
val:long;
count:ushort (key);
}
table Referrable {
id:ulong(key, hash:"fnv1a_64");
}
/// an example documentation comment: "monster object"
table Monster {
pos:Vec3 (id: 0);
hp:short = 100 (id: 2);
mana:short = 150 (id: 1);
name:string (id: 3, key);
color:Color = Blue (id: 6);
inventory:[ubyte] (id: 5);
friendly:bool = false (deprecated, priority: 1, id: 4);
/// an example documentation comment: this will end up in the generated code
/// multiline too
testarrayoftables:[Monster] (id: 11);
testarrayofstring:[string] (id: 10);
testarrayofstring2:[string] (id: 28);
testarrayofbools:[bool] (id: 24);
testarrayofsortedstruct:[Ability] (id: 29);
enemy:MyGame.Example.Monster (id:12); // Test referring by full namespace.
test:Any (id: 8);
test4:[Test] (id: 9);
test5:[Test] (id: 31);
testnestedflatbuffer:[ubyte] (id:13, nested_flatbuffer: "Monster");
testempty:Stat (id:14);
testbool:bool (id:15);
testhashs32_fnv1:int (id:16, hash:"fnv1_32");
testhashu32_fnv1:uint (id:17, hash:"fnv1_32");
testhashs64_fnv1:long (id:18, hash:"fnv1_64");
testhashu64_fnv1:ulong (id:19, hash:"fnv1_64");
testhashs32_fnv1a:int (id:20, hash:"fnv1a_32");
testhashu32_fnv1a:uint (id:21, hash:"fnv1a_32", cpp_type:"Stat");
testhashs64_fnv1a:long (id:22, hash:"fnv1a_64");
testhashu64_fnv1a:ulong (id:23, hash:"fnv1a_64");
testf:float = 3.14159 (id:25);
testf2:float = 3 (id:26);
testf3:float (id:27);
flex:[ubyte] (id:30, flexbuffer);
vector_of_longs:[long] (id:32);
vector_of_doubles:[double] (id:33);
parent_namespace_test:InParentNamespace (id:34);
vector_of_referrables:[Referrable](id:35);
single_weak_reference:ulong(id:36, hash:"fnv1a_64", cpp_type:"ReferrableT");
vector_of_weak_references:[ulong](id:37, hash:"fnv1a_64", cpp_type:"ReferrableT");
vector_of_strong_referrables:[Referrable](id:38, cpp_ptr_type:"default_ptr_type"); //was shared_ptr
co_owning_reference:ulong(id:39, hash:"fnv1a_64", cpp_type:"ReferrableT", cpp_ptr_type:"naked"); //was shared_ptr as well
vector_of_co_owning_references:[ulong](id:40, hash:"fnv1a_64", cpp_type:"ReferrableT", cpp_ptr_type:"default_ptr_type", cpp_ptr_type_get:".get()"); //was shared_ptr
non_owning_reference:ulong(id:41, hash:"fnv1a_64", cpp_type:"ReferrableT", cpp_ptr_type:"naked", cpp_ptr_type_get:""); //was weak_ptr
vector_of_non_owning_references:[ulong](id:42, hash:"fnv1a_64", cpp_type:"ReferrableT", cpp_ptr_type:"naked", cpp_ptr_type_get:""); //was weak_ptr
any_unique:AnyUniqueAliases(id:44);
any_ambiguous:AnyAmbiguousAliases (id:46);
vector_of_enums:[Color] (id:47);
signed_enum:Race = None (id:48);
testrequirednestedflatbuffer:[ubyte] (id:49, nested_flatbuffer: "Monster");
scalar_key_sorted_tables:[Stat] (id: 50);
}
table TypeAliases {
i8:int8;
u8:uint8;
i16:int16;
u16:uint16;
i32:int32;
u32:uint32;
i64:int64;
u64:uint64;
f32:float32;
f64:float64;
v8:[int8];
vf64:[float64];
}
rpc_service MonsterStorage {
Store(Monster):Stat (streaming: "none");
Retrieve(Stat):Monster (streaming: "server", idempotent);
GetMaxHitPoint(Monster):Stat (streaming: "client");
GetMinMaxHitPoints(Monster):Stat (streaming: "bidi");
}
root_type Monster;
file_identifier "MONS";
file_extension "mon";

Binary file not shown.

View File

@ -28,14 +28,12 @@ if [[ "$sampledir" != "$currentdir" ]]; then
exit 1
fi
cd ../dart/example
# Run `flatc`. Note: This requires you to compile using `cmake` from the
# root `/flatbuffers` directory.
if [ -e ../../flatc ]; then
../../flatc --dart ../../samples/monster.fbs
elif [ -e ../../Debug/flatc ]; then
../../Debug/flatc --dart ../../samples/monster.fbs
if [ -e ../flatc ]; then
../flatc --dart -o ../dart/example/ monster.fbs
elif [ -e ../Debug/flatc ]; then
../Debug/flatc --dart -o ../dart/example/ monster.fbs
else
echo 'flatc' could not be found. Make sure to build FlatBuffers from the \
$rootdir directory.
@ -45,6 +43,7 @@ fi
echo Running the Dart sample.
# Execute the sample.
dart example.dart
dart ../dart/example/example.dart
cd ../../samples
# Copy the source schema so it is distributed when published to pub.dev
cp monster.fbs ../dart/example/

View File

@ -21,6 +21,7 @@ command -v dart >/dev/null 2>&1 || { echo >&2 "Dart tests require dart to be in
# distribute them and more people can more easily run the dart tests
../flatc --dart --gen-object-api -I include_test -o ../dart/test monster_test.fbs
cp monsterdata_test.mon ../dart/test
cp monster_test.fbs ../dart/test
cd ../dart
@ -28,6 +29,3 @@ cd ../dart
dart pub get
# Execute the sample.
dart test
# cleanup
rm ../dart/test/monsterdata_test.mon