Skip to content

Commit

Permalink
feat(array): Added array marker support
Browse files Browse the repository at this point in the history
  • Loading branch information
benaclejames committed Oct 31, 2023
1 parent ef085ef commit de926b5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "fti_osc"
version = "0.1.0"
version = "1.0.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["cdylib"]
crate-type = ["lib", "cdylib"]

[dependencies]
20 changes: 15 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub enum OscType {
Float,
Bool,
String,
ArrayBegin,
ArrayEnd
}

#[derive(Debug)]
Expand Down Expand Up @@ -139,6 +141,12 @@ fn extract_osc_values(buf: &[u8], ix: &mut usize) -> Result<Vec<OscValue>, Parse
value.osc_type = OscType::String;

}
'[' => {
value.osc_type = OscType::ArrayBegin;
}
']' => {
value.osc_type = OscType::ArrayEnd;
}
_ => {
continue;
}
Expand Down Expand Up @@ -227,11 +235,13 @@ pub extern "C" fn create_osc_message(buf: *mut c_uchar, osc_template: &OscMessag
let value = &osc_template.value[i];

let type_tag = match value.osc_type {
OscType::Int => 105, // i
OscType::Float => 102, // f
OscType::Bool => {if value.bool { 84 } else { 70 }}, // T or F
_ => 0,
};
OscType::Int => 'i', // i
OscType::Float => 'f', // f
OscType::Bool => {if value.bool { 'T' } else { 'F' }}, // T or F
OscType::ArrayBegin => '[',
OscType::ArrayEnd => ']',
_ => '\0',
} as c_uchar;
buf[ix] = type_tag;
ix += 1;
}
Expand Down

0 comments on commit de926b5

Please sign in to comment.