GNOME Bugzilla – Bug 610574
[jsapi-util] Add a few convenience macros
Last modified: 2010-02-24 22:46:34 UTC
This are required by the cairo bindings, in which it will be necessary to use macros as the module will create various prototypes. (10+)
Created attachment 154297 [details] [review] [jsapi-util] Add a few convenience macros GJS_DEFINE_PROTO/GJS_DEFINE_PROTO_ABSTRACT are boilerplate macros which significantly reduces the amount of code required to create a new prototype.
Created attachment 154415 [details] [review] [jsapi-util] Add a few convenience macros GJS_DEFINE_PROTO/GJS_DEFINE_PROTO_ABSTRACT are boilerplate macros which significantly reduces the amount of code required to create a new prototype.
Review of attachment 154415 [details] [review]: With the huge caveat that I'm not all that familiar with this part of the Spidermonkey APIs, this patch looks basically reasonable. I notice though there are a lot of flags we're hardcoding here, and it's unclear to me how often/when we might want those to vary. With this we're basically saying there's one "right" way to define a JSClass for objects representing C types, right?
Well, these macros have worked out pretty well for me & the cairo use case. Which is 3 abstract and 8 non-abstract (so-far) classes. We might want to add other macros which allows you to specify the FLAGS and/or modify the parameters send to JS_InitClass, but in most cases we just don't care, we just want a simple prototype that can be instantiated and has some methods. Havoc, what do you say?
Review of attachment 154415 [details] [review]: It seems a bit like the macros only handle one particular case. But doesn't seem worse than the rest of the gjs "internal" API :-P if it fixes cairo cut-and-paste why not experiment with it and maybe we can extend it to more cases over time.
Fixed in HEAD, thanks!