digitalmars.D - DLL in D based on Tango
- BLS <nanali nospam-wanadoo.fr> Jul 05 2007
- Sean Kelly <sean f4.ca> Jul 09 2007
- BLS <nanali nospam-wanadoo.fr> Jul 09 2007
- Sean Kelly <sean f4.ca> Jul 09 2007
- BLS <nanali nixspam-wanadoo.fr> Jul 09 2007
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. An example will help ;-) Okay this question is TANGO independent : My Scripting language is passing strings as zero terminated C strings and I have to manipulate them (in my D DLL) before passing these strings to another C stdcall DLL - using --- char* . Any hints ? Many thanks in advance. Bjoern BTW I am talking about the ASPELL Interface
Jul 05 2007
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
Jul 09 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
Jul 09 2007
BLS wrote: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().
The D runtime includes a bunch of stuff, including the GC. When you run a D app, the runtime is initialized before main() starts, and one of the things that happens is gc_init() is called. Assuming you want DLL_PROCESS_ATTACH to be equivalent to 'starting' your DLL, then just replace gc_init() with rt_init(). rt_init() will call gc_init() as a part of its processing.I am sorry about beeing so uninformed:ignorant but I never really understand the GC/Runtime Tango/Phobos problem.
No problem. It's kind of tricky if you haven't spent time with that portion of the code. That's one reason I decided to talk about the runtime at the D conference. Sean
Jul 09 2007
Sean Kelly Wrote:.... That's one reason I decided to talk about the runtime at the D conference.
Take care about the voice recording; One of the often underestimated things. What remains ? Saying Thank You...Picking on your nerves again at DSource regarding the DLL stuff. <friendly grin> Bjoern Bjoern
Jul 09 2007








BLS <nanali nixspam-wanadoo.fr>