GNOME Bugzilla – Bug 725282
Some fixes and improvements to GParamSpec
Last modified: 2014-04-10 23:36:39 UTC
This started of as a crasher fix for GObject.param_spec_* (which is in the documentation), and ended up with a lot of improvements. Unfortunately, the most beautiful improvement of all, killing off the hand coded GParamSpec constructors, is not possible because the JS variants have the flags argument in the wrong place. Having automatic static methods for GParamSpec is still useful for, say, g_param_spec_unichar(), which is not hand-coded. Needs a gobject-introspection fix to pick up the methods.
Created attachment 270429 [details] [review] ParamSpec: fix argument marshalling We need to treat GParamSpec and derived classes as gjs_param, otherwise we fallback on gjs_fundamental and crash.
Created attachment 270430 [details] [review] GParamSpec: remove custom constructor With proper argument marshalling, we don't need the custom code anymore, the regular GObject functions works just as well. We still need a lot of JS override code, because the arguments are swapped...
Created attachment 270431 [details] [review] GParamSpec: implement methods Methods are definitely expected for GParamSpec classes, even more than fields, and are easy to implement.
Created attachment 270432 [details] [review] all: fix method resolution on prototypes We must define as methods on prototypes only the functions that have the IS_METHOD flag, or we get static functions there.
Created attachment 270433 [details] [review] param: use accessors to read name, nick, blurb and default value The GParamSpec API provides binding friendly accessors for name, nick, blurb and default, so we don't need to recurse the hierarchy looking for a field.
Created attachment 270434 [details] [review] param: implement static methods We can share the code with object, and get them for free.
Attachment 270429 [details] pushed as 45bbf5b - ParamSpec: fix argument marshalling Attachment 270430 [details] pushed as 221e158 - GParamSpec: remove custom constructor Attachment 270431 [details] pushed as a393b31 - GParamSpec: implement methods Attachment 270432 [details] pushed as aae358f - all: fix method resolution on prototypes Attachment 270433 [details] pushed as c57a4d7 - param: use accessors to read name, nick, blurb and default value Attachment 270434 [details] pushed as e20d7d7 - param: implement static methods