From c196f9f022c00e5ede27ebcfb70f1753c2fdab7b Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Thu, 30 Jan 2020 08:21:57 -0800 Subject: [PATCH] gobject-introspection: support more number type constants. --- basis/gobject-introspection/ffi/ffi.factor | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/basis/gobject-introspection/ffi/ffi.factor b/basis/gobject-introspection/ffi/ffi.factor index 6e51f8010e..1683be9fb2 100644 --- a/basis/gobject-introspection/ffi/ffi.factor +++ b/basis/gobject-introspection/ffi/ffi.factor @@ -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 ;