Using DLLs to extend an existing class

Sebastian Trent null at null.com
Tue Dec 19 22:02:08 UTC 2017


I'm developing a plugin system for a D program.

I have a complex class hierarchy which will be complied into our 
executable, and I want
third parties to be able to further extend it with their own DLLs 
- subject to implementing an API present in the most derived 
class - which will be provided to the user as a auto generated 
header (.di) file using "dmd -H [modules]"


For example, in our program:

---
class A
{
     //Protected and public methods
}


class B : A
{
     //Protected and public methods.

     public string apiMethod()
     {
         return "Class B";
     }

}
---

And in a typical "Dll to be' plugin:

---

import B; //Currently using a 'header' file generated with dmd -H 
b.d;

mixin dllBoilerplate;


export class C : B
{
    //Public (export?) API implimentation
     override public string apiMethod()
     {
         return "Class C";
     }

    //Private methods
}


Currently, when I try to compile the plugin DLL, I get linker 
errors that mangled symbol for apiMethod is not defined - These 
are the symbols defined in the header (b.di) file, but are not 
implemented: by definition intended to be part of the main 
program, instead.

Can anyone explain how I should go about building the plugin - I 
suspect it involved what I am and am not declaring 'export', but 
I'm unable to find any material that puts light on my situation.

Thanks.

ST.









More information about the Digitalmars-d-learn mailing list