servo / gleam

Generated OpenGL bindings and wrapper for Servo.
Other
84 stars 58 forks source link

declare_gl_apis! macros doesn't allow us to add default function implementations #229

Open jamienicol opened 1 year ago

jamienicol commented 1 year ago

For #228, I would have liked to add default (empty) implementations of the newly added functions. This would be nice because a) the extension I'm exposing is GLES-only, so does not need a GlFns implementation. And b) currently every time we expose a new API to the Gl trait it's a breaking change and we have to bump the semver, and in gecko we need to add an impl to our swgl trait, even when it won't be used.

Unfortunately, trying to add a default impl currently results in a compilation error due to the declare_gl_apis macro:

error: no rules expected the token `{`
   --> src/gl.rs:765:113
    |
81  | macro_rules! declare_gl_apis {
    | ---------------------------- when calling this macro
...
765 |     fn start_tiling_qcom(&self, x: GLuint, y: GLuint, width: GLuint, height: GLuint, preserve_mask: GLbitfield) {
    |                                                                                                                 ^ no rules expected this token in macro call
    |
note: while trying to match `;`
   --> src/gl.rs:83:106
    |
83  |     ($($(unsafe $([$garbo:expr])*)* fn $name:ident(&self $(, $arg:ident: $t:ty)* $(,)*) $(-> $retty:ty)* ;)+) => {
    |