Skip to content

Commit

Permalink
App: Make instance ID an integer instead of string, add initial locat…
Browse files Browse the repository at this point in the history
…ion argument
  • Loading branch information
helgoboss committed Mar 7, 2024
1 parent 171154b commit 4f14349
Show file tree
Hide file tree
Showing 12 changed files with 274 additions and 279 deletions.
2 changes: 1 addition & 1 deletion main/src/domain/processor_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub struct ProcessorContext {
bypass_param_index: u32,
}

pub const HELGOBOX_INSTANCE_ID: &str = "instance_id";
pub const HELGOBOX_INSTANCE_ID_KEY: &str = "instance_id";

impl ProcessorContext {
pub fn from_host(host: HostCallback) -> anyhow::Result<ProcessorContext> {
Expand Down
20 changes: 10 additions & 10 deletions main/src/infrastructure/plugin/backbone_shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1213,11 +1213,11 @@ impl BackboneShell {
})
}

pub fn find_instance_shell_by_instance_id_str(
pub fn get_instance_shell_by_instance_id(
&self,
instance_id: &str,
instance_id: InstanceId,
) -> anyhow::Result<SharedInstanceShell> {
self.find_instance_shell_by_instance_id(instance_id.parse()?)
self.find_instance_shell_by_instance_id(instance_id)
.context("couldn't find instance")
}

Expand Down Expand Up @@ -1260,31 +1260,31 @@ impl BackboneShell {
#[cfg(feature = "playtime")]
pub fn with_clip_matrix<R>(
&self,
clip_matrix_id: &str,
clip_matrix_id: InstanceId,
f: impl FnOnce(&playtime_clip_engine::base::Matrix) -> R,
) -> anyhow::Result<R> {
let instance = self
.find_instance_by_instance_id(clip_matrix_id.parse()?)
.find_instance_by_instance_id(clip_matrix_id)
.context("instance not found")?;
Backbone::get().with_clip_matrix(&instance, f)
}

#[cfg(feature = "playtime")]
pub fn with_clip_matrix_mut<R>(
&self,
clip_matrix_id: &str,
clip_matrix_id: InstanceId,
f: impl FnOnce(&mut playtime_clip_engine::base::Matrix) -> R,
) -> anyhow::Result<R> {
let instance = self
.find_instance_by_instance_id(clip_matrix_id.parse()?)
.find_instance_by_instance_id(clip_matrix_id)
.context("instance not found")?;
Backbone::get().with_clip_matrix_mut(&instance, f)
}

#[allow(unused)]
pub fn create_clip_matrix(&self, clip_matrix_id: &str) -> anyhow::Result<()> {
pub fn create_clip_matrix(&self, clip_matrix_id: InstanceId) -> anyhow::Result<()> {
let instance_shell = self
.find_instance_shell_by_instance_id_str(clip_matrix_id)
.find_instance_shell_by_instance_id(clip_matrix_id)
.context("instance not found")?;
instance_shell.insert_owned_clip_matrix_if_necessary()?;
Ok(())
Expand Down Expand Up @@ -2624,7 +2624,7 @@ fn load_app_library() -> anyhow::Result<crate::infrastructure::ui::AppLibrary> {
tracing::info!("App library loaded successfully");
}
Err(e) => {
tracing::warn!("App library loading failed: {e}");
tracing::warn!("App library loading failed: {e:#}");
}
}
lib
Expand Down
2 changes: 1 addition & 1 deletion main/src/infrastructure/plugin/helgobox_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ impl HelgoboxPlugin {
return Err("empty buffer");
}
match param_name {
crate::domain::HELGOBOX_INSTANCE_ID => {
crate::domain::HELGOBOX_INSTANCE_ID_KEY => {
let instance_id_c_string =
CString::new(self.instance_id.to_string()).expect("should be number");
let mut bytes = instance_id_c_string
Expand Down
8 changes: 2 additions & 6 deletions main/src/infrastructure/plugin/instance_shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl InstanceHandler for CustomInstanceHandler {
) {
// TODO-medium If we would make the instance ID generic, we could save the string conversion
BackboneShell::get().proto_hub().notify_clip_matrix_changed(
&instance_id.to_string(),
instance_id,
matrix,
events,
is_poll,
Expand All @@ -94,11 +94,7 @@ impl InstanceHandler for CustomInstanceHandler {
) {
BackboneShell::get()
.proto_hub()
.send_occasional_matrix_updates_caused_by_reaper(
&instance_id.to_string(),
matrix,
events,
);
.send_occasional_matrix_updates_caused_by_reaper(instance_id, matrix, events);
}
}

Expand Down
Loading

0 comments on commit 4f14349

Please sign in to comment.