Merge /home/cb/pkg/nim/Nim into devel
This commit is contained in:
commit
8e685585a6
20 changed files with 152 additions and 241 deletions
|
|
@ -186,7 +186,7 @@ proc newRollingFileLogger*(filename = defaultFilename(),
|
|||
## a new log file will be started and the old will be renamed.
|
||||
new(result)
|
||||
result.levelThreshold = levelThreshold
|
||||
result.fmtStr = defaultFmtStr
|
||||
result.fmtStr = fmtStr
|
||||
result.maxLines = maxLines
|
||||
result.f = open(filename, mode)
|
||||
result.curLine = 0
|
||||
|
|
|
|||
|
|
@ -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>".}
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ proc `[]`*(t: StringTableRef, key: string): string {.rtl, extern: "nstGet".} =
|
|||
proc mget*(t: StringTableRef, key: string): var string {.
|
||||
rtl, extern: "nstTake".} =
|
||||
## retrieves the location at ``t[key]``. If `key` is not in `t`, the
|
||||
## ``EInvalidKey`` exception is raised.
|
||||
## ``KeyError`` exception is raised.
|
||||
var index = rawGet(t, key)
|
||||
if index >= 0: result = t.data[index].val
|
||||
else: raise newException(KeyError, "key does not exist: " & key)
|
||||
|
|
@ -158,7 +158,7 @@ proc getValue(t: StringTableRef, flags: set[FormatFlag], key: string): string =
|
|||
else: result = ""
|
||||
if result.len == 0:
|
||||
if useKey in flags: result = '$' & key
|
||||
elif not (useEmpty in flags): raiseFormatException(key)
|
||||
elif useEmpty notin flags: raiseFormatException(key)
|
||||
|
||||
proc newStringTable*(mode: StringTableMode): StringTableRef {.
|
||||
rtl, extern: "nst$1".} =
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue