Skip to content
This repository has been archived by the owner on Nov 26, 2020. It is now read-only.

Use macros to reduce repetition #17

Open
mzabaluev opened this issue Jan 6, 2015 · 0 comments
Open

Use macros to reduce repetition #17

mzabaluev opened this issue Jan 6, 2015 · 0 comments

Comments

@mzabaluev
Copy link
Member

Rust's powerful macro system can greatly improve readability for the generated code and facilitate creation of bindings by hand, should such a need arise.
Ideally, declarations of binding types for GObject could look like this:

gobject_decl! {
    class FileInputStream : InputStream {
        type_fn g_file_input_stream_get_type();
    }

    sync class Cancellable {
        type_fn g_cancellable_get_type();
    }

    interface AsyncResult {
        type_fn g_async_result_get_type();
    }
}

The type structs and much of the boilerplate traits for type ID, casting and wrapping can be generated from such compact descriptions.

Another area to benefit from macroization is transformation of parameters and output values between Rust and C.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant