Skip to content

Commit

Permalink
Rust enum codegen 1/N (#5291)
Browse files Browse the repository at this point in the history
### What
* Part of #3384

This implements C-style `enum` support in the codegen, with a full Rust
implementation.

There is no example included, because the Python and C++ codegen is
still emitting an error when attempting to use `enum`, but I have tested
the codegen a bit locally, and the generated code at least _compiles_.

Future PRs:
* Python codegen
* C++ codegen
* Tests
* Converting existing types to `enum`

While working on the PR I also cleaned up some other codegen stuff, but
reviewing everything commit-by-commit should make it all obvious.

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using newly built examples:
[app.rerun.io](https://app.rerun.io/pr/5291/index.html)
* Using examples from latest `main` build:
[app.rerun.io](https://app.rerun.io/pr/5291/index.html?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[app.rerun.io](https://app.rerun.io/pr/5291/index.html?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!

- [PR Build Summary](https://build.rerun.io/pr/5291)
- [Docs
preview](https://rerun.io/preview/017812cb07a396308b070e411334edcf2a4cf352/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/017812cb07a396308b070e411334edcf2a4cf352/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
  • Loading branch information
emilk authored Feb 27, 2024
1 parent 8b4e650 commit 61956e1
Show file tree
Hide file tree
Showing 295 changed files with 3,427 additions and 4,292 deletions.
22 changes: 22 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,27 @@
"args": [],
"cwd": "${workspaceFolder}"
},
{
"name": "Debug 'codegen'",
"type": "lldb",
"request": "launch",
"cargo": {
"args": [
"build",
"--package=re_types_builder",
],
"filter": {
"name": "build_re_types",
"kind": "bin"
}
},
"args": [
"--force" // always run codegen, even if hashes hasn't changed
],
"cwd": "${workspaceFolder}",
"env": {
"RAYON_NUM_THREADS": "1" // less confusing debugging experience
}
},
]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions crates/re_string_interner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ impl AsRef<str> for InternedString {

impl std::ops::Deref for InternedString {
type Target = str;

#[inline]
fn deref(&self) -> &str {
self.as_str()
Expand Down Expand Up @@ -249,6 +250,7 @@ macro_rules! declare_new_type {

impl std::ops::Deref for $StructName {
type Target = str;

#[inline]
fn deref(&self) -> &str {
self.as_str()
Expand Down
7 changes: 3 additions & 4 deletions crates/re_types/src/blueprint/components/active_tab.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 6 additions & 13 deletions crates/re_types/src/blueprint/components/column_shares.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 6 additions & 8 deletions crates/re_types/src/blueprint/components/corner2d.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 6 additions & 13 deletions crates/re_types/src/blueprint/components/included_contents.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 3 additions & 9 deletions crates/re_types/src/blueprint/components/included_queries.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 6 additions & 13 deletions crates/re_types/src/blueprint/components/row_shares.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions crates/re_types/src/blueprint/components/space_view_class.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions crates/re_types/src/blueprint/components/space_view_origin.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions crates/re_types/src/blueprint/components/visible.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 3 additions & 10 deletions crates/re_types/src/components/annotation_context.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 6 additions & 13 deletions crates/re_types/src/components/blob.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 61956e1

Please sign in to comment.