Skip to content

Commit

Permalink
Low-level API: Update functions
Browse files Browse the repository at this point in the history
  • Loading branch information
helgoboss committed Apr 23, 2024
1 parent 46908ec commit c086aee
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 1 deletion.
3 changes: 3 additions & 0 deletions main/low/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ mod codegen {
"GlobalAlloc",
"GlobalLock",
"GlobalUnlock",
// # processthreadsapi.h
"SetThreadPriority",
"GetCurrentThreadId",
];

/// This is a list of types that influence if a generated method will be marked as unsafe
Expand Down
11 changes: 11 additions & 0 deletions main/low/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5735,6 +5735,17 @@ pub mod root {
) -> ::std::os::raw::c_int,
>;
}
extern "C" {
#[link_name = "\u{1}_ZN16reaper_functions12Menu_GetHashE"]
pub static mut Menu_GetHash: ::std::option::Option<
unsafe extern "C" fn(
menuname: *const ::std::os::raw::c_char,
flag: ::std::os::raw::c_int,
hashOut: *mut ::std::os::raw::c_char,
hashOut_sz: ::std::os::raw::c_int,
) -> bool,
>;
}
extern "C" {
#[link_name = "\u{1}_ZN16reaper_functions14MIDI_CountEvtsE"]
pub static mut MIDI_CountEvts: ::std::option::Option<
Expand Down
34 changes: 33 additions & 1 deletion main/low/src/reaper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1932,6 +1932,9 @@ impl Reaper {
c_str_macro::c_str!(stringify!(MediaItemDescendsFromTrack)).as_ptr(),
),
),
Menu_GetHash: std::mem::transmute(
plugin_context.GetFunc(c_str_macro::c_str!(stringify!(Menu_GetHash)).as_ptr()),
),
MIDI_CountEvts: std::mem::transmute(
plugin_context
.GetFunc(c_str_macro::c_str!(stringify!(MIDI_CountEvts)).as_ptr()),
Expand Down Expand Up @@ -4840,6 +4843,9 @@ impl Reaper {
if pointers.MediaItemDescendsFromTrack.is_some() {
loaded_count += 1;
}
if pointers.Menu_GetHash.is_some() {
loaded_count += 1;
}
if pointers.MIDI_CountEvts.is_some() {
loaded_count += 1;
}
Expand Down Expand Up @@ -13677,6 +13683,24 @@ impl Reaper {
#[doc = r" # Safety"]
#[doc = r""]
#[doc = r" REAPER can crash if you pass an invalid pointer."]
pub unsafe fn Menu_GetHash(
&self,
menuname: *const ::std::os::raw::c_char,
flag: ::std::os::raw::c_int,
hashOut: *mut ::std::os::raw::c_char,
hashOut_sz: ::std::os::raw::c_int,
) -> bool {
match self.pointers.Menu_GetHash {
None => panic!(
"Attempt to use a function that has not been loaded: {}",
stringify!(Menu_GetHash)
),
Some(f) => f(menuname, flag, hashOut, hashOut_sz),
}
}
#[doc = r" # Safety"]
#[doc = r""]
#[doc = r" REAPER can crash if you pass an invalid pointer."]
pub unsafe fn MIDI_CountEvts(
&self,
take: *mut root::MediaItem_Take,
Expand Down Expand Up @@ -22424,6 +22448,14 @@ pub struct ReaperFunctionPointers {
track: *mut root::MediaTrack,
) -> ::std::os::raw::c_int,
>,
pub Menu_GetHash: Option<
unsafe extern "C" fn(
menuname: *const ::std::os::raw::c_char,
flag: ::std::os::raw::c_int,
hashOut: *mut ::std::os::raw::c_char,
hashOut_sz: ::std::os::raw::c_int,
) -> bool,
>,
pub MIDI_CountEvts: Option<
unsafe extern "C" fn(
take: *mut root::MediaItem_Take,
Expand Down Expand Up @@ -24530,5 +24562,5 @@ pub struct ReaperFunctionPointers {
>,
}
impl ReaperFunctionPointers {
pub(crate) const TOTAL_COUNT: u32 = 858u32;
pub(crate) const TOTAL_COUNT: u32 = 859u32;
}
21 changes: 21 additions & 0 deletions main/low/src/swell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7769,6 +7769,21 @@ impl Swell {
unsafe { windows::GlobalUnlock(h) }
}
#[cfg(target_family = "windows")]
pub fn GetCurrentThreadId(&self) -> root::DWORD {
unsafe { windows::GetCurrentThreadId() }
}
#[cfg(target_family = "windows")]
#[doc = r" # Safety"]
#[doc = r""]
#[doc = r" REAPER can crash if you pass an invalid pointer."]
pub unsafe fn SetThreadPriority(
&self,
evt: root::HANDLE,
prio: ::std::os::raw::c_int,
) -> root::BOOL {
unsafe { windows::SetThreadPriority(evt, prio) }
}
#[cfg(target_family = "windows")]
pub fn CreateSolidBrush(&self, col: ::std::os::raw::c_int) -> root::HBRUSH {
unsafe { windows::CreateSolidBrush(col) }
}
Expand Down Expand Up @@ -9562,6 +9577,12 @@ mod windows {
extern "system" {
pub fn GlobalUnlock(h: root::HANDLE);
}
extern "system" {
pub fn GetCurrentThreadId() -> root::DWORD;
}
extern "system" {
pub fn SetThreadPriority(evt: root::HANDLE, prio: ::std::os::raw::c_int) -> root::BOOL;
}
extern "system" {
pub fn CreateSolidBrush(col: ::std::os::raw::c_int) -> root::HBRUSH;
}
Expand Down

0 comments on commit c086aee

Please sign in to comment.