diff --git a/api/sixtyfps-cpp/include/sixtyfps.h b/api/sixtyfps-cpp/include/sixtyfps.h index 3a402d889..f682b013c 100644 --- a/api/sixtyfps-cpp/include/sixtyfps.h +++ b/api/sixtyfps-cpp/include/sixtyfps.h @@ -384,19 +384,7 @@ private: int64_t id; }; -// layouts: -using cbindgen_private::BoxLayoutCellData; -using cbindgen_private::BoxLayoutData; -using cbindgen_private::GridLayoutCellData; -using cbindgen_private::GridLayoutData; -using cbindgen_private::LayoutAlignment; -using cbindgen_private::LayoutInfo; -using cbindgen_private::Orientation; -using cbindgen_private::Padding; -using cbindgen_private::PathLayoutData; -using cbindgen_private::Rect; - -#if !defined(DOXYGEN) +namespace cbindgen_private { inline LayoutInfo LayoutInfo::merge(const LayoutInfo &other) const { // Note: This "logic" is duplicated from LayoutInfo::merge in layout.rs. @@ -407,10 +395,8 @@ inline LayoutInfo LayoutInfo::merge(const LayoutInfo &other) const std::max(preferred, other.preferred), std::min(stretch, other.stretch) }; } -#endif /// FIXME! this should be done by cbindgen -namespace cbindgen_private { inline bool operator==(const LayoutInfo &a, const LayoutInfo &b) { return a.min == b.min && a.max == b.max && a.min_percent == b.min_percent @@ -425,7 +411,8 @@ inline bool operator!=(const LayoutInfo &a, const LayoutInfo &b) namespace private_api { -inline SharedVector solve_box_layout(const BoxLayoutData &data, Slice repeater_indexes) +inline SharedVector solve_box_layout(const cbindgen_private::BoxLayoutData &data, + Slice repeater_indexes) { SharedVector result; Slice ri { reinterpret_cast(repeater_indexes.ptr), repeater_indexes.len }; @@ -433,31 +420,36 @@ inline SharedVector solve_box_layout(const BoxLayoutData &data, Slice solve_grid_layout(const GridLayoutData &data) +inline SharedVector solve_grid_layout(const cbindgen_private::GridLayoutData &data) { SharedVector result; cbindgen_private::sixtyfps_solve_grid_layout(&data, &result); return result; } -inline LayoutInfo grid_layout_info(Slice cells, float spacing, - const Padding &padding) +inline cbindgen_private::LayoutInfo +grid_layout_info(Slice cells, float spacing, + const cbindgen_private::Padding &padding) { return cbindgen_private::sixtyfps_grid_layout_info(cells, spacing, &padding); } -inline LayoutInfo box_layout_info(Slice cells, float spacing, - const Padding &padding, LayoutAlignment alignment) +inline cbindgen_private::LayoutInfo +box_layout_info(Slice cells, float spacing, + const cbindgen_private::Padding &padding, + cbindgen_private::LayoutAlignment alignment) { return cbindgen_private::sixtyfps_box_layout_info(cells, spacing, &padding, alignment); } -inline LayoutInfo box_layout_info_ortho(Slice cells, const Padding &padding) +inline cbindgen_private::LayoutInfo +box_layout_info_ortho(Slice cells, + const cbindgen_private::Padding &padding) { return cbindgen_private::sixtyfps_box_layout_info_ortho(cells, &padding); } -inline SharedVector solve_path_layout(const PathLayoutData &data, +inline SharedVector solve_path_layout(const cbindgen_private::PathLayoutData &data, Slice repeater_indexes) { SharedVector result; diff --git a/sixtyfps_compiler/generator/cpp.rs b/sixtyfps_compiler/generator/cpp.rs index ed3a141f2..a288dd7b2 100644 --- a/sixtyfps_compiler/generator/cpp.rs +++ b/sixtyfps_compiler/generator/cpp.rs @@ -345,8 +345,8 @@ impl CppType for Type { fn to_cpp_orientation(o: Orientation) -> &'static str { match o { - Orientation::Horizontal => "sixtyfps::Orientation::Horizontal", - Orientation::Vertical => "sixtyfps::Orientation::Vertical", + Orientation::Horizontal => "sixtyfps::cbindgen_private::Orientation::Horizontal", + Orientation::Vertical => "sixtyfps::cbindgen_private::Orientation::Vertical", } } @@ -925,7 +925,7 @@ fn generate_item_tree( Declaration::Function(Function { name: "layout_info".into(), signature: - "([[maybe_unused]] sixtyfps::private_api::ComponentRef component, sixtyfps::Orientation o) -> sixtyfps::LayoutInfo" + "([[maybe_unused]] sixtyfps::private_api::ComponentRef component, sixtyfps::cbindgen_private::Orientation o) -> sixtyfps::cbindgen_private::LayoutInfo" .into(), is_static: true, statements: Some(vec![format!( @@ -1307,7 +1307,7 @@ fn generate_sub_component( Access::Public, Declaration::Function(Function { name: "layout_info".into(), - signature: "(sixtyfps::cbindgen_private::Orientation o) const -> sixtyfps::LayoutInfo" + signature: "(sixtyfps::cbindgen_private::Orientation o) const -> sixtyfps::cbindgen_private::LayoutInfo" .into(), statements: Some(vec![ "[[maybe_unused]] auto self = this;".into(), @@ -1421,7 +1421,7 @@ fn generate_repeated_component( Access::Public, // Because Repeater accesses it Declaration::Function(Function { name: "box_layout_data".into(), - signature: "(sixtyfps::Orientation o) const -> sixtyfps::BoxLayoutCellData".to_owned(), + signature: "(sixtyfps::cbindgen_private::Orientation o) const -> sixtyfps::cbindgen_private::BoxLayoutCellData".to_owned(), statements: Some(vec!["return { layout_info({&static_vtable, const_cast(static_cast(this))}, o) };".into()]), ..Function::default() @@ -2204,7 +2204,8 @@ fn box_layout_function( ctx: &llr_EvaluationContext, ) -> String { let repeated_indices = repeated_indices.map(ident); - let mut push_code = "std::vector cells_vector;".to_owned(); + let mut push_code = + "std::vector cells_vector;".to_owned(); let mut repeater_idx = 0usize; for item in elements { @@ -2246,7 +2247,7 @@ fn box_layout_function( format!("std::array {}_array;", 2 * repeater_idx, ri) }); format!( - "[&]{{ {} {} sixtyfps::Slice{}{{cells_vector.data(), cells_vector.size()}}; return {}; }}()", + "[&]{{ {} {} sixtyfps::Slice{}{{cells_vector.data(), cells_vector.size()}}; return {}; }}()", ri, push_code, ident(cells_variable),