 
 : com-wrap ( object wrapper -- wrapped-object )
     [ vtbls>> ] [ (malloc-wrapped-object) ] bi
-    [ [ set-void*-nth ] curry each-index ] keep
+    [ over length <direct-void*-array> 0 swap copy ] keep
     [ +wrapped-objects+ get-global set-at ] keep ;

        _ case
        [
            "void*" heap-size * rot <displaced-alien> com-add-ref
            0 rot set-void*-nth S_OK
        ] [ nip f 0 rot set-void*-nth E_NOINTERFACE ] if*
    ] ;

: (make-add-ref) ( interfaces -- quot )
    length "void*" heap-size * '[
        _ swap <displaced-alien>
        0 over ulong-nth
        1+ [ 0 rot set-ulong-nth ] keep
    ] ;

: (make-release) ( interfaces -- quot )
    length "void*" heap-size * '[
        _ over <displaced-alien>
        0 over ulong-nth
        1- [ 0 rot set-ulong-nth ] keep
        dup zero? [ swap (free-wrapped-object) ] [ nip ] if
    ] ;

: (make-iunknown-methods) ( interfaces -- quots )

USING: alien alien.c-types alien.accessors windows.com.syntax
init windows.com.syntax.private windows.com continuations kernel
namespaces windows.ole32 libc vocabs assocs accessors arrays
sequences quotations combinators math words compiler.units
destructors fry math.parser generalizations sets
specialized-arrays.alien specialized-arrays.direct.alien ;
IN: windows.com.wrapper

TUPLE: com-wrapper callbacks vtbls disposed ;
