use wrapped_mono::*;
#[derive(InteropSend,InteropRecive)]
struct Vec3{
x:f32,
y:f32,
z:f32,
}
static vec3_class:LazyLock<Class> = LazyLock::new(||{
let img = Assembly::assembly_loaded("AsmWithVec3").expect("Could not find assembly").get_image();
let vec3_class = Class::from_name(&img,"Vec3Namespace","Vec3").expect("Could not find vec3!");
vec3_class
});
impl InteropClass for Vec3{
fn get_mono_class()->Class{
return vec3_class;
}
}
impl InteropBox for Vec3{}
#[invokable]
fn do_vec3_magic(Vec3:input)->Vec3{
println!("Doing magic with vec3!");
return input;
}
fn vec3_expose_magic(){
add_internal_call!("Vec3Namespace.Vec3::DoMagic",do_vec3_magic);
}
fn make_vec3_array()->Array<Vec3>{
return Array::new(doamin.get_curr(),64);
}
fn box_n_unbox_vec3(input:Vec3)->Vec3{
let boxed = Object::box_val::<Vec3>(input);
let unbox = boxed.unbox();
return unboxed;
}
struct SomeObjectClass{
obj:Object,
}
impl InteropRecive for SomeObjectClass{
type SourceType = *mut MonoObject;
fn get_rust_rep(src:Self::SourceType)->Self{
return unsafe{Object::from_ptr(src)}.expect("Got null on a non nullable type!");
}
}
impl InteropRecive for Option<SomeObjectClass>{
type SourceType = Option<Object>;
fn get_rust_rep(src:Self::SourceType)->Self{
return src;
}
}
impl InteropSend for SomeObjectClass{
type TargetType = *mut MonoObject;
fn get_mono_rep(src:Self)->Self::TargetType{
return src.get_ptr();
}
}
use core::ptr::null_mut;
impl InteropSend for Option<SomeObjectClass>{
type Targetype = *mut MonoObject;
fn get_mono_rep(src:Self)->Self::TargetType{
match src{
Some(src)=>return src.get_ptr(),
None=>return null_mut(),
}
}
}