[perl-Glib-Object-Introspection] Add functions for handling raw flags values



commit 15c0b5122fbcf588625b4f3c2c9135e78b7f321a
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date:   Mon May 1 15:09:15 2017 +0200

    Add functions for handling raw flags values
    
    Glib::Object::Introspection->convert_flags_to_sv and
    Glib::Object::Introspection->convert_sv_to_flags.

 GObjectIntrospection.xs          |   20 ++++++++++++++++++++
 lib/Glib/Object/Introspection.pm |   17 +++++++++++------
 2 files changed, 31 insertions(+), 6 deletions(-)
---
diff --git a/GObjectIntrospection.xs b/GObjectIntrospection.xs
index 2361dc9..58fe26f 100644
--- a/GObjectIntrospection.xs
+++ b/GObjectIntrospection.xs
@@ -1019,6 +1019,26 @@ convert_enum_to_sv (class, const gchar *package, gint n)
     OUTPUT:
        RETVAL
 
+gint
+convert_sv_to_flags (class, const gchar *package, SV *sv)
+    PREINIT:
+       GType gtype;
+    CODE:
+       gtype = gperl_type_from_package (package);
+       RETVAL = gperl_convert_flags (gtype, sv);
+    OUTPUT:
+       RETVAL
+
+SV *
+convert_flags_to_sv (class, const gchar *package, gint n)
+    PREINIT:
+       GType gtype;
+    CODE:
+       gtype = gperl_type_from_package (package);
+       RETVAL = gperl_convert_back_flags (gtype, n);
+    OUTPUT:
+       RETVAL
+
 # --------------------------------------------------------------------------- #
 
 MODULE = Glib::Object::Introspection   PACKAGE = Glib::Object::Introspection::GValueWrapper
diff --git a/lib/Glib/Object/Introspection.pm b/lib/Glib/Object/Introspection.pm
index 7439408..555acef 100644
--- a/lib/Glib/Object/Introspection.pm
+++ b/lib/Glib/Object/Introspection.pm
@@ -688,18 +688,23 @@ For example:
   $box->child_get_property ($label, 'expand', $gvalue);
   my $value = $gvalue->get_value
 
-=head2 Handling extendable enumerations
-
-If you need to handle extendable enumerations for which more than the
-pre-defined values might be valid, then use C<<
-Glib::Object::Introspection->convert_enum_to_sv >> and C<<
-Glib::Object::Introspection->convert_sv_to_enum >>.  They will raise an
+=head2 Handling raw enumerations and flags
+
+If you need to handle raw enumerations/flags or extendable enumerations for
+which more than the pre-defined values might be valid, then use C<<
+Glib::Object::Introspection->convert_enum_to_sv >>, C<<
+Glib::Object::Introspection->convert_sv_to_enum >>, C<<
+Glib::Object::Introspection->convert_flags_to_sv >> and C<<
+Glib::Object::Introspection->convert_sv_to_flags >>.  They will raise an
 exception on unknown values; catching it then allows you to implement fallback
 behavior.
 
   Glib::Object::Introspection->convert_enum_to_sv (package, enum_value)
   Glib::Object::Introspection->convert_sv_to_enum (package, sv)
 
+  Glib::Object::Introspection->convert_flags_to_sv (package, flags_value)
+  Glib::Object::Introspection->convert_sv_to_flags (package, sv)
+
 =head1 SEE ALSO
 
 =over


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