]> gitweb.factorcode.org Git - factor.git/blob - basis/gobject-introspection/gobject-introspection.factor
gobject-introspection: add REPLACE-C-TYPE: parsing word
[factor.git] / basis / gobject-introspection / gobject-introspection.factor
1 ! Copyright (C) 2009 Anton Gorenko.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs combinators gobject-introspection.common
4 gobject-introspection.ffi gobject-introspection.loader kernel lexer
5 locals math namespaces sequences strings.parser vocabs.parser xml ;
6 IN: gobject-introspection
7
8 : with-child-vocab ( name quot -- )
9     swap current-vocab name>>
10     [ swap "." glue set-current-vocab call ] keep
11     set-current-vocab ; inline
12
13 :: define-gir-vocab ( file-name -- )
14     file-name file>xml xml>repository
15
16     current-vocab name>> dup ffi-vocab tail?
17     [ ffi-vocab length 1 + head* current-lib set-global ]
18     [ drop ] if ! throw the error
19     {
20         [ define-ffi-repository ]
21     } cleave
22     V{ } clone implement-structs set-global
23     H{ } clone replaced-c-types set-global ;
24
25 SYNTAX: GIR: scan define-gir-vocab ;
26
27 SYNTAX: IMPLEMENT-STRUCTS:
28     ";" parse-tokens
29     implement-structs [ swap append! ] change-global ;
30
31 SYNTAX: REPLACE-C-TYPE:
32     scan unescape-string scan swap
33     replaced-c-types get-global set-at ;