lots of C++ codegen improvements

This commit is contained in:
Araq 2015-02-06 21:26:40 +01:00
commit e84834db79
10 changed files with 71 additions and 119 deletions

View file

@ -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))

View file

@ -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)