[gjs] Make sure that all calls to BOOLEAN_TO_JSVAL pass a true boolean



commit 46b1443c4771cd53b9eff16dd4542669dc1816d0
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri Jan 4 13:16:53 2013 -0500

    Make sure that all calls to BOOLEAN_TO_JSVAL pass a true boolean
    
    Debug builds of libmozjs assert that the value passed to BOOLEAN_TO_JSVAL
    is not just truthy, but one of JS_FALSE (0) or JS_TRUE (1). We can't
    possibly fix all API consumers to respect this rule, so do the conversion
    for them.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=691038

 gi/arg.c   |    2 +-
 gi/value.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/gi/arg.c b/gi/arg.c
index 7796225..7c019d3 100644
--- a/gi/arg.c
+++ b/gi/arg.c
@@ -2373,7 +2373,7 @@ gjs_value_from_g_argument (JSContext  *context,
         break;
 
     case GI_TYPE_TAG_BOOLEAN:
-        *value_p = BOOLEAN_TO_JSVAL(arg->v_int);
+        *value_p = BOOLEAN_TO_JSVAL(!!arg->v_int);
         break;
 
     case GI_TYPE_TAG_INT32:
diff --git a/gi/value.c b/gi/value.c
index 18cd76b..0119d90 100644
--- a/gi/value.c
+++ b/gi/value.c
@@ -669,7 +669,7 @@ gjs_value_from_g_value_internal(JSContext    *context,
     } else if (gtype == G_TYPE_BOOLEAN) {
         gboolean v;
         v = g_value_get_boolean(gvalue);
-        *value_p = BOOLEAN_TO_JSVAL(v);
+        *value_p = BOOLEAN_TO_JSVAL(!!v);
     } else if (g_type_is_a(gtype, G_TYPE_OBJECT) || g_type_is_a(gtype, G_TYPE_INTERFACE)) {
         GObject *gobj;
         JSObject *obj;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]