alien.marshall: unmarshaller fixes

db4
Jeremy Hughes 2009-07-09 10:36:21 +12:00
parent e2c6b21bfb
commit 426d173b7c
1 changed files with 6 additions and 4 deletions

View File

@ -230,17 +230,19 @@ M: struct-wrapper dynamic-cast ;
} case ;
: ?malloc-byte-array ( c-type -- alien )
dup alien? [ malloc-byte-array ] unless ;
: struct-unmarshaller ( type -- quot )
current-vocab lookup [
dup superclasses [ struct-wrapper? ] any? [
[ class name>> heap-size ] keep
'[ _ malloc-byte-array _ new swap >>underlying ]
dup superclasses [ \ struct-wrapper = ] any? [
'[ ?malloc-byte-array _ new swap >>underlying ]
] [ drop [ ] ] if
] [ [ ] ] if* ;
: pointer-unmarshaller ( type -- quot )
type-sans-pointer current-vocab lookup [
dup superclasses [ alien-wrapper? ] any? [
dup superclasses [ \ alien-wrapper = ] any? [
'[ _ new swap >>underlying dynamic-cast ]
] [ drop [ ] ] if
] [ [ ] ] if* ;