1. Calling Callback function
Hi,
Does any one know how to call a euphoria function from a C++ DLL, using it's
callback address?
Thanks :)
--PatRat (Thomas Parslow)
-- ()___()
-- (o o)
-- =\O/=
-- Rat Software
-- http://free.prohosting.com/~rats/ratsoft/
2. Re: Calling Callback function
- Posted by Daniel Berstein <daber at PAIR.COM>
Jan 29, 1999
-
Last edited Jan 30, 1999
At 03:24 p.m. 29-01-99 +0000, you wrote:
>Hi,
>Does any one know how to call a euphoria function from a C++ DLL, using it's
>callback address?
I don't know C++, but in Delphi all you do is assign to a
procedure/function type the
address of the callback function:
In Euphoria:
atom cb
cb = call_back(routine_id(my_func))
Then you must pass the address of my_func (cb) to the DLL.
MyDLL = open_dll("MyDLL")
SomeProc = define_c_proc(MyDLL, "SomeProc", {C_POINTER})
c_proc(SomeProc, {cb})
On the DLL use something like:
//In C this should be a typedef
type
TEuCallback: procedure([parameter list]; stdcall;
var
EuCallback: TEuCallback;
//The address of (@) operator is used to assign the callback address
procedure SomeProc (cb: pointer);
begin
@EuCallback := cb;
end;
And to call the callback routine "execute" the callback routine:
EuCallback([parameters]);
It's important you use stdcall as the calling convention (if it's not the
default
on your language, I belive C uses stdcall by default).
Regards,
Daniel Berstein
daber at pair.com
3. Re: Calling Callback function
Thomas Parslow writes:
> Does any one know how to call a euphoria function from
> a C++ DLL, using it's callback address?
See the end of PLATFORM.DOC in 2.1. There's an example of how
to declare a Euphoria function so it's callable from WATCOM C.
You have to specify the correct C calling convention.
I think it's usually called "stdcall". Also, in C++ you have to specify
something special to call a C function - extern "C" - or something.
Regards,
Rob Craig
Rapid Deployment Software
http://members.aol.com/FilesEu/