]> gitweb.factorcode.org Git - factor.git/commitdiff
gobject-introspection: support more number type constants.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 30 Jan 2020 16:21:57 +0000 (08:21 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 30 Jan 2020 16:23:13 +0000 (08:23 -0800)
basis/gobject-introspection/ffi/ffi.factor

index 6e51f8010e99b3c0f09bced46f140fabca638bde..1683be9fb22b15f3e3acd0160acb723a91f50549 100644 (file)
@@ -67,11 +67,21 @@ M: incorrect-type type>c-type drop void* ;
 
 GENERIC: parse-const-value ( str data-type -- value )
 
+: number-type? ( name -- ? )
+    {
+        [ "gint" head? ]
+        [ "guint" head? ]
+        [ "gchar" = ]
+        [ "guchar" = ]
+        [ "gdouble" = ]
+        [ "gfloat" = ]
+    } 1|| ;
+
 M: atomic-type parse-const-value
     name>> {
-        { "gint" [ string>number ] }
-        { "gdouble" [ string>number ] }
-    } case ;
+        { [ dup number-type? ] [ drop string>number ] }
+        { [ dup "gboolean" = ] [ drop "true" = ] }
+    } cond ;
 
 M: utf8-type parse-const-value drop ;