diff options
author | Araq <rumpf_a@web.de> | 2015-02-06 21:26:40 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2015-02-07 10:48:07 +0100 |
commit | e84834db79854c6ccc89263ec20d3749b8a87a05 (patch) | |
tree | 4232d1e7638c232eded8c6a1f3d82120f272d586 /lib | |
parent | d020ad097c7f1e8155c6b6e7bafbf7731caaafe8 (diff) | |
download | Nim-e84834db79854c6ccc89263ec20d3749b8a87a05.tar.gz |
lots of C++ codegen improvements
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/os.nim | 8 | ||||
-rw-r--r-- | lib/system/dyncalls.nim | 6 | ||||
-rw-r--r-- | lib/system/sysio.nim | 16 |
3 files changed, 21 insertions, 9 deletions
diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 147614d3d..f01343673 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -1074,8 +1074,12 @@ when defined(windows): # because we support Windows GUI applications, things get really # messy here... when useWinUnicode: - proc strEnd(cstr: WideCString, c = 0'i32): WideCString {. - importc: "wcschr", header: "<string.h>".} + when defined(cpp): + proc strEnd(cstr: WideCString, c = 0'i32): WideCString {. + importcpp: "(NI16*)wcschr((const wchar_t *)#, #)", header: "<string.h>".} + else: + proc strEnd(cstr: WideCString, c = 0'i32): WideCString {. + importc: "wcschr", header: "<string.h>".} else: proc strEnd(cstr: cstring, c = 0'i32): cstring {. importc: "strchr", header: "<string.h>".} diff --git a/lib/system/dyncalls.nim b/lib/system/dyncalls.nim index aab2a7b61..539e37aaf 100644 --- a/lib/system/dyncalls.nim +++ b/lib/system/dyncalls.nim @@ -84,16 +84,18 @@ elif defined(windows) or defined(dos): type THINSTANCE {.importc: "HINSTANCE".} = object x: pointer + proc getProcAddress(lib: THINSTANCE, name: cstring): TProcAddr {. + importcpp: "(void*)GetProcAddress(@)", header: "<windows.h>", stdcall.} else: type THINSTANCE {.importc: "HINSTANCE".} = pointer + proc getProcAddress(lib: THINSTANCE, name: cstring): TProcAddr {. + importc: "GetProcAddress", header: "<windows.h>", stdcall.} proc freeLibrary(lib: THINSTANCE) {. importc: "FreeLibrary", header: "<windows.h>", stdcall.} proc winLoadLibrary(path: cstring): THINSTANCE {. importc: "LoadLibraryA", header: "<windows.h>", stdcall.} - proc getProcAddress(lib: THINSTANCE, name: cstring): TProcAddr {. - importc: "GetProcAddress", header: "<windows.h>", stdcall.} proc nimUnloadLibrary(lib: TLibHandle) = freeLibrary(cast[THINSTANCE](lib)) diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim index 7908fbe4d..2e254c87b 100644 --- a/lib/system/sysio.nim +++ b/lib/system/sysio.nim @@ -183,11 +183,17 @@ proc rawEchoNL() {.inline, compilerproc.} = write(stdout, "\n") when (defined(windows) and not defined(useWinAnsi)) or defined(nimdoc): include "system/widestrs" -when defined(windows) and not defined(useWinAnsi): - proc wfopen(filename, mode: WideCString): pointer {. - importc: "_wfopen", nodecl.} - proc wfreopen(filename, mode: WideCString, stream: File): File {. - importc: "_wfreopen", nodecl.} +when defined(windows) and not defined(useWinAnsi): + when defined(cpp): + proc wfopen(filename, mode: WideCString): pointer {. + importcpp: "_wfopen((const wchar_t*)#, (const wchar_t*)#)", nodecl.} + proc wfreopen(filename, mode: WideCString, stream: File): File {. + importc: "_wfreopen((const wchar_t*)#, (const wchar_t*)#)", nodecl.} + else: + proc wfopen(filename, mode: WideCString): pointer {. + importc: "_wfopen", nodecl.} + proc wfreopen(filename, mode: WideCString, stream: File): File {. + importc: "_wfreopen", nodecl.} proc fopen(filename, mode: cstring): pointer = var f = newWideCString(filename) |