Skip to content

Commit

Permalink
generate code
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind committed Sep 25, 2024
1 parent d11d1d9 commit e68854e
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 241 deletions.
96 changes: 33 additions & 63 deletions dart/test/keyword_test_keyword_test_generated.dart
Original file line number Diff line number Diff line change
@@ -1,45 +1,35 @@
// automatically generated by the FlatBuffers compiler, do not modify
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable, constant_identifier_names

library keyword_test;

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


class Abc {
enum Abc {
$void(0),
where(1),
stackalloc(2);

final int value;
const Abc._(this.value);
const Abc(this.value);

factory Abc.fromValue(int value) {
final result = values[value];
if (result == null) {
throw StateError('Invalid value $value for bit flag enum Abc');
switch (value) {
case 0: return Abc.$void;
case 1: return Abc.where;
case 2: return Abc.stackalloc;
default: throw StateError('Invalid value $value for bit flag enum');
}
return result;
}

static Abc? _createOrNull(int? value) =>
static Abc? _createOrNull(int? value) =>
value == null ? null : Abc.fromValue(value);

static const int minValue = 0;
static const int maxValue = 2;
static bool containsValue(int value) => values.containsKey(value);

static const Abc $void = Abc._(0);
static const Abc where = Abc._(1);
static const Abc stackalloc = Abc._(2);
static const Map<int, Abc> values = {
0: $void,
1: where,
2: stackalloc};

static const fb.Reader<Abc> reader = _AbcReader();

@override
String toString() {
return 'Abc{value: $value}';
}
}

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

class Public {
enum Public {
NONE(0);

final int value;
const Public._(this.value);
const Public(this.value);

factory Public.fromValue(int value) {
final result = values[value];
if (result == null) {
throw StateError('Invalid value $value for bit flag enum Public');
switch (value) {
case 0: return Public.NONE;
default: throw StateError('Invalid value $value for bit flag enum');
}
return result;
}

static Public? _createOrNull(int? value) =>
static Public? _createOrNull(int? value) =>
value == null ? null : Public.fromValue(value);

static const int minValue = 0;
static const int maxValue = 0;
static bool containsValue(int value) => values.containsKey(value);

static const Public NONE = Public._(0);
static const Map<int, Public> values = {
0: NONE};

static const fb.Reader<Public> reader = _PublicReader();

@override
String toString() {
return 'Public{value: $value}';
}
}

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

class KeywordsInUnionTypeId {
enum KeywordsInUnionTypeId {
NONE(0),
$static(1),
internal(2);

final int value;
const KeywordsInUnionTypeId._(this.value);
const KeywordsInUnionTypeId(this.value);

factory KeywordsInUnionTypeId.fromValue(int value) {
final result = values[value];
if (result == null) {
throw StateError('Invalid value $value for bit flag enum KeywordsInUnionTypeId');
switch (value) {
case 0: return KeywordsInUnionTypeId.NONE;
case 1: return KeywordsInUnionTypeId.$static;
case 2: return KeywordsInUnionTypeId.internal;
default: throw StateError('Invalid value $value for bit flag enum');
}
return result;
}

static KeywordsInUnionTypeId? _createOrNull(int? value) =>
static KeywordsInUnionTypeId? _createOrNull(int? value) =>
value == null ? null : KeywordsInUnionTypeId.fromValue(value);

static const int minValue = 0;
static const int maxValue = 2;
static bool containsValue(int value) => values.containsKey(value);

static const KeywordsInUnionTypeId NONE = KeywordsInUnionTypeId._(0);
static const KeywordsInUnionTypeId $static = KeywordsInUnionTypeId._(1);
static const KeywordsInUnionTypeId internal = KeywordsInUnionTypeId._(2);
static const Map<int, KeywordsInUnionTypeId> values = {
0: NONE,
1: $static,
2: internal};

static const fb.Reader<KeywordsInUnionTypeId> reader = _KeywordsInUnionTypeIdReader();

@override
String toString() {
return 'KeywordsInUnionTypeId{value: $value}';
}
}

class _KeywordsInUnionTypeIdReader extends fb.Reader<KeywordsInUnionTypeId> {
Expand Down
2 changes: 1 addition & 1 deletion tests/include_test1_generated.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// automatically generated by the FlatBuffers compiler, do not modify
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable, constant_identifier_names

import 'dart:typed_data' show Uint8List;
import 'package:flat_buffers/flat_buffers.dart' as fb;
Expand Down
28 changes: 9 additions & 19 deletions tests/include_test2_my_game.other_name_space_generated.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// automatically generated by the FlatBuffers compiler, do not modify
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable, constant_identifier_names

library my_game.other_name_space;

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

import './include_test1_generated.dart';

class FromInclude {
enum FromInclude {
IncludeVal(0);

final int value;
const FromInclude._(this.value);
const FromInclude(this.value);

factory FromInclude.fromValue(int value) {
final result = values[value];
if (result == null) {
throw StateError('Invalid value $value for bit flag enum FromInclude');
switch (value) {
case 0: return FromInclude.IncludeVal;
default: throw StateError('Invalid value $value for bit flag enum');
}
return result;
}

static FromInclude? _createOrNull(int? value) =>
static FromInclude? _createOrNull(int? value) =>
value == null ? null : FromInclude.fromValue(value);

static const int minValue = 0;
static const int maxValue = 0;
static bool containsValue(int value) => values.containsKey(value);

static const FromInclude IncludeVal = FromInclude._(0);
static const Map<int, FromInclude> values = {
0: IncludeVal};

static const fb.Reader<FromInclude> reader = _FromIncludeReader();

@override
String toString() {
return 'FromInclude{value: $value}';
}
}

class _FromIncludeReader extends fb.Reader<FromInclude> {
Expand Down
2 changes: 1 addition & 1 deletion tests/monster_extra_my_game_generated.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// automatically generated by the FlatBuffers compiler, do not modify
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable, constant_identifier_names

library my_game;

Expand Down
2 changes: 1 addition & 1 deletion tests/monster_test_my_game.example2_generated.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// automatically generated by the FlatBuffers compiler, do not modify
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable
// ignore_for_file: unused_import, unused_field, unused_element, unused_local_variable, constant_identifier_names

library my_game.example2;

Expand Down
Loading

0 comments on commit e68854e

Please sign in to comment.