[perl-Glib-Object-Introspection] Allow undefined values for boolean arguments



commit 9e4e77b0ced3c4999878f4ce58170001cbab6647
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date:   Sun Feb 9 19:49:36 2014 +0100

    Allow undefined values for boolean arguments
    
    Interpret them as "false".

 NEWS                     |    1 +
 gperl-i11n-marshal-arg.c |    5 +++--
 t/00-basic-types.t       |    4 +++-
 3 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/NEWS b/NEWS
index b2f6ce9..75e4708 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
 Overview of changes in Glib::Object::Introspection <next>
 ========================================================
 
+* Allow undefined values for boolean arguments (and interpret them as "false").
 * Fix a few internal signed/unsigned integer mismatches.
 
 Overview of changes in Glib::Object::Introspection 0.019
diff --git a/gperl-i11n-marshal-arg.c b/gperl-i11n-marshal-arg.c
index 74cfa49..7e49b34 100644
--- a/gperl-i11n-marshal-arg.c
+++ b/gperl-i11n-marshal-arg.c
@@ -14,9 +14,10 @@ sv_to_arg (SV * sv,
        GITypeTag tag = g_type_info_get_tag (type_info);
 
        if (!gperl_sv_is_defined (sv))
-               /* Interfaces and void types need to be able to handle undef
-                * separately. */
+               /* Interfaces, booleans and void types need to be able to
+                * handle undef separately.*/
                if (!may_be_null && tag != GI_TYPE_TAG_INTERFACE
+                                && tag != GI_TYPE_TAG_BOOLEAN
                                 && tag != GI_TYPE_TAG_VOID)
                {
                        if (arg_info) {
diff --git a/t/00-basic-types.t b/t/00-basic-types.t
index 7f28e0d..1230d48 100644
--- a/t/00-basic-types.t
+++ b/t/00-basic-types.t
@@ -8,10 +8,12 @@ use warnings;
 use utf8;
 use POSIX qw(FLT_MIN FLT_MAX DBL_MIN DBL_MAX);
 
-plan tests => 34;
+plan tests => 36;
 
 ok (Regress::test_boolean (1));
 ok (!Regress::test_boolean (0));
+ok (!Regress::test_boolean (''));
+ok (!Regress::test_boolean (undef));
 is (Regress::test_int8 (-127), -127);
 is (Regress::test_uint8 (255), 255);
 is (Regress::test_int16 (-32767), -32767);


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