Skip to content

Commit e68854e

Browse files
committed
generate code
1 parent d11d1d9 commit e68854e

7 files changed

+132
-241
lines changed

dart/test/keyword_test_keyword_test_generated.dart

Lines changed: 33 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,35 @@
11
// automatically generated by the FlatBuffers compiler, do not modify
2-
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
2+
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable, constant_identifier_names
33

44
library keyword_test;
55

66
import 'dart:typed_data' show Uint8List;
77
import 'package:flat_buffers/flat_buffers.dart' as fb;
88

99

10-
class Abc {
10+
enum Abc {
11+
$void(0),
12+
where(1),
13+
stackalloc(2);
14+
1115
final int value;
12-
const Abc._(this.value);
16+
const Abc(this.value);
1317

1418
factory Abc.fromValue(int value) {
15-
final result = values[value];
16-
if (result == null) {
17-
throw StateError('Invalid value $value for bit flag enum Abc');
19+
switch (value) {
20+
case 0: return Abc.$void;
21+
case 1: return Abc.where;
22+
case 2: return Abc.stackalloc;
23+
default: throw StateError('Invalid value $value for bit flag enum');
1824
}
19-
return result;
2025
}
2126

22-
static Abc? _createOrNull(int? value) =>
27+
static Abc? _createOrNull(int? value) =>
2328
value == null ? null : Abc.fromValue(value);
2429

2530
static const int minValue = 0;
2631
static const int maxValue = 2;
27-
static bool containsValue(int value) => values.containsKey(value);
28-
29-
static const Abc $void = Abc._(0);
30-
static const Abc where = Abc._(1);
31-
static const Abc stackalloc = Abc._(2);
32-
static const Map<int, Abc> values = {
33-
0: $void,
34-
1: where,
35-
2: stackalloc};
36-
3732
static const fb.Reader<Abc> reader = _AbcReader();
38-
39-
@override
40-
String toString() {
41-
return 'Abc{value: $value}';
42-
}
4333
}
4434

4535
class _AbcReader extends fb.Reader<Abc> {
@@ -53,35 +43,25 @@ class _AbcReader extends fb.Reader<Abc> {
5343
Abc.fromValue(const fb.Int32Reader().read(bc, offset));
5444
}
5545

56-
class Public {
46+
enum Public {
47+
NONE(0);
48+
5749
final int value;
58-
const Public._(this.value);
50+
const Public(this.value);
5951

6052
factory Public.fromValue(int value) {
61-
final result = values[value];
62-
if (result == null) {
63-
throw StateError('Invalid value $value for bit flag enum Public');
53+
switch (value) {
54+
case 0: return Public.NONE;
55+
default: throw StateError('Invalid value $value for bit flag enum');
6456
}
65-
return result;
6657
}
6758

68-
static Public? _createOrNull(int? value) =>
59+
static Public? _createOrNull(int? value) =>
6960
value == null ? null : Public.fromValue(value);
7061

7162
static const int minValue = 0;
7263
static const int maxValue = 0;
73-
static bool containsValue(int value) => values.containsKey(value);
74-
75-
static const Public NONE = Public._(0);
76-
static const Map<int, Public> values = {
77-
0: NONE};
78-
7964
static const fb.Reader<Public> reader = _PublicReader();
80-
81-
@override
82-
String toString() {
83-
return 'Public{value: $value}';
84-
}
8565
}
8666

8767
class _PublicReader extends fb.Reader<Public> {
@@ -95,39 +75,29 @@ class _PublicReader extends fb.Reader<Public> {
9575
Public.fromValue(const fb.Int32Reader().read(bc, offset));
9676
}
9777

98-
class KeywordsInUnionTypeId {
78+
enum KeywordsInUnionTypeId {
79+
NONE(0),
80+
$static(1),
81+
internal(2);
82+
9983
final int value;
100-
const KeywordsInUnionTypeId._(this.value);
84+
const KeywordsInUnionTypeId(this.value);
10185

10286
factory KeywordsInUnionTypeId.fromValue(int value) {
103-
final result = values[value];
104-
if (result == null) {
105-
throw StateError('Invalid value $value for bit flag enum KeywordsInUnionTypeId');
87+
switch (value) {
88+
case 0: return KeywordsInUnionTypeId.NONE;
89+
case 1: return KeywordsInUnionTypeId.$static;
90+
case 2: return KeywordsInUnionTypeId.internal;
91+
default: throw StateError('Invalid value $value for bit flag enum');
10692
}
107-
return result;
10893
}
10994

110-
static KeywordsInUnionTypeId? _createOrNull(int? value) =>
95+
static KeywordsInUnionTypeId? _createOrNull(int? value) =>
11196
value == null ? null : KeywordsInUnionTypeId.fromValue(value);
11297

11398
static const int minValue = 0;
11499
static const int maxValue = 2;
115-
static bool containsValue(int value) => values.containsKey(value);
116-
117-
static const KeywordsInUnionTypeId NONE = KeywordsInUnionTypeId._(0);
118-
static const KeywordsInUnionTypeId $static = KeywordsInUnionTypeId._(1);
119-
static const KeywordsInUnionTypeId internal = KeywordsInUnionTypeId._(2);
120-
static const Map<int, KeywordsInUnionTypeId> values = {
121-
0: NONE,
122-
1: $static,
123-
2: internal};
124-
125100
static const fb.Reader<KeywordsInUnionTypeId> reader = _KeywordsInUnionTypeIdReader();
126-
127-
@override
128-
String toString() {
129-
return 'KeywordsInUnionTypeId{value: $value}';
130-
}
131101
}
132102

133103
class _KeywordsInUnionTypeIdReader extends fb.Reader<KeywordsInUnionTypeId> {

tests/include_test1_generated.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// automatically generated by the FlatBuffers compiler, do not modify
2-
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
2+
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable, constant_identifier_names
33

44
import 'dart:typed_data' show Uint8List;
55
import 'package:flat_buffers/flat_buffers.dart' as fb;

tests/include_test2_my_game.other_name_space_generated.dart

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// automatically generated by the FlatBuffers compiler, do not modify
2-
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
2+
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable, constant_identifier_names
33

44
library my_game.other_name_space;
55

@@ -9,35 +9,25 @@ import 'package:flat_buffers/flat_buffers.dart' as fb;
99

1010
import './include_test1_generated.dart';
1111

12-
class FromInclude {
12+
enum FromInclude {
13+
IncludeVal(0);
14+
1315
final int value;
14-
const FromInclude._(this.value);
16+
const FromInclude(this.value);
1517

1618
factory FromInclude.fromValue(int value) {
17-
final result = values[value];
18-
if (result == null) {
19-
throw StateError('Invalid value $value for bit flag enum FromInclude');
19+
switch (value) {
20+
case 0: return FromInclude.IncludeVal;
21+
default: throw StateError('Invalid value $value for bit flag enum');
2022
}
21-
return result;
2223
}
2324

24-
static FromInclude? _createOrNull(int? value) =>
25+
static FromInclude? _createOrNull(int? value) =>
2526
value == null ? null : FromInclude.fromValue(value);
2627

2728
static const int minValue = 0;
2829
static const int maxValue = 0;
29-
static bool containsValue(int value) => values.containsKey(value);
30-
31-
static const FromInclude IncludeVal = FromInclude._(0);
32-
static const Map<int, FromInclude> values = {
33-
0: IncludeVal};
34-
3530
static const fb.Reader<FromInclude> reader = _FromIncludeReader();
36-
37-
@override
38-
String toString() {
39-
return 'FromInclude{value: $value}';
40-
}
4131
}
4232

4333
class _FromIncludeReader extends fb.Reader<FromInclude> {

tests/monster_extra_my_game_generated.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// automatically generated by the FlatBuffers compiler, do not modify
2-
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
2+
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable, constant_identifier_names
33

44
library my_game;
55

tests/monster_test_my_game.example2_generated.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// automatically generated by the FlatBuffers compiler, do not modify
2-
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
2+
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable, constant_identifier_names
33

44
library my_game.example2;
55

0 commit comments

Comments
 (0)