GNOME Bugzilla – Bug 666360
Allow grabbing things off of interface types
Last modified: 2012-01-03 20:35:45 UTC
Right now, this only works for static methods and methods on the prototype. https://bugzilla.gnome.org/show_bug.cgi?id=663492
Created attachment 203661 [details] [review] Allow grabbing things off of interface types
Created attachment 204516 [details] [review] Allow grabbing things off of interface types Right now, this only works for static methods and methods on the prototype.
Review of attachment 204516 [details] [review]: I'd summarize this as "Add native JSClass for interfaces". Elaborate on "things" - what data do you want? ::: gi/interface.c @@ +1,3 @@ +/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ +/* + * Copyright (c) 2008 litl, LLC You should probably keep the litl copyright since I assume you copy/sed'ed this from another file, but do add your own as well. @@ +57,3 @@ + message = g_strdup_printf("You cannot construct new instances of '%s'", + g_base_info_get_name(priv->info)); + gjs_throw(context, message); gjs_throw() already takes a print format, so this code would blow up if the interface name happened to contain '%'. You should either use gjs_throw_literal(), or drop the g_strdup_printf() - the second is best I think. @@ +95,3 @@ + GIFunctionInfoFlags flags; + + meth_info = g_struct_info_get_method (info, i); Shouldn't this be g_interface_info_get_method()?
Created attachment 204517 [details] [review] Add native JSClass for interfaces This allows us to retrieve static methods and methods from the prototype. This also lays the foundation for when we want to implement implementing interfaces. (In reply to comment #3) > Review of attachment 204516 [details] [review]: > > I'd summarize this as "Add native JSClass for interfaces". Elaborate on > "things" - what data do you want? Right now it's just the constructor methods and prototype methods... so Clutter.Container.prototype.add_actor (even though this is less important because of the Clutter apocalypses) > ::: gi/interface.c > @@ +1,3 @@ > +/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ > +/* > + * Copyright (c) 2008 litl, LLC > > You should probably keep the litl copyright since I assume you copy/sed'ed this > from another file, but do add your own as well. I put "Red Hat, Inc.". Not sure what you want here. > @@ +57,3 @@ > + message = g_strdup_printf("You cannot construct new instances of '%s'", > + g_base_info_get_name(priv->info)); > + gjs_throw(context, message); > > gjs_throw() already takes a print format, so this code would blow up if the > interface name happened to contain '%'. You should either use > gjs_throw_literal(), or drop the g_strdup_printf() - the second is best I > think. Hah, didn't know that. Fixed. > @@ +95,3 @@ > + GIFunctionInfoFlags flags; > + > + meth_info = g_struct_info_get_method (info, i); > > Shouldn't this be g_interface_info_get_method()? Yes, yes it should. (I also noticed one bug with constructor methods that's now fixed).
Review of attachment 204517 [details] [review]: Looks OK to me now then, thanks.
Attachment 204517 [details] pushed as 43eade6 - Add native JSClass for interfaces