factor/basis/gobject-introspection/gobject-introspection.factor

34 lines
1.0 KiB
Factor
Raw Normal View History

! Copyright (C) 2009 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
2010-07-17 07:17:03 -04:00
USING: accessors assocs combinators gobject-introspection.common
gobject-introspection.ffi gobject-introspection.loader kernel lexer
locals math namespaces sequences strings.parser vocabs.parser xml ;
2010-07-17 07:17:03 -04:00
IN: gobject-introspection
: with-child-vocab ( name quot -- )
swap current-vocab name>>
[ swap "." glue set-current-vocab call ] keep
set-current-vocab ; inline
:: define-gir-vocab ( file-name -- )
file-name file>xml xml>repository
current-vocab name>> dup ffi-vocab tail?
[ ffi-vocab length 1 + head* current-lib set-global ]
[ drop ] if ! throw the error
{
[ define-ffi-repository ]
} cleave
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 [ swap append! ] change-global ;
SYNTAX: REPLACE-C-TYPE:
scan unescape-string scan swap
replaced-c-types get-global set-at ;