diff --git a/basis/gdk/ffi/ffi.factor b/basis/gdk/ffi/ffi.factor index 11dbbc6fdb..28a9f7be37 100644 --- a/basis/gdk/ffi/ffi.factor +++ b/basis/gdk/ffi/ffi.factor @@ -18,6 +18,8 @@ TYPEDEF: guint32 GdkNativeWindow TYPEDEF: guint32 GdkWChar C-TYPE: GdkXEvent +REPLACE-C-TYPE: any gpointer + IMPLEMENT-STRUCTS: GdkEventAny GdkEventKey GdkEventButton GdkEventScroll GdkEventMotion GdkEventExpose GdkEventVisibility GdkEventCrossing GdkEventFocus GdkEventConfigure GdkEventProperty diff --git a/basis/glib/ffi/ffi.factor b/basis/glib/ffi/ffi.factor index d7b265004e..f810348aa0 100644 --- a/basis/glib/ffi/ffi.factor +++ b/basis/glib/ffi/ffi.factor @@ -13,8 +13,6 @@ IN: glib.ffi } cond >> -<< double "long double" current-vocab create typedef >> - TYPEDEF: char gchar TYPEDEF: uchar guchar TYPEDEF: short gshort @@ -65,7 +63,9 @@ TYPEDEF: guint32 gunichar TYPEDEF: guint16 gunichar2 TYPEDEF: gpointer pointer -TYPEDEF: gpointer any + +REPLACE-C-TYPE: long\sdouble double +REPLACE-C-TYPE: any gpointer IMPLEMENT-STRUCTS: GPollFD GSource GSourceFuncs ; diff --git a/basis/gobject-introspection/common/common.factor b/basis/gobject-introspection/common/common.factor index 8bf2c7eb78..7ffca04bde 100644 --- a/basis/gobject-introspection/common/common.factor +++ b/basis/gobject-introspection/common/common.factor @@ -14,4 +14,8 @@ SYMBOL: aliases aliases [ H{ } ] initialize SYMBOL: implement-structs +implement-structs [ V{ } ] initialize + +SYMBOL: replaced-c-types +replaced-c-types [ H{ } ] initialize diff --git a/basis/gobject-introspection/ffi/ffi.factor b/basis/gobject-introspection/ffi/ffi.factor index 9af0186553..fb58ede1f6 100644 --- a/basis/gobject-introspection/ffi/ffi.factor +++ b/basis/gobject-introspection/ffi/ffi.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2009 Anton Gorenko. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien alien.c-types alien.parser arrays +USING: accessors alien alien.c-types alien.parser arrays assocs classes.parser classes.struct combinators combinators.short-circuit definitions effects fry gobject-introspection.common gobject-introspection.types kernel @@ -9,7 +9,9 @@ sequences.generalizations words words.constant ; IN: gobject-introspection.ffi : string>c-type ( str -- c-type ) - parse-c-type ; + dup CHAR: * swap index [ cut ] [ "" ] if* + [ replaced-c-types get-global ?at drop ] dip + append parse-c-type ; : define-each ( nodes quot -- ) '[ dup @ >>ffi drop ] each ; inline diff --git a/basis/gobject-introspection/gobject-introspection.factor b/basis/gobject-introspection/gobject-introspection.factor index f0a5a982b2..ae934ea76f 100755 --- a/basis/gobject-introspection/gobject-introspection.factor +++ b/basis/gobject-introspection/gobject-introspection.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2009 Anton Gorenko. ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs combinators gobject-introspection.common -gobject-introspection.ffi gobject-introspection.loader -kernel lexer locals math namespaces sequences vocabs.parser xml ; +gobject-introspection.ffi gobject-introspection.loader kernel lexer +locals math namespaces sequences strings.parser vocabs.parser xml ; IN: gobject-introspection : with-child-vocab ( name quot -- ) @@ -19,9 +19,15 @@ IN: gobject-introspection { [ define-ffi-repository ] } cleave - f implement-structs set-global ; + V{ } clone implement-structs set-global + H{ } clone replaced-c-types set-global ; SYNTAX: GIR: scan define-gir-vocab ; SYNTAX: IMPLEMENT-STRUCTS: - ";" parse-tokens implement-structs set-global ; + ";" parse-tokens + implement-structs [ swap append! ] change-global ; + +SYNTAX: REPLACE-C-TYPE: + scan unescape-string scan swap + replaced-c-types get-global set-at ; diff --git a/basis/gobject/ffi/ffi.factor b/basis/gobject/ffi/ffi.factor index 2904ceb833..7e2c5eace6 100644 --- a/basis/gobject/ffi/ffi.factor +++ b/basis/gobject/ffi/ffi.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2009 Anton Gorenko. ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.syntax alien.destructors alien.libraries -combinators kernel literals math system +classes.struct combinators kernel literals math system gobject-introspection glib.ffi ; EXCLUDE: alien.c-types => pointer ; IN: gobject.ffi @@ -18,12 +18,13 @@ TYPEDEF: void* GSignalCMarshaller TYPEDEF: void GStrv TYPEDEF: gchar* gchararray -IMPLEMENT-STRUCTS: GValue ; - GIR: vocab:gobject/GObject-2.0.gir IN: gobject.ffi +FORGET: GValue +STRUCT: GValue { g_type GType } { data guint64[2] } ; + FORGET: GIOCondition FORGET: G_IO_IN FORGET: G_IO_OUT diff --git a/extra/gstreamer/net/ffi/ffi.factor b/extra/gstreamer/net/ffi/ffi.factor index 5c5e315c39..fbd5148ff4 100644 --- a/extra/gstreamer/net/ffi/ffi.factor +++ b/extra/gstreamer/net/ffi/ffi.factor @@ -13,5 +13,7 @@ IN: gstreamer.net.ffi } cond >> +REPLACE-C-TYPE: any gpointer + GIR: vocab:gstreamer/net/GstNet-0.10.gir