From 02dda7def100f7fd0ad1ed580bb1efbc2ad96f1b Mon Sep 17 00:00:00 2001 From: hkrn <129939+hkrn@users.noreply.github.com> Date: Mon, 18 Sep 2023 17:13:43 +0900 Subject: [PATCH] [rust] fix build on Linux due to difference type of `c_char` --- rust/plugin_wasm/src/model/c_api.rs | 20 ++++++------- rust/plugin_wasm/src/model/core.rs | 16 +++++----- rust/plugin_wasm/src/motion/c_api.rs | 24 +++++++-------- rust/plugin_wasm/src/motion/core.rs | 16 +++++----- rust/plugin_wasm_test_model_full/src/lib.rs | 26 ++++++++-------- .../plugin_wasm_test_model_minimum/src/lib.rs | 17 ++++++----- rust/plugin_wasm_test_motion_full/src/lib.rs | 30 +++++++++---------- .../src/lib.rs | 21 ++++++------- 8 files changed, 86 insertions(+), 84 deletions(-) diff --git a/rust/plugin_wasm/src/model/c_api.rs b/rust/plugin_wasm/src/model/c_api.rs index fa637dc2..e05d44ef 100644 --- a/rust/plugin_wasm/src/model/c_api.rs +++ b/rust/plugin_wasm/src/model/c_api.rs @@ -44,7 +44,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOCreate( /// This function should be called from nanoem via plugin loader #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginModelIOCreateWithLocation( - path: *const i8, + path: *const c_char, ) -> *mut nanoem_application_plugin_model_io_t { let path = CStr::from_ptr(path as *const c_char); if let Ok(mut instance) = nanoem_application_plugin_model_io_t::new(path) { @@ -76,7 +76,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOSetLanguage( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetName( plugin: *const nanoem_application_plugin_model_io_t, -) -> *const i8 { +) -> *const c_char { match nanoem_application_plugin_model_io_t::get(plugin) { Some(instance) => instance.name(), None => null(), @@ -89,7 +89,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetName( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetDescription( plugin: *const nanoem_application_plugin_model_io_t, -) -> *const i8 { +) -> *const c_char { match nanoem_application_plugin_model_io_t::get(plugin) { Some(instance) => instance.description(), None => null(), @@ -102,7 +102,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetDescription( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetVersion( plugin: *const nanoem_application_plugin_model_io_t, -) -> *const i8 { +) -> *const c_char { match nanoem_application_plugin_model_io_t::get(plugin) { Some(instance) => instance.version(), None => null(), @@ -129,7 +129,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOCountAllFunctions( pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetFunctionName( plugin: *const nanoem_application_plugin_model_io_t, index: i32, -) -> *const i8 { +) -> *const c_char { match nanoem_application_plugin_model_io_t::get(plugin) { Some(instance) => instance.function_name(index), None => null(), @@ -663,7 +663,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetUIWindowLayoutData( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginModelIOSetUIComponentLayoutData( plugin: *mut nanoem_application_plugin_model_io_t, - id: *const i8, + id: *const c_char, data: *const u8, length: u32, reload_layout: *mut i32, @@ -695,10 +695,10 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOSetUIComponentLayoutData( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetFailureReason( plugin: *const nanoem_application_plugin_model_io_t, -) -> *const i8 { +) -> *const c_char { match nanoem_application_plugin_model_io_t::get(plugin) { Some(instance) => match instance.failure_reason() { - Some(reason) => reason.as_ptr() as *const i8, + Some(reason) => reason.as_ptr() as *const c_char, None => null(), }, None => null(), @@ -711,10 +711,10 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetFailureReason( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetRecoverySuggestion( plugin: *const nanoem_application_plugin_model_io_t, -) -> *const i8 { +) -> *const c_char { match nanoem_application_plugin_model_io_t::get(plugin) { Some(instance) => match instance.recovery_suggestion() { - Some(reason) => reason.as_ptr() as *const i8, + Some(reason) => reason.as_ptr() as *const c_char, None => null(), }, None => null(), diff --git a/rust/plugin_wasm/src/model/core.rs b/rust/plugin_wasm/src/model/core.rs index 8505f257..e0ead8b6 100644 --- a/rust/plugin_wasm/src/model/core.rs +++ b/rust/plugin_wasm/src/model/core.rs @@ -10,7 +10,7 @@ use crate::nanoem_application_plugin_status_t; use super::plugin::ModelIOPluginController; -use std::ffi::CStr; +use std::ffi::{c_char, CStr}; use std::path::Path; use std::ptr::null; @@ -52,19 +52,19 @@ impl nanoem_application_plugin_model_io_t { pub fn create(&mut self) -> Result<()> { self.controller.create() } - pub fn name(&self) -> *const i8 { - crate::PLUGIN_NAME.as_ptr() as *const i8 + pub fn name(&self) -> *const c_char { + crate::PLUGIN_NAME.as_ptr() as *const c_char } - pub fn description(&self) -> *const i8 { - crate::PLUGIN_DESCRIPTION.as_ptr() as *const i8 + pub fn description(&self) -> *const c_char { + crate::PLUGIN_DESCRIPTION.as_ptr() as *const c_char } - pub fn version(&self) -> *const i8 { - crate::PLUGIN_VERSION.as_ptr() as *const i8 + pub fn version(&self) -> *const c_char { + crate::PLUGIN_VERSION.as_ptr() as *const c_char } pub fn count_all_functions(&self) -> i32 { self.controller.count_all_functions() } - pub fn function_name(&self, value: i32) -> *const i8 { + pub fn function_name(&self, value: i32) -> *const c_char { if let Ok(name) = self.controller.function_name(value) { name.as_ptr() } else { diff --git a/rust/plugin_wasm/src/motion/c_api.rs b/rust/plugin_wasm/src/motion/c_api.rs index 0273659e..321406a9 100644 --- a/rust/plugin_wasm/src/motion/c_api.rs +++ b/rust/plugin_wasm/src/motion/c_api.rs @@ -44,7 +44,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOCreate( /// This function should be called from nanoem via plugin loader #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginMotionIOCreateWithLocation( - path: *const i8, + path: *const c_char, ) -> *mut nanoem_application_plugin_motion_io_t { let path = CStr::from_ptr(path as *const c_char); if let Ok(mut instance) = nanoem_application_plugin_motion_io_t::new(path) { @@ -76,7 +76,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOSetLanguage( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetName( plugin: *const nanoem_application_plugin_motion_io_t, -) -> *const i8 { +) -> *const c_char { match nanoem_application_plugin_motion_io_t::get(plugin) { Some(instance) => instance.name(), None => null(), @@ -89,7 +89,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetName( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetDescription( plugin: *const nanoem_application_plugin_motion_io_t, -) -> *const i8 { +) -> *const c_char { match nanoem_application_plugin_motion_io_t::get(plugin) { Some(instance) => instance.description(), None => null(), @@ -102,7 +102,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetDescription( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetVersion( plugin: *const nanoem_application_plugin_motion_io_t, -) -> *const i8 { +) -> *const c_char { match nanoem_application_plugin_motion_io_t::get(plugin) { Some(instance) => instance.version(), None => null(), @@ -129,7 +129,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOCountAllFunctions( pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetFunctionName( plugin: *const nanoem_application_plugin_motion_io_t, index: i32, -) -> *const i8 { +) -> *const c_char { match nanoem_application_plugin_motion_io_t::get(plugin) { Some(instance) => instance.function_name(index), None => null(), @@ -161,7 +161,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOSetFunction( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginMotionIOSetAllNamedSelectedBoneKeyframes( plugin: *mut nanoem_application_plugin_motion_io_t, - name: *const i8, + name: *const c_char, frame_indices: *const u32, length: u32, status_ptr: *mut nanoem_application_plugin_status_t, @@ -191,7 +191,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOSetAllNamedSelectedBoneK #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginMotionIOSetAllNamedSelectedMorphKeyframes( plugin: *mut nanoem_application_plugin_motion_io_t, - name: *const i8, + name: *const c_char, frame_indices: *const u32, length: u32, status_ptr: *mut nanoem_application_plugin_status_t, @@ -643,7 +643,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetUIWindowLayoutData( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginMotionIOSetUIComponentLayoutData( plugin: *mut nanoem_application_plugin_motion_io_t, - id: *const i8, + id: *const c_char, data: *const u8, length: u32, reload_layout: *mut i32, @@ -675,10 +675,10 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOSetUIComponentLayoutData #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetFailureReason( plugin: *const nanoem_application_plugin_motion_io_t, -) -> *const i8 { +) -> *const c_char { match nanoem_application_plugin_motion_io_t::get(plugin) { Some(instance) => match instance.failure_reason() { - Some(reason) => reason.as_ptr() as *const i8, + Some(reason) => reason.as_ptr() as *const c_char, None => null(), }, None => null(), @@ -691,10 +691,10 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetFailureReason( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetRecoverySuggestion( plugin: *const nanoem_application_plugin_motion_io_t, -) -> *const i8 { +) -> *const c_char { match nanoem_application_plugin_motion_io_t::get(plugin) { Some(instance) => match instance.recovery_suggestion() { - Some(reason) => reason.as_ptr() as *const i8, + Some(reason) => reason.as_ptr() as *const c_char, None => null(), }, None => null(), diff --git a/rust/plugin_wasm/src/motion/core.rs b/rust/plugin_wasm/src/motion/core.rs index f1a66a45..ed03582d 100644 --- a/rust/plugin_wasm/src/motion/core.rs +++ b/rust/plugin_wasm/src/motion/core.rs @@ -10,7 +10,7 @@ use crate::nanoem_application_plugin_status_t; use super::plugin::MotionIOPluginController; -use std::ffi::CStr; +use std::ffi::{c_char, CStr}; use std::path::Path; use std::ptr::null; @@ -52,19 +52,19 @@ impl nanoem_application_plugin_motion_io_t { pub fn create(&mut self) -> Result<()> { self.controller.create() } - pub fn name(&self) -> *const i8 { - crate::PLUGIN_NAME.as_ptr() as *const i8 + pub fn name(&self) -> *const c_char { + crate::PLUGIN_NAME.as_ptr() as *const c_char } - pub fn description(&self) -> *const i8 { - crate::PLUGIN_DESCRIPTION.as_ptr() as *const i8 + pub fn description(&self) -> *const c_char { + crate::PLUGIN_DESCRIPTION.as_ptr() as *const c_char } - pub fn version(&self) -> *const i8 { - crate::PLUGIN_VERSION.as_ptr() as *const i8 + pub fn version(&self) -> *const c_char { + crate::PLUGIN_VERSION.as_ptr() as *const c_char } pub fn count_all_functions(&self) -> i32 { self.controller.count_all_functions() } - pub fn function_name(&self, value: i32) -> *const i8 { + pub fn function_name(&self, value: i32) -> *const c_char { if let Ok(name) = self.controller.function_name(value) { name.as_ptr() } else { diff --git a/rust/plugin_wasm_test_model_full/src/lib.rs b/rust/plugin_wasm_test_model_full/src/lib.rs index aad09b38..2f484f1e 100644 --- a/rust/plugin_wasm_test_model_full/src/lib.rs +++ b/rust/plugin_wasm_test_model_full/src/lib.rs @@ -126,7 +126,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOSetLanguage( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetName( _plugin: *const nanoem_application_plugin_model_io_t, -) -> *const i8 { +) -> *const c_char { println!( "{}", serde_json::to_string(&Output { @@ -135,7 +135,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetName( }) .unwrap() ); - b"plugin_wasm_test_model_full\0" as *const u8 as *const i8 + b"plugin_wasm_test_model_full\0" as *const u8 as *const c_char } /// # Safety @@ -144,7 +144,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetName( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetDescription( _plugin: *const nanoem_application_plugin_model_io_t, -) -> *const i8 { +) -> *const c_char { println!( "{}", serde_json::to_string(&Output { @@ -153,7 +153,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetDescription( }) .unwrap() ); - b"This is plugin_wasm_test_model_full\0" as *const u8 as *const i8 + b"This is plugin_wasm_test_model_full\0" as *const u8 as *const c_char } /// # Safety @@ -162,7 +162,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetDescription( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetVersion( _plugin: *const nanoem_application_plugin_model_io_t, -) -> *const i8 { +) -> *const c_char { println!( "{}", serde_json::to_string(&Output { @@ -171,7 +171,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetVersion( }) .unwrap() ); - b"1.2.3\0" as *const u8 as *const i8 + b"1.2.3\0" as *const u8 as *const c_char } /// # Safety @@ -199,7 +199,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOCountAllFunctions( pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetFunctionName( _plugin: *const nanoem_application_plugin_model_io_t, index: i32, -) -> *const i8 { +) -> *const c_char { let mut arguments = HashMap::new(); arguments.insert("index".to_owned(), json!(index)); println!( @@ -210,7 +210,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetFunctionName( }) .unwrap() ); - b"function0\0" as *const u8 as *const i8 + b"function0\0" as *const u8 as *const c_char } /// # Safety @@ -729,7 +729,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetUIWindowLayoutData( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginModelIOSetUIComponentLayoutData( _plugin: *mut nanoem_application_plugin_model_io_t, - id: *const i8, + id: *const c_char, data: *const u8, length: u32, _reload_layout: *mut u32, @@ -758,7 +758,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOSetUIComponentLayoutData( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetFailureReason( _plugin: *const nanoem_application_plugin_model_io_t, -) -> *const i8 { +) -> *const c_char { println!( "{}", serde_json::to_string(&Output { @@ -767,7 +767,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetFailureReason( }) .unwrap() ); - b"Failure Reason\0" as *const u8 as *const i8 + b"Failure Reason\0" as *const u8 as *const c_char } /// # Safety @@ -776,7 +776,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetFailureReason( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetRecoverySuggestion( _plugin: *const nanoem_application_plugin_model_io_t, -) -> *const i8 { +) -> *const c_char { println!( "{}", serde_json::to_string(&Output { @@ -785,7 +785,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetRecoverySuggestion( }) .unwrap() ); - b"Recovery Suggestion\0" as *const u8 as *const i8 + b"Recovery Suggestion\0" as *const u8 as *const c_char } /// # Safety diff --git a/rust/plugin_wasm_test_model_minimum/src/lib.rs b/rust/plugin_wasm_test_model_minimum/src/lib.rs index 1bb95acf..650e1e78 100644 --- a/rust/plugin_wasm_test_model_minimum/src/lib.rs +++ b/rust/plugin_wasm_test_model_minimum/src/lib.rs @@ -7,6 +7,7 @@ use serde_derive::{Deserialize, Serialize}; use serde_json::{json, Value}; use std::collections::HashMap; +use std::ffi::c_char; use std::os::raw::c_void; #[allow(non_camel_case_types)] @@ -95,7 +96,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOSetLanguage( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetName( _plugin: *const nanoem_application_plugin_model_io_t, -) -> *const i8 { +) -> *const c_char { println!( "{}", serde_json::to_string(&Output { @@ -104,7 +105,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetName( }) .unwrap() ); - b"plugin_wasm_test_model_minimum\0" as *const u8 as *const i8 + b"plugin_wasm_test_model_minimum\0" as *const u8 as *const c_char } /// # Safety @@ -113,7 +114,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetName( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetVersion( _plugin: *const nanoem_application_plugin_model_io_t, -) -> *const i8 { +) -> *const c_char { println!( "{}", serde_json::to_string(&Output { @@ -122,7 +123,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetVersion( }) .unwrap() ); - b"1.2.3\0" as *const u8 as *const i8 + b"1.2.3\0" as *const u8 as *const c_char } /// # Safety @@ -150,7 +151,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOCountAllFunctions( pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetFunctionName( _plugin: *const nanoem_application_plugin_model_io_t, index: i32, -) -> *const i8 { +) -> *const c_char { let mut arguments = HashMap::new(); arguments.insert("index".to_owned(), json!(index)); println!( @@ -161,7 +162,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetFunctionName( }) .unwrap() ); - b"function0\0" as *const u8 as *const i8 + b"function0\0" as *const u8 as *const c_char } /// # Safety @@ -290,7 +291,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetOutputModelData( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetFailureReason( _plugin: *const nanoem_application_plugin_model_io_t, -) -> *const i8 { +) -> *const c_char { println!( "{}", serde_json::to_string(&Output { @@ -299,7 +300,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginModelIOGetFailureReason( }) .unwrap() ); - b"Failure Reason\0" as *const u8 as *const i8 + b"Failure Reason\0" as *const u8 as *const c_char } /// # Safety diff --git a/rust/plugin_wasm_test_motion_full/src/lib.rs b/rust/plugin_wasm_test_motion_full/src/lib.rs index 031dac90..23b50c1b 100644 --- a/rust/plugin_wasm_test_motion_full/src/lib.rs +++ b/rust/plugin_wasm_test_motion_full/src/lib.rs @@ -126,7 +126,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOSetLanguage( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetName( _plugin: *const nanoem_application_plugin_motion_io_t, -) -> *const i8 { +) -> *const c_char { println!( "{}", serde_json::to_string(&Output { @@ -135,7 +135,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetName( }) .unwrap() ); - b"plugin_wasm_test_motion_full\0" as *const u8 as *const i8 + b"plugin_wasm_test_motion_full\0" as *const u8 as *const c_char } /// # Safety @@ -144,7 +144,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetName( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetDescription( _plugin: *const nanoem_application_plugin_motion_io_t, -) -> *const i8 { +) -> *const c_char { println!( "{}", serde_json::to_string(&Output { @@ -153,7 +153,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetDescription( }) .unwrap() ); - b"This is plugin_wasm_test_motion_full\0" as *const u8 as *const i8 + b"This is plugin_wasm_test_motion_full\0" as *const u8 as *const c_char } /// # Safety @@ -162,7 +162,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetDescription( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetVersion( _plugin: *const nanoem_application_plugin_motion_io_t, -) -> *const i8 { +) -> *const c_char { println!( "{}", serde_json::to_string(&Output { @@ -171,7 +171,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetVersion( }) .unwrap() ); - b"1.2.3\0" as *const u8 as *const i8 + b"1.2.3\0" as *const u8 as *const c_char } /// # Safety @@ -199,7 +199,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOCountAllFunctions( pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetFunctionName( _plugin: *const nanoem_application_plugin_motion_io_t, index: i32, -) -> *const i8 { +) -> *const c_char { let mut arguments = HashMap::new(); arguments.insert("index".to_owned(), json!(index)); println!( @@ -210,7 +210,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetFunctionName( }) .unwrap() ); - b"function0\0" as *const u8 as *const i8 + b"function0\0" as *const u8 as *const c_char } /// # Safety @@ -244,7 +244,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOSetFunction( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginMotionIOSetAllNamedSelectedBoneKeyframes( _plugin: *mut nanoem_application_plugin_motion_io_t, - name: *const i8, + name: *const c_char, frame_indices: *const u32, length: u32, status_ptr: *mut nanoem_application_plugin_status_t, @@ -272,7 +272,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOSetAllNamedSelectedBoneK #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginMotionIOSetAllNamedSelectedMorphKeyframes( _plugin: *mut nanoem_application_plugin_motion_io_t, - name: *const i8, + name: *const c_char, frame_indices: *const u32, length: u32, status_ptr: *mut nanoem_application_plugin_status_t, @@ -710,7 +710,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetUIWindowLayoutData( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginMotionIOSetUIComponentLayoutData( _plugin: *mut nanoem_application_plugin_motion_io_t, - id: *const i8, + id: *const c_char, data: *const u8, length: u32, _reload_layout: *mut i32, @@ -739,7 +739,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOSetUIComponentLayoutData #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetFailureReason( _plugin: *const nanoem_application_plugin_motion_io_t, -) -> *const i8 { +) -> *const c_char { println!( "{}", serde_json::to_string(&Output { @@ -748,7 +748,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetFailureReason( }) .unwrap() ); - b"Failure Reason\0" as *const u8 as *const i8 + b"Failure Reason\0" as *const u8 as *const c_char } /// # Safety @@ -757,7 +757,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetFailureReason( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetRecoverySuggestion( _plugin: *const nanoem_application_plugin_motion_io_t, -) -> *const i8 { +) -> *const c_char { println!( "{}", serde_json::to_string(&Output { @@ -766,7 +766,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetRecoverySuggestion( }) .unwrap() ); - b"Recovery Suggestion\0" as *const u8 as *const i8 + b"Recovery Suggestion\0" as *const u8 as *const c_char } /// # Safety diff --git a/rust/plugin_wasm_test_motion_minimum/src/lib.rs b/rust/plugin_wasm_test_motion_minimum/src/lib.rs index 1be0ac82..5dc4de2f 100644 --- a/rust/plugin_wasm_test_motion_minimum/src/lib.rs +++ b/rust/plugin_wasm_test_motion_minimum/src/lib.rs @@ -7,6 +7,7 @@ use serde_derive::{Deserialize, Serialize}; use serde_json::{json, Value}; use std::collections::HashMap; +use std::ffi::c_char; use std::os::raw::c_void; #[allow(non_camel_case_types)] @@ -95,7 +96,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOSetLanguage( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetName( _plugin: *const nanoem_application_plugin_motion_io_t, -) -> *const i8 { +) -> *const c_char { println!( "{}", serde_json::to_string(&Output { @@ -104,7 +105,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetName( }) .unwrap() ); - b"plugin_wasm_test_motion_minimum\0" as *const u8 as *const i8 + b"plugin_wasm_test_motion_minimum\0" as *const u8 as *const c_char } /// # Safety @@ -113,7 +114,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetName( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetDescription( _plugin: *const nanoem_application_plugin_motion_io_t, -) -> *const i8 { +) -> *const c_char { println!( "{}", serde_json::to_string(&Output { @@ -122,7 +123,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetDescription( }) .unwrap() ); - b"This is plugin_wasm_test_motion_minimum\0" as *const u8 as *const i8 + b"This is plugin_wasm_test_motion_minimum\0" as *const u8 as *const c_char } /// # Safety @@ -131,7 +132,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetDescription( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetVersion( _plugin: *const nanoem_application_plugin_motion_io_t, -) -> *const i8 { +) -> *const c_char { println!( "{}", serde_json::to_string(&Output { @@ -140,7 +141,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetVersion( }) .unwrap() ); - b"1.2.3\0" as *const u8 as *const i8 + b"1.2.3\0" as *const u8 as *const c_char } /// # Safety @@ -168,7 +169,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOCountAllFunctions( pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetFunctionName( _plugin: *const nanoem_application_plugin_motion_io_t, index: i32, -) -> *const i8 { +) -> *const c_char { let mut arguments = HashMap::new(); arguments.insert("index".to_owned(), json!(index)); println!( @@ -179,7 +180,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetFunctionName( }) .unwrap() ); - b"function0\0" as *const u8 as *const i8 + b"function0\0" as *const u8 as *const c_char } /// # Safety @@ -308,7 +309,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetOutputMotionData( #[no_mangle] pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetFailureReason( _plugin: *const nanoem_application_plugin_motion_io_t, -) -> *const i8 { +) -> *const c_char { println!( "{}", serde_json::to_string(&Output { @@ -317,7 +318,7 @@ pub unsafe extern "C" fn nanoemApplicationPluginMotionIOGetFailureReason( }) .unwrap() ); - b"Failure Reason\0" as *const u8 as *const i8 + b"Failure Reason\0" as *const u8 as *const c_char } /// # Safety