February 05, 2014
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.
February 05, 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
February 05, 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?
February 05, 2014
Am 05.02.2014 19:11, schrieb Jeroen Bollen:
> 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?

You always have to put the class defintion and implementation into the same executable / library. You can however define a interface and query the actual implementation from the library. So basically it would come down to a getInstance method or factory method.
1 2
Next ›   Last »