Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(650)

Unified Diff: mojo/dart/packages/_mojo_for_test_only/lib/mojo/test/test_enums.mojom.dart

Issue 1943643002: Go bindings: Change generated enum value constants to be typed as the enum type. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | mojo/go/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/dart/packages/_mojo_for_test_only/lib/mojo/test/test_enums.mojom.dart
diff --git a/mojo/dart/packages/_mojo_for_test_only/lib/mojo/test/test_enums.mojom.dart b/mojo/dart/packages/_mojo_for_test_only/lib/mojo/test/test_enums.mojom.dart
index b6f3ca9a836810c5b42753f8939bb62430592854..e39162d7af4e1eac1c227bdf43d3bebab9ced32d 100644
--- a/mojo/dart/packages/_mojo_for_test_only/lib/mojo/test/test_enums.mojom.dart
+++ b/mojo/dart/packages/_mojo_for_test_only/lib/mojo/test/test_enums.mojom.dart
@@ -77,6 +77,72 @@ class TestEnum extends bindings.MojoEnum {
int toJson() => mojoEnumValue;
}
+class TestEnum2 extends bindings.MojoEnum {
+ static const TestEnum2 test = const TestEnum2._(0);
+ static const TestEnum2 v = const TestEnum2._(1);
+ static const TestEnum2 foo = const TestEnum2._(2);
+ static const TestEnum2 bar = const TestEnum2._(3);
+
+ const TestEnum2._(int v) : super(v);
+
+ static const Map<String, TestEnum2> valuesMap = const {
+ "test": test,
+ "v": v,
+ "foo": foo,
+ "bar": bar,
+ };
+ static const List<TestEnum2> values = const [
+ test,
+ v,
+ foo,
+ bar,
+ ];
+
+ static TestEnum2 valueOf(String name) => valuesMap[name];
+
+ factory TestEnum2(int v) {
+ switch (v) {
+ case 0:
+ return TestEnum2.test;
+ case 1:
+ return TestEnum2.v;
+ case 2:
+ return TestEnum2.foo;
+ case 3:
+ return TestEnum2.bar;
+ default:
+ return null;
+ }
+ }
+
+ static TestEnum2 decode(bindings.Decoder decoder0, int offset) {
+ int v = decoder0.decodeUint32(offset);
+ TestEnum2 result = new TestEnum2(v);
+ if (result == null) {
+ throw new bindings.MojoCodecError(
+ 'Bad value $v for enum TestEnum2.');
+ }
+ return result;
+ }
+
+ String toString() {
+ switch(this) {
+ case test:
+ return 'TestEnum2.test';
+ case v:
+ return 'TestEnum2.v';
+ case foo:
+ return 'TestEnum2.foo';
+ case bar:
+ return 'TestEnum2.bar';
+ default:
+ return null;
+ }
+ }
+
+ int toJson() => mojoEnumValue;
+}
+
mojom_types.RuntimeTypeInfo getRuntimeTypeInfo() => _runtimeTypeInfo ??
@@ -91,7 +157,7 @@ mojom_types.RuntimeTypeInfo _initRuntimeTypeInfo() {
// serializedRuntimeTypeInfo contains the bytes of the Mojo serialization of
// a mojom_types.RuntimeTypeInfo struct describing the Mojom types in this
// file. The string contains the base64 encoding of the gzip-compressed bytes.
- var serializedRuntimeTypeInfo = "H4sIAAAJbogC/5JggAABKG0ApdHFYTQHGo2uzgGJz4ikThmIpYE4JDLANd7bNdIqNz8rX68ktbhELwRIuOaV5sLNY8RiH7o9L9DsY0BzvwWU/g8FHgzYgQDUDpgjpIBsISDG4TwMdzADMSsQhwOxPxDrZ+TnpuoXlabk52bmpRbpg8zRLy5KhjAKSpNyMpP1M/NKUovSEpNTi/WTMvNSMvPSi/VBdkHI+FSgbcV6IA25DBpAM1mAWAFqXwIjhF7ABKEfMKP6WwPmMUZUd0owovqb0nDjgborxDU4BMSXB2JxrOGmB1aCHm4gvUw0DDdi05sANA7Rw4FQODJSKRw5oWaFQfkyQCyCPRzDsKU/1kEWjowkhiMTlcKRG2q/m78/mC8HxGLYwxGsBD0c2QZZODKRGI7MVA5HJ8cgQuEIVoIejuyDLBxh4QIIAAD//1XEaKPoBgAA";
+ var serializedRuntimeTypeInfo = "H4sIAAAJbogC/5JggAABKG0ApdHFYTQHGo2urgBJnAmLucpALA3EIZEBrvHerpFWuflZ+XolqcUleiFAwjWvNBesTgWIZfCrMwKp00CzB909HmzYxV9AaQcGVABzpwWU/g8FHgzYgQA0LGCOkgKyhYAYh7cw3MEMxKxAHA7E/kCsn5Gfm6pfVJqSn5uZl1qkDzJHv7goGcIoKE3KyUzWz8wrSS1KS0xOLdZPysxLycxLL9YH2QUh41OBthXrgTTkgsOHBYgVoPYlMELoBUwQ+gEzqr81YB5jRHWnBCOqvykNNx6ou0Jcg0NAfHkgFscabnpgJejhxgKNd1qFG7HpVAAah+jhQCgcGakUjpxQs8KgfFCeEcEejmHY0h/rIAtHRhLDkYlK4cgNtd/N3x/MlwNiMezhCFaCHo5sgywcmUgMR2Yqh6OTYxChcAQrQQ9H9kEWjsw46pUPBMLLAS28AnCElyA0D6NUalA3CmMNNyOs7uGicz0SAE03E6AJ7QKBegQXoHY9ogANGyzhBq5I0MONm8bpjdh2zEDXG7JALIoj3MKwpDeeQRJug63ewN2OMQJXHOjhyDvIwnGw1Bv4whGkBj0c+QZZOMLCBRAAAP//1ph0oGANAAA=";
// Deserialize RuntimeTypeInfo
var bytes = BASE64.decode(serializedRuntimeTypeInfo);
« no previous file with comments | « no previous file | mojo/go/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698