| 1 |
/+ |
|---|
| 2 |
Copyright (c) 2005-2007 Eric Anderton |
|---|
| 3 |
|
|---|
| 4 |
Permission is hereby granted, free of charge, to any person |
|---|
| 5 |
obtaining a copy of this software and associated documentation |
|---|
| 6 |
files (the "Software"), to deal in the Software without |
|---|
| 7 |
restriction, including without limitation the rights to use, |
|---|
| 8 |
copy, modify, merge, publish, distribute, sublicense, and/or |
|---|
| 9 |
sell copies of the Software, and to permit persons to whom the |
|---|
| 10 |
Software is furnished to do so, subject to the following |
|---|
| 11 |
conditions: |
|---|
| 12 |
|
|---|
| 13 |
The above copyright notice and this permission notice shall be |
|---|
| 14 |
included in all copies or substantial portions of the Software. |
|---|
| 15 |
|
|---|
| 16 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|---|
| 17 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|---|
| 18 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|---|
| 19 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|---|
| 20 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|---|
| 21 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|---|
| 22 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|---|
| 23 |
OTHER DEALINGS IN THE SOFTWARE. |
|---|
| 24 |
+/ |
|---|
| 25 |
module test.linktest0; |
|---|
| 26 |
import ddl.Linker; |
|---|
| 27 |
import ddl.all; |
|---|
| 28 |
|
|---|
| 29 |
import test.testconfig; |
|---|
| 30 |
|
|---|
| 31 |
import tango.io.Stdout; |
|---|
| 32 |
|
|---|
| 33 |
/** |
|---|
| 34 |
Covers the following scenarios: |
|---|
| 35 |
- static module initialization |
|---|
| 36 |
*/ |
|---|
| 37 |
|
|---|
| 38 |
private import test.testclassinterface; |
|---|
| 39 |
|
|---|
| 40 |
private import std.moduleinit; |
|---|
| 41 |
|
|---|
| 42 |
void main(){ |
|---|
| 43 |
Stdout.println("Starting."); |
|---|
| 44 |
|
|---|
| 45 |
Stdout.println("%d modules: ",_moduleinfo_array.length); |
|---|
| 46 |
for(uint i=0; i<_moduleinfo_array.length; i++){ |
|---|
| 47 |
ModuleInfo* mi = &(_moduleinfo_array[i]); |
|---|
| 48 |
Stdout.println("mi: %s [%0.8X]",mi.name,*cast(void**)mi); |
|---|
| 49 |
} |
|---|
| 50 |
|
|---|
| 51 |
auto linker = new Linker(new DefaultRegistry()); |
|---|
| 52 |
linker.loadAndRegister("test\\linktest0.ddl"); |
|---|
| 53 |
linker.loadAndRegister(dmPath ~ "lib\\snn.lib"); |
|---|
| 54 |
linker.loadAndRegister(dmdPath ~ "lib\\phobos.lib"); |
|---|
| 55 |
linker.loadAndRegister(dmPath ~ "lib\\kernel32.lib"); |
|---|
| 56 |
linker.loadAndRegister(dmPath ~ "lib\\user32.lib"); |
|---|
| 57 |
|
|---|
| 58 |
Stdout.println("Loading test module"); |
|---|
| 59 |
auto testLibrary = linker.loadAndLink("test\\testmodule.obj"); |
|---|
| 60 |
assert(testLibrary != null,"testmodule failed to load."); |
|---|
| 61 |
|
|---|
| 62 |
auto result = cast(uint)testLibrary.getSymbol("_D4test10testmodule10intializedk").address; |
|---|
| 63 |
assert(result,"Testmodule static ctor was never run."); |
|---|
| 64 |
Stdout.println("Module Init Test Passed."); |
|---|
| 65 |
Stdout.println("Done."); |
|---|
| 66 |
} |
|---|