! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien.complex.functor sequences kernel ;
+USING: alien.c-types alien.complex.functor accessors
+sequences kernel ;
IN: alien.complex
-<< { "float" "double" } [ dup "complex-" prepend define-complex-type ] each >>
\ No newline at end of file
+<<
+{ "float" "double" } [ dup "complex-" prepend define-complex-type ] each
+
+! This overrides the fact that small structures are never returned
+! in registers on NetBSD, Linux and Solaris running on 32-bit x86.
+"complex-float" c-type t >>return-in-registers? drop
+ >>
USING: accessors arrays assocs generic hashtables kernel kernel.private
math namespaces parser sequences strings words libc fry
alien.c-types alien.structs.fields cpu.architecture math.order
-quotations ;
+quotations byte-arrays ;
IN: alien.structs
TUPLE: struct-type
{ boxer-quot callable }
{ unboxer-quot callable }
{ getter callable }
-{ setter callable } ;
+{ setter callable }
+return-in-registers? ;
+
+M: struct-type c-type ;
M: struct-type heap-size size>> ;
-M: struct-type c-type-class drop object ;
+M: struct-type c-type-class drop byte-array ;
M: struct-type c-type-align align>> ;
[ %box-large-struct ] [ box-parameter ] if-value-struct ;
: if-small-struct ( c-type true false -- ? )
- [ dup struct-small-enough? ] 2dip '[ f swap @ ] if ; inline
+ [ dup return-struct-in-registers? ] 2dip '[ f swap @ ] if ; inline
M: struct-type unbox-return
[ %unbox-small-struct ] [ %unbox-large-struct ] if-small-struct ;
IN: compiler.alien
: large-struct? ( ctype -- ? )
- dup c-struct? [ struct-small-enough? not ] [ drop f ] if ;
+ dup c-struct? [ return-struct-in-registers? not ] [ drop f ] if ;
: alien-parameters ( params -- seq )
dup parameters>>
HOOK: small-enough? cpu ( n -- ? )
! Is this structure small enough to be returned in registers?
-HOOK: struct-small-enough? cpu ( c-type -- ? )
+HOOK: return-struct-in-registers? cpu ( c-type -- ? )
! Do we pass this struct by value or hidden reference?
HOOK: value-struct? cpu ( c-type -- ? )
M: ppc small-enough? ( n -- ? ) -32768 32767 between? ;
-M: ppc struct-small-enough? ( size -- ? ) drop f ;
+M: ppc return-struct-in-registers? ( c-type -- ? ) drop f ;
M: ppc %box-small-struct
drop "No small structs" throw ;
M: x86.32 %alien-invoke-tail (JMP) rel-dlsym ;
-M: x86.32 struct-small-enough? ( size -- ? )
- heap-size { 1 2 4 8 } member?
- os { linux netbsd solaris } member? not and ;
+M: x86.32 return-struct-in-registers? ( c-type -- ? )
+ c-type
+ [ return-in-registers?>> ]
+ [ heap-size { 1 2 4 8 } member? ] bi
+ os { linux netbsd solaris } member? not
+ and or ;
: struct-return@ ( n -- operand )
[ next-stack@ ] [ stack-frame get params>> stack@ ] if* ;
flatten-small-struct
] if ;
-M: x86.64 struct-small-enough? ( size -- ? )
+M: x86.64 return-struct-in-registers? ( c-type -- ? )
heap-size 2 cells <= ;
M: x86.64 dummy-stack-params? f ;
M: x86.64 reserved-area-size 4 cells ;
-M: x86.64 struct-small-enough? heap-size { 1 2 4 8 } member? ;
+M: x86.64 return-struct-in-registers? ( c-type -- ? )
+ heap-size { 1 2 4 8 } member? ;
M: x86.64 value-struct? heap-size { 1 2 4 8 } member? ;
! Copyright (C) 2008, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors colors arrays kernel sequences math byte-arrays
-namespaces grouping fry cap images.bitmap
-ui.gadgets ui.gadgets.packs ui.gadgets.borders ui.gadgets.grids
-ui.gadgets.grid-lines ui.gadgets.labels ui.gadgets.buttons
-ui.render ui opengl opengl.gl colors.constants images ;
+namespaces grouping fry cap images.bitmap ui.gadgets ui.gadgets.packs
+ui.gadgets.borders ui.gadgets.grids ui.gadgets.grid-lines
+ui.gadgets.labels ui.gadgets.buttons ui.pens ui.pens.solid ui.render
+ui opengl opengl.gl colors.constants images images.loader ;
IN: ui.render.test
SINGLETON: line-test
screenshot
[ render-output set-global ]
[
- "resource:extra/ui/render/test/reference.bmp" <image>
+ "resource:extra/ui/render/test/reference.bmp" load-image
bitmap= "is perfect" "needs work" ?
"Your UI rendering " prepend
message-window