Skip to content

Commit

Permalink
extra deprecation warning suppression for cpp (unfortunately messes w…
Browse files Browse the repository at this point in the history
…ith some whitespace
  • Loading branch information
Wumpf committed Dec 16, 2024
1 parent 5f8ce34 commit ed1756d
Show file tree
Hide file tree
Showing 95 changed files with 129 additions and 220 deletions.
71 changes: 37 additions & 34 deletions crates/build/re_types_builder/src/codegen/cpp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,21 +366,12 @@ fn generate_hpp_cpp(
) -> Result<(TokenStream, Option<TokenStream>)> {
let QuotedObject { hpp, cpp } =
QuotedObject::new(reporter, objects, obj, hpp_includes, hpp_type_extensions)?;
let snake_case_name = obj.snake_case_name();
let hash = quote! { # };
let pragma_once = pragma_once();
let header_file_name = format!("{snake_case_name}.hpp");

let hpp = quote! {
#pragma_once
#hpp
};
let cpp = cpp.map(|cpp| {
quote! {
#hash include #header_file_name #NEWLINE_TOKEN #NEWLINE_TOKEN
#cpp
}
});

Ok((hpp, cpp))
}
Expand Down Expand Up @@ -454,6 +445,7 @@ impl QuotedObject {
let quoted_docs = quote_obj_docs(reporter, objects, obj);

let mut cpp_includes = Includes::new(obj.fqname.clone(), obj.scope());
cpp_includes.insert_relative(&format!("{}.hpp", obj.snake_case_name()));
cpp_includes.insert_rerun("collection_adapter_builtins.hpp");
hpp_includes.insert_system("utility"); // std::move
hpp_includes.insert_rerun("indicator_component.hpp");
Expand Down Expand Up @@ -567,19 +559,17 @@ impl QuotedObject {
format!("{}Indicator", obj.fqname).replace("archetypes", "components");
let doc_hide_comment = quote_hide_from_docs();
let deprecation_notice = quote_deprecation_notice(obj);
let has_deprecation = obj.deprecation_notice().is_some();
let (deprecation_ignore_start, deprecation_ignore_end) =
if obj.deprecation_notice().is_some() {
hpp_includes.insert_rerun("compiler_utils.hpp");
(
quote! {
RR_PUSH_WARNINGS #NEWLINE_TOKEN
RR_DISABLE_DEPRECATION_WARNING #NEWLINE_TOKEN
},
quote! { RR_POP_WARNINGS },
)
} else {
(quote!(), quote!())
};
quote_deprecation_ignore_start_and_end(&mut hpp_includes, has_deprecation);

let extra_compiler_utils_include = if has_deprecation {
let hash = quote! { # };
let compiler_utils_path = "../compiler_utils.hpp";
quote! { #hash include #compiler_utils_path #NEWLINE_TOKEN }
} else {
quote! {}
};

let hpp = quote! {
#hpp_includes
Expand Down Expand Up @@ -628,9 +618,11 @@ impl QuotedObject {
};

let cpp = quote! {
#extra_compiler_utils_include
#deprecation_ignore_start

#cpp_includes

#deprecation_ignore_start

namespace rerun::#quoted_namespace {
#(#methods_cpp)*
Expand Down Expand Up @@ -672,6 +664,7 @@ impl QuotedObject {
let deprecation_notice = quote_deprecation_notice(obj);

let mut cpp_includes = Includes::new(obj.fqname.clone(), obj.scope());
cpp_includes.insert_relative(&format!("{}.hpp", obj.snake_case_name()));
let mut hpp_declarations = ForwardDecls::default();

let field_declarations = obj
Expand Down Expand Up @@ -852,6 +845,7 @@ impl QuotedObject {
hpp_includes.insert_system("cstring"); // std::memcpy

let mut cpp_includes = Includes::new(obj.fqname.clone(), obj.scope());
cpp_includes.insert_relative(&format!("{}.hpp", obj.snake_case_name()));
#[allow(unused)]
let mut hpp_declarations = ForwardDecls::default();

Expand Down Expand Up @@ -1245,6 +1239,7 @@ impl QuotedObject {
let deprecation_notice = quote_deprecation_notice(obj);

let mut cpp_includes = Includes::new(obj.fqname.clone(), obj.scope());
cpp_includes.insert_relative(&format!("{}.hpp", obj.snake_case_name()));
let mut hpp_declarations = ForwardDecls::default();

let field_declarations = obj
Expand Down Expand Up @@ -2591,18 +2586,8 @@ fn quote_loggable_hpp_and_cpp(

hpp_includes.insert_rerun("component_descriptor.hpp");

let (deprecation_ignore_start, deprecation_ignore_end) = if obj.deprecation_notice().is_some() {
hpp_includes.insert_rerun("compiler_utils.hpp");
(
quote! {
RR_PUSH_WARNINGS #NEWLINE_TOKEN
RR_DISABLE_DEPRECATION_WARNING #NEWLINE_TOKEN
},
quote! { RR_POP_WARNINGS },
)
} else {
(quote!(), quote!())
};
let (deprecation_ignore_start, deprecation_ignore_end) =
quote_deprecation_ignore_start_and_end(hpp_includes, obj.deprecation_notice().is_some());

let hpp = quote! {
#deprecation_ignore_start
Expand Down Expand Up @@ -2646,3 +2631,21 @@ fn quote_deprecation_notice(obj: &Object) -> TokenStream {
quote! {}
}
}

fn quote_deprecation_ignore_start_and_end(
includes: &mut Includes,
should_deprecate: bool,
) -> (TokenStream, TokenStream) {
if should_deprecate {
includes.insert_rerun("compiler_utils.hpp");
(
quote! {
RR_PUSH_WARNINGS #NEWLINE_TOKEN
RR_DISABLE_DEPRECATION_WARNING #NEWLINE_TOKEN
},
quote! { RR_POP_WARNINGS },
)
} else {
(quote!(), quote!())
}
}
3 changes: 1 addition & 2 deletions rerun_cpp/src/rerun/archetypes/annotation_context.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/archetypes/arrows2d.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/archetypes/arrows3d.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/archetypes/asset3d.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/archetypes/asset_video.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/archetypes/bar_chart.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/archetypes/boxes2d.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/archetypes/boxes3d.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/archetypes/capsules3d.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/archetypes/clear.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/archetypes/depth_image.cpp

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

7 changes: 3 additions & 4 deletions rerun_cpp/src/rerun/archetypes/disconnected_space.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/archetypes/ellipsoids3d.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/archetypes/encoded_image.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/archetypes/geo_line_strings.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/archetypes/geo_points.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/archetypes/graph_edges.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/archetypes/graph_nodes.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/archetypes/image.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/archetypes/instance_poses3d.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/archetypes/line_strips2d.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/archetypes/line_strips3d.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/archetypes/mesh3d.cpp

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

Loading

0 comments on commit ed1756d

Please sign in to comment.