Is there a way to do 2-way linking?

Jeroen Bollen jbinero at gmail.com
Wed Feb 5 10:11:42 PST 2014


On Wednesday, 5 February 2014 at 17:59:38 UTC, Benjamin Thaut 
wrote:
> 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

But what if I want to define a class loader side and implement it 
library side? I guess I'll have to write 'getInstance' methods?


More information about the Digitalmars-d mailing list