Merge branch 'master' of git://github.com/slavapestov/factor

db4
John Benediktsson 2011-03-05 19:07:49 -08:00
commit 73f5fb866f
185 changed files with 309387 additions and 557 deletions

9798
basis/atk/Atk-1.0.gir Normal file

File diff suppressed because it is too large Load Diff

5
basis/atk/atk.factor Normal file
View File

@ -0,0 +1,5 @@
! Copyright (C) 2009 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: atk.ffi ;
IN: atk

1
basis/atk/authors.txt Normal file
View File

@ -0,0 +1 @@
Anton Gorenko

20
basis/atk/ffi/ffi.factor Normal file
View File

@ -0,0 +1,20 @@
! Copyright (C) 2010 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.libraries alien.syntax combinators
gobject-introspection kernel system vocabs.loader ;
IN: atk.ffi
<<
"gobject.ffi" require
>>
LIBRARY: atk
<<
"atk" {
{ [ os winnt? ] [ "libatk-1.0-0.dll" cdecl add-library ] }
{ [ os unix? ] [ drop ] }
} cond
>>
GIR: vocab:atk/Atk-1.0.gir

1
basis/atk/summary.txt Normal file
View File

@ -0,0 +1 @@
Atk binding

0
basis/pango/fonts/tags.txt → basis/atk/tags.txt Normal file → Executable file
View File

View File

@ -2,10 +2,11 @@ USING: system vocabs vocabs.loader kernel combinators
namespaces sequences io.backend accessors ;
IN: bootstrap.io
"bootstrap.compiler" vocab [
"io.backend." {
{ [ "io-backend" get ] [ "io-backend" get ] }
{ [ os unix? ] [ "unix." os name>> append ] }
{ [ os windows? ] [ "windows" ] }
} cond append require
] when
"bootstrap.compiler" require
"bootstrap.threads" require
"io.backend." {
{ [ "io-backend" get ] [ "io-backend" get ] }
{ [ os unix? ] [ "unix." os name>> append ] }
{ [ os windows? ] [ "windows" ] }
} cond append require

View File

@ -2,12 +2,14 @@ USING: alien namespaces system combinators kernel sequences
vocabs vocabs.loader ;
IN: bootstrap.ui
"bootstrap.compiler" vocab [
"ui-backend" get [
{
{ [ os macosx? ] [ "cocoa" ] }
{ [ os windows? ] [ "windows" ] }
{ [ os unix? ] [ "x11" ] }
} cond
] unless* "ui.backend." prepend require
] when
"bootstrap.math" require
"bootstrap.compiler" require
"bootstrap.threads" require
"ui-backend" get [
{
{ [ os macosx? ] [ "cocoa" ] }
{ [ os windows? ] [ "windows" ] }
{ [ os unix? ] [ "gtk" ] }
} cond
] unless* "ui.backend." prepend require

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays classes.tuple combinators
combinators.short-circuit kernel locals math math.functions
math.order sequences summary system threads vocabs.loader ;
math.order sequences summary system vocabs.loader ;
IN: calendar
HOOK: gmt-offset os ( -- hours minutes seconds )
@ -540,10 +540,9 @@ M: integer end-of-year 12 31 <date> ;
: unix-time>timestamp ( seconds -- timestamp )
seconds unix-1970 time+ ;
M: duration sleep
duration>nanoseconds >integer nano-count + sleep-until ;
{
{ [ os unix? ] [ "calendar.unix" ] }
{ [ os windows? ] [ "calendar.windows" ] }
} cond require
{ "threads" "calendar" } "calendar.threads" require-when

View File

@ -0,0 +1,7 @@
! Copyright (C) 2011 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: calendar math system threads ;
IN: calendar.threads
M: duration sleep
duration>nanoseconds >integer nano-count + sleep-until ;

View File

@ -1,19 +1,20 @@
! Copyright (C) 2009, 2010 Doug Coleman, Slava Pestov.
! Copyright (C) 2009, 2011 Doug Coleman, Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors combinators combinators.short-circuit kernel
locals math math.order sequences assocs namespaces vectors fry
arrays splitting compiler.cfg.def-use compiler.cfg
USING: arrays accessors assocs combinators combinators.short-circuit
dlists deques kernel locals math math.order sequences
sets vectors fry splitting compiler.cfg.def-use compiler.cfg
compiler.cfg.rpo compiler.cfg.predecessors compiler.cfg.renaming
compiler.cfg.instructions compiler.cfg.utilities ;
FROM: namespaces => get set ;
IN: compiler.cfg.branch-splitting
: clone-instructions ( insns -- insns' )
[ clone dup rename-insn-temps ] map ;
: clone-basic-block ( bb -- bb' )
! The new block temporarily gets the same RPO number as the old one,
! until the next time RPO is computed. This is just to make
! 'back-edge?' work.
! The new block temporarily gets the same RPO number as the
! old one, until the next time RPO is computed. This is just
! to make 'back-edge?' work.
<basic-block>
swap
{
@ -25,18 +26,21 @@ IN: compiler.cfg.branch-splitting
: new-blocks ( bb -- copies )
dup predecessors>> [
[ clone-basic-block ] dip
1vector >>predecessors
[ clone-basic-block ] [ 1vector ] bi*
>>predecessors
] with map ;
: update-predecessor-successors ( copies old-bb -- )
[ predecessors>> swap ] keep
'[ [ _ ] 2dip update-predecessors ] 2each ;
'[ [ _ ] dip update-successors ] 2each ;
:: update-successor-predecessor ( copies old-bb succ -- )
succ
[ { old-bb } split copies join V{ } like ] change-predecessors
drop ;
succ predecessors>> dup >array :> ( preds preds' )
preds delete-all
preds' [
dup old-bb eq?
[ drop copies preds push-all ] [ preds push ] if
] each ;
: update-successor-predecessors ( copies old-bb -- )
dup successors>>
@ -77,11 +81,29 @@ UNION: irrelevant ##peek ##replace ##inc-d ##inc-r ;
] if
] if ;
SYMBOL: worklist
SYMBOL: visited
: add-to-worklist ( bb -- )
dup visited get in? [ drop ] [
[ visited get adjoin ]
[ worklist get push-front ] bi
] if ;
: init-worklist ( cfg -- )
<dlist> worklist set
HS{ } clone visited set
entry>> add-to-worklist ;
: split-branches ( cfg -- cfg' )
needs-predecessors
dup [
dup split-branch? [ split-branch ] [ drop ] if
] each-basic-block
dup init-worklist
! For back-edge?
dup post-order drop
worklist get [
dup split-branch? [ dup split-branch ] when
successors>> [ add-to-worklist ] each
] slurp-deque
cfg-changed ;

View File

@ -221,3 +221,6 @@ IN: compiler.cfg.builder.tests
! Regression. Make sure everything is inlined correctly
[ f ] [ M\ hashtable set-at [ { [ ##call? ] [ word>> \ set-slot eq? ] } 1&& ] contains-insn? ] unit-test
! Regression. Make sure branch splitting works.
[ 2 ] [ [ 1 2 ? ] [ ##return? ] count-insns ] unit-test

19560
basis/gdk/Gdk-3.0.gir Normal file

File diff suppressed because it is too large Load Diff

1
basis/gdk/authors.txt Normal file
View File

@ -0,0 +1 @@
Anton Gorenko

103
basis/gdk/ffi/ffi.factor Normal file
View File

@ -0,0 +1,103 @@
! Copyright (C) 2010 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types alien.destructors alien.libraries
alien.syntax cairo.ffi classes.struct combinators
gobject-introspection gobject-introspection.standard-types
kernel system vocabs.loader ;
IN: gdk.ffi
<<
"pango.ffi" require
"gdk.pixbuf.ffi" require
>>
LIBRARY: gdk
<<
"gdk" {
{ [ os winnt? ] [ "libgdk-win32-2.0-0.dll" cdecl add-library ] }
{ [ os unix? ] [ drop ] }
} cond
>>
! <workaround these types are from cairo 1.10
STRUCT: cairo_rectangle_int_t
{ x int } { y int } { width int } { height int } ;
C-TYPE: cairo_region_t
! workaround>
FOREIGN-RECORD-TYPE: cairo.RectangleInt cairo_rectangle_int_t
FOREIGN-RECORD-TYPE: cairo.Region cairo_region_t
FOREIGN-RECORD-TYPE: cairo.FontOptions cairo_font_options_t
FOREIGN-RECORD-TYPE: cairo.Surface cairo_surface_t
FOREIGN-RECORD-TYPE: cairo.Pattern cairo_pattern_t
FOREIGN-RECORD-TYPE: cairo.Context cairo_t
FOREIGN-ENUM-TYPE: cairo.Content cairo_content_t
GIR: vocab:gdk/Gdk-3.0.gir
DESTRUCTOR: gdk_cursor_unref
STRUCT: GdkEventButton
{ type GdkEventType }
{ window GdkWindow* }
{ send_event gint8 }
{ time guint32 }
{ x gdouble }
{ y gdouble }
{ axes gdouble* }
{ state guint }
{ button guint }
{ device GdkDevice* }
{ x_root gdouble }
{ y_root gdouble } ;
STRUCT: GdkEventConfigure
{ type GdkEventType }
{ window GdkWindow* }
{ send_event gint8 }
{ x gint }
{ y gint }
{ width gint }
{ height gint } ;
STRUCT: GdkEventKey
{ type GdkEventType }
{ window GdkWindow* }
{ send_event gint8 }
{ time guint32 }
{ state guint }
{ keyval guint }
{ length gint }
{ string gchar* }
{ hardware_keycode guint16 }
{ group guint8 }
{ is_modifier uint bits: 1 } ;
STRUCT: GdkEventMotion
{ type GdkEventType }
{ window GdkWindow* }
{ send_event gint8 }
{ time guint32 }
{ x gdouble }
{ y gdouble }
{ axes gdouble* }
{ state guint }
{ is_hint gint16 }
{ device GdkDevice* }
{ x_root gdouble }
{ y_root gdouble } ;
STRUCT: GdkEventScroll
{ type GdkEventType }
{ window GdkWindow* }
{ send_event gint8 }
{ time guint32 }
{ x gdouble }
{ y gdouble }
{ state guint }
{ direction GdkScrollDirection }
{ device GdkDevice* }
{ x_root gdouble }
{ y_root gdouble } ;

5
basis/gdk/gdk.factor Normal file
View File

@ -0,0 +1,5 @@
! Copyright (C) 2009 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: gdk.ffi ;
IN: gdk

File diff suppressed because it is too large Load Diff

1
basis/gdk/gl/authors.txt Normal file
View File

@ -0,0 +1 @@
Anton Gorenko

View File

@ -0,0 +1,13 @@
! Copyright (C) 2010 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.libraries alien.syntax combinators
gobject-introspection kernel system vocabs.loader ;
IN: gdk.gl.ffi
<<
"gdk.ffi" require
>>
LIBRARY: gdk.gl
GIR: vocab:gdk/gl/GdkGLExt-1.0.gir

5
basis/gdk/gl/gl.factor Normal file
View File

@ -0,0 +1,5 @@
! Copyright (C) 2010 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: gdk.gl.ffi ;
IN: gdk.gl

1
basis/gdk/gl/summary.txt Normal file
View File

@ -0,0 +1 @@
GdkGLExt binding

1
basis/gdk/gl/tags.txt Executable file
View File

@ -0,0 +1 @@
bindings

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
Anton Gorenko

View File

@ -0,0 +1,20 @@
! Copyright (C) 2010 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.libraries alien.syntax combinators
gobject-introspection kernel system vocabs.loader ;
IN: gdk.pixbuf.ffi
<<
"gio.ffi" require
>>
LIBRARY: gdk.pixbuf
<<
"gdk.pixbuf" {
{ [ os winnt? ] [ "libgdk_pixbuf-2.0-0.dll" cdecl add-library ] }
{ [ os unix? ] [ drop ] }
} cond
>>
GIR: vocab:gdk/pixbuf/GdkPixbuf-2.0.gir

View File

@ -0,0 +1,5 @@
! Copyright (C) 2009 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: gdk.pixbuf.ffi ;
IN: gdk.pixbuf

View File

@ -0,0 +1 @@
GdkPixbuf binding

1
basis/gdk/pixbuf/tags.txt Executable file
View File

@ -0,0 +1 @@
bindings

1
basis/gdk/summary.txt Normal file
View File

@ -0,0 +1 @@
Gdk binding

1
basis/gdk/tags.txt Executable file
View File

@ -0,0 +1 @@
bindings

44841
basis/gio/Gio-2.0.gir Normal file

File diff suppressed because it is too large Load Diff

1
basis/gio/authors.txt Normal file
View File

@ -0,0 +1 @@
Anton Gorenko

20
basis/gio/ffi/ffi.factor Normal file
View File

@ -0,0 +1,20 @@
! Copyright (C) 2010 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.libraries alien.syntax combinators
gobject-introspection kernel system vocabs.loader ;
IN: gio.ffi
<<
"gobject.ffi" require
>>
LIBRARY: gio
<<
"gio" {
{ [ os winnt? ] [ "libgio-2.0-0.dll" cdecl add-library ] }
{ [ os unix? ] [ drop ] }
} cond
>>
GIR: vocab:gio/Gio-2.0.gir

5
basis/gio/gio.factor Normal file
View File

@ -0,0 +1,5 @@
! Copyright (C) 2009 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: gio.ffi ;
IN: gio

1
basis/gio/summary.txt Normal file
View File

@ -0,0 +1 @@
GIO binding

1
basis/gio/tags.txt Executable file
View File

@ -0,0 +1 @@
bindings

20393
basis/glib/GLib-2.0.gir Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,2 +1 @@
Matthew Willis
Slava Pestov
Anton Gorenko

40
basis/glib/ffi/ffi.factor Normal file
View File

@ -0,0 +1,40 @@
! Copyright (C) 2010 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.destructors alien.libraries alien.syntax
combinators kernel gobject-introspection
gobject-introspection.standard-types system ;
IN: glib.ffi
LIBRARY: glib
<<
"glib" {
{ [ os winnt? ] [ "libglib-2.0-0.dll" cdecl add-library ] }
{ [ os macosx? ] [ "/opt/local/lib/libglib-2.0.0.dylib" cdecl add-library ] }
{ [ os unix? ] [ drop ] }
} cond
>>
IMPLEMENT-STRUCTS: GPollFD GSource GSourceFuncs ;
CONSTANT: G_MININT8 HEX: -80
CONSTANT: G_MAXINT8 HEX: 7f
CONSTANT: G_MAXUINT8 HEX: ff
CONSTANT: G_MININT16 HEX: -8000
CONSTANT: G_MAXINT16 HEX: 7fff
CONSTANT: G_MAXUINT16 HEX: ffff
CONSTANT: G_MININT32 HEX: -80000000
CONSTANT: G_MAXINT32 HEX: 7fffffff
CONSTANT: G_MAXUINT32 HEX: ffffffff
CONSTANT: G_MININT64 HEX: -8000000000000000
CONSTANT: G_MAXINT64 HEX: 7fffffffffffffff
CONSTANT: G_MAXUINT64 HEX: ffffffffffffffff
GIR: vocab:glib/GLib-2.0.gir
DESTRUCTOR: g_source_unref
DESTRUCTOR: g_free
CALLBACK: gboolean GSourceFuncsPrepareFunc ( GSource* source, gint* timeout_ ) ;
CALLBACK: gboolean GSourceFuncsCheckFunc ( GSource* source ) ;
CALLBACK: gboolean GSourceFuncsDispatchFunc ( GSource* source, GSourceFunc callback, gpointer user_data ) ;

View File

@ -1,36 +1,5 @@
! Copyright (C) 2008 Matthew Willis.
! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license
USING: alien alien.c-types alien.syntax alien.destructors
combinators system alien.libraries ;
! Copyright (C) 2009 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: glib.ffi ;
IN: glib
<<
{
{ [ os winnt? ] [ "glib" "libglib-2.0-0.dll" cdecl add-library ] }
{ [ os macosx? ] [ "glib" "/opt/local/lib/libglib-2.0.0.dylib" cdecl add-library ] }
{ [ os unix? ] [ ] }
} cond
{
{ [ os winnt? ] [ "gobject" "libgobject-2.0-0.dll" cdecl add-library ] }
{ [ os macosx? ] [ "gobject" "/opt/local/lib/libgobject-2.0.0.dylib" cdecl add-library ] }
{ [ os unix? ] [ ] }
} cond
>>
LIBRARY: glib
TYPEDEF: void* gpointer
TYPEDEF: int gint
TYPEDEF: bool gboolean
FUNCTION: void g_free ( gpointer mem ) ;
LIBRARY: gobject
FUNCTION: void g_object_unref ( gpointer object ) ;
DESTRUCTOR: g_object_unref

View File

@ -1 +1 @@
Binding for GLib
GLib binding

0
basis/glib/tags.txt Normal file → Executable file
View File

View File

@ -0,0 +1,111 @@
<?xml version="1.0"?>
<!-- This file was automatically generated from C sources - DO NOT EDIT!
To affect the contents of this file, edit the original C definitions,
and/or use gtk-doc annotations. -->
<repository version="1.2"
xmlns="http://www.gtk.org/introspection/core/1.0"
xmlns:c="http://www.gtk.org/introspection/c/1.0"
xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<include name="GLib" version="2.0"/>
<package name="gmodule-2.0"/>
<c:include name="gmodule.h"/>
<namespace name="GModule"
version="2.0"
shared-library="libgmodule-2.0.so.0"
c:identifier-prefixes="G"
c:symbol-prefixes="g">
<record name="Module" c:type="GModule" disguised="1">
<method name="close" c:identifier="g_module_close">
<return-value transfer-ownership="none">
<type name="gboolean" c:type="gboolean"/>
</return-value>
</method>
<method name="make_resident" c:identifier="g_module_make_resident">
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
</method>
<method name="name" c:identifier="g_module_name">
<return-value transfer-ownership="none">
<type name="utf8" c:type="gchar*"/>
</return-value>
</method>
<method name="symbol" c:identifier="g_module_symbol">
<return-value transfer-ownership="none">
<type name="gboolean" c:type="gboolean"/>
</return-value>
<parameters>
<parameter name="symbol_name" transfer-ownership="none">
<type name="utf8" c:type="gchar*"/>
</parameter>
<parameter name="symbol" transfer-ownership="none">
<type name="gpointer" c:type="gpointer*"/>
</parameter>
</parameters>
</method>
</record>
<callback name="ModuleCheckInit" c:type="GModuleCheckInit">
<return-value transfer-ownership="none">
<type name="utf8" c:type="gchar*"/>
</return-value>
<parameters>
<parameter name="module" transfer-ownership="none">
<type name="Module" c:type="GModule*"/>
</parameter>
</parameters>
</callback>
<bitfield name="ModuleFlags" c:type="GModuleFlags">
<member name="lazy" value="1" c:identifier="G_MODULE_BIND_LAZY"/>
<member name="local" value="2" c:identifier="G_MODULE_BIND_LOCAL"/>
<member name="mask" value="3" c:identifier="G_MODULE_BIND_MASK"/>
</bitfield>
<callback name="ModuleUnload" c:type="GModuleUnload">
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<parameter name="module" transfer-ownership="none">
<type name="Module" c:type="GModule*"/>
</parameter>
</parameters>
</callback>
<function name="module_build_path" c:identifier="g_module_build_path">
<return-value transfer-ownership="full">
<type name="utf8" c:type="gchar*"/>
</return-value>
<parameters>
<parameter name="directory" transfer-ownership="none">
<type name="utf8" c:type="gchar*"/>
</parameter>
<parameter name="module_name" transfer-ownership="none">
<type name="utf8" c:type="gchar*"/>
</parameter>
</parameters>
</function>
<function name="module_error" c:identifier="g_module_error">
<return-value transfer-ownership="none">
<type name="utf8" c:type="gchar*"/>
</return-value>
</function>
<function name="module_open"
c:identifier="g_module_open"
introspectable="0">
<return-value>
<type name="Module" c:type="GModule*"/>
</return-value>
<parameters>
<parameter name="file_name" transfer-ownership="none">
<type name="utf8" c:type="gchar*"/>
</parameter>
<parameter name="flags" transfer-ownership="none">
<type name="ModuleFlags" c:type="GModuleFlags"/>
</parameter>
</parameters>
</function>
<function name="module_supported" c:identifier="g_module_supported">
<return-value transfer-ownership="none">
<type name="gboolean" c:type="gboolean"/>
</return-value>
</function>
</namespace>
</repository>

View File

@ -0,0 +1 @@
Anton Gorenko

View File

@ -0,0 +1,21 @@
! Copyright (C) 2010 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.libraries alien.syntax combinators
gobject-introspection kernel system vocabs.loader ;
IN: gmodule.ffi
<<
"glib.ffi" require
>>
LIBRARY: gmodule
<<
"gmodule" {
{ [ os winnt? ] [ "libgmodule-2.0-0.dll" cdecl add-library ] }
{ [ os macosx? ] [ drop ] }
{ [ os unix? ] [ "libgmodule-2.0.so" cdecl add-library ] }
} cond
>>
GIR: vocab:gmodule/GModule-2.0.gir

View File

@ -0,0 +1,5 @@
! Copyright (C) 2009 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: gmodule.ffi ;
IN: gmodule

View File

@ -0,0 +1 @@
GModule binding

1
basis/gmodule/tags.txt Executable file
View File

@ -0,0 +1 @@
bindings

View File

@ -0,0 +1 @@
Anton Gorenko

View File

@ -0,0 +1,9 @@
! Copyright (C) 2010 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: namespaces ;
IN: gobject-introspection.common
SYMBOL: current-namespace-name
SYMBOL: implement-structs
implement-structs [ V{ } ] initialize

View File

@ -0,0 +1,352 @@
! Copyright (C) 2010 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.c-types alien.parser arrays ascii
classes.parser classes.struct combinators combinators.short-circuit
gobject-introspection.common gobject-introspection.repository
gobject-introspection.types kernel locals make math.parser namespaces
parser sequences splitting.monotonic vocabs.parser words
words.constant ;
IN: gobject-introspection.ffi
SYMBOL: constant-prefix
: def-c-type ( c-type-name base-c-type -- )
swap (CREATE-C-TYPE) typedef ;
: defer-c-type ( c-type-name -- c-type )
deferred-type swap (CREATE-C-TYPE) [ typedef ] keep ;
! create-in dup
! [ fake-definition ] [ undefined-def define ] bi ;
:: defer-types ( types type-info-class -- )
types [
[ c-type>> defer-c-type ]
[ name>> qualified-name ] bi
type-info-class new swap register-type
] each ;
: def-alias-c-type ( base-c-type c-type-name -- c-type )
(CREATE-C-TYPE) [ typedef ] keep ;
: alias-c-type-name ( alias -- c-type-name )
! <workaround for alises w/o c:type (Atk)
[ c-type>> ] [ name>> ] bi or ;
! workaround>
! c-type>> ;
:: def-alias ( alias -- )
alias type>> get-type-info
[ c-type>> alias alias-c-type-name def-alias-c-type ]
[ clone ] bi alias name>> qualified-name register-type ;
: def-aliases ( aliases -- )
[ def-alias ] each ;
GENERIC: type>c-type ( type -- c-type )
M: atomic-type type>c-type get-type-info c-type>> ;
M: enum-type type>c-type get-type-info c-type>> ;
M: bitfield-type type>c-type get-type-info c-type>> ;
M: record-type type>c-type get-type-info c-type>> <pointer> ;
M: union-type type>c-type get-type-info c-type>> <pointer> ;
M: boxed-type type>c-type get-type-info c-type>> <pointer> ;
M: callback-type type>c-type get-type-info c-type>> ;
M: class-type type>c-type get-type-info c-type>> <pointer> ;
M: interface-type type>c-type get-type-info c-type>> <pointer> ;
M: boxed-array-type type>c-type
name>> simple-type new swap >>name type>c-type ;
M: c-array-type type>c-type
element-type>> type>c-type <pointer> ;
M: fixed-size-array-type type>c-type
[ element-type>> type>c-type ] [ fixed-size>> ] bi 2array ;
! <workaround for <type/> (in some signals and properties)
PREDICATE: incorrect-type < simple-type name>> not ;
M: incorrect-type type>c-type drop void* ;
! workaround>
GENERIC: parse-const-value ( str data-type -- value )
M: atomic-type parse-const-value
name>> {
{ "gint" [ string>number ] }
{ "gdouble" [ string>number ] }
} case ;
M: utf8-type parse-const-value drop ;
: const-value ( const -- value )
[ value>> ] [ type>> ] bi parse-const-value ;
: const-name ( const -- name )
name>> constant-prefix get swap "_" glue ;
: def-const ( const -- )
[ const-name create-in dup reset-generic ]
[ const-value ] bi define-constant ;
: def-consts ( consts -- )
[ def-const ] each ;
: define-enum-member ( member -- )
[ c-identifier>> create-in dup reset-generic ]
[ value>> ] bi define-constant ;
: def-enum-type ( enum -- )
[ members>> [ define-enum-member ] each ]
[ c-type>> int def-c-type ] bi ;
: def-bitfield-type ( bitfield -- )
def-enum-type ;
GENERIC: parameter-type>c-type ( data-type -- c-type )
M: data-type parameter-type>c-type type>c-type ;
M: varargs-type parameter-type>c-type drop void* ;
: parameter-c-type ( parameter -- c-type )
[ type>> parameter-type>c-type ] keep
direction>> "in" = [ <pointer> ] unless ;
GENERIC: return-type>c-type ( data-type -- c-type )
M: data-type return-type>c-type type>c-type ;
M: none-type return-type>c-type drop void ;
: return-c-type ( return -- c-type )
type>> return-type>c-type ;
: parameter-name ( parameter -- name )
dup type>> varargs-type?
[ drop "varargs" ] [ name>> "!incorrect-name!" or ] if ;
: error-parameter ( -- parameter )
parameter new
"error" >>name
"in" >>direction
"none" >>transfer-ownership
simple-type new "GLib.Error" >>name >>type ;
: ?suffix-parameters-with-error ( callable -- parameters )
[ parameters>> ] [ throws?>> ] bi
[ error-parameter suffix ] when ;
: parameter-names&types ( callable -- names types )
[ [ parameter-c-type ] map ] [ [ parameter-name ] map ] bi ;
: def-function ( function -- )
{
[ return>> return-c-type ]
[ identifier>> ]
[ drop current-library get ]
[ ?suffix-parameters-with-error parameter-names&types ]
} cleave make-function define-inline ;
: def-functions ( functions -- )
[ def-function ] each ;
GENERIC: type>data-type ( type -- data-type )
M: type type>data-type
[ simple-type new ] dip name>> >>name ;
: word-started? ( word letter -- ? )
[ letter? ] [ LETTER? ] bi* and ; inline
: camel-case>underscore-separated ( str -- str' )
[ word-started? not ] monotonic-split "_" join >lower ;
: type>parameter-name ( type -- name )
name>> camel-case>underscore-separated ;
: type>parameter ( type -- parameter )
[ parameter new ] dip {
[ type>parameter-name >>name ]
[ type>data-type >>type ]
[ drop "in" >>direction "none" >>transfer-ownership ]
} cleave ;
:: def-method ( method type -- )
method {
[ return>> return-c-type ]
[ identifier>> ]
[ drop current-library get ]
[
?suffix-parameters-with-error
type type>parameter prefix
parameter-names&types
]
} cleave make-function define-inline ;
: def-methods ( methods type -- )
[ def-method ] curry each ;
: def-callback-type ( callback -- )
{
[ drop current-library get ]
[ return>> return-c-type ]
[ c-type>> ]
[ ?suffix-parameters-with-error parameter-names&types ]
} cleave make-callback-type define-inline ;
GENERIC: field-type>c-type ( data-type -- c-type )
M: simple-type field-type>c-type type>c-type ;
M: inner-callback-type field-type>c-type drop void* ;
M: array-type field-type>c-type type>c-type ;
: field>struct-slot ( field -- slot )
[ name>> ]
[ dup bits>> [ drop uint ] [ type>> field-type>c-type ] if ]
[
[
[ drop ] ! [ writable?>> [ read-only , ] unless ]
[ bits>> [ bits: , , ] when* ] bi
] V{ } make
] tri <struct-slot-spec> ;
: def-record-type ( record -- )
dup c-type>> implement-structs get-global member?
[
[ c-type>> create-class-in ]
[ fields>> [ field>struct-slot ] map ] bi
define-struct-class
] [ c-type>> void def-c-type ] if ;
: def-record ( record -- )
{
[ def-record-type ]
[ constructors>> def-functions ]
[ functions>> def-functions ]
[ [ methods>> ] keep def-methods ]
} cleave ;
: def-union-type ( union -- )
c-type>> void def-c-type ;
: private-record? ( record -- ? )
{
[ struct-for>> ]
[ name>> "Class" tail? ]
[ name>> "Private" tail? ]
[ name>> "Iface" tail? ]
} 1|| ;
: def-union ( union -- )
{
[ def-union-type ]
[ constructors>> def-functions ]
[ functions>> def-functions ]
[ [ methods>> ] keep def-methods ]
} cleave ;
: def-boxed-type ( boxed -- )
c-type>> void def-c-type ;
: signal-name ( signal type -- name )
swap [ c-type>> ] [ name>> ] bi* ":" glue ;
: user-data-parameter ( -- parameter )
parameter new
"user_data" >>name
"in" >>direction
"none" >>transfer-ownership
simple-type new "gpointer" >>name >>type ;
:: def-signal ( signal type -- )
signal {
[ drop current-library get ]
[ return>> return-c-type ]
[ type signal-name ]
[
parameters>> type type>parameter prefix
user-data-parameter suffix parameter-names&types
]
} cleave make-callback-type define-inline ;
: def-signals ( signals type -- )
[ def-signal ] curry each ;
: def-class-type ( class -- )
c-type>> void def-c-type ;
: def-class ( class -- )
{
[ def-class-type ]
[ constructors>> def-functions ]
[ functions>> def-functions ]
[ [ methods>> ] keep def-methods ]
[ [ signals>> ] keep def-signals ]
} cleave ;
: def-interface-type ( interface -- )
c-type>> void def-c-type ;
: def-interface ( class -- )
{
[ def-interface-type ]
[ functions>> def-functions ]
[ [ methods>> ] keep def-methods ]
[ [ signals>> ] keep def-signals ]
} cleave ;
: defer-enums ( enums -- ) enum-info defer-types ;
: defer-bitfields ( bitfields -- ) bitfield-info defer-types ;
: defer-unions ( unions -- ) union-info defer-types ;
: defer-boxeds ( boxeds -- ) boxed-info defer-types ;
: defer-callbacks ( callbacks -- ) callback-info defer-types ;
: defer-interfaces ( interfaces -- ) interface-info defer-types ;
: defer-classes ( class -- ) class-info defer-types ;
: defer-records ( records -- )
[ private-record? ] partition
[ begin-private record-info defer-types end-private ]
[ record-info defer-types ] bi* ;
: def-enums ( enums -- ) [ def-enum-type ] each ;
: def-bitfields ( bitfields -- ) [ def-bitfield-type ] each ;
: def-unions ( unions -- ) [ def-union ] each ;
: def-boxeds ( boxeds -- ) [ def-boxed-type ] each ;
: def-callbacks ( callbacks -- ) [ def-callback-type ] each ;
: def-interfaces ( interfaces -- ) [ def-interface ] each ;
: def-classes ( classes -- ) [ def-class ] each ;
: def-records ( records -- )
[ private-record? ] partition
[ begin-private [ def-record ] each end-private ]
[ [ def-record ] each ] bi* ;
: def-namespace ( namespace -- )
{
[ symbol-prefixes>> first >upper constant-prefix set ]
[ consts>> def-consts ]
[ enums>> defer-enums ]
[ bitfields>> defer-bitfields ]
[ records>> defer-records ]
[ unions>> defer-unions ]
[ boxeds>> defer-boxeds ]
[ callbacks>> defer-callbacks ]
[ interfaces>> defer-interfaces ]
[ classes>> defer-classes ]
[ aliases>> def-aliases ]
[ enums>> def-enums ]
[ bitfields>> def-bitfields ]
[ records>> def-records ]
[ unions>> def-unions ]
[ boxeds>> def-boxeds ]
[ callbacks>> def-callbacks ]
[ interfaces>> def-interfaces ]
[ classes>> def-classes ]
[ functions>> def-functions ]
} cleave ;
: def-ffi-repository ( repository -- )
namespace>> def-namespace ;

View File

@ -0,0 +1,34 @@
! Copyright (C) 2010 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors combinators gobject-introspection.common
gobject-introspection.ffi gobject-introspection.loader
gobject-introspection.types kernel lexer locals namespaces parser
sequences xml ;
IN: gobject-introspection
<PRIVATE
:: define-gir-vocab ( file-name -- )
file-name file>xml xml>repository
{
[ namespace>> name>> current-namespace-name set-global ]
[ def-ffi-repository ]
} cleave
V{ } clone implement-structs set-global ;
PRIVATE>
SYNTAX: GIR: scan define-gir-vocab ;
SYNTAX: IMPLEMENT-STRUCTS:
";" parse-tokens
implement-structs [ swap append! ] change-global ;
SYNTAX: FOREIGN-ATOMIC-TYPE:
scan-token scan-object swap register-atomic-type ;
SYNTAX: FOREIGN-ENUM-TYPE:
scan-token scan-object swap register-enum-type ;
SYNTAX: FOREIGN-RECORD-TYPE:
scan-token scan-object swap register-record-type ;

View File

@ -0,0 +1,215 @@
! Copyright (C) 2010 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors combinators gobject-introspection.repository kernel
literals math.parser sequences splitting xml.data xml.traversal ;
IN: gobject-introspection.loader
: xml>simple-type ( xml -- type )
[ simple-type new ] dip {
[ "name" attr >>name ]
[
"type" tags-named
[ xml>simple-type ] map f like >>element-types
]
} cleave ;
: xml>varargs-type ( xml -- type )
drop varargs-type new ;
: xml>array-type ( xml -- type )
[ array-type new ] dip {
[ "name" attr >>name ]
[ "zero-terminated" attr "0" = not >>zero-terminated? ]
[ "length" attr string>number >>length ]
[ "fixed-size" attr string>number >>fixed-size ]
[ "type" tag-named xml>simple-type >>element-type ]
} cleave ;
: xml>inner-callback-type ( xml -- type )
[ inner-callback-type new ] dip {
[ "name" attr >>name ]
} cleave ;
: xml>type ( xml -- type )
dup name>> main>> {
{ "type" [ xml>simple-type ] }
{ "array"[ xml>array-type ] }
{ "callback" [ xml>inner-callback-type ] }
{ "varargs" [ xml>varargs-type ] }
} case ;
CONSTANT: type-tags
$[ { "array" "type" "callback" "varargs" } [ <null-name> ] map ]
: child-type-tag ( xml -- type-tag )
children-tags [
type-tags [ swap tag-named? ] with any?
] find nip ;
: xml>alias ( xml -- alias )
[ alias new ] dip {
[ "name" attr >>name ]
[ "type" attr >>c-type ]
[ child-type-tag xml>type >>type ]
} cleave ;
: xml>const ( xml -- const )
[ const new ] dip {
[ "name" attr >>name ]
[ "value" attr >>value ]
[ child-type-tag xml>type >>type ]
} cleave ;
: load-type ( type xml -- type )
{
[ "name" attr >>name ]
[ [ "type" attr ] [ "type-name" attr ] bi or >>c-type ]
[ "get-type" attr >>get-type ]
} cleave ;
: xml>member ( xml -- member )
[ enum-member new ] dip {
[ "name" attr >>name ]
[ "identifier" attr >>c-identifier ]
[ "value" attr string>number >>value ]
} cleave ;
: xml>enum ( xml -- enum )
[ enum new ] dip {
[ load-type ]
[ "member" tags-named [ xml>member ] map >>members ]
} cleave ;
: load-parameter ( param xml -- param )
[ child-type-tag xml>type >>type ]
[ "transfer-ownership" attr >>transfer-ownership ] bi ;
: xml>parameter ( xml -- parameter )
[ parameter new ] dip {
[ "name" attr >>name ]
[ "direction" attr dup "in" ? >>direction ]
[ "allow-none" attr "1" = >>allow-none? ]
[ child-type-tag xml>type >>type ]
[ "transfer-ownership" attr >>transfer-ownership ]
} cleave ;
: xml>return ( xml -- return )
[ return new ] dip {
[ child-type-tag xml>type >>type ]
[ "transfer-ownership" attr >>transfer-ownership ]
} cleave ;
: load-callable ( callable xml -- callable )
[ "return-value" tag-named xml>return >>return ]
[
"parameters" tag-named "parameter" tags-named
[ xml>parameter ] map >>parameters
] bi ;
: xml>function ( xml -- function )
[ function new ] dip {
[ "name" attr >>name ]
[ "identifier" attr >>identifier ]
[ load-callable ]
[ "throws" attr "1" = >>throws? ]
} cleave ;
: load-functions ( xml tag-name -- functions )
tags-named [ xml>function ] map ;
: xml>field ( xml -- field )
[ field new ] dip {
[ "name" attr >>name ]
[ "writable" attr "1" = >>writable? ]
[ "bits" attr string>number >>bits ]
[ child-type-tag xml>type >>type ]
} cleave ;
: xml>record ( xml -- record )
[ record new ] dip {
[ load-type ]
[ "field" tags-named [ xml>field ] map >>fields ]
[ "constructor" load-functions >>constructors ]
[ "method" load-functions >>methods ]
[ "function" load-functions >>functions ]
[ "disguised" attr "1" = >>disguised? ]
[ "is-gtype-struct-for" attr >>struct-for ]
} cleave ;
: xml>union ( xml -- union )
[ union new ] dip {
[ load-type ]
[ "field" tags-named [ xml>field ] map >>fields ]
[ "constructor" load-functions >>constructors ]
[ "method" load-functions >>methods ]
[ "function" load-functions >>functions ]
} cleave ;
: xml>callback ( xml -- callback )
[ callback new ] dip {
[ load-type ]
[ load-callable ]
[ "throws" attr "1" = >>throws? ]
} cleave ;
: xml>signal ( xml -- signal )
[ signal new ] dip {
[ "name" attr >>name ]
[ load-callable ]
} cleave ;
: xml>property ( xml -- property )
[ property new ] dip {
[ "name" attr >>name ]
[ "writable" attr "1" = >>writable? ]
[ "readable" attr "0" = not >>readable? ]
[ "construct" attr "1" = >>construct? ]
[ "construct-only" attr "1" = >>construct-only? ]
[ child-type-tag xml>type >>type ]
} cleave ;
: xml>class ( xml -- class )
[ class new ] dip {
[ load-type ]
[ "abstract" attr "1" = >>abstract? ]
[ "parent" attr >>parent ]
[ "type-struct" attr >>type-struct ]
[ "constructor" load-functions >>constructors ]
[ "method" load-functions >>methods ]
[ "function" load-functions >>functions ]
[ "signal" tags-named [ xml>signal ] map >>signals ]
} cleave ;
: xml>interface ( xml -- interface )
[ interface new ] dip {
[ load-type ]
[ "method" load-functions >>methods ]
[ "function" load-functions >>functions ]
[ "signal" tags-named [ xml>signal ] map >>signals ]
} cleave ;
: xml>boxed ( xml -- boxed )
[ boxed new ] dip
load-type ;
: xml>namespace ( xml -- namespace )
[ namespace new ] dip {
[ "name" attr >>name ]
[ "identifier-prefixes" attr "," split >>identifier-prefixes ]
[ "symbol-prefixes" attr "," split >>symbol-prefixes ]
[ "alias" tags-named [ xml>alias ] map >>aliases ]
[ "constant" tags-named [ xml>const ] map >>consts ]
[ "enumeration" tags-named [ xml>enum ] map >>enums ]
[ "bitfield" tags-named [ xml>enum ] map >>bitfields ]
[ "record" tags-named [ xml>record ] map >>records ]
[ "union" tags-named [ xml>union ] map >>unions ]
[ "boxed" tags-named [ xml>boxed ] map >>boxeds ]
[ "callback" tags-named [ xml>callback ] map >>callbacks ]
[ "class" tags-named [ xml>class ] map >>classes ]
[ "interface" tags-named [ xml>interface ] map >>interfaces ]
[ "function" load-functions >>functions ]
} cleave ;
: xml>repository ( xml -- repository )
[ repository new ] dip
"namespace" tag-named xml>namespace >>namespace ;

View File

@ -0,0 +1,135 @@
! Copyright (C) 2010 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: ;
IN: gobject-introspection.repository
TUPLE: repository
namespace ;
TUPLE: namespace
name
identifier-prefixes
symbol-prefixes
aliases
consts
enums
bitfields
records
unions
boxeds
callbacks
classes
interfaces
functions ;
TUPLE: data-type
name ;
TUPLE: simple-type < data-type
element-types ;
TUPLE: array-type < data-type
zero-terminated?
fixed-size
length
element-type ;
TUPLE: inner-callback-type < data-type ;
TUPLE: varargs-type < data-type ;
TUPLE: alias
name
c-type
type ;
TUPLE: const
name
value
type ;
TUPLE: type
name
c-type
get-type ;
TUPLE: enum-member
name
value
c-identifier ;
TUPLE: enum < type
members ;
TUPLE: record < type
fields
constructors
methods
functions
disguised?
struct-for ;
TUPLE: field
name
writable?
bits
type ;
TUPLE: union < type
fields
constructors
methods
functions ;
TUPLE: return
type
transfer-ownership ;
TUPLE: parameter
name
type
direction
allow-none?
transfer-ownership ;
TUPLE: function
name
identifier
return
parameters
throws? ;
TUPLE: callback < type
return
parameters
throws? ;
TUPLE: class < type
abstract?
parent
type-struct
constructors
methods
functions
signals ;
TUPLE: interface < type
constructors
methods
functions
signals ;
TUPLE: boxed < type ;
TUPLE: signal
name
return
parameters ;
TUPLE: property
name
readable?
writable?
construct?
construct-only?
type ;

View File

@ -0,0 +1,71 @@
! Copyright (C) 2010 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.c-types alien.syntax
classes.struct gobject-introspection.types kernel parser ;
IN: gobject-introspection.standard-types
<<
TYPEDEF: char gchar
TYPEDEF: uchar guchar
TYPEDEF: short gshort
TYPEDEF: ushort gushort
TYPEDEF: long glong
TYPEDEF: ulong gulong
TYPEDEF: int gint
TYPEDEF: uint guint
TYPEDEF: char gint8
TYPEDEF: uchar guint8
TYPEDEF: short gint16
TYPEDEF: ushort guint16
TYPEDEF: int gint32
TYPEDEF: uint guint32
TYPEDEF: longlong gint64
TYPEDEF: ulonglong guint64
TYPEDEF: float gfloat
TYPEDEF: double gdouble
TYPEDEF: gulong GType
TYPEDEF: void* gpointer
TYPEDEF: guint32 gunichar
TYPEDEF: void* va_list
int c-type clone
[ >c-bool ] >>unboxer-quot
[ c-bool> ] >>boxer-quot
object >>boxed-class
"gboolean" create-in typedef
STRUCT: longdouble { data char[10] } ;
>>
gchar "gchar" register-standard-type
guchar "guchar" register-standard-type
gshort "gshort" register-standard-type
gushort "gushort" register-standard-type
glong "glong" register-standard-type
gulong "gulong" register-standard-type
gint "gint" register-standard-type
guint "guint" register-standard-type
gint8 "gint8" register-standard-type
guint8 "guint8" register-standard-type
gint16 "gint16" register-standard-type
guint16 "guint16" register-standard-type
gint32 "gint32" register-standard-type
guint32 "guint32" register-standard-type
gint64 "gint64" register-standard-type
guint64 "guint64" register-standard-type
gfloat "gfloat" register-standard-type
gdouble "gdouble" register-standard-type
GType "GType" register-standard-type
gpointer "gpointer" register-standard-type
gunichar "gunichar" register-standard-type
va_list "va_list" register-standard-type
gboolean "gboolean" register-standard-type
pointer: gchar "utf8" register-standard-type
longdouble "long double" register-standard-type

View File

@ -0,0 +1 @@
GObjectIntrospection support

View File

@ -0,0 +1,112 @@
! Copyright (C) 2010 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.c-types assocs combinators.short-circuit
gobject-introspection.common gobject-introspection.repository kernel
locals namespaces parser sequences sets ;
IN: gobject-introspection.types
SYMBOL: type-infos
type-infos [ H{ } ] initialize
SYMBOL: standard-types
standard-types [ V{ } ] initialize
TUPLE: type-info c-type ;
TUPLE: atomic-info < type-info ;
TUPLE: enum-info < type-info ;
TUPLE: bitfield-info < type-info ;
TUPLE: record-info < type-info ;
TUPLE: union-info < type-info ;
TUPLE: boxed-info < type-info ;
TUPLE: callback-info < type-info ;
TUPLE: class-info < type-info ;
TUPLE: interface-info < type-info ;
DEFER: find-type-info
PREDICATE: none-type < simple-type
name>> "none" = ;
PREDICATE: atomic-type < simple-type
find-type-info atomic-info? ;
PREDICATE: utf8-type < atomic-type
name>> "utf8" = ;
PREDICATE: enum-type < simple-type
find-type-info enum-info? ;
PREDICATE: bitfield-type < simple-type
find-type-info bitfield-info? ;
PREDICATE: record-type < simple-type
find-type-info record-info? ;
PREDICATE: union-type < simple-type
find-type-info union-info? ;
PREDICATE: boxed-type < simple-type
find-type-info boxed-info? ;
PREDICATE: callback-type < simple-type
find-type-info callback-info? ;
PREDICATE: class-type < simple-type
find-type-info class-info? ;
PREDICATE: interface-type < simple-type
find-type-info interface-info? ;
PREDICATE: boxed-array-type < array-type name>> >boolean ;
PREDICATE: c-array-type < array-type name>> not ;
PREDICATE: fixed-size-array-type < c-array-type fixed-size>> >boolean ;
: standard-type? ( data-type -- ? )
name>> standard-types get-global in? ;
: qualified-name ( name -- qualified-name )
current-namespace-name get-global swap "." glue ;
: qualified-type-name ( data-type -- name )
[ name>> ] keep {
[ name>> CHAR: . swap member? ]
[ none-type? ]
[ standard-type? ]
} 1|| [ qualified-name ] unless ;
ERROR: unknown-type-error type ;
: get-type-info ( data-type -- info )
qualified-type-name dup type-infos get-global at
[ ] [ unknown-type-error ] ?if ;
: find-type-info ( data-type -- info/f )
qualified-type-name type-infos get-global at ;
:: register-type ( c-type type-info name -- )
type-info c-type >>c-type name
type-infos get-global set-at ;
: register-standard-type ( c-type name -- )
dup standard-types get-global adjoin
atomic-info new swap register-type ;
: register-atomic-type ( c-type name -- )
atomic-info new swap register-type ;
: register-enum-type ( c-type name -- )
enum-info new swap register-type ;
: register-record-type ( c-type name -- )
record-info new swap register-type ;
ERROR: deferred-type-error ;
<<
void* c-type clone
[ drop deferred-type-error ] >>unboxer-quot
[ drop deferred-type-error ] >>boxer-quot
object >>boxed-class
"deferred-type" create-in typedef
>>

10021
basis/gobject/GObject-2.0.gir Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
Anton Gorenko

View File

@ -0,0 +1,67 @@
! Copyright (C) 2010 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.destructors alien.libraries alien.syntax kernel
combinators gobject-introspection literals math system vocabs.loader ;
IN: gobject.ffi
<<
"glib.ffi" require
>>
LIBRARY: gobject
<<
"gobject" {
{ [ os winnt? ] [ "libobject-2.0-0.dll" cdecl add-library ] }
{ [ os unix? ] [ drop ] }
} cond
>>
IMPLEMENT-STRUCTS: GValue GParamSpecVariant ;
GIR: vocab:gobject/GObject-2.0.gir
IN: gobject.ffi
FORGET: GIOCondition
FORGET: G_IO_IN
FORGET: G_IO_OUT
FORGET: G_IO_PRI
FORGET: G_IO_ERR
FORGET: G_IO_HUP
FORGET: G_IO_NVAL
DESTRUCTOR: g_object_unref
CONSTANT: G_TYPE_INVALID $[ 0 2 shift ]
CONSTANT: G_TYPE_NONE $[ 1 2 shift ]
CONSTANT: G_TYPE_INTERFACE $[ 2 2 shift ]
CONSTANT: G_TYPE_CHAR $[ 3 2 shift ]
CONSTANT: G_TYPE_UCHAR $[ 4 2 shift ]
CONSTANT: G_TYPE_BOOLEAN $[ 5 2 shift ]
CONSTANT: G_TYPE_INT $[ 6 2 shift ]
CONSTANT: G_TYPE_UINT $[ 7 2 shift ]
CONSTANT: G_TYPE_LONG $[ 8 2 shift ]
CONSTANT: G_TYPE_ULONG $[ 9 2 shift ]
CONSTANT: G_TYPE_INT64 $[ 10 2 shift ]
CONSTANT: G_TYPE_UINT64 $[ 11 2 shift ]
CONSTANT: G_TYPE_ENUM $[ 12 2 shift ]
CONSTANT: G_TYPE_FLAGS $[ 13 2 shift ]
CONSTANT: G_TYPE_FLOAT $[ 14 2 shift ]
CONSTANT: G_TYPE_DOUBLE $[ 15 2 shift ]
CONSTANT: G_TYPE_STRING $[ 16 2 shift ]
CONSTANT: G_TYPE_POINTER $[ 17 2 shift ]
CONSTANT: G_TYPE_BOXED $[ 18 2 shift ]
CONSTANT: G_TYPE_PARAM $[ 19 2 shift ]
CONSTANT: G_TYPE_OBJECT $[ 20 2 shift ]
! Macros
: g_signal_connect ( instance detailed_signal c_handler data -- result )
f 0 g_signal_connect_data ;
: g_signal_connect_after ( instance detailed_signal c_handler data -- result )
f G_CONNECT_AFTER g_signal_connect_data ;
: g_signal_connect_swapped ( instance detailed_signal c_handler data -- result )
f G_CONNECT_SWAPPED g_signal_connect_data ;

View File

@ -0,0 +1,5 @@
! Copyright (C) 2009 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: gobject.ffi ;
IN: gobject

View File

@ -0,0 +1 @@
GObject binding

1
basis/gobject/tags.txt Executable file
View File

@ -0,0 +1 @@
bindings

81744
basis/gtk/Gtk-3.0.gir Normal file

File diff suppressed because it is too large Load Diff

1
basis/gtk/authors.txt Normal file
View File

@ -0,0 +1 @@
Anton Gorenko

33
basis/gtk/ffi/ffi.factor Normal file
View File

@ -0,0 +1,33 @@
! Copyright (C) 2010 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types alien.destructors alien.libraries
alien.syntax combinators gobject-introspection
gobject-introspection.standard-types kernel pango.ffi system
vocabs.loader ;
IN: gtk.ffi
<<
"atk.ffi" require
"gdk.ffi" require
>>
LIBRARY: gtk
<<
"gtk" {
{ [ os winnt? ] [ "libgtk-win32-2.0-0.dll" cdecl add-library ] }
{ [ os unix? ] [ drop ] }
} cond
>>
IMPLEMENT-STRUCTS: GtkTreeIter ;
GIR: vocab:gtk/Gtk-3.0.gir
DESTRUCTOR: gtk_widget_destroy
! <workaround
FORGET: gtk_im_context_get_preedit_string
FUNCTION: void
gtk_im_context_get_preedit_string ( GtkIMContext* imcontext, gchar** str, PangoAttrList** attrs, gint* cursor_pos ) ;
! workaround>

View File

@ -0,0 +1,213 @@
<?xml version="1.0"?>
<!-- This file was automatically generated from C sources - DO NOT EDIT!
To affect the contents of this file, edit the original C definitions,
and/or use gtk-doc annotations. -->
<repository version="1.2"
xmlns="http://www.gtk.org/introspection/core/1.0"
xmlns:c="http://www.gtk.org/introspection/c/1.0"
xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<include name="Atk" version="1.0"/>
<include name="GLib" version="2.0"/>
<include name="GModule" version="2.0"/>
<include name="GObject" version="2.0"/>
<include name="Gdk" version="3.0"/>
<include name="GdkGLExt" version="1.0"/>
<include name="GdkPixbuf" version="2.0"/>
<include name="Gio" version="2.0"/>
<include name="Gtk" version="3.0"/>
<include name="Pango" version="1.0"/>
<include name="cairo" version="1.0"/>
<package name="gtkglext-1.0"/>
<namespace name="GtkGL"
version="1.0"
shared-library="libgtkglext-x11-1.0.so.0"
c:identifier-prefixes="GtkGL,Gtk"
c:symbol-prefixes="gtk_gl,gtk">
<bitfield name="DebugFlag" c:type="GtkGLDebugFlag">
<member name="misc" value="1" c:identifier="GTK_GL_DEBUG_MISC"/>
<member name="func" value="2" c:identifier="GTK_GL_DEBUG_FUNC"/>
</bitfield>
<function name="init" c:identifier="gtk_gl_init">
<doc xml:whitespace="preserve">Call this function before using any other GtkGLExt functions in your
applications. It will initialize everything needed to operate the library
and parses some standard command line options. @argc and
never see those standard arguments.
&lt;note&gt;&lt;para&gt;
This function will terminate your program if it was unable to initialize
the library for some reason. If you want your program to fall back to a
textual interface you want to call gtk_gl_init_check() instead.
&lt;/para&gt;&lt;/note&gt;</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<parameter name="argc"
direction="inout"
caller-allocates="0"
transfer-ownership="full">
<doc xml:whitespace="preserve">Address of the &lt;parameter&gt;argc&lt;/parameter&gt; parameter of your &lt;function&gt;main()&lt;/function&gt; function. Changed if any arguments were handled.</doc>
<type name="gint" c:type="int*"/>
</parameter>
<parameter name="argv"
direction="inout"
caller-allocates="0"
transfer-ownership="full"
allow-none="1">
<doc xml:whitespace="preserve">Address of the &lt;parameter&gt;argv&lt;/parameter&gt; parameter of &lt;function&gt;main()&lt;/function&gt;. Any parameters understood by gtk_gl_init() are stripped before return.</doc>
<array length="0" c:type="char***">
<type name="utf8"/>
</array>
</parameter>
</parameters>
</function>
<function name="init_check" c:identifier="gtk_gl_init_check">
<doc xml:whitespace="preserve">This function does the same work as gtk_gl_init() with only
initialized. Instead it returns %FALSE on failure.
This way the application can fall back to some other means of communication
with the user - for example a curses or command line interface.
%FALSE otherwise.</doc>
<return-value transfer-ownership="none">
<doc xml:whitespace="preserve">%TRUE if the GUI has been successfully initialized,</doc>
<type name="gboolean" c:type="gboolean"/>
</return-value>
<parameters>
<parameter name="argc"
direction="inout"
caller-allocates="0"
transfer-ownership="full">
<doc xml:whitespace="preserve">Address of the &lt;parameter&gt;argc&lt;/parameter&gt; parameter of your &lt;function&gt;main()&lt;/function&gt; function. Changed if any arguments were handled.</doc>
<type name="gint" c:type="int*"/>
</parameter>
<parameter name="argv"
direction="inout"
caller-allocates="0"
transfer-ownership="full"
allow-none="1">
<doc xml:whitespace="preserve">Address of the &lt;parameter&gt;argv&lt;/parameter&gt; parameter of &lt;function&gt;main()&lt;/function&gt;. Any parameters understood by gtk_gl_init() are stripped before return.</doc>
<array length="0" c:type="char***">
<type name="utf8"/>
</array>
</parameter>
</parameters>
</function>
<function name="widget_create_gl_context"
c:identifier="gtk_widget_create_gl_context">
<doc xml:whitespace="preserve">Creates a new #GdkGLContext with the appropriate #GdkGLDrawable
for this widget. The GL context must be freed when you're
finished with it. See also gtk_widget_get_gl_context().</doc>
<return-value transfer-ownership="full">
<doc xml:whitespace="preserve">the new #GdkGLContext.</doc>
<type name="GdkGL.Context" c:type="GdkGLContext*"/>
</return-value>
<parameters>
<parameter name="widget" transfer-ownership="none">
<doc xml:whitespace="preserve">a #GtkWidget.</doc>
<type name="Gtk.Widget" c:type="GtkWidget*"/>
</parameter>
<parameter name="share_list" transfer-ownership="none" allow-none="1">
<doc xml:whitespace="preserve">the #GdkGLContext with which to share display lists and texture objects. NULL indicates that no sharing is to take place.</doc>
<type name="GdkGL.Context" c:type="GdkGLContext*"/>
</parameter>
<parameter name="direct" transfer-ownership="none">
<doc xml:whitespace="preserve">whether rendering is to be done with a direct connection to the graphics system.</doc>
<type name="gboolean" c:type="gboolean"/>
</parameter>
<parameter name="render_type" transfer-ownership="none">
<doc xml:whitespace="preserve">GDK_GL_RGBA_TYPE or GDK_GL_COLOR_INDEX_TYPE (currently not used).</doc>
<type name="gint" c:type="int"/>
</parameter>
</parameters>
</function>
<function name="widget_get_gl_config"
c:identifier="gtk_widget_get_gl_config">
<doc xml:whitespace="preserve">Returns the #GdkGLConfig referred by the @widget.</doc>
<return-value transfer-ownership="none">
<doc xml:whitespace="preserve">the #GdkGLConfig.</doc>
<type name="GdkGL.Config" c:type="GdkGLConfig*"/>
</return-value>
<parameters>
<parameter name="widget" transfer-ownership="none">
<doc xml:whitespace="preserve">a #GtkWidget.</doc>
<type name="Gtk.Widget" c:type="GtkWidget*"/>
</parameter>
</parameters>
</function>
<function name="widget_get_gl_context"
c:identifier="gtk_widget_get_gl_context">
<doc xml:whitespace="preserve">Returns the #GdkGLContext with the appropriate #GdkGLDrawable
for this widget. Unlike the GL context returned by
gtk_widget_create_gl_context(), this context is owned by the widget.
#GdkGLContext is needed for the function gdk_gl_drawable_begin,
or for sharing display lists (see gtk_widget_set_gl_capability()).</doc>
<return-value transfer-ownership="none">
<doc xml:whitespace="preserve">the #GdkGLContext.</doc>
<type name="GdkGL.Context" c:type="GdkGLContext*"/>
</return-value>
<parameters>
<parameter name="widget" transfer-ownership="none">
<doc xml:whitespace="preserve">a #GtkWidget.</doc>
<type name="Gtk.Widget" c:type="GtkWidget*"/>
</parameter>
</parameters>
</function>
<function name="widget_get_gl_window"
c:identifier="gtk_widget_get_gl_window">
<doc xml:whitespace="preserve">Returns the #GdkGLWindow owned by the @widget.</doc>
<return-value transfer-ownership="none">
<doc xml:whitespace="preserve">the #GdkGLWindow.</doc>
<type name="GdkGL.Window" c:type="GdkGLWindow*"/>
</return-value>
<parameters>
<parameter name="widget" transfer-ownership="none">
<doc xml:whitespace="preserve">a #GtkWidget.</doc>
<type name="Gtk.Widget" c:type="GtkWidget*"/>
</parameter>
</parameters>
</function>
<function name="widget_is_gl_capable"
c:identifier="gtk_widget_is_gl_capable">
<doc xml:whitespace="preserve">Returns whether the @widget is OpenGL-capable.</doc>
<return-value transfer-ownership="none">
<doc xml:whitespace="preserve">TRUE if the @widget is OpenGL-capable, FALSE otherwise.</doc>
<type name="gboolean" c:type="gboolean"/>
</return-value>
<parameters>
<parameter name="widget" transfer-ownership="none">
<doc xml:whitespace="preserve">a #GtkWidget.</doc>
<type name="Gtk.Widget" c:type="GtkWidget*"/>
</parameter>
</parameters>
</function>
<function name="widget_set_gl_capability"
c:identifier="gtk_widget_set_gl_capability">
<doc xml:whitespace="preserve">Set the OpenGL-capability to the @widget.
This function prepares the widget for its use with OpenGL.</doc>
<return-value transfer-ownership="none">
<doc xml:whitespace="preserve">TRUE if it is successful, FALSE otherwise.</doc>
<type name="gboolean" c:type="gboolean"/>
</return-value>
<parameters>
<parameter name="widget" transfer-ownership="none">
<doc xml:whitespace="preserve">the #GtkWidget to be used as the rendering area.</doc>
<type name="Gtk.Widget" c:type="GtkWidget*"/>
</parameter>
<parameter name="glconfig" transfer-ownership="none">
<doc xml:whitespace="preserve">a #GdkGLConfig.</doc>
<type name="GdkGL.Config" c:type="GdkGLConfig*"/>
</parameter>
<parameter name="share_list" transfer-ownership="none" allow-none="1">
<doc xml:whitespace="preserve">the #GdkGLContext with which to share display lists and texture objects. NULL indicates that no sharing is to take place.</doc>
<type name="GdkGL.Context" c:type="GdkGLContext*"/>
</parameter>
<parameter name="direct" transfer-ownership="none">
<doc xml:whitespace="preserve">whether rendering is to be done with a direct connection to the graphics system.</doc>
<type name="gboolean" c:type="gboolean"/>
</parameter>
<parameter name="render_type" transfer-ownership="none">
<doc xml:whitespace="preserve">GDK_GL_RGBA_TYPE or GDK_GL_COLOR_INDEX_TYPE (currently not used).</doc>
<type name="gint" c:type="int"/>
</parameter>
</parameters>
</function>
</namespace>
</repository>

1
basis/gtk/gl/authors.txt Normal file
View File

@ -0,0 +1 @@
Anton Gorenko

View File

@ -0,0 +1,22 @@
! Copyright (C) 2010 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.libraries alien.syntax combinators
gobject-introspection kernel system vocabs.loader ;
IN: gtk.gl.ffi
<<
"gtk.ffi" require
"gdk.gl.ffi" require
>>
LIBRARY: gtk.gl
<<
"gtk.gl" {
{ [ os winnt? ] [ drop ] }
{ [ os macosx? ] [ drop ] }
{ [ os unix? ] [ "libgtkglext-x11-1.0.so" cdecl add-library ] }
} cond
>>
GIR: vocab:gtk/gl/GtkGLExt-1.0.gir

5
basis/gtk/gl/gl.factor Normal file
View File

@ -0,0 +1,5 @@
! Copyright (C) 2010 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: gtk.gl.ffi ;
IN: gtk.gl

1
basis/gtk/gl/summary.txt Normal file
View File

@ -0,0 +1 @@
GtkGLExt binding

1
basis/gtk/gl/tags.txt Executable file
View File

@ -0,0 +1 @@
bindings

5
basis/gtk/gtk.factor Normal file
View File

@ -0,0 +1,5 @@
! Copyright (C) 2009 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: gtk.ffi ;
IN: gtk

1
basis/gtk/summary.txt Normal file
View File

@ -0,0 +1 @@
Gtk binding

1
basis/gtk/tags.txt Executable file
View File

@ -0,0 +1 @@
bindings

View File

@ -1,10 +1,13 @@
USING: io.sockets io.sockets.private sequences math tools.test
namespaces accessors kernel destructors calendar io.timeouts
io.encodings.utf8 io concurrency.promises threads
io.streams.string present ;
io.streams.string present system ;
IN: io.sockets.tests
[ T{ local f "/tmp/foo" } ] [ "/tmp/foo" <local> ] unit-test
os unix? [
[ T{ local f "/tmp/foo" } ] [ "/tmp/foo" <local> ] unit-test
] when
[ T{ inet4 f f 0 } ] [ f 0 <inet4> ] unit-test
[ T{ inet6 f f 0 1 } ] [ f 1 <inet6> ] unit-test

View File

@ -1,10 +1,10 @@
! Copyright (C) 2007, 2010 Slava Pestov, Doug Coleman,
! Copyright (C) 2007, 2011 Slava Pestov, Doug Coleman,
! Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.c-types alien.data alien.strings arrays
assocs byte-arrays classes classes.struct combinators
combinators.short-circuit continuations destructors fry generic
grouping init io.backend io.binary io.encodings
grouping init io.backend io.pathnames io.binary io.encodings
io.encodings.ascii io.encodings.binary io.ports
io.streams.duplex kernel math math.parser memoize namespaces
parser present sequences splitting strings summary system
@ -55,10 +55,10 @@ HOOK: addrspec-of-family os ( af -- addrspec )
PRIVATE>
TUPLE: local { path read-only } ;
TUPLE: local { path string read-only } ;
: <local> ( path -- addrspec )
normalize-path local boa ;
absolute-path local boa ;
M: local present path>> "Unix domain socket: " prepend ;

View File

@ -7,7 +7,7 @@ ERROR: unknown-gl-platform ;
<< {
{ [ os windows? ] [ "opengl.gl.windows" ] }
{ [ os macosx? ] [ "opengl.gl.macosx" ] }
{ [ os unix? ] [ "opengl.gl.x11" ] }
{ [ os unix? ] [ "opengl.gl.gtk" ] }
[ unknown-gl-platform ]
} cond use-vocab >>

View File

@ -0,0 +1 @@
Anton Gorenko

View File

@ -0,0 +1,14 @@
! Copyright (C) 2010 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.strings io.encodings.ascii
gdk.gl.ffi ;
IN: opengl.gl.gtk
: gl-function-context ( -- context )
gdk_gl_context_get_current ; inline
: gl-function-address ( name -- address )
ascii string>alien gdk_gl_get_proc_address ; inline
: gl-function-calling-convention ( -- str ) cdecl ; inline

7825
basis/pango/Pango-1.0.gir Normal file

File diff suppressed because it is too large Load Diff

1
basis/pango/authors.txt Normal file
View File

@ -0,0 +1 @@
Anton Gorenko

View File

@ -0,0 +1,658 @@
<?xml version="1.0"?>
<!-- This file was automatically generated from C sources - DO NOT EDIT!
To affect the contents of this file, edit the original C definitions,
and/or use gtk-doc annotations. -->
<repository version="1.2"
xmlns="http://www.gtk.org/introspection/core/1.0"
xmlns:c="http://www.gtk.org/introspection/c/1.0"
xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<include name="GLib" version="2.0"/>
<include name="GObject" version="2.0"/>
<include name="Pango" version="1.0"/>
<include name="PangoFT2" version="1.0"/>
<include name="cairo" version="1.0"/>
<include name="fontconfig" version="2.0"/>
<include name="freetype2" version="2.0"/>
<package name="cairo"/>
<package name="gobject-2.0"/>
<namespace name="PangoCairo"
version="1.0"
shared-library="libpangocairo-1.0.so.0"
c:identifier-prefixes="PangoCairo"
c:symbol-prefixes="pango_cairo">
<class name="FcFontMap"
c:symbol-prefix="fc_font_map"
c:type="PangoCairoFcFontMap"
parent="Pango.FontMap"
glib:type-name="PangoCairoFcFontMap"
glib:get-type="pango_cairo_fc_font_map_get_type">
<implements name="FontMap"/>
<field name="parent_instance" introspectable="0">
<type c:type="PangoFcFontMap"/>
</field>
<field name="dpi">
<type name="gdouble" c:type="double"/>
</field>
<field name="library">
<type name="freetype2.Library" c:type="FT_Library"/>
</field>
</class>
<interface name="Font"
c:symbol-prefix="font"
c:type="PangoCairoFont"
version="1.18"
glib:type-name="PangoCairoFont"
glib:get-type="pango_cairo_font_get_type">
<doc xml:whitespace="preserve">#PangoCairoFont is an interface exported by fonts for
use with Cairo. The actual type of the font will depend
on the particular font technology Cairo was compiled to use.</doc>
<prerequisite name="Pango.Font"/>
<method name="get_scaled_font"
c:identifier="pango_cairo_font_get_scaled_font"
version="1.18">
<doc xml:whitespace="preserve">Gets the #cairo_scaled_font_t used by @font.
The scaled font can be referenced and kept using
cairo_scaled_font_reference().
or %NULL if @font is %NULL.</doc>
<return-value transfer-ownership="full">
<doc xml:whitespace="preserve">the #cairo_scaled_font_t used by @font,</doc>
<type name="cairo.ScaledFont" c:type="cairo_scaled_font_t*"/>
</return-value>
</method>
</interface>
<interface name="FontMap"
c:symbol-prefix="font_map"
c:type="PangoCairoFontMap"
version="1.10"
glib:type-name="PangoCairoFontMap"
glib:get-type="pango_cairo_font_map_get_type">
<doc xml:whitespace="preserve">#PangoCairoFontMap is an interface exported by font maps for
use with Cairo. The actual type of the font map will depend
on the particular font technology Cairo was compiled to use.</doc>
<prerequisite name="Pango.FontMap"/>
<method name="create_context"
c:identifier="pango_cairo_font_map_create_context"
version="1.10"
introspectable="0"
deprecated="Use pango_font_map_create_context() instead."
deprecated-version="1.22">
<doc xml:whitespace="preserve">Create a #PangoContext for the given fontmap.</doc>
<return-value>
<doc xml:whitespace="preserve">the newly created context; free with g_object_unref().</doc>
<type name="Pango.Context" c:type="PangoContext*"/>
</return-value>
</method>
<method name="get_font_type"
c:identifier="pango_cairo_font_map_get_font_type"
version="1.18">
<doc xml:whitespace="preserve">Gets the type of Cairo font backend that @fontmap uses.</doc>
<return-value transfer-ownership="full">
<doc xml:whitespace="preserve">the #cairo_font_type_t cairo font backend type</doc>
<type name="cairo.FontType" c:type="cairo_font_type_t"/>
</return-value>
</method>
<method name="get_resolution"
c:identifier="pango_cairo_font_map_get_resolution"
version="1.10">
<doc xml:whitespace="preserve">Gets the resolution for the fontmap. See pango_cairo_font_map_set_resolution()</doc>
<return-value transfer-ownership="none">
<doc xml:whitespace="preserve">the resolution in "dots per inch"</doc>
<type name="gdouble" c:type="double"/>
</return-value>
</method>
<method name="set_default"
c:identifier="pango_cairo_font_map_set_default"
version="1.22">
<doc xml:whitespace="preserve">Sets a default #PangoCairoFontMap to use with Cairo.
This can be used to change the Cairo font backend that the
default fontmap uses for example. The old default font map
is unreffed and the new font map referenced.
A value of %NULL for @fontmap will cause the current default
font map to be released and a new default font
map to be created on demand, using pango_cairo_font_map_new().</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
</method>
<method name="set_resolution"
c:identifier="pango_cairo_font_map_set_resolution"
version="1.10">
<doc xml:whitespace="preserve">Sets the resolution for the fontmap. This is a scale factor between
points specified in a #PangoFontDescription and Cairo units. The
default value is 96, meaning that a 10 point font will be 13
units high. (10 * 96. / 72. = 13.3).</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<parameter name="dpi" transfer-ownership="none">
<doc xml:whitespace="preserve">the resolution in "dots per inch". (Physical inches aren't actually involved; the terminology is conventional.)</doc>
<type name="gdouble" c:type="double"/>
</parameter>
</parameters>
</method>
</interface>
<callback name="ShapeRendererFunc" c:type="PangoCairoShapeRendererFunc">
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<parameter name="cr" transfer-ownership="none">
<type name="cairo.Context" c:type="cairo_t*"/>
</parameter>
<parameter name="attr" transfer-ownership="none">
<type name="Pango.AttrShape" c:type="PangoAttrShape*"/>
</parameter>
<parameter name="do_path" transfer-ownership="none">
<type name="gboolean" c:type="gboolean"/>
</parameter>
<parameter name="data" transfer-ownership="none">
<type name="gpointer" c:type="gpointer"/>
</parameter>
</parameters>
</callback>
<function name="context_get_font_options"
c:identifier="pango_cairo_context_get_font_options"
version="1.10">
<doc xml:whitespace="preserve">Retrieves any font rendering options previously set with
pango_cairo_font_map_set_font_options(). This function does not report options
that are derived from the target surface by pango_cairo_update_context()
if no options have been set. This value is owned by the context
and must not be modified or freed.</doc>
<return-value transfer-ownership="none">
<doc xml:whitespace="preserve">the font options previously set on the context, or %NULL</doc>
<type name="cairo.FontOptions" c:type="cairo_font_options_t*"/>
</return-value>
<parameters>
<parameter name="context" transfer-ownership="none">
<doc xml:whitespace="preserve">a #PangoContext, from a pangocairo font map</doc>
<type name="Pango.Context" c:type="PangoContext*"/>
</parameter>
</parameters>
</function>
<function name="context_get_resolution"
c:identifier="pango_cairo_context_get_resolution"
version="1.10">
<doc xml:whitespace="preserve">Gets the resolution for the context. See pango_cairo_context_set_resolution()
be returned if no resolution has previously been set.</doc>
<return-value transfer-ownership="none">
<doc xml:whitespace="preserve">the resolution in "dots per inch". A negative value will</doc>
<type name="gdouble" c:type="double"/>
</return-value>
<parameters>
<parameter name="context" transfer-ownership="none">
<doc xml:whitespace="preserve">a #PangoContext, from a pangocairo font map</doc>
<type name="Pango.Context" c:type="PangoContext*"/>
</parameter>
</parameters>
</function>
<function name="context_get_shape_renderer"
c:identifier="pango_cairo_context_get_shape_renderer"
version="1.18"
introspectable="0">
<doc xml:whitespace="preserve">Sets callback function for context to use for rendering attributes
of type %PANGO_ATTR_SHAPE. See #PangoCairoShapeRendererFunc for
details.
Retrieves callback function and associated user data for rendering
attributes of type %PANGO_ATTR_SHAPE as set by
pango_cairo_context_set_shape_renderer(), if any.
if no shape rendering callback have been set.</doc>
<return-value>
<doc xml:whitespace="preserve">the shape rendering callback previously set on the context, or %NULL</doc>
<type name="ShapeRendererFunc" c:type="PangoCairoShapeRendererFunc"/>
</return-value>
<parameters>
<parameter name="context" transfer-ownership="none">
<doc xml:whitespace="preserve">a #PangoContext, from a pangocairo font map</doc>
<type name="Pango.Context" c:type="PangoContext*"/>
</parameter>
<parameter name="data" transfer-ownership="none">
<doc xml:whitespace="preserve">Pointer to #gpointer to return user data</doc>
<type name="gpointer" c:type="gpointer*"/>
</parameter>
</parameters>
</function>
<function name="context_set_font_options"
c:identifier="pango_cairo_context_set_font_options"
version="1.10">
<doc xml:whitespace="preserve">Sets the font options used when rendering text with this context.
These options override any options that pango_cairo_update_context()
derives from the target surface.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<parameter name="context" transfer-ownership="none">
<doc xml:whitespace="preserve">a #PangoContext, from a pangocairo font map</doc>
<type name="Pango.Context" c:type="PangoContext*"/>
</parameter>
<parameter name="options" transfer-ownership="none">
<doc xml:whitespace="preserve">a #cairo_font_options_t, or %NULL to unset any previously set options. A copy is made.</doc>
<type name="cairo.FontOptions" c:type="cairo_font_options_t*"/>
</parameter>
</parameters>
</function>
<function name="context_set_resolution"
c:identifier="pango_cairo_context_set_resolution"
version="1.10">
<doc xml:whitespace="preserve">Sets the resolution for the context. This is a scale factor between
points specified in a #PangoFontDescription and Cairo units. The
default value is 96, meaning that a 10 point font will be 13
units high. (10 * 96. / 72. = 13.3).</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<parameter name="context" transfer-ownership="none">
<doc xml:whitespace="preserve">a #PangoContext, from a pangocairo font map</doc>
<type name="Pango.Context" c:type="PangoContext*"/>
</parameter>
<parameter name="dpi" transfer-ownership="none">
<doc xml:whitespace="preserve">the resolution in "dots per inch". (Physical inches aren't actually involved; the terminology is conventional.) A 0 or negative value means to use the resolution from the font map.</doc>
<type name="gdouble" c:type="double"/>
</parameter>
</parameters>
</function>
<function name="context_set_shape_renderer"
c:identifier="pango_cairo_context_set_shape_renderer"
version="1.18">
<doc xml:whitespace="preserve">Sets callback function for context to use for rendering attributes
of type %PANGO_ATTR_SHAPE. See #PangoCairoShapeRendererFunc for
details.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<parameter name="context" transfer-ownership="none">
<doc xml:whitespace="preserve">a #PangoContext, from a pangocairo font map</doc>
<type name="Pango.Context" c:type="PangoContext*"/>
</parameter>
<parameter name="func"
transfer-ownership="none"
scope="notified"
closure="2"
destroy="3">
<doc xml:whitespace="preserve">Callback function for rendering attributes of type %PANGO_ATTR_SHAPE, or %NULL to disable shape rendering.</doc>
<type name="ShapeRendererFunc" c:type="PangoCairoShapeRendererFunc"/>
</parameter>
<parameter name="data" transfer-ownership="none">
<doc xml:whitespace="preserve">User data that will be passed to @func.</doc>
<type name="gpointer" c:type="gpointer"/>
</parameter>
<parameter name="dnotify" transfer-ownership="none" scope="async">
<doc xml:whitespace="preserve">Callback that will be called when the context is freed to release @data, or %NULL.</doc>
<type name="GLib.DestroyNotify" c:type="GDestroyNotify"/>
</parameter>
</parameters>
</function>
<function name="create_context"
c:identifier="pango_cairo_create_context"
version="1.22"
introspectable="0">
<doc xml:whitespace="preserve">Creates a context object set up to match the current transformation
and target surface of the Cairo context. This context can then be
used to create a layout using pango_layout_new().
This function is a convenience function that creates a context using
the default font map, then updates it to @cr. If you just need to
create a layout for use with @cr and do not need to access #PangoContext
directly, you can use pango_cairo_create_layout() instead.
g_object_unref().</doc>
<return-value>
<doc xml:whitespace="preserve">the newly created #PangoContext. Free with</doc>
<type name="Pango.Context" c:type="PangoContext*"/>
</return-value>
<parameters>
<parameter name="cr" transfer-ownership="none">
<doc xml:whitespace="preserve">a Cairo context</doc>
<type name="cairo.Context" c:type="cairo_t*"/>
</parameter>
</parameters>
</function>
<function name="create_layout"
c:identifier="pango_cairo_create_layout"
version="1.10"
introspectable="0">
<doc xml:whitespace="preserve">Creates a layout object set up to match the current transformation
and target surface of the Cairo context. This layout can then be
used for text measurement with functions like
pango_layout_get_size() or drawing with functions like
pango_cairo_show_layout(). If you change the transformation
or target surface for @cr, you need to call pango_cairo_update_layout()
This function is the most convenient way to use Cairo with Pango,
however it is slightly inefficient since it creates a separate
#PangoContext object for each layout. This might matter in an
application that was laying out large amounts of text.
g_object_unref().</doc>
<return-value>
<doc xml:whitespace="preserve">the newly created #PangoLayout. Free with</doc>
<type name="Pango.Layout" c:type="PangoLayout*"/>
</return-value>
<parameters>
<parameter name="cr" transfer-ownership="none">
<doc xml:whitespace="preserve">a Cairo context</doc>
<type name="cairo.Context" c:type="cairo_t*"/>
</parameter>
</parameters>
</function>
<function name="error_underline_path"
c:identifier="pango_cairo_error_underline_path"
version="1.14">
<doc xml:whitespace="preserve">Add a squiggly line to the current path in the specified cairo context that
approximately covers the given rectangle in the style of an underline used
to indicate a spelling error. (The width of the underline is rounded to an
integer number of up/down segments and the resulting rectangle is centered
in the original rectangle)</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<parameter name="cr" transfer-ownership="none">
<doc xml:whitespace="preserve">a Cairo context</doc>
<type name="cairo.Context" c:type="cairo_t*"/>
</parameter>
<parameter name="x" transfer-ownership="none">
<doc xml:whitespace="preserve">The X coordinate of one corner of the rectangle</doc>
<type name="gdouble" c:type="double"/>
</parameter>
<parameter name="y" transfer-ownership="none">
<doc xml:whitespace="preserve">The Y coordinate of one corner of the rectangle</doc>
<type name="gdouble" c:type="double"/>
</parameter>
<parameter name="width" transfer-ownership="none">
<doc xml:whitespace="preserve">Non-negative width of the rectangle</doc>
<type name="gdouble" c:type="double"/>
</parameter>
<parameter name="height" transfer-ownership="none">
<doc xml:whitespace="preserve">Non-negative height of the rectangle</doc>
<type name="gdouble" c:type="double"/>
</parameter>
</parameters>
</function>
<function name="font_map_get_default"
c:identifier="pango_cairo_font_map_get_default"
version="1.10"
introspectable="0">
<doc xml:whitespace="preserve">Gets a default #PangoCairoFontMap to use with Cairo.
Note that the type of the returned object will depend
on the particular font backend Cairo was compiled to use;
You generally should only use the #PangoFontMap and
#PangoCairoFontMap interfaces on the returned object.
The default Cairo fontmap can be changed by using
pango_cairo_font_map_set_default(). This can be used to
change the Cairo font backend that the default fontmap
uses for example.
object is owned by Pango and must not be freed.</doc>
<return-value>
<doc xml:whitespace="preserve">the default Cairo fontmap for Pango. This</doc>
<type name="Pango.FontMap" c:type="PangoFontMap*"/>
</return-value>
</function>
<function name="font_map_new"
c:identifier="pango_cairo_font_map_new"
version="1.10"
introspectable="0">
<doc xml:whitespace="preserve">Creates a new #PangoCairoFontMap object; a fontmap is used
to cache information about available fonts, and holds
certain global parameters such as the resolution.
In most cases, you can use pango_cairo_font_map_get_default()
instead.
Note that the type of the returned object will depend
on the particular font backend Cairo was compiled to use;
You generally should only use the #PangoFontMap and
#PangoCairoFontMap interfaces on the returned object.
be freed with g_object_unref().</doc>
<return-value>
<doc xml:whitespace="preserve">the newly allocated #PangoFontMap, which should</doc>
<type name="Pango.FontMap" c:type="PangoFontMap*"/>
</return-value>
</function>
<function name="font_map_new_for_font_type"
c:identifier="pango_cairo_font_map_new_for_font_type"
version="1.18"
introspectable="0">
<doc xml:whitespace="preserve">Creates a new #PangoCairoFontMap object of the type suitable
to be used with cairo font backend of type @fonttype.
In most cases one should simply use @pango_cairo_font_map_new(),
or in fact in most of those cases, just use
which should be freed with g_object_unref(),
or %NULL if the requested cairo font backend is
not supported / compiled in.</doc>
<return-value>
<doc xml:whitespace="preserve">the newly allocated #PangoFontMap of suitable type</doc>
<type name="Pango.FontMap" c:type="PangoFontMap*"/>
</return-value>
<parameters>
<parameter name="fonttype" transfer-ownership="none">
<doc xml:whitespace="preserve">desired #cairo_font_type_t</doc>
<type name="cairo.FontType" c:type="cairo_font_type_t"/>
</parameter>
</parameters>
</function>
<function name="glyph_string_path"
c:identifier="pango_cairo_glyph_string_path">
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<parameter name="cr" transfer-ownership="none">
<type name="cairo.Context" c:type="cairo_t*"/>
</parameter>
<parameter name="font" transfer-ownership="none">
<type name="Pango.Font" c:type="PangoFont*"/>
</parameter>
<parameter name="glyphs" transfer-ownership="none">
<type name="Pango.GlyphString" c:type="PangoGlyphString*"/>
</parameter>
</parameters>
</function>
<function name="layout_line_path"
c:identifier="pango_cairo_layout_line_path"
version="1.10">
<doc xml:whitespace="preserve">Adds the text in #PangoLayoutLine to the current path in the
specified cairo context. The origin of the glyphs (the left edge
of the line) will be at the current point of the cairo context.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<parameter name="cr" transfer-ownership="none">
<doc xml:whitespace="preserve">a Cairo context</doc>
<type name="cairo.Context" c:type="cairo_t*"/>
</parameter>
<parameter name="line" transfer-ownership="none">
<doc xml:whitespace="preserve">a #PangoLayoutLine</doc>
<type name="Pango.LayoutLine" c:type="PangoLayoutLine*"/>
</parameter>
</parameters>
</function>
<function name="layout_path"
c:identifier="pango_cairo_layout_path"
version="1.10">
<doc xml:whitespace="preserve">Adds the text in a #PangoLayout to the current path in the
specified cairo context. The top-left corner of the #PangoLayout
will be at the current point of the cairo context.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<parameter name="cr" transfer-ownership="none">
<doc xml:whitespace="preserve">a Cairo context</doc>
<type name="cairo.Context" c:type="cairo_t*"/>
</parameter>
<parameter name="layout" transfer-ownership="none">
<doc xml:whitespace="preserve">a Pango layout</doc>
<type name="Pango.Layout" c:type="PangoLayout*"/>
</parameter>
</parameters>
</function>
<function name="show_error_underline"
c:identifier="pango_cairo_show_error_underline"
version="1.14">
<doc xml:whitespace="preserve">Draw a squiggly line in the specified cairo context that approximately
covers the given rectangle in the style of an underline used to indicate a
spelling error. (The width of the underline is rounded to an integer
number of up/down segments and the resulting rectangle is centered in the
original rectangle)</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<parameter name="cr" transfer-ownership="none">
<doc xml:whitespace="preserve">a Cairo context</doc>
<type name="cairo.Context" c:type="cairo_t*"/>
</parameter>
<parameter name="x" transfer-ownership="none">
<doc xml:whitespace="preserve">The X coordinate of one corner of the rectangle</doc>
<type name="gdouble" c:type="double"/>
</parameter>
<parameter name="y" transfer-ownership="none">
<doc xml:whitespace="preserve">The Y coordinate of one corner of the rectangle</doc>
<type name="gdouble" c:type="double"/>
</parameter>
<parameter name="width" transfer-ownership="none">
<doc xml:whitespace="preserve">Non-negative width of the rectangle</doc>
<type name="gdouble" c:type="double"/>
</parameter>
<parameter name="height" transfer-ownership="none">
<doc xml:whitespace="preserve">Non-negative height of the rectangle</doc>
<type name="gdouble" c:type="double"/>
</parameter>
</parameters>
</function>
<function name="show_glyph_item"
c:identifier="pango_cairo_show_glyph_item"
version="1.22">
<doc xml:whitespace="preserve">Draws the glyphs in @glyph_item in the specified cairo context,
embedding the text associated with the glyphs in the output if the
output format supports it (PDF for example), otherwise it acts
similar to pango_cairo_show_glyph_string().
The origin of the glyphs (the left edge of the baseline) will
be drawn at the current point of the cairo context.
Note that @text is the start of the text for layout, which is then
indexed by &lt;literal&gt;@glyph_item-&gt;item-&gt;offset&lt;/literal&gt;.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<parameter name="cr" transfer-ownership="none">
<doc xml:whitespace="preserve">a Cairo context</doc>
<type name="cairo.Context" c:type="cairo_t*"/>
</parameter>
<parameter name="text" transfer-ownership="none">
<doc xml:whitespace="preserve">the UTF-8 text that @glyph_item refers to</doc>
<type name="utf8" c:type="char*"/>
</parameter>
<parameter name="glyph_item" transfer-ownership="none">
<doc xml:whitespace="preserve">a #PangoGlyphItem</doc>
<type name="Pango.GlyphItem" c:type="PangoGlyphItem*"/>
</parameter>
</parameters>
</function>
<function name="show_glyph_string"
c:identifier="pango_cairo_show_glyph_string"
version="1.10">
<doc xml:whitespace="preserve">Draws the glyphs in @glyphs in the specified cairo context.
The origin of the glyphs (the left edge of the baseline) will
be drawn at the current point of the cairo context.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<parameter name="cr" transfer-ownership="none">
<doc xml:whitespace="preserve">a Cairo context</doc>
<type name="cairo.Context" c:type="cairo_t*"/>
</parameter>
<parameter name="font" transfer-ownership="none">
<doc xml:whitespace="preserve">a #PangoFont from a #PangoCairoFontMap</doc>
<type name="Pango.Font" c:type="PangoFont*"/>
</parameter>
<parameter name="glyphs" transfer-ownership="none">
<doc xml:whitespace="preserve">a #PangoGlyphString</doc>
<type name="Pango.GlyphString" c:type="PangoGlyphString*"/>
</parameter>
</parameters>
</function>
<function name="show_layout"
c:identifier="pango_cairo_show_layout"
version="1.10">
<doc xml:whitespace="preserve">Draws a #PangoLayout in the specified cairo context.
The top-left corner of the #PangoLayout will be drawn
at the current point of the cairo context.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<parameter name="cr" transfer-ownership="none">
<doc xml:whitespace="preserve">a Cairo context</doc>
<type name="cairo.Context" c:type="cairo_t*"/>
</parameter>
<parameter name="layout" transfer-ownership="none">
<doc xml:whitespace="preserve">a Pango layout</doc>
<type name="Pango.Layout" c:type="PangoLayout*"/>
</parameter>
</parameters>
</function>
<function name="show_layout_line"
c:identifier="pango_cairo_show_layout_line"
version="1.10">
<doc xml:whitespace="preserve">Draws a #PangoLayoutLine in the specified cairo context.
The origin of the glyphs (the left edge of the line) will
be drawn at the current point of the cairo context.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<parameter name="cr" transfer-ownership="none">
<doc xml:whitespace="preserve">a Cairo context</doc>
<type name="cairo.Context" c:type="cairo_t*"/>
</parameter>
<parameter name="line" transfer-ownership="none">
<doc xml:whitespace="preserve">a #PangoLayoutLine</doc>
<type name="Pango.LayoutLine" c:type="PangoLayoutLine*"/>
</parameter>
</parameters>
</function>
<function name="update_context"
c:identifier="pango_cairo_update_context"
version="1.10">
<doc xml:whitespace="preserve">Updates a #PangoContext previously created for use with Cairo to
match the current transformation and target surface of a Cairo
context. If any layouts have been created for the context,
it's necessary to call pango_layout_context_changed() on those
layouts.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<parameter name="cr" transfer-ownership="none">
<doc xml:whitespace="preserve">a Cairo context</doc>
<type name="cairo.Context" c:type="cairo_t*"/>
</parameter>
<parameter name="context" transfer-ownership="none">
<doc xml:whitespace="preserve">a #PangoContext, from a pangocairo font map</doc>
<type name="Pango.Context" c:type="PangoContext*"/>
</parameter>
</parameters>
</function>
<function name="update_layout"
c:identifier="pango_cairo_update_layout"
version="1.10">
<doc xml:whitespace="preserve">Updates the private #PangoContext of a #PangoLayout created with
pango_cairo_create_layout() to match the current transformation
and target surface of a Cairo context.</doc>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<parameter name="cr" transfer-ownership="none">
<doc xml:whitespace="preserve">a Cairo context</doc>
<type name="cairo.Context" c:type="cairo_t*"/>
</parameter>
<parameter name="layout" transfer-ownership="none">
<doc xml:whitespace="preserve">a #PangoLayout, from pango_cairo_create_layout()</doc>
<type name="Pango.Layout" c:type="PangoLayout*"/>
</parameter>
</parameters>
</function>
</namespace>
</repository>

View File

@ -1,2 +1 @@
Matthew Willis
Slava Pestov
Anton Gorenko

View File

@ -1,243 +1,5 @@
! Copyright (C) 2008 Matthew Willis.
! Copyright (C) 2009 Slava Pestov.
! Copyright (C) 2010 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
!
! pangocairo bindings, from pango/pangocairo.h
USING: arrays sequences alien alien.c-types alien.data
alien.destructors alien.libraries alien.syntax math
math.functions math.vectors destructors combinators colors fonts
accessors assocs namespaces kernel pango pango.fonts
pango.layouts glib unicode.data images cache init system
math.rectangles fry memoize io.encodings.utf8 classes.struct
cairo cairo.ffi ;
USING: pango.cairo.ffi ;
IN: pango.cairo
<< {
{ [ os winnt? ] [ "pangocairo" "libpangocairo-1.0-0.dll" cdecl add-library ] }
{ [ os macosx? ] [ "pangocairo" "/opt/local/lib/libpangocairo-1.0.0.dylib" cdecl add-library ] }
{ [ os unix? ] [ ] }
} cond >>
LIBRARY: pangocairo
C-TYPE: PangoCairoFontMap
C-TYPE: PangoCairoFont
FUNCTION: PangoFontMap*
pango_cairo_font_map_new ( ) ;
FUNCTION: PangoFontMap*
pango_cairo_font_map_new_for_font_type ( cairo_font_type_t fonttype ) ;
FUNCTION: PangoFontMap*
pango_cairo_font_map_get_default ( ) ;
FUNCTION: cairo_font_type_t
pango_cairo_font_map_get_font_type ( PangoCairoFontMap* fontmap ) ;
FUNCTION: void
pango_cairo_font_map_set_resolution ( PangoCairoFontMap* fontmap, double dpi ) ;
FUNCTION: double
pango_cairo_font_map_get_resolution ( PangoCairoFontMap* fontmap ) ;
FUNCTION: PangoContext*
pango_cairo_font_map_create_context ( PangoCairoFontMap* fontmap ) ;
FUNCTION: cairo_scaled_font_t*
pango_cairo_font_get_scaled_font ( PangoCairoFont* font ) ;
! Update a Pango context for the current state of a cairo context
FUNCTION: void
pango_cairo_update_context ( cairo_t* cr, PangoContext* context ) ;
FUNCTION: void
pango_cairo_context_set_font_options ( PangoContext* context, cairo_font_options_t* options ) ;
FUNCTION: cairo_font_options_t*
pango_cairo_context_get_font_options ( PangoContext* context ) ;
FUNCTION: void
pango_cairo_context_set_resolution ( PangoContext* context, double dpi ) ;
FUNCTION: double
pango_cairo_context_get_resolution ( PangoContext* context ) ;
! Convenience
FUNCTION: PangoLayout*
pango_cairo_create_layout ( cairo_t* cr ) ;
FUNCTION: void
pango_cairo_update_layout ( cairo_t* cr, PangoLayout* layout ) ;
! Rendering
FUNCTION: void
pango_cairo_show_glyph_string ( cairo_t* cr, PangoFont* font, PangoGlyphString* glyphs ) ;
FUNCTION: void
pango_cairo_show_layout_line ( cairo_t* cr, PangoLayoutLine* line ) ;
FUNCTION: void
pango_cairo_show_layout ( cairo_t* cr, PangoLayout* layout ) ;
FUNCTION: void
pango_cairo_show_error_underline ( cairo_t* cr, double x, double y, double width, double height ) ;
! Rendering to a path
FUNCTION: void
pango_cairo_glyph_string_path ( cairo_t* cr, PangoFont* font, PangoGlyphString* glyphs ) ;
FUNCTION: void
pango_cairo_layout_line_path ( cairo_t* cr, PangoLayoutLine* line ) ;
FUNCTION: void
pango_cairo_layout_path ( cairo_t* cr, PangoLayout* layout ) ;
FUNCTION: void
pango_cairo_error_underline_path ( cairo_t* cr, double x, double y, double width, double height ) ;
TUPLE: layout < disposable font string selection layout metrics ink-rect logical-rect image ;
SYMBOL: dpi
72 dpi set-global
: set-layout-font ( font layout -- )
swap cache-font-description pango_layout_set_font_description ;
: set-layout-text ( str layout -- )
swap -1 pango_layout_set_text ;
: layout-extents ( layout -- ink-rect logical-rect )
PangoRectangle <struct>
PangoRectangle <struct>
[ pango_layout_get_extents ] 2keep
[ PangoRectangle>rect ] bi@ ;
: layout-baseline ( layout -- baseline )
pango_layout_get_iter &pango_layout_iter_free
pango_layout_iter_get_baseline
pango>float ;
: set-foreground ( cr font -- )
foreground>> set-source-color ;
: fill-background ( cr font dim -- )
[ background>> set-source-color ]
[ [ { 0 0 } ] dip <rect> fill-rect ] bi-curry* bi ;
: rect-translate-x ( rect x -- rect' )
'[ _ 0 2array v- ] change-loc ;
: first-line ( layout -- line )
layout>> 0 pango_layout_get_line_readonly ;
: line-offset>x ( layout n -- x )
#! n is an index into the UTF8 encoding of the text
[ drop first-line ] [ swap string>> >utf8-index ] 2bi
0 { int } [ pango_layout_line_index_to_x ] with-out-parameters
pango>float ;
: x>line-offset ( layout x -- n )
#! n is an index into the UTF8 encoding of the text
[
[ first-line ] dip
float>pango
{ int int }
[ pango_layout_line_x_to_index drop ] with-out-parameters
swap
] [ drop string>> ] 2bi utf8-index> + ;
: selection-start/end ( selection -- start end )
selection>> [ start>> ] [ end>> ] bi ;
: selection-rect ( layout -- rect )
[ ink-rect>> dim>> ] [ ] [ selection-start/end ] tri [ line-offset>x ] bi-curry@ bi
[ drop nip 0 2array ] [ swap - swap second 2array ] 3bi <rect> ;
: fill-selection-background ( cr layout -- )
dup selection>> [
[ selection>> color>> set-source-color ]
[
[ selection-rect ] [ ink-rect>> loc>> first ] bi
rect-translate-x
fill-rect
] 2bi
] [ 2drop ] if ;
: text-position ( layout -- loc )
[ logical-rect>> ] [ ink-rect>> ] bi [ loc>> ] bi@ v- ;
: set-text-position ( cr loc -- )
first2 cairo_move_to ;
: draw-layout ( layout -- image )
dup ink-rect>> dim>> [ >fixnum ] map [
swap {
[ layout>> pango_cairo_update_layout ]
[ [ font>> ] [ ink-rect>> dim>> ] bi fill-background ]
[ fill-selection-background ]
[ text-position set-text-position ]
[ font>> set-foreground ]
[ layout>> pango_cairo_show_layout ]
} 2cleave
] make-bitmap-image ;
: escape-nulls ( str -- str' )
{ { 0 CHAR: zero-width-no-break-space } } substitute ;
: unpack-selection ( layout string/selection -- layout )
dup selection? [
[ string>> escape-nulls >>string ] [ >>selection ] bi
] [ escape-nulls >>string ] if ; inline
: set-layout-resolution ( layout -- )
pango_layout_get_context dpi get pango_cairo_context_set_resolution ;
: <PangoLayout> ( text font -- layout )
dummy-cairo pango_cairo_create_layout |g_object_unref
[ set-layout-resolution ] keep
[ set-layout-font ] keep
[ set-layout-text ] keep ;
: glyph-height ( font string -- y )
swap <PangoLayout> &g_object_unref layout-extents drop dim>> second ;
MEMO: missing-font-metrics ( font -- metrics )
#! Pango doesn't provide x-height and cap-height but Core Text does, so we
#! simulate them on Pango.
[
[ metrics new ] dip
[ "x" glyph-height >>x-height ]
[ "Y" glyph-height >>cap-height ] bi
] with-destructors ;
: layout-metrics ( layout -- metrics )
dup font>> missing-font-metrics clone
swap
[ layout>> layout-baseline >>ascent ]
[ logical-rect>> dim>> [ first >>width ] [ second >>height ] bi ] bi
dup [ height>> ] [ ascent>> ] bi - >>descent ;
: <layout> ( font string -- line )
[
layout new-disposable
swap unpack-selection
swap >>font
dup [ string>> ] [ font>> ] bi <PangoLayout> >>layout
dup layout>> layout-extents [ >>ink-rect ] [ >>logical-rect ] bi*
dup layout-metrics >>metrics
dup draw-layout >>image
] with-destructors ;
M: layout dispose* layout>> g_object_unref ;
SYMBOL: cached-layouts
: cached-layout ( font string -- layout )
cached-layouts get [ <layout> ] 2cache ;
: cached-line ( font string -- line )
cached-layout layout>> first-line ;
[ <cache-assoc> cached-layouts set-global ] "pango.cairo" add-startup-hook

View File

@ -0,0 +1,26 @@
! Copyright (C) 2010 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.libraries alien.syntax cairo.ffi combinators
kernel gobject-introspection system vocabs.loader ;
IN: pango.cairo.ffi
<<
"pango.ffi" require
>>
LIBRARY: pango.cairo
<<
"pango.cairo" {
{ [ os winnt? ] [ "libpangocairo-1.0-0.dll" cdecl add-library ] }
{ [ os macosx? ] [ drop ] }
{ [ os unix? ] [ drop ] }
} cond
>>
FOREIGN-RECORD-TYPE: cairo.Context cairo_t
FOREIGN-RECORD-TYPE: cairo.ScaledFont cairo_scaled_font_t
FOREIGN-ENUM-TYPE: cairo.FontType cairo_font_type_t
FOREIGN-RECORD-TYPE: cairo.FontOptions cairo_font_options_t
GIR: vocab:pango/cairo/PangoCairo-1.0.gir

View File

@ -0,0 +1 @@
PangoCairo binding

1
basis/pango/cairo/tags.txt Executable file
View File

@ -0,0 +1 @@
bindings

View File

@ -0,0 +1,38 @@
! Copyright (C) 2010 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types alien.destructors alien.libraries
alien.syntax combinators kernel gobject-introspection
gobject-introspection.standard-types system vocabs.loader ;
IN: pango.ffi
<<
"gobject.ffi" require
>>
LIBRARY: pango
<<
"pango" {
{ [ os winnt? ] [ "libpango-1.0-0.dll" cdecl add-library ] }
{ [ os unix? ] [ drop ] }
} cond
>>
IMPLEMENT-STRUCTS: PangoRectangle ;
GIR: vocab:pango/Pango-1.0.gir
DESTRUCTOR: pango_font_description_free
DESTRUCTOR: pango_layout_iter_free
! <workaround
FORGET: pango_layout_line_index_to_x
FUNCTION: void
pango_layout_line_index_to_x ( PangoLayoutLine* line, gint index_, gboolean trailing, gint* x_pos ) ;
FORGET: pango_layout_line_x_to_index
FUNCTION: gboolean
pango_layout_line_x_to_index ( PangoLayoutLine* line, gint x_pos, gint* index_, gint* trailing ) ;
! workaround>

View File

@ -1,2 +0,0 @@
Matthew Willis
Slava Pestov

View File

@ -1,113 +0,0 @@
! Copyright (C) 2008 Matthew Willis.
! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license
USING: pango alien.syntax alien.c-types alien.destructors
kernel glib accessors combinators destructors init fonts
memoize math ;
IN: pango.fonts
LIBRARY: pango
ENUM: PangoStyle
PANGO_STYLE_NORMAL
PANGO_STYLE_OBLIQUE
PANGO_STYLE_ITALIC ;
TYPEDEF: int PangoWeight
C-TYPE: PangoFont
C-TYPE: PangoFontFamily
C-TYPE: PangoFontFace
C-TYPE: PangoFontMap
C-TYPE: PangoFontMetrics
C-TYPE: PangoFontDescription
C-TYPE: PangoGlyphString
C-TYPE: PangoLanguage
CONSTANT: PANGO_WEIGHT_THIN 100
CONSTANT: PANGO_WEIGHT_ULTRALIGHT 200
CONSTANT: PANGO_WEIGHT_LIGHT 300
CONSTANT: PANGO_WEIGHT_BOOK 380
CONSTANT: PANGO_WEIGHT_NORMAL 400
CONSTANT: PANGO_WEIGHT_MEDIUM 500
CONSTANT: PANGO_WEIGHT_SEMIBOLD 600
CONSTANT: PANGO_WEIGHT_BOLD 700
CONSTANT: PANGO_WEIGHT_ULTRABOLD 800
CONSTANT: PANGO_WEIGHT_HEAVY 900
CONSTANT: PANGO_WEIGHT_ULTRAHEAVY 1000
FUNCTION: PangoFontDescription*
pango_font_description_new ( ) ;
FUNCTION: void
pango_font_description_free ( PangoFontDescription* desc ) ;
DESTRUCTOR: pango_font_description_free
FUNCTION: PangoFontDescription*
pango_font_description_from_string ( c-string str ) ;
FUNCTION: c-string
pango_font_description_to_string ( PangoFontDescription* desc ) ;
FUNCTION: c-string
pango_font_description_to_filename ( PangoFontDescription* desc ) ;
FUNCTION: void
pango_font_description_set_family ( PangoFontDescription* desc, c-string family ) ;
FUNCTION: void
pango_font_description_set_style ( PangoFontDescription* desc, PangoStyle style ) ;
FUNCTION: void
pango_font_description_set_weight ( PangoFontDescription* desc, PangoWeight weight ) ;
FUNCTION: void
pango_font_description_set_size ( PangoFontDescription* desc, gint size ) ;
FUNCTION: void
pango_font_map_list_families ( PangoFontMap* fontmap, PangoFontFamily*** families, int* n_families ) ;
FUNCTION: c-string
pango_font_family_get_name ( PangoFontFamily* family ) ;
FUNCTION: int
pango_font_family_is_monospace ( PangoFontFamily* family ) ;
FUNCTION: void
pango_font_family_list_faces ( PangoFontFamily* family, PangoFontFace*** faces, int* n_faces ) ;
FUNCTION: c-string
pango_font_face_get_face_name ( PangoFontFace* face ) ;
FUNCTION: void
pango_font_face_list_sizes ( PangoFontFace* face, int** sizes, int* n_sizes ) ;
FUNCTION: void pango_font_metrics_unref ( PangoFontMetrics* metrics ) ;
DESTRUCTOR: pango_font_metrics_unref
FUNCTION: int pango_font_metrics_get_ascent ( PangoFontMetrics* metrics ) ;
FUNCTION: int pango_font_metrics_get_descent ( PangoFontMetrics* metrics ) ;
FUNCTION: PangoFont* pango_font_map_load_font ( PangoFontMap* fontmap, PangoContext* context, PangoFontDescription* desc ) ;
FUNCTION: PangoFontMetrics* pango_context_get_metrics ( PangoContext* context, PangoFontDescription* desc, PangoLanguage* language ) ;
FUNCTION: PangoFontMetrics* pango_font_get_metrics ( PangoFont* font, PangoLanguage* language ) ;
MEMO: (cache-font-description) ( font -- description )
[
[ pango_font_description_new |pango_font_description_free ] dip {
[ name>> pango_font_description_set_family ]
[ size>> float>pango pango_font_description_set_size ]
[ bold?>> PANGO_WEIGHT_BOLD PANGO_WEIGHT_NORMAL ? pango_font_description_set_weight ]
[ italic?>> PANGO_STYLE_ITALIC PANGO_STYLE_NORMAL ? pango_font_description_set_style ]
[ drop ]
} 2cleave
] with-destructors ;
: cache-font-description ( font -- description )
strip-font-colors (cache-font-description) ;
[ \ (cache-font-description) reset-memoized ] "pango.fonts" add-startup-hook

View File

@ -1,11 +0,0 @@
IN: pango.layouts.tests
USING: pango.layouts pango.cairo tools.test glib fonts accessors
sequences combinators.short-circuit math destructors ;
[ t ] [
[
<font> "Helvetica" >>name 12 >>size
"OH, HAI"
cached-layout ink-rect>> dim>>
] with-destructors [ 0 > ] all?
] unit-test

View File

@ -1,63 +0,0 @@
! Copyright (C) 2008 Matthew Willis.
! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.c-types alien.destructors alien.syntax glib pango
pango.fonts ;
IN: pango.layouts
LIBRARY: pango
C-TYPE: PangoLayout
C-TYPE: PangoLayoutIter
C-TYPE: PangoLayoutLine
FUNCTION: PangoLayout*
pango_layout_new ( PangoContext* context ) ;
FUNCTION: PangoContext*
pango_layout_get_context ( PangoLayout* layout ) ;
FUNCTION: void
pango_layout_set_text ( PangoLayout* layout, c-string text, int length ) ;
FUNCTION: c-string
pango_layout_get_text ( PangoLayout* layout ) ;
FUNCTION: void
pango_layout_get_size ( PangoLayout* layout, int* width, int* height ) ;
FUNCTION: void
pango_layout_set_font_description ( PangoLayout* layout, PangoFontDescription* desc ) ;
FUNCTION: PangoFontDescription*
pango_layout_get_font_description ( PangoLayout* layout ) ;
FUNCTION: void
pango_layout_get_pixel_size ( PangoLayout* layout, int* width, int* height ) ;
FUNCTION: void
pango_layout_get_extents ( PangoLayout* layout, PangoRectangle* ink_rect, PangoRectangle* logical_rect ) ;
FUNCTION: void
pango_layout_get_pixel_extents ( PangoLayout* layout, PangoRectangle* ink_rect, PangoRectangle* logical_rect ) ;
FUNCTION: PangoLayoutLine*
pango_layout_get_line_readonly ( PangoLayout* layout, int line ) ;
FUNCTION: void
pango_layout_line_index_to_x ( PangoLayoutLine* line, int index_, uint trailing, int* x_pos ) ;
FUNCTION: gboolean
pango_layout_line_x_to_index ( PangoLayoutLine* line, int x_pos, int* index_, int* trailing ) ;
FUNCTION: PangoLayoutIter*
pango_layout_get_iter ( PangoLayout* layout ) ;
FUNCTION: int
pango_layout_iter_get_baseline ( PangoLayoutIter* iter ) ;
FUNCTION: void
pango_layout_iter_free ( PangoLayoutIter* iter ) ;
DESTRUCTOR: pango_layout_iter_free

View File

@ -1,39 +1,5 @@
! Copyright (C) 2008 Matthew Willis.
! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license
USING: arrays system alien.destructors alien.c-types alien.syntax alien
combinators math.rectangles kernel math alien.libraries classes.struct
accessors ;
! Copyright (C) 2009 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: pango.ffi ;
IN: pango
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Helpful functions from other parts of pango
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<< {
{ [ os winnt? ] [ "pango" "libpango-1.0-0.dll" cdecl add-library ] }
{ [ os macosx? ] [ "pango" "/opt/local/lib/libpango-1.0.0.dylib" cdecl add-library ] }
{ [ os unix? ] [ ] }
} cond >>
LIBRARY: pango
CONSTANT: PANGO_SCALE 1024
: pango>float ( n -- x ) PANGO_SCALE /f ; inline
: float>pango ( x -- n ) PANGO_SCALE * >integer ; inline
C-TYPE: PangoContext
FUNCTION: PangoContext* pango_context_new ( ) ;
STRUCT: PangoRectangle
{ x int }
{ y int }
{ width int }
{ height int } ;
: PangoRectangle>rect ( PangoRectangle -- rect )
[ [ x>> pango>float ] [ y>> pango>float ] bi 2array ]
[ [ width>> pango>float ] [ height>> pango>float ] bi 2array ] bi
<rect> ;

1
basis/pango/summary.txt Normal file
View File

@ -0,0 +1 @@
Pango binding

1
basis/pango/tags.txt Executable file
View File

@ -0,0 +1 @@
bindings

View File

@ -140,13 +140,13 @@ os macosx? [
[ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><foo>Factor</foo>" ]
[ deploy-test-command ascii [ readln ] with-process-reader ] unit-test
[ ] [ 800000 small-enough? ] unit-test
[ ] [ 850000 small-enough? ] unit-test
[ ] [ "tools.deploy.test.21" shake-and-bake ] unit-test
[ "1 2 3" ]
[ deploy-test-command ascii [ readln ] with-process-reader ] unit-test
[ ] [ 600000 small-enough? ] unit-test
[ ] [ 800000 small-enough? ] unit-test
[ ] [ "benchmark.ui-panes" shake-and-bake run-temp-image ] unit-test

View File

@ -93,6 +93,13 @@ IN: tools.deploy.shaker
run-file
] when ;
: strip-gobject ( -- )
"gobject-introspection.types" vocab [
"Stripping GObject type info" show
"vocab:tools/deploy/shaker/strip-gobject.factor"
run-file
] when ;
: strip-specialized-arrays ( -- )
strip-dictionary? "specialized-arrays" vocab and [
"Stripping specialized arrays" show
@ -534,6 +541,7 @@ SYMBOL: deploy-vocab
strip-destructors
strip-call
strip-cocoa
strip-gobject
strip-debugger
strip-ui-error-hook
strip-specialized-arrays

View File

@ -0,0 +1,3 @@
USING: namespaces assocs gobject-introspection.types ;
type-infos global delete-at

View File

@ -10,6 +10,6 @@ H{
{ deploy-reflection 1 }
{ deploy-word-props? f }
{ deploy-math? t }
{ deploy-threads? t }
{ deploy-threads? f }
{ deploy-word-defs? f }
}

Some files were not shown because too many files have changed in this diff Show More