-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for Java enum generation (#158)
* adds changes for enum support * adds tests for enum generation * Adds changes for placeholder Rust enum template * Fixes bug for Rust namespace in generated code
- Loading branch information
Showing
27 changed files
with
372 additions
and
8 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
code-gen-projects/input/bad/enum_type/invalid_case_enum_varaint.ion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
FoobarBaz // expected FooBarBaz, found FoobarBaz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
hello // expected (foo, bar, baz or FooBarBaz) found hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"foo" // expected a symbol value foo for enum, found string "foo" |
7 changes: 7 additions & 0 deletions
7
code-gen-projects/input/bad/struct_with_enum_fields/mismatched_sequence_element_type.ion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// struct with mismatched sequence element | ||
{ | ||
A: "hello", | ||
B: 12, | ||
C: (1 2 3), // expected sexpression of strings | ||
D: 10e2 | ||
} |
7 changes: 7 additions & 0 deletions
7
code-gen-projects/input/bad/struct_with_enum_fields/mismatched_sequence_type.ion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// simple struct with type mismatched sequence type | ||
{ | ||
A: "hello", | ||
B: 12, | ||
C: ["foo", "bar", "baz"], // expected sexp | ||
D: 10e2 | ||
} |
7 changes: 7 additions & 0 deletions
7
code-gen-projects/input/bad/struct_with_enum_fields/mismatched_type.ion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// simple struct with type mismatched fields | ||
{ | ||
A: "hello", | ||
B: false, // expected field type: int | ||
C: ("foo" "bar" "baz"), | ||
D: 10e2 | ||
} |
7 changes: 7 additions & 0 deletions
7
code-gen-projects/input/bad/struct_with_enum_fields/missing_required_fields.ion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// simple struct with all valid fields | ||
{ | ||
A: "hello", | ||
B: 12, | ||
// C: ("foo" "bar" "baz"), // since `C` is a required field, this is an invalid struct | ||
D: 10e2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
baz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
FooBarBaz |
7 changes: 7 additions & 0 deletions
7
code-gen-projects/input/good/struct_with_enum_fields/empty_values.ion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// struct with empty list, empty string and zeros | ||
{ | ||
C: (), | ||
A: "", | ||
B: 0, | ||
D: 0e0, | ||
} |
8 changes: 8 additions & 0 deletions
8
code-gen-projects/input/good/struct_with_enum_fields/valid_fields.ion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// simple struct with all valid fields | ||
{ | ||
A: "hello", | ||
B: 12, | ||
C: ("foo" "bar" "baz"), | ||
D: 10e2, | ||
E: foo | ||
} |
8 changes: 8 additions & 0 deletions
8
code-gen-projects/input/good/struct_with_enum_fields/valid_optional_fields.ion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// simple struct with all valid fields | ||
{ | ||
A: "hello", | ||
B: 12, | ||
C: ("foo" "bar" "baz"), | ||
// D: 10e2, // since `D` is optional field, this is a valid struct | ||
E: foo, | ||
} |
8 changes: 8 additions & 0 deletions
8
code-gen-projects/input/good/struct_with_enum_fields/valid_unordered_fields.ion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// struct with unordered fields | ||
{ | ||
C: ("foo" "bar" "baz"), | ||
A: "hello", | ||
B: 12, | ||
E: foo, | ||
D: 10e2, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
type::{ | ||
name: enum_type, | ||
valid_values: [foo, bar, baz, FooBarBaz] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
type::{ | ||
name: struct_with_enum_fields, | ||
type: struct, | ||
fields: { | ||
A: string, | ||
B: int, | ||
C: { element: string, type: sexp, occurs: required }, | ||
D: float, | ||
E: { valid_values: [foo, bar, baz] } | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.