From c0511a54eae9c8eda4a406404a1ed172d4c26b53 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 7 Jun 2021 12:08:35 +0200 Subject: [PATCH] Rename ComponentDefintion::callback_names() to just callbacks() That's consistent with properties(). --- api/sixtyfps-cpp/include/sixtyfps_interpreter.h | 9 ++++----- api/sixtyfps-cpp/tests/interpreter.cpp | 2 +- sixtyfps_runtime/interpreter/api.rs | 4 ++-- sixtyfps_runtime/interpreter/ffi.rs | 7 +++---- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/api/sixtyfps-cpp/include/sixtyfps_interpreter.h b/api/sixtyfps-cpp/include/sixtyfps_interpreter.h index bbe330fa3..80ef5c743 100644 --- a/api/sixtyfps-cpp/include/sixtyfps_interpreter.h +++ b/api/sixtyfps-cpp/include/sixtyfps_interpreter.h @@ -712,12 +712,11 @@ public: /// Returns a vector of strings that describe the list of public callbacks that can be invoked /// using ComponentInstance::invoke_callback and set using ComponentInstance::set_callback. - sixtyfps::SharedVector callback_names() const + sixtyfps::SharedVector callbacks() const { - sixtyfps::SharedVector callback_names; - cbindgen_private::sixtyfps_interpreter_component_definition_callback_names(&inner, - &callback_names); - return callback_names; + sixtyfps::SharedVector callbacks; + cbindgen_private::sixtyfps_interpreter_component_definition_callbacks(&inner, &callbacks); + return callbacks; } /// Returns the name of this Component as written in the .60 file diff --git a/api/sixtyfps-cpp/tests/interpreter.cpp b/api/sixtyfps-cpp/tests/interpreter.cpp index ee522e3dd..70711b9bd 100644 --- a/api/sixtyfps-cpp/tests/interpreter.cpp +++ b/api/sixtyfps-cpp/tests/interpreter.cpp @@ -313,7 +313,7 @@ SCENARIO("Component Definition Properties") REQUIRE(properties[0].property_name == "test"); REQUIRE(properties[0].property_type == Value::Type::String); - auto callback_names = comp_def.callback_names(); + auto callback_names = comp_def.callbacks(); REQUIRE(callback_names.size() == 1); REQUIRE(callback_names[0] == "dummy"); } diff --git a/sixtyfps_runtime/interpreter/api.rs b/sixtyfps_runtime/interpreter/api.rs index ba3782c76..e773606ea 100644 --- a/sixtyfps_runtime/interpreter/api.rs +++ b/sixtyfps_runtime/interpreter/api.rs @@ -611,7 +611,7 @@ impl ComponentDefinition { } /// Returns the names of all publicly declared callbacks. - pub fn callback_names<'a>(&'a self) -> impl Iterator + 'a { + pub fn callbacks<'a>(&'a self) -> impl Iterator + 'a { // We create here a 'static guard, because unfortunately the returned type would be restricted to the guard lifetime // which is not required, but this is safe because there is only one instance of the unerased type let guard = unsafe { generativity::Guard::new(generativity::Id::new()) }; @@ -949,7 +949,7 @@ fn component_definition_properties2() { assert_eq!(props[0].0, "sub_text"); assert_eq!(props[0].1, ValueType::String); - let callbacks = comp_def.callback_names().collect::>(); + let callbacks = comp_def.callbacks().collect::>(); assert_eq!(callbacks.len(), 1); assert_eq!(callbacks[0], "hello"); } diff --git a/sixtyfps_runtime/interpreter/ffi.rs b/sixtyfps_runtime/interpreter/ffi.rs index f248d8601..692f85b8f 100644 --- a/sixtyfps_runtime/interpreter/ffi.rs +++ b/sixtyfps_runtime/interpreter/ffi.rs @@ -736,12 +736,11 @@ pub unsafe extern "C" fn sixtyfps_interpreter_component_definition_properties( /// Returns the list of callback names of the component the component definition describes #[no_mangle] -pub unsafe extern "C" fn sixtyfps_interpreter_component_definition_callback_names( +pub unsafe extern "C" fn sixtyfps_interpreter_component_definition_callbacks( def: &ComponentDefinitionOpaque, - callback_names: &mut SharedVector, + callbacks: &mut SharedVector, ) { - callback_names - .extend((&*def).as_component_definition().callback_names().map(|name| name.into())) + callbacks.extend((&*def).as_component_definition().callbacks().map(|name| name.into())) } /// Return the name of the component definition