USING: alien alien.c-types help.syntax help.markup libc
kernel.private byte-arrays math strings hashtables alien.syntax
alien.strings sequences io.encodings.string debugger destructors
-vocabs.loader classes.struct quotations ;
+vocabs.loader classes.struct quotations kernel ;
IN: alien.data
HELP: <c-array>
"For example, if a C function returns a " { $link c-string } " but stipulates that the caller must deallocate the memory afterward, you must define the function as returning " { $snippet "char*" } " and call " { $link (free) } " yourself." ;
HELP: <ref>
-{ $values { "c-type" "a C type" } }
+{ $values { "value" object } { "c-type" "a C type" } { "c-ptr" c-ptr } }
{ $description "Creates a new byte array to store a Factor object as a C value." }
{ $examples
{ $example "USING: alien.c-types alien.data prettyprint sequences ;" "123 int <ref> length ." "4" }
} ;
HELP: deref
-{ $values { "c-type" "a C type" } }
+{ $values { "c-ptr" c-ptr } { "c-type" "a C type" } { "value" object } }
{ $description "Loads a C value from a byte array." }
{ $examples
{ $example "USING: alien.c-types alien.data prettyprint sequences ;" "321 int <ref> int deref ." "321" }
-USING: alien alien.c-types alien.data alien.syntax
+USING: alien alien.data alien.syntax
classes.struct kernel sequences specialized-arrays
-specialized-arrays.private tools.test compiler.units vocabs ;
+specialized-arrays.private tools.test compiler.units vocabs
+system ;
+QUALIFIED-WITH: alien.c-types c
IN: alien.data.tests
-
-[ -1 ] [ -1 char <ref> char deref ] unit-test
-[ -1 ] [ -1 short <ref> short deref ] unit-test
-[ -1 ] [ -1 int <ref> int deref ] unit-test
+[ -1 ] [ -1 c:char <ref> c:char deref ] unit-test
+[ -1 ] [ -1 c:short <ref> c:short deref ] unit-test
+[ -1 ] [ -1 c:int <ref> c:int deref ] unit-test
! I don't care if this throws an error or works, but at least
! it should be consistent between platforms
-[ -1 ] [ -1.0 int <ref> int deref ] unit-test
-[ -1 ] [ -1.0 long <ref> long deref ] unit-test
-[ -1 ] [ -1.0 longlong <ref> longlong deref ] unit-test
-[ 1 ] [ 1.0 uint <ref> uint deref ] unit-test
-[ 1 ] [ 1.0 ulong <ref> ulong deref ] unit-test
-[ 1 ] [ 1.0 ulonglong <ref> ulonglong deref ] unit-test
+[ -1 ] [ -1.0 c:int <ref> c:int deref ] unit-test
+[ -1 ] [ -1.0 c:long <ref> c:long deref ] unit-test
+[ -1 ] [ -1.0 c:longlong <ref> c:longlong deref ] unit-test
+[ 1 ] [ 1.0 c:uint <ref> c:uint deref ] unit-test
+[ 1 ] [ 1.0 c:ulong <ref> c:ulong deref ] unit-test
+[ 1 ] [ 1.0 c:ulonglong <ref> c:ulonglong deref ] unit-test
[
- 0 B{ 1 2 3 4 } <displaced-alien> void* <ref>
+ 0 B{ 1 2 3 4 } <displaced-alien> c:void* <ref>
] must-fail
os windows? cpu x86.64? and [
- [ -2147467259 ] [ 2147500037 long <ref> long deref ] unit-test
+ [ -2147467259 ] [ 2147500037 c:long <ref> c:long deref ] unit-test
] when
-STRUCT: foo { a int } { b void* } { c bool } ;
+STRUCT: foo { a c:int } { b c:void* } { c c:bool } ;
SPECIALIZED-ARRAY: foo
[ [
! [<fortran-result>]
- [ complex-float <c-object> ] 1 ndip
+ [ complex-float heap-size <byte-array> ] 1 ndip
! [fortran-args>c-args]
{ [ { [ ] } spread ] [ { [ drop ] } spread ] } 1 ncleave
! [fortran-invoke]
USING: tools.test kernel.private kernel arrays sequences
math.private math generic words quotations alien alien.c-types
-strings sbufs sequences.private slots.private combinators
-definitions system layouts vectors math.partial-dispatch
-math.order math.functions accessors hashtables classes assocs
-io.encodings.utf8 io.encodings.ascii io.encodings fry slots
-sorting.private combinators.short-circuit grouping prettyprint
-generalizations
+alien.data strings sbufs sequences.private slots.private
+combinators definitions system layouts vectors
+math.partial-dispatch math.order math.functions accessors
+hashtables classes assocs io.encodings.utf8 io.encodings.ascii
+io.encodings fry slots sorting.private combinators.short-circuit
+grouping prettyprint generalizations
compiler.tree
compiler.tree.combinators
compiler.tree.cleanup
] cleaned-up-tree nodes>quot
] unit-test
-USING: alien alien.c-types ;
-
[ t ] [
[ int { } cdecl [ 2 2 + ] alien-callback ]
{ + } inlined?
alien.data math.vectors definitions compiler.test ;
FROM: specialized-arrays.private => specialized-array-vocab ;
FROM: alien.c-types => int float bool char float ulonglong ushort uint
-heap-size little-endian? ;
+heap-size ;
+FROM: alien.data => little-endian? ;
IN: specialized-arrays.tests
SPECIALIZED-ARRAY: int
-USING: accessors alien.c-types kernel
+USING: accessors alien.c-types alien.data kernel
io.encodings.utf16 io.streams.byte-array tools.test ;
IN: io.encodings.utf16n