Skip to content

Commit

Permalink
More moonwave docs (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
qwreey committed Oct 21, 2024
1 parent 706efaf commit 144f49a
Show file tree
Hide file tree
Showing 3 changed files with 314 additions and 179 deletions.
8 changes: 6 additions & 2 deletions crates/lune-std-ffi/src/c/types/isize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ impl FfiConvert for CTypeInfo<isize> {
dst: &Ref<dyn FfiData>,
src: &Ref<dyn FfiData>,
) -> LuaResult<()> {
*dst.get_inner_pointer().byte_offset(dst_offset).cast::<isize>() =
*src.get_inner_pointer().byte_offset(src_offset).cast::<isize>();
*dst.get_inner_pointer()
.byte_offset(dst_offset)
.cast::<isize>() = *src
.get_inner_pointer()
.byte_offset(src_offset)
.cast::<isize>();
Ok(())
}
unsafe fn stringify_data(
Expand Down
25 changes: 20 additions & 5 deletions crates/lune-std-ffi/src/c/types/u32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ impl FfiConvert for CTypeInfo<u32> {
}
};
unsafe {
*(data_handle.get_inner_pointer().byte_offset(offset).cast::<u32>()) = value;
*(data_handle
.get_inner_pointer()
.byte_offset(offset)
.cast::<u32>()) = value;
}
Ok(())
}
Expand All @@ -49,7 +52,11 @@ impl FfiConvert for CTypeInfo<u32> {
data_handle: &Ref<dyn FfiData>,
) -> LuaResult<LuaValue<'lua>> {
let value = unsafe {
(*data_handle.get_inner_pointer().byte_offset(offset).cast::<u32>()).into_lua(lua)?
(*data_handle
.get_inner_pointer()
.byte_offset(offset)
.cast::<u32>())
.into_lua(lua)?
};
Ok(value)
}
Expand All @@ -61,8 +68,12 @@ impl FfiConvert for CTypeInfo<u32> {
dst: &Ref<dyn FfiData>,
src: &Ref<dyn FfiData>,
) -> LuaResult<()> {
*dst.get_inner_pointer().byte_offset(dst_offset).cast::<u32>() =
*src.get_inner_pointer().byte_offset(src_offset).cast::<u32>();
*dst.get_inner_pointer()
.byte_offset(dst_offset)
.cast::<u32>() = *src
.get_inner_pointer()
.byte_offset(src_offset)
.cast::<u32>();
Ok(())
}
unsafe fn stringify_data(
Expand All @@ -71,6 +82,10 @@ impl FfiConvert for CTypeInfo<u32> {
offset: isize,
data_handle: &Ref<dyn FfiData>,
) -> LuaResult<String> {
Ok((*data_handle.get_inner_pointer().byte_offset(offset).cast::<f32>()).to_string())
Ok((*data_handle
.get_inner_pointer()
.byte_offset(offset)
.cast::<f32>())
.to_string())
}
}
Loading

0 comments on commit 144f49a

Please sign in to comment.