Skip to content

amjoshuamichael/cxc_derive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🪞 cxc-derive: Make any type usable in cxc

use cxc::Unit;
use cxc::XcReflect;

#[derive(Default, Clone, Copy, Debug, XcReflect, PartialEq, Eq)]
pub struct Numbers5 {
    pub a: i32,
    pub b: i32,
    pub c: i32,
    pub d: i32,
    pub e: i32,
}

#[test]
fn numbers_5() {
    let mut unit = Unit::new();

    unit.add_reflect_type::<Numbers5>();
    unit.add_external_default::<Numbers5>();

    unit.push_script(
        "
        some_numbers(); Numbers5 {
            ; Numbers5 { a = 4, b = 9, c = 39, ++ }
        }
        "
    ).unwrap();

    let some_numbers = unit.get_fn("some_numbers").unwrap().downcast::<(), Numbers5>();
    let numbers5 = some_numbers();

    assert_eq!(numbers5, Numbers5 { a: 4, b: 9, c: 39, ..Default::default() });
}

Supports regular struct types, enums, tuples, function types, references, raw pointers, etc. AFAIK, the only thing it doesn't support it Unions, because those aren't in cxc. If there's anything that it doesn't support that you think it should, then please submit an issue

About

Derivation library for cxc

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages