Mercurial > projects > qtd
comparison d2/qtd/Core.d @ 384:d2f48c4cb3e3
Same behavior of shared libs on linux and windows. Minor build script fixes.
author | Max Samukha <maxter@spambox.com> |
---|---|
date | Fri, 16 Jul 2010 20:04:29 +0300 |
parents | a032df77b6ab |
children | 7dddafad5a20 |
comparison
equal
deleted
inserted
replaced
383:bd7f485e3573 | 384:d2f48c4cb3e3 |
---|---|
33 template Type(T) | 33 template Type(T) |
34 { | 34 { |
35 alias T Type; | 35 alias T Type; |
36 } | 36 } |
37 | 37 |
38 enum qtdExtern = "extern (C)"; | |
39 | |
40 extern(C) alias void function() VoidFunc; | 38 extern(C) alias void function() VoidFunc; |
41 extern(C) void qtdInitCore(); | 39 extern(C) void qtdInitCore(); |
42 | 40 |
43 static this() | 41 static this() |
44 { | 42 { |
51 registered with the DLL at program startup. | 49 registered with the DLL at program startup. |
52 */ | 50 */ |
53 string qtdExport(string retType, string name, string args, string funcBody) | 51 string qtdExport(string retType, string name, string args, string funcBody) |
54 { | 52 { |
55 string ret; | 53 string ret; |
56 version (cpp_shared) // TODO: cpp_shared implies Windows, which is not correct | 54 enum ext = "extern (C)"; |
55 version (QtdCppShared) | |
57 { | 56 { |
57 version(Windows) | |
58 enum exp = "export"; | |
59 else | |
60 enum exp = ""; | |
61 | |
58 // TODO: hackery to workaround a dmd/optlink bug corrupting symbol names | 62 // TODO: hackery to workaround a dmd/optlink bug corrupting symbol names |
59 // when a direct function pointer export is used | 63 // when a direct function pointer export is used |
60 ret ~= format_ctfe( | 64 ret ~= format_ctfe( |
61 " ${4} ${0} qtd_export_${1}(${2}) { ${3} }\n" | 65 " ${4} ${0} qtd_export_${1}(${2}) { ${3} }\n" |
62 " ${4} export void qtd_set_${1}(VoidFunc func);\n" | 66 " ${4} ${5} void qtd_set_${1}(VoidFunc func);\n" |
63 " static this() { qtd_set_${1}(cast(VoidFunc)&qtd_export_${1}); }\n", | 67 " static this() { qtd_set_${1}(cast(VoidFunc)&qtd_export_${1}); }\n", |
64 retType, name, args, funcBody, qtdExtern); | 68 retType, name, args, funcBody, ext, exp); |
65 } | 69 } |
66 else | 70 else |
67 { | 71 { |
68 ret = format_ctfe( | 72 ret = format_ctfe( |
69 "${4} ${0} qtd_${1}(${2}) { ${3} }\n", | 73 "${4} ${0} qtd_${1}(${2}) { ${3} }\n", |
70 retType, name, args, funcBody, qtdExtern); | 74 retType, name, args, funcBody, ext); |
71 } | 75 } |
72 | 76 |
73 return ret; | 77 return ret; |
74 } | 78 } |