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 725061 - Post-merge fixes for fundamental type support
Post-merge fixes for fundamental type support
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks:
 
 
Reported: 2014-02-24 13:04 UTC by Giovanni Campagna
Modified: 2014-02-26 00:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix typecheck_is_object/is_fundamental (1.97 KB, patch)
2014-02-24 13:04 UTC, Giovanni Campagna
committed Details | Review
arg: don't check manually for interface prerequisites (3.89 KB, patch)
2014-02-24 13:04 UTC, Giovanni Campagna
committed Details | Review
fundamental: assert that priv is not NULL if we are on the right JSClass (1.17 KB, patch)
2014-02-24 13:04 UTC, Giovanni Campagna
committed Details | Review
arg: fix cast checking for objects and fundamentals (4.70 KB, patch)
2014-02-24 13:04 UTC, Giovanni Campagna
committed Details | Review

Description Giovanni Campagna 2014-02-24 13:04:23 UTC
Should have been caught in review, especially because tests are
failing.
Comment 1 Giovanni Campagna 2014-02-24 13:04:26 UTC
Created attachment 270120 [details] [review]
Fix typecheck_is_object/is_fundamental

We don't need to check if priv == NULL, the purpose of those
calls is only to check the JSClass. Additionally, we don't
need to throw an exception, do_base_typecheck() already does.
Comment 2 Giovanni Campagna 2014-02-24 13:04:31 UTC
Created attachment 270121 [details] [review]
arg: don't check manually for interface prerequisites

g_type_is_a(interface, prerequisite) already does the expected thing,
we don't need a slow manual check.
Moreover, it's not documented, but add_prerequisite() always
resolves a GTypeInterface type into the instantiable prerequisites,
so g_type_interface_prerequisites() always returns instantiatable
types.
Comment 3 Giovanni Campagna 2014-02-24 13:04:36 UTC
Created attachment 270122 [details] [review]
fundamental: assert that priv is not NULL if we are on the right JSClass

We don't have custom inheritance for fundamental types, so we don't
need to run JS code before the C object is constructed.
Comment 4 Giovanni Campagna 2014-02-24 13:04:40 UTC
Created attachment 270123 [details] [review]
arg: fix cast checking for objects and fundamentals

We must make sure that all code paths successfully set the object
or throw an exception.
Comment 5 Colin Walters 2014-02-25 14:55:25 UTC
Review of attachment 270120 [details] [review]:

Ok.
Comment 6 Colin Walters 2014-02-25 15:42:20 UTC
Review of attachment 270121 [details] [review]:

This may be totally fine...

::: gi/arg.cpp
@@ +2692,3 @@
             } else if (gtype == G_TYPE_NONE) {
                 gjs_throw(context, "Unexpected unregistered type packing GArgument into jsval");
+            } else if (G_TYPE_IS_INSTANTIATABLE(gtype) || G_TYPE_IS_INTERFACE(gtype)) {

Just so I understand this - do we need || G_TYPE_IS_INTERFACE here?

It looks like in the old code, we made them a GObject proxy (and djdeath preserved that) - now you're changing things so that non-gobject interfaces are fundamentals.  

Or hm...maybe I'm confused as to why the *old* code had:

if (g_type_is_a(gtype, G_TYPE_OBJECT) || g_type_is_a(gtype, G_TYPE_INTERFACE))

Given that we only supported GObjects.
Comment 7 Colin Walters 2014-02-25 15:42:44 UTC
Review of attachment 270122 [details] [review]:

Right.
Comment 8 Colin Walters 2014-02-25 15:46:25 UTC
Review of attachment 270123 [details] [review]:

Makes sense to me.
Comment 9 Giovanni Campagna 2014-02-26 00:56:35 UTC
Attachment 270120 [details] pushed as 38164a1 - Fix typecheck_is_object/is_fundamental
Attachment 270121 [details] pushed as 58ab20d - arg: don't check manually for interface prerequisites
Attachment 270122 [details] pushed as 9680de8 - fundamental: assert that priv is not NULL if we are on the right JSClass
Attachment 270123 [details] pushed as 3d8bd0a - arg: fix cast checking for objects and fundamentals