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

Use macros to reduce repetition #17

Description

@mzabaluev

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions