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 ; } case ;
: ?malloc-byte-array ( c-type -- alien )
dup alien? [ malloc-byte-array ] unless ;
: struct-unmarshaller ( type -- quot ) : struct-unmarshaller ( type -- quot )
current-vocab lookup [ current-vocab lookup [
dup superclasses [ struct-wrapper? ] any? [ dup superclasses [ \ struct-wrapper = ] any? [
[ class name>> heap-size ] keep '[ ?malloc-byte-array _ new swap >>underlying ]
'[ _ malloc-byte-array _ new swap >>underlying ]
] [ drop [ ] ] if ] [ drop [ ] ] if
] [ [ ] ] if* ; ] [ [ ] ] if* ;
: pointer-unmarshaller ( type -- quot ) : pointer-unmarshaller ( type -- quot )
type-sans-pointer current-vocab lookup [ type-sans-pointer current-vocab lookup [
dup superclasses [ alien-wrapper? ] any? [ dup superclasses [ \ alien-wrapper = ] any? [
'[ _ new swap >>underlying dynamic-cast ] '[ _ new swap >>underlying dynamic-cast ]
] [ drop [ ] ] if ] [ drop [ ] ] if
] [ [ ] ] if* ; ] [ [ ] ] if* ;