After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 666360 - Allow grabbing things off of interface types
Allow grabbing things off of interface types
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks:
 
 
Reported: 2011-12-16 13:03 UTC by Jasper St. Pierre (not reading bugmail)
Modified: 2012-01-03 20:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Allow grabbing things off of interface types (13.27 KB, patch)
2011-12-16 13:03 UTC, Jasper St. Pierre (not reading bugmail)
none Details | Review
Allow grabbing things off of interface types (13.39 KB, patch)
2012-01-03 20:00 UTC, Jasper St. Pierre (not reading bugmail)
reviewed Details | Review
Add native JSClass for interfaces (13.57 KB, patch)
2012-01-03 20:24 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review

Description Jasper St. Pierre (not reading bugmail) 2011-12-16 13:03:27 UTC
Right now, this only works for static methods and methods on the prototype.

https://bugzilla.gnome.org/show_bug.cgi?id=663492
Comment 1 Jasper St. Pierre (not reading bugmail) 2011-12-16 13:03:30 UTC
Created attachment 203661 [details] [review]
Allow grabbing things off of interface types
Comment 2 Jasper St. Pierre (not reading bugmail) 2012-01-03 20:00:07 UTC
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.
Comment 3 Colin Walters 2012-01-03 20:07:57 UTC
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()?
Comment 4 Jasper St. Pierre (not reading bugmail) 2012-01-03 20:24:45 UTC
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).
Comment 5 Colin Walters 2012-01-03 20:30:06 UTC
Review of attachment 204517 [details] [review]:

Looks OK to me now then, thanks.
Comment 6 Jasper St. Pierre (not reading bugmail) 2012-01-03 20:35:42 UTC
Attachment 204517 [details] pushed as 43eade6 - Add native JSClass for interfaces