Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion src/hyperlight_guest_capi/src/flatbuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ limitations under the License.
*/

use alloc::boxed::Box;
use alloc::ffi::CString;
use alloc::string::String;
use alloc::vec::Vec;
use core::ffi::{CStr, c_char};

use hyperlight_common::flatbuffer_wrappers::util::get_flatbuffer_result;
Expand Down Expand Up @@ -115,4 +118,34 @@ pub extern "C" fn hl_get_host_return_value_as_ULong() -> u64 {
get_host_return_value().expect("Unable to get host return value as ulong")
}

// TODO add bool, float, double, string, vecbytes
#[unsafe(no_mangle)]
pub extern "C" fn hl_get_host_return_value_as_Bool() -> bool {
get_host_return_value().expect("Unable to get host return value as bool")
}

#[unsafe(no_mangle)]
pub extern "C" fn hl_get_host_return_value_as_float() -> f32 {
get_host_return_value().expect("Unable to get host return value as f32")
}

#[unsafe(no_mangle)]
pub extern "C" fn hl_get_host_return_value_as_double() -> f64 {
get_host_return_value().expect("Unable to get host return value as f32")
}

#[unsafe(no_mangle)]
pub extern "C" fn hl_get_host_return_value_as_String() -> *const c_char {
let string_value: String =
get_host_return_value().expect("Unable to get host return value as string");

let c_string = CString::new(string_value).expect("Failed to create CString");
c_string.into_raw()
}

#[unsafe(no_mangle)]
pub extern "C" fn hl_get_host_return_value_as_VecBytes() -> Box<FfiVec> {
let vec_value: Vec<u8> =
get_host_return_value().expect("Unable to get host return value as vec bytes");

Box::new(unsafe { FfiVec::from_vec(vec_value) })
}
4 changes: 2 additions & 2 deletions src/tests/rust_guests/simpleguest/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading