Skip to content

Commit

Permalink
C++ codegen arrow serialize non-union components/datatypes without ne…
Browse files Browse the repository at this point in the history
…sted rerun types (#2820)

* Part of #2647
* Next step after: #2766

### What

Generates serialization for all non-union components and datatypes
except for datatypes nested in structs & unions.
Uses new serialization methods for 2D & 3D point logging. Ergonomics are
pretty poor at this point, handling this will be a follow-up.

Commit history got a bit messy at some point - **not** recommending
commit by commit reviewing ;)

Next Steps:
* work towards Point2D roundtrip
   * builder methods on archetype
   * make logging on Recording stream nice'ish
   * basic testing
* serialize unions
* serialize datatypes nested in unions, structs and lists
* more testing & roundtripping

### 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/2820) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/2820)
- [Docs
preview](https://rerun.io/preview/pr%3Aandreas%2Fcpp-codegen%2Farrow-serialize-structs/docs)
- [Examples
preview](https://rerun.io/preview/pr%3Aandreas%2Fcpp-codegen%2Farrow-serialize-structs/examples)
  • Loading branch information
Wumpf committed Jul 26, 2023
1 parent 3c3b56a commit 7832e4c
Show file tree
Hide file tree
Showing 114 changed files with 3,096 additions and 375 deletions.
4 changes: 3 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ BasedOnStyle: Google
# Make it slightly more similar to Rust.
# Based loosely on https://gist.github.com/YodaEmbedding/c2c77dc693d11f3734d78489f9a6eea4
AccessModifierOffset: -2
AlignAfterOpenBracket: BlockIndent
AllowAllArgumentsOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
Expand All @@ -19,9 +21,9 @@ InsertTrailingCommas: Wrapped
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
PointerAlignment: Left
ReflowComments: true
SeparateDefinitionBlocks: Always
SpacesBeforeTrailingComments: 1
ReflowComments: true

# Don't change include blocks, we want to control this manually.
# Sorting headers however is allowed as all our headers should be standalone.
Expand Down
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.

1 change: 1 addition & 0 deletions crates/re_types_builder/src/codegen/cpp/forward_decl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub struct ForwardDecls {
}

impl ForwardDecls {
#[allow(dead_code)]
pub fn insert(&mut self, namespace: impl Into<String>, decl: ForwardDecl) {
self.declarations_per_namespace
.entry(namespace.into())
Expand Down
6 changes: 4 additions & 2 deletions crates/re_types_builder/src/codegen/cpp/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use quote::quote;

use crate::Docs;

use super::{doc_comment, quote_docstrings, NEWLINE_TOKEN};
use super::{quote_doc_comment, quote_docstrings, NEWLINE_TOKEN};

#[derive(Default)]
pub struct MethodDeclaration {
Expand Down Expand Up @@ -82,7 +82,7 @@ impl quote::ToTokens for MethodDocumentation {
match self {
Self::None => {}
Self::String(s) => {
tokens.extend(doc_comment(s));
tokens.extend(quote_doc_comment(s));
}
Self::Docs(docs) => tokens.extend(quote_docstrings(docs)),
}
Expand Down Expand Up @@ -125,12 +125,14 @@ impl Method {
#declaration {
#definition_body
}
#NEWLINE_TOKEN
}
} else {
quote! {
#NEWLINE_TOKEN
#docs
#declaration;
#NEWLINE_TOKEN
}
}
}
Expand Down

0 comments on commit 7832e4c

Please sign in to comment.