Merge branch 'master' of git://factorcode.org/git/factor
commit
1f58ca9e2a
|
@ -65,3 +65,6 @@ M: struct-type stack-size
|
||||||
: offset-of ( field struct -- offset )
|
: offset-of ( field struct -- offset )
|
||||||
c-types get at fields>>
|
c-types get at fields>>
|
||||||
[ name>> = ] with find nip offset>> ;
|
[ name>> = ] with find nip offset>> ;
|
||||||
|
|
||||||
|
USE: vocabs.loader
|
||||||
|
"struct-arrays" require
|
||||||
|
|
|
@ -5,7 +5,8 @@ destructors io.encodings.utf8 io.pathnames io.streams.string
|
||||||
kernel libc literals math multiline namespaces prettyprint
|
kernel libc literals math multiline namespaces prettyprint
|
||||||
prettyprint.config see sequences specialized-arrays.ushort
|
prettyprint.config see sequences specialized-arrays.ushort
|
||||||
system tools.test compiler.tree.debugger struct-arrays
|
system tools.test compiler.tree.debugger struct-arrays
|
||||||
classes.tuple.private specialized-arrays.direct.int ;
|
classes.tuple.private specialized-arrays.direct.int
|
||||||
|
compiler.units ;
|
||||||
IN: classes.struct.tests
|
IN: classes.struct.tests
|
||||||
|
|
||||||
<<
|
<<
|
||||||
|
@ -22,6 +23,11 @@ IN: classes.struct.tests
|
||||||
"f-stdcall" libfactor-ffi-tests-path "stdcall" add-library
|
"f-stdcall" libfactor-ffi-tests-path "stdcall" add-library
|
||||||
>>
|
>>
|
||||||
|
|
||||||
|
SYMBOL: struct-test-empty
|
||||||
|
|
||||||
|
[ [ struct-test-empty { } define-struct-class ] with-compilation-unit ]
|
||||||
|
[ struct-must-have-slots? ] must-fail-with
|
||||||
|
|
||||||
STRUCT: struct-test-foo
|
STRUCT: struct-test-foo
|
||||||
{ x char }
|
{ x char }
|
||||||
{ y int initial: 123 }
|
{ y int initial: 123 }
|
||||||
|
|
|
@ -12,6 +12,8 @@ IN: classes.struct
|
||||||
|
|
||||||
! struct class
|
! struct class
|
||||||
|
|
||||||
|
ERROR: struct-must-have-slots ;
|
||||||
|
|
||||||
TUPLE: struct
|
TUPLE: struct
|
||||||
{ (underlying) c-ptr read-only } ;
|
{ (underlying) c-ptr read-only } ;
|
||||||
|
|
||||||
|
@ -207,7 +209,10 @@ M: struct-class heap-size
|
||||||
[ c-type>> c-type drop ] each ;
|
[ c-type>> c-type drop ] each ;
|
||||||
|
|
||||||
: (define-struct-class) ( class slots offsets-quot -- )
|
: (define-struct-class) ( class slots offsets-quot -- )
|
||||||
[ drop struct f define-tuple-class ]
|
[
|
||||||
|
[ struct-must-have-slots ]
|
||||||
|
[ drop struct f define-tuple-class ] if-empty
|
||||||
|
]
|
||||||
swap '[
|
swap '[
|
||||||
make-slots dup
|
make-slots dup
|
||||||
[ check-struct-slots ] _ [ struct-align [ align ] keep ] tri
|
[ check-struct-slots ] _ [ struct-align [ align ] keep ] tri
|
||||||
|
|
Loading…
Reference in New Issue