Is there a way to do 2-way linking?

Benjamin Thaut code at benjamin-thaut.de
Wed Feb 5 09:59:38 PST 2014


Am 05.02.2014 18:51, schrieb Benjamin Thaut:
> Am 05.02.2014 18:41, schrieb Jeroen Bollen:
>> How exactly would that work for classes?
>
> Once again, make an interface for all methods you want to be available.
>
> interface IExposed
> {
>    void method1();
>    void method2();
> }
>
> then pass that interface to the plugin. Because all interface methods
> are virtual function calls, the plugin does not have to know the
> location of these methods at link time.

If you need real world code:
https://github.com/Ingrater/Spacecraft/blob/physics/game/sources/physics/dllmain.d
The "InitPlugin" function establishes the two way communication.

You can find the loader here:
https://github.com/Ingrater/thBase/blob/master/src/thBase/plugin.d#L265

Kind Regards
Benjamin Thaut


More information about the Digitalmars-d mailing list