[racket-dev] Calling virtual functions

From: Yuriy Kovalev (yoschi at mail.ru)
Date: Sun Feb 13 07:38:46 EST 2011

pIdisp is not vtable itself, but a pointer to this one. So, this code works:

(let* ([vtable (ptr-ref pIdisp _pointer)]
       [addref (ptr-ref vtable (_fun #:abi 'stdcall _com-interface -> _uint) 
       [release (ptr-ref vtable (_fun #:abi 'stdcall _com-interface -> 
_uint) 2)])
  (addref pIdisp)
  (release pIdisp))

Thanks for help!

----- Original Message ----- 
From: Ben Goetter <goetter at mazama.net>
To: Kovalev Yuriy <yoschi at mail.ru>
Cc: dev at racket-lang.org
Subject: Re: [racket-dev] Calling virtual functions
> To dig into that vtable, use ptr-ref.  Don't forget to pass the
> interface back to the method as its first parameter.
> Following is untested.  Not even paren-balanced.
> (let ((addref (ptr-ref pIdisp (_fun #:abi 'stdcall _com-interface ->
> _uint) 1))
>        (release (ptr-ref pIdisp (_fun #:abi 'stdcall _com-interface ->
> _uint) 2)))
>  (addref pIdisp)
>  ...
>  (release pIdisp))

Posted on the dev mailing list.