DLL in D based on Tango

BLS nanali at nospam-wanadoo.fr
Mon Jul 9 13:08:45 PDT 2007


Sean Kelly schrieb:
> BLS wrote:
>> Hello,
>> My question is :
>> Can I create a DLL written in *D* having a simple C Interface  *A* 
>> scripting language can use ?
>> Probabely yes.
>>  Using TANGO ? I do not know.
> 
> Tango has two routines for initializing and terminating the runtime:
> 
> extern (C) bool  rt_init( void delegate( Exception ) dg = null );
> extern (C) bool  rt_term( void delegate( Exception ) dg = null );
> 
> Call these in DllMain or wherever appropriate.  The delegate will be 
> passed any exceptions thrown while the functions are processing, and 
> will return true/false on success/failure.
> 
> As for the rest, building a DLL in Tango should be the same as doing so 
> with Phobos.
> 
> 
> Sean

Thank you Sean !
Sean :
 > Tango has two routines for initializing and terminating the runtime:
 >
 > extern (C) bool  rt_init( void delegate( Exception ) dg = null );
 > Call these in DllMain or wherever appropriate.

leaves a lot of room for improvements, f.i.:

BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved)
{
     switch (ulReason)
     {
	case DLL_PROCESS_ATTACH:
	    gc_init();			// initialize GC
............
	case DLL_PROCESS_DETACH:
............
Pretty sure it will make you shake your head - But I have to ask: Shall 
I simply replace gc_init() with rt_init().

I am sorry about beeing so uninformed:ignorant but I never really 
understand the GC/Runtime Tango/Phobos problem.

So Sean;  I remain with a Thank You and hope you will be patient enough 
to offer a minimalistic sample ?
(probabely on DSource/Tango. may be more people are interested)

Bjoern





More information about the Digitalmars-d mailing list