impl sync and send for types (🥴) as well as "AsObject" for casting for objects

This commit is contained in:
Janis 2023-04-21 22:01:11 +02:00
parent ed5c4a5702
commit 8c195f224b

View file

@ -160,6 +160,9 @@ pub fn generate_class<W: Write>(class: &Class, _sdk: &Sdk, w: &mut W) -> anyhow:
if !is_class {
writeln!(w, "pub struct {name}(UnsafeCell<[u8; {size}]>);")?;
writeln!(w, "unsafe impl Send for {name} {{}}")?;
writeln!(w, "unsafe impl Sync for {name} {{}}")?;
write!(
w,
r#"
@ -187,6 +190,24 @@ impl {name} {{
} else {
writeln!(w, "pub struct {name}(NonNull<UnsafeCell<u8>>);")?;
writeln!(w, "unsafe impl Send for {name} {{}}")?;
writeln!(w, "unsafe impl Sync for {name} {{}}")?;
write!(
w,
r#"
impl AsUObject for {name} {{
fn as_uobject(&self) -> UObject {{
UObject(self.0)
}}
fn from_uobject(obj: UObject) -> Self {{
Self(obj.0)
}}
}}
"#
)?;
write!(
w,
r#"