|
Revision 69, 0.9 kB
(checked in by KirkMcDonald, 2 years ago)
|
Inroads on Tango support. (Not there yet, though.)
|
| Line | |
|---|
| 1 |
/* This code is currently just a copy-n-paste from the Digital Mars DLL example |
|---|
| 2 |
* code at http://www.digitalmars.com/d/dll.html */ |
|---|
| 3 |
|
|---|
| 4 |
version (Pyd_with_Tango) { |
|---|
| 5 |
import tango.sys.windows.minwin; |
|---|
| 6 |
} else { |
|---|
| 7 |
import std.c.windows.windows; |
|---|
| 8 |
} |
|---|
| 9 |
|
|---|
| 10 |
HINSTANCE g_hInst; |
|---|
| 11 |
|
|---|
| 12 |
extern (C) |
|---|
| 13 |
{ |
|---|
| 14 |
void gc_init(); |
|---|
| 15 |
void gc_term(); |
|---|
| 16 |
void _minit(); |
|---|
| 17 |
void _moduleCtor(); |
|---|
| 18 |
void _moduleUnitTests(); |
|---|
| 19 |
} |
|---|
| 20 |
|
|---|
| 21 |
extern (Windows) |
|---|
| 22 |
BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved) |
|---|
| 23 |
{ |
|---|
| 24 |
switch (ulReason) |
|---|
| 25 |
{ |
|---|
| 26 |
case DLL_PROCESS_ATTACH: |
|---|
| 27 |
gc_init(); // initialize GC |
|---|
| 28 |
_minit(); // initialize module list |
|---|
| 29 |
_moduleCtor(); // run module constructors |
|---|
| 30 |
_moduleUnitTests(); // run module unit tests |
|---|
| 31 |
|
|---|
| 32 |
break; |
|---|
| 33 |
|
|---|
| 34 |
case DLL_PROCESS_DETACH: |
|---|
| 35 |
gc_term(); // shut down GC |
|---|
| 36 |
break; |
|---|
| 37 |
|
|---|
| 38 |
case DLL_THREAD_ATTACH: |
|---|
| 39 |
case DLL_THREAD_DETACH: |
|---|
| 40 |
// Multiple threads not supported yet |
|---|
| 41 |
return false; |
|---|
| 42 |
} |
|---|
| 43 |
g_hInst=hInstance; |
|---|
| 44 |
return true; |
|---|
| 45 |
} |
|---|