RE: Eu's good design

new topic     » goto parent     » topic index » view thread      » older message » newer message

Al Getz wrote:
> 
> jbrown105 at speedymail.org wrote:
> >
> > Well, how would you call a virtual function in Euphoria?
>
> For example...
> 
> 
> include dll.e
> RoutineName = define_c_func( {}, RoutineMemAddress, {C_POINTER}, 
> C_LONG)
> 
> --Then you can call it via c_func:
> 
> atom retv
> retv=c_func(RoutineName,{Params})
> 
> Rob said he was thinking of a way to 'undefine' the c func
> too in case you dont need that particular routine any longer.
> 
> It works pretty good for fairly static methods that will
> probably be used throughout the program instances life.

It's also possible to do it using fptr.e in a truly dynamic way:

ok = call_cdecl(peek4u(peek4u(this)+func_offset), {this, arg1, arg2})

Because technically, you should be looking up the function in the 
object's virtual function table (this is how C++ compilers do it) 
because it could be overridden.

Matt Lewis

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu