Fix FFI for EffectParameters to return IdentifiablePointers

This commit is contained in:
Deukhoofd 2023-01-03 12:54:38 +01:00
parent aae41b93bb
commit df47976d97
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 9 additions and 9 deletions

View File

@ -1,4 +1,4 @@
use crate::ffi::{ExternPointer, OwnedPtr};
use crate::ffi::{ExternPointer, IdentifiablePointer, OwnedPtr};
use crate::static_data::EffectParameter;
use crate::StringKey;
use std::ffi::{c_char, CStr, CString};
@ -27,27 +27,27 @@ mod statistic_set;
/// Instantiates an effect parameter with a boolean.
#[no_mangle]
extern "C" fn effect_parameter_new_bool(value: u8) -> OwnedPtr<EffectParameter> {
Box::into_raw(Box::new((value == 1).into()))
extern "C" fn effect_parameter_new_bool(value: u8) -> IdentifiablePointer<EffectParameter> {
Box::<EffectParameter>::new((value == 1).into()).into()
}
/// Instantiates an effect parameter with an integer.
#[no_mangle]
extern "C" fn effect_parameter_new_int(value: i64) -> OwnedPtr<EffectParameter> {
Box::into_raw(Box::new(value.into()))
extern "C" fn effect_parameter_new_int(value: i64) -> IdentifiablePointer<EffectParameter> {
Box::<EffectParameter>::new(value.into()).into()
}
/// Instantiates an effect parameter with a float.
#[no_mangle]
extern "C" fn effect_parameter_new_float(value: f32) -> OwnedPtr<EffectParameter> {
Box::into_raw(Box::new(value.into()))
extern "C" fn effect_parameter_new_float(value: f32) -> IdentifiablePointer<EffectParameter> {
Box::<EffectParameter>::new(value.into()).into()
}
/// Instantiates an effect parameter with a string.
#[no_mangle]
unsafe extern "C" fn effect_parameter_new_string(value: *const c_char) -> OwnedPtr<EffectParameter> {
unsafe extern "C" fn effect_parameter_new_string(value: *const c_char) -> IdentifiablePointer<EffectParameter> {
let sk: StringKey = CStr::from_ptr(value).to_str().unwrap().into();
Box::into_raw(Box::new(sk.into()))
Box::<EffectParameter>::new(sk.into()).into()
}
/// Drop an effect parameter.