Handbook
Glossary
define-complex-type ( N T -- )
Vocabulary
alien
.
complex
.
functor
Inputs
N
an
object
T
an
object
Outputs
None
Definition
USING:
accessors
alien
alien.c-types
arrays
classes.parser
classes.struct
functors.backend
functors.private
io
io.streams.string
kernel
math
parser
present
quotations
sequences
vectors
words
;
IN:
alien.complex.functor
::
define-complex-type
( N T -- )
[
N
present
write
]
with-string-writer
parse-word
:>
N-type
[
T
present
write
]
with-string-writer
create-class-in
:>
T-class
[
"<"
write
T
present
write
">"
write
]
with-string-writer
create-word-in
:>
<T>
[
"*"
write
T
present
write
]
with-string-writer
create-word-in
:>
*T T-class 8
<vector>
"real"
N-type
V{
}
<struct-slot-spec>
suffix!
"imaginary"
N-type
V{
}
<struct-slot-spec>
suffix!
>array
define-struct-class
<T>
T{
fake-quotation
{
seq
{
>rect
T-class
boa
>c-ptr
}
}
}
fake-quotations>
first
( z -- alien )
define-declared*
*T
T{
fake-quotation
{
seq
{
T-class
memory>struct
T{
fake-quotation
{
seq ~array~
}
}
T{
fake-quotation
{
seq ~array~
}
}
bi
rect>
}
}
}
fake-quotations>
first
( alien -- z )
define-declared*
last-word
make-inline
T-class
lookup-c-type
<T>
1quotation
>>unboxer-quot
*T
1quotation
>>boxer-quot
complex
>>boxed-class
drop
;