Skip to content

Commit

Permalink
C++ serialization support for most nested types, transform3d roundtri…
Browse files Browse the repository at this point in the history
…p test (#2937)

Part of:
* #2919 
* #2791

### What

Major facelift of the C++ codegen as it got restructured to support more
support more nested kind of serialization and moved away entirely from
using the arrow type registry at all (this happened originally due to
c&p from Rust without understanding the details; this change makes a lot
of the code a lot simpler!)

In order to test the new nested serialization this also enables the
transform 3d roundtrip test which required adding some extensions on
various datatypes to make the test code readable.
**These are not the transform related final extensions.** More is under
way in a future PR to make transform usable.

The resulting transforms can't yet be loaded in the viewer due to #2871

The only remaining cases that don't produce (presumably until tested)
correct serialization now are:
* nullable component/datatype inside a transparent component/datatype
* lists/vectors inside as a union variant

(they are not particularly hard to solve, just left out of this PR)

### 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 [demo.rerun.io](https://demo.rerun.io/pr/2937) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/2937)
- [Docs
preview](https://rerun.io/preview/pr%3Aandreas%2Fcpp%2Funion-support/docs)
- [Examples
preview](https://rerun.io/preview/pr%3Aandreas%2Fcpp%2Funion-support/examples)
  • Loading branch information
Wumpf authored Aug 9, 2023
1 parent 367499f commit b3689d9
Show file tree
Hide file tree
Showing 56 changed files with 1,718 additions and 895 deletions.
2 changes: 1 addition & 1 deletion crates/re_types/source_hash.txt

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

933 changes: 499 additions & 434 deletions crates/re_types_builder/src/codegen/cpp/mod.rs

Large diffs are not rendered by default.

38 changes: 12 additions & 26 deletions crates/re_types_builder/src/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,12 +900,17 @@ impl Type {

/// True if this is some kind of array/vector.
pub fn is_plural(&self) -> bool {
self.plural_inner().is_some()
}

/// Returns element type for arrays and vectors.
pub fn plural_inner(&self) -> Option<&ElementType> {
match self {
Self::Array {
elem_type: _,
Self::Vector { elem_type }
| Self::Array {
elem_type,
length: _,
}
| Self::Vector { elem_type: _ } => true,
} => Some(elem_type),
Self::UInt8
| Self::UInt16
| Self::UInt32
Expand All @@ -919,32 +924,13 @@ impl Type {
| Self::Float32
| Self::Float64
| Self::String
| Self::Object(_) => false,
| Self::Object(_) => None,
}
}

pub fn vector_inner(&self) -> Option<&ElementType> {
match self {
Self::Vector { elem_type } => Some(elem_type),
Self::Array {
elem_type: _,
length: _,
}
| Self::UInt8
| Self::UInt16
| Self::UInt32
| Self::UInt64
| Self::Int8
| Self::Int16
| Self::Int32
| Self::Int64
| Self::Bool
| Self::Float16
| Self::Float32
| Self::Float64
| Self::String
| Self::Object(_) => None,
}
self.plural_inner()
.filter(|_| matches!(self, Self::Vector { .. }))
}

/// `Some(fqname)` if this is an `Object` or an `Array`/`Vector` of `Object`s.
Expand Down
5 changes: 2 additions & 3 deletions rerun_cpp/src/rerun/components/affix_fuzzer11.cpp

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

3 changes: 1 addition & 2 deletions rerun_cpp/src/rerun/components/affix_fuzzer12.cpp

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

3 changes: 1 addition & 2 deletions rerun_cpp/src/rerun/components/affix_fuzzer13.cpp

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

39 changes: 23 additions & 16 deletions rerun_cpp/src/rerun/components/affix_fuzzer16.cpp

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

43 changes: 27 additions & 16 deletions rerun_cpp/src/rerun/components/affix_fuzzer17.cpp

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

43 changes: 27 additions & 16 deletions rerun_cpp/src/rerun/components/affix_fuzzer18.cpp

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

43 changes: 27 additions & 16 deletions rerun_cpp/src/rerun/components/affix_fuzzer7.cpp

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

Loading

0 comments on commit b3689d9

Please sign in to comment.