Merge branch 'master' of git://factorcode.org/git/factor

db4
Doug Coleman 2009-08-25 16:30:35 -05:00
commit d51e9c54cb
2 changed files with 14 additions and 3 deletions

View File

@ -1,7 +1,7 @@
! (c)Joe Groff bsd license ! (c)Joe Groff bsd license
USING: accessors alien.c-types alien.libraries USING: accessors alien.c-types alien.libraries
alien.structs.fields alien.syntax classes.struct combinators alien.structs.fields alien.syntax classes.struct combinators
io.pathnames io.streams.string kernel libc literals math destructors io.pathnames io.streams.string kernel libc literals math
multiline namespaces prettyprint prettyprint.config see system multiline namespaces prettyprint prettyprint.config see system
tools.test ; tools.test ;
IN: classes.struct.tests IN: classes.struct.tests
@ -54,7 +54,18 @@ UNION-STRUCT: struct-test-float-and-bits
[ 1.0 ] [ struct-test-float-and-bits <struct> 1.0 float>bits >>bits f>> ] unit-test [ 1.0 ] [ struct-test-float-and-bits <struct> 1.0 float>bits >>bits f>> ] unit-test
[ 4 ] [ struct-test-float-and-bits heap-size ] unit-test [ 4 ] [ struct-test-float-and-bits heap-size ] unit-test
[ ] [ struct-test-foo malloc-struct free ] unit-test [ ] [ [ struct-test-foo malloc-struct &free drop ] with-destructors ] unit-test
STRUCT: struct-test-string-ptr
{ x char* } ;
[ "hello world" ] [
[
struct-test-string-ptr <struct>
"hello world" utf8 malloc-string &free >>x
x>>
] with-destructors
] unit-test
[ "S{ struct-test-foo { y 7654 } }" ] [ "S{ struct-test-foo { y 7654 } }" ]
[ [

View File

@ -204,7 +204,7 @@ M: struct-class heap-size
ERROR: invalid-struct-slot token ; ERROR: invalid-struct-slot token ;
: struct-slot-class ( c-type -- class' ) : struct-slot-class ( c-type -- class' )
c-type boxed-class>> c-type c-type-boxed-class
dup \ byte-array = [ drop \ c-ptr ] when ; dup \ byte-array = [ drop \ c-ptr ] when ;
: parse-struct-slot ( -- slot ) : parse-struct-slot ( -- slot )