mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 22:31:14 +00:00
Move StateInfo to the private namespace
This commit is contained in:
parent
daff9e8e65
commit
16ba23ae47
4 changed files with 16 additions and 19 deletions
|
@ -11,20 +11,16 @@ LICENSE END */
|
|||
#include <string_view>
|
||||
#include <memory>
|
||||
|
||||
namespace sixtyfps {
|
||||
namespace cbindgen_private {
|
||||
namespace sixtyfps::cbindgen_private {
|
||||
struct PropertyAnimation;
|
||||
}
|
||||
}
|
||||
|
||||
#include "sixtyfps_properties_internal.h"
|
||||
|
||||
namespace sixtyfps {
|
||||
namespace sixtyfps::private_api {
|
||||
|
||||
using cbindgen_private::StateInfo;
|
||||
|
||||
namespace private_api {
|
||||
|
||||
inline void sixtyfps_property_set_animated_binding_helper(
|
||||
const cbindgen_private::PropertyHandleOpaque *handle, void (*binding)(void *, int32_t *),
|
||||
void *user_data, void (*drop_user_data)(void *),
|
||||
|
@ -301,6 +297,4 @@ private:
|
|||
cbindgen_private::PropertyTrackerOpaque inner;
|
||||
};
|
||||
|
||||
} // namespace private_api
|
||||
|
||||
} // namespace sixtyfps
|
||||
} // namespace sixtyfps::private_api
|
||||
|
|
|
@ -208,11 +208,6 @@ pub fn register_font_from_path<P: AsRef<std::path::Path>>(
|
|||
sixtyfps_rendering_backend_default::backend().register_font_from_path(path.as_ref())
|
||||
}
|
||||
|
||||
// FIXME: this should not be in this namespace
|
||||
// but the name is `sixtyfps::StateInfo` in builtin.60
|
||||
#[doc(hidden)]
|
||||
pub use sixtyfps_corelib::properties::StateInfo;
|
||||
|
||||
/// internal re_exports used by the macro generated
|
||||
#[doc(hidden)]
|
||||
pub mod re_exports {
|
||||
|
@ -241,7 +236,9 @@ pub mod re_exports {
|
|||
pub use sixtyfps_corelib::items::*;
|
||||
pub use sixtyfps_corelib::layout::*;
|
||||
pub use sixtyfps_corelib::model::*;
|
||||
pub use sixtyfps_corelib::properties::{set_state_binding, Property, PropertyTracker};
|
||||
pub use sixtyfps_corelib::properties::{
|
||||
set_state_binding, Property, PropertyTracker, StateInfo,
|
||||
};
|
||||
pub use sixtyfps_corelib::slice::Slice;
|
||||
pub use sixtyfps_corelib::window::ComponentWindow;
|
||||
pub use sixtyfps_corelib::Color;
|
||||
|
|
|
@ -378,7 +378,7 @@ export struct StandardListViewItem := {
|
|||
}
|
||||
|
||||
export struct StateInfo := {
|
||||
//-name:sixtyfps::StateInfo
|
||||
//-name:sixtyfps::private_api::StateInfo
|
||||
current_state: int,
|
||||
previous_state: int,
|
||||
//change_time: duration,
|
||||
|
|
|
@ -55,7 +55,7 @@ fn rust_type(ty: &Type) -> Option<proc_macro2::TokenStream> {
|
|||
// This will produce a tuple
|
||||
Some(quote!((#(#elem,)*)))
|
||||
}
|
||||
Type::Struct { name: Some(name), .. } => Some(name.parse().unwrap()),
|
||||
Type::Struct { name: Some(name), .. } => Some(struct_name_to_tokens(&name)),
|
||||
Type::Array(o) => {
|
||||
let inner = rust_type(&o)?;
|
||||
Some(quote!(sixtyfps::re_exports::ModelHandle<#inner>))
|
||||
|
@ -1078,7 +1078,7 @@ fn compile_expression(expr: &Expression, component: &Rc<Component>) -> TokenStre
|
|||
let name = format_ident!("{}", name);
|
||||
quote!(#name: obj.#index as _)
|
||||
});
|
||||
let id : TokenStream = n.parse().unwrap();
|
||||
let id = struct_name_to_tokens(n);
|
||||
quote!({ let obj = #f; #id { #(#fields),*} })
|
||||
}
|
||||
_ => f,
|
||||
|
@ -1399,7 +1399,7 @@ fn compile_expression(expr: &Expression, component: &Rc<Component>) -> TokenStre
|
|||
})
|
||||
});
|
||||
if let Some(name) = name {
|
||||
let name : TokenStream = name.parse().unwrap();
|
||||
let name : TokenStream = struct_name_to_tokens(name.as_str());
|
||||
let keys = fields.keys().map(|k| k.parse::<TokenStream>().unwrap());
|
||||
quote!(#name { #(#keys: #elem,)* })
|
||||
} else {
|
||||
|
@ -1537,6 +1537,12 @@ fn compile_expression(expr: &Expression, component: &Rc<Component>) -> TokenStre
|
|||
}
|
||||
}
|
||||
|
||||
/// Return a TokenStream for a name (as in [`Type::Struct::name`])
|
||||
fn struct_name_to_tokens(name: &str) -> TokenStream {
|
||||
// the name match the C++ signature so we need to change that to the rust namespace
|
||||
name.replace("::private_api::", "::re_exports::").parse().unwrap()
|
||||
}
|
||||
|
||||
fn compile_assignment(
|
||||
lhs: &Expression,
|
||||
op: char,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue