fleabitdev / glsp

The GameLisp scripting language

Home Page:https://gamelisp.rs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What's the prefered method for using types from other libraries as rdata?

Grinshpon opened this issue · comments

The 0.1 version of the documentation had an rdata! macro and this example:

rdata! {
    struct Sprite {
        name: Sym,
        texture: ggez::graphics::Image
    }
}

But in 0.2 the macro is gone and it seems the only way to do this is to wrap the type and create a custom impl. Is there a different, preferred way of doing this, or will the rdata! macro come back at some point?

The rules surrounding Rust data have been greatly simplified in 0.2. You can now pass values of any 'static type to the glsp::rdata function, with no fuss:

let file_rdata: Root<RData> = glsp::rdata(File::open("example.png")?);

The new Rust Bindings section of the reference manual has all of the details.

The rules surrounding Rust data have been greatly simplified in 0.2. You can now pass values of any 'static type to the glsp::rdata function, with no fuss:

let file_rdata: Root<RData> = glsp::rdata(File::open("example.png")?);

The new Rust Bindings section of the reference manual has all of the details.

Hmm, I guess I thought otherwise because I keep getting an error pertaining to some ggez types, specifically DrawMode and Color. The error complains about WrappedCall not being implemented. Should I open a new issue for this?

Edit: I see what my issue was now, I was conflating IntoVal and FromVal, and skimmed over the part in the documentation talking about rfn arguments. All I needed to do was take a reference to the type. I'm sorry, I should have paid more attention to the documentation!