diff options
231 files changed, 7909 insertions, 6733 deletions
diff --git a/.gitignore b/.gitignore index d804fb8f5..1971a23cb 100644 --- a/.gitignore +++ b/.gitignore @@ -41,4 +41,4 @@ xcuserdata/ /testresults.html /testresults.json testament.db -/csources/ +/csources diff --git a/build.sh b/bootstrap.sh index 139c28359..ade74a9aa 100644..100755 --- a/build.sh +++ b/bootstrap.sh @@ -2,8 +2,8 @@ set -e set -x -if [ ! -d "csources" ]; then - git clone --depth 1 https://github.com/nim-lang/csources.git +if [ ! -e csources/.git ]; then + git clone --depth 1 git://github.com/nim-lang/csources.git csources fi cd "csources" diff --git a/compiler.nimble b/compiler.nimble index 52eb4083b..9d39af502 100644 --- a/compiler.nimble +++ b/compiler.nimble @@ -1,6 +1,6 @@ [Package] name = "compiler" -version = "0.10.3" +version = "0.11.3" author = "Andreas Rumpf" description = "Compiler package providing the compiler sources as a library." license = "MIT" @@ -8,4 +8,4 @@ license = "MIT" InstallDirs = "doc, compiler" [Deps] -Requires: "nim >= 0.10.3" +Requires: "nim >= 0.11.3" diff --git a/compiler/ast.nim b/compiler/ast.nim index 3798410e8..c141352cb 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -423,6 +423,7 @@ type # but unfortunately it has measurable impact for compilation # efficiency nfTransf, # node has been transformed + nfNoRewrite # node should not be transformed anymore nfSem # node has been checked for semantics nfLL # node has gone through lambda lifting nfDotField # the call can use a dot operator @@ -842,7 +843,7 @@ type data*: TIdNodePairSeq TNodePair* = object - h*: THash # because it is expensive to compute! + h*: Hash # because it is expensive to compute! key*: PNode val*: int @@ -1198,23 +1199,11 @@ proc newSons*(father: PType, length: int) = else: setLen(father.sons, length) -proc sonsLen*(n: PType): int = - if isNil(n.sons): result = 0 - else: result = len(n.sons) - -proc len*(n: PType): int = - if isNil(n.sons): result = 0 - else: result = len(n.sons) - -proc sonsLen*(n: PNode): int = - if isNil(n.sons): result = 0 - else: result = len(n.sons) - -proc lastSon*(n: PNode): PNode = - result = n.sons[sonsLen(n) - 1] - -proc lastSon*(n: PType): PType = - result = n.sons[sonsLen(n) - 1] +proc sonsLen*(n: PType): int = n.sons.len +proc len*(n: PType): int = n.sons.len +proc sonsLen*(n: PNode): int = n.sons.len +proc lastSon*(n: PNode): PNode = n.sons[^1] +proc lastSon*(n: PType): PType = n.sons[^1] proc assignType*(dest, src: PType) = dest.kind = src.kind @@ -1357,7 +1346,7 @@ proc propagateToOwner*(owner, elem: PType) = owner.flags.incl tfHasAsgn if owner.kind notin {tyProc, tyGenericInst, tyGenericBody, - tyGenericInvocation}: + tyGenericInvocation, tyPtr}: let elemB = elem.skipTypes({tyGenericInst}) if elemB.isGCedMem or tfHasGCedMem in elemB.flags: # for simplicity, we propagate this flag even to generics. We then diff --git a/compiler/astalgo.nim b/compiler/astalgo.nim index 1707718d7..5980edb27 100644 --- a/compiler/astalgo.nim +++ b/compiler/astalgo.nim @@ -14,7 +14,7 @@ import ast, hashes, intsets, strutils, options, msgs, ropes, idents, rodutils -proc hashNode*(p: RootRef): THash +proc hashNode*(p: RootRef): Hash proc treeToYaml*(n: PNode, indent: int = 0, maxRecDepth: int = - 1): Rope # Convert a tree into its YAML representation; this is used by the # YAML code generator and it is invaluable for debugging purposes. @@ -49,7 +49,7 @@ proc strTableGet*(t: TStrTable, name: PIdent): PSym type TTabIter*{.final.} = object # consider all fields here private - h*: THash # current hash + h*: Hash # current hash proc initTabIter*(ti: var TTabIter, tab: TStrTable): PSym proc nextIter*(ti: var TTabIter, tab: TStrTable): PSym @@ -65,7 +65,7 @@ proc nextIter*(ti: var TTabIter, tab: TStrTable): PSym type TIdentIter*{.final.} = object # iterator over all syms with same identifier - h*: THash # current hash + h*: Hash # current hash name*: PIdent @@ -94,7 +94,7 @@ proc getSymFromList*(list: PNode, ident: PIdent, start: int = 0): PSym proc lookupInRecord*(n: PNode, field: PIdent): PSym proc getModule*(s: PSym): PSym proc mustRehash*(length, counter: int): bool -proc nextTry*(h, maxHash: THash): THash {.inline.} +proc nextTry*(h, maxHash: Hash): Hash {.inline.} # ------------- table[int, int] --------------------------------------------- const @@ -196,7 +196,7 @@ proc getSymFromList(list: PNode, ident: PIdent, start: int = 0): PSym = else: internalError(list.info, "getSymFromList") result = nil -proc hashNode(p: RootRef): THash = +proc hashNode(p: RootRef): Hash = result = hash(cast[pointer](p)) proc mustRehash(length, counter: int): bool = @@ -466,7 +466,7 @@ proc debug(n: PNode) = const EmptySeq = @[] -proc nextTry(h, maxHash: THash): THash = +proc nextTry(h, maxHash: Hash): Hash = result = ((5 * h) + 1) and maxHash # For any initial h in range(maxHash), repeating that maxHash times # generates each int in range(maxHash) exactly once (see any text on @@ -474,7 +474,7 @@ proc nextTry(h, maxHash: THash): THash = proc objectSetContains(t: TObjectSet, obj: RootRef): bool = # returns true whether n is in t - var h: THash = hashNode(obj) and high(t.data) # start with real hash value + var h: Hash = hashNode(obj) and high(t.data) # start with real hash value while t.data[h] != nil: if t.data[h] == obj: return true @@ -482,7 +482,7 @@ proc objectSetContains(t: TObjectSet, obj: RootRef): bool = result = false proc objectSetRawInsert(data: var TObjectSeq, obj: RootRef) = - var h: THash = hashNode(obj) and high(data) + var h: Hash = hashNode(obj) and high(data) while data[h] != nil: assert(data[h] != obj) h = nextTry(h, high(data)) @@ -503,7 +503,7 @@ proc objectSetIncl(t: var TObjectSet, obj: RootRef) = proc objectSetContainsOrIncl(t: var TObjectSet, obj: RootRef): bool = # returns true if obj is already in the string table: - var h: THash = hashNode(obj) and high(t.data) + var h: Hash = hashNode(obj) and high(t.data) while true: var it = t.data[h] if it == nil: break @@ -520,7 +520,7 @@ proc objectSetContainsOrIncl(t: var TObjectSet, obj: RootRef): bool = result = false proc tableRawGet(t: TTable, key: RootRef): int = - var h: THash = hashNode(key) and high(t.data) # start with real hash value + var h: Hash = hashNode(key) and high(t.data) # start with real hash value while t.data[h].key != nil: if t.data[h].key == key: return h @@ -529,7 +529,7 @@ proc tableRawGet(t: TTable, key: RootRef): int = proc tableSearch(t: TTable, key, closure: RootRef, comparator: TCmpProc): RootRef = - var h: THash = hashNode(key) and high(t.data) # start with real hash value + var h: Hash = hashNode(key) and high(t.data) # start with real hash value while t.data[h].key != nil: if t.data[h].key == key: if comparator(t.data[h].val, closure): @@ -544,7 +544,7 @@ proc tableGet(t: TTable, key: RootRef): RootRef = else: result = nil proc tableRawInsert(data: var TPairSeq, key, val: RootRef) = - var h: THash = hashNode(key) and high(data) + var h: Hash = hashNode(key) and high(data) while data[h].key != nil: assert(data[h].key != key) h = nextTry(h, high(data)) @@ -569,7 +569,7 @@ proc tablePut(t: var TTable, key, val: RootRef) = inc(t.counter) proc strTableContains(t: TStrTable, n: PSym): bool = - var h: THash = n.name.h and high(t.data) # start with real hash value + var h: Hash = n.name.h and high(t.data) # start with real hash value while t.data[h] != nil: if (t.data[h] == n): return true @@ -577,7 +577,7 @@ proc strTableContains(t: TStrTable, n: PSym): bool = result = false proc strTableRawInsert(data: var TSymSeq, n: PSym) = - var h: THash = n.name.h and high(data) + var h: Hash = n.name.h and high(data) if sfImmediate notin n.flags: # fast path: while data[h] != nil: @@ -606,7 +606,7 @@ proc strTableRawInsert(data: var TSymSeq, n: PSym) = proc symTabReplaceRaw(data: var TSymSeq, prevSym: PSym, newSym: PSym) = assert prevSym.name.h == newSym.name.h - var h: THash = prevSym.name.h and high(data) + var h: Hash = prevSym.name.h and high(data) while data[h] != nil: if data[h] == prevSym: data[h] = newSym @@ -640,7 +640,7 @@ proc strTableIncl*(t: var TStrTable, n: PSym): bool {.discardable.} = # It is essential that `n` is written nevertheless! # This way the newest redefinition is picked by the semantic analyses! assert n.name != nil - var h: THash = n.name.h and high(t.data) + var h: Hash = n.name.h and high(t.data) var replaceSlot = -1 while true: var it = t.data[h] @@ -666,7 +666,7 @@ proc strTableIncl*(t: var TStrTable, n: PSym): bool {.discardable.} = result = false proc strTableGet(t: TStrTable, name: PIdent): PSym = - var h: THash = name.h and high(t.data) + var h: Hash = name.h and high(t.data) while true: result = t.data[h] if result == nil: break @@ -694,7 +694,7 @@ proc nextIdentIter(ti: var TIdentIter, tab: TStrTable): PSym = proc nextIdentExcluding*(ti: var TIdentIter, tab: TStrTable, excluding: IntSet): PSym = - var h: THash = ti.h and high(tab.data) + var h: Hash = ti.h and high(tab.data) var start = h result = tab.data[h] while result != nil: @@ -743,7 +743,7 @@ proc hasEmptySlot(data: TIdPairSeq): bool = result = false proc idTableRawGet(t: TIdTable, key: int): int = - var h: THash + var h: Hash h = key and high(t.data) # start with real hash value while t.data[h].key != nil: if t.data[h].key.id == key: @@ -772,7 +772,7 @@ iterator pairs*(t: TIdTable): tuple[key: int, value: RootRef] = yield (t.data[i].key.id, t.data[i].val) proc idTableRawInsert(data: var TIdPairSeq, key: PIdObj, val: RootRef) = - var h: THash + var h: Hash h = key.id and high(data) while data[h].key != nil: assert(data[h].key.id != key.id) @@ -805,7 +805,7 @@ iterator idTablePairs*(t: TIdTable): tuple[key: PIdObj, val: RootRef] = if not isNil(t.data[i].key): yield (t.data[i].key, t.data[i].val) proc idNodeTableRawGet(t: TIdNodeTable, key: PIdObj): int = - var h: THash + var h: Hash h = key.id and high(t.data) # start with real hash value while t.data[h].key != nil: if t.data[h].key.id == key.id: @@ -824,7 +824,7 @@ proc idNodeTableGetLazy*(t: TIdNodeTable, key: PIdObj): PNode = result = idNodeTableGet(t, key) proc idNodeTableRawInsert(data: var TIdNodePairSeq, key: PIdObj, val: PNode) = - var h: THash + var h: Hash h = key.id and high(data) while data[h].key != nil: assert(data[h].key.id != key.id) @@ -863,7 +863,7 @@ proc initIITable(x: var TIITable) = for i in countup(0, StartSize - 1): x.data[i].key = InvalidKey proc iiTableRawGet(t: TIITable, key: int): int = - var h: THash + var h: Hash h = key and high(t.data) # start with real hash value while t.data[h].key != InvalidKey: if t.data[h].key == key: return h @@ -876,7 +876,7 @@ proc iiTableGet(t: TIITable, key: int): int = else: result = InvalidKey proc iiTableRawInsert(data: var TIIPairSeq, key, val: int) = - var h: THash + var h: Hash h = key and high(data) while data[h].key != InvalidKey: assert(data[h].key != key) diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 93a9dd65d..64902c3fc 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -964,8 +964,11 @@ proc genEcho(p: BProc, n: PNode) = var args: Rope = nil var a: TLoc for i in countup(0, n.len-1): - initLocExpr(p, n.sons[i], a) - addf(args, ", $1? ($1)->data:\"nil\"", [rdLoc(a)]) + if n.sons[i].skipConv.kind == nkNilLit: + add(args, ", \"nil\"") + else: + initLocExpr(p, n.sons[i], a) + addf(args, ", $1? ($1)->data:\"nil\"", [rdLoc(a)]) linefmt(p, cpsStmts, "printf($1$2);$n", makeCString(repeat("%s", n.len) & tnl), args) @@ -2147,7 +2150,7 @@ proc genNamedConstExpr(p: BProc, n: PNode): Rope = proc genConstSimpleList(p: BProc, n: PNode): Rope = var length = sonsLen(n) result = rope("{") - for i in countup(0, length - 2): + for i in countup(ord(n.kind == nkObjConstr), length - 2): addf(result, "$1,$n", [genNamedConstExpr(p, n.sons[i])]) if length > 0: add(result, genNamedConstExpr(p, n.sons[length - 1])) addf(result, "}$n", []) diff --git a/compiler/cgen.nim b/compiler/cgen.nim index da9c6f653..91877833a 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -676,8 +676,11 @@ proc genProcAux(m: BModule, prc: PSym) = closureSetup(p, prc) genStmts(p, prc.getBody) # modifies p.locals, p.init, etc. var generatedProc: Rope + if sfNoReturn in prc.flags: + if hasDeclspec in extccomp.CC[extccomp.cCompiler].props: + header = "__declspec(noreturn) " & header if sfPure in prc.flags: - if hasNakedDeclspec in extccomp.CC[extccomp.cCompiler].props: + if hasDeclspec in extccomp.CC[extccomp.cCompiler].props: header = "__declspec(naked) " & header generatedProc = rfmt(nil, "$N$1 {$n$2$3$4}$N$N", header, p.s(cpsLocals), p.s(cpsInit), p.s(cpsStmts)) @@ -718,10 +721,14 @@ proc genProcPrototype(m: BModule, sym: PSym) = getTypeDesc(m, sym.loc.t), mangleDynLibProc(sym))) elif not containsOrIncl(m.declaredProtos, sym.id): var header = genProcHeader(m, sym) + if sfNoReturn in sym.flags and hasDeclspec in extccomp.CC[cCompiler].props: + header = "__declspec(noreturn) " & header if sym.typ.callConv != ccInline and crossesCppBoundary(m, sym): header = "extern \"C\" " & header - if sfPure in sym.flags and hasNakedAttribute in CC[cCompiler].props: + if sfPure in sym.flags and hasAttribute in CC[cCompiler].props: header.add(" __attribute__((naked))") + if sfNoReturn in sym.flags and hasAttribute in CC[cCompiler].props: + header.add(" __attribute__((noreturn))") add(m.s[cfsProcHeaders], rfmt(nil, "$1;$n", header)) proc genProcNoForward(m: BModule, prc: PSym) = diff --git a/compiler/commands.nim b/compiler/commands.nim index b6ebb6bcb..d30d8326c 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -229,7 +229,8 @@ proc testCompileOption*(switch: string, info: TLineInfo): bool = of "experimental": result = gExperimentalMode else: invalidCmdLineOption(passCmd1, switch, info) -proc processPath(path: string, notRelativeToProj = false): string = +proc processPath(path: string, notRelativeToProj = false, + cfginfo = unknownLineInfo()): string = let p = if notRelativeToProj or os.isAbsolute(path) or '$' in path or path[0] == '.': path @@ -239,6 +240,7 @@ proc processPath(path: string, notRelativeToProj = false): string = "nim", getPrefixDir(), "lib", libpath, "home", removeTrailingDirSep(os.getHomeDir()), + "config", cfginfo.toFullPath().splitFile().dir, "projectname", options.gProjectName, "projectpath", options.gProjectPath]) @@ -281,7 +283,7 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo) = case switch.normalize of "path", "p": expectArg(switch, arg, pass, info) - addPath(processPath(arg), info) + addPath(processPath(arg, cfginfo=info), info) of "nimblepath", "babelpath": # keep the old name for compat if pass in {passCmd2, passPP} and not options.gNoNimblePath: diff --git a/compiler/docgen.nim b/compiler/docgen.nim index f8489d825..4b52b1c92 100644 --- a/compiler/docgen.nim +++ b/compiler/docgen.nim @@ -18,7 +18,7 @@ import type TSections = array[TSymKind, Rope] - TDocumentor = object of rstgen.TRstGenerator + TDocumentor = object of rstgen.RstGenerator modDesc: Rope # module description id: int # for generating IDs toc, section: TSections @@ -29,7 +29,7 @@ type PDoc* = ref TDocumentor ## Alias to type less. proc compilerMsgHandler(filename: string, line, col: int, - msgKind: rst.TMsgKind, arg: string) {.procvar.} = + msgKind: rst.MsgKind, arg: string) {.procvar.} = # translate msg kind: var k: msgs.TMsgKind case msgKind @@ -53,7 +53,7 @@ proc docgenFindFile(s: string): string {.procvar.} = proc parseRst(text, filename: string, line, column: int, hasToc: var bool, - rstOptions: TRstParseOptions): PRstNode = + rstOptions: RstParseOptions): PRstNode = result = rstParse(text, filename, line, column, hasToc, rstOptions, docgenFindFile, compilerMsgHandler) diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim index 26f0318ee..186a3884d 100644 --- a/compiler/extccomp.nim +++ b/compiler/extccomp.nim @@ -26,8 +26,8 @@ type hasAssume, # CC has __assume (Visual C extension) hasGcGuard, # CC supports GC_GUARD to keep stack roots hasGnuAsm, # CC's asm uses the absurd GNU assembler syntax - hasNakedDeclspec, # CC has __declspec(naked) - hasNakedAttribute # CC has __attribute__((naked)) + hasDeclspec, # CC has __declspec(X) + hasAttribute, # CC has __attribute__((X)) TInfoCCProps* = set[TInfoCCProp] TInfoCC* = tuple[ name: string, # the short name of the compiler @@ -85,7 +85,7 @@ compiler gcc: structStmtFmt: "$1 $3 $2 ", # struct|union [packed] $name packedPragma: "__attribute__((__packed__))", props: {hasSwitchRange, hasComputedGoto, hasCpp, hasGcGuard, hasGnuAsm, - hasNakedAttribute}) + hasAttribute}) # LLVM Frontend for GCC/G++ compiler llvmGcc: @@ -127,7 +127,7 @@ compiler vcc: asmStmtFrmt: "__asm{$n$1$n}$n", structStmtFmt: "$3$n$1 $2", packedPragma: "#pragma pack(1)", - props: {hasCpp, hasAssume, hasNakedDeclspec}) + props: {hasCpp, hasAssume, hasDeclspec}) # Intel C/C++ Compiler compiler icl: @@ -668,7 +668,8 @@ proc callCCompiler*(projectfile: string) = it = PStrEntry(it.next) if optGenStaticLib in gGlobalOptions: - linkCmd = CC[c].buildLib % ["libfile", (libNameTmpl() % gProjectName), + let name = splitFile(gProjectName).name + linkCmd = CC[c].buildLib % ["libfile", (libNameTmpl() % name), "objfiles", objfiles] else: var linkerExe = getConfigVar(c, ".linkerexe") diff --git a/compiler/idents.nim b/compiler/idents.nim index 0cca18929..6986800cf 100644 --- a/compiler/idents.nim +++ b/compiler/idents.nim @@ -12,7 +12,7 @@ # id. This module is essential for the compiler's performance. import - hashes, strutils + hashes, strutils, etcpriv type TIdObj* = object of RootObj @@ -23,7 +23,7 @@ type TIdent*{.acyclic.} = object of TIdObj s*: string next*: PIdent # for hash-table chaining - h*: THash # hash value of s + h*: Hash # hash value of s var firstCharIsCS*: bool = true var buckets*: array[0..4096 * 2 - 1, PIdent] @@ -37,6 +37,8 @@ proc cmpIgnoreStyle(a, b: cstring, blen: int): int = while j < blen: while a[i] == '_': inc(i) while b[j] == '_': inc(j) + while isMagicIdentSeparatorRune(a, i): inc(i, magicIdentSeparatorRuneByteWidth) + while isMagicIdentSeparatorRune(b, j): inc(j, magicIdentSeparatorRuneByteWidth) # tolower inlined: var aa = a[i] var bb = b[j] @@ -65,7 +67,7 @@ proc cmpExact(a, b: cstring, blen: int): int = var wordCounter = 1 -proc getIdent*(identifier: cstring, length: int, h: THash): PIdent = +proc getIdent*(identifier: cstring, length: int, h: Hash): PIdent = var idx = h and high(buckets) result = buckets[idx] var last: PIdent = nil @@ -99,7 +101,7 @@ proc getIdent*(identifier: string): PIdent = result = getIdent(cstring(identifier), len(identifier), hashIgnoreStyle(identifier)) -proc getIdent*(identifier: string, h: THash): PIdent = +proc getIdent*(identifier: string, h: Hash): PIdent = result = getIdent(cstring(identifier), len(identifier), h) proc identEq*(id: PIdent, name: string): bool = diff --git a/compiler/installer.ini b/compiler/installer.ini index 4ee50f2ff..821309a34 100644 --- a/compiler/installer.ini +++ b/compiler/installer.ini @@ -47,7 +47,7 @@ Start: "doc/overview.html" [Other] Files: "readme.txt;install.txt;contributors.txt;copying.txt" -Files: "configure;makefile" +Files: "makefile" Files: "*.ini" Files: "koch.nim" @@ -70,6 +70,10 @@ Files: "doc/*.nim" Files: "doc/*.cfg" Files: "compiler/nimfix/*.nim" Files: "compiler/nimfix/*.cfg" +Files: "compiler/nimsuggest/*.nim" +Files: "compiler/nimsuggest/*.cfg" +Files: "compiler/plugins/locals/*.nim" +Files: "compiler/plugins/active.nim" Files: "tools/*.nim" Files: "tools/*.cfg" Files: "tools/*.tmpl" @@ -97,13 +101,8 @@ Files: "lib/pure/concurrency/*.cfg" Files: "lib/impure/*.nim" Files: "lib/wrappers/*.nim" -Files: "lib/wrappers/cairo/*.nim" -Files: "lib/wrappers/gtk/*.nim" -Files: "lib/wrappers/lua/*.nim" -Files: "lib/wrappers/opengl/*.nim" Files: "lib/wrappers/readline/*.nim" Files: "lib/wrappers/sdl/*.nim" -Files: "lib/wrappers/x11/*.nim" Files: "lib/wrappers/zip/*.nim" Files: "lib/wrappers/zip/libzip_all.c" @@ -115,8 +114,6 @@ Files: "lib/packages/docutils/*.nim" [Other] Files: "examples/*.nim" -Files: "examples/gtk/*.nim" -Files: "examples/0mq/*.nim" Files: "examples/c++iface/*.nim" Files: "examples/objciface/*.nim" Files: "examples/cross_calculator/" @@ -206,7 +203,11 @@ Files: "tests/stdlib/*.nim" Files: "tests/system/*.nim" Files: "tests/template/*.nim" Files: "tests/testament/*.nim" -Files: "tests/testdata/*.nim" +Files: "tests/testdata/*.csv" +Files: "tests/testdata/*.html" +Files: "tests/testdata/*.json" +Files: "tests/testdata/*.txt" +Files: "tests/testdata/*.xml" Files: "tests/threads/*.nim" Files: "tests/threads/*.cfg" Files: "tests/trmacros/*.nim" @@ -239,7 +240,7 @@ BinPath: r"bin;dist\mingw\bin;dist" ; Section | dir | zipFile | size hint (in KB) | url | exe start menu entry Download: r"Documentation|doc|docs.zip|13824|http://nim-lang.org/download/docs-${version}.zip|overview.html" Download: r"C Compiler (MingW)|dist|mingw.zip|82944|http://nim-lang.org/download/${mingw}.zip" -Download: r"Aporia IDE|dist|aporia.zip|97997|http://nim-lang.org/download/aporia-0.3.0.zip|aporia\bin\aporia.exe" +Download: r"Aporia IDE|dist|aporia.zip|97997|http://nim-lang.org/download/aporia-0.3.0.zip|aporia-0.3.0\bin\aporia.exe" ; for now only NSIS supports optional downloads [UnixBin] diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index 704713243..2fdf14b76 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -880,7 +880,7 @@ proc genFieldAccess(p: PProc, n: PNode, r: var TCompRes) = if skipTypes(n.sons[0].typ, abstractVarRange).kind == tyTuple: r.res = "$1.Field$2" % [r.res, getFieldPosition(n.sons[1]).rope] else: - if n.sons[1].kind != nkSym: internalError(n.sons[1].info, "genFieldAddr") + if n.sons[1].kind != nkSym: internalError(n.sons[1].info, "genFieldAccess") var f = n.sons[1].sym if f.loc.r == nil: f.loc.r = mangleName(f) r.res = "$1.$2" % [r.res, f.loc.r] @@ -970,7 +970,10 @@ proc genAddr(p: PProc, n: PNode, r: var TCompRes) = of nkCheckedFieldExpr: genCheckedFieldAddr(p, n, r) of nkDotExpr: - genFieldAddr(p, n.sons[0], r) + if mapType(n.typ) == etyBaseIndex: + genFieldAddr(p, n.sons[0], r) + else: + genFieldAccess(p, n.sons[0], r) of nkBracketExpr: var ty = skipTypes(n.sons[0].typ, abstractVarRange) if ty.kind in {tyRef, tyPtr}: ty = skipTypes(ty.lastSon, abstractVarRange) @@ -983,6 +986,15 @@ proc genAddr(p: PProc, n: PNode, r: var TCompRes) = else: internalError(n.sons[0].info, "expr(nkBracketExpr, " & $ty.kind & ')') else: internalError(n.sons[0].info, "genAddr") +proc genProcForSymIfNeeded(p: PProc, s: PSym) = + if not p.g.generatedSyms.containsOrIncl(s.id): + let newp = genProc(p, s) + var owner = p + while owner != nil and owner.prc != s.owner: + owner = owner.up + if owner != nil: add(owner.locals, newp) + else: add(p.g.code, newp) + proc genSym(p: PProc, n: PNode, r: var TCompRes) = var s = n.sym case s.kind @@ -1018,13 +1030,8 @@ proc genSym(p: PProc, n: PNode, r: var TCompRes) = discard elif sfForward in s.flags: p.g.forwarded.add(s) - elif not p.g.generatedSyms.containsOrIncl(s.id): - let newp = genProc(p, s) - var owner = p - while owner != nil and owner.prc != s.owner: - owner = owner.up - if owner != nil: add(owner.locals, newp) - else: add(p.g.code, newp) + else: + genProcForSymIfNeeded(p, s) else: if s.loc.r == nil: internalError(n.info, "symbol has no generated name: " & s.name.s) @@ -1052,11 +1059,13 @@ proc genArg(p: PProc, n: PNode, r: var TCompRes) = proc genArgs(p: PProc, n: PNode, r: var TCompRes) = add(r.res, "(") + var hasArgs = false for i in countup(1, sonsLen(n) - 1): let it = n.sons[i] if it.typ.isCompileTimeOnly: continue - if i > 1: add(r.res, ", ") + if hasArgs: add(r.res, ", ") genArg(p, it, r) + hasArgs = true add(r.res, ")") r.kind = resExpr @@ -1389,6 +1398,9 @@ proc genMagic(p: PProc, n: PNode, r: var TCompRes) = of mCopyStrLast: ternaryExpr(p, n, r, "", "($1.slice($2, ($3)+1).concat(0))") of mNewString: unaryExpr(p, n, r, "mnewString", "mnewString($1)") of mNewStringOfCap: unaryExpr(p, n, r, "mnewString", "mnewString(0)") + of mDotDot: + genProcForSymIfNeeded(p, n.sons[0].sym) + genCall(p, n, r) else: genCall(p, n, r) #else internalError(e.info, 'genMagic: ' + magicToStr[op]); diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim index c68bc352c..69b45c980 100644 --- a/compiler/lambdalifting.nim +++ b/compiler/lambdalifting.nim @@ -946,7 +946,11 @@ proc transformOuterProc(o: POuterContext, n: PNode; it: TIter): PNode = proc liftLambdas*(fn: PSym, body: PNode): PNode = # XXX gCmd == cmdCompileToJS does not suffice! The compiletime stuff needs # the transformation even when compiling to JS ... - if body.kind == nkEmpty or gCmd == cmdCompileToJS or + + # However we can do lifting for the stuff which is *only* compiletime. + let isCompileTime = sfCompileTime in fn.flags or fn.kind == skMacro + + if body.kind == nkEmpty or (gCmd == cmdCompileToJS and not isCompileTime) or fn.skipGenericOwner.kind != skModule: # ignore forward declaration: result = body diff --git a/compiler/lexer.nim b/compiler/lexer.nim index 8080e0e8c..6b38ee062 100644 --- a/compiler/lexer.nim +++ b/compiler/lexer.nim @@ -17,7 +17,7 @@ import hashes, options, msgs, strutils, platform, idents, nimlexbase, llstream, - wordrecg + wordrecg, etcpriv const MaxLineLength* = 80 # lines longer than this lead to a warning @@ -140,10 +140,12 @@ proc isKeyword*(kind: TTokType): bool = proc isNimIdentifier*(s: string): bool = if s[0] in SymStartChars: var i = 1 - while i < s.len: + var sLen = s.len + while i < sLen: if s[i] == '_': inc(i) - if s[i] notin SymChars: return + elif isMagicIdentSeparatorRune(cstring s, i): + inc(i, magicIdentSeparatorRuneByteWidth) if s[i] notin SymChars: return inc(i) result = true @@ -229,23 +231,6 @@ proc lexMessagePos(L: var TLexer, msg: TMsgKind, pos: int, arg = "") = var info = newLineInfo(L.fileIdx, L.lineNumber, pos - L.lineStart) L.dispMessage(info, msg, arg) -proc matchUnderscoreChars(L: var TLexer, tok: var TToken, chars: set[char]) = - var pos = L.bufpos # use registers for pos, buf - var buf = L.buf - while true: - if buf[pos] in chars: - add(tok.literal, buf[pos]) - inc(pos) - else: - break - if buf[pos] == '_': - if buf[pos+1] notin chars: - lexMessage(L, errInvalidToken, "_") - break - add(tok.literal, '_') - inc(pos) - L.bufpos = pos - proc matchTwoChars(L: TLexer, first: char, second: set[char]): bool = result = (L.buf[L.bufpos] == first) and (L.buf[L.bufpos + 1] in second) @@ -268,136 +253,195 @@ proc unsafeParseUInt(s: string, b: var BiggestInt, start = 0): int = result = i - start {.pop.} # overflowChecks + +template eatChar(L: var TLexer, t: var TToken, replacementChar: char) = + add(t.literal, replacementChar) + inc(L.bufpos) + +template eatChar(L: var TLexer, t: var TToken) = + add(t.literal, L.buf[L.bufpos]) + inc(L.bufpos) + proc getNumber(L: var TLexer): TToken = var - pos, endpos: int + startpos, endpos: int xi: BiggestInt - # get the base: + const literalishChars = { 'A'..'F', 'a'..'f', '0'..'9', 'X', 'x', 'o', 'c', + 'C', 'b', 'B', '_', '.', '\''} + const literalishCharsNoDot = literalishChars - {'.'} + + proc matchUnderscoreChars(L: var TLexer, tok: var TToken, chars: set[char]) = + var pos = L.bufpos # use registers for pos, buf + var buf = L.buf + while true: + if buf[pos] in chars: + add(tok.literal, buf[pos]) + inc(pos) + else: + break + if buf[pos] == '_': + if buf[pos+1] notin chars: + lexMessage(L, errInvalidToken, "_") + break + add(tok.literal, '_') + inc(pos) + L.bufpos = pos + + proc matchChars(L: var TLexer, tok: var TToken, chars: set[char]) = + var pos = L.bufpos # use registers for pos, buf + var buf = L.buf + while buf[pos] in chars: + add(tok.literal, buf[pos]) + inc(pos) + L.bufpos = pos + + proc lexMessageLitNum(L: var TLexer, msg: TMsgKind, startpos: int) = + # Used to get slightly human friendlier err messages. + # Note: the erroneous 'O' char in the character set is intentional + const literalishChars = {'A'..'F', 'a'..'f', '0'..'9', 'X', 'x', 'o', 'O', + 'c', 'C', 'b', 'B', '_', '.', '\'', 'd', 'i', 'u'} + var msgPos = L.bufpos + var t: TToken + t.literal = "" + L.bufpos = startpos # Use L.bufpos as pos because of matchChars + matchChars(L, t, literalishChars) + # We must verify +/- specifically so that we're not past the literal + if L.buf[L.bufpos] in {'+', '-'} and + L.buf[L.bufpos - 1] in {'e', 'E'}: + add(t.literal, L.buf[L.bufpos]) + inc(L.bufpos) + matchChars(L, t, literalishChars) + if L.buf[L.bufpos] in {'\'', 'f', 'F', 'd', 'D', 'i', 'I', 'u', 'U'}: + inc(L.bufpos) + add(t.literal, L.buf[L.bufpos]) + matchChars(L, t, {'0'..'9'}) + L.bufpos = msgPos + lexMessage(L, msg, t.literal) + result.tokType = tkIntLit # int literal until we know better result.literal = "" - result.base = base10 # BUGFIX - pos = L.bufpos # make sure the literal is correct for error messages: - var eallowed = false - if L.buf[pos] == '0' and L.buf[pos+1] in {'X', 'x'}: - matchUnderscoreChars(L, result, {'A'..'F', 'a'..'f', '0'..'9', 'X', 'x'}) + result.base = base10 + startpos = L.bufpos + var isAFloatLiteral = false + # First stage: find out base, make verifications, build token literal string + if L.buf[L.bufpos] == '0' and + L.buf[L.bufpos + 1] in {'X', 'x', 'o', 'O', 'c', 'C', 'b', 'B'}: + eatChar(L, result, '0') + case L.buf[L.bufpos] + of 'O': + lexMessageLitNum(L, errInvalidNumberOctalCode, startpos) + of 'x', 'X': + eatChar(L, result, 'x') + matchUnderscoreChars(L, result, {'0'..'9', 'a'..'f', 'A'..'F'}) + of 'o', 'c', 'C': + eatChar(L, result, 'c') + matchUnderscoreChars(L, result, {'0'..'7'}) + of 'b', 'B': + eatChar(L, result, 'b') + matchUnderscoreChars(L, result, {'0'..'1'}) + else: + internalError(getLineInfo(L), "getNumber") else: - matchUnderscoreChars(L, result, {'0'..'9', 'b', 'B', 'o', 'c', 'C'}) - eallowed = true - if (L.buf[L.bufpos] == '.') and (L.buf[L.bufpos + 1] in {'0'..'9'}): - add(result.literal, '.') - inc(L.bufpos) - matchUnderscoreChars(L, result, {'0'..'9'}) - eallowed = true - if eallowed and L.buf[L.bufpos] in {'e', 'E'}: - add(result.literal, 'e') - inc(L.bufpos) - if L.buf[L.bufpos] in {'+', '-'}: - add(result.literal, L.buf[L.bufpos]) - inc(L.bufpos) matchUnderscoreChars(L, result, {'0'..'9'}) + if (L.buf[L.bufpos] == '.') and (L.buf[L.bufpos + 1] in {'0'..'9'}): + isAFloatLiteral = true + eatChar(L, result, '.') + matchUnderscoreChars(L, result, {'0'..'9'}) + if L.buf[L.bufpos] in {'e', 'E'}: + isAFloatLiteral = true + eatChar(L, result, 'e') + if L.buf[L.bufpos] in {'+', '-'}: + eatChar(L, result) + matchUnderscoreChars(L, result, {'0'..'9'}) endpos = L.bufpos - if L.buf[endpos] in {'\'', 'f', 'F', 'i', 'I', 'u', 'U'}: - if L.buf[endpos] == '\'': inc(endpos) - L.bufpos = pos # restore position - case L.buf[endpos] + # Second stage, find out if there's a datatype postfix and handle it + var postPos = endpos + if L.buf[postPos] in {'\'', 'f', 'F', 'd', 'D', 'i', 'I', 'u', 'U'}: + if L.buf[postPos] == '\'': + inc(postPos) + case L.buf[postPos] of 'f', 'F': - inc(endpos) - if (L.buf[endpos] == '3') and (L.buf[endpos + 1] == '2'): + inc(postPos) + if (L.buf[postPos] == '3') and (L.buf[postPos + 1] == '2'): result.tokType = tkFloat32Lit - inc(endpos, 2) - elif (L.buf[endpos] == '6') and (L.buf[endpos + 1] == '4'): + inc(postPos, 2) + elif (L.buf[postPos] == '6') and (L.buf[postPos + 1] == '4'): result.tokType = tkFloat64Lit - inc(endpos, 2) - elif (L.buf[endpos] == '1') and - (L.buf[endpos + 1] == '2') and - (L.buf[endpos + 2] == '8'): + inc(postPos, 2) + elif (L.buf[postPos] == '1') and + (L.buf[postPos + 1] == '2') and + (L.buf[postPos + 2] == '8'): result.tokType = tkFloat128Lit - inc(endpos, 3) - else: - lexMessage(L, errInvalidNumber, result.literal & "'f" & L.buf[endpos]) + inc(postPos, 3) + else: # "f" alone defaults to float32 + result.tokType = tkFloat32Lit + of 'd', 'D': # ad hoc convenience shortcut for f64 + inc(postPos) + result.tokType = tkFloat64Lit of 'i', 'I': - inc(endpos) - if (L.buf[endpos] == '6') and (L.buf[endpos + 1] == '4'): + inc(postPos) + if (L.buf[postPos] == '6') and (L.buf[postPos + 1] == '4'): result.tokType = tkInt64Lit - inc(endpos, 2) - elif (L.buf[endpos] == '3') and (L.buf[endpos + 1] == '2'): + inc(postPos, 2) + elif (L.buf[postPos] == '3') and (L.buf[postPos + 1] == '2'): result.tokType = tkInt32Lit - inc(endpos, 2) - elif (L.buf[endpos] == '1') and (L.buf[endpos + 1] == '6'): + inc(postPos, 2) + elif (L.buf[postPos] == '1') and (L.buf[postPos + 1] == '6'): result.tokType = tkInt16Lit - inc(endpos, 2) - elif (L.buf[endpos] == '8'): + inc(postPos, 2) + elif (L.buf[postPos] == '8'): result.tokType = tkInt8Lit - inc(endpos) + inc(postPos) else: - lexMessage(L, errInvalidNumber, result.literal & "'i" & L.buf[endpos]) + lexMessageLitNum(L, errInvalidNumber, startpos) of 'u', 'U': - inc(endpos) - if (L.buf[endpos] == '6') and (L.buf[endpos + 1] == '4'): + inc(postPos) + if (L.buf[postPos] == '6') and (L.buf[postPos + 1] == '4'): result.tokType = tkUInt64Lit - inc(endpos, 2) - elif (L.buf[endpos] == '3') and (L.buf[endpos + 1] == '2'): + inc(postPos, 2) + elif (L.buf[postPos] == '3') and (L.buf[postPos + 1] == '2'): result.tokType = tkUInt32Lit - inc(endpos, 2) - elif (L.buf[endpos] == '1') and (L.buf[endpos + 1] == '6'): + inc(postPos, 2) + elif (L.buf[postPos] == '1') and (L.buf[postPos + 1] == '6'): result.tokType = tkUInt16Lit - inc(endpos, 2) - elif (L.buf[endpos] == '8'): + inc(postPos, 2) + elif (L.buf[postPos] == '8'): result.tokType = tkUInt8Lit - inc(endpos) + inc(postPos) else: result.tokType = tkUIntLit - else: lexMessage(L, errInvalidNumber, result.literal & "'" & L.buf[endpos]) - else: - L.bufpos = pos # restore position + else: + lexMessageLitNum(L, errInvalidNumber, startpos) + # Is there still a literalish char awaiting? Then it's an error! + if L.buf[postPos] in literalishCharsNoDot or + (L.buf[postPos] == '.' and L.buf[postPos + 1] in {'0'..'9'}): + lexMessageLitNum(L, errInvalidNumber, startpos) + # Third stage, extract actual number + L.bufpos = startpos # restore position + var pos: int = startpos try: if (L.buf[pos] == '0') and (L.buf[pos + 1] in {'x', 'X', 'b', 'B', 'o', 'O', 'c', 'C'}): inc(pos, 2) - xi = 0 # it may be a base prefix + xi = 0 # it is a base prefix case L.buf[pos - 1] # now look at the optional type suffix: of 'b', 'B': result.base = base2 - while true: - case L.buf[pos] - of '2'..'9', '.': - lexMessage(L, errInvalidNumber, result.literal) - inc(pos) - of '_': - if L.buf[pos+1] notin {'0'..'1'}: - lexMessage(L, errInvalidToken, "_") - break - inc(pos) - of '0', '1': + while pos < endpos: + if L.buf[pos] != '_': xi = `shl`(xi, 1) or (ord(L.buf[pos]) - ord('0')) - inc(pos) - else: break + inc(pos) of 'o', 'c', 'C': result.base = base8 - while true: - case L.buf[pos] - of '8'..'9', '.': - lexMessage(L, errInvalidNumber, result.literal) - inc(pos) - of '_': - if L.buf[pos+1] notin {'0'..'7'}: - lexMessage(L, errInvalidToken, "_") - break - inc(pos) - of '0'..'7': + while pos < endpos: + if L.buf[pos] != '_': xi = `shl`(xi, 3) or (ord(L.buf[pos]) - ord('0')) - inc(pos) - else: break - of 'O': - lexMessage(L, errInvalidNumber, result.literal) + inc(pos) of 'x', 'X': result.base = base16 - while true: + while pos < endpos: case L.buf[pos] of '_': - if L.buf[pos+1] notin {'0'..'9', 'a'..'f', 'A'..'F'}: - lexMessage(L, errInvalidToken, "_") - break inc(pos) of '0'..'9': xi = `shl`(xi, 4) or (ord(L.buf[pos]) - ord('0')) @@ -408,8 +452,10 @@ proc getNumber(L: var TLexer): TToken = of 'A'..'F': xi = `shl`(xi, 4) or (ord(L.buf[pos]) - ord('A') + 10) inc(pos) - else: break - else: internalError(getLineInfo(L), "getNumber") + else: + break + else: + internalError(getLineInfo(L), "getNumber") case result.tokType of tkIntLit, tkInt64Lit: result.iNumber = xi of tkInt8Lit: result.iNumber = BiggestInt(int8(toU8(int(xi)))) @@ -425,7 +471,7 @@ proc getNumber(L: var TLexer): TToken = # XXX: Test this on big endian machine! of tkFloat64Lit: result.fNumber = (cast[PFloat64](addr(xi)))[] else: internalError(getLineInfo(L), "getNumber") - elif isFloatLiteral(result.literal) or (result.tokType == tkFloat32Lit) or + elif isAFloatLiteral or (result.tokType == tkFloat32Lit) or (result.tokType == tkFloat64Lit): result.fNumber = parseFloat(result.literal) if result.tokType == tkIntLit: result.tokType = tkFloatLit @@ -441,18 +487,18 @@ proc getNumber(L: var TLexer): TToken = if result.tokType == tkIntLit: result.tokType = tkInt64Lit elif result.tokType in {tkInt8Lit, tkInt16Lit, tkInt32Lit}: - lexMessage(L, errNumberOutOfRange, result.literal) + lexMessageLitNum(L, errNumberOutOfRange, startpos) elif result.tokType == tkInt8Lit and (result.iNumber < int8.low or result.iNumber > int8.high): - lexMessage(L, errNumberOutOfRange, result.literal) + lexMessageLitNum(L, errNumberOutOfRange, startpos) elif result.tokType == tkInt16Lit and (result.iNumber < int16.low or result.iNumber > int16.high): - lexMessage(L, errNumberOutOfRange, result.literal) + lexMessageLitNum(L, errNumberOutOfRange, startpos) except ValueError: - lexMessage(L, errInvalidNumber, result.literal) + lexMessageLitNum(L, errInvalidNumber, startpos) except OverflowError, RangeError: - lexMessage(L, errNumberOutOfRange, result.literal) - L.bufpos = endpos + lexMessageLitNum(L, errNumberOutOfRange, startpos) + L.bufpos = postPos proc handleHexChar(L: var TLexer, xi: var int) = case L.buf[L.bufpos] @@ -625,23 +671,34 @@ proc getCharacter(L: var TLexer, tok: var TToken) = inc(L.bufpos) # skip ' proc getSymbol(L: var TLexer, tok: var TToken) = - var h: THash = 0 + var h: Hash = 0 var pos = L.bufpos var buf = L.buf while true: var c = buf[pos] case c of 'a'..'z', '0'..'9', '\x80'..'\xFF': - h = h !& ord(c) + if c == '\226' and + buf[pos+1] == '\128' and + buf[pos+2] == '\147': # It's a 'magic separator' en-dash Unicode + if buf[pos + magicIdentSeparatorRuneByteWidth] notin SymChars: + lexMessage(L, errInvalidToken, "–") + break + inc(pos, magicIdentSeparatorRuneByteWidth) + else: + h = h !& ord(c) + inc(pos) of 'A'..'Z': c = chr(ord(c) + (ord('a') - ord('A'))) # toLower() h = h !& ord(c) + inc(pos) of '_': if buf[pos+1] notin SymChars: lexMessage(L, errInvalidToken, "_") break + inc(pos) + else: break - inc(pos) h = !$h tok.ident = getIdent(addr(L.buf[L.bufpos]), pos - L.bufpos, h) L.bufpos = pos @@ -652,7 +709,7 @@ proc getSymbol(L: var TLexer, tok: var TToken) = tok.tokType = TTokType(tok.ident.id + ord(tkSymbol)) proc endOperator(L: var TLexer, tok: var TToken, pos: int, - hash: THash) {.inline.} = + hash: Hash) {.inline.} = var h = !$hash tok.ident = getIdent(addr(L.buf[L.bufpos]), pos - L.bufpos, h) if (tok.ident.id < oprLow) or (tok.ident.id > oprHigh): tok.tokType = tkOpr @@ -662,7 +719,7 @@ proc endOperator(L: var TLexer, tok: var TToken, pos: int, proc getOperator(L: var TLexer, tok: var TToken) = var pos = L.bufpos var buf = L.buf - var h: THash = 0 + var h: Hash = 0 while true: var c = buf[pos] if c notin OpChars: break diff --git a/compiler/main.nim b/compiler/main.nim index 0c80c19b7..a01b6fe4f 100644 --- a/compiler/main.nim +++ b/compiler/main.nim @@ -63,7 +63,7 @@ proc commandCompileToC = compileProject() cgenWriteModules() if gCmd != cmdRun: - extccomp.callCCompiler(if gProjectName == "-": "stdinfile" else: changeFileExt(gProjectFull, "")) + extccomp.callCCompiler(changeFileExt(gProjectFull, "")) if isServing: # caas will keep track only of the compilation commands diff --git a/compiler/modules.nim b/compiler/modules.nim index a2b739efc..2fa46f356 100644 --- a/compiler/modules.nim +++ b/compiler/modules.nim @@ -10,8 +10,8 @@ ## implements the module handling import - ast, astalgo, magicsys, crc, rodread, msgs, cgendata, sigmatch, options, - idents, os, lexer, idgen, passes, syntaxes + ast, astalgo, magicsys, crc, rodread, msgs, cgendata, sigmatch, options, + idents, os, lexer, idgen, passes, syntaxes, llstream type TNeedRecompile* = enum Maybe, No, Yes, Probing, Recompiled @@ -39,12 +39,12 @@ template crc(x: PSym): expr = proc crcChanged(fileIdx: int32): bool = internalAssert fileIdx >= 0 and fileIdx < gMemCacheData.len - + template updateStatus = gMemCacheData[fileIdx].crcStatus = if result: crcHasChanged else: crcNotChanged # echo "TESTING CRC: ", fileIdx.toFilename, " ", result - + case gMemCacheData[fileIdx].crcStatus: of crcHasChanged: result = true @@ -96,7 +96,7 @@ proc checkDepMem(fileIdx: int32): TNeedRecompile = if optForceFullMake in gGlobalOptions or crcChanged(fileIdx): markDirty - + if gMemCacheData[fileIdx].deps != nil: gMemCacheData[fileIdx].needsRecompile = Probing for dep in gMemCacheData[fileIdx].deps: @@ -104,30 +104,30 @@ proc checkDepMem(fileIdx: int32): TNeedRecompile = if d in {Yes, Recompiled}: # echo fileIdx.toFilename, " depends on ", dep.toFilename, " ", d markDirty - + gMemCacheData[fileIdx].needsRecompile = No return No proc newModule(fileIdx: int32): PSym = # We cannot call ``newSym`` here, because we have to circumvent the ID - # mechanism, which we do in order to assign each module a persistent ID. + # mechanism, which we do in order to assign each module a persistent ID. new(result) result.id = - 1 # for better error checking result.kind = skModule let filename = fileIdx.toFullPath result.name = getIdent(splitFile(filename).name) - if result.name.s != "-" and not isNimIdentifier(result.name.s): + if not isNimIdentifier(result.name.s): rawMessage(errInvalidModuleName, result.name.s) - + result.info = newLineInfo(fileIdx, 1, 1) result.owner = newSym(skPackage, getIdent(getPackageName(filename)), nil, result.info) result.position = fileIdx - + growCache gMemCacheData, fileIdx growCache gCompiledModules, fileIdx gCompiledModules[result.position] = result - + incl(result.flags, sfUsed) initStrTable(result.tab) strTableAdd(result.tab, result) # a module knows itself @@ -143,12 +143,15 @@ proc compileModule*(fileIdx: int32, flags: TSymFlags): PSym = result.flags = result.flags + flags if gCmd in {cmdCompileToC, cmdCompileToCpp, cmdCheck, cmdIdeTools}: rd = handleSymbolFile(result) - if result.id < 0: + if result.id < 0: internalError("handleSymbolFile should have set the module\'s ID") return else: result.id = getID() - processModule(result, nil, rd) + if sfMainModule in flags and gProjectIsStdin: + processModule(result, llStreamOpen(stdin), rd) + else: + processModule(result, nil, rd) if optCaasEnabled in gGlobalOptions: gMemCacheData[fileIdx].compiledAt = gLastCmdTime gMemCacheData[fileIdx].needsRecompile = Recompiled diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 041a181be..81a62371e 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -17,10 +17,9 @@ type errIntLiteralExpected, errInvalidCharacterConstant, errClosingTripleQuoteExpected, errClosingQuoteExpected, errTabulatorsAreNotAllowed, errInvalidToken, errLineTooLong, - errInvalidNumber, errNumberOutOfRange, errNnotAllowedInCharacter, - errClosingBracketExpected, errMissingFinalQuote, errIdentifierExpected, - errNewlineExpected, - errInvalidModuleName, + errInvalidNumber, errInvalidNumberOctalCode, errNumberOutOfRange, + errNnotAllowedInCharacter, errClosingBracketExpected, errMissingFinalQuote, + errIdentifierExpected, errNewlineExpected, errInvalidModuleName, errOperatorExpected, errTokenExpected, errStringAfterIncludeExpected, errRecursiveDependencyX, errOnOrOffExpected, errNoneSpeedOrSizeExpected, errInvalidPragma, errUnknownPragma, errInvalidDirectiveX, @@ -35,7 +34,9 @@ type errNoneSpeedOrSizeExpectedButXFound, errGuiConsoleOrLibExpectedButXFound, errUnknownOS, errUnknownCPU, errGenOutExpectedButXFound, errArgsNeedRunOption, errInvalidMultipleAsgn, errColonOrEqualsExpected, - errExprExpected, errUndeclaredIdentifier, errUseQualifier, errTypeExpected, + errExprExpected, errUndeclaredIdentifier, errUndeclaredField, + errUndeclaredRoutine, errUseQualifier, + errTypeExpected, errSystemNeeds, errExecutionOfProgramFailed, errNotOverloadable, errInvalidArgForX, errStmtHasNoEffect, errXExpectsTypeOrValue, errXExpectsArrayType, errIteratorCannotBeInstantiated, errExprXAmbiguous, @@ -143,6 +144,7 @@ const errInvalidToken: "invalid token: $1", errLineTooLong: "line too long", errInvalidNumber: "$1 is not a valid number", + errInvalidNumberOctalCode: "$1 is not a valid number; did you mean octal? Then use one of '0o', '0c' or '0C'.", errNumberOutOfRange: "number $1 out of valid range", errNnotAllowedInCharacter: "\\n not allowed in character literal", errClosingBracketExpected: "closing ']' expected, but end of file reached", @@ -190,6 +192,8 @@ const errColonOrEqualsExpected: "\':\' or \'=\' expected, but found \'$1\'", errExprExpected: "expression expected, but found \'$1\'", errUndeclaredIdentifier: "undeclared identifier: \'$1\'", + errUndeclaredField: "undeclared field: \'$1\'", + errUndeclaredRoutine: "attempting to call undeclared routine: \'$1\'", errUseQualifier: "ambiguous identifier: \'$1\' -- use a qualifier", errTypeExpected: "type expected", errSystemNeeds: "system module needs \'$1\'", diff --git a/compiler/nim.nim b/compiler/nim.nim index b8ba2c6da..89db22e8f 100644 --- a/compiler/nim.nim +++ b/compiler/nim.nim @@ -38,7 +38,12 @@ proc handleCmdLine() = else: # Process command line arguments: processCmdLine(passCmd1, "") - if gProjectName != "": + if gProjectName == "-": + gProjectName = "stdinfile" + gProjectFull = "stdinfile" + gProjectPath = getCurrentDir() + gProjectIsStdin = true + elif gProjectName != "": try: gProjectFull = canonicalizePath(gProjectName) except OSError: @@ -61,8 +66,6 @@ proc handleCmdLine() = if gCmd == cmdRun: tccgen.run(commands.arguments) if optRun in gGlobalOptions: - if gProjectName == "-": - gProjectFull = "stdinfile" if gCmd == cmdCompileToJS: var ex: string if options.outFile.len > 0: diff --git a/compiler/nimfix/nimfix.nim b/compiler/nimfix/nimfix.nim index 8caa23ee3..3641aec36 100644 --- a/compiler/nimfix/nimfix.nim +++ b/compiler/nimfix/nimfix.nim @@ -10,8 +10,10 @@ ## Nimfix is a tool that helps to convert old-style Nimrod code to Nim code. import strutils, os, parseopt -import options, commands, modules, sem, passes, passaux, pretty, msgs, nimconf, - extccomp, condsyms, lists +import compiler/options, compiler/commands, compiler/modules, compiler/sem, + compiler/passes, compiler/passaux, compiler/nimfix/pretty, + compiler/msgs, compiler/nimconf, + compiler/extccomp, compiler/condsyms, compiler/lists const Usage = """ Nimfix - Tool to patch Nim code @@ -24,7 +26,7 @@ Options: --wholeProject overwrite every processed file. --checkExtern:on|off style check also extern names --styleCheck:on|off|auto performs style checking for identifiers - and suggests an alternative spelling; + and suggests an alternative spelling; 'auto' corrects the spelling. --bestEffort try to fix the code even when there are errors. @@ -48,11 +50,11 @@ proc processCmdLine*(pass: TCmdLinePass, cmd: string) = var p = parseopt.initOptParser(cmd) var argsCount = 0 gOnlyMainfile = true - while true: + while true: parseopt.next(p) case p.kind - of cmdEnd: break - of cmdLongoption, cmdShortOption: + of cmdEnd: break + of cmdLongoption, cmdShortOption: case p.key.normalize of "overwritefiles": case p.val.normalize diff --git a/compiler/nimfix/pretty.nim b/compiler/nimfix/pretty.nim index d2d5b5e83..1123afb9e 100644 --- a/compiler/nimfix/pretty.nim +++ b/compiler/nimfix/pretty.nim @@ -10,9 +10,11 @@ ## This module implements the code "prettifier". This is part of the toolchain ## to convert Nim code into a consistent style. -import - strutils, os, options, ast, astalgo, msgs, ropes, idents, - intsets, strtabs, semdata, prettybase +import + strutils, os, intsets, strtabs + +import compiler/options, compiler/ast, compiler/astalgo, compiler/msgs, + compiler/semdata, compiler/nimfix/prettybase, compiler/ropes, compiler/idents type StyleCheck* {.pure.} = enum None, Warn, Auto @@ -92,7 +94,7 @@ proc beautifyName(s: string, k: TSymKind): string = proc replaceInFile(info: TLineInfo; newName: string) = loadFile(info) - + let line = gSourceFiles[info.fileIndex].lines[info.line-1] var first = min(info.col.int, line.len) if first < 0: return @@ -100,18 +102,18 @@ proc replaceInFile(info: TLineInfo; newName: string) = while first > 0 and line[first-1] in prettybase.Letters: dec first if first < 0: return if line[first] == '`': inc first - + let last = first+identLen(line, first)-1 if differ(line, first, last, newName): - # last-first+1 != newName.len or - var x = line.substr(0, first-1) & newName & line.substr(last+1) + # last-first+1 != newName.len or + var x = line.substr(0, first-1) & newName & line.substr(last+1) system.shallowCopy(gSourceFiles[info.fileIndex].lines[info.line-1], x) gSourceFiles[info.fileIndex].dirty = true proc checkStyle(info: TLineInfo, s: string, k: TSymKind; sym: PSym) = let beau = beautifyName(s, k) if s != beau: - if gStyleCheck == StyleCheck.Auto: + if gStyleCheck == StyleCheck.Auto: sym.name = getIdent(beau) replaceInFile(info, beau) else: @@ -137,7 +139,7 @@ proc styleCheckUseImpl(info: TLineInfo; s: PSym) = if info.fileIndex < 0: return # we simply convert it to what it looks like in the definition # for consistency - + # operators stay as they are: if s.kind in {skResult, skTemp} or s.name.s[0] notin prettybase.Letters: return diff --git a/compiler/nimfix/prettybase.nim b/compiler/nimfix/prettybase.nim index 5130d1863..0f17cbcb1 100644 --- a/compiler/nimfix/prettybase.nim +++ b/compiler/nimfix/prettybase.nim @@ -7,7 +7,8 @@ # distribution, for details about the copyright. # -import ast, msgs, strutils, idents, lexbase, streams +import strutils, lexbase, streams +import compiler/ast, compiler/msgs, compiler/idents from os import splitFile type @@ -39,7 +40,7 @@ proc loadFile*(info: TLineInfo) = var pos = lex.bufpos while true: case lex.buf[pos] - of '\c': + of '\c': gSourceFiles[i].newline = "\c\L" break of '\L', '\0': @@ -70,7 +71,7 @@ proc replaceDeprecated*(info: TLineInfo; oldSym, newSym: PIdent) = while first > 0 and line[first-1] in Letters: dec first if first < 0: return if line[first] == '`': inc first - + let last = first+identLen(line, first)-1 if cmpIgnoreStyle(line[first..last], oldSym.s) == 0: var x = line.substr(0, first-1) & newSym.s & line.substr(last+1) diff --git a/compiler/nimsuggest/nimsuggest.nim b/compiler/nimsuggest/nimsuggest.nim index 8285d81d9..2be368d68 100644 --- a/compiler/nimsuggest/nimsuggest.nim +++ b/compiler/nimsuggest/nimsuggest.nim @@ -7,192 +7,6 @@ # distribution, for details about the copyright. # -## Nimsuggest is a tool that helps to give editors IDE like capabilities. +## Nimsuggest has been moved to https://github.com/nim-lang/nimsuggest -import strutils, os, parseopt, parseUtils -import options, commands, modules, sem, passes, passaux, msgs, nimconf, - extccomp, condsyms, lists, net, rdstdin - -const Usage = """ -Nimsuggest - Tool to give every editor IDE like capabilities for Nim -Usage: - nimsuggest [options] projectfile.nim - -Options: - --port:PORT port, by default 6000 - --address:HOST binds to that address, by default "" - --stdin read commands from stdin and write results to - stdout instead of using sockets - -The server then listens to the connection and takes line-based commands. - -In addition, all command line options of Nim that do not affect code generation -are supported. -""" - -var - gPort = 6000.Port - gAddress = "" - gUseStdin: bool - -const - seps = {':', ';', ' ', '\t'} - Help = "usage: sug|con|def|use file.nim[;dirtyfile.nim]:line:col\n"& - "type 'quit' to quit\n" & - "type 'debug' to toggle debug mode on/off\n" & - "type 'terse' to toggle terse mode on/off" - -proc parseQuoted(cmd: string; outp: var string; start: int): int = - var i = start - i += skipWhitespace(cmd, i) - if cmd[i] == '"': - i += parseUntil(cmd, outp, '"', i+1)+2 - else: - i += parseUntil(cmd, outp, seps, i) - result = i - -proc action(cmd: string) = - template toggle(sw) = - if sw in gGlobalOptions: - excl(gGlobalOptions, sw) - else: - incl(gGlobalOptions, sw) - return - - template err() = - echo Help - return - - var opc = "" - var i = parseIdent(cmd, opc, 0) - case opc.normalize - of "sug": gIdeCmd = ideSug - of "con": gIdeCmd = ideCon - of "def": gIdeCmd = ideDef - of "use": - modules.resetAllModules() - gIdeCmd = ideUse - of "quit": quit() - of "debug": toggle optIdeDebug - of "terse": toggle optIdeTerse - else: err() - var dirtyfile = "" - var orig = "" - i = parseQuoted(cmd, orig, i) - if cmd[i] == ';': - i = parseQuoted(cmd, dirtyfile, i+1) - i += skipWhile(cmd, seps, i) - var line = -1 - var col = 0 - i += parseInt(cmd, line, i) - i += skipWhile(cmd, seps, i) - i += parseInt(cmd, col, i) - - var isKnownFile = true - if orig.len == 0: err() - let dirtyIdx = orig.fileInfoIdx(isKnownFile) - - if dirtyfile.len != 0: msgs.setDirtyFile(dirtyIdx, dirtyfile) - else: msgs.setDirtyFile(dirtyIdx, nil) - - resetModule dirtyIdx - if dirtyIdx != gProjectMainIdx: - resetModule gProjectMainIdx - gTrackPos = newLineInfo(dirtyIdx, line, col-1) - #echo dirtyfile, gDirtyBufferIdx, " project ", gProjectMainIdx - gErrorCounter = 0 - if not isKnownFile: - compileProject(dirtyIdx) - else: - compileProject() - -proc serve() = - # do not stop after the first error: - msgs.gErrorMax = high(int) - if gUseStdin: - echo Help - var line = "" - while readLineFromStdin("> ", line): - action line - echo "" - flushFile(stdout) - else: - var server = newSocket() - server.bindAddr(gPort, gAddress) - var inp = "".TaintedString - server.listen() - - while true: - var stdoutSocket = newSocket() - msgs.writelnHook = proc (line: string) = - stdoutSocket.send(line & "\c\L") - - accept(server, stdoutSocket) - - stdoutSocket.readLine(inp) - action inp.string - - stdoutSocket.send("\c\L") - stdoutSocket.close() - -proc mainCommand = - registerPass verbosePass - registerPass semPass - gCmd = cmdIdeTools - incl gGlobalOptions, optCaasEnabled - isServing = true - wantMainModule() - appendStr(searchPaths, options.libpath) - if gProjectFull.len != 0: - # current path is always looked first for modules - prependStr(searchPaths, gProjectPath) - - serve() - -proc processCmdLine*(pass: TCmdLinePass, cmd: string) = - var p = parseopt.initOptParser(cmd) - while true: - parseopt.next(p) - case p.kind - of cmdEnd: break - of cmdLongoption, cmdShortOption: - case p.key.normalize - of "port": gPort = parseInt(p.val).Port - of "address": gAddress = p.val - of "stdin": gUseStdin = true - else: processSwitch(pass, p) - of cmdArgument: - options.gProjectName = unixToNativePath(p.key) - # if processArgument(pass, p, argsCount): break - -proc handleCmdLine() = - if paramCount() == 0: - stdout.writeln(Usage) - else: - processCmdLine(passCmd1, "") - if gProjectName != "": - try: - gProjectFull = canonicalizePath(gProjectName) - except OSError: - gProjectFull = gProjectName - var p = splitFile(gProjectFull) - gProjectPath = p.dir - gProjectName = p.name - else: - gProjectPath = getCurrentDir() - loadConfigs(DefaultConfig) # load all config files - # now process command line arguments again, because some options in the - # command line can overwite the config file's settings - extccomp.initVars() - processCmdLine(passCmd2, "") - mainCommand() - -when false: - proc quitCalled() {.noconv.} = - writeStackTrace() - - addQuitProc(quitCalled) - -condsyms.initDefines() -defineSymbol "nimsuggest" -handleCmdline() +{.error: "This project has moved to the following repo: https://github.com/nim-lang/nimsuggest".} diff --git a/compiler/nimsuggest/nimsuggest.nim.cfg b/compiler/nimsuggest/nimsuggest.nim.cfg deleted file mode 100644 index acca17396..000000000 --- a/compiler/nimsuggest/nimsuggest.nim.cfg +++ /dev/null @@ -1,17 +0,0 @@ -# Special configuration file for the Nim project - -gc:markAndSweep - -hint[XDeclaredButNotUsed]:off -path:"$projectPath/../.." - -path:"$lib/packages/docutils" -path:"../../compiler" - -define:useStdoutAsStdmsg -define:nimsuggest - -cs:partial -#define:useNodeIds -define:booting -#define:noDocgen diff --git a/compiler/options.nim b/compiler/options.nim index 65250f519..b3060a180 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -1,7 +1,7 @@ # # # The Nim Compiler -# (c) Copyright 2013 Andreas Rumpf +# (c) Copyright 2015 Andreas Rumpf # # See the file "copying.txt", included in this # distribution, for details about the copyright. @@ -83,11 +83,11 @@ type # please make sure we have under 32 options TGCMode* = enum # the selected GC gcNone, gcBoehm, gcMarkAndSweep, gcRefc, gcV2, gcGenerational - TIdeCmd* = enum + IdeCmd* = enum ideNone, ideSug, ideCon, ideDef, ideUse var - gIdeCmd*: TIdeCmd + gIdeCmd*: IdeCmd const ChecksOptions* = {optObjCheck, optFieldCheck, optRangeCheck, optNilCheck, @@ -149,6 +149,7 @@ var gProjectName* = "" # holds a name like 'nimrod' gProjectPath* = "" # holds a path like /home/alice/projects/nimrod/compiler/ gProjectFull* = "" # projectPath/projectName + gProjectIsStdin* = false # whether we're compiling from stdin gProjectMainIdx*: int32 # the canonical path id of the main module nimcacheDir* = "" command* = "" # the main command (e.g. cc, check, scan, etc) @@ -395,3 +396,18 @@ template cnimdbg*: expr = p.module.module.fileIdx == gProjectMainIdx template pnimdbg*: expr = p.lex.fileIdx == gProjectMainIdx template lnimdbg*: expr = L.fileIdx == gProjectMainIdx +proc parseIdeCmd*(s: string): IdeCmd = + case s: + of "sug": ideSug + of "con": ideCon + of "def": ideDef + of "use": ideUse + else: ideNone + +proc `$`*(c: IdeCmd): string = + case c: + of ideSug: "sug" + of ideCon: "con" + of ideDef: "def" + of ideUse: "use" + of ideNone: "none" diff --git a/compiler/parser.nim b/compiler/parser.nim index 0d2ba7cfc..05b4df13d 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -64,6 +64,7 @@ proc setBaseFlags*(n: PNode, base: TNumericalBase) proc parseSymbol*(p: var TParser, allowNil = false): PNode proc parseTry(p: var TParser; isExpr: bool): PNode proc parseCase(p: var TParser): PNode +proc parseStmtPragma(p: var TParser): PNode # implementation proc getTok(p: var TParser) = @@ -499,10 +500,13 @@ proc parsePar(p: var TParser): PNode = #| parKeyw = 'discard' | 'include' | 'if' | 'while' | 'case' | 'try' #| | 'finally' | 'except' | 'for' | 'block' | 'const' | 'let' #| | 'when' | 'var' | 'mixin' - #| par = '(' optInd (&parKeyw complexOrSimpleStmt ^+ ';' - #| | simpleExpr ('=' expr (';' complexOrSimpleStmt ^+ ';' )? )? - #| | (':' expr)? (',' (exprColonEqExpr comma?)*)? )? - #| optPar ')' + #| par = '(' optInd + #| ( &parKeyw complexOrSimpleStmt ^+ ';' + #| | ';' complexOrSimpleStmt ^+ ';' + #| | pragmaStmt + #| | simpleExpr ( ('=' expr (';' complexOrSimpleStmt ^+ ';' )? ) + #| | (':' expr (',' exprColonEqExpr ^+ ',' )? ) ) ) + #| optPar ')' # # unfortunately it's ambiguous: (expr: expr) vs (exprStmt); however a # leading ';' could be used to enforce a 'stmt' context ... @@ -521,6 +525,8 @@ proc parsePar(p: var TParser): PNode = getTok(p) optInd(p, result) semiStmtList(p, result) + elif p.tok.tokType == tkCurlyDotLe: + result.add(parseStmtPragma(p)) elif p.tok.tokType != tkParRi: var a = simpleExpr(p) if p.tok.tokType == tkEquals: diff --git a/compiler/passes.nim b/compiler/passes.nim index 129d8ad47..e031dae10 100644 --- a/compiler/passes.nim +++ b/compiler/passes.nim @@ -170,11 +170,7 @@ proc processModule(module: PSym, stream: PLLStream, rd: PRodReader) = openPasses(a, module) if stream == nil: let filename = fileIdx.toFullPathConsiderDirty - if module.name.s == "-": - module.name.s = "stdinfile" - s = llStreamOpen(stdin) - else: - s = llStreamOpen(filename, fmRead) + s = llStreamOpen(filename, fmRead) if s == nil: rawMessage(errCannotOpenFile, filename) return diff --git a/compiler/patterns.nim b/compiler/patterns.nim index 368b0b37b..3f8b05940 100644 --- a/compiler/patterns.nim +++ b/compiler/patterns.nim @@ -130,7 +130,9 @@ proc matchNested(c: PPatternContext, p, n: PNode, rpn: bool): bool = proc matches(c: PPatternContext, p, n: PNode): bool = # hidden conversions (?) - if isPatternParam(c, p): + if nfNoRewrite in n.flags: + result = false + elif isPatternParam(c, p): result = bindOrCheck(c, p.sym, n) elif n.kind == nkSym and p.kind == nkIdent: result = p.ident.id == n.sym.name.id diff --git a/compiler/plugins/locals/locals.nim b/compiler/plugins/locals/locals.nim index d89149f33..59e3d677d 100644 --- a/compiler/plugins/locals/locals.nim +++ b/compiler/plugins/locals/locals.nim @@ -9,7 +9,8 @@ ## The builtin 'system.locals' implemented as a plugin. -import plugins, ast, astalgo, magicsys, lookups, semdata, lowerings +import compiler/plugins, compiler/ast, compiler/astalgo, compiler/magicsys, + compiler/lookups, compiler/semdata, compiler/lowerings proc semLocals(c: PContext, n: PNode): PNode = var counter = 0 diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index c048d78e9..6f37fe756 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -37,7 +37,7 @@ const wImportc, wExportc, wNodecl, wMagic, wDeprecated, wBorrow, wExtern, wImportCpp, wImportObjC, wError, wDiscardable, wGensym, wInject, wRaises, wTags, wLocks, wGcSafe} - exprPragmas* = {wLine, wLocks} + exprPragmas* = {wLine, wLocks, wNoRewrite} stmtPragmas* = {wChecks, wObjChecks, wFieldChecks, wRangechecks, wBoundchecks, wOverflowchecks, wNilchecks, wAssertions, wWarnings, wHints, wLinedir, wStacktrace, wLinetrace, wOptimization, wHint, wWarning, wError, @@ -859,6 +859,8 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: int, c.module.flags.incl sfExperimental else: localError(it.info, "'experimental' pragma only valid as toplevel statement") + of wNoRewrite: + noVal(it) else: invalidPragma(it) else: invalidPragma(it) else: processNote(c, it) diff --git a/compiler/renderer.nim b/compiler/renderer.nim index ffdb60696..376c0d6f7 100644 --- a/compiler/renderer.nim +++ b/compiler/renderer.nim @@ -767,7 +767,8 @@ proc gasm(g: var TSrcGen, n: PNode) = putWithSpace(g, tkAsm, "asm") gsub(g, n.sons[0]) gcoms(g) - gsub(g, n.sons[1]) + if n.sons.len > 1: + gsub(g, n.sons[1]) proc gident(g: var TSrcGen, n: PNode) = if g.checkAnon and n.kind == nkSym and sfAnon in n.sym.flags: return diff --git a/compiler/semcall.nim b/compiler/semcall.nim index c48e761e3..571504c3a 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -209,7 +209,10 @@ proc resolveOverloads(c: PContext, n, orig: PNode, pickBest(callOp) if overloadsState == csEmpty and result.state == csEmpty: - localError(n.info, errUndeclaredIdentifier, considerQuotedIdent(f).s) + if nfDotField in n.flags and nfExplicitCall notin n.flags: + localError(n.info, errUndeclaredField, considerQuotedIdent(f).s) + else: + localError(n.info, errUndeclaredRoutine, considerQuotedIdent(f).s) return elif result.state != csMatch: if nfExprCall in n.flags: diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 21fc4ec40..cd6ba3753 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -535,7 +535,18 @@ proc semArrayConstr(c: PContext, n: PNode, flags: TExprFlags): PNode = result.sons[i] = fitNode(c, typ, result.sons[i]) result.typ.sons[0] = makeRangeType(c, 0, sonsLen(result) - 1, n.info) -template fixAbstractType(c: PContext, n: PNode) = +proc fixAbstractType(c: PContext, n: PNode) = + for i in 1 .. < n.len: + let it = n.sons[i] + # do not get rid of nkHiddenSubConv for OpenArrays, the codegen needs it: + if it.kind == nkHiddenSubConv and + skipTypes(it.typ, abstractVar).kind notin {tyOpenArray, tyVarargs}: + if skipTypes(it.sons[1].typ, abstractVar).kind in + {tyNil, tyArrayConstr, tyTuple, tySet}: + var s = skipTypes(it.typ, abstractVar) + if s.kind != tyExpr: + changeType(it.sons[1], s, check=true) + n.sons[i] = it.sons[1] when false: # XXX finally rewrite that crap! for i in countup(1, sonsLen(n) - 1): @@ -2042,7 +2053,7 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode = of nkEmpty, nkNone, nkCommentStmt: discard of nkNilLit: - result.typ = getSysType(tyNil) + if result.typ == nil: result.typ = getSysType(tyNil) of nkIntLit: if result.typ == nil: setIntLitType(result) of nkInt8Lit: diff --git a/compiler/semfold.nim b/compiler/semfold.nim index 941d47bb4..da24005c2 100644 --- a/compiler/semfold.nim +++ b/compiler/semfold.nim @@ -286,10 +286,13 @@ proc evalOp(m: TMagic, n, a, b, c: PNode): PNode = of mNot: result = newIntNodeT(1 - getInt(a), n) of mCard: result = newIntNodeT(nimsets.cardSet(a), n) of mBitnotI, mBitnotI64: result = newIntNodeT(not getInt(a), n) - of mLengthStr, mXLenStr: result = newIntNodeT(len(getStr(a)), n) + of mLengthStr, mXLenStr: + if a.kind == nkNilLit: result = newIntNodeT(0, n) + else: result = newIntNodeT(len(getStr(a)), n) of mLengthArray: result = newIntNodeT(lengthOrd(a.typ), n) of mLengthSeq, mLengthOpenArray, mXLenSeq: - result = newIntNodeT(sonsLen(a), n) # BUGFIX + if a.kind == nkNilLit: result = newIntNodeT(0, n) + else: result = newIntNodeT(sonsLen(a), n) # BUGFIX of mUnaryPlusI, mUnaryPlusF64: result = a # throw `+` away of mToFloat, mToBiggestFloat: result = newFloatNodeT(toFloat(int(getInt(a))), n) @@ -545,7 +548,7 @@ proc foldConv*(n, a: PNode; check = false): PNode = discard else: result = a - result.typ = takeType(n.typ, a.typ) + result.typ = n.typ proc getArrayConstr(m: PSym, n: PNode): PNode = if n.kind == nkBracket: @@ -652,7 +655,7 @@ proc getConstExpr(m: PSym, n: PNode): PNode = result = copyNode(n) of nkIfExpr: result = getConstIfExpr(m, n) - of nkCall, nkCommand, nkCallStrLit, nkPrefix, nkInfix: + of nkCallKinds: if n.sons[0].kind != nkSym: return var s = n.sons[0].sym if s.kind != skProc: return diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index adf03be64..12c4a7c7b 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -207,9 +207,9 @@ proc markGcUnsafe(a: PEffects; reason: PNode) = a.owner.gcUnsafetyReason = newSym(skUnknown, getIdent("<unknown>"), a.owner, reason.info) -proc listGcUnsafety(s: PSym; onlyWarning: bool) = +proc listGcUnsafety(s: PSym; onlyWarning: bool; cycleCheck: var IntSet) = let u = s.gcUnsafetyReason - if u != nil: + if u != nil and not cycleCheck.containsOrIncl(u.id): let msgKind = if onlyWarning: warnGcUnsafe2 else: errGenerated if u.kind in {skLet, skVar}: message(s.info, msgKind, @@ -218,7 +218,7 @@ proc listGcUnsafety(s: PSym; onlyWarning: bool) = elif u.kind in routineKinds: # recursive call *always* produces only a warning so the full error # message is printed: - listGcUnsafety(u, true) + listGcUnsafety(u, true, cycleCheck) message(s.info, msgKind, "'$#' is not GC-safe as it calls '$#'" % [s.name.s, u.name.s]) @@ -227,6 +227,10 @@ proc listGcUnsafety(s: PSym; onlyWarning: bool) = message(u.info, msgKind, "'$#' is not GC-safe as it performs an indirect call here" % s.name.s) +proc listGcUnsafety(s: PSym; onlyWarning: bool) = + var cycleCheck = initIntSet() + listGcUnsafety(s, onlyWarning, cycleCheck) + proc useVar(a: PEffects, n: PNode) = let s = n.sym if isLocalVar(a, s): diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index c355a5bf1..43cdca866 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -1268,6 +1268,8 @@ proc semPragmaBlock(c: PContext, n: PNode): PNode = of wLocks: result = n result.typ = n.sons[1].typ + of wNoRewrite: + incl(result.flags, nfNoRewrite) else: discard proc semStaticStmt(c: PContext, n: PNode): PNode = diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 2a9d15b5a..7ea2c3d6f 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -1281,7 +1281,10 @@ proc paramTypesMatchAux(m: var TCandidate, f, argType: PType, result = implicitConv(nkHiddenStdConv, f, arg, m, c) of isSubtype: inc(m.subtypeMatches) - result = implicitConv(nkHiddenSubConv, f, arg, m, c) + if f.kind == tyTypeDesc: + result = arg + else: + result = implicitConv(nkHiddenSubConv, f, arg, m, c) of isSubrange: inc(m.subtypeMatches) if f.kind == tyVar: diff --git a/compiler/suggest.nim b/compiler/suggest.nim index 6b168670c..659f1fa16 100644 --- a/compiler/suggest.nim +++ b/compiler/suggest.nim @@ -15,57 +15,79 @@ import algorithm, sequtils const sep = '\t' - sectionSuggest = "sug" - sectionDef = "def" - sectionContext = "con" - sectionUsage = "use" + +type + Suggest* = object + section*: IdeCmd + qualifiedPath*: seq[string] + filePath*: string + line*: int # Starts at 1 + column*: int # Starts at 0 + doc*: string # Not escaped (yet) + symkind*: TSymKind + forth*: string # XXX TODO object on symkind + +var + suggestionResultHook*: proc (result: Suggest) {.closure.} #template sectionSuggest(): expr = "##begin\n" & getStackTrace() & "##end\n" template origModuleName(m: PSym): string = m.name.s -proc symToStr(s: PSym, isLocal: bool, section: string, li: TLineInfo): string = - result = section - result.add(sep) +proc symToSuggest(s: PSym, isLocal: bool, section: string, li: TLineInfo): Suggest = + result.section = parseIdeCmd(section) if optIdeTerse in gGlobalOptions: - if s.kind in routineKinds: - result.add renderTree(s.ast, {renderNoBody, renderNoComments, - renderDocComments, renderNoPragmas}) - else: - result.add s.name.s - result.add(sep) - result.add(toFullPath(li)) - result.add(sep) - result.add($toLinenumber(li)) - result.add(sep) - result.add($toColumn(li)) + result.symkind = s.kind + result.filePath = toFullPath(li) + result.line = toLinenumber(li) + result.column = toColumn(li) else: - result.add($s.kind) - result.add(sep) + result.symkind = s.kind + result.qualifiedPath = @[] if not isLocal and s.kind != skModule: let ow = s.owner if ow.kind != skModule and ow.owner != nil: let ow2 = ow.owner - result.add(ow2.origModuleName) - result.add('.') - result.add(ow.origModuleName) - result.add('.') - result.add(s.name.s) - result.add(sep) + result.qualifiedPath.add(ow2.origModuleName) + result.qualifiedPath.add(ow.origModuleName) + result.qualifiedPath.add(s.name.s) + if s.typ != nil: - result.add(typeToString(s.typ)) - result.add(sep) - result.add(toFullPath(li)) - result.add(sep) - result.add($toLinenumber(li)) - result.add(sep) - result.add($toColumn(li)) - result.add(sep) + result.forth = typeToString(s.typ) + else: + result.forth = "" + result.filePath = toFullPath(li) + result.line = toLinenumber(li) + result.column = toColumn(li) when not defined(noDocgen): - result.add(s.extractDocComment.escape) + result.doc = s.extractDocComment + +proc `$`(suggest: Suggest): string = + result = $suggest.section + result.add(sep) + result.add($suggest.symkind) + result.add(sep) + result.add(suggest.qualifiedPath.join(".")) + result.add(sep) + result.add(suggest.forth) + result.add(sep) + result.add(suggest.filePath) + result.add(sep) + result.add($suggest.line) + result.add(sep) + result.add($suggest.column) + result.add(sep) + when not defined(noDocgen): + result.add(suggest.doc.escape) -proc symToStr(s: PSym, isLocal: bool, section: string): string = - result = symToStr(s, isLocal, section, s.info) +proc symToSuggest(s: PSym, isLocal: bool, section: string): Suggest = + result = symToSuggest(s, isLocal, section, s.info) + +proc suggestResult(s: Suggest) = + if not isNil(suggestionResultHook): + suggestionResultHook(s) + else: + suggestWriteln($(s)) proc filterSym(s: PSym): bool {.inline.} = result = s.kind != skModule @@ -84,7 +106,7 @@ proc fieldVisible*(c: PContext, f: PSym): bool {.inline.} = proc suggestField(c: PContext, s: PSym, outputs: var int) = if filterSym(s) and fieldVisible(c, s): - suggestWriteln(symToStr(s, isLocal=true, sectionSuggest)) + suggestResult(symToSuggest(s, isLocal=true, $ideSug)) inc outputs template wholeSymTab(cond, section: expr) {.immediate.} = @@ -97,7 +119,7 @@ template wholeSymTab(cond, section: expr) {.immediate.} = for item in entries: let it {.inject.} = item if cond: - suggestWriteln(symToStr(it, isLocal = isLocal, section)) + suggestResult(symToSuggest(it, isLocal = isLocal, section)) inc outputs proc suggestSymList(c: PContext, list: PNode, outputs: var int) = @@ -140,7 +162,7 @@ proc argsFit(c: PContext, candidate: PSym, n, nOrig: PNode): bool = proc suggestCall(c: PContext, n, nOrig: PNode, outputs: var int) = wholeSymTab(filterSym(it) and nameFits(c, it, n) and argsFit(c, it, n, nOrig), - sectionContext) + $ideCon) proc typeFits(c: PContext, s: PSym, firstArg: PType): bool {.inline.} = if s.typ != nil and sonsLen(s.typ) > 1 and s.typ.sons[1] != nil: @@ -157,7 +179,7 @@ proc typeFits(c: PContext, s: PSym, firstArg: PType): bool {.inline.} = proc suggestOperations(c: PContext, n: PNode, typ: PType, outputs: var int) = assert typ != nil - wholeSymTab(filterSymNoOpr(it) and typeFits(c, it, typ), sectionSuggest) + wholeSymTab(filterSymNoOpr(it) and typeFits(c, it, typ), $ideSug) proc suggestEverything(c: PContext, n: PNode, outputs: var int) = # do not produce too many symbols: @@ -166,7 +188,7 @@ proc suggestEverything(c: PContext, n: PNode, outputs: var int) = if scope == c.topLevelScope: isLocal = false for it in items(scope.symbols): if filterSym(it): - suggestWriteln(symToStr(it, isLocal = isLocal, sectionSuggest)) + suggestResult(symToSuggest(it, isLocal = isLocal, $ideSug)) inc outputs if scope == c.topLevelScope: break @@ -181,12 +203,12 @@ proc suggestFieldAccess(c: PContext, n: PNode, outputs: var int) = # all symbols accessible, because we are in the current module: for it in items(c.topLevelScope.symbols): if filterSym(it): - suggestWriteln(symToStr(it, isLocal=false, sectionSuggest)) + suggestResult(symToSuggest(it, isLocal=false, $ideSug)) inc outputs else: for it in items(n.sym.tab): if filterSym(it): - suggestWriteln(symToStr(it, isLocal=false, sectionSuggest)) + suggestResult(symToSuggest(it, isLocal=false, $ideSug)) inc outputs else: # fallback: @@ -263,16 +285,16 @@ var proc findUsages(info: TLineInfo; s: PSym) = if usageSym == nil and isTracked(info, s.name.s.len): usageSym = s - suggestWriteln(symToStr(s, isLocal=false, sectionUsage)) + suggestResult(symToSuggest(s, isLocal=false, $ideUse)) elif s == usageSym: if lastLineInfo != info: - suggestWriteln(symToStr(s, isLocal=false, sectionUsage, info)) + suggestResult(symToSuggest(s, isLocal=false, $ideUse, info)) lastLineInfo = info proc findDefinition(info: TLineInfo; s: PSym) = if s.isNil: return if isTracked(info, s.name.s.len): - suggestWriteln(symToStr(s, isLocal=false, sectionDef)) + suggestResult(symToSuggest(s, isLocal=false, $ideDef)) suggestQuit() proc ensureIdx[T](x: var T, y: int) = diff --git a/compiler/transf.nim b/compiler/transf.nim index 3bdbdfadd..57547b682 100644 --- a/compiler/transf.nim +++ b/compiler/transf.nim @@ -716,8 +716,7 @@ proc transform(c: PTransf, n: PNode): PTransNode = add(result, PTransNode(newSymNode(labl))) of nkBreakStmt: result = transformBreak(c, n) of nkWhileStmt: result = transformWhile(c, n) - of nkCall, nkHiddenCallConv, nkCommand, nkInfix, nkPrefix, nkPostfix, - nkCallStrLit: + of nkCallKinds: result = transformCall(c, n) of nkAddr, nkHiddenAddr: result = transformAddrDeref(c, n, nkDerefExpr, nkHiddenDeref) diff --git a/compiler/treetab.nim b/compiler/treetab.nim index 8d66d56c7..adfc7b2ce 100644 --- a/compiler/treetab.nim +++ b/compiler/treetab.nim @@ -12,7 +12,7 @@ import hashes, ast, astalgo, types -proc hashTree(n: PNode): THash = +proc hashTree(n: PNode): Hash = if n == nil: return result = ord(n.kind) case n.kind @@ -53,8 +53,8 @@ proc treesEquivalent(a, b: PNode): bool = result = true if result: result = sameTypeOrNil(a.typ, b.typ) -proc nodeTableRawGet(t: TNodeTable, k: THash, key: PNode): int = - var h: THash = k and high(t.data) +proc nodeTableRawGet(t: TNodeTable, k: Hash, key: PNode): int = + var h: Hash = k and high(t.data) while t.data[h].key != nil: if (t.data[h].h == k) and treesEquivalent(t.data[h].key, key): return h @@ -66,9 +66,9 @@ proc nodeTableGet*(t: TNodeTable, key: PNode): int = if index >= 0: result = t.data[index].val else: result = low(int) -proc nodeTableRawInsert(data: var TNodePairSeq, k: THash, key: PNode, +proc nodeTableRawInsert(data: var TNodePairSeq, k: Hash, key: PNode, val: int) = - var h: THash = k and high(data) + var h: Hash = k and high(data) while data[h].key != nil: h = nextTry(h, high(data)) assert(data[h].key == nil) data[h].h = k @@ -77,7 +77,7 @@ proc nodeTableRawInsert(data: var TNodePairSeq, k: THash, key: PNode, proc nodeTablePut*(t: var TNodeTable, key: PNode, val: int) = var n: TNodePairSeq - var k: THash = hashTree(key) + var k: Hash = hashTree(key) var index = nodeTableRawGet(t, k, key) if index >= 0: assert(t.data[index].key != nil) @@ -94,7 +94,7 @@ proc nodeTablePut*(t: var TNodeTable, key: PNode, val: int) = proc nodeTableTestOrSet*(t: var TNodeTable, key: PNode, val: int): int = var n: TNodePairSeq - var k: THash = hashTree(key) + var k: Hash = hashTree(key) var index = nodeTableRawGet(t, k, key) if index >= 0: assert(t.data[index].key != nil) diff --git a/compiler/vm.nim b/compiler/vm.nim index 1c6c9a30b..e49bed522 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -1121,7 +1121,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = decodeB(rkInt) let a = regs[rb].node case a.kind - of nkCharLit..nkInt64Lit: regs[ra].intVal = a.intVal + of nkCharLit..nkUInt64Lit: regs[ra].intVal = a.intVal else: stackTrace(c, tos, pc, errFieldXNotFound, "intVal") of opcNFloatVal: decodeB(rkFloat) @@ -1276,7 +1276,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = of opcNSetIntVal: decodeB(rkNode) var dest = regs[ra].node - if dest.kind in {nkCharLit..nkInt64Lit} and + if dest.kind in {nkCharLit..nkUInt64Lit} and regs[rb].kind in {rkInt}: dest.intVal = regs[rb].intVal else: diff --git a/compiler/wordrecg.nim b/compiler/wordrecg.nim index 63fd995c4..deb12536f 100644 --- a/compiler/wordrecg.nim +++ b/compiler/wordrecg.nim @@ -55,7 +55,7 @@ type wFloatchecks, wNanChecks, wInfChecks, wAssertions, wPatterns, wWarnings, wHints, wOptimization, wRaises, wWrites, wReads, wSize, wEffects, wTags, - wDeadCodeElim, wSafecode, wNoForward, + wDeadCodeElim, wSafecode, wNoForward, wNoRewrite, wPragma, wCompileTime, wNoInit, wPassc, wPassl, wBorrow, wDiscardable, @@ -139,7 +139,7 @@ const "assertions", "patterns", "warnings", "hints", "optimization", "raises", "writes", "reads", "size", "effects", "tags", - "deadcodeelim", "safecode", "noforward", + "deadcodeelim", "safecode", "noforward", "norewrite", "pragma", "compiletime", "noinit", "passc", "passl", "borrow", "discardable", "fieldchecks", diff --git a/config/nim.cfg b/config/nim.cfg index ccb9977db..0c3ffef4e 100644 --- a/config/nim.cfg +++ b/config/nim.cfg @@ -78,6 +78,7 @@ path="$lib/pure/unidecode" gcc.options.linker = "-ldl" gcc.cpp.options.linker = "-ldl" clang.options.linker = "-ldl" + clang.cpp.options.linker = "-ldl" tcc.options.linker = "-ldl" @end @if bsd or haiku: @@ -96,7 +97,7 @@ path="$lib/pure/unidecode" # Configuration for the GNU C/C++ compiler: @if windows: - #gcc.path = r"$nimrod\dist\mingw\bin" + #gcc.path = r"$nim\dist\mingw\bin" @if gcc: tlsEmulation:on @end diff --git a/doc/astspec.txt b/doc/astspec.txt index 4c27272e2..68bb9f1cd 100644 --- a/doc/astspec.txt +++ b/doc/astspec.txt @@ -23,7 +23,7 @@ contains: case kind: NimNodeKind ## the node's kind of nnkNone, nnkEmpty, nnkNilLit: discard ## node contains no additional fields - of nnkCharLit..nnkInt64Lit: + of nnkCharLit..nnkUInt64Lit: intVal: biggestInt ## the int literal of nnkFloatLit..nnkFloat64Lit: floatVal: biggestFloat ## the float literal diff --git a/doc/exception_hierarchy_fragment.txt b/doc/exception_hierarchy_fragment.txt index f4a419fc4..a02d9ccef 100644 --- a/doc/exception_hierarchy_fragment.txt +++ b/doc/exception_hierarchy_fragment.txt @@ -11,8 +11,8 @@ * `FloatInvalidOpError <system.html#FloatInvalidOpError>`_ * `FloatOverflowError <system.html#FloatOverflowError>`_ * `FloatUnderflowError <system.html#FloatUnderflowError>`_ - * `FieldError <system.html#InvalidFieldError>`_ - * `IndexError <system.html#InvalidIndexError>`_ + * `FieldError <system.html#FieldError>`_ + * `IndexError <system.html#IndexError>`_ * `ObjectAssignmentError <system.html#ObjectAssignmentError>`_ * `ObjectConversionError <system.html#ObjectConversionError>`_ * `ValueError <system.html#ValueError>`_ diff --git a/doc/lib.txt b/doc/lib.txt index 1c0278068..fd5218b0a 100644 --- a/doc/lib.txt +++ b/doc/lib.txt @@ -123,11 +123,6 @@ String handling Ropes can represent very long strings efficiently; especially concatenation is done in O(1) instead of O(n). -* `unidecode <unidecode.html>`_ - This module provides Unicode to ASCII transliterations: - It finds the sequence of ASCII characters that is the closest approximation - to the Unicode string. - * `matchers <matchers.html>`_ This module contains various string matchers for email addresses, etc. @@ -325,6 +320,10 @@ Parsers * `rstgen <rstgen.html>`_ This module implements a generator of HTML/Latex from reStructuredText. +* `sexp <sexp.html>`_ + High performance sexp parser and generator, mainly for communication + with emacs. + XML Processing -------------- diff --git a/doc/manual/about.txt b/doc/manual/about.txt index 78167efe3..8528ff978 100644 --- a/doc/manual/about.txt +++ b/doc/manual/about.txt @@ -1,15 +1,15 @@ About this document =================== -**Note**: This document is a draft! Several of Nim's features need more -precise wording. This manual will evolve into a proper specification some -day. +**Note**: This document is a draft! Several of Nim's features may need more +precise wording. This manual is constantly evolving until the 1.0 release and is +not to be considered as the final proper specification. This document describes the lexis, the syntax, and the semantics of Nim. -The language constructs are explained using an extended BNF, in -which ``(a)*`` means 0 or more ``a``'s, ``a+`` means 1 or more ``a``'s, and -``(a)?`` means an optional *a*. Parentheses may be used to group elements. +The language constructs are explained using an extended BNF, in which ``(a)*`` +means 0 or more ``a``'s, ``a+`` means 1 or more ``a``'s, and ``(a)?`` means an +optional *a*. Parentheses may be used to group elements. ``&`` is the lookahead operator; ``&a`` means that an ``a`` is expected but not consumed. It will be consumed in the following rule. @@ -33,5 +33,5 @@ and ``a ^* b`` is short for ``(a (b a)*)?``. Example:: arrayConstructor = '[' expr ^* ',' ']' Other parts of Nim - like scoping rules or runtime semantics are only -described in an informal manner for now. +described in the, more easily comprehensible, informal manner for now. diff --git a/doc/manual/definitions.txt b/doc/manual/definitions.txt index 9eb20f70f..9004ce658 100644 --- a/doc/manual/definitions.txt +++ b/doc/manual/definitions.txt @@ -30,7 +30,7 @@ exceptions* or *dying with a fatal error*. However, the implementation provides a means to disable these runtime checks. See the section pragmas_ for details. -Wether a checked runtime error results in an exception or in a fatal error at +Whether a checked runtime error results in an exception or in a fatal error at runtime is implementation specific. Thus the following program is always invalid: diff --git a/doc/manual/effects.txt b/doc/manual/effects.txt index a79f6ea85..40532b080 100644 --- a/doc/manual/effects.txt +++ b/doc/manual/effects.txt @@ -48,7 +48,7 @@ possibly raised exceptions; the algorithm operates on ``p``'s call graph: However if the call is of the form ``f(...)`` where ``f`` is a parameter of the currently analysed routine it is ignored. The call is optimistically assumed to have no effect. Rule 2 compensates for this case. -2. Every expression of some proc type wihtin a call that is not a call +2. Every expression of some proc type within a call that is not a call itself (and not nil) is assumed to be called indirectly somehow and thus its raises list is added to ``p``'s raises list. 3. Every call to a proc ``q`` which has an unknown body (due to a forward diff --git a/doc/manual/lexing.txt b/doc/manual/lexing.txt index df6d85636..fab6da416 100644 --- a/doc/manual/lexing.txt +++ b/doc/manual/lexing.txt @@ -25,7 +25,7 @@ a separate token. This trick allows parsing of Nim with only 1 token of lookahead. The parser uses a stack of indentation levels: the stack consists of integers -counting the spaces. The indentation information is queried at strategic +counting the spaces. The indentation information is queried at strategic places in the parser but ignored otherwise: The pseudo terminal ``IND{>}`` denotes an indentation that consists of more spaces than the entry at the top of the stack; IND{=} an indentation that has the same number of spaces. ``DED`` @@ -80,7 +80,7 @@ underscores ``__`` are not allowed:: digit ::= '0'..'9' IDENTIFIER ::= letter ( ['_'] (letter | digit) )* -Currently any unicode character with an ordinal value > 127 (non ASCII) is +Currently any Unicode character with an ordinal value > 127 (non ASCII) is classified as a ``letter`` and may thus be part of an identifier but later versions of the language may assign some Unicode characters to belong to the operator characters instead. @@ -276,7 +276,7 @@ Numerical constants are of a single type and have the form:: bindigit = '0'..'1' HEX_LIT = '0' ('x' | 'X' ) hexdigit ( ['_'] hexdigit )* DEC_LIT = digit ( ['_'] digit )* - OCT_LIT = '0o' octdigit ( ['_'] octdigit )* + OCT_LIT = '0' ('o' | 'c' | 'C') octdigit ( ['_'] octdigit )* BIN_LIT = '0' ('b' | 'B' ) bindigit ( ['_'] bindigit )* INT_LIT = HEX_LIT @@ -297,15 +297,17 @@ Numerical constants are of a single type and have the form:: exponent = ('e' | 'E' ) ['+' | '-'] digit ( ['_'] digit )* FLOAT_LIT = digit (['_'] digit)* (('.' (['_'] digit)* [exponent]) |exponent) - FLOAT32_LIT = HEX_LIT '\'' ('f'|'F') '32' - | (FLOAT_LIT | DEC_LIT | OCT_LIT | BIN_LIT) ['\''] ('f'|'F') '32' - FLOAT64_LIT = HEX_LIT '\'' ('f'|'F') '64' - | (FLOAT_LIT | DEC_LIT | OCT_LIT | BIN_LIT) ['\''] ('f'|'F') '64' + FLOAT32_SUFFIX = ('f' | 'F') ['32'] + FLOAT32_LIT = HEX_LIT '\'' FLOAT32_SUFFIX + | (FLOAT_LIT | DEC_LIT | OCT_LIT | BIN_LIT) ['\''] FLOAT32_SUFFIX + FLOAT64_SUFFIX = ( ('f' | 'F') '64' ) | 'd' | 'D' + FLOAT64_LIT = HEX_LIT '\'' FLOAT64_SUFFIX + | (FLOAT_LIT | DEC_LIT | OCT_LIT | BIN_LIT) ['\''] FLOAT64_SUFFIX As can be seen in the productions, numerical constants can contain underscores for readability. Integer and floating point literals may be given in decimal (no -prefix), binary (prefix ``0b``), octal (prefix ``0o``) and hexadecimal +prefix), binary (prefix ``0b``), octal (prefix ``0o`` or ``0c``) and hexadecimal (prefix ``0x``) notation. There exists a literal for each numerical type that is @@ -331,8 +333,11 @@ The type suffixes are: ``'u16`` uint16 ``'u32`` uint32 ``'u64`` uint64 + ``'f`` float32 + ``'d`` float64 ``'f32`` float32 ``'f64`` float64 + ``'f128`` float128 ================= ========================= Floating point literals may also be in binary, octal or hexadecimal @@ -344,8 +349,8 @@ is approximately 1.72826e35 according to the IEEE floating point standard. Operators --------- -In Nim one can define his own operators. An operator is any -combination of the following characters:: +Nim allows user defined operators. An operator is any combination of the +following characters:: = + - * / < > @ $ ~ & % | @@ -355,7 +360,7 @@ These keywords are also operators: ``and or not xor shl shr div mod in notin is isnot of``. `=`:tok:, `:`:tok:, `::`:tok: are not available as general operators; they -are used for other notational purposes. +are used for other notational purposes. ``*:`` is as a special case the two tokens `*`:tok: and `:`:tok: (to support ``var v*: T``). diff --git a/doc/manual/modules.txt b/doc/manual/modules.txt index 70f6026b2..fe3360773 100644 --- a/doc/manual/modules.txt +++ b/doc/manual/modules.txt @@ -178,8 +178,7 @@ Module scope ~~~~~~~~~~~~ All identifiers of a module are valid from the point of declaration until the end of the module. Identifiers from indirectly dependent modules are *not* -available. The `system`:idx: module is automatically imported in every other -module. +available. The `system`:idx: module is automatically imported in every module. If a module imports an identifier by two different modules, each occurrence of the identifier has to be qualified, unless it is an overloaded procedure or diff --git a/doc/manual/pragmas.txt b/doc/manual/pragmas.txt index 39aebd826..51125f576 100644 --- a/doc/manual/pragmas.txt +++ b/doc/manual/pragmas.txt @@ -18,9 +18,7 @@ The deprecated pragma is used to mark a symbol as deprecated: proc p() {.deprecated.} var x {.deprecated.}: char -It can also be used as a statement. Then it takes a list of *renamings*. The -upcoming ``nimfix`` tool can automatically update the code and perform these -renamings: +It can also be used as a statement, in that case it takes a list of *renamings*. .. code-block:: nim type @@ -28,6 +26,9 @@ renamings: Stream = ref object {.deprecated: [TFile: File, PStream: Stream].} +The ``nimfix`` tool can be used to, without effort, automatically update your +code and refactor it by performing these renamings. + noSideEffect pragma ------------------- @@ -54,9 +55,7 @@ destructor pragma ----------------- The ``destructor`` pragma is used to mark a proc to act as a type destructor. -Its usage is deprecated, use the ``override`` pragma instead. -See `type bound operations`_. - +Its usage is deprecated, See `type bound operations`_ instead. override pragma --------------- @@ -371,7 +370,7 @@ The ``register`` pragma is for variables only. It declares the variable as in a hardware register for faster access. C compilers usually ignore this though and for good reasons: Often they do a better job without it anyway. -In highly specific cases (a dispatch loop of an bytecode interpreter for +In highly specific cases (a dispatch loop of a bytecode interpreter for example) it may provide benefits, though. @@ -429,13 +428,13 @@ Example: 2. When a top level call is encountered (usually at the very end of the module), the compiler will try to determine the actual types of all of the symbols in the matching overload set. This is a potentially recursive process as the signatures - of the symbols may include other call expressions, whoose types will be resolved + of the symbols may include other call expressions, whose types will be resolved at this point too. - 3. Finally, after the best overload is picked, the compiler will start compiling - the body of the respective symbol. This in turn will lead the compiler to discover - more call expresions that need to be resolved and steps 2 and 3 will be repeated - as necessary. + 3. Finally, after the best overload is picked, the compiler will start + compiling the body of the respective symbol. This in turn will lead the + compiler to discover more call expressions that need to be resolved and steps + 2 and 3 will be repeated as necessary. Please note that if a callable symbol is never used in this scenario, its body will never be compiled. This is the default behavior leading to best compilation diff --git a/doc/manual/procs.txt b/doc/manual/procs.txt index 9de984ecf..23b5e4d1e 100644 --- a/doc/manual/procs.txt +++ b/doc/manual/procs.txt @@ -2,17 +2,46 @@ Procedures ========== What most programming languages call `methods`:idx: or `functions`:idx: are -called `procedures`:idx: in Nim (which is the correct terminology). A -procedure declaration defines an identifier and associates it with a block -of code. -A procedure may call itself recursively. A parameter may be given a default -value that is used if the caller does not provide a value for this parameter. - -If the proc declaration has no body, it is a `forward`:idx: declaration. If -the proc returns a value, the procedure body can access an implicitly declared +called `procedures`:idx: in Nim (which is the correct terminology). A procedure +declaration consists of an identifier, zero or more formal parameters, a return +value type and a block of code. Formal parameters are declared as a list of +identifiers separated by either comma or semicolon. A parameter is given a type +by ``: typename``. The type applies to all parameters immediately before it, +until either the beginning of the parameter list, a semicolon separator or an +already typed parameter, is reached. The semicolon can be used to make +separation of types and subsequent identifiers more distinct. + +.. code-block:: nim + # Using only commas + proc foo(a, b: int, c, d: bool): int + + # Using semicolon for visual distinction + proc foo(a, b: int; c, d: bool): int + + # Will fail: a is untyped since ';' stops type propagation. + proc foo(a; b: int; c, d: bool): int + +A parameter may be declared with a default value which is used if the caller +does not provide a value for the argument. + +.. code-block:: nim + # b is optional with 47 as its default value + proc foo(a: int, b: int = 47): int + +Parameters can be declared mutable and so allow the proc to modify those +arguments, by using the type modifier `var`. + +.. code-block:: nim + # "returning" a value to the caller through the 2nd argument + # Notice that the function uses no actual return value at all (ie void) + proc foo(inp: int, outp: var int) = + outp = inp + 47 + +If the proc declaration has no body, it is a `forward`:idx: declaration. If the +proc returns a value, the procedure body can access an implicitly declared variable named `result`:idx: that represents the return value. Procs can be -overloaded. The overloading resolution algorithm tries to find the proc that is -the best match for the arguments. Example: +overloaded. The overloading resolution algorithm determines which proc is the +best match for the arguments. Example: .. code-block:: nim @@ -41,9 +70,8 @@ Calling a procedure can be done in many different ways: # call as a command statement: no () needed: callme 0, 1, "abc", '\t' +A procedure may call itself recursively. -A procedure cannot modify its parameters (unless the parameters have the type -`var`). `Operators`:idx: are procedures with a special operator symbol as identifier: @@ -376,7 +404,7 @@ dispatch. result.a = a result.b = b -echo eval(newPlus(newPlus(newLit(1), newLit(2)), newLit(4))) + echo eval(newPlus(newPlus(newLit(1), newLit(2)), newLit(4))) In the example the constructors ``newLit`` and ``newPlus`` are procs because they should use static binding, but ``eval`` is a method because it @@ -475,7 +503,7 @@ If the for loop has exactly 2 variables, a ``pairs`` iterator is implicitly invoked. Symbol lookup of the identifiers ``items``/``pairs`` is performed after -the rewriting step, so that all overloadings of ``items``/``pairs`` are taken +the rewriting step, so that all overloads of ``items``/``pairs`` are taken into account. @@ -511,11 +539,12 @@ Closure iterators have other restrictions than inline iterators: 1. ``yield`` in a closure iterator can not occur in a ``try`` statement. 2. For now, a closure iterator cannot be evaluated at compile time. -3. ``return`` is allowed in a closure iterator (but rarely useful). -4. Both inline and closure iterators cannot be recursive. +3. ``return`` is allowed in a closure iterator (but rarely useful) and ends + iteration. +4. Neither inline nor closure iterators can be recursive. Iterators that are neither marked ``{.closure.}`` nor ``{.inline.}`` explicitly -default to being inline, but that this may change in future versions of the +default to being inline, but this may change in future versions of the implementation. The ``iterator`` type is always of the calling convention ``closure`` @@ -612,8 +641,8 @@ parameters of an outer factory proc: Implicit return type -------------------- - Since inline interators must always produce values that will be consumed in - a for loop, the compiler will implicity use the ``auto`` return type if no + Since inline iterators must always produce values that will be consumed in + a for loop, the compiler will implicitly use the ``auto`` return type if no type is given by the user. In contrast, since closure iterators can be used as a collaborative tasking system, ``void`` is a valid return type for them. diff --git a/doc/manual/stmts.txt b/doc/manual/stmts.txt index 5e47110e9..32c01dccb 100644 --- a/doc/manual/stmts.txt +++ b/doc/manual/stmts.txt @@ -10,7 +10,7 @@ Statements are separated into `simple statements`:idx: and Simple statements are statements that cannot contain other statements like assignments, calls or the ``return`` statement; complex statements can contain other statements. To avoid the `dangling else problem`:idx:, complex -statements always have to be intended. The details can be found in the grammar. +statements always have to be indented. The details can be found in the grammar. Statement list expression @@ -176,9 +176,9 @@ The rules for compile-time computability are: 1. Literals are compile-time computable. 2. Type conversions are compile-time computable. 3. Procedure calls of the form ``p(X)`` are compile-time computable if - ``p`` is a proc without side-effects (see the `noSideEffect pragma`_ - for details) and if ``X`` is a (possibly empty) list of compile-time - computable arguments. + ``p`` is a proc without side-effects (see the `noSideEffect pragma + <#pragmas-nosideeffect-pragma>`_ for details) and if ``X`` is a + (possibly empty) list of compile-time computable arguments. Constants cannot be of type ``ptr``, ``ref``, ``var`` or ``object``, nor can @@ -229,22 +229,18 @@ the expression after the ``elif`` is evaluated (if there is an ``elif`` branch), if it is true the corresponding statements after the ``:`` are executed. This goes on until the last ``elif``. If all conditions fail, the ``else`` part is executed. If there is no ``else`` -part, execution continues with the statement after the ``if`` statement. +part, execution continues with the next statement. -The scoping for an ``if`` statement is slightly subtle to support an important -use case. A new scope starts for the ``if``/``elif`` condition and ends after -the corresponding *then* block: +In ``if`` statements new scopes begin immediately after the ``if``/``elif``/``else`` keywords and ends after the corresponding *then* block. +For visualization purposes the scopes have been enclosed in ``{| |}`` in the following example: .. code-block:: nim if {| (let m = input =~ re"(\w+)=\w+"; m.isMatch): echo "key ", m[0], " value ", m[1] |} elif {| (let m = input =~ re""; m.isMatch): - echo "new m in this scope" |} - else: - # 'm' not declared here - -In the example the scopes have been enclosed in ``{| |}``. - + echo "new m in this scope" |} + else: {| + echo "m not declared here" |} Case statement -------------- @@ -601,7 +597,7 @@ A table constructor is syntactic sugar for an array constructor: The empty table can be written ``{:}`` (in contrast to the empty set which is ``{}``) which is thus another way to write as the empty array -constructor ``[]``. This slightly unusal way of supporting tables +constructor ``[]``. This slightly unusual way of supporting tables has lots of advantages: * The order of the (key,value)-pairs is preserved, thus it is easy to diff --git a/doc/manual/threads.txt b/doc/manual/threads.txt index fc3040c87..f2b79a34f 100644 --- a/doc/manual/threads.txt +++ b/doc/manual/threads.txt @@ -37,7 +37,7 @@ that contains GC'ed memory (``string``, ``seq``, ``ref`` or a closure) either directly or indirectly through a call to a GC unsafe proc. The `gcsafe`:idx: annotation can be used to mark a proc to be gcsafe, -otherwise this property is inferred by the compiler. Note that ``noSideEfect`` +otherwise this property is inferred by the compiler. Note that ``noSideEffect`` implies ``gcsafe``. The only way to create a thread is via ``spawn`` or ``createThead``. ``spawn`` is usually the preferable method. Either way the invoked proc must not use ``var`` parameters nor must any of its parameters @@ -146,7 +146,7 @@ wait on multiple flow variables at the same time: # wait until 2 out of 3 servers received the update: proc main = - var responses = newSeq[RawFlowVar](3) + var responses = newSeq[FlowVarBase](3) for i in 0..2: responses[i] = spawn tellServer(Update, "key", "value") var index = awaitAny(responses) diff --git a/doc/manual/trmacros.txt b/doc/manual/trmacros.txt index 90d01e475..5ff24a36a 100644 --- a/doc/manual/trmacros.txt +++ b/doc/manual/trmacros.txt @@ -43,6 +43,10 @@ Fortunately Nim supports side effect analysis: echo f() * 2 # not optimized ;-) +You can make one overload matching with a constraint and one without, and the +one with a constraint will have precedence, and so you can handle both cases +differently. + So what about ``2 * a``? We should tell the compiler ``*`` is commutative. We cannot really do that however as the following code only swaps arguments blindly: @@ -105,8 +109,10 @@ Predicate Meaning with the marked parameter. =================== ===================================================== +Predicates that share their name with a keyword have to be escaped with +backticks: `` `const` ``. The ``alias`` and ``noalias`` predicates refer not only to the matching AST, -but also to every other bound parameter; syntactially they need to occur after +but also to every other bound parameter; syntactically they need to occur after the ordinary AST predicates: .. code-block:: nim @@ -144,7 +150,7 @@ constant folding, so the following does not work: The reason is that the compiler already transformed the 1 into "1" for the ``echo`` statement. However, a term rewriting macro should not change the -semantics anyway. In fact they can be deactived with the ``--patterns:off`` +semantics anyway. In fact they can be deactivated with the ``--patterns:off`` command line option or temporarily with the ``patterns`` pragma. @@ -345,15 +351,15 @@ optimization for types that have copying semantics: ## puts a (key, value)-pair into `t`. The semantics of string require ## a copy here: let idx = findInsertionPosition(key) - t[idx] = key - t[idx] = val + t[idx].key = key + t[idx].val = val proc `[]=`*(t: var Table, key: string{call}, val: string{call}) = ## puts a (key, value)-pair into `t`. Optimized version that knows that ## the strings are unique and thus don't need to be copied: let idx = findInsertionPosition(key) - shallowCopy t[idx], key - shallowCopy t[idx], val + shallowCopy t[idx].key, key + shallowCopy t[idx].val, val var t: Table # overloading resolution ensures that the optimized []= is called here: diff --git a/doc/manual/type_rel.txt b/doc/manual/type_rel.txt index d1593a02e..5c8372e1e 100644 --- a/doc/manual/type_rel.txt +++ b/doc/manual/type_rel.txt @@ -9,11 +9,11 @@ Type equality ------------- Nim uses structural type equivalence for most types. Only for objects, enumerations and distinct types name equivalence is used. The following -algorithm (in pseudo-code) determines type equality: +algorithm, *in pseudo-code*, determines type equality: .. code-block:: nim proc typeEqualsAux(a, b: PType, - s: var set[PType * PType]): bool = + s: var HashSet[(PType, PType)]): bool = if (a,b) in s: return true incl(s, (a,b)) if a.kind == b.kind: @@ -43,7 +43,7 @@ algorithm (in pseudo-code) determines type equality: a.callingConvention == b.callingConvention proc typeEquals(a, b: PType): bool = - var s: set[PType * PType] = {} + var s: HashSet[(PType, PType)] = {} result = typeEqualsAux(a, b, s) Since types are graphs which can have cycles, the above algorithm needs an diff --git a/doc/manual/types.txt b/doc/manual/types.txt index bdf51941d..81ae9d6b4 100644 --- a/doc/manual/types.txt +++ b/doc/manual/types.txt @@ -803,7 +803,7 @@ exclude ``nil`` as a valid value with the ``not nil`` annotation: p(x) The compiler ensures that every code path initializes variables which contain -not nilable pointers. The details of this analysis are still to be specified +non nilable pointers. The details of this analysis are still to be specified here. @@ -963,7 +963,7 @@ Most calling conventions exist only for the Windows 32-bit platform. Assigning/passing a procedure to a procedural variable is only allowed if one of the following conditions hold: 1) The procedure that is accessed resides in the current module. -2) The procedure is marked with the ``procvar`` pragma (see `procvar pragma`_). +2) The procedure is marked with the ``procvar`` pragma (see `procvar pragma <#pragmas-procvar-pragma>`_). 3) The procedure has a calling convention that differs from ``nimcall``. 4) The procedure is anonymous. @@ -1132,7 +1132,7 @@ that don't. Distinct types provide a means to introduce a new string type It is an essential property of abstract types that they **do not** imply a -subtype relation between the abtract type and its base type. Explict type +subtype relation between the abstract type and its base type. Explicit type conversions from ``string`` to ``SQL`` are allowed: .. code-block:: nim diff --git a/doc/spawn.txt b/doc/spawn.txt index fb2f851c7..36bd02e96 100644 --- a/doc/spawn.txt +++ b/doc/spawn.txt @@ -33,7 +33,7 @@ variables at the same time: # wait until 2 out of 3 servers received the update: proc main = - var responses = newSeq[RawFlowVar](3) + var responses = newSeq[FlowVarBase](3) for i in 0..2: responses[i] = spawn tellServer(Update, "key", "value") var index = awaitAny(responses) diff --git a/doc/tut1.txt b/doc/tut1.txt index cb5a0c8dd..1fa495054 100644 --- a/doc/tut1.txt +++ b/doc/tut1.txt @@ -16,7 +16,7 @@ Introduction </p></blockquote> -This document is a tutorial for the programming language *Nim*. +This document is a tutorial for the programming language *Nim*. This tutorial assumes that you are familiar with basic programming concepts like variables, types or statements but is kept very basic. The `manual <manual.html>`_ contains many more examples of the advanced language features. @@ -50,7 +50,7 @@ Commonly used commands and switches have abbreviations, so you can also use:: nim c -r greetings.nim To compile a release version use:: - + nim c -d:release greetings.nim By default the Nim compiler generates a large amount of runtime checks @@ -116,7 +116,7 @@ hash character ``#``. Documentation comments start with ``##``: .. code-block:: nim # A comment. - + var myVariable: int ## a documentation comment @@ -200,7 +200,7 @@ constant declaration at compile time: .. code-block:: nim const x = "abc" # the constant x contains the string "abc" - + Indentation can be used after the ``const`` keyword to list a whole section of constants: @@ -214,7 +214,7 @@ constants: The let statement ================= -The ``let`` statement works like the ``var`` statement but the declared +The ``let`` statement works like the ``var`` statement but the declared symbols are *single assignment* variables: After the initialization their value cannot change: @@ -228,7 +228,7 @@ and put it into a data section": .. code-block:: const input = readLine(stdin) # Error: constant expression expected - + .. code-block:: let input = readLine(stdin) # works @@ -310,8 +310,8 @@ the compiler that for every other value nothing should be done: else: discard The empty `discard statement`_ is a *do nothing* statement. The compiler knows -that a case statement with an else part cannot fail and thus the error -disappears. Note that it is impossible to cover all possible string values: +that a case statement with an else part cannot fail and thus the error +disappears. Note that it is impossible to cover all possible string values: that is why string cases always need an ``else`` branch. In general the case statement is used for subrange types or enumerations where @@ -406,7 +406,7 @@ The block's *label* (``myblock`` in the example) is optional. Break statement --------------- A block can be left prematurely with a ``break`` statement. The break statement -can leave a ``while``, ``for``, or a ``block`` statement. It leaves the +can leave a ``while``, ``for``, or a ``block`` statement. It leaves the innermost construct, unless a label of a block is given: .. code-block:: nim @@ -461,7 +461,7 @@ differences: * The statements within a branch do not open a new scope. * The compiler checks the semantics and produces code *only* for the statements that belong to the first condition that evaluates to ``true``. - + The ``when`` statement is useful for writing platform specific code, similar to the ``#ifdef`` construct in the C programming language. @@ -486,14 +486,14 @@ to be indented, but single simple statements do not: .. code-block:: nim # no indentation needed for single assignment statement: if x: x = false - + # indentation needed for nested if statement: if x: if y: y = false else: y = true - + # indentation needed, because two statements follow the condition: if x: x = false @@ -514,7 +514,7 @@ contain indentation at certain places for better readability: As a rule of thumb, indentation within expressions is allowed after operators, an open parenthesis and after commas. -With parenthesis and semicolons ``(;)`` you can use statements where only +With parenthesis and semicolons ``(;)`` you can use statements where only an expression is allowed: .. code-block:: nim @@ -560,45 +560,45 @@ Some terminology: in the example ``question`` is called a (formal) *parameter*, Result variable --------------- -A procedure that returns a value has an implicit ``result`` variable declared +A procedure that returns a value has an implicit ``result`` variable declared that represents the return value. A ``return`` statement with no expression is a -shorthand for ``return result``. The ``result`` value is always returned +shorthand for ``return result``. The ``result`` value is always returned automatically at the end a procedure if there is no ``return`` statement at the exit. .. code-block:: nim - proc sumTillNegative(x: varargs[int]): int = + proc sumTillNegative(x: varargs[int]): int = for i in x: if i < 0: return - result = result + i - + result = result + i + echo sumTillNegative() # echos 0 echo sumTillNegative(3, 4, 5) # echos 12 echo sumTillNegative(3, 4 , -1 , 6) # echos 7 -The ``result`` variable is already implicitly declared at the start of the +The ``result`` variable is already implicitly declared at the start of the function, so declaring it again with 'var result', for example, would shadow it with a normal variable of the same name. The result variable is also already initialised with the type's default value. Note that referential data types will be ``nil`` at the start of the procedure, and thus may require manual initialisation. - + Parameters ---------- Parameters are constant in the procedure body. By default, their value cannot be -changed because this allows the compiler to implement parameter passing in the +changed because this allows the compiler to implement parameter passing in the most efficient way. If a mutable variable is needed inside the procedure, it has to be declared with ``var`` in the procedure body. Shadowing the parameter name -is possible, and actually an idiom: +is possible, and actually an idiom: .. code-block:: nim proc printSeq(s: seq, nprinted: int = -1) = var nprinted = if nprinted == -1: s.len else: min(nprinted, s.len) for i in 0 .. <nprinted: echo s[i] - + If the procedure needs to modify the argument for the caller, a ``var`` parameter can be used: @@ -630,12 +630,12 @@ allow to silently throw away a return value: The return value can be ignored implicitly if the called proc/iterator has -been declared with the ``discardable`` pragma: +been declared with the ``discardable`` pragma: .. code-block:: nim - proc p(x, y: int): int {.discardable.} = + proc p(x, y: int): int {.discardable.} = return x + y - + p(3, 4) # now valid The ``discard`` statement can also be used to create block comments as @@ -899,7 +899,7 @@ object on the heap, so there is a trade-off to be made here. Integers -------- -Nim has these integer types built-in: +Nim has these integer types built-in: ``int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64``. The default integer type is ``int``. Integer literals can have a *type suffix* @@ -1114,7 +1114,7 @@ Arrays An array is a simple fixed length container. Each element in the array has the same type. The array's index type can be any ordinal type. -Arrays can be constructed via ``[]``: +Arrays can be constructed via ``[]``: .. code-block:: nim @@ -1303,7 +1303,7 @@ type conversions in this context: myWriteln(stdout, 123, "abc", 4.0) # is transformed by the compiler to: - myWriteln(stdout, [$123, $"def", $4.0]) + myWriteln(stdout, [$123, $"abc", $4.0]) In this example `$ <system.html#$>`_ is applied to any argument that is passed to the parameter ``a``. Note that `$ <system.html#$>`_ applied to strings is a @@ -1325,7 +1325,7 @@ define operators which accept Slice objects to define ranges. b = "Slices are useless." echo a[7..12] # --> 'a prog' - b[11.. -2] = "useful" + b[11.. ^2] = "useful" echo b # --> 'Slices are useful.' In the previous example slices are used to modify a part of a string, and even @@ -1370,12 +1370,12 @@ integer. var building: tuple[street: string, number: int] building = ("Rue del Percebe", 13) echo(building.street) - + # The following line does not compile, they are different tuples! #person = building # --> Error: type mismatch: got (tuple[street: string, number: int]) # but expected 'Person' - + # The following works because the field names and types are the same. var teacher: tuple[name: string, age: int] = ("Mark", 42) person = teacher @@ -1450,13 +1450,13 @@ operators perform implicit dereferencing operations for reference types: type Node = ref NodeObj - NodeObj = object - le, ri: PNode + NodeObj = object + le, ri: Node data: int var n: Node new(n) - n.data = 9 + n.data = 9 # no need to write n[].data; in fact n[].data is highly discouraged! To allocate a new traced object, the built-in procedure ``new`` has to be used. @@ -1559,9 +1559,9 @@ This is best illustrated by an example: A symbol of a module *can* be *qualified* with the ``module.symbol`` syntax. If -the symbol is ambiguous, it even *has* to be qualified. A symbol is ambiguous -if it is defined in two (or more) different modules and both modules are -imported by a third one: +the symbol is ambiguous, it even *has* to be qualified. A symbol is ambiguous +if it is defined in two (or more) different modules and both modules are +imported by a third one: .. code-block:: nim # Module A diff --git a/koch.nim b/koch.nim index 55019b544..fc292401a 100644 --- a/koch.nim +++ b/koch.nim @@ -47,6 +47,7 @@ Possible Commands: csource [options] builds the C sources for installation pdf builds the PDF documentation zip builds the installation ZIP package + xz builds the installation XZ package nsis [options] builds the NSIS Setup installer (for Windows) tests [options] run the testsuite update updates nim to the latest version from github @@ -106,10 +107,10 @@ proc zip(args: string) = exec("$# --var:version=$# --var:mingw=none --main:compiler/nim.nim zip compiler/installer.ini" % ["tools/niminst/niminst".exe, VersionAsString]) -proc targz(args: string) = +proc xz(args: string) = exec("$3 cc -r $2 --var:version=$1 --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" % [VersionAsString, compileNimInst, findNim()]) - exec("$# --var:version=$# --var:mingw=none --main:compiler/nim.nim targz compiler/installer.ini" % + exec("$# --var:version=$# --var:mingw=none --main:compiler/nim.nim xz compiler/installer.ini" % ["tools" / "niminst" / "niminst".exe, VersionAsString]) proc buildTool(toolname, args: string) = @@ -333,8 +334,10 @@ proc tests(args: string) = # taint mode test :-) exec "nim cc --taintMode:on tests/testament/tester" let tester = quoteShell(getCurrentDir() / "tests/testament/tester".exe) - exec tester & " " & (args|"all") + let success = tryExec tester & " " & (args|"all") exec tester & " html" + if not success: + quit("tests failed", QuitFailure) proc temp(args: string) = var output = "compiler" / "nim".exe @@ -365,7 +368,7 @@ of cmdArgument: of "pdf": pdf() of "csource", "csources": csource(op.cmdLineRest) of "zip": zip(op.cmdLineRest) - of "targz": targz(op.cmdLineRest) + of "xz": xz(op.cmdLineRest) of "nsis": nsis(op.cmdLineRest) of "install": install(op.cmdLineRest) of "test", "tests": tests(op.cmdLineRest) diff --git a/lib/core/locks.nim b/lib/core/locks.nim index 8a809fc84..12f289e74 100644 --- a/lib/core/locks.nim +++ b/lib/core/locks.nim @@ -1,7 +1,7 @@ # # # Nim's Runtime Library -# (c) Copyright 2012 Andreas Rumpf +# (c) Copyright 2015 Andreas Rumpf # # See the file "copying.txt", included in this # distribution, for details about the copyright. @@ -12,56 +12,46 @@ include "system/syslocks" type - TLock* = TSysLock ## Nim lock; whether this is re-entrant + Lock* = SysLock ## Nim lock; whether this is re-entrant ## or not is unspecified! - TCond* = TSysCond ## Nim condition variable - - LockEffect* {.deprecated.} = object of RootEffect ## \ - ## effect that denotes that some lock operation - ## is performed. Deprecated, do not use anymore! - AquireEffect* {.deprecated.} = object of LockEffect ## \ - ## effect that denotes that some lock is - ## acquired. Deprecated, do not use anymore! - ReleaseEffect* {.deprecated.} = object of LockEffect ## \ - ## effect that denotes that some lock is - ## released. Deprecated, do not use anymore! -{.deprecated: [FLock: LockEffect, FAquireLock: AquireEffect, - FReleaseLock: ReleaseEffect].} -proc initLock*(lock: var TLock) {.inline.} = + Cond* = SysCond ## Nim condition variable + +{.deprecated: [TLock: Lock, TCond: Cond].} + +proc initLock*(lock: var Lock) {.inline.} = ## Initializes the given lock. initSysLock(lock) -proc deinitLock*(lock: var TLock) {.inline.} = +proc deinitLock*(lock: var Lock) {.inline.} = ## Frees the resources associated with the lock. deinitSys(lock) -proc tryAcquire*(lock: var TLock): bool = +proc tryAcquire*(lock: var Lock): bool = ## Tries to acquire the given lock. Returns `true` on success. result = tryAcquireSys(lock) -proc acquire*(lock: var TLock) = +proc acquire*(lock: var Lock) = ## Acquires the given lock. acquireSys(lock) - -proc release*(lock: var TLock) = + +proc release*(lock: var Lock) = ## Releases the given lock. releaseSys(lock) -proc initCond*(cond: var TCond) {.inline.} = +proc initCond*(cond: var Cond) {.inline.} = ## Initializes the given condition variable. initSysCond(cond) -proc deinitCond*(cond: var TCond) {.inline.} = +proc deinitCond*(cond: var Cond) {.inline.} = ## Frees the resources associated with the lock. deinitSysCond(cond) -proc wait*(cond: var TCond, lock: var TLock) {.inline.} = - ## waits on the condition variable `cond`. +proc wait*(cond: var Cond, lock: var Lock) {.inline.} = + ## waits on the condition variable `cond`. waitSysCond(cond, lock) - -proc signal*(cond: var TCond) {.inline.} = - ## sends a signal to the condition variable `cond`. - signalSysCond(cond) +proc signal*(cond: var Cond) {.inline.} = + ## sends a signal to the condition variable `cond`. + signalSysCond(cond) diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 35f0f61c1..7e6e4ccc9 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -177,6 +177,12 @@ proc getType*(n: NimNode): NimNode {.magic: "NGetType", noSideEffect.} ## resolve recursive types, you have to call 'getType' again. To see what ## kind of type it is, call `typeKind` on getType's result. +proc getType*(n: typedesc): NimNode {.magic: "NGetType", noSideEffect.} + ## Returns the Nim type node for given type. This can be used to turn macro + ## typedesc parameter into proper NimNode representing type, since typedesc + ## are an exception in macro calls - they are not mapped implicitly to + ## NimNode like any other arguments. + proc typeKind*(n: NimNode): NimTypeKind {.magic: "NGetType", noSideEffect.} ## Returns the type kind of the node 'n' that should represent a type, that ## means the node should have been obtained via `getType`. diff --git a/lib/core/typeinfo.nim b/lib/core/typeinfo.nim index f08f74c20..ab150b2a4 100644 --- a/lib/core/typeinfo.nim +++ b/lib/core/typeinfo.nim @@ -9,7 +9,7 @@ ## This module implements an interface to Nim's `runtime type information`:idx: ## (`RTTI`:idx:). -## Note that even though ``TAny`` and its operations hide the nasty low level +## Note that even though ``Any`` and its operations hide the nasty low level ## details from its clients, it remains inherently unsafe! ## ## See the `marshal <marshal.html>`_ module for what this module allows you @@ -23,7 +23,7 @@ include "system/hti.nim" {.pop.} type - TAnyKind* = enum ## what kind of ``any`` it is + AnyKind* = enum ## what kind of ``any`` it is akNone = 0, ## invalid any akBool = 1, ## any represents a ``bool`` akChar = 2, ## any represents a ``char`` @@ -55,9 +55,9 @@ type akUInt32 = 43, ## any represents an unsigned int32 akUInt64 = 44, ## any represents an unsigned int64 - TAny* = object ## can represent any nim value; NOTE: the wrapped + Any* = object ## can represent any nim value; NOTE: the wrapped ## value can be modified with its wrapper! This means - ## that ``TAny`` keeps a non-traced pointer to its + ## that ``Any`` keeps a non-traced pointer to its ## wrapped value and **must not** live longer than ## its wrapped value. value: pointer @@ -69,6 +69,7 @@ type TGenericSeq {.importc.} = object len, space: int PGenSeq = ptr TGenericSeq +{.deprecated: [TAny: Any, TAnyKind: AnyKind].} const GenericSeqSize = (2 * sizeof(int)) @@ -103,58 +104,58 @@ proc selectBranch(aa: pointer, n: ptr TNimNode): ptr TNimNode = else: result = n.sons[n.len] -proc newAny(value: pointer, rawType: PNimType): TAny = +proc newAny(value: pointer, rawType: PNimType): Any = result.value = value result.rawType = rawType -when declared(system.TVarSlot): - proc toAny*(x: TVarSlot): TAny {.inline.} = - ## constructs a ``TAny`` object from a variable slot ``x``. +when declared(system.VarSlot): + proc toAny*(x: VarSlot): Any {.inline.} = + ## constructs a ``Any`` object from a variable slot ``x``. ## This captures `x`'s address, so `x` can be modified with its - ## ``TAny`` wrapper! The client needs to ensure that the wrapper + ## ``Any`` wrapper! The client needs to ensure that the wrapper ## **does not** live longer than `x`! ## This is provided for easier reflection capabilities of a debugger. result.value = x.address result.rawType = x.typ -proc toAny*[T](x: var T): TAny {.inline.} = - ## constructs a ``TAny`` object from `x`. This captures `x`'s address, so - ## `x` can be modified with its ``TAny`` wrapper! The client needs to ensure +proc toAny*[T](x: var T): Any {.inline.} = + ## constructs a ``Any`` object from `x`. This captures `x`'s address, so + ## `x` can be modified with its ``Any`` wrapper! The client needs to ensure ## that the wrapper **does not** live longer than `x`! result.value = addr(x) result.rawType = cast[PNimType](getTypeInfo(x)) -proc kind*(x: TAny): TAnyKind {.inline.} = +proc kind*(x: Any): AnyKind {.inline.} = ## get the type kind - result = TAnyKind(ord(x.rawType.kind)) + result = AnyKind(ord(x.rawType.kind)) -proc size*(x: TAny): int {.inline.} = +proc size*(x: Any): int {.inline.} = ## returns the size of `x`'s type. result = x.rawType.size -proc baseTypeKind*(x: TAny): TAnyKind {.inline.} = +proc baseTypeKind*(x: Any): AnyKind {.inline.} = ## get the base type's kind; ``akNone`` is returned if `x` has no base type. if x.rawType.base != nil: - result = TAnyKind(ord(x.rawType.base.kind)) + result = AnyKind(ord(x.rawType.base.kind)) -proc baseTypeSize*(x: TAny): int {.inline.} = +proc baseTypeSize*(x: Any): int {.inline.} = ## returns the size of `x`'s basetype. if x.rawType.base != nil: result = x.rawType.base.size -proc invokeNew*(x: TAny) = +proc invokeNew*(x: Any) = ## performs ``new(x)``. `x` needs to represent a ``ref``. assert x.rawType.kind == tyRef var z = newObj(x.rawType, x.rawType.base.size) genericAssign(x.value, addr(z), x.rawType) -proc invokeNewSeq*(x: TAny, len: int) = +proc invokeNewSeq*(x: Any, len: int) = ## performs ``newSeq(x, len)``. `x` needs to represent a ``seq``. assert x.rawType.kind == tySequence var z = newSeq(x.rawType, len) genericShallowAssign(x.value, addr(z), x.rawType) -proc extendSeq*(x: TAny) = +proc extendSeq*(x: Any) = ## performs ``setLen(x, x.len+1)``. `x` needs to represent a ``seq``. assert x.rawType.kind == tySequence var y = cast[ptr PGenSeq](x.value)[] @@ -164,7 +165,7 @@ proc extendSeq*(x: TAny) = cast[ppointer](x.value)[] = z #genericShallowAssign(x.value, addr(z), x.rawType) -proc setObjectRuntimeType*(x: TAny) = +proc setObjectRuntimeType*(x: Any) = ## this needs to be called to set `x`'s runtime object type field. assert x.rawType.kind == tyObject objectInit(x.value, x.rawType) @@ -173,7 +174,7 @@ proc skipRange(x: PNimType): PNimType {.inline.} = result = x if result.kind == tyRange: result = result.base -proc `[]`*(x: TAny, i: int): TAny = +proc `[]`*(x: Any, i: int): Any = ## accessor for an any `x` that represents an array or a sequence. case x.rawType.kind of tyArray: @@ -190,7 +191,7 @@ proc `[]`*(x: TAny, i: int): TAny = return newAny(s +!! (GenericSeqSize+i*bs), x.rawType.base) else: assert false -proc `[]=`*(x: TAny, i: int, y: TAny) = +proc `[]=`*(x: Any, i: int, y: Any) = ## accessor for an any `x` that represents an array or a sequence. case x.rawType.kind of tyArray: @@ -209,7 +210,7 @@ proc `[]=`*(x: TAny, i: int, y: TAny) = genericAssign(s +!! (GenericSeqSize+i*bs), y.value, y.rawType) else: assert false -proc len*(x: TAny): int = +proc len*(x: Any): int = ## len for an any `x` that represents an array or a sequence. case x.rawType.kind of tyArray: result = x.rawType.size div x.rawType.base.size @@ -217,20 +218,20 @@ proc len*(x: TAny): int = else: assert false -proc base*(x: TAny): TAny = - ## returns base TAny (useful for inherited object types). +proc base*(x: Any): Any = + ## returns base Any (useful for inherited object types). result.rawType = x.rawType.base result.value = x.value -proc isNil*(x: TAny): bool = +proc isNil*(x: Any): bool = ## `isNil` for an any `x` that represents a sequence, string, cstring, ## proc or some pointer type. assert x.rawType.kind in {tyString, tyCString, tyRef, tyPtr, tyPointer, tySequence, tyProc} result = isNil(cast[ppointer](x.value)[]) -proc getPointer*(x: TAny): pointer = +proc getPointer*(x: Any): pointer = ## retrieve the pointer value out of `x`. ``x`` needs to be of kind ## ``akString``, ``akCString``, ``akProc``, ``akRef``, ``akPtr``, ## ``akPointer``, ``akSequence``. @@ -238,7 +239,7 @@ proc getPointer*(x: TAny): pointer = tySequence, tyProc} result = cast[ppointer](x.value)[] -proc setPointer*(x: TAny, y: pointer) = +proc setPointer*(x: Any, y: pointer) = ## sets the pointer value of `x`. ``x`` needs to be of kind ## ``akString``, ``akCString``, ``akProc``, ``akRef``, ``akPtr``, ## ``akPointer``, ``akSequence``. @@ -247,7 +248,7 @@ proc setPointer*(x: TAny, y: pointer) = cast[ppointer](x.value)[] = y proc fieldsAux(p: pointer, n: ptr TNimNode, - ret: var seq[tuple[name: cstring, any: TAny]]) = + ret: var seq[tuple[name: cstring, any: Any]]) = case n.kind of nkNone: assert(false) of nkSlot: @@ -260,7 +261,7 @@ proc fieldsAux(p: pointer, n: ptr TNimNode, ret.add((n.name, newAny(p +!! n.offset, n.typ))) if m != nil: fieldsAux(p, m, ret) -iterator fields*(x: TAny): tuple[name: string, any: TAny] = +iterator fields*(x: Any): tuple[name: string, any: Any] = ## iterates over every active field of the any `x` that represents an object ## or a tuple. assert x.rawType.kind in {tyTuple, tyObject} @@ -269,7 +270,7 @@ iterator fields*(x: TAny): tuple[name: string, any: TAny] = # XXX BUG: does not work yet, however is questionable anyway when false: if x.rawType.kind == tyObject: t = cast[ptr PNimType](x.value)[] - var ret: seq[tuple[name: cstring, any: TAny]] = @[] + var ret: seq[tuple[name: cstring, any: Any]] = @[] if t.kind == tyObject: while true: fieldsAux(p, t.node, ret) @@ -314,7 +315,7 @@ proc getFieldNode(p: pointer, n: ptr TNimNode, var m = selectBranch(p, n) if m != nil: result = getFieldNode(p, m, name) -proc `[]=`*(x: TAny, fieldName: string, value: TAny) = +proc `[]=`*(x: Any, fieldName: string, value: Any) = ## sets a field of `x`; `x` represents an object or a tuple. var t = x.rawType # XXX BUG: does not work yet, however is questionable anyway @@ -328,7 +329,7 @@ proc `[]=`*(x: TAny, fieldName: string, value: TAny) = else: raise newException(ValueError, "invalid field name: " & fieldName) -proc `[]`*(x: TAny, fieldName: string): TAny = +proc `[]`*(x: Any, fieldName: string): Any = ## gets a field of `x`; `x` represents an object or a tuple. var t = x.rawType # XXX BUG: does not work yet, however is questionable anyway @@ -344,44 +345,44 @@ proc `[]`*(x: TAny, fieldName: string): TAny = else: raise newException(ValueError, "invalid field name: " & fieldName) -proc `[]`*(x: TAny): TAny = +proc `[]`*(x: Any): Any = ## dereference operation for the any `x` that represents a ptr or a ref. assert x.rawType.kind in {tyRef, tyPtr} result.value = cast[ppointer](x.value)[] result.rawType = x.rawType.base -proc `[]=`*(x, y: TAny) = +proc `[]=`*(x, y: Any) = ## dereference operation for the any `x` that represents a ptr or a ref. assert x.rawType.kind in {tyRef, tyPtr} assert y.rawType == x.rawType.base genericAssign(cast[ppointer](x.value)[], y.value, y.rawType) -proc getInt*(x: TAny): int = +proc getInt*(x: Any): int = ## retrieve the int value out of `x`. `x` needs to represent an int. assert skipRange(x.rawType).kind == tyInt result = cast[ptr int](x.value)[] -proc getInt8*(x: TAny): int8 = +proc getInt8*(x: Any): int8 = ## retrieve the int8 value out of `x`. `x` needs to represent an int8. assert skipRange(x.rawType).kind == tyInt8 result = cast[ptr int8](x.value)[] -proc getInt16*(x: TAny): int16 = +proc getInt16*(x: Any): int16 = ## retrieve the int16 value out of `x`. `x` needs to represent an int16. assert skipRange(x.rawType).kind == tyInt16 result = cast[ptr int16](x.value)[] -proc getInt32*(x: TAny): int32 = +proc getInt32*(x: Any): int32 = ## retrieve the int32 value out of `x`. `x` needs to represent an int32. assert skipRange(x.rawType).kind == tyInt32 result = cast[ptr int32](x.value)[] -proc getInt64*(x: TAny): int64 = +proc getInt64*(x: Any): int64 = ## retrieve the int64 value out of `x`. `x` needs to represent an int64. assert skipRange(x.rawType).kind == tyInt64 result = cast[ptr int64](x.value)[] -proc getBiggestInt*(x: TAny): BiggestInt = +proc getBiggestInt*(x: Any): BiggestInt = ## retrieve the integer value out of `x`. `x` needs to represent ## some integer, a bool, a char, an enum or a small enough bit set. ## The value might be sign-extended to ``BiggestInt``. @@ -407,7 +408,7 @@ proc getBiggestInt*(x: TAny): BiggestInt = of tyUInt32: result = BiggestInt(cast[ptr uint32](x.value)[]) else: assert false -proc setBiggestInt*(x: TAny, y: BiggestInt) = +proc setBiggestInt*(x: Any, y: BiggestInt) = ## sets the integer value of `x`. `x` needs to represent ## some integer, a bool, a char, an enum or a small enough bit set. var t = skipRange(x.rawType) @@ -432,36 +433,36 @@ proc setBiggestInt*(x: TAny, y: BiggestInt) = of tyUInt32: cast[ptr uint32](x.value)[] = uint32(y) else: assert false -proc getUInt*(x: TAny): uint = +proc getUInt*(x: Any): uint = ## retrieve the uint value out of `x`, `x` needs to represent an uint. assert skipRange(x.rawType).kind == tyUInt result = cast[ptr uint](x.value)[] -proc getUInt8*(x: TAny): uint8 = +proc getUInt8*(x: Any): uint8 = ## retrieve the uint8 value out of `x`, `x` needs to represent an ## uint8. assert skipRange(x.rawType).kind == tyUInt8 result = cast[ptr uint8](x.value)[] -proc getUInt16*(x: TAny): uint16 = +proc getUInt16*(x: Any): uint16 = ## retrieve the uint16 value out of `x`, `x` needs to represent an ## uint16. assert skipRange(x.rawType).kind == tyUInt16 result = cast[ptr uint16](x.value)[] -proc getUInt32*(x: TAny): uint32 = +proc getUInt32*(x: Any): uint32 = ## retrieve the uint32 value out of `x`, `x` needs to represent an ## uint32. assert skipRange(x.rawType).kind == tyUInt32 result = cast[ptr uint32](x.value)[] -proc getUInt64*(x: TAny): uint64 = +proc getUInt64*(x: Any): uint64 = ## retrieve the uint64 value out of `x`, `x` needs to represent an ## uint64. assert skipRange(x.rawType).kind == tyUInt64 result = cast[ptr uint64](x.value)[] -proc getBiggestUint*(x: TAny): uint64 = +proc getBiggestUint*(x: Any): uint64 = ## retrieve the unsigned integer value out of `x`. `x` needs to ## represent an unsigned integer. var t = skipRange(x.rawType) @@ -473,7 +474,7 @@ proc getBiggestUint*(x: TAny): uint64 = of tyUInt64: result = uint64(cast[ptr uint64](x.value)[]) else: assert false -proc setBiggestUint*(x: TAny; y: uint64) = +proc setBiggestUint*(x: Any; y: uint64) = ## sets the unsigned integer value of `c`. `c` needs to represent an ## unsigned integer. var t = skipRange(x.rawType) @@ -485,25 +486,25 @@ proc setBiggestUint*(x: TAny; y: uint64) = of tyUInt64: cast[ptr uint64](x.value)[] = uint64(y) else: assert false -proc getChar*(x: TAny): char = +proc getChar*(x: Any): char = ## retrieve the char value out of `x`. `x` needs to represent a char. var t = skipRange(x.rawType) assert t.kind == tyChar result = cast[ptr char](x.value)[] -proc getBool*(x: TAny): bool = +proc getBool*(x: Any): bool = ## retrieve the bool value out of `x`. `x` needs to represent a bool. var t = skipRange(x.rawType) assert t.kind == tyBool result = cast[ptr bool](x.value)[] -proc skipRange*(x: TAny): TAny = +proc skipRange*(x: Any): Any = ## skips the range information of `x`. assert x.rawType.kind == tyRange result.rawType = x.rawType.base result.value = x.value -proc getEnumOrdinal*(x: TAny, name: string): int = +proc getEnumOrdinal*(x: Any, name: string): int = ## gets the enum field ordinal from `name`. `x` needs to represent an enum ## but is only used to access the type information. In case of an error ## ``low(int)`` is returned. @@ -519,7 +520,7 @@ proc getEnumOrdinal*(x: TAny, name: string): int = return s[i].offset result = low(int) -proc getEnumField*(x: TAny, ordinalValue: int): string = +proc getEnumField*(x: Any, ordinalValue: int): string = ## gets the enum field name as a string. `x` needs to represent an enum ## but is only used to access the type information. The field name of ## `ordinalValue` is returned. @@ -537,26 +538,26 @@ proc getEnumField*(x: TAny, ordinalValue: int): string = if s[i].offset == e: return $s[i].name result = $e -proc getEnumField*(x: TAny): string = +proc getEnumField*(x: Any): string = ## gets the enum field name as a string. `x` needs to represent an enum. result = getEnumField(x, getBiggestInt(x).int) -proc getFloat*(x: TAny): float = +proc getFloat*(x: Any): float = ## retrieve the float value out of `x`. `x` needs to represent an float. assert skipRange(x.rawType).kind == tyFloat result = cast[ptr float](x.value)[] -proc getFloat32*(x: TAny): float32 = +proc getFloat32*(x: Any): float32 = ## retrieve the float32 value out of `x`. `x` needs to represent an float32. assert skipRange(x.rawType).kind == tyFloat32 result = cast[ptr float32](x.value)[] -proc getFloat64*(x: TAny): float64 = +proc getFloat64*(x: Any): float64 = ## retrieve the float64 value out of `x`. `x` needs to represent an float64. assert skipRange(x.rawType).kind == tyFloat64 result = cast[ptr float64](x.value)[] -proc getBiggestFloat*(x: TAny): BiggestFloat = +proc getBiggestFloat*(x: Any): BiggestFloat = ## retrieve the float value out of `x`. `x` needs to represent ## some float. The value is extended to ``BiggestFloat``. case skipRange(x.rawType).kind @@ -565,7 +566,7 @@ proc getBiggestFloat*(x: TAny): BiggestFloat = of tyFloat64: result = BiggestFloat(cast[ptr float64](x.value)[]) else: assert false -proc setBiggestFloat*(x: TAny, y: BiggestFloat) = +proc setBiggestFloat*(x: Any, y: BiggestFloat) = ## sets the float value of `x`. `x` needs to represent ## some float. case skipRange(x.rawType).kind @@ -574,29 +575,29 @@ proc setBiggestFloat*(x: TAny, y: BiggestFloat) = of tyFloat64: cast[ptr float64](x.value)[] = y else: assert false -proc getString*(x: TAny): string = +proc getString*(x: Any): string = ## retrieve the string value out of `x`. `x` needs to represent a string. assert x.rawType.kind == tyString if not isNil(cast[ptr pointer](x.value)[]): result = cast[ptr string](x.value)[] -proc setString*(x: TAny, y: string) = +proc setString*(x: Any, y: string) = ## sets the string value of `x`. `x` needs to represent a string. assert x.rawType.kind == tyString cast[ptr string](x.value)[] = y -proc getCString*(x: TAny): cstring = +proc getCString*(x: Any): cstring = ## retrieve the cstring value out of `x`. `x` needs to represent a cstring. assert x.rawType.kind == tyCString result = cast[ptr cstring](x.value)[] -proc assign*(x, y: TAny) = - ## copies the value of `y` to `x`. The assignment operator for ``TAny`` +proc assign*(x, y: Any) = + ## copies the value of `y` to `x`. The assignment operator for ``Any`` ## does NOT do this; it performs a shallow copy instead! assert y.rawType == x.rawType genericAssign(x.value, y.value, y.rawType) -iterator elements*(x: TAny): int = +iterator elements*(x: Any): int = ## iterates over every element of `x` that represents a Nim bitset. assert x.rawType.kind == tySet var typ = x.rawType @@ -618,7 +619,7 @@ iterator elements*(x: TAny): int = if (u and (1'i64 shl int64(i))) != 0'i64: yield i+typ.node.len -proc inclSetElement*(x: TAny, elem: int) = +proc inclSetElement*(x: Any, elem: int) = ## includes an element `elem` in `x`. `x` needs to represent a Nim bitset. assert x.rawType.kind == tySet var typ = x.rawType diff --git a/lib/impure/db_mysql.nim b/lib/impure/db_mysql.nim index b8180cd87..619c2a656 100644 --- a/lib/impure/db_mysql.nim +++ b/lib/impure/db_mysql.nim @@ -13,27 +13,28 @@ import strutils, mysql type - TDbConn* = PMySQL ## encapsulates a database connection - TRow* = seq[string] ## a row of a dataset. NULL database values will be + DbConn* = PMySQL ## encapsulates a database connection + Row* = seq[string] ## a row of a dataset. NULL database values will be ## transformed always to the empty string. EDb* = object of IOError ## exception that is raised if a database error occurs - TSqlQuery* = distinct string ## an SQL query string + SqlQuery* = distinct string ## an SQL query string FDb* = object of IOEffect ## effect that denotes a database operation FReadDb* = object of FDb ## effect that denotes a read operation FWriteDb* = object of FDb ## effect that denotes a write operation +{.deprecated: [TRow: Row, TSqlQuery: SqlQuery, TDbConn: DbConn].} -proc sql*(query: string): TSqlQuery {.noSideEffect, inline.} = - ## constructs a TSqlQuery from the string `query`. This is supposed to be +proc sql*(query: string): SqlQuery {.noSideEffect, inline.} = + ## constructs a SqlQuery from the string `query`. This is supposed to be ## used as a raw-string-literal modifier: ## ``sql"update user set counter = counter + 1"`` ## ## If assertions are turned off, it does nothing. If assertions are turned ## on, later versions will check the string for valid syntax. - result = TSqlQuery(query) + result = SqlQuery(query) -proc dbError(db: TDbConn) {.noreturn.} = +proc dbError(db: DbConn) {.noreturn.} = ## raises an EDb exception. var e: ref EDb new(e) @@ -48,7 +49,7 @@ proc dbError*(msg: string) {.noreturn.} = raise e when false: - proc dbQueryOpt*(db: TDbConn, query: string, args: varargs[string, `$`]) = + proc dbQueryOpt*(db: DbConn, query: string, args: varargs[string, `$`]) = var stmt = mysql_stmt_init(db) if stmt == nil: dbError(db) if mysql_stmt_prepare(stmt, query, len(query)) != 0: @@ -65,7 +66,7 @@ proc dbQuote*(s: string): string = else: add(result, c) add(result, '\'') -proc dbFormat(formatstr: TSqlQuery, args: varargs[string]): string = +proc dbFormat(formatstr: SqlQuery, args: varargs[string]): string = result = "" var a = 0 for c in items(string(formatstr)): @@ -78,23 +79,23 @@ proc dbFormat(formatstr: TSqlQuery, args: varargs[string]): string = else: add(result, c) -proc tryExec*(db: TDbConn, query: TSqlQuery, args: varargs[string, `$`]): bool {. +proc tryExec*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): bool {. tags: [FReadDB, FWriteDb].} = ## tries to execute the query and returns true if successful, false otherwise. var q = dbFormat(query, args) return mysql.realQuery(db, q, q.len) == 0'i32 -proc rawExec(db: TDbConn, query: TSqlQuery, args: varargs[string, `$`]) = +proc rawExec(db: DbConn, query: SqlQuery, args: varargs[string, `$`]) = var q = dbFormat(query, args) if mysql.realQuery(db, q, q.len) != 0'i32: dbError(db) -proc exec*(db: TDbConn, query: TSqlQuery, args: varargs[string, `$`]) {. +proc exec*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]) {. tags: [FReadDB, FWriteDb].} = ## executes the query and raises EDB if not successful. var q = dbFormat(query, args) if mysql.realQuery(db, q, q.len) != 0'i32: dbError(db) -proc newRow(L: int): TRow = +proc newRow(L: int): Row = newSeq(result, L) for i in 0..L-1: result[i] = "" @@ -103,8 +104,8 @@ proc properFreeResult(sqlres: mysql.PRES, row: cstringArray) = while mysql.fetchRow(sqlres) != nil: discard mysql.freeResult(sqlres) -iterator fastRows*(db: TDbConn, query: TSqlQuery, - args: varargs[string, `$`]): TRow {.tags: [FReadDB].} = +iterator fastRows*(db: DbConn, query: SqlQuery, + args: varargs[string, `$`]): Row {.tags: [FReadDB].} = ## executes the query and iterates over the result dataset. This is very ## fast, but potenially dangerous: If the for-loop-body executes another ## query, the results can be undefined. For MySQL this is the case!. @@ -126,10 +127,10 @@ iterator fastRows*(db: TDbConn, query: TSqlQuery, yield result properFreeResult(sqlres, row) -proc getRow*(db: TDbConn, query: TSqlQuery, - args: varargs[string, `$`]): TRow {.tags: [FReadDB].} = +proc getRow*(db: DbConn, query: SqlQuery, + args: varargs[string, `$`]): Row {.tags: [FReadDB].} = ## retrieves a single row. If the query doesn't return any rows, this proc - ## will return a TRow with empty strings for each column. + ## will return a Row with empty strings for each column. rawExec(db, query, args) var sqlres = mysql.useResult(db) if sqlres != nil: @@ -145,8 +146,8 @@ proc getRow*(db: TDbConn, query: TSqlQuery, add(result[i], row[i]) properFreeResult(sqlres, row) -proc getAllRows*(db: TDbConn, query: TSqlQuery, - args: varargs[string, `$`]): seq[TRow] {.tags: [FReadDB].} = +proc getAllRows*(db: DbConn, query: SqlQuery, + args: varargs[string, `$`]): seq[Row] {.tags: [FReadDB].} = ## executes the query and returns the whole result dataset. result = @[] rawExec(db, query, args) @@ -168,12 +169,12 @@ proc getAllRows*(db: TDbConn, query: TSqlQuery, inc(j) mysql.freeResult(sqlres) -iterator rows*(db: TDbConn, query: TSqlQuery, - args: varargs[string, `$`]): TRow {.tags: [FReadDB].} = +iterator rows*(db: DbConn, query: SqlQuery, + args: varargs[string, `$`]): Row {.tags: [FReadDB].} = ## same as `fastRows`, but slower and safe. for r in items(getAllRows(db, query, args)): yield r -proc getValue*(db: TDbConn, query: TSqlQuery, +proc getValue*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): string {.tags: [FReadDB].} = ## executes the query and returns the first column of the first row of the ## result dataset. Returns "" if the dataset contains no rows or the database @@ -183,7 +184,7 @@ proc getValue*(db: TDbConn, query: TSqlQuery, result = row[0] break -proc tryInsertId*(db: TDbConn, query: TSqlQuery, +proc tryInsertId*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): int64 {.tags: [FWriteDb].} = ## executes the query (typically "INSERT") and returns the ## generated ID for the row or -1 in case of an error. @@ -193,14 +194,14 @@ proc tryInsertId*(db: TDbConn, query: TSqlQuery, else: result = mysql.insertId(db) -proc insertId*(db: TDbConn, query: TSqlQuery, +proc insertId*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): int64 {.tags: [FWriteDb].} = ## executes the query (typically "INSERT") and returns the ## generated ID for the row. result = tryInsertID(db, query, args) if result < 0: dbError(db) -proc execAffectedRows*(db: TDbConn, query: TSqlQuery, +proc execAffectedRows*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): int64 {. tags: [FReadDB, FWriteDb].} = ## runs the query (typically "UPDATE") and returns the @@ -208,11 +209,11 @@ proc execAffectedRows*(db: TDbConn, query: TSqlQuery, rawExec(db, query, args) result = mysql.affectedRows(db) -proc close*(db: TDbConn) {.tags: [FDb].} = +proc close*(db: DbConn) {.tags: [FDb].} = ## closes the database connection. if db != nil: mysql.close(db) -proc open*(connection, user, password, database: string): TDbConn {. +proc open*(connection, user, password, database: string): DbConn {. tags: [FDb].} = ## opens a database connection. Raises `EDb` if the connection could not ## be established. @@ -230,8 +231,8 @@ proc open*(connection, user, password, database: string): TDbConn {. db_mysql.close(result) dbError(errmsg) -proc setEncoding*(connection: TDbConn, encoding: string): bool {. +proc setEncoding*(connection: DbConn, encoding: string): bool {. tags: [FDb].} = ## sets the encoding of a database connection, returns true for ## success, false for failure. - result = mysql.set_character_set(connection, encoding) == 0 \ No newline at end of file + result = mysql.set_character_set(connection, encoding) == 0 diff --git a/lib/impure/db_postgres.nim b/lib/impure/db_postgres.nim index ffb8bbcda..774cb1510 100644 --- a/lib/impure/db_postgres.nim +++ b/lib/impure/db_postgres.nim @@ -13,28 +13,30 @@ import strutils, postgres type - TDbConn* = PPGconn ## encapsulates a database connection - TRow* = seq[string] ## a row of a dataset. NULL database values will be + DbConn* = PPGconn ## encapsulates a database connection + Row* = seq[string] ## a row of a dataset. NULL database values will be ## transformed always to the empty string. EDb* = object of IOError ## exception that is raised if a database error occurs - TSqlQuery* = distinct string ## an SQL query string - TSqlPrepared* = distinct string ## a identifier for the prepared queries + SqlQuery* = distinct string ## an SQL query string + SqlPrepared* = distinct string ## a identifier for the prepared queries FDb* = object of IOEffect ## effect that denotes a database operation FReadDb* = object of FDb ## effect that denotes a read operation FWriteDb* = object of FDb ## effect that denotes a write operation +{.deprecated: [TRow: Row, TSqlQuery: SqlQuery, TDbConn: DbConn, + TSqlPrepared: SqlPrepared].} -proc sql*(query: string): TSqlQuery {.noSideEffect, inline.} = - ## constructs a TSqlQuery from the string `query`. This is supposed to be +proc sql*(query: string): SqlQuery {.noSideEffect, inline.} = + ## constructs a SqlQuery from the string `query`. This is supposed to be ## used as a raw-string-literal modifier: ## ``sql"update user set counter = counter + 1"`` ## ## If assertions are turned off, it does nothing. If assertions are turned ## on, later versions will check the string for valid syntax. - result = TSqlQuery(query) + result = SqlQuery(query) -proc dbError*(db: TDbConn) {.noreturn.} = +proc dbError*(db: DbConn) {.noreturn.} = ## raises an EDb exception. var e: ref EDb new(e) @@ -56,7 +58,7 @@ proc dbQuote*(s: string): string = else: add(result, c) add(result, '\'') -proc dbFormat(formatstr: TSqlQuery, args: varargs[string]): string = +proc dbFormat(formatstr: SqlQuery, args: varargs[string]): string = result = "" var a = 0 for c in items(string(formatstr)): @@ -69,7 +71,7 @@ proc dbFormat(formatstr: TSqlQuery, args: varargs[string]): string = else: add(result, c) -proc tryExec*(db: TDbConn, query: TSqlQuery, +proc tryExec*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): bool {.tags: [FReadDB, FWriteDb].} = ## tries to execute the query and returns true if successful, false otherwise. var arr = allocCStringArray(args) @@ -79,7 +81,7 @@ proc tryExec*(db: TDbConn, query: TSqlQuery, result = pqresultStatus(res) == PGRES_COMMAND_OK pqclear(res) -proc exec*(db: TDbConn, query: TSqlQuery, args: varargs[string, `$`]) {. +proc exec*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]) {. tags: [FReadDB, FWriteDb].} = ## executes the query and raises EDB if not successful. var arr = allocCStringArray(args) @@ -89,7 +91,7 @@ proc exec*(db: TDbConn, query: TSqlQuery, args: varargs[string, `$`]) {. if pqresultStatus(res) != PGRES_COMMAND_OK: dbError(db) pqclear(res) -proc exec*(db: TDbConn, stmtName: TSqlPrepared, +proc exec*(db: DbConn, stmtName: SqlPrepared, args: varargs[string]) {.tags: [FReadDB, FWriteDb].} = var arr = allocCStringArray(args) var res = pqexecPrepared(db, stmtName.string, int32(args.len), arr, @@ -98,11 +100,11 @@ proc exec*(db: TDbConn, stmtName: TSqlPrepared, if pqResultStatus(res) != PGRES_COMMAND_OK: dbError(db) pqclear(res) -proc newRow(L: int): TRow = +proc newRow(L: int): Row = newSeq(result, L) for i in 0..L-1: result[i] = "" -proc setupQuery(db: TDbConn, query: TSqlQuery, +proc setupQuery(db: DbConn, query: SqlQuery, args: varargs[string]): PPGresult = var arr = allocCStringArray(args) result = pqexecParams(db, query.string, int32(args.len), nil, arr, @@ -110,7 +112,7 @@ proc setupQuery(db: TDbConn, query: TSqlQuery, deallocCStringArray(arr) if pqResultStatus(result) != PGRES_TUPLES_OK: dbError(db) -proc setupQuery(db: TDbConn, stmtName: TSqlPrepared, +proc setupQuery(db: DbConn, stmtName: SqlPrepared, args: varargs[string]): PPGresult = var arr = allocCStringArray(args) result = pqexecPrepared(db, stmtName.string, int32(args.len), arr, @@ -118,13 +120,13 @@ proc setupQuery(db: TDbConn, stmtName: TSqlPrepared, deallocCStringArray(arr) if pqResultStatus(result) != PGRES_TUPLES_OK: dbError(db) -proc prepare*(db: TDbConn; stmtName: string, query: TSqlQuery; - nParams: int): TSqlPrepared = +proc prepare*(db: DbConn; stmtName: string, query: SqlQuery; + nParams: int): SqlPrepared = var res = pqprepare(db, stmtName, query.string, int32(nParams), nil) if pqResultStatus(res) != PGRES_COMMAND_OK: dbError(db) - return TSqlPrepared(stmtName) + return SqlPrepared(stmtName) -proc setRow(res: PPGresult, r: var TRow, line, cols: int32) = +proc setRow(res: PPGresult, r: var Row, line, cols: int32) = for col in 0..cols-1: setLen(r[col], 0) let x = pqgetvalue(res, line, col) @@ -133,8 +135,8 @@ proc setRow(res: PPGresult, r: var TRow, line, cols: int32) = else: add(r[col], x) -iterator fastRows*(db: TDbConn, query: TSqlQuery, - args: varargs[string, `$`]): TRow {.tags: [FReadDB].} = +iterator fastRows*(db: DbConn, query: SqlQuery, + args: varargs[string, `$`]): Row {.tags: [FReadDB].} = ## executes the query and iterates over the result dataset. This is very ## fast, but potenially dangerous: If the for-loop-body executes another ## query, the results can be undefined. For Postgres it is safe though. @@ -146,8 +148,8 @@ iterator fastRows*(db: TDbConn, query: TSqlQuery, yield result pqclear(res) -iterator fastRows*(db: TDbConn, stmtName: TSqlPrepared, - args: varargs[string, `$`]): TRow {.tags: [FReadDB].} = +iterator fastRows*(db: DbConn, stmtName: SqlPrepared, + args: varargs[string, `$`]): Row {.tags: [FReadDB].} = ## executes the prepared query and iterates over the result dataset. var res = setupQuery(db, stmtName, args) var L = pqNfields(res) @@ -157,44 +159,44 @@ iterator fastRows*(db: TDbConn, stmtName: TSqlPrepared, yield result pqClear(res) -proc getRow*(db: TDbConn, query: TSqlQuery, - args: varargs[string, `$`]): TRow {.tags: [FReadDB].} = +proc getRow*(db: DbConn, query: SqlQuery, + args: varargs[string, `$`]): Row {.tags: [FReadDB].} = ## retrieves a single row. If the query doesn't return any rows, this proc - ## will return a TRow with empty strings for each column. + ## will return a Row with empty strings for each column. var res = setupQuery(db, query, args) var L = pqnfields(res) result = newRow(L) setRow(res, result, 0, L) pqclear(res) -proc getRow*(db: TDbConn, stmtName: TSqlPrepared, - args: varargs[string, `$`]): TRow {.tags: [FReadDB].} = +proc getRow*(db: DbConn, stmtName: SqlPrepared, + args: varargs[string, `$`]): Row {.tags: [FReadDB].} = var res = setupQuery(db, stmtName, args) var L = pqNfields(res) result = newRow(L) setRow(res, result, 0, L) pqClear(res) -proc getAllRows*(db: TDbConn, query: TSqlQuery, - args: varargs[string, `$`]): seq[TRow] {.tags: [FReadDB].} = +proc getAllRows*(db: DbConn, query: SqlQuery, + args: varargs[string, `$`]): seq[Row] {.tags: [FReadDB].} = ## executes the query and returns the whole result dataset. result = @[] for r in fastRows(db, query, args): result.add(r) -proc getAllRows*(db: TDbConn, stmtName: TSqlPrepared, - args: varargs[string, `$`]): seq[TRow] {.tags: [FReadDB].} = +proc getAllRows*(db: DbConn, stmtName: SqlPrepared, + args: varargs[string, `$`]): seq[Row] {.tags: [FReadDB].} = ## executes the prepared query and returns the whole result dataset. result = @[] for r in fastRows(db, stmtName, args): result.add(r) -iterator rows*(db: TDbConn, query: TSqlQuery, - args: varargs[string, `$`]): TRow {.tags: [FReadDB].} = +iterator rows*(db: DbConn, query: SqlQuery, + args: varargs[string, `$`]): Row {.tags: [FReadDB].} = ## same as `fastRows`, but slower and safe. for r in items(getAllRows(db, query, args)): yield r -proc getValue*(db: TDbConn, query: TSqlQuery, +proc getValue*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): string {.tags: [FReadDB].} = ## executes the query and returns the first column of the first row of the ## result dataset. Returns "" if the dataset contains no rows or the database @@ -202,20 +204,20 @@ proc getValue*(db: TDbConn, query: TSqlQuery, var x = pqgetvalue(setupQuery(db, query, args), 0, 0) result = if isNil(x): "" else: $x -proc tryInsertID*(db: TDbConn, query: TSqlQuery, +proc tryInsertID*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): int64 {.tags: [FWriteDb].}= ## executes the query (typically "INSERT") and returns the ## generated ID for the row or -1 in case of an error. For Postgre this adds ## ``RETURNING id`` to the query, so it only works if your primary key is ## named ``id``. - var x = pqgetvalue(setupQuery(db, TSqlQuery(string(query) & " RETURNING id"), + var x = pqgetvalue(setupQuery(db, SqlQuery(string(query) & " RETURNING id"), args), 0, 0) if not isNil(x): result = parseBiggestInt($x) else: result = -1 -proc insertID*(db: TDbConn, query: TSqlQuery, +proc insertID*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): int64 {.tags: [FWriteDb].} = ## executes the query (typically "INSERT") and returns the ## generated ID for the row. For Postgre this adds @@ -224,7 +226,7 @@ proc insertID*(db: TDbConn, query: TSqlQuery, result = tryInsertID(db, query, args) if result < 0: dbError(db) -proc execAffectedRows*(db: TDbConn, query: TSqlQuery, +proc execAffectedRows*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): int64 {.tags: [ FReadDB, FWriteDb].} = ## executes the query (typically "UPDATE") and returns the @@ -235,11 +237,11 @@ proc execAffectedRows*(db: TDbConn, query: TSqlQuery, result = parseBiggestInt($pqcmdTuples(res)) pqclear(res) -proc close*(db: TDbConn) {.tags: [FDb].} = +proc close*(db: DbConn) {.tags: [FDb].} = ## closes the database connection. if db != nil: pqfinish(db) -proc open*(connection, user, password, database: string): TDbConn {. +proc open*(connection, user, password, database: string): DbConn {. tags: [FDb].} = ## opens a database connection. Raises `EDb` if the connection could not ## be established. @@ -261,8 +263,8 @@ proc open*(connection, user, password, database: string): TDbConn {. result = pqsetdbLogin(nil, nil, nil, nil, database, user, password) if pqStatus(result) != CONNECTION_OK: dbError(result) # result = nil -proc setEncoding*(connection: TDbConn, encoding: string): bool {. +proc setEncoding*(connection: DbConn, encoding: string): bool {. tags: [FDb].} = ## sets the encoding of a database connection, returns true for ## success, false for failure. - return pqsetClientEncoding(connection, encoding) == 0 \ No newline at end of file + return pqsetClientEncoding(connection, encoding) == 0 diff --git a/lib/impure/db_sqlite.nim b/lib/impure/db_sqlite.nim index 8536ab6f2..47e7c1900 100644 --- a/lib/impure/db_sqlite.nim +++ b/lib/impure/db_sqlite.nim @@ -13,27 +13,28 @@ import strutils, sqlite3 type - TDbConn* = PSqlite3 ## encapsulates a database connection - TRow* = seq[string] ## a row of a dataset. NULL database values will be + DbConn* = PSqlite3 ## encapsulates a database connection + Row* = seq[string] ## a row of a dataset. NULL database values will be ## transformed always to the empty string. EDb* = object of IOError ## exception that is raised if a database error occurs - TSqlQuery* = distinct string ## an SQL query string + SqlQuery* = distinct string ## an SQL query string FDb* = object of IOEffect ## effect that denotes a database operation FReadDb* = object of FDb ## effect that denotes a read operation FWriteDb* = object of FDb ## effect that denotes a write operation +{.deprecated: [TRow: Row, TSqlQuery: SqlQuery, TDbConn: DbConn].} -proc sql*(query: string): TSqlQuery {.noSideEffect, inline.} = - ## constructs a TSqlQuery from the string `query`. This is supposed to be +proc sql*(query: string): SqlQuery {.noSideEffect, inline.} = + ## constructs a SqlQuery from the string `query`. This is supposed to be ## used as a raw-string-literal modifier: ## ``sql"update user set counter = counter + 1"`` ## ## If assertions are turned off, it does nothing. If assertions are turned ## on, later versions will check the string for valid syntax. - result = TSqlQuery(query) + result = SqlQuery(query) -proc dbError(db: TDbConn) {.noreturn.} = +proc dbError(db: DbConn) {.noreturn.} = ## raises an EDb exception. var e: ref EDb new(e) @@ -55,7 +56,7 @@ proc dbQuote(s: string): string = else: add(result, c) add(result, '\'') -proc dbFormat(formatstr: TSqlQuery, args: varargs[string]): string = +proc dbFormat(formatstr: SqlQuery, args: varargs[string]): string = result = "" var a = 0 for c in items(string(formatstr)): @@ -65,7 +66,7 @@ proc dbFormat(formatstr: TSqlQuery, args: varargs[string]): string = else: add(result, c) -proc tryExec*(db: TDbConn, query: TSqlQuery, +proc tryExec*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): bool {.tags: [FReadDb, FWriteDb].} = ## tries to execute the query and returns true if successful, false otherwise. var q = dbFormat(query, args) @@ -74,29 +75,29 @@ proc tryExec*(db: TDbConn, query: TSqlQuery, if step(stmt) == SQLITE_DONE: result = finalize(stmt) == SQLITE_OK -proc exec*(db: TDbConn, query: TSqlQuery, args: varargs[string, `$`]) {. +proc exec*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]) {. tags: [FReadDb, FWriteDb].} = ## executes the query and raises EDB if not successful. if not tryExec(db, query, args): dbError(db) -proc newRow(L: int): TRow = +proc newRow(L: int): Row = newSeq(result, L) for i in 0..L-1: result[i] = "" -proc setupQuery(db: TDbConn, query: TSqlQuery, +proc setupQuery(db: DbConn, query: SqlQuery, args: varargs[string]): Pstmt = var q = dbFormat(query, args) if prepare_v2(db, q, q.len.cint, result, nil) != SQLITE_OK: dbError(db) -proc setRow(stmt: Pstmt, r: var TRow, cols: cint) = +proc setRow(stmt: Pstmt, r: var Row, cols: cint) = for col in 0..cols-1: setLen(r[col], column_bytes(stmt, col)) # set capacity setLen(r[col], 0) let x = column_text(stmt, col) if not isNil(x): add(r[col], x) -iterator fastRows*(db: TDbConn, query: TSqlQuery, - args: varargs[string, `$`]): TRow {.tags: [FReadDb].} = +iterator fastRows*(db: DbConn, query: SqlQuery, + args: varargs[string, `$`]): Row {.tags: [FReadDb].} = ## executes the query and iterates over the result dataset. This is very ## fast, but potenially dangerous: If the for-loop-body executes another ## query, the results can be undefined. For Sqlite it is safe though. @@ -108,10 +109,10 @@ iterator fastRows*(db: TDbConn, query: TSqlQuery, yield result if finalize(stmt) != SQLITE_OK: dbError(db) -proc getRow*(db: TDbConn, query: TSqlQuery, - args: varargs[string, `$`]): TRow {.tags: [FReadDb].} = +proc getRow*(db: DbConn, query: SqlQuery, + args: varargs[string, `$`]): Row {.tags: [FReadDb].} = ## retrieves a single row. If the query doesn't return any rows, this proc - ## will return a TRow with empty strings for each column. + ## will return a Row with empty strings for each column. var stmt = setupQuery(db, query, args) var L = (column_count(stmt)) result = newRow(L) @@ -119,19 +120,19 @@ proc getRow*(db: TDbConn, query: TSqlQuery, setRow(stmt, result, L) if finalize(stmt) != SQLITE_OK: dbError(db) -proc getAllRows*(db: TDbConn, query: TSqlQuery, - args: varargs[string, `$`]): seq[TRow] {.tags: [FReadDb].} = +proc getAllRows*(db: DbConn, query: SqlQuery, + args: varargs[string, `$`]): seq[Row] {.tags: [FReadDb].} = ## executes the query and returns the whole result dataset. result = @[] for r in fastRows(db, query, args): result.add(r) -iterator rows*(db: TDbConn, query: TSqlQuery, - args: varargs[string, `$`]): TRow {.tags: [FReadDb].} = +iterator rows*(db: DbConn, query: SqlQuery, + args: varargs[string, `$`]): Row {.tags: [FReadDb].} = ## same as `FastRows`, but slower and safe. for r in fastRows(db, query, args): yield r -proc getValue*(db: TDbConn, query: TSqlQuery, +proc getValue*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): string {.tags: [FReadDb].} = ## executes the query and returns the first column of the first row of the ## result dataset. Returns "" if the dataset contains no rows or the database @@ -148,7 +149,7 @@ proc getValue*(db: TDbConn, query: TSqlQuery, result = "" if finalize(stmt) != SQLITE_OK: dbError(db) -proc tryInsertID*(db: TDbConn, query: TSqlQuery, +proc tryInsertID*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): int64 {.tags: [FWriteDb], raises: [].} = ## executes the query (typically "INSERT") and returns the @@ -162,7 +163,7 @@ proc tryInsertID*(db: TDbConn, query: TSqlQuery, if finalize(stmt) != SQLITE_OK: result = -1 -proc insertID*(db: TDbConn, query: TSqlQuery, +proc insertID*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): int64 {.tags: [FWriteDb].} = ## executes the query (typically "INSERT") and returns the ## generated ID for the row. For Postgre this adds @@ -171,7 +172,7 @@ proc insertID*(db: TDbConn, query: TSqlQuery, result = tryInsertID(db, query, args) if result < 0: dbError(db) -proc execAffectedRows*(db: TDbConn, query: TSqlQuery, +proc execAffectedRows*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): int64 {. tags: [FReadDb, FWriteDb].} = ## executes the query (typically "UPDATE") and returns the @@ -179,21 +180,21 @@ proc execAffectedRows*(db: TDbConn, query: TSqlQuery, exec(db, query, args) result = changes(db) -proc close*(db: TDbConn) {.tags: [FDb].} = +proc close*(db: DbConn) {.tags: [FDb].} = ## closes the database connection. if sqlite3.close(db) != SQLITE_OK: dbError(db) -proc open*(connection, user, password, database: string): TDbConn {. +proc open*(connection, user, password, database: string): DbConn {. tags: [FDb].} = ## opens a database connection. Raises `EDb` if the connection could not ## be established. Only the ``connection`` parameter is used for ``sqlite``. - var db: TDbConn + var db: DbConn if sqlite3.open(connection, db) == SQLITE_OK: result = db else: dbError(db) -proc setEncoding*(connection: TDbConn, encoding: string): bool {. +proc setEncoding*(connection: DbConn, encoding: string): bool {. tags: [FDb].} = ## sets the encoding of a database connection, returns true for ## success, false for failure. diff --git a/lib/impure/graphics.nim b/lib/impure/graphics.nim index 814c0ebe1..1b3d1d5b6 100644 --- a/lib/impure/graphics.nim +++ b/lib/impure/graphics.nim @@ -17,23 +17,24 @@ from sdl import PSurface # Bug from sdl_ttf import openFont, closeFont type - TRect* = tuple[x, y, width, height: int] - TPoint* = tuple[x, y: int] + Rect* = tuple[x, y, width, height: int] + Point* = tuple[x, y: int] - PSurface* = ref TSurface ## a surface to draw onto - TSurface* {.pure, final.} = object + PSurface* = ref Surface ## a surface to draw onto + Surface* {.pure, final.} = object w*, h*: Natural s*: sdl.PSurface EGraphics* = object of IOError - TFont {.pure, final.} = object + Font {.pure, final.} = object f: sdl_ttf.PFont - color: sdl.TColor - PFont* = ref TFont ## represents a font + color: sdl.Color + PFont* = ref Font ## represents a font +{.deprecated: [TSurface: Surface, TFont: Font, TRect: Rect, TPoint: Point].} -proc toSdlColor*(c: Color): sdl.TColor = - ## Convert colors.TColor to sdl.TColor +proc toSdlColor*(c: Color): sdl.Color = + ## Convert colors.Color to sdl.Color var x = c.extractRGB result.r = x.r and 0xff result.g = x.g and 0xff @@ -45,8 +46,8 @@ proc createSdlColor*(sur: PSurface, c: Color, alpha: int = 0): int32 = return sdl.mapRGBA(sur.s.format, x.r and 0xff, x.g and 0xff, x.b and 0xff, alpha and 0xff) -proc toSdlRect*(r: TRect): sdl.TRect = - ## Convert ``graphics.TRect`` to ``sdl.TRect``. +proc toSdlRect*(r: Rect): sdl.Rect = + ## Convert ``graphics.Rect`` to ``sdl.Rect``. result.x = int16(r.x) result.y = int16(r.y) result.w = uint16(r.width) @@ -103,8 +104,9 @@ proc writeToBMP*(sur: PSurface, filename: string) = raise newException(IOError, "cannot write: " & filename) type - TPixels = array[0..1000_000-1, int32] - PPixels = ptr TPixels + Pixels = array[0..1000_000-1, int32] + PPixels = ptr Pixels +{.deprecated: [TPixels: Pixels].} template setPix(video, pitch, x, y, col: expr): stmt = video[y * pitch + x] = int32(col) @@ -128,7 +130,7 @@ proc setPixel(sur: PSurface, x, y: Natural, col: colors.Color) {.inline.} = #pixs[y * (sur.s.pitch div colSize) + x] = int(col) setPix(pixs, sur.s.pitch.int div ColSize, x, y, col) -proc `[]`*(sur: PSurface, p: TPoint): Color = +proc `[]`*(sur: PSurface, p: Point): Color = ## get pixel at position `p`. No range checking is done! result = getPixel(sur, p.x, p.y) @@ -136,7 +138,7 @@ proc `[]`*(sur: PSurface, x, y: int): Color = ## get pixel at position ``(x, y)``. No range checking is done! result = getPixel(sur, x, y) -proc `[]=`*(sur: PSurface, p: TPoint, col: Color) = +proc `[]=`*(sur: PSurface, p: Point, col: Color) = ## set the pixel at position `p`. No range checking is done! setPixel(sur, p.x, p.y, col) @@ -144,10 +146,10 @@ proc `[]=`*(sur: PSurface, x, y: int, col: Color) = ## set the pixel at position ``(x, y)``. No range checking is done! setPixel(sur, x, y, col) -proc blit*(destSurf: PSurface, destRect: TRect, srcSurf: PSurface, - srcRect: TRect) = +proc blit*(destSurf: PSurface, destRect: Rect, srcSurf: PSurface, + srcRect: Rect) = ## Copies ``srcSurf`` into ``destSurf`` - var destTRect, srcTRect: sdl.TRect + var destTRect, srcTRect: sdl.Rect destTRect.x = int16(destRect.x) destTRect.y = int16(destRect.y) @@ -168,7 +170,7 @@ proc textBounds*(text: string, font = defaultFont): tuple[width, height: int] = result.width = int(w) result.height = int(h) -proc drawText*(sur: PSurface, p: TPoint, text: string, font = defaultFont) = +proc drawText*(sur: PSurface, p: Point, text: string, font = defaultFont) = ## Draws text with a transparent background, at location ``p`` with the given ## font. var textSur: PSurface # This surface will have the text drawn on it @@ -179,7 +181,7 @@ proc drawText*(sur: PSurface, p: TPoint, text: string, font = defaultFont) = # Merge the text surface with sur sur.blit((p.x, p.y, sur.w, sur.h), textSur, (0, 0, sur.w, sur.h)) -proc drawText*(sur: PSurface, p: TPoint, text: string, +proc drawText*(sur: PSurface, p: Point, text: string, bg: Color, font = defaultFont) = ## Draws text, at location ``p`` with font ``font``. ``bg`` ## is the background color. @@ -189,7 +191,7 @@ proc drawText*(sur: PSurface, p: TPoint, text: string, # Merge the text surface with sur sur.blit((p.x, p.y, sur.w, sur.h), textSur, (0, 0, sur.w, sur.h)) -proc drawCircle*(sur: PSurface, p: TPoint, r: Natural, color: Color) = +proc drawCircle*(sur: PSurface, p: Point, r: Natural, color: Color) = ## draws a circle with center `p` and radius `r` with the given color ## onto the surface `sur`. var video = cast[PPixels](sur.s.pixels) @@ -229,7 +231,7 @@ proc `>-<`(val: int, s: PSurface): int {.inline.} = proc `>|<`(val: int, s: PSurface): int {.inline.} = return if val < 0: 0 elif val >= s.h: s.h-1 else: val -proc drawLine*(sur: PSurface, p1, p2: TPoint, color: Color) = +proc drawLine*(sur: PSurface, p1, p2: Point, color: Color) = ## draws a line between the two points `p1` and `p2` with the given color ## onto the surface `sur`. var stepx, stepy: int = 0 @@ -291,7 +293,7 @@ proc drawVerLine*(sur: PSurface, x, y, h: Natural, color: Color) = for i in 0 .. min(sur.s.h-y, h)-1: setPix(video, pitch, x, y + i, color) -proc fillCircle*(s: PSurface, p: TPoint, r: Natural, color: Color) = +proc fillCircle*(s: PSurface, p: Point, r: Natural, color: Color) = ## draws a circle with center `p` and radius `r` with the given color ## onto the surface `sur` and fills it. var a = 1 - r @@ -319,7 +321,7 @@ proc fillCircle*(s: PSurface, p: TPoint, r: Natural, color: Color) = drawVerLine(s, x - py - 1, y - px, px, color) px = px + 1 -proc drawRect*(sur: PSurface, r: TRect, color: Color) = +proc drawRect*(sur: PSurface, r: Rect, color: Color) = ## draws a rectangle. var video = cast[PPixels](sur.s.pixels) var pitch = sur.s.pitch.int div ColSize @@ -337,7 +339,7 @@ proc drawRect*(sur: PSurface, r: TRect, color: Color) = setPix(video, pitch, r.x, r.y + i, color) setPix(video, pitch, r.x + minW - 1, r.y + i, color) # Draw right side -proc fillRect*(sur: PSurface, r: TRect, col: Color) = +proc fillRect*(sur: PSurface, r: Rect, col: Color) = ## Fills a rectangle using sdl's ``FillRect`` function. var rect = toSdlRect(r) if sdl.fillRect(sur.s, addr(rect), sur.createSdlColor(col)) == -1: @@ -424,7 +426,7 @@ template cround(x: expr): expr = ipart(x + 0.5) template fpart(x: expr): expr = x - ipart(x) template rfpart(x: expr): expr = 1.0 - fpart(x) -proc drawLineAA*(sur: PSurface, p1, p2: TPoint, color: Color) = +proc drawLineAA*(sur: PSurface, p1, p2: Point, color: Color) = ## Draws a anti-aliased line from ``p1`` to ``p2``, using Xiaolin Wu's ## line algorithm var (x1, x2, y1, y2) = (p1.x.toFloat(), p2.x.toFloat(), @@ -490,9 +492,9 @@ proc fillSurface*(sur: PSurface, color: Color) = template withEvents*(surf: PSurface, event: expr, actions: stmt): stmt {. immediate.} = ## Simple template which creates an event loop. ``Event`` is the name of the - ## variable containing the TEvent object. + ## variable containing the Event object. while true: - var event: sdl.TEvent + var event: sdl.Event if sdl.waitEvent(addr(event)) == 1: actions diff --git a/lib/impure/rdstdin.nim b/lib/impure/rdstdin.nim index f4d00979c..dfe3e22eb 100644 --- a/lib/impure/rdstdin.nim +++ b/lib/impure/rdstdin.nim @@ -135,7 +135,7 @@ else: var cur, old: Termios discard fd.tcgetattr(cur.addr) old = cur - cur.c_lflag = cur.c_lflag and not Tcflag(ECHO) + cur.c_lflag = cur.c_lflag and not Cflag(ECHO) discard fd.tcsetattr(TCSADRAIN, cur.addr) stdout.write prompt result = stdin.readLine(password) diff --git a/lib/impure/re.nim b/lib/impure/re.nim index fb95610f6..279f8aadd 100644 --- a/lib/impure/re.nim +++ b/lib/impure/re.nim @@ -146,8 +146,8 @@ proc findBounds*(s: string, pattern: Regex, proc findBounds*(s: string, pattern: Regex, start = 0): tuple[first, last: int] = - ## returns the starting position of `pattern` in `s`. If it does not - ## match, ``(-1,0)`` is returned. + ## returns the starting position and end position of ``pattern`` in ``s``. + ## If it does not match, ``(-1,0)`` is returned. var rtarray = initRtArray[cint](3) rawMatches = rtarray.getRawData diff --git a/lib/impure/ssl.nim b/lib/impure/ssl.nim index d318a1979..079a2c3a2 100644 --- a/lib/impure/ssl.nim +++ b/lib/impure/ssl.nim @@ -15,11 +15,12 @@ import openssl, strutils, os type - TSecureSocket* = object + SecureSocket* = object ssl: SslPtr bio: BIO +{.deprecated: [TSecureSocket: SecureSocket].} -proc connect*(sock: var TSecureSocket, address: string, +proc connect*(sock: var SecureSocket, address: string, port: int): int = ## Connects to the specified `address` on the specified `port`. ## Returns the result of the certificate validation. @@ -52,7 +53,7 @@ proc connect*(sock: var TSecureSocket, address: string, result = SSL_get_verify_result(sock.ssl) -proc recvLine*(sock: TSecureSocket, line: var TaintedString): bool = +proc recvLine*(sock: SecureSocket, line: var TaintedString): bool = ## Acts in a similar fashion to the `recvLine` in the sockets module. ## Returns false when no data is available to be read. ## `Line` must be initialized and not nil! @@ -71,19 +72,19 @@ proc recvLine*(sock: TSecureSocket, line: var TaintedString): bool = add(line.string, c) -proc send*(sock: TSecureSocket, data: string) = +proc send*(sock: SecureSocket, data: string) = ## Writes `data` to the socket. if BIO_write(sock.bio, data, data.len.cint) <= 0: raiseOSError(osLastError()) -proc close*(sock: TSecureSocket) = +proc close*(sock: SecureSocket) = ## Closes the socket if BIO_free(sock.bio) <= 0: ERR_print_errors_fp(stderr) raiseOSError(osLastError()) when not defined(testing) and isMainModule: - var s: TSecureSocket + var s: SecureSocket echo connect(s, "smtp.gmail.com", 465) #var buffer: array[0..255, char] diff --git a/lib/impure/zipfiles.nim b/lib/impure/zipfiles.nim index c22294061..d8903f5c1 100644 --- a/lib/impure/zipfiles.nim +++ b/lib/impure/zipfiles.nim @@ -9,23 +9,23 @@ ## This module implements a zip archive creator/reader/modifier. -import - streams, libzip, times, os +import + streams, libzip, times, os, strutils type - TZipArchive* = object of RootObj ## represents a zip archive + ZipArchive* = object of RootObj ## represents a zip archive mode: FileMode w: PZip +{.deprecated: [TZipArchive: ZipArchive].} - -proc zipError(z: var TZipArchive) = +proc zipError(z: var ZipArchive) = var e: ref IOError new(e) e.msg = $zip_strerror(z.w) raise e - -proc open*(z: var TZipArchive, filename: string, mode: FileMode = fmRead): bool = - ## Opens a zip file for reading, writing or appending. All file modes are + +proc open*(z: var ZipArchive, filename: string, mode: FileMode = fmRead): bool = + ## Opens a zip file for reading, writing or appending. All file modes are ## supported. Returns true iff successful, false otherwise. var err, flags: int32 case mode @@ -38,24 +38,24 @@ proc open*(z: var TZipArchive, filename: string, mode: FileMode = fmRead): bool z.mode = mode result = z.w != nil -proc close*(z: var TZipArchive) = +proc close*(z: var ZipArchive) = ## Closes a zip file. zip_close(z.w) - -proc createDir*(z: var TZipArchive, dir: string) = + +proc createDir*(z: var ZipArchive, dir: string) = ## Creates a directory within the `z` archive. This does not fail if the - ## directory already exists. Note that for adding a file like + ## directory already exists. Note that for adding a file like ## ``"path1/path2/filename"`` it is not necessary - ## to create the ``"path/path2"`` subdirectories - it will be done - ## automatically by ``addFile``. - assert(z.mode != fmRead) + ## to create the ``"path/path2"`` subdirectories - it will be done + ## automatically by ``addFile``. + assert(z.mode != fmRead) discard zip_add_dir(z.w, dir) zip_error_clear(z.w) -proc addFile*(z: var TZipArchive, dest, src: string) = +proc addFile*(z: var ZipArchive, dest, src: string) = ## Adds the file `src` to the archive `z` with the name `dest`. `dest` - ## may contain a path that will be created. - assert(z.mode != fmRead) + ## may contain a path that will be created. + assert(z.mode != fmRead) if not fileExists(src): raise newException(IOError, "File '" & src & "' does not exist") var zipsrc = zip_source_file(z.w, src, 0, -1) @@ -67,26 +67,26 @@ proc addFile*(z: var TZipArchive, dest, src: string) = zip_source_free(zipsrc) zipError(z) -proc addFile*(z: var TZipArchive, file: string) = +proc addFile*(z: var ZipArchive, file: string) = ## A shortcut for ``addFile(z, file, file)``, i.e. the name of the source is ## the name of the destination. addFile(z, file, file) - -proc mySourceCallback(state, data: pointer, len: int, - cmd: TZipSourceCmd): int {.cdecl.} = + +proc mySourceCallback(state, data: pointer, len: int, + cmd: ZipSourceCmd): int {.cdecl.} = var src = cast[Stream](state) case cmd - of ZIP_SOURCE_OPEN: + of ZIP_SOURCE_OPEN: if src.setPositionImpl != nil: setPosition(src, 0) # reset of ZIP_SOURCE_READ: result = readData(src, data, len) of ZIP_SOURCE_CLOSE: close(src) - of ZIP_SOURCE_STAT: + of ZIP_SOURCE_STAT: var stat = cast[PZipStat](data) zip_stat_init(stat) stat.size = high(int32)-1 # we don't know the size stat.mtime = getTime() - result = sizeof(TZipStat) + result = sizeof(ZipStat) of ZIP_SOURCE_ERROR: var err = cast[ptr array[0..1, cint]](data) err[0] = ZIP_ER_INTERNAL @@ -94,8 +94,8 @@ proc mySourceCallback(state, data: pointer, len: int, result = 2*sizeof(cint) of constZIP_SOURCE_FREE: GC_unref(src) else: assert(false) - -proc addFile*(z: var TZipArchive, dest: string, src: Stream) = + +proc addFile*(z: var ZipArchive, dest: string, src: Stream) = ## Adds a file named with `dest` to the archive `z`. `dest` ## may contain a path. The file's content is read from the `src` stream. assert(z.mode != fmRead) @@ -105,39 +105,45 @@ proc addFile*(z: var TZipArchive, dest: string, src: Stream) = if zip_add(z.w, dest, zipsrc) < 0'i32: zip_source_free(zipsrc) zipError(z) - + # -------------- zip file stream --------------------------------------------- type TZipFileStream = object of StreamObj f: PZipFile + atEnd: bool - PZipFileStream* = - ref TZipFileStream ## a reader stream of a file within a zip archive + PZipFileStream* = + ref TZipFileStream ## a reader stream of a file within a zip archive proc fsClose(s: Stream) = zip_fclose(PZipFileStream(s).f) -proc fsReadData(s: Stream, buffer: pointer, bufLen: int): int = +proc fsAtEnd(s: Stream): bool = PZipFileStream(s).atEnd +proc fsReadData(s: Stream, buffer: pointer, bufLen: int): int = result = zip_fread(PZipFileStream(s).f, buffer, bufLen) + if result == 0: + PZipFileStream(s).atEnd = true -proc newZipFileStream(f: PZipFile): PZipFileStream = +proc newZipFileStream(f: PZipFile): PZipFileStream = new(result) result.f = f + result.atEnd = false result.closeImpl = fsClose result.readDataImpl = fsReadData + result.atEndImpl = fsAtEnd # other methods are nil! # ---------------------------------------------------------------------------- - -proc getStream*(z: var TZipArchive, filename: string): PZipFileStream = + +proc getStream*(z: var ZipArchive, filename: string): PZipFileStream = ## returns a stream that can be used to read the file named `filename` ## from the archive `z`. Returns nil in case of an error. - ## The returned stream does not support the `setPosition`, `getPosition`, + ## The returned stream does not support the `setPosition`, `getPosition`, ## `writeData` or `atEnd` methods. var x = zip_fopen(z.w, filename, 0'i32) if x != nil: result = newZipFileStream(x) - -iterator walkFiles*(z: var TZipArchive): string = - ## walks over all files in the archive `z` and returns the filename + +iterator walkFiles*(z: var ZipArchive): string = + ## walks over all files in the archive `z` and returns the filename ## (including the path). var i = 0'i32 var num = zip_get_num_files(z.w) @@ -146,7 +152,7 @@ iterator walkFiles*(z: var TZipArchive): string = inc(i) -proc extractFile*(z: var TZipArchive, srcFile: string, dest: Stream) = +proc extractFile*(z: var ZipArchive, srcFile: string, dest: Stream) = ## extracts a file from the zip archive `z` to the destination stream. var strm = getStream(z, srcFile) while true: @@ -156,14 +162,22 @@ proc extractFile*(z: var TZipArchive, srcFile: string, dest: Stream) = dest.flush() strm.close() -proc extractFile*(z: var TZipArchive, srcFile: string, dest: string) = +proc extractFile*(z: var ZipArchive, srcFile: string, dest: string) = ## extracts a file from the zip archive `z` to the destination filename. - var file = newFileStream(dest, fmReadWrite) + var file = newFileStream(dest, fmWrite) extractFile(z, srcFile, file) file.close() -proc extractAll*(z: var TZipArchive, dest: string) = +proc extractAll*(z: var ZipArchive, dest: string) = ## extracts all files from archive `z` to the destination directory. for file in walkFiles(z): - extractFile(z, file, dest / extractFilename(file)) - + if file.endsWith("/"): + createDir(dest / file) + else: + extractFile(z, file, dest / file) + +when not defined(testing) and isMainModule: + var zip: ZipArchive + if not zip.open("nim-0.11.0.zip"): + raise newException(IOError, "opening zip failed") + zip.extractAll("test") diff --git a/lib/packages/docutils/highlite.nim b/lib/packages/docutils/highlite.nim index 9485f3912..640b8cd5a 100644 --- a/lib/packages/docutils/highlite.nim +++ b/lib/packages/docutils/highlite.nim @@ -15,7 +15,7 @@ import strutils type - TTokenClass* = enum + TokenClass* = enum gtEof, gtNone, gtWhitespace, gtDecNumber, gtBinNumber, gtHexNumber, gtOctNumber, gtFloatNumber, gtIdentifier, gtKeyword, gtStringLit, gtLongStringLit, gtCharLit, gtEscapeSequence, # escape sequence like \xff @@ -23,20 +23,22 @@ type gtTagStart, gtTagEnd, gtKey, gtValue, gtRawData, gtAssembler, gtPreprocessor, gtDirective, gtCommand, gtRule, gtHyperlink, gtLabel, gtReference, gtOther - TGeneralTokenizer* = object of RootObj - kind*: TTokenClass + GeneralTokenizer* = object of RootObj + kind*: TokenClass start*, length*: int buf: cstring pos: int - state: TTokenClass + state: TokenClass - TSourceLanguage* = enum + SourceLanguage* = enum langNone, langNim, langNimrod, langCpp, langCsharp, langC, langJava +{.deprecated: [TSourceLanguage: SourceLanguage, TTokenClass: TokenClass, + TGeneralTokenizer: GeneralTokenizer].} const - sourceLanguageToStr*: array[TSourceLanguage, string] = ["none", + sourceLanguageToStr*: array[SourceLanguage, string] = ["none", "Nim", "Nimrod", "C++", "C#", "C", "Java"] - tokenClassToStr*: array[TTokenClass, string] = ["Eof", "None", "Whitespace", + tokenClassToStr*: array[TokenClass, string] = ["Eof", "None", "Whitespace", "DecNumber", "BinNumber", "HexNumber", "OctNumber", "FloatNumber", "Identifier", "Keyword", "StringLit", "LongStringLit", "CharLit", "EscapeSequence", "Operator", "Punctuation", "Comment", "LongComment", @@ -58,29 +60,29 @@ const "template", "try", "tuple", "type", "using", "var", "when", "while", "with", "without", "xor", "yield"] -proc getSourceLanguage*(name: string): TSourceLanguage = - for i in countup(succ(low(TSourceLanguage)), high(TSourceLanguage)): +proc getSourceLanguage*(name: string): SourceLanguage = + for i in countup(succ(low(SourceLanguage)), high(SourceLanguage)): if cmpIgnoreStyle(name, sourceLanguageToStr[i]) == 0: return i result = langNone -proc initGeneralTokenizer*(g: var TGeneralTokenizer, buf: cstring) = +proc initGeneralTokenizer*(g: var GeneralTokenizer, buf: cstring) = g.buf = buf - g.kind = low(TTokenClass) + g.kind = low(TokenClass) g.start = 0 g.length = 0 - g.state = low(TTokenClass) + g.state = low(TokenClass) var pos = 0 # skip initial whitespace: while g.buf[pos] in {' ', '\x09'..'\x0D'}: inc(pos) g.pos = pos -proc initGeneralTokenizer*(g: var TGeneralTokenizer, buf: string) = +proc initGeneralTokenizer*(g: var GeneralTokenizer, buf: string) = initGeneralTokenizer(g, cstring(buf)) -proc deinitGeneralTokenizer*(g: var TGeneralTokenizer) = +proc deinitGeneralTokenizer*(g: var GeneralTokenizer) = discard -proc nimGetKeyword(id: string): TTokenClass = +proc nimGetKeyword(id: string): TokenClass = for k in nimKeywords: if cmpIgnoreStyle(id, k) == 0: return gtKeyword result = gtIdentifier @@ -92,7 +94,7 @@ proc nimGetKeyword(id: string): TTokenClass = else: result = gtIdentifier -proc nimNumberPostfix(g: var TGeneralTokenizer, position: int): int = +proc nimNumberPostfix(g: var GeneralTokenizer, position: int): int = var pos = position if g.buf[pos] == '\'': inc(pos) @@ -110,7 +112,7 @@ proc nimNumberPostfix(g: var TGeneralTokenizer, position: int): int = discard result = pos -proc nimNumber(g: var TGeneralTokenizer, position: int): int = +proc nimNumber(g: var GeneralTokenizer, position: int): int = const decChars = {'0'..'9', '_'} var pos = position g.kind = gtDecNumber @@ -130,7 +132,7 @@ const OpChars = {'+', '-', '*', '/', '\\', '<', '>', '!', '?', '^', '.', '|', '=', '%', '&', '$', '@', '~', ':', '\x80'..'\xFF'} -proc nimNextToken(g: var TGeneralTokenizer) = +proc nimNextToken(g: var GeneralTokenizer) = const hexChars = {'0'..'9', 'A'..'F', 'a'..'f', '_'} octChars = {'0'..'7', '_'} @@ -278,7 +280,7 @@ proc nimNextToken(g: var TGeneralTokenizer) = assert false, "nimNextToken: produced an empty token" g.pos = pos -proc generalNumber(g: var TGeneralTokenizer, position: int): int = +proc generalNumber(g: var GeneralTokenizer, position: int): int = const decChars = {'0'..'9'} var pos = position g.kind = gtDecNumber @@ -294,7 +296,7 @@ proc generalNumber(g: var TGeneralTokenizer, position: int): int = while g.buf[pos] in decChars: inc(pos) result = pos -proc generalStrLit(g: var TGeneralTokenizer, position: int): int = +proc generalStrLit(g: var GeneralTokenizer, position: int): int = const decChars = {'0'..'9'} hexChars = {'0'..'9', 'A'..'F', 'a'..'f'} @@ -355,12 +357,13 @@ proc isKeywordIgnoreCase(x: openArray[string], y: string): int = result = - 1 type - TTokenizerFlag = enum + TokenizerFlag = enum hasPreprocessor, hasNestedComments - TTokenizerFlags = set[TTokenizerFlag] + TokenizerFlags = set[TokenizerFlag] +{.deprecated: [TTokenizerFlag: TokenizerFlag, TTokenizerFlags: TokenizerFlags].} -proc clikeNextToken(g: var TGeneralTokenizer, keywords: openArray[string], - flags: TTokenizerFlags) = +proc clikeNextToken(g: var GeneralTokenizer, keywords: openArray[string], + flags: TokenizerFlags) = const hexChars = {'0'..'9', 'A'..'F', 'a'..'f'} octChars = {'0'..'7'} @@ -493,7 +496,7 @@ proc clikeNextToken(g: var TGeneralTokenizer, keywords: openArray[string], assert false, "clikeNextToken: produced an empty token" g.pos = pos -proc cNextToken(g: var TGeneralTokenizer) = +proc cNextToken(g: var GeneralTokenizer) = const keywords: array[0..36, string] = ["_Bool", "_Complex", "_Imaginary", "auto", "break", "case", "char", "const", "continue", "default", "do", "double", @@ -503,7 +506,7 @@ proc cNextToken(g: var TGeneralTokenizer) = "volatile", "while"] clikeNextToken(g, keywords, {hasPreprocessor}) -proc cppNextToken(g: var TGeneralTokenizer) = +proc cppNextToken(g: var GeneralTokenizer) = const keywords: array[0..47, string] = ["asm", "auto", "break", "case", "catch", "char", "class", "const", "continue", "default", "delete", "do", "double", @@ -514,7 +517,7 @@ proc cppNextToken(g: var TGeneralTokenizer) = "union", "unsigned", "virtual", "void", "volatile", "while"] clikeNextToken(g, keywords, {hasPreprocessor}) -proc csharpNextToken(g: var TGeneralTokenizer) = +proc csharpNextToken(g: var GeneralTokenizer) = const keywords: array[0..76, string] = ["abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", "continue", @@ -529,7 +532,7 @@ proc csharpNextToken(g: var TGeneralTokenizer) = "virtual", "void", "volatile", "while"] clikeNextToken(g, keywords, {hasPreprocessor}) -proc javaNextToken(g: var TGeneralTokenizer) = +proc javaNextToken(g: var GeneralTokenizer) = const keywords: array[0..52, string] = ["abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "default", @@ -541,7 +544,7 @@ proc javaNextToken(g: var TGeneralTokenizer) = "try", "void", "volatile", "while"] clikeNextToken(g, keywords, {}) -proc getNextToken*(g: var TGeneralTokenizer, lang: TSourceLanguage) = +proc getNextToken*(g: var GeneralTokenizer, lang: SourceLanguage) = case lang of langNone: assert false of langNim, langNimrod: nimNextToken(g) diff --git a/lib/packages/docutils/rst.nim b/lib/packages/docutils/rst.nim index 2ee94ba13..ae3ed8feb 100644 --- a/lib/packages/docutils/rst.nim +++ b/lib/packages/docutils/rst.nim @@ -15,7 +15,7 @@ import os, strutils, rstast type - TRstParseOption* = enum ## options for the RST parser + RstParseOption* = enum ## options for the RST parser roSkipPounds, ## skip ``#`` at line beginning (documentation ## embedded in Nim comments) roSupportSmilies, ## make the RST parser support smilies like ``:)`` @@ -23,14 +23,14 @@ type ## it for sandboxing) roSupportMarkdown ## support additional features of markdown - TRstParseOptions* = set[TRstParseOption] + RstParseOptions* = set[RstParseOption] - TMsgClass* = enum + MsgClass* = enum mcHint = "Hint", mcWarning = "Warning", mcError = "Error" - TMsgKind* = enum ## the possible messages + MsgKind* = enum ## the possible messages meCannotOpenFile, meExpected, meGridTableNotImplemented, @@ -42,12 +42,14 @@ type mwUnsupportedLanguage, mwUnsupportedField - TMsgHandler* = proc (filename: string, line, col: int, msgKind: TMsgKind, + MsgHandler* = proc (filename: string, line, col: int, msgKind: MsgKind, arg: string) {.nimcall.} ## what to do in case of an error - TFindFileHandler* = proc (filename: string): string {.nimcall.} + FindFileHandler* = proc (filename: string): string {.nimcall.} +{.deprecated: [TRstParseOptions: RstParseOptions, TRstParseOption: RstParseOption, + TMsgKind: MsgKind].} const - messages: array [TMsgKind, string] = [ + messages: array [MsgKind, string] = [ meCannotOpenFile: "cannot open '$1'", meExpected: "'$1' expected", meGridTableNotImplemented: "grid table is not implemented", @@ -111,23 +113,24 @@ const } type - TTokType = enum + TokType = enum tkEof, tkIndent, tkWhite, tkWord, tkAdornment, tkPunct, tkOther - TToken = object # a RST token - kind*: TTokType # the type of the token + Token = object # a RST token + kind*: TokType # the type of the token ival*: int # the indentation or parsed integer value symbol*: string # the parsed symbol as string line*, col*: int # line and column of the token - TTokenSeq = seq[TToken] - TLexer = object of RootObj + TokenSeq = seq[Token] + Lexer = object of RootObj buf*: cstring bufpos*: int line*, col*, baseIndent*: int skipPounds*: bool +{.deprecated: [TTokType: TokType, TToken: Token, TTokenSeq: TokenSeq, + TLexer: Lexer].} - -proc getThing(L: var TLexer, tok: var TToken, s: set[char]) = +proc getThing(L: var Lexer, tok: var Token, s: set[char]) = tok.kind = tkWord tok.line = L.line tok.col = L.col @@ -139,7 +142,7 @@ proc getThing(L: var TLexer, tok: var TToken, s: set[char]) = inc(L.col, pos - L.bufpos) L.bufpos = pos -proc getAdornment(L: var TLexer, tok: var TToken) = +proc getAdornment(L: var Lexer, tok: var Token) = tok.kind = tkAdornment tok.line = L.line tok.col = L.col @@ -152,7 +155,7 @@ proc getAdornment(L: var TLexer, tok: var TToken) = inc(L.col, pos - L.bufpos) L.bufpos = pos -proc getIndentAux(L: var TLexer, start: int): int = +proc getIndentAux(L: var Lexer, start: int): int = var pos = start var buf = L.buf # skip the newline (but include it in the token!) @@ -181,7 +184,7 @@ proc getIndentAux(L: var TLexer, start: int): int = result = getIndentAux(L, pos) L.bufpos = pos # no need to set back buf -proc getIndent(L: var TLexer, tok: var TToken) = +proc getIndent(L: var Lexer, tok: var Token) = tok.col = 0 tok.kind = tkIndent # skip the newline (but include it in the token!) tok.ival = getIndentAux(L, L.bufpos) @@ -191,7 +194,7 @@ proc getIndent(L: var TLexer, tok: var TToken) = tok.ival = max(tok.ival - L.baseIndent, 0) tok.symbol = "\n" & spaces(tok.ival) -proc rawGetTok(L: var TLexer, tok: var TToken) = +proc rawGetTok(L: var Lexer, tok: var Token) = tok.symbol = "" tok.ival = 0 var c = L.buf[L.bufpos] @@ -222,8 +225,8 @@ proc rawGetTok(L: var TLexer, tok: var TToken) = inc(L.col) tok.col = max(tok.col - L.baseIndent, 0) -proc getTokens(buffer: string, skipPounds: bool, tokens: var TTokenSeq): int = - var L: TLexer +proc getTokens(buffer: string, skipPounds: bool, tokens: var TokenSeq): int = + var L: Lexer var length = len(tokens) L.buf = cstring(buffer) L.line = 0 # skip UTF-8 BOM @@ -253,31 +256,31 @@ proc getTokens(buffer: string, skipPounds: bool, tokens: var TTokenSeq): int = tokens[0].kind = tkIndent type - TLevelMap = array[char, int] - TSubstitution = object + LevelMap = array[char, int] + Substitution = object key*: string value*: PRstNode - TSharedState = object - options: TRstParseOptions # parsing options + SharedState = object + options: RstParseOptions # parsing options uLevel, oLevel: int # counters for the section levels - subs: seq[TSubstitution] # substitutions - refs: seq[TSubstitution] # references - underlineToLevel: TLevelMap # Saves for each possible title adornment + subs: seq[Substitution] # substitutions + refs: seq[Substitution] # references + underlineToLevel: LevelMap # Saves for each possible title adornment # character its level in the # current document. # This is for single underline adornments. - overlineToLevel: TLevelMap # Saves for each possible title adornment + overlineToLevel: LevelMap # Saves for each possible title adornment # character its level in the current # document. # This is for over-underline adornments. - msgHandler: TMsgHandler # How to handle errors. - findFile: TFindFileHandler # How to find files. + msgHandler: MsgHandler # How to handle errors. + findFile: FindFileHandler # How to find files. - PSharedState = ref TSharedState - TRstParser = object of RootObj + PSharedState = ref SharedState + RstParser = object of RootObj idx*: int - tok*: TTokenSeq + tok*: TokenSeq s*: PSharedState indentStack*: seq[int] filename*: string @@ -285,8 +288,12 @@ type hasToc*: bool EParseError* = object of ValueError +{.deprecated: [TLevelMap: LevelMap, TSubstitution: Substitution, + TSharedState: SharedState, TRstParser: RstParser, + TMsgHandler: MsgHandler, TFindFileHandler: FindFileHandler, + TMsgClass: MsgClass].} -proc whichMsgClass*(k: TMsgKind): TMsgClass = +proc whichMsgClass*(k: MsgKind): MsgClass = ## returns which message class `k` belongs to. case ($k)[1] of 'e', 'E': result = mcError @@ -294,7 +301,7 @@ proc whichMsgClass*(k: TMsgKind): TMsgClass = of 'h', 'H': result = mcHint else: assert false, "msgkind does not fit naming scheme" -proc defaultMsgHandler*(filename: string, line, col: int, msgkind: TMsgKind, +proc defaultMsgHandler*(filename: string, line, col: int, msgkind: MsgKind, arg: string) {.procvar.} = let mc = msgkind.whichMsgClass let a = messages[msgkind] % arg @@ -306,9 +313,9 @@ proc defaultFindFile*(filename: string): string {.procvar.} = if existsFile(filename): result = filename else: result = "" -proc newSharedState(options: TRstParseOptions, - findFile: TFindFileHandler, - msgHandler: TMsgHandler): PSharedState = +proc newSharedState(options: RstParseOptions, + findFile: FindFileHandler, + msgHandler: MsgHandler): PSharedState = new(result) result.subs = @[] result.refs = @[] @@ -316,34 +323,34 @@ proc newSharedState(options: TRstParseOptions, result.msgHandler = if not isNil(msgHandler): msgHandler else: defaultMsgHandler result.findFile = if not isNil(findFile): findFile else: defaultFindFile -proc rstMessage(p: TRstParser, msgKind: TMsgKind, arg: string) = +proc rstMessage(p: RstParser, msgKind: MsgKind, arg: string) = p.s.msgHandler(p.filename, p.line + p.tok[p.idx].line, p.col + p.tok[p.idx].col, msgKind, arg) -proc rstMessage(p: TRstParser, msgKind: TMsgKind, arg: string, line, col: int) = +proc rstMessage(p: RstParser, msgKind: MsgKind, arg: string, line, col: int) = p.s.msgHandler(p.filename, p.line + line, p.col + col, msgKind, arg) -proc rstMessage(p: TRstParser, msgKind: TMsgKind) = +proc rstMessage(p: RstParser, msgKind: MsgKind) = p.s.msgHandler(p.filename, p.line + p.tok[p.idx].line, p.col + p.tok[p.idx].col, msgKind, p.tok[p.idx].symbol) when false: - proc corrupt(p: TRstParser) = + proc corrupt(p: RstParser) = assert p.indentStack[0] == 0 for i in 1 .. high(p.indentStack): assert p.indentStack[i] < 1_000 -proc currInd(p: TRstParser): int = +proc currInd(p: RstParser): int = result = p.indentStack[high(p.indentStack)] -proc pushInd(p: var TRstParser, ind: int) = +proc pushInd(p: var RstParser, ind: int) = add(p.indentStack, ind) -proc popInd(p: var TRstParser) = +proc popInd(p: var RstParser) = if len(p.indentStack) > 1: setLen(p.indentStack, len(p.indentStack) - 1) -proc initParser(p: var TRstParser, sharedState: PSharedState) = +proc initParser(p: var RstParser, sharedState: PSharedState) = p.indentStack = @[0] p.tok = @[] p.idx = 0 @@ -393,7 +400,7 @@ proc rstnodeToRefname(n: PRstNode): string = var b = false rstnodeToRefnameAux(n, result, b) -proc findSub(p: var TRstParser, n: PRstNode): int = +proc findSub(p: var RstParser, n: PRstNode): int = var key = addNodes(n) # the spec says: if no exact match, try one without case distinction: for i in countup(0, high(p.s.subs)): @@ -404,7 +411,7 @@ proc findSub(p: var TRstParser, n: PRstNode): int = return i result = -1 -proc setSub(p: var TRstParser, key: string, value: PRstNode) = +proc setSub(p: var RstParser, key: string, value: PRstNode) = var length = len(p.s.subs) for i in countup(0, length - 1): if key == p.s.subs[i].key: @@ -414,7 +421,7 @@ proc setSub(p: var TRstParser, key: string, value: PRstNode) = p.s.subs[length].key = key p.s.subs[length].value = value -proc setRef(p: var TRstParser, key: string, value: PRstNode) = +proc setRef(p: var RstParser, key: string, value: PRstNode) = var length = len(p.s.refs) for i in countup(0, length - 1): if key == p.s.refs[i].key: @@ -427,15 +434,15 @@ proc setRef(p: var TRstParser, key: string, value: PRstNode) = p.s.refs[length].key = key p.s.refs[length].value = value -proc findRef(p: var TRstParser, key: string): PRstNode = +proc findRef(p: var RstParser, key: string): PRstNode = for i in countup(0, high(p.s.refs)): if key == p.s.refs[i].key: return p.s.refs[i].value -proc newLeaf(p: var TRstParser): PRstNode = +proc newLeaf(p: var RstParser): PRstNode = result = newRstNode(rnLeaf, p.tok[p.idx].symbol) -proc getReferenceName(p: var TRstParser, endStr: string): PRstNode = +proc getReferenceName(p: var RstParser, endStr: string): PRstNode = var res = newRstNode(rnInner) while true: case p.tok[p.idx].kind @@ -453,17 +460,17 @@ proc getReferenceName(p: var TRstParser, endStr: string): PRstNode = inc(p.idx) result = res -proc untilEol(p: var TRstParser): PRstNode = +proc untilEol(p: var RstParser): PRstNode = result = newRstNode(rnInner) while not (p.tok[p.idx].kind in {tkIndent, tkEof}): add(result, newLeaf(p)) inc(p.idx) -proc expect(p: var TRstParser, tok: string) = +proc expect(p: var RstParser, tok: string) = if p.tok[p.idx].symbol == tok: inc(p.idx) else: rstMessage(p, meExpected, tok) -proc isInlineMarkupEnd(p: TRstParser, markup: string): bool = +proc isInlineMarkupEnd(p: RstParser, markup: string): bool = result = p.tok[p.idx].symbol == markup if not result: return # Rule 3: @@ -480,7 +487,7 @@ proc isInlineMarkupEnd(p: TRstParser, markup: string): bool = if (markup != "``") and (p.tok[p.idx - 1].symbol == "\\"): result = false -proc isInlineMarkupStart(p: TRstParser, markup: string): bool = +proc isInlineMarkupStart(p: RstParser, markup: string): bool = var d: char result = p.tok[p.idx].symbol == markup if not result: @@ -507,7 +514,7 @@ proc isInlineMarkupStart(p: TRstParser, markup: string): bool = else: d = '\0' if d != '\0': result = p.tok[p.idx + 1].symbol[0] != d -proc match(p: TRstParser, start: int, expr: string): bool = +proc match(p: RstParser, start: int, expr: string): bool = # regular expressions are: # special char exact match # 'w' tkWord @@ -562,7 +569,7 @@ proc fixupEmbeddedRef(n, a, b: PRstNode) = for i in countup(0, sep - incr): add(a, n.sons[i]) for i in countup(sep + 1, len(n) - 2): add(b, n.sons[i]) -proc parsePostfix(p: var TRstParser, n: PRstNode): PRstNode = +proc parsePostfix(p: var RstParser, n: PRstNode): PRstNode = result = n if isInlineMarkupEnd(p, "_") or isInlineMarkupEnd(p, "__"): inc(p.idx) @@ -606,7 +613,7 @@ proc parsePostfix(p: var TRstParser, n: PRstNode): PRstNode = add(result, newRstNode(rnLeaf, p.tok[p.idx + 1].symbol)) inc(p.idx, 3) -proc matchVerbatim(p: TRstParser, start: int, expr: string): int = +proc matchVerbatim(p: RstParser, start: int, expr: string): int = result = start var j = 0 while j < expr.len and result < p.tok.len and @@ -615,7 +622,7 @@ proc matchVerbatim(p: TRstParser, start: int, expr: string): int = inc result if j < expr.len: result = 0 -proc parseSmiley(p: var TRstParser): PRstNode = +proc parseSmiley(p: var RstParser): PRstNode = if p.tok[p.idx].symbol[0] notin SmileyStartChars: return for key, val in items(Smilies): let m = matchVerbatim(p, p.idx, key) @@ -631,12 +638,12 @@ when false: '$', '(', ')', '~', '_', '?', '+', '-', '=', '\\', '.', '&', '\128'..'\255'} -proc isUrl(p: TRstParser, i: int): bool = +proc isUrl(p: RstParser, i: int): bool = result = (p.tok[i+1].symbol == ":") and (p.tok[i+2].symbol == "//") and (p.tok[i+3].kind == tkWord) and (p.tok[i].symbol in ["http", "https", "ftp", "telnet", "file"]) -proc parseUrl(p: var TRstParser, father: PRstNode) = +proc parseUrl(p: var RstParser, father: PRstNode) = #if p.tok[p.idx].symbol[strStart] == '<': if isUrl(p, p.idx): var n = newRstNode(rnStandaloneHyperlink) @@ -656,7 +663,7 @@ proc parseUrl(p: var TRstParser, father: PRstNode) = if p.tok[p.idx].symbol == "_": n = parsePostfix(p, n) add(father, n) -proc parseBackslash(p: var TRstParser, father: PRstNode) = +proc parseBackslash(p: var RstParser, father: PRstNode) = assert(p.tok[p.idx].kind == tkPunct) if p.tok[p.idx].symbol == "\\\\": add(father, newRstNode(rnLeaf, "\\")) @@ -671,7 +678,7 @@ proc parseBackslash(p: var TRstParser, father: PRstNode) = inc(p.idx) when false: - proc parseAdhoc(p: var TRstParser, father: PRstNode, verbatim: bool) = + proc parseAdhoc(p: var RstParser, father: PRstNode, verbatim: bool) = if not verbatim and isURL(p, p.idx): var n = newRstNode(rnStandaloneHyperlink) while true: @@ -694,7 +701,7 @@ when false: if p.tok[p.idx].symbol == "_": n = parsePostfix(p, n) add(father, n) -proc parseUntil(p: var TRstParser, father: PRstNode, postfix: string, +proc parseUntil(p: var RstParser, father: PRstNode, postfix: string, interpretBackslash: bool) = let line = p.tok[p.idx].line @@ -725,7 +732,7 @@ proc parseUntil(p: var TRstParser, father: PRstNode, postfix: string, inc(p.idx) else: rstMessage(p, meExpected, postfix, line, col) -proc parseMarkdownCodeblock(p: var TRstParser): PRstNode = +proc parseMarkdownCodeblock(p: var RstParser): PRstNode = var args = newRstNode(rnDirArg) if p.tok[p.idx].kind == tkWord: add(args, newLeaf(p)) @@ -755,7 +762,7 @@ proc parseMarkdownCodeblock(p: var TRstParser): PRstNode = add(result, nil) add(result, lb) -proc parseInline(p: var TRstParser, father: PRstNode) = +proc parseInline(p: var RstParser, father: PRstNode) = case p.tok[p.idx].kind of tkPunct: if isInlineMarkupStart(p, "***"): @@ -810,7 +817,7 @@ proc parseInline(p: var TRstParser, father: PRstNode) = inc(p.idx) else: discard -proc getDirective(p: var TRstParser): string = +proc getDirective(p: var RstParser): string = if p.tok[p.idx].kind == tkWhite and p.tok[p.idx+1].kind == tkWord: var j = p.idx inc(p.idx) @@ -830,7 +837,7 @@ proc getDirective(p: var TRstParser): string = else: result = "" -proc parseComment(p: var TRstParser): PRstNode = +proc parseComment(p: var RstParser): PRstNode = case p.tok[p.idx].kind of tkIndent, tkEof: if p.tok[p.idx].kind != tkEof and p.tok[p.idx + 1].kind == tkIndent: @@ -851,34 +858,35 @@ proc parseComment(p: var TRstParser): PRstNode = result = nil type - TDirKind = enum # must be ordered alphabetically! + DirKind = enum # must be ordered alphabetically! dkNone, dkAuthor, dkAuthors, dkCode, dkCodeBlock, dkContainer, dkContents, dkFigure, dkImage, dkInclude, dkIndex, dkRaw, dkTitle +{.deprecated: [TDirKind: DirKind].} const DirIds: array[0..12, string] = ["", "author", "authors", "code", "code-block", "container", "contents", "figure", "image", "include", "index", "raw", "title"] -proc getDirKind(s: string): TDirKind = +proc getDirKind(s: string): DirKind = let i = find(DirIds, s) - if i >= 0: result = TDirKind(i) + if i >= 0: result = DirKind(i) else: result = dkNone -proc parseLine(p: var TRstParser, father: PRstNode) = +proc parseLine(p: var RstParser, father: PRstNode) = while true: case p.tok[p.idx].kind of tkWhite, tkWord, tkOther, tkPunct: parseInline(p, father) else: break -proc parseUntilNewline(p: var TRstParser, father: PRstNode) = +proc parseUntilNewline(p: var RstParser, father: PRstNode) = while true: case p.tok[p.idx].kind of tkWhite, tkWord, tkAdornment, tkOther, tkPunct: parseInline(p, father) of tkEof, tkIndent: break -proc parseSection(p: var TRstParser, result: PRstNode) {.gcsafe.} -proc parseField(p: var TRstParser): PRstNode = +proc parseSection(p: var RstParser, result: PRstNode) {.gcsafe.} +proc parseField(p: var RstParser): PRstNode = ## Returns a parsed rnField node. ## ## rnField nodes have two children nodes, a rnFieldName and a rnFieldBody. @@ -897,7 +905,7 @@ proc parseField(p: var TRstParser): PRstNode = add(result, fieldname) add(result, fieldbody) -proc parseFields(p: var TRstParser): PRstNode = +proc parseFields(p: var RstParser): PRstNode = ## Parses fields for a section or directive block. ## ## This proc may return nil if the parsing doesn't find anything of value, @@ -947,8 +955,8 @@ proc getArgument(n: PRstNode): string = if n.sons[0] == nil: result = "" else: result = addNodes(n.sons[0]) -proc parseDotDot(p: var TRstParser): PRstNode {.gcsafe.} -proc parseLiteralBlock(p: var TRstParser): PRstNode = +proc parseDotDot(p: var RstParser): PRstNode {.gcsafe.} +proc parseLiteralBlock(p: var RstParser): PRstNode = result = newRstNode(rnLiteralBlock) var n = newRstNode(rnLeaf, "") if p.tok[p.idx].kind == tkIndent: @@ -974,13 +982,13 @@ proc parseLiteralBlock(p: var TRstParser): PRstNode = inc(p.idx) add(result, n) -proc getLevel(map: var TLevelMap, lvl: var int, c: char): int = +proc getLevel(map: var LevelMap, lvl: var int, c: char): int = if map[c] == 0: inc(lvl) map[c] = lvl result = map[c] -proc tokenAfterNewline(p: TRstParser): int = +proc tokenAfterNewline(p: RstParser): int = result = p.idx while true: case p.tok[result].kind @@ -991,28 +999,28 @@ proc tokenAfterNewline(p: TRstParser): int = break else: inc(result) -proc isLineBlock(p: TRstParser): bool = +proc isLineBlock(p: RstParser): bool = var j = tokenAfterNewline(p) result = (p.tok[p.idx].col == p.tok[j].col) and (p.tok[j].symbol == "|") or (p.tok[j].col > p.tok[p.idx].col) -proc predNL(p: TRstParser): bool = +proc predNL(p: RstParser): bool = result = true if p.idx > 0: result = p.tok[p.idx-1].kind == tkIndent and p.tok[p.idx-1].ival == currInd(p) -proc isDefList(p: TRstParser): bool = +proc isDefList(p: RstParser): bool = var j = tokenAfterNewline(p) result = (p.tok[p.idx].col < p.tok[j].col) and (p.tok[j].kind in {tkWord, tkOther, tkPunct}) and (p.tok[j - 2].symbol != "::") -proc isOptionList(p: TRstParser): bool = +proc isOptionList(p: RstParser): bool = result = match(p, p.idx, "-w") or match(p, p.idx, "--w") or match(p, p.idx, "/w") or match(p, p.idx, "//w") -proc whichSection(p: TRstParser): TRstNodeKind = +proc whichSection(p: RstParser): RstNodeKind = case p.tok[p.idx].kind of tkAdornment: if match(p, p.idx + 1, "ii"): result = rnTransition @@ -1053,7 +1061,7 @@ proc whichSection(p: TRstParser): TRstNodeKind = else: result = rnParagraph else: result = rnLeaf -proc parseLineBlock(p: var TRstParser): PRstNode = +proc parseLineBlock(p: var RstParser): PRstNode = result = nil if p.tok[p.idx + 1].kind == tkWhite: var col = p.tok[p.idx].col @@ -1072,7 +1080,7 @@ proc parseLineBlock(p: var TRstParser): PRstNode = break popInd(p) -proc parseParagraph(p: var TRstParser, result: PRstNode) = +proc parseParagraph(p: var RstParser, result: PRstNode) = while true: case p.tok[p.idx].kind of tkIndent: @@ -1103,7 +1111,7 @@ proc parseParagraph(p: var TRstParser, result: PRstNode) = parseInline(p, result) else: break -proc parseHeadline(p: var TRstParser): PRstNode = +proc parseHeadline(p: var RstParser): PRstNode = result = newRstNode(rnHeadline) parseUntilNewline(p, result) assert(p.tok[p.idx].kind == tkIndent) @@ -1113,12 +1121,13 @@ proc parseHeadline(p: var TRstParser): PRstNode = result.level = getLevel(p.s.underlineToLevel, p.s.uLevel, c) type - TIntSeq = seq[int] + IntSeq = seq[int] +{.deprecated: [TIntSeq: IntSeq].} -proc tokEnd(p: TRstParser): int = +proc tokEnd(p: RstParser): int = result = p.tok[p.idx].col + len(p.tok[p.idx].symbol) - 1 -proc getColumns(p: var TRstParser, cols: var TIntSeq) = +proc getColumns(p: var RstParser, cols: var IntSeq) = var L = 0 while true: inc(L) @@ -1133,15 +1142,15 @@ proc getColumns(p: var TRstParser, cols: var TIntSeq) = # last column has no limit: cols[L - 1] = 32000 -proc parseDoc(p: var TRstParser): PRstNode {.gcsafe.} +proc parseDoc(p: var RstParser): PRstNode {.gcsafe.} -proc parseSimpleTable(p: var TRstParser): PRstNode = +proc parseSimpleTable(p: var RstParser): PRstNode = var - cols: TIntSeq + cols: IntSeq row: seq[string] i, last, line: int c: char - q: TRstParser + q: RstParser a, b: PRstNode result = newRstNode(rnTable) cols = @[] @@ -1188,13 +1197,13 @@ proc parseSimpleTable(p: var TRstParser): PRstNode = add(a, b) add(result, a) -proc parseTransition(p: var TRstParser): PRstNode = +proc parseTransition(p: var RstParser): PRstNode = result = newRstNode(rnTransition) inc(p.idx) if p.tok[p.idx].kind == tkIndent: inc(p.idx) if p.tok[p.idx].kind == tkIndent: inc(p.idx) -proc parseOverline(p: var TRstParser): PRstNode = +proc parseOverline(p: var RstParser): PRstNode = var c = p.tok[p.idx].symbol[0] inc(p.idx, 2) result = newRstNode(rnOverline) @@ -1213,7 +1222,7 @@ proc parseOverline(p: var TRstParser): PRstNode = inc(p.idx) # XXX: check? if p.tok[p.idx].kind == tkIndent: inc(p.idx) -proc parseBulletList(p: var TRstParser): PRstNode = +proc parseBulletList(p: var RstParser): PRstNode = result = nil if p.tok[p.idx + 1].kind == tkWhite: var bullet = p.tok[p.idx].symbol @@ -1233,7 +1242,7 @@ proc parseBulletList(p: var TRstParser): PRstNode = break popInd(p) -proc parseOptionList(p: var TRstParser): PRstNode = +proc parseOptionList(p: var RstParser): PRstNode = result = newRstNode(rnOptionList) while true: if isOptionList(p): @@ -1262,7 +1271,7 @@ proc parseOptionList(p: var TRstParser): PRstNode = else: break -proc parseDefinitionList(p: var TRstParser): PRstNode = +proc parseDefinitionList(p: var RstParser): PRstNode = result = nil var j = tokenAfterNewline(p) - 1 if (j >= 1) and (p.tok[j].kind == tkIndent) and @@ -1298,7 +1307,7 @@ proc parseDefinitionList(p: var TRstParser): PRstNode = break if len(result) == 0: result = nil -proc parseEnumList(p: var TRstParser): PRstNode = +proc parseEnumList(p: var RstParser): PRstNode = const wildcards: array[0..2, string] = ["(e) ", "e) ", "e. "] wildpos: array[0..2, int] = [1, 0, 0] @@ -1328,11 +1337,11 @@ proc parseEnumList(p: var TRstParser): PRstNode = dec(p.idx, wildpos[w] + 3) result = nil -proc sonKind(father: PRstNode, i: int): TRstNodeKind = +proc sonKind(father: PRstNode, i: int): RstNodeKind = result = rnLeaf if i < len(father): result = father.sons[i].kind -proc parseSection(p: var TRstParser, result: PRstNode) = +proc parseSection(p: var RstParser, result: PRstNode) = while true: var leave = false assert(p.idx >= 0) @@ -1380,16 +1389,16 @@ proc parseSection(p: var TRstParser, result: PRstNode) = if sonKind(result, 0) == rnParagraph and sonKind(result, 1) != rnParagraph: result.sons[0].kind = rnInner -proc parseSectionWrapper(p: var TRstParser): PRstNode = +proc parseSectionWrapper(p: var RstParser): PRstNode = result = newRstNode(rnInner) parseSection(p, result) while (result.kind == rnInner) and (len(result) == 1): result = result.sons[0] -proc `$`(t: TToken): string = +proc `$`(t: Token): string = result = $t.kind & ' ' & (if isNil(t.symbol): "NIL" else: t.symbol) -proc parseDoc(p: var TRstParser): PRstNode = +proc parseDoc(p: var RstParser): PRstNode = result = parseSectionWrapper(p) if p.tok[p.idx].kind != tkEof: when false: @@ -1403,12 +1412,14 @@ proc parseDoc(p: var TRstParser): PRstNode = rstMessage(p, meGeneralParseError) type - TDirFlag = enum + DirFlag = enum hasArg, hasOptions, argIsFile, argIsWord - TDirFlags = set[TDirFlag] - TSectionParser = proc (p: var TRstParser): PRstNode {.nimcall.} + DirFlags = set[DirFlag] + SectionParser = proc (p: var RstParser): PRstNode {.nimcall.} +{.deprecated: [TDirFlag: DirFlag, TDirFlags: DirFlags, + TSectionParser: SectionParser].} -proc parseDirective(p: var TRstParser, flags: TDirFlags): PRstNode = +proc parseDirective(p: var RstParser, flags: DirFlags): PRstNode = ## Parses arguments and options for a directive block. ## ## A directive block will always have three sons: the arguments for the @@ -1446,11 +1457,11 @@ proc parseDirective(p: var TRstParser, flags: TDirFlags): PRstNode = options = parseFields(p) add(result, options) -proc indFollows(p: TRstParser): bool = +proc indFollows(p: RstParser): bool = result = p.tok[p.idx].kind == tkIndent and p.tok[p.idx].ival > currInd(p) -proc parseDirective(p: var TRstParser, flags: TDirFlags, - contentParser: TSectionParser): PRstNode = +proc parseDirective(p: var RstParser, flags: DirFlags, + contentParser: SectionParser): PRstNode = ## Returns a generic rnDirective tree. ## ## The children are rnDirArg, rnFieldList and rnLineBlock. Any might be nil. @@ -1463,13 +1474,13 @@ proc parseDirective(p: var TRstParser, flags: TDirFlags, else: add(result, nil) -proc parseDirBody(p: var TRstParser, contentParser: TSectionParser): PRstNode = +proc parseDirBody(p: var RstParser, contentParser: SectionParser): PRstNode = if indFollows(p): pushInd(p, p.tok[p.idx].ival) result = contentParser(p) popInd(p) -proc dirInclude(p: var TRstParser): PRstNode = +proc dirInclude(p: var RstParser): PRstNode = # #The following options are recognized: # @@ -1498,7 +1509,7 @@ proc dirInclude(p: var TRstParser): PRstNode = result = newRstNode(rnLiteralBlock) add(result, newRstNode(rnLeaf, readFile(path))) else: - var q: TRstParser + var q: RstParser initParser(q, p.s) q.filename = filename q.col += getTokens(readFile(path), false, q.tok) @@ -1507,7 +1518,7 @@ proc dirInclude(p: var TRstParser): PRstNode = # InternalError("Too many binary zeros in include file") result = parseDoc(q) -proc dirCodeBlock(p: var TRstParser, nimrodExtension = false): PRstNode = +proc dirCodeBlock(p: var RstParser, nimrodExtension = false): PRstNode = ## Parses a code block. ## ## Code blocks are rnDirective trees with a `kind` of rnCodeBlock. See the @@ -1548,35 +1559,35 @@ proc dirCodeBlock(p: var TRstParser, nimrodExtension = false): PRstNode = result.kind = rnCodeBlock -proc dirContainer(p: var TRstParser): PRstNode = +proc dirContainer(p: var RstParser): PRstNode = result = parseDirective(p, {hasArg}, parseSectionWrapper) assert(result.kind == rnDirective) assert(len(result) == 3) result.kind = rnContainer -proc dirImage(p: var TRstParser): PRstNode = +proc dirImage(p: var RstParser): PRstNode = result = parseDirective(p, {hasOptions, hasArg, argIsFile}, nil) result.kind = rnImage -proc dirFigure(p: var TRstParser): PRstNode = +proc dirFigure(p: var RstParser): PRstNode = result = parseDirective(p, {hasOptions, hasArg, argIsFile}, parseSectionWrapper) result.kind = rnFigure -proc dirTitle(p: var TRstParser): PRstNode = +proc dirTitle(p: var RstParser): PRstNode = result = parseDirective(p, {hasArg}, nil) result.kind = rnTitle -proc dirContents(p: var TRstParser): PRstNode = +proc dirContents(p: var RstParser): PRstNode = result = parseDirective(p, {hasArg}, nil) result.kind = rnContents -proc dirIndex(p: var TRstParser): PRstNode = +proc dirIndex(p: var RstParser): PRstNode = result = parseDirective(p, {}, parseSectionWrapper) result.kind = rnIndex -proc dirRawAux(p: var TRstParser, result: var PRstNode, kind: TRstNodeKind, - contentParser: TSectionParser) = +proc dirRawAux(p: var RstParser, result: var PRstNode, kind: RstNodeKind, + contentParser: SectionParser) = var filename = getFieldValue(result, "file") if filename.len > 0: var path = p.s.findFile(filename) @@ -1590,7 +1601,7 @@ proc dirRawAux(p: var TRstParser, result: var PRstNode, kind: TRstNodeKind, result.kind = kind add(result, parseDirBody(p, contentParser)) -proc dirRaw(p: var TRstParser): PRstNode = +proc dirRaw(p: var RstParser): PRstNode = # #The following options are recognized: # @@ -1610,7 +1621,7 @@ proc dirRaw(p: var TRstParser): PRstNode = else: dirRawAux(p, result, rnRaw, parseSectionWrapper) -proc parseDotDot(p: var TRstParser): PRstNode = +proc parseDotDot(p: var RstParser): PRstNode = result = nil var col = p.tok[p.idx].col inc(p.idx) @@ -1667,7 +1678,7 @@ proc parseDotDot(p: var TRstParser): PRstNode = else: result = parseComment(p) -proc resolveSubs(p: var TRstParser, n: PRstNode): PRstNode = +proc resolveSubs(p: var RstParser, n: PRstNode): PRstNode = result = n if n == nil: return case n.kind @@ -1696,10 +1707,10 @@ proc resolveSubs(p: var TRstParser, n: PRstNode): PRstNode = proc rstParse*(text, filename: string, line, column: int, hasToc: var bool, - options: TRstParseOptions, - findFile: TFindFileHandler = nil, - msgHandler: TMsgHandler = nil): PRstNode = - var p: TRstParser + options: RstParseOptions, + findFile: FindFileHandler = nil, + msgHandler: MsgHandler = nil): PRstNode = + var p: RstParser initParser(p, newSharedState(options, findFile, msgHandler)) p.filename = filename p.line = line diff --git a/lib/packages/docutils/rstast.nim b/lib/packages/docutils/rstast.nim index c3956ab8b..7be4470c1 100644 --- a/lib/packages/docutils/rstast.nim +++ b/lib/packages/docutils/rstast.nim @@ -12,7 +12,7 @@ import strutils, json type - TRstNodeKind* = enum ## the possible node kinds of an PRstNode + RstNodeKind* = enum ## the possible node kinds of an PRstNode rnInner, # an inner node or a root rnHeadline, # a headline rnOverline, # an over- and underlined headline @@ -62,24 +62,26 @@ type # leaf val - PRstNode* = ref TRstNode ## an RST node - TRstNodeSeq* = seq[PRstNode] - TRstNode* {.acyclic, final.} = object ## an RST node's description - kind*: TRstNodeKind ## the node's kind + PRstNode* = ref RstNode ## an RST node + RstNodeSeq* = seq[PRstNode] + RstNode* {.acyclic, final.} = object ## an RST node's description + kind*: RstNodeKind ## the node's kind text*: string ## valid for leafs in the AST; and the title of ## the document or the section level*: int ## valid for some node kinds - sons*: TRstNodeSeq ## the node's sons + sons*: RstNodeSeq ## the node's sons +{.deprecated: [TRstNodeKind: RstNodeKind, TRstNodeSeq: RstNodeSeq, + TRstNode: RstNode].} proc len*(n: PRstNode): int = result = len(n.sons) -proc newRstNode*(kind: TRstNodeKind): PRstNode = +proc newRstNode*(kind: RstNodeKind): PRstNode = new(result) result.sons = @[] result.kind = kind -proc newRstNode*(kind: TRstNodeKind, s: string): PRstNode = +proc newRstNode*(kind: RstNodeKind, s: string): PRstNode = result = newRstNode(kind) result.text = s @@ -94,18 +96,19 @@ proc addIfNotNil*(father, son: PRstNode) = type - TRenderContext {.pure.} = object + RenderContext {.pure.} = object indent: int verbatim: int +{.deprecated: [TRenderContext: RenderContext].} -proc renderRstToRst(d: var TRenderContext, n: PRstNode, +proc renderRstToRst(d: var RenderContext, n: PRstNode, result: var string) {.gcsafe.} -proc renderRstSons(d: var TRenderContext, n: PRstNode, result: var string) = +proc renderRstSons(d: var RenderContext, n: PRstNode, result: var string) = for i in countup(0, len(n) - 1): renderRstToRst(d, n.sons[i], result) -proc renderRstToRst(d: var TRenderContext, n: PRstNode, result: var string) = +proc renderRstToRst(d: var RenderContext, n: PRstNode, result: var string) = # this is needed for the index generation; it may also be useful for # debugging, but most code is already debugged... const @@ -284,7 +287,7 @@ proc renderRstToRst(d: var TRenderContext, n: PRstNode, result: var string) = proc renderRstToRst*(n: PRstNode, result: var string) = ## renders `n` into its string representation and appends to `result`. - var d: TRenderContext + var d: RenderContext renderRstToRst(d, n, result) proc renderRstToJsonNode(node: PRstNode): JsonNode = diff --git a/lib/packages/docutils/rstgen.nim b/lib/packages/docutils/rstgen.nim index 9e96d8a63..f9c8198f2 100644 --- a/lib/packages/docutils/rstgen.nim +++ b/lib/packages/docutils/rstgen.nim @@ -18,7 +18,7 @@ ## document you provide yourself, so it won't contain the usual ``<header>`` or ## ``<body>`` parts. ## -## You can also create a ``TRstGenerator`` structure and populate it with the +## You can also create a ``RstGenerator`` structure and populate it with the ## other lower level methods to finally build complete documents. This requires ## many options and tweaking, but you are not limited to snippets and can ## generate `LaTeX documents <https://en.wikipedia.org/wiki/LaTeX>`_ too. @@ -31,29 +31,29 @@ const IndexExt* = ".idx" type - TOutputTarget* = enum ## which document type to generate + OutputTarget* = enum ## which document type to generate outHtml, # output is HTML outLatex # output is Latex - TTocEntry = object + TocEntry = object n*: PRstNode refname*, header*: string - TMetaEnum* = enum + MetaEnum* = enum metaNone, metaTitle, metaSubtitle, metaAuthor, metaVersion - TRstGenerator* = object of RootObj - target*: TOutputTarget + RstGenerator* = object of RootObj + target*: OutputTarget config*: StringTableRef splitAfter*: int # split too long entries in the TOC - tocPart*: seq[TTocEntry] + tocPart*: seq[TocEntry] hasToc*: bool theIndex: string # Contents of the index file to be dumped at the end. - options*: TRstParseOptions - findFile*: TFindFileHandler - msgHandler*: TMsgHandler + options*: RstParseOptions + findFile*: FindFileHandler + msgHandler*: MsgHandler filename*: string - meta*: array[TMetaEnum, string] + meta*: array[MetaEnum, string] currentSection: string ## \ ## Stores the empty string or the last headline/overline found in the rst ## document, so it can be used as a prettier name for term index generation. @@ -61,14 +61,15 @@ type ## Keeps count of same text index terms to generate different identifiers ## for hyperlinks. See renderIndexTerm proc for details. - PDoc = var TRstGenerator ## Alias to type less. + PDoc = var RstGenerator ## Alias to type less. CodeBlockParams = object ## Stores code block params. numberLines: bool ## True if the renderer has to show line numbers. startLine: int ## The starting line of the code block, by default 1. langStr: string ## Input string used to specify the language. - lang: TSourceLanguage ## Type of highlighting, by default none. - + lang: SourceLanguage ## Type of highlighting, by default none. +{.deprecated: [TRstGenerator: RstGenerator, TTocEntry: TocEntry, + TOutputTarget: OutputTarget, TMetaEnum: MetaEnum].} proc init(p: var CodeBlockParams) = ## Default initialisation of CodeBlockParams to sane values. @@ -76,14 +77,14 @@ proc init(p: var CodeBlockParams) = p.lang = langNone p.langStr = "" -proc initRstGenerator*(g: var TRstGenerator, target: TOutputTarget, +proc initRstGenerator*(g: var RstGenerator, target: OutputTarget, config: StringTableRef, filename: string, - options: TRstParseOptions, - findFile: TFindFileHandler=nil, - msgHandler: TMsgHandler=nil) = - ## Initializes a ``TRstGenerator``. + options: RstParseOptions, + findFile: FindFileHandler=nil, + msgHandler: MsgHandler=nil) = + ## Initializes a ``RstGenerator``. ## - ## You need to call this before using a ``TRstGenerator`` with any other + ## You need to call this before using a ``RstGenerator`` with any other ## procs in this module. Pass a non ``nil`` ``StringTableRef`` value as ## `config` with parameters used by the HTML output generator. If you don't ## know what to use, pass the results of the `defaultConfig() @@ -96,7 +97,7 @@ proc initRstGenerator*(g: var TRstGenerator, target: TOutputTarget, ## filename``. This default title can be overriden by the embedded rst, but ## it helps to prettify the generated index if no title is found. ## - ## The ``TRstParseOptions``, ``TFindFileHandler`` and ``TMsgHandler`` types + ## The ``RstParseOptions``, ``FindFileHandler`` and ``MsgHandler`` types ## are defined in the the `packages/docutils/rst module <rst.html>`_. ## ``options`` selects the behaviour of the rst parser. ## @@ -120,7 +121,7 @@ proc initRstGenerator*(g: var TRstGenerator, target: TOutputTarget, ## ## import packages/docutils/rstgen ## - ## var gen: TRstGenerator + ## var gen: RstGenerator ## gen.initRstGenerator(outHtml, defaultConfig(), "filename", {}) g.config = config g.target = target @@ -141,7 +142,7 @@ proc initRstGenerator*(g: var TRstGenerator, target: TOutputTarget, if s != "": g.splitAfter = parseInt(s) for i in low(g.meta)..high(g.meta): g.meta[i] = "" -proc writeIndexFile*(g: var TRstGenerator, outfile: string) = +proc writeIndexFile*(g: var RstGenerator, outfile: string) = ## Writes the current index buffer to the specified output file. ## ## You previously need to add entries to the index with the `setIndexTerm() @@ -183,7 +184,7 @@ proc addTexChar(dest: var string, c: char) = var splitter*: string = "<wbr />" -proc escChar*(target: TOutputTarget, dest: var string, c: char) {.inline.} = +proc escChar*(target: OutputTarget, dest: var string, c: char) {.inline.} = case target of outHtml: addXmlChar(dest, c) of outLatex: addTexChar(dest, c) @@ -200,7 +201,7 @@ proc nextSplitPoint*(s: string, start: int): int = inc(result) dec(result) # last valid index -proc esc*(target: TOutputTarget, s: string, splitAfter = -1): string = +proc esc*(target: OutputTarget, s: string, splitAfter = -1): string = result = "" if splitAfter >= 0: var partLen = 0 @@ -217,16 +218,16 @@ proc esc*(target: TOutputTarget, s: string, splitAfter = -1): string = for i in countup(0, len(s) - 1): escChar(target, result, s[i]) -proc disp(target: TOutputTarget, xml, tex: string): string = +proc disp(target: OutputTarget, xml, tex: string): string = if target != outLatex: result = xml else: result = tex -proc dispF(target: TOutputTarget, xml, tex: string, +proc dispF(target: OutputTarget, xml, tex: string, args: varargs[string]): string = if target != outLatex: result = xml % args else: result = tex % args -proc dispA(target: TOutputTarget, dest: var string, +proc dispA(target: OutputTarget, dest: var string, xml, tex: string, args: varargs[string]) = if target != outLatex: addf(dest, xml, args) else: addf(dest, tex, args) @@ -234,10 +235,10 @@ proc dispA(target: TOutputTarget, dest: var string, proc `or`(x, y: string): string {.inline.} = result = if x.isNil: y else: x -proc renderRstToOut*(d: var TRstGenerator, n: PRstNode, result: var string) +proc renderRstToOut*(d: var RstGenerator, n: PRstNode, result: var string) ## Writes into ``result`` the rst ast ``n`` using the ``d`` configuration. ## - ## Before using this proc you need to initialise a ``TRstGenerator`` with + ## Before using this proc you need to initialise a ``RstGenerator`` with ## ``initRstGenerator`` and parse a rst file with ``rstParse`` from the ## `packages/docutils/rst module <rst.html>`_. Example: ## @@ -277,7 +278,7 @@ proc unquoteIndexColumn(text: string): string = ## Returns the unquoted version generated by ``quoteIndexColumn``. result = text.replace("\\t", "\t").replace("\\n", "\n").replace("\\\\", "\\") -proc setIndexTerm*(d: var TRstGenerator, id, term: string, +proc setIndexTerm*(d: var RstGenerator, id, term: string, linkTitle, linkDesc = "") = ## Adds a `term` to the index using the specified hyperlink identifier. ## @@ -351,30 +352,30 @@ proc renderIndexTerm*(d: PDoc, n: PRstNode, result: var string) = [id, term]) type - TIndexEntry = object + IndexEntry = object keyword: string link: string linkTitle: string ## If not nil, contains a prettier text for the href linkDesc: string ## If not nil, the title attribute of the final href - TIndexedDocs = Table[TIndexEntry, seq[TIndexEntry]] ## \ + IndexedDocs = Table[IndexEntry, seq[IndexEntry]] ## \ ## Contains the index sequences for doc types. ## - ## The key is a *fake* TIndexEntry which will contain the title of the + ## The key is a *fake* IndexEntry which will contain the title of the ## document in the `keyword` field and `link` will contain the html ## filename for the document. `linkTitle` and `linkDesc` will be nil. ## - ## The value indexed by this TIndexEntry is a sequence with the real index + ## The value indexed by this IndexEntry is a sequence with the real index ## entries found in the ``.idx`` file. +{.deprecated: [TIndexEntry: IndexEntry, TIndexedDocs: IndexedDocs].} - -proc cmp(a, b: TIndexEntry): int = - ## Sorts two ``TIndexEntry`` first by `keyword` field, then by `link`. +proc cmp(a, b: IndexEntry): int = + ## Sorts two ``IndexEntry`` first by `keyword` field, then by `link`. result = cmpIgnoreStyle(a.keyword, b.keyword) if result == 0: result = cmpIgnoreStyle(a.link, b.link) -proc hash(x: TIndexEntry): THash = +proc hash(x: IndexEntry): Hash = ## Returns the hash for the combined fields of the type. ## ## The hash is computed as the chained hash of the individual string hashes. @@ -385,7 +386,7 @@ proc hash(x: TIndexEntry): THash = result = result !& (x.linkDesc or "").hash result = !$result -proc `<-`(a: var TIndexEntry, b: TIndexEntry) = +proc `<-`(a: var IndexEntry, b: IndexEntry) = shallowCopy a.keyword, b.keyword shallowCopy a.link, b.link if b.linkTitle.isNil: a.linkTitle = nil @@ -393,7 +394,7 @@ proc `<-`(a: var TIndexEntry, b: TIndexEntry) = if b.linkDesc.isNil: a.linkDesc = nil else: shallowCopy a.linkDesc, b.linkDesc -proc sortIndex(a: var openArray[TIndexEntry]) = +proc sortIndex(a: var openArray[IndexEntry]) = # we use shellsort here; fast and simple let n = len(a) var h = 1 @@ -403,7 +404,7 @@ proc sortIndex(a: var openArray[TIndexEntry]) = while true: h = h div 3 for i in countup(h, n - 1): - var v: TIndexEntry + var v: IndexEntry v <- a[i] var j = i while cmp(a[j-h], v) >= 0: @@ -413,7 +414,7 @@ proc sortIndex(a: var openArray[TIndexEntry]) = a[j] <- v if h == 1: break -proc generateSymbolIndex(symbols: seq[TIndexEntry]): string = +proc generateSymbolIndex(symbols: seq[IndexEntry]): string = result = "" var i = 0 while i < symbols.len: @@ -466,7 +467,7 @@ proc indentToLevel(level: var int, newLevel: int): string = result = repeat("</ul>", level - newLevel) level = newLevel -proc generateDocumentationTOC(entries: seq[TIndexEntry]): string = +proc generateDocumentationTOC(entries: seq[IndexEntry]): string = ## Returns the sequence of index entries in an HTML hierarchical list. result = "" # Build a list of levels and extracted titles to make processing easier. @@ -507,12 +508,12 @@ proc generateDocumentationTOC(entries: seq[TIndexEntry]): string = assert(not titleRef.isNil, "Can't use this proc on an API index, docs always have a title entry") -proc generateDocumentationIndex(docs: TIndexedDocs): string = +proc generateDocumentationIndex(docs: IndexedDocs): string = ## Returns all the documentation TOCs in an HTML hierarchical list. result = "" # Sort the titles to generate their toc in alphabetical order. - var titles = toSeq(keys[TIndexEntry, seq[TIndexEntry]](docs)) + var titles = toSeq(keys[IndexEntry, seq[IndexEntry]](docs)) sort(titles, cmp) for title in titles: @@ -520,12 +521,12 @@ proc generateDocumentationIndex(docs: TIndexedDocs): string = result.add("<ul><li><a href=\"" & title.link & "\">" & title.keyword & "</a>\n" & tocList & "</ul>\n") -proc generateDocumentationJumps(docs: TIndexedDocs): string = +proc generateDocumentationJumps(docs: IndexedDocs): string = ## Returns a plain list of hyperlinks to documentation TOCs in HTML. result = "Documents: " # Sort the titles to generate their toc in alphabetical order. - var titles = toSeq(keys[TIndexEntry, seq[TIndexEntry]](docs)) + var titles = toSeq(keys[IndexEntry, seq[IndexEntry]](docs)) sort(titles, cmp) var chunks: seq[string] = @[] @@ -545,14 +546,14 @@ proc generateModuleJumps(modules: seq[string]): string = result.add(chunks.join(", ") & ".<br>") proc readIndexDir(dir: string): - tuple[modules: seq[string], symbols: seq[TIndexEntry], docs: TIndexedDocs] = - ## Walks `dir` reading ``.idx`` files converting them in TIndexEntry items. + tuple[modules: seq[string], symbols: seq[IndexEntry], docs: IndexedDocs] = + ## Walks `dir` reading ``.idx`` files converting them in IndexEntry items. ## ## Returns the list of found module names, the list of free symbol entries ## and the different documentation indexes. The list of modules is sorted. ## See the documentation of ``mergeIndexes`` for details. result.modules = @[] - result.docs = initTable[TIndexEntry, seq[TIndexEntry]](32) + result.docs = initTable[IndexEntry, seq[IndexEntry]](32) newSeq(result.symbols, 15_000) setLen(result.symbols, 0) var L = 0 @@ -560,8 +561,8 @@ proc readIndexDir(dir: string): for kind, path in walkDir(dir): if kind == pcFile and path.endsWith(IndexExt): var - fileEntries: seq[TIndexEntry] - title: TIndexEntry + fileEntries: seq[IndexEntry] + title: IndexEntry F = 0 newSeq(fileEntries, 500) setLen(fileEntries, 0) @@ -662,7 +663,7 @@ proc mergeIndexes*(dir: string): string = proc stripTOCHTML(s: string): string = ## Ugly quick hack to remove HTML tags from TOC titles. ## - ## A TTocEntry.header field already contains rendered HTML tags. Instead of + ## A TocEntry.header field already contains rendered HTML tags. Instead of ## implementing a proper version of renderRstToOut() which recursively ## renders an rst tree to plain text, we simply remove text found between ## angled brackets. Given the limited possibilities of rst inside TOC titles @@ -728,12 +729,12 @@ proc renderOverline(d: PDoc, n: PRstNode, result: var string) = rstnodeToRefname(n), tmp, $chr(n.level - 1 + ord('A'))]) -proc renderTocEntry(d: PDoc, e: TTocEntry, result: var string) = +proc renderTocEntry(d: PDoc, e: TocEntry, result: var string) = dispA(d.target, result, "<li><a class=\"reference\" id=\"$1_toc\" href=\"#$1\">$2</a></li>\n", "\\item\\label{$1_toc} $2\\ref{$1}\n", [e.refname, e.header]) -proc renderTocEntries*(d: var TRstGenerator, j: var int, lvl: int, +proc renderTocEntries*(d: var RstGenerator, j: var int, lvl: int, result: var string) = var tmp = "" while j <= high(d.tocPart): @@ -878,7 +879,7 @@ proc renderCodeBlock(d: PDoc, n: PRstNode, result: var string) = d.msgHandler(d.filename, 1, 0, mwUnsupportedLanguage, params.langStr) for letter in m.text: escChar(d.target, result, letter) else: - var g: TGeneralTokenizer + var g: GeneralTokenizer initGeneralTokenizer(g, m.text) while true: getNextToken(g, params.lang) @@ -1214,7 +1215,7 @@ $content # ---------- forum --------------------------------------------------------- -proc rstToHtml*(s: string, options: TRstParseOptions, +proc rstToHtml*(s: string, options: RstParseOptions, config: StringTableRef): string = ## Converts an input rst string into embeddable HTML. ## @@ -1233,7 +1234,7 @@ proc rstToHtml*(s: string, options: TRstParseOptions, ## # --> <em>Hello</em> <strong>world</strong>! ## ## If you need to allow the rst ``include`` directive or tweak the generated - ## output you have to create your own ``TRstGenerator`` with + ## output you have to create your own ``RstGenerator`` with ## ``initRstGenerator`` and related procs. proc myFindFile(filename: string): string = @@ -1241,7 +1242,7 @@ proc rstToHtml*(s: string, options: TRstParseOptions, result = "" const filen = "input" - var d: TRstGenerator + var d: RstGenerator initRstGenerator(d, outHtml, config, filen, options, myFindFile, rst.defaultMsgHandler) var dummyHasToc = false diff --git a/lib/posix/inotify.nim b/lib/posix/inotify.nim index c6f0633ff..14cac4d72 100644 --- a/lib/posix/inotify.nim +++ b/lib/posix/inotify.nim @@ -12,14 +12,15 @@ # Get the platform-dependent flags. # Structure describing an inotify event. type - Tinotify_event*{.pure, final, importc: "struct inotify_event", + InotifyEvent*{.pure, final, importc: "struct inotify_event", header: "<sys/inotify.h>".} = object wd*{.importc: "wd".}: cint # Watch descriptor. mask*{.importc: "mask".}: uint32 # Watch mask. cookie*{.importc: "cookie".}: uint32 # Cookie to synchronize two events. len*{.importc: "len".}: uint32 # Length (including NULs) of name. name*{.importc: "name".}: char # Name. - +{.deprecated: [Tinotify_event: InotifyEvent].} + # Supported events suitable for MASK parameter of INOTIFY_ADD_WATCH. const IN_ACCESS* = 0x00000001 # File was accessed. @@ -69,4 +70,4 @@ proc inotify_add_watch*(fd: cint; name: cstring; mask: uint32): cint{. cdecl, importc: "inotify_add_watch", header: "<sys/inotify.h>".} # Remove the watch specified by WD from the inotify instance FD. proc inotify_rm_watch*(fd: cint; wd: cint): cint{.cdecl, - importc: "inotify_rm_watch", header: "<sys/inotify.h>".} \ No newline at end of file + importc: "inotify_rm_watch", header: "<sys/inotify.h>".} diff --git a/lib/posix/linux.nim b/lib/posix/linux.nim index be591e29a..05eab52bc 100644 --- a/lib/posix/linux.nim +++ b/lib/posix/linux.nim @@ -24,5 +24,5 @@ const # fn should be of type proc (a2: pointer): void {.cdecl.} proc clone*(fn: pointer; child_stack: pointer; flags: cint; - arg: pointer; ptid: ptr TPid; tls: pointer; - ctid: ptr TPid): cint {.importc, header: "<sched.h>".} + arg: pointer; ptid: ptr Pid; tls: pointer; + ctid: ptr Pid): cint {.importc, header: "<sched.h>".} diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim index 0c7b84090..dba79cbf6 100644 --- a/lib/posix/posix.nim +++ b/lib/posix/posix.nim @@ -81,9 +81,10 @@ const DT_WHT* = 14 type - TDIR* {.importc: "DIR", header: "<dirent.h>", + DIR* {.importc: "DIR", header: "<dirent.h>", incompleteStruct.} = object ## A type representing a directory stream. +{.deprecated: [TDIR: DIR].} type SocketHandle* = distinct cint # The type used to represent socket descriptors @@ -91,47 +92,47 @@ type {.deprecated: [TSocketHandle: SocketHandle].} type - Tdirent* {.importc: "struct dirent", + Dirent* {.importc: "struct dirent", header: "<dirent.h>", final, pure.} = object ## dirent_t struct - d_ino*: Tino ## File serial number. + d_ino*: Ino ## File serial number. when defined(linux) or defined(macosx) or defined(bsd): d_reclen*: cshort ## Length of this record. (not POSIX) d_type*: int8 ## Type of file; not supported by all filesystem types. ## (not POSIX) when defined(linux) or defined(bsd): - d_off*: TOff ## Not an offset. Value that ``telldir()`` would return. + d_off*: Off ## Not an offset. Value that ``telldir()`` would return. d_name*: array [0..255, char] ## Name of entry. Tflock* {.importc: "struct flock", final, pure, header: "<fcntl.h>".} = object ## flock type l_type*: cshort ## Type of lock; F_RDLCK, F_WRLCK, F_UNLCK. l_whence*: cshort ## Flag for starting offset. - l_start*: TOff ## Relative offset in bytes. - l_len*: TOff ## Size; if 0 then until EOF. - l_pid*: TPid ## Process ID of the process holding the lock; + l_start*: Off ## Relative offset in bytes. + l_len*: Off ## Size; if 0 then until EOF. + l_pid*: Pid ## Process ID of the process holding the lock; ## returned with F_GETLK. - TFTW* {.importc: "struct FTW", header: "<ftw.h>", final, pure.} = object + FTW* {.importc: "struct FTW", header: "<ftw.h>", final, pure.} = object base*: cint level*: cint - TGlob* {.importc: "glob_t", header: "<glob.h>", + Glob* {.importc: "glob_t", header: "<glob.h>", final, pure.} = object ## glob_t gl_pathc*: int ## Count of paths matched by pattern. gl_pathv*: cstringArray ## Pointer to a list of matched pathnames. gl_offs*: int ## Slots to reserve at the beginning of gl_pathv. - TGroup* {.importc: "struct group", header: "<grp.h>", + Group* {.importc: "struct group", header: "<grp.h>", final, pure.} = object ## struct group gr_name*: cstring ## The name of the group. - gr_gid*: TGid ## Numerical group ID. + gr_gid*: Gid ## Numerical group ID. gr_mem*: cstringArray ## Pointer to a null-terminated array of character ## pointers to member names. - Ticonv* {.importc: "iconv_t", header: "<iconv.h>", final, pure.} = + Iconv* {.importc: "iconv_t", header: "<iconv.h>", final, pure.} = object ## Identifies the conversion from one codeset to another. - Tlconv* {.importc: "struct lconv", header: "<locale.h>", final, + Lconv* {.importc: "struct lconv", header: "<locale.h>", final, pure.} = object currency_symbol*: cstring decimal_point*: cstring @@ -158,8 +159,8 @@ type p_sign_posn*: char thousands_sep*: cstring - TMqd* {.importc: "mqd_t", header: "<mqueue.h>", final, pure.} = object - TMqAttr* {.importc: "struct mq_attr", + Mqd* {.importc: "mqd_t", header: "<mqueue.h>", final, pure.} = object + MqAttr* {.importc: "struct mq_attr", header: "<mqueue.h>", final, pure.} = object ## message queue attribute mq_flags*: int ## Message queue flags. @@ -167,64 +168,64 @@ type mq_msgsize*: int ## Maximum message size. mq_curmsgs*: int ## Number of messages currently queued. - TPasswd* {.importc: "struct passwd", header: "<pwd.h>", + Passwd* {.importc: "struct passwd", header: "<pwd.h>", final, pure.} = object ## struct passwd pw_name*: cstring ## User's login name. - pw_uid*: Tuid ## Numerical user ID. - pw_gid*: TGid ## Numerical group ID. + pw_uid*: Uid ## Numerical user ID. + pw_gid*: Gid ## Numerical group ID. pw_dir*: cstring ## Initial working directory. pw_shell*: cstring ## Program to use as shell. - Tblkcnt* {.importc: "blkcnt_t", header: "<sys/types.h>".} = int + Blkcnt* {.importc: "blkcnt_t", header: "<sys/types.h>".} = int ## used for file block counts - Tblksize* {.importc: "blksize_t", header: "<sys/types.h>".} = int + Blksize* {.importc: "blksize_t", header: "<sys/types.h>".} = int ## used for block sizes - TClock* {.importc: "clock_t", header: "<sys/types.h>".} = int - TClockId* {.importc: "clockid_t", header: "<sys/types.h>".} = int - TDev* {.importc: "dev_t", header: "<sys/types.h>".} = int - Tfsblkcnt* {.importc: "fsblkcnt_t", header: "<sys/types.h>".} = int - Tfsfilcnt* {.importc: "fsfilcnt_t", header: "<sys/types.h>".} = int - TGid* {.importc: "gid_t", header: "<sys/types.h>".} = int - Tid* {.importc: "id_t", header: "<sys/types.h>".} = int - Tino* {.importc: "ino_t", header: "<sys/types.h>".} = int - TKey* {.importc: "key_t", header: "<sys/types.h>".} = int - TMode* {.importc: "mode_t", header: "<sys/types.h>".} = cint - TNlink* {.importc: "nlink_t", header: "<sys/types.h>".} = int - TOff* {.importc: "off_t", header: "<sys/types.h>".} = int64 - TPid* {.importc: "pid_t", header: "<sys/types.h>".} = int - Tpthread_attr* {.importc: "pthread_attr_t", header: "<sys/types.h>".} = int - Tpthread_barrier* {.importc: "pthread_barrier_t", + Clock* {.importc: "clock_t", header: "<sys/types.h>".} = int + ClockId* {.importc: "clockid_t", header: "<sys/types.h>".} = int + Dev* {.importc: "dev_t", header: "<sys/types.h>".} = int + Fsblkcnt* {.importc: "fsblkcnt_t", header: "<sys/types.h>".} = int + Fsfilcnt* {.importc: "fsfilcnt_t", header: "<sys/types.h>".} = int + Gid* {.importc: "gid_t", header: "<sys/types.h>".} = int + Id* {.importc: "id_t", header: "<sys/types.h>".} = int + Ino* {.importc: "ino_t", header: "<sys/types.h>".} = int + Key* {.importc: "key_t", header: "<sys/types.h>".} = int + Mode* {.importc: "mode_t", header: "<sys/types.h>".} = cint + Nlink* {.importc: "nlink_t", header: "<sys/types.h>".} = int + Off* {.importc: "off_t", header: "<sys/types.h>".} = int64 + Pid* {.importc: "pid_t", header: "<sys/types.h>".} = int + Pthread_attr* {.importc: "pthread_attr_t", header: "<sys/types.h>".} = int + Pthread_barrier* {.importc: "pthread_barrier_t", header: "<sys/types.h>".} = int - Tpthread_barrierattr* {.importc: "pthread_barrierattr_t", + Pthread_barrierattr* {.importc: "pthread_barrierattr_t", header: "<sys/types.h>".} = int - Tpthread_cond* {.importc: "pthread_cond_t", header: "<sys/types.h>".} = int - Tpthread_condattr* {.importc: "pthread_condattr_t", + Pthread_cond* {.importc: "pthread_cond_t", header: "<sys/types.h>".} = int + Pthread_condattr* {.importc: "pthread_condattr_t", header: "<sys/types.h>".} = int - Tpthread_key* {.importc: "pthread_key_t", header: "<sys/types.h>".} = int - Tpthread_mutex* {.importc: "pthread_mutex_t", header: "<sys/types.h>".} = int - Tpthread_mutexattr* {.importc: "pthread_mutexattr_t", + Pthread_key* {.importc: "pthread_key_t", header: "<sys/types.h>".} = int + Pthread_mutex* {.importc: "pthread_mutex_t", header: "<sys/types.h>".} = int + Pthread_mutexattr* {.importc: "pthread_mutexattr_t", header: "<sys/types.h>".} = int - Tpthread_once* {.importc: "pthread_once_t", header: "<sys/types.h>".} = int - Tpthread_rwlock* {.importc: "pthread_rwlock_t", + Pthread_once* {.importc: "pthread_once_t", header: "<sys/types.h>".} = int + Pthread_rwlock* {.importc: "pthread_rwlock_t", header: "<sys/types.h>".} = int - Tpthread_rwlockattr* {.importc: "pthread_rwlockattr_t", + Pthread_rwlockattr* {.importc: "pthread_rwlockattr_t", header: "<sys/types.h>".} = int - Tpthread_spinlock* {.importc: "pthread_spinlock_t", + Pthread_spinlock* {.importc: "pthread_spinlock_t", header: "<sys/types.h>".} = int - Tpthread* {.importc: "pthread_t", header: "<sys/types.h>".} = int - Tsuseconds* {.importc: "suseconds_t", header: "<sys/types.h>".} = int + Pthread* {.importc: "pthread_t", header: "<sys/types.h>".} = int + Suseconds* {.importc: "suseconds_t", header: "<sys/types.h>".} = int #Ttime* {.importc: "time_t", header: "<sys/types.h>".} = int - Ttimer* {.importc: "timer_t", header: "<sys/types.h>".} = int - Ttrace_attr* {.importc: "trace_attr_t", header: "<sys/types.h>".} = int - Ttrace_event_id* {.importc: "trace_event_id_t", + Timer* {.importc: "timer_t", header: "<sys/types.h>".} = int + Trace_attr* {.importc: "trace_attr_t", header: "<sys/types.h>".} = int + Trace_event_id* {.importc: "trace_event_id_t", header: "<sys/types.h>".} = int - Ttrace_event_set* {.importc: "trace_event_set_t", + Trace_event_set* {.importc: "trace_event_set_t", header: "<sys/types.h>".} = int - Ttrace_id* {.importc: "trace_id_t", header: "<sys/types.h>".} = int - Tuid* {.importc: "uid_t", header: "<sys/types.h>".} = int - Tuseconds* {.importc: "useconds_t", header: "<sys/types.h>".} = int + Trace_id* {.importc: "trace_id_t", header: "<sys/types.h>".} = int + Uid* {.importc: "uid_t", header: "<sys/types.h>".} = int + Useconds* {.importc: "useconds_t", header: "<sys/types.h>".} = int - Tutsname* {.importc: "struct utsname", + Utsname* {.importc: "struct utsname", header: "<sys/utsname.h>", final, pure.} = object ## struct utsname sysname*, ## Name of this implementation of the operating system. @@ -235,25 +236,25 @@ type machine*: array [0..255, char] ## Name of the hardware type on which the ## system is running. - TSem* {.importc: "sem_t", header: "<semaphore.h>", final, pure.} = object - Tipc_perm* {.importc: "struct ipc_perm", + Sem* {.importc: "sem_t", header: "<semaphore.h>", final, pure.} = object + Ipc_perm* {.importc: "struct ipc_perm", header: "<sys/ipc.h>", final, pure.} = object ## struct ipc_perm - uid*: Tuid ## Owner's user ID. - gid*: TGid ## Owner's group ID. - cuid*: Tuid ## Creator's user ID. - cgid*: TGid ## Creator's group ID. - mode*: TMode ## Read/write permission. + uid*: Uid ## Owner's user ID. + gid*: Gid ## Owner's group ID. + cuid*: Uid ## Creator's user ID. + cgid*: Gid ## Creator's group ID. + mode*: Mode ## Read/write permission. - TStat* {.importc: "struct stat", + Stat* {.importc: "struct stat", header: "<sys/stat.h>", final, pure.} = object ## struct stat - st_dev*: TDev ## Device ID of device containing file. - st_ino*: Tino ## File serial number. - st_mode*: TMode ## Mode of file (see below). - st_nlink*: TNlink ## Number of hard links to the file. - st_uid*: Tuid ## User ID of file. - st_gid*: TGid ## Group ID of file. - st_rdev*: TDev ## Device ID (if file is character or block special). - st_size*: TOff ## For regular files, the file size in bytes. + st_dev*: Dev ## Device ID of device containing file. + st_ino*: Ino ## File serial number. + st_mode*: Mode ## Mode of file (see below). + st_nlink*: Nlink ## Number of hard links to the file. + st_uid*: Uid ## User ID of file. + st_gid*: Gid ## Group ID of file. + st_rdev*: Dev ## Device ID (if file is character or block special). + st_size*: Off ## For regular files, the file size in bytes. ## For symbolic links, the length in bytes of the ## pathname contained in the symbolic link. ## For a shared memory object, the length in bytes. @@ -263,34 +264,34 @@ type st_atime*: Time ## Time of last access. st_mtime*: Time ## Time of last data modification. st_ctime*: Time ## Time of last status change. - st_blksize*: Tblksize ## A file system-specific preferred I/O block size + st_blksize*: Blksize ## A file system-specific preferred I/O block size ## for this object. In some file system types, this ## may vary from file to file. - st_blocks*: Tblkcnt ## Number of blocks allocated for this object. + st_blocks*: Blkcnt ## Number of blocks allocated for this object. - TStatvfs* {.importc: "struct statvfs", header: "<sys/statvfs.h>", + Statvfs* {.importc: "struct statvfs", header: "<sys/statvfs.h>", final, pure.} = object ## struct statvfs f_bsize*: int ## File system block size. f_frsize*: int ## Fundamental file system block size. - f_blocks*: Tfsblkcnt ## Total number of blocks on file system + f_blocks*: Fsblkcnt ## Total number of blocks on file system ## in units of f_frsize. - f_bfree*: Tfsblkcnt ## Total number of free blocks. - f_bavail*: Tfsblkcnt ## Number of free blocks available to + f_bfree*: Fsblkcnt ## Total number of free blocks. + f_bavail*: Fsblkcnt ## Number of free blocks available to ## non-privileged process. - f_files*: Tfsfilcnt ## Total number of file serial numbers. - f_ffree*: Tfsfilcnt ## Total number of free file serial numbers. - f_favail*: Tfsfilcnt ## Number of file serial numbers available to + f_files*: Fsfilcnt ## Total number of file serial numbers. + f_ffree*: Fsfilcnt ## Total number of free file serial numbers. + f_favail*: Fsfilcnt ## Number of file serial numbers available to ## non-privileged process. f_fsid*: int ## File system ID. f_flag*: int ## Bit mask of f_flag values. f_namemax*: int ## Maximum filename length. - Tposix_typed_mem_info* {.importc: "struct posix_typed_mem_info", + Posix_typed_mem_info* {.importc: "struct posix_typed_mem_info", header: "<sys/mman.h>", final, pure.} = object posix_tmi_length*: int - Ttm* {.importc: "struct tm", header: "<time.h>", + Tm* {.importc: "struct tm", header: "<time.h>", final, pure.} = object ## struct tm tm_sec*: cint ## Seconds [0,60]. tm_min*: cint ## Minutes [0,59]. @@ -301,79 +302,79 @@ type tm_wday*: cint ## Day of week [0,6] (Sunday =0). tm_yday*: cint ## Day of year [0,365]. tm_isdst*: cint ## Daylight Savings flag. - Ttimespec* {.importc: "struct timespec", + Timespec* {.importc: "struct timespec", header: "<time.h>", final, pure.} = object ## struct timespec tv_sec*: Time ## Seconds. tv_nsec*: int ## Nanoseconds. - titimerspec* {.importc: "struct itimerspec", header: "<time.h>", + Itimerspec* {.importc: "struct itimerspec", header: "<time.h>", final, pure.} = object ## struct itimerspec - it_interval*: Ttimespec ## Timer period. - it_value*: Ttimespec ## Timer expiration. + it_interval*: Timespec ## Timer period. + it_value*: Timespec ## Timer expiration. - Tsig_atomic* {.importc: "sig_atomic_t", header: "<signal.h>".} = cint + Sig_atomic* {.importc: "sig_atomic_t", header: "<signal.h>".} = cint ## Possibly volatile-qualified integer type of an object that can be ## accessed as an atomic entity, even in the presence of asynchronous ## interrupts. - Tsigset* {.importc: "sigset_t", header: "<signal.h>", final, pure.} = object + Sigset* {.importc: "sigset_t", header: "<signal.h>", final, pure.} = object - TsigEvent* {.importc: "struct sigevent", + SigEvent* {.importc: "struct sigevent", header: "<signal.h>", final, pure.} = object ## struct sigevent sigev_notify*: cint ## Notification type. sigev_signo*: cint ## Signal number. - sigev_value*: TsigVal ## Signal value. - sigev_notify_function*: proc (x: TsigVal) {.noconv.} ## Notification func. - sigev_notify_attributes*: ptr Tpthread_attr ## Notification attributes. + sigev_value*: SigVal ## Signal value. + sigev_notify_function*: proc (x: SigVal) {.noconv.} ## Notification func. + sigev_notify_attributes*: ptr PthreadAttr ## Notification attributes. - TsigVal* {.importc: "union sigval", + SigVal* {.importc: "union sigval", header: "<signal.h>", final, pure.} = object ## struct sigval sival_ptr*: pointer ## pointer signal value; ## integer signal value not defined! - TSigaction* {.importc: "struct sigaction", + Sigaction* {.importc: "struct sigaction", header: "<signal.h>", final, pure.} = object ## struct sigaction sa_handler*: proc (x: cint) {.noconv.} ## Pointer to a signal-catching ## function or one of the macros ## SIG_IGN or SIG_DFL. - sa_mask*: Tsigset ## Set of signals to be blocked during execution of + sa_mask*: Sigset ## Set of signals to be blocked during execution of ## the signal handling function. sa_flags*: cint ## Special flags. - sa_sigaction*: proc (x: cint, y: var TsigInfo, z: pointer) {.noconv.} + sa_sigaction*: proc (x: cint, y: var SigInfo, z: pointer) {.noconv.} - TStack* {.importc: "stack_t", + Stack* {.importc: "stack_t", header: "<signal.h>", final, pure.} = object ## stack_t ss_sp*: pointer ## Stack base or pointer. ss_size*: int ## Stack size. ss_flags*: cint ## Flags. - TSigStack* {.importc: "struct sigstack", + SigStack* {.importc: "struct sigstack", header: "<signal.h>", final, pure.} = object ## struct sigstack ss_onstack*: cint ## Non-zero when signal stack is in use. ss_sp*: pointer ## Signal stack pointer. - TsigInfo* {.importc: "siginfo_t", + SigInfo* {.importc: "siginfo_t", header: "<signal.h>", final, pure.} = object ## siginfo_t si_signo*: cint ## Signal number. si_code*: cint ## Signal code. si_errno*: cint ## If non-zero, an errno value associated with ## this signal, as defined in <errno.h>. - si_pid*: TPid ## Sending process ID. - si_uid*: Tuid ## Real user ID of sending process. + si_pid*: Pid ## Sending process ID. + si_uid*: Uid ## Real user ID of sending process. si_addr*: pointer ## Address of faulting instruction. si_status*: cint ## Exit value or signal. si_band*: int ## Band event for SIGPOLL. - si_value*: TsigVal ## Signal value. + si_value*: SigVal ## Signal value. - Tnl_item* {.importc: "nl_item", header: "<nl_types.h>".} = cint - Tnl_catd* {.importc: "nl_catd", header: "<nl_types.h>".} = cint + Nl_item* {.importc: "nl_item", header: "<nl_types.h>".} = cint + Nl_catd* {.importc: "nl_catd", header: "<nl_types.h>".} = cint - Tsched_param* {.importc: "struct sched_param", + Sched_param* {.importc: "struct sched_param", header: "<sched.h>", final, pure.} = object ## struct sched_param sched_priority*: cint sched_ss_low_priority*: cint ## Low scheduling priority for ## sporadic server. - sched_ss_repl_period*: Ttimespec ## Replenishment period for + sched_ss_repl_period*: Timespec ## Replenishment period for ## sporadic server. - sched_ss_init_budget*: Ttimespec ## Initial budget for sporadic server. + sched_ss_init_budget*: Timespec ## Initial budget for sporadic server. sched_ss_max_repl*: cint ## Maximum pending replenishments for ## sporadic server. @@ -383,28 +384,52 @@ type tv_usec*: int ## Microseconds. TFdSet* {.importc: "fd_set", header: "<sys/select.h>", final, pure.} = object - Tmcontext* {.importc: "mcontext_t", header: "<ucontext.h>", + Mcontext* {.importc: "mcontext_t", header: "<ucontext.h>", final, pure.} = object - Tucontext* {.importc: "ucontext_t", header: "<ucontext.h>", + Ucontext* {.importc: "ucontext_t", header: "<ucontext.h>", final, pure.} = object ## ucontext_t - uc_link*: ptr Tucontext ## Pointer to the context that is resumed + uc_link*: ptr Ucontext ## Pointer to the context that is resumed ## when this context returns. - uc_sigmask*: Tsigset ## The set of signals that are blocked when this + uc_sigmask*: Sigset ## The set of signals that are blocked when this ## context is active. - uc_stack*: TStack ## The stack used by this context. - uc_mcontext*: Tmcontext ## A machine-specific representation of the saved + uc_stack*: Stack ## The stack used by this context. + uc_mcontext*: Mcontext ## A machine-specific representation of the saved ## context. - +{.deprecated: [TOff: Off, TPid: Pid, TGid: Gid, TMode: Mode, TDev: Dev, + TNlink: Nlink, TStack: Stack, TGroup: Group, TMqd: Mqd, + TPasswd: Passwd, TClock: Clock, TClockId: ClockId, TKey: Key, + TSem: Sem, Tpthread_attr: PthreadAttr, Ttimespec: Timespec, + Tdirent: Dirent, TFTW: FTW, TGlob: Glob, + # Tflock: Flock, # Naming conflict if we drop the `T` + Ticonv: Iconv, Tlconv: Lconv, TMqAttr: MqAttr, Tblkcnt: Blkcnt, + Tblksize: Blksize, Tfsblkcnt: Fsblkcnt, Tfsfilcnt: Fsfilcnt, + Tid: Id, Tino: Ino, Tpthread_barrier: Pthread_barrier, + Tpthread_barrierattr: Pthread_barrierattr, Tpthread_cond: Pthread_cond, + TPthread_condattr: Pthread_condattr, Tpthread_key: Pthread_key, + Tpthread_mutex: Pthread_mutex, Tpthread_mutexattr: Pthread_mutexattr, + Tpthread_once: Pthread_once, Tpthread_rwlock: Pthread_rwlock, + Tpthread_rwlockattr: Pthread_rwlockattr, Tpthread_spinlock: Pthread_spinlock, + Tpthread: Pthread, Tsuseconds: Suseconds, Ttimer: Timer, + Ttrace_attr: Trace_attr, Ttrace_event_id: Trace_event_id, + Ttrace_event_set: Trace_event_set, Ttrace_id: Trace_id, + Tuid: Uid, Tuseconds: Useconds, Tutsname: Utsname, Tipc_perm: Ipc_perm, + TStat: Stat, TStatvfs: Statvfs, Tposix_typed_mem_info: Posix_typed_mem_info, + Ttm: Tm, titimerspec: Itimerspec, Tsig_atomic: Sig_atomic, Tsigset: Sigset, + TsigEvent: SigEvent, TsigVal: SigVal, TSigaction: Sigaction, + TSigStack: SigStack, TsigInfo: SigInfo, Tnl_item: Nl_item, + Tnl_catd: Nl_catd, Tsched_param: Sched_param, + # TFdSet: FdSet, # Naming conflict if we drop the `T` + Tmcontext: Mcontext, Tucontext: Ucontext].} when hasAioH: type Taiocb* {.importc: "struct aiocb", header: "<aio.h>", final, pure.} = object ## struct aiocb aio_fildes*: cint ## File descriptor. - aio_offset*: TOff ## File offset. + aio_offset*: Off ## File offset. aio_buf*: pointer ## Location of buffer. aio_nbytes*: int ## Length of transfer. aio_reqprio*: cint ## Request priority offset. - aio_sigevent*: TsigEvent ## Signal number and value. + aio_sigevent*: SigEvent ## Signal number and value. aio_lio_opcode: cint ## Operation to be performed. when hasSpawnH: @@ -434,7 +459,7 @@ type if_name*: cstring ## Null-terminated name of the interface. - TIOVec* {.importc: "struct iovec", pure, final, + IOVec* {.importc: "struct iovec", pure, final, header: "<sys/uio.h>".} = object ## struct iovec iov_base*: pointer ## Base address of a memory region for input or output. iov_len*: int ## The size of the memory pointed to by iov_base. @@ -443,7 +468,7 @@ type header: "<sys/socket.h>".} = object ## struct msghdr msg_name*: pointer ## Optional address. msg_namelen*: Socklen ## Size of address. - msg_iov*: ptr TIOVec ## Scatter/gather array. + msg_iov*: ptr IOVec ## Scatter/gather array. msg_iovlen*: cint ## Members in msg_iov. msg_control*: pointer ## Ancillary data; see below. msg_controllen*: Socklen ## Ancillary data buffer len. @@ -461,37 +486,37 @@ type l_onoff*: cint ## Indicates whether linger option is enabled. l_linger*: cint ## Linger time, in seconds. - TInPort* = int16 ## unsigned! - TInAddrScalar* = int32 ## unsigned! + InPort* = int16 ## unsigned! + InAddrScalar* = int32 ## unsigned! - TInAddrT* {.importc: "in_addr_t", pure, final, + InAddrT* {.importc: "in_addr_t", pure, final, header: "<netinet/in.h>".} = int32 ## unsigned! InAddr* {.importc: "struct in_addr", pure, final, header: "<netinet/in.h>".} = object ## struct in_addr - s_addr*: TInAddrScalar + s_addr*: InAddrScalar Sockaddr_in* {.importc: "struct sockaddr_in", pure, final, header: "<netinet/in.h>".} = object ## struct sockaddr_in sin_family*: TSa_Family ## AF_INET. - sin_port*: TInPort ## Port number. + sin_port*: InPort ## Port number. sin_addr*: InAddr ## IP address. - TIn6Addr* {.importc: "struct in6_addr", pure, final, + In6Addr* {.importc: "struct in6_addr", pure, final, header: "<netinet/in.h>".} = object ## struct in6_addr s6_addr*: array [0..15, char] Tsockaddr_in6* {.importc: "struct sockaddr_in6", pure, final, header: "<netinet/in.h>".} = object ## struct sockaddr_in6 sin6_family*: TSa_Family ## AF_INET6. - sin6_port*: TInPort ## Port number. + sin6_port*: InPort ## Port number. sin6_flowinfo*: int32 ## IPv6 traffic class and flow information. - sin6_addr*: TIn6Addr ## IPv6 address. + sin6_addr*: In6Addr ## IPv6 address. sin6_scope_id*: int32 ## Set of interfaces for a scope. Tipv6_mreq* {.importc: "struct ipv6_mreq", pure, final, header: "<netinet/in.h>".} = object ## struct ipv6_mreq - ipv6mr_multiaddr*: TIn6Addr ## IPv6 multicast address. + ipv6mr_multiaddr*: In6Addr ## IPv6 multicast address. ipv6mr_interface*: cint ## Interface index. Hostent* {.importc: "struct hostent", pure, final, @@ -516,7 +541,7 @@ type n_addrtype*: cint ## The address type of the network. n_net*: int32 ## The network number, in host byte order. - TProtoent* {.importc: "struct protoent", pure, final, + Protoent* {.importc: "struct protoent", pure, final, header: "<netdb.h>".} = object ## struct protoent p_name*: cstring ## Official name of the protocol. p_aliases*: cstringArray ## A pointer to an array of pointers to @@ -557,7 +582,8 @@ type {.deprecated: [TSockaddr_in: Sockaddr_in, TAddrinfo: AddrInfo, TSockAddr: SockAddr, TSockLen: SockLen, TTimeval: Timeval, Thostent: Hostent, TServent: Servent, - TInAddr: InAddr].} + TInAddr: InAddr, TIOVec: IOVec, TInPort: InPort, TInAddrT: InAddrT, + TIn6Addr: In6Addr, TInAddrScalar: InAddrScalar, TProtoent: Protoent].} var errno* {.importc, header: "<errno.h>".}: cint ## error variable @@ -1629,9 +1655,9 @@ var IPPROTO_UDP* {.importc, header: "<netinet/in.h>".}: cint ## User datagram protocol. - INADDR_ANY* {.importc, header: "<netinet/in.h>".}: TInAddrScalar + INADDR_ANY* {.importc, header: "<netinet/in.h>".}: InAddrScalar ## IPv4 local host address. - INADDR_BROADCAST* {.importc, header: "<netinet/in.h>".}: TInAddrScalar + INADDR_BROADCAST* {.importc, header: "<netinet/in.h>".}: InAddrScalar ## IPv4 broadcast address. INET_ADDRSTRLEN* {.importc, header: "<netinet/in.h>".}: cint @@ -1766,11 +1792,11 @@ when hasAioH: proc aio_fsync*(a1: cint, a2: ptr Taiocb): cint {.importc, header: "<aio.h>".} proc aio_read*(a1: ptr Taiocb): cint {.importc, header: "<aio.h>".} proc aio_return*(a1: ptr Taiocb): int {.importc, header: "<aio.h>".} - proc aio_suspend*(a1: ptr ptr Taiocb, a2: cint, a3: ptr Ttimespec): cint {. + proc aio_suspend*(a1: ptr ptr Taiocb, a2: cint, a3: ptr Timespec): cint {. importc, header: "<aio.h>".} proc aio_write*(a1: ptr Taiocb): cint {.importc, header: "<aio.h>".} proc lio_listio*(a1: cint, a2: ptr ptr Taiocb, a3: cint, - a4: ptr TsigEvent): cint {.importc, header: "<aio.h>".} + a4: ptr SigEvent): cint {.importc, header: "<aio.h>".} # arpa/inet.h proc htonl*(a1: int32): int32 {.importc, header: "<arpa/inet.h>".} @@ -1778,7 +1804,7 @@ proc htons*(a1: int16): int16 {.importc, header: "<arpa/inet.h>".} proc ntohl*(a1: int32): int32 {.importc, header: "<arpa/inet.h>".} proc ntohs*(a1: int16): int16 {.importc, header: "<arpa/inet.h>".} -proc inet_addr*(a1: cstring): TInAddrT {.importc, header: "<arpa/inet.h>".} +proc inet_addr*(a1: cstring): InAddrT {.importc, header: "<arpa/inet.h>".} proc inet_ntoa*(a1: InAddr): cstring {.importc, header: "<arpa/inet.h>".} proc inet_ntop*(a1: cint, a2: pointer, a3: cstring, a4: int32): cstring {. importc, header: "<arpa/inet.h>".} @@ -1786,21 +1812,21 @@ proc inet_pton*(a1: cint, a2: cstring, a3: pointer): cint {. importc, header: "<arpa/inet.h>".} var - in6addr_any* {.importc, header: "<netinet/in.h>".}: TIn6Addr - in6addr_loopback* {.importc, header: "<netinet/in.h>".}: TIn6Addr + in6addr_any* {.importc, header: "<netinet/in.h>".}: In6Addr + in6addr_loopback* {.importc, header: "<netinet/in.h>".}: In6Addr -proc IN6ADDR_ANY_INIT* (): TIn6Addr {.importc, header: "<netinet/in.h>".} -proc IN6ADDR_LOOPBACK_INIT* (): TIn6Addr {.importc, header: "<netinet/in.h>".} +proc IN6ADDR_ANY_INIT* (): In6Addr {.importc, header: "<netinet/in.h>".} +proc IN6ADDR_LOOPBACK_INIT* (): In6Addr {.importc, header: "<netinet/in.h>".} # dirent.h -proc closedir*(a1: ptr TDIR): cint {.importc, header: "<dirent.h>".} -proc opendir*(a1: cstring): ptr TDIR {.importc, header: "<dirent.h>".} -proc readdir*(a1: ptr TDIR): ptr Tdirent {.importc, header: "<dirent.h>".} -proc readdir_r*(a1: ptr TDIR, a2: ptr Tdirent, a3: ptr ptr Tdirent): cint {. +proc closedir*(a1: ptr DIR): cint {.importc, header: "<dirent.h>".} +proc opendir*(a1: cstring): ptr DIR {.importc, header: "<dirent.h>".} +proc readdir*(a1: ptr DIR): ptr Dirent {.importc, header: "<dirent.h>".} +proc readdir_r*(a1: ptr DIR, a2: ptr Dirent, a3: ptr ptr Dirent): cint {. importc, header: "<dirent.h>".} -proc rewinddir*(a1: ptr TDIR) {.importc, header: "<dirent.h>".} -proc seekdir*(a1: ptr TDIR, a2: int) {.importc, header: "<dirent.h>".} -proc telldir*(a1: ptr TDIR): int {.importc, header: "<dirent.h>".} +proc rewinddir*(a1: ptr DIR) {.importc, header: "<dirent.h>".} +proc seekdir*(a1: ptr DIR, a2: int) {.importc, header: "<dirent.h>".} +proc telldir*(a1: ptr DIR): int {.importc, header: "<dirent.h>".} # dlfcn.h proc dlclose*(a1: pointer): cint {.importc, header: "<dlfcn.h>".} @@ -1808,12 +1834,12 @@ proc dlerror*(): cstring {.importc, header: "<dlfcn.h>".} proc dlopen*(a1: cstring, a2: cint): pointer {.importc, header: "<dlfcn.h>".} proc dlsym*(a1: pointer, a2: cstring): pointer {.importc, header: "<dlfcn.h>".} -proc creat*(a1: cstring, a2: TMode): cint {.importc, header: "<fcntl.h>".} +proc creat*(a1: cstring, a2: Mode): cint {.importc, header: "<fcntl.h>".} proc fcntl*(a1: cint | SocketHandle, a2: cint): cint {.varargs, importc, header: "<fcntl.h>".} proc open*(a1: cstring, a2: cint): cint {.varargs, importc, header: "<fcntl.h>".} -proc posix_fadvise*(a1: cint, a2, a3: TOff, a4: cint): cint {. +proc posix_fadvise*(a1: cint, a2, a3: Off, a4: cint): cint {. importc, header: "<fcntl.h>".} -proc posix_fallocate*(a1: cint, a2, a3: TOff): cint {. +proc posix_fallocate*(a1: cint, a2, a3: Off): cint {. importc, header: "<fcntl.h>".} when not defined(haiku) and not defined(OpenBSD): @@ -1822,248 +1848,248 @@ when not defined(haiku) and not defined(OpenBSD): proc fnmatch*(a1, a2: cstring, a3: cint): cint {.importc, header: "<fnmatch.h>".} proc ftw*(a1: cstring, - a2: proc (x1: cstring, x2: ptr TStat, x3: cint): cint {.noconv.}, + a2: proc (x1: cstring, x2: ptr Stat, x3: cint): cint {.noconv.}, a3: cint): cint {.importc, header: "<ftw.h>".} proc nftw*(a1: cstring, - a2: proc (x1: cstring, x2: ptr TStat, - x3: cint, x4: ptr TFTW): cint {.noconv.}, + a2: proc (x1: cstring, x2: ptr Stat, + x3: cint, x4: ptr FTW): cint {.noconv.}, a3: cint, a4: cint): cint {.importc, header: "<ftw.h>".} proc glob*(a1: cstring, a2: cint, a3: proc (x1: cstring, x2: cint): cint {.noconv.}, - a4: ptr TGlob): cint {.importc, header: "<glob.h>".} -proc globfree*(a1: ptr TGlob) {.importc, header: "<glob.h>".} - -proc getgrgid*(a1: TGid): ptr TGroup {.importc, header: "<grp.h>".} -proc getgrnam*(a1: cstring): ptr TGroup {.importc, header: "<grp.h>".} -proc getgrgid_r*(a1: TGid, a2: ptr TGroup, a3: cstring, a4: int, - a5: ptr ptr TGroup): cint {.importc, header: "<grp.h>".} -proc getgrnam_r*(a1: cstring, a2: ptr TGroup, a3: cstring, - a4: int, a5: ptr ptr TGroup): cint {. + a4: ptr Glob): cint {.importc, header: "<glob.h>".} +proc globfree*(a1: ptr Glob) {.importc, header: "<glob.h>".} + +proc getgrgid*(a1: Gid): ptr Group {.importc, header: "<grp.h>".} +proc getgrnam*(a1: cstring): ptr Group {.importc, header: "<grp.h>".} +proc getgrgid_r*(a1: Gid, a2: ptr Group, a3: cstring, a4: int, + a5: ptr ptr Group): cint {.importc, header: "<grp.h>".} +proc getgrnam_r*(a1: cstring, a2: ptr Group, a3: cstring, + a4: int, a5: ptr ptr Group): cint {. importc, header: "<grp.h>".} -proc getgrent*(): ptr TGroup {.importc, header: "<grp.h>".} +proc getgrent*(): ptr Group {.importc, header: "<grp.h>".} proc endgrent*() {.importc, header: "<grp.h>".} proc setgrent*() {.importc, header: "<grp.h>".} -proc iconv_open*(a1, a2: cstring): Ticonv {.importc, header: "<iconv.h>".} -proc iconv*(a1: Ticonv, a2: var cstring, a3: var int, a4: var cstring, +proc iconv_open*(a1, a2: cstring): Iconv {.importc, header: "<iconv.h>".} +proc iconv*(a1: Iconv, a2: var cstring, a3: var int, a4: var cstring, a5: var int): int {.importc, header: "<iconv.h>".} -proc iconv_close*(a1: Ticonv): cint {.importc, header: "<iconv.h>".} +proc iconv_close*(a1: Iconv): cint {.importc, header: "<iconv.h>".} -proc nl_langinfo*(a1: Tnl_item): cstring {.importc, header: "<langinfo.h>".} +proc nl_langinfo*(a1: Nl_item): cstring {.importc, header: "<langinfo.h>".} proc basename*(a1: cstring): cstring {.importc, header: "<libgen.h>".} proc dirname*(a1: cstring): cstring {.importc, header: "<libgen.h>".} -proc localeconv*(): ptr Tlconv {.importc, header: "<locale.h>".} +proc localeconv*(): ptr Lconv {.importc, header: "<locale.h>".} proc setlocale*(a1: cint, a2: cstring): cstring {. importc, header: "<locale.h>".} proc strfmon*(a1: cstring, a2: int, a3: cstring): int {.varargs, importc, header: "<monetary.h>".} -proc mq_close*(a1: TMqd): cint {.importc, header: "<mqueue.h>".} -proc mq_getattr*(a1: TMqd, a2: ptr TMqAttr): cint {. +proc mq_close*(a1: Mqd): cint {.importc, header: "<mqueue.h>".} +proc mq_getattr*(a1: Mqd, a2: ptr MqAttr): cint {. importc, header: "<mqueue.h>".} -proc mq_notify*(a1: TMqd, a2: ptr TsigEvent): cint {. +proc mq_notify*(a1: Mqd, a2: ptr SigEvent): cint {. importc, header: "<mqueue.h>".} -proc mq_open*(a1: cstring, a2: cint): TMqd {. +proc mq_open*(a1: cstring, a2: cint): Mqd {. varargs, importc, header: "<mqueue.h>".} -proc mq_receive*(a1: TMqd, a2: cstring, a3: int, a4: var int): int {. +proc mq_receive*(a1: Mqd, a2: cstring, a3: int, a4: var int): int {. importc, header: "<mqueue.h>".} -proc mq_send*(a1: TMqd, a2: cstring, a3: int, a4: int): cint {. +proc mq_send*(a1: Mqd, a2: cstring, a3: int, a4: int): cint {. importc, header: "<mqueue.h>".} -proc mq_setattr*(a1: TMqd, a2, a3: ptr TMqAttr): cint {. +proc mq_setattr*(a1: Mqd, a2, a3: ptr MqAttr): cint {. importc, header: "<mqueue.h>".} -proc mq_timedreceive*(a1: TMqd, a2: cstring, a3: int, a4: int, - a5: ptr Ttimespec): int {.importc, header: "<mqueue.h>".} -proc mq_timedsend*(a1: TMqd, a2: cstring, a3: int, a4: int, - a5: ptr Ttimespec): cint {.importc, header: "<mqueue.h>".} +proc mq_timedreceive*(a1: Mqd, a2: cstring, a3: int, a4: int, + a5: ptr Timespec): int {.importc, header: "<mqueue.h>".} +proc mq_timedsend*(a1: Mqd, a2: cstring, a3: int, a4: int, + a5: ptr Timespec): cint {.importc, header: "<mqueue.h>".} proc mq_unlink*(a1: cstring): cint {.importc, header: "<mqueue.h>".} -proc getpwnam*(a1: cstring): ptr TPasswd {.importc, header: "<pwd.h>".} -proc getpwuid*(a1: Tuid): ptr TPasswd {.importc, header: "<pwd.h>".} -proc getpwnam_r*(a1: cstring, a2: ptr TPasswd, a3: cstring, a4: int, - a5: ptr ptr TPasswd): cint {.importc, header: "<pwd.h>".} -proc getpwuid_r*(a1: Tuid, a2: ptr TPasswd, a3: cstring, - a4: int, a5: ptr ptr TPasswd): cint {.importc, header: "<pwd.h>".} +proc getpwnam*(a1: cstring): ptr Passwd {.importc, header: "<pwd.h>".} +proc getpwuid*(a1: Uid): ptr Passwd {.importc, header: "<pwd.h>".} +proc getpwnam_r*(a1: cstring, a2: ptr Passwd, a3: cstring, a4: int, + a5: ptr ptr Passwd): cint {.importc, header: "<pwd.h>".} +proc getpwuid_r*(a1: Uid, a2: ptr Passwd, a3: cstring, + a4: int, a5: ptr ptr Passwd): cint {.importc, header: "<pwd.h>".} proc endpwent*() {.importc, header: "<pwd.h>".} -proc getpwent*(): ptr TPasswd {.importc, header: "<pwd.h>".} +proc getpwent*(): ptr Passwd {.importc, header: "<pwd.h>".} proc setpwent*() {.importc, header: "<pwd.h>".} -proc uname*(a1: var Tutsname): cint {.importc, header: "<sys/utsname.h>".} +proc uname*(a1: var Utsname): cint {.importc, header: "<sys/utsname.h>".} proc pthread_atfork*(a1, a2, a3: proc () {.noconv.}): cint {. importc, header: "<pthread.h>".} -proc pthread_attr_destroy*(a1: ptr Tpthread_attr): cint {. +proc pthread_attr_destroy*(a1: ptr PthreadAttr): cint {. importc, header: "<pthread.h>".} -proc pthread_attr_getdetachstate*(a1: ptr Tpthread_attr, a2: cint): cint {. +proc pthread_attr_getdetachstate*(a1: ptr PthreadAttr, a2: cint): cint {. importc, header: "<pthread.h>".} -proc pthread_attr_getguardsize*(a1: ptr Tpthread_attr, a2: var cint): cint {. +proc pthread_attr_getguardsize*(a1: ptr PthreadAttr, a2: var cint): cint {. importc, header: "<pthread.h>".} -proc pthread_attr_getinheritsched*(a1: ptr Tpthread_attr, +proc pthread_attr_getinheritsched*(a1: ptr PthreadAttr, a2: var cint): cint {.importc, header: "<pthread.h>".} -proc pthread_attr_getschedparam*(a1: ptr Tpthread_attr, - a2: ptr Tsched_param): cint {.importc, header: "<pthread.h>".} -proc pthread_attr_getschedpolicy*(a1: ptr Tpthread_attr, +proc pthread_attr_getschedparam*(a1: ptr PthreadAttr, + a2: ptr Sched_param): cint {.importc, header: "<pthread.h>".} +proc pthread_attr_getschedpolicy*(a1: ptr PthreadAttr, a2: var cint): cint {.importc, header: "<pthread.h>".} -proc pthread_attr_getscope*(a1: ptr Tpthread_attr, +proc pthread_attr_getscope*(a1: ptr PthreadAttr, a2: var cint): cint {.importc, header: "<pthread.h>".} -proc pthread_attr_getstack*(a1: ptr Tpthread_attr, +proc pthread_attr_getstack*(a1: ptr PthreadAttr, a2: var pointer, a3: var int): cint {.importc, header: "<pthread.h>".} -proc pthread_attr_getstackaddr*(a1: ptr Tpthread_attr, +proc pthread_attr_getstackaddr*(a1: ptr PthreadAttr, a2: var pointer): cint {.importc, header: "<pthread.h>".} -proc pthread_attr_getstacksize*(a1: ptr Tpthread_attr, +proc pthread_attr_getstacksize*(a1: ptr PthreadAttr, a2: var int): cint {.importc, header: "<pthread.h>".} -proc pthread_attr_init*(a1: ptr Tpthread_attr): cint {. +proc pthread_attr_init*(a1: ptr PthreadAttr): cint {. importc, header: "<pthread.h>".} -proc pthread_attr_setdetachstate*(a1: ptr Tpthread_attr, a2: cint): cint {. +proc pthread_attr_setdetachstate*(a1: ptr PthreadAttr, a2: cint): cint {. importc, header: "<pthread.h>".} -proc pthread_attr_setguardsize*(a1: ptr Tpthread_attr, a2: int): cint {. +proc pthread_attr_setguardsize*(a1: ptr PthreadAttr, a2: int): cint {. importc, header: "<pthread.h>".} -proc pthread_attr_setinheritsched*(a1: ptr Tpthread_attr, a2: cint): cint {. +proc pthread_attr_setinheritsched*(a1: ptr PthreadAttr, a2: cint): cint {. importc, header: "<pthread.h>".} -proc pthread_attr_setschedparam*(a1: ptr Tpthread_attr, - a2: ptr Tsched_param): cint {.importc, header: "<pthread.h>".} -proc pthread_attr_setschedpolicy*(a1: ptr Tpthread_attr, a2: cint): cint {. +proc pthread_attr_setschedparam*(a1: ptr PthreadAttr, + a2: ptr Sched_param): cint {.importc, header: "<pthread.h>".} +proc pthread_attr_setschedpolicy*(a1: ptr PthreadAttr, a2: cint): cint {. importc, header: "<pthread.h>".} -proc pthread_attr_setscope*(a1: ptr Tpthread_attr, a2: cint): cint {.importc, +proc pthread_attr_setscope*(a1: ptr PthreadAttr, a2: cint): cint {.importc, header: "<pthread.h>".} -proc pthread_attr_setstack*(a1: ptr Tpthread_attr, a2: pointer, a3: int): cint {. +proc pthread_attr_setstack*(a1: ptr PthreadAttr, a2: pointer, a3: int): cint {. importc, header: "<pthread.h>".} -proc pthread_attr_setstackaddr*(a1: ptr Tpthread_attr, a2: pointer): cint {. +proc pthread_attr_setstackaddr*(a1: ptr PthreadAttr, a2: pointer): cint {. importc, header: "<pthread.h>".} -proc pthread_attr_setstacksize*(a1: ptr Tpthread_attr, a2: int): cint {. +proc pthread_attr_setstacksize*(a1: ptr PthreadAttr, a2: int): cint {. importc, header: "<pthread.h>".} -proc pthread_barrier_destroy*(a1: ptr Tpthread_barrier): cint {. +proc pthread_barrier_destroy*(a1: ptr Pthread_barrier): cint {. importc, header: "<pthread.h>".} -proc pthread_barrier_init*(a1: ptr Tpthread_barrier, - a2: ptr Tpthread_barrierattr, a3: cint): cint {. +proc pthread_barrier_init*(a1: ptr Pthread_barrier, + a2: ptr Pthread_barrierattr, a3: cint): cint {. importc, header: "<pthread.h>".} -proc pthread_barrier_wait*(a1: ptr Tpthread_barrier): cint {. +proc pthread_barrier_wait*(a1: ptr Pthread_barrier): cint {. importc, header: "<pthread.h>".} -proc pthread_barrierattr_destroy*(a1: ptr Tpthread_barrierattr): cint {. +proc pthread_barrierattr_destroy*(a1: ptr Pthread_barrierattr): cint {. importc, header: "<pthread.h>".} proc pthread_barrierattr_getpshared*( - a1: ptr Tpthread_barrierattr, a2: var cint): cint {. + a1: ptr Pthread_barrierattr, a2: var cint): cint {. importc, header: "<pthread.h>".} -proc pthread_barrierattr_init*(a1: ptr Tpthread_barrierattr): cint {. +proc pthread_barrierattr_init*(a1: ptr Pthread_barrierattr): cint {. importc, header: "<pthread.h>".} -proc pthread_barrierattr_setpshared*(a1: ptr Tpthread_barrierattr, +proc pthread_barrierattr_setpshared*(a1: ptr Pthread_barrierattr, a2: cint): cint {.importc, header: "<pthread.h>".} -proc pthread_cancel*(a1: Tpthread): cint {.importc, header: "<pthread.h>".} +proc pthread_cancel*(a1: Pthread): cint {.importc, header: "<pthread.h>".} proc pthread_cleanup_push*(a1: proc (x: pointer) {.noconv.}, a2: pointer) {. importc, header: "<pthread.h>".} proc pthread_cleanup_pop*(a1: cint) {.importc, header: "<pthread.h>".} -proc pthread_cond_broadcast*(a1: ptr Tpthread_cond): cint {. +proc pthread_cond_broadcast*(a1: ptr Pthread_cond): cint {. importc, header: "<pthread.h>".} -proc pthread_cond_destroy*(a1: ptr Tpthread_cond): cint {.importc, header: "<pthread.h>".} -proc pthread_cond_init*(a1: ptr Tpthread_cond, - a2: ptr Tpthread_condattr): cint {.importc, header: "<pthread.h>".} -proc pthread_cond_signal*(a1: ptr Tpthread_cond): cint {.importc, header: "<pthread.h>".} -proc pthread_cond_timedwait*(a1: ptr Tpthread_cond, - a2: ptr Tpthread_mutex, a3: ptr Ttimespec): cint {.importc, header: "<pthread.h>".} - -proc pthread_cond_wait*(a1: ptr Tpthread_cond, - a2: ptr Tpthread_mutex): cint {.importc, header: "<pthread.h>".} -proc pthread_condattr_destroy*(a1: ptr Tpthread_condattr): cint {.importc, header: "<pthread.h>".} -proc pthread_condattr_getclock*(a1: ptr Tpthread_condattr, - a2: var TClockId): cint {.importc, header: "<pthread.h>".} -proc pthread_condattr_getpshared*(a1: ptr Tpthread_condattr, +proc pthread_cond_destroy*(a1: ptr Pthread_cond): cint {.importc, header: "<pthread.h>".} +proc pthread_cond_init*(a1: ptr Pthread_cond, + a2: ptr Pthread_condattr): cint {.importc, header: "<pthread.h>".} +proc pthread_cond_signal*(a1: ptr Pthread_cond): cint {.importc, header: "<pthread.h>".} +proc pthread_cond_timedwait*(a1: ptr Pthread_cond, + a2: ptr Pthread_mutex, a3: ptr Timespec): cint {.importc, header: "<pthread.h>".} + +proc pthread_cond_wait*(a1: ptr Pthread_cond, + a2: ptr Pthread_mutex): cint {.importc, header: "<pthread.h>".} +proc pthread_condattr_destroy*(a1: ptr Pthread_condattr): cint {.importc, header: "<pthread.h>".} +proc pthread_condattr_getclock*(a1: ptr Pthread_condattr, + a2: var ClockId): cint {.importc, header: "<pthread.h>".} +proc pthread_condattr_getpshared*(a1: ptr Pthread_condattr, a2: var cint): cint {.importc, header: "<pthread.h>".} -proc pthread_condattr_init*(a1: ptr Tpthread_condattr): cint {.importc, header: "<pthread.h>".} -proc pthread_condattr_setclock*(a1: ptr Tpthread_condattr,a2: TClockId): cint {.importc, header: "<pthread.h>".} -proc pthread_condattr_setpshared*(a1: ptr Tpthread_condattr, a2: cint): cint {.importc, header: "<pthread.h>".} +proc pthread_condattr_init*(a1: ptr Pthread_condattr): cint {.importc, header: "<pthread.h>".} +proc pthread_condattr_setclock*(a1: ptr Pthread_condattr,a2: ClockId): cint {.importc, header: "<pthread.h>".} +proc pthread_condattr_setpshared*(a1: ptr Pthread_condattr, a2: cint): cint {.importc, header: "<pthread.h>".} -proc pthread_create*(a1: ptr Tpthread, a2: ptr Tpthread_attr, +proc pthread_create*(a1: ptr Pthread, a2: ptr PthreadAttr, a3: proc (x: pointer): pointer {.noconv.}, a4: pointer): cint {.importc, header: "<pthread.h>".} -proc pthread_detach*(a1: Tpthread): cint {.importc, header: "<pthread.h>".} -proc pthread_equal*(a1, a2: Tpthread): cint {.importc, header: "<pthread.h>".} +proc pthread_detach*(a1: Pthread): cint {.importc, header: "<pthread.h>".} +proc pthread_equal*(a1, a2: Pthread): cint {.importc, header: "<pthread.h>".} proc pthread_exit*(a1: pointer) {.importc, header: "<pthread.h>".} proc pthread_getconcurrency*(): cint {.importc, header: "<pthread.h>".} -proc pthread_getcpuclockid*(a1: Tpthread, a2: var TClockId): cint {.importc, header: "<pthread.h>".} -proc pthread_getschedparam*(a1: Tpthread, a2: var cint, - a3: ptr Tsched_param): cint {.importc, header: "<pthread.h>".} -proc pthread_getspecific*(a1: Tpthread_key): pointer {.importc, header: "<pthread.h>".} -proc pthread_join*(a1: Tpthread, a2: ptr pointer): cint {.importc, header: "<pthread.h>".} -proc pthread_key_create*(a1: ptr Tpthread_key, a2: proc (x: pointer) {.noconv.}): cint {.importc, header: "<pthread.h>".} -proc pthread_key_delete*(a1: Tpthread_key): cint {.importc, header: "<pthread.h>".} - -proc pthread_mutex_destroy*(a1: ptr Tpthread_mutex): cint {.importc, header: "<pthread.h>".} -proc pthread_mutex_getprioceiling*(a1: ptr Tpthread_mutex, +proc pthread_getcpuclockid*(a1: Pthread, a2: var ClockId): cint {.importc, header: "<pthread.h>".} +proc pthread_getschedparam*(a1: Pthread, a2: var cint, + a3: ptr Sched_param): cint {.importc, header: "<pthread.h>".} +proc pthread_getspecific*(a1: Pthread_key): pointer {.importc, header: "<pthread.h>".} +proc pthread_join*(a1: Pthread, a2: ptr pointer): cint {.importc, header: "<pthread.h>".} +proc pthread_key_create*(a1: ptr Pthread_key, a2: proc (x: pointer) {.noconv.}): cint {.importc, header: "<pthread.h>".} +proc pthread_key_delete*(a1: Pthread_key): cint {.importc, header: "<pthread.h>".} + +proc pthread_mutex_destroy*(a1: ptr Pthread_mutex): cint {.importc, header: "<pthread.h>".} +proc pthread_mutex_getprioceiling*(a1: ptr Pthread_mutex, a2: var cint): cint {.importc, header: "<pthread.h>".} -proc pthread_mutex_init*(a1: ptr Tpthread_mutex, - a2: ptr Tpthread_mutexattr): cint {.importc, header: "<pthread.h>".} -proc pthread_mutex_lock*(a1: ptr Tpthread_mutex): cint {.importc, header: "<pthread.h>".} -proc pthread_mutex_setprioceiling*(a1: ptr Tpthread_mutex,a2: cint, +proc pthread_mutex_init*(a1: ptr Pthread_mutex, + a2: ptr Pthread_mutexattr): cint {.importc, header: "<pthread.h>".} +proc pthread_mutex_lock*(a1: ptr Pthread_mutex): cint {.importc, header: "<pthread.h>".} +proc pthread_mutex_setprioceiling*(a1: ptr Pthread_mutex,a2: cint, a3: var cint): cint {.importc, header: "<pthread.h>".} -proc pthread_mutex_timedlock*(a1: ptr Tpthread_mutex, - a2: ptr Ttimespec): cint {.importc, header: "<pthread.h>".} -proc pthread_mutex_trylock*(a1: ptr Tpthread_mutex): cint {.importc, header: "<pthread.h>".} -proc pthread_mutex_unlock*(a1: ptr Tpthread_mutex): cint {.importc, header: "<pthread.h>".} -proc pthread_mutexattr_destroy*(a1: ptr Tpthread_mutexattr): cint {.importc, header: "<pthread.h>".} +proc pthread_mutex_timedlock*(a1: ptr Pthread_mutex, + a2: ptr Timespec): cint {.importc, header: "<pthread.h>".} +proc pthread_mutex_trylock*(a1: ptr Pthread_mutex): cint {.importc, header: "<pthread.h>".} +proc pthread_mutex_unlock*(a1: ptr Pthread_mutex): cint {.importc, header: "<pthread.h>".} +proc pthread_mutexattr_destroy*(a1: ptr Pthread_mutexattr): cint {.importc, header: "<pthread.h>".} proc pthread_mutexattr_getprioceiling*( - a1: ptr Tpthread_mutexattr, a2: var cint): cint {.importc, header: "<pthread.h>".} -proc pthread_mutexattr_getprotocol*(a1: ptr Tpthread_mutexattr, + a1: ptr Pthread_mutexattr, a2: var cint): cint {.importc, header: "<pthread.h>".} +proc pthread_mutexattr_getprotocol*(a1: ptr Pthread_mutexattr, a2: var cint): cint {.importc, header: "<pthread.h>".} -proc pthread_mutexattr_getpshared*(a1: ptr Tpthread_mutexattr, +proc pthread_mutexattr_getpshared*(a1: ptr Pthread_mutexattr, a2: var cint): cint {.importc, header: "<pthread.h>".} -proc pthread_mutexattr_gettype*(a1: ptr Tpthread_mutexattr, +proc pthread_mutexattr_gettype*(a1: ptr Pthread_mutexattr, a2: var cint): cint {.importc, header: "<pthread.h>".} -proc pthread_mutexattr_init*(a1: ptr Tpthread_mutexattr): cint {.importc, header: "<pthread.h>".} -proc pthread_mutexattr_setprioceiling*(a1: ptr Tpthread_mutexattr, a2: cint): cint {.importc, header: "<pthread.h>".} -proc pthread_mutexattr_setprotocol*(a1: ptr Tpthread_mutexattr, a2: cint): cint {.importc, header: "<pthread.h>".} -proc pthread_mutexattr_setpshared*(a1: ptr Tpthread_mutexattr, a2: cint): cint {.importc, header: "<pthread.h>".} -proc pthread_mutexattr_settype*(a1: ptr Tpthread_mutexattr, a2: cint): cint {.importc, header: "<pthread.h>".} - -proc pthread_once*(a1: ptr Tpthread_once, a2: proc () {.noconv.}): cint {.importc, header: "<pthread.h>".} - -proc pthread_rwlock_destroy*(a1: ptr Tpthread_rwlock): cint {.importc, header: "<pthread.h>".} -proc pthread_rwlock_init*(a1: ptr Tpthread_rwlock, - a2: ptr Tpthread_rwlockattr): cint {.importc, header: "<pthread.h>".} -proc pthread_rwlock_rdlock*(a1: ptr Tpthread_rwlock): cint {.importc, header: "<pthread.h>".} -proc pthread_rwlock_timedrdlock*(a1: ptr Tpthread_rwlock, - a2: ptr Ttimespec): cint {.importc, header: "<pthread.h>".} -proc pthread_rwlock_timedwrlock*(a1: ptr Tpthread_rwlock, - a2: ptr Ttimespec): cint {.importc, header: "<pthread.h>".} - -proc pthread_rwlock_tryrdlock*(a1: ptr Tpthread_rwlock): cint {.importc, header: "<pthread.h>".} -proc pthread_rwlock_trywrlock*(a1: ptr Tpthread_rwlock): cint {.importc, header: "<pthread.h>".} -proc pthread_rwlock_unlock*(a1: ptr Tpthread_rwlock): cint {.importc, header: "<pthread.h>".} -proc pthread_rwlock_wrlock*(a1: ptr Tpthread_rwlock): cint {.importc, header: "<pthread.h>".} -proc pthread_rwlockattr_destroy*(a1: ptr Tpthread_rwlockattr): cint {.importc, header: "<pthread.h>".} +proc pthread_mutexattr_init*(a1: ptr Pthread_mutexattr): cint {.importc, header: "<pthread.h>".} +proc pthread_mutexattr_setprioceiling*(a1: ptr Pthread_mutexattr, a2: cint): cint {.importc, header: "<pthread.h>".} +proc pthread_mutexattr_setprotocol*(a1: ptr Pthread_mutexattr, a2: cint): cint {.importc, header: "<pthread.h>".} +proc pthread_mutexattr_setpshared*(a1: ptr Pthread_mutexattr, a2: cint): cint {.importc, header: "<pthread.h>".} +proc pthread_mutexattr_settype*(a1: ptr Pthread_mutexattr, a2: cint): cint {.importc, header: "<pthread.h>".} + +proc pthread_once*(a1: ptr Pthread_once, a2: proc () {.noconv.}): cint {.importc, header: "<pthread.h>".} + +proc pthread_rwlock_destroy*(a1: ptr Pthread_rwlock): cint {.importc, header: "<pthread.h>".} +proc pthread_rwlock_init*(a1: ptr Pthread_rwlock, + a2: ptr Pthread_rwlockattr): cint {.importc, header: "<pthread.h>".} +proc pthread_rwlock_rdlock*(a1: ptr Pthread_rwlock): cint {.importc, header: "<pthread.h>".} +proc pthread_rwlock_timedrdlock*(a1: ptr Pthread_rwlock, + a2: ptr Timespec): cint {.importc, header: "<pthread.h>".} +proc pthread_rwlock_timedwrlock*(a1: ptr Pthread_rwlock, + a2: ptr Timespec): cint {.importc, header: "<pthread.h>".} + +proc pthread_rwlock_tryrdlock*(a1: ptr Pthread_rwlock): cint {.importc, header: "<pthread.h>".} +proc pthread_rwlock_trywrlock*(a1: ptr Pthread_rwlock): cint {.importc, header: "<pthread.h>".} +proc pthread_rwlock_unlock*(a1: ptr Pthread_rwlock): cint {.importc, header: "<pthread.h>".} +proc pthread_rwlock_wrlock*(a1: ptr Pthread_rwlock): cint {.importc, header: "<pthread.h>".} +proc pthread_rwlockattr_destroy*(a1: ptr Pthread_rwlockattr): cint {.importc, header: "<pthread.h>".} proc pthread_rwlockattr_getpshared*( - a1: ptr Tpthread_rwlockattr, a2: var cint): cint {.importc, header: "<pthread.h>".} -proc pthread_rwlockattr_init*(a1: ptr Tpthread_rwlockattr): cint {.importc, header: "<pthread.h>".} -proc pthread_rwlockattr_setpshared*(a1: ptr Tpthread_rwlockattr, a2: cint): cint {.importc, header: "<pthread.h>".} + a1: ptr Pthread_rwlockattr, a2: var cint): cint {.importc, header: "<pthread.h>".} +proc pthread_rwlockattr_init*(a1: ptr Pthread_rwlockattr): cint {.importc, header: "<pthread.h>".} +proc pthread_rwlockattr_setpshared*(a1: ptr Pthread_rwlockattr, a2: cint): cint {.importc, header: "<pthread.h>".} -proc pthread_self*(): Tpthread {.importc, header: "<pthread.h>".} +proc pthread_self*(): Pthread {.importc, header: "<pthread.h>".} proc pthread_setcancelstate*(a1: cint, a2: var cint): cint {.importc, header: "<pthread.h>".} proc pthread_setcanceltype*(a1: cint, a2: var cint): cint {.importc, header: "<pthread.h>".} proc pthread_setconcurrency*(a1: cint): cint {.importc, header: "<pthread.h>".} -proc pthread_setschedparam*(a1: Tpthread, a2: cint, - a3: ptr Tsched_param): cint {.importc, header: "<pthread.h>".} +proc pthread_setschedparam*(a1: Pthread, a2: cint, + a3: ptr Sched_param): cint {.importc, header: "<pthread.h>".} -proc pthread_setschedprio*(a1: Tpthread, a2: cint): cint {. +proc pthread_setschedprio*(a1: Pthread, a2: cint): cint {. importc, header: "<pthread.h>".} -proc pthread_setspecific*(a1: Tpthread_key, a2: pointer): cint {. +proc pthread_setspecific*(a1: Pthread_key, a2: pointer): cint {. importc, header: "<pthread.h>".} -proc pthread_spin_destroy*(a1: ptr Tpthread_spinlock): cint {. +proc pthread_spin_destroy*(a1: ptr Pthread_spinlock): cint {. importc, header: "<pthread.h>".} -proc pthread_spin_init*(a1: ptr Tpthread_spinlock, a2: cint): cint {. +proc pthread_spin_init*(a1: ptr Pthread_spinlock, a2: cint): cint {. importc, header: "<pthread.h>".} -proc pthread_spin_lock*(a1: ptr Tpthread_spinlock): cint {. +proc pthread_spin_lock*(a1: ptr Pthread_spinlock): cint {. importc, header: "<pthread.h>".} -proc pthread_spin_trylock*(a1: ptr Tpthread_spinlock): cint{. +proc pthread_spin_trylock*(a1: ptr Pthread_spinlock): cint{. importc, header: "<pthread.h>".} -proc pthread_spin_unlock*(a1: ptr Tpthread_spinlock): cint {. +proc pthread_spin_unlock*(a1: ptr Pthread_spinlock): cint {. importc, header: "<pthread.h>".} proc pthread_testcancel*() {.importc, header: "<pthread.h>".} @@ -2072,7 +2098,7 @@ proc exitnow*(code: int): void {.importc: "_exit", header: "<unistd.h>".} proc access*(a1: cstring, a2: cint): cint {.importc, header: "<unistd.h>".} proc alarm*(a1: cint): cint {.importc, header: "<unistd.h>".} proc chdir*(a1: cstring): cint {.importc, header: "<unistd.h>".} -proc chown*(a1: cstring, a2: Tuid, a3: TGid): cint {.importc, header: "<unistd.h>".} +proc chown*(a1: cstring, a2: Uid, a3: Gid): cint {.importc, header: "<unistd.h>".} proc close*(a1: cint | SocketHandle): cint {.importc, header: "<unistd.h>".} proc confstr*(a1: cint, a2: cstring, a3: int): int {.importc, header: "<unistd.h>".} proc crypt*(a1, a2: cstring): cstring {.importc, header: "<unistd.h>".} @@ -2089,19 +2115,19 @@ proc execve*(a1: cstring, a2, a3: cstringArray): cint {. importc, header: "<unistd.h>".} proc execvp*(a1: cstring, a2: cstringArray): cint {.importc, header: "<unistd.h>".} proc execvpe*(a1: cstring, a2: cstringArray, a3: cstringArray): cint {.importc, header: "<unistd.h>".} -proc fchown*(a1: cint, a2: Tuid, a3: TGid): cint {.importc, header: "<unistd.h>".} +proc fchown*(a1: cint, a2: Uid, a3: Gid): cint {.importc, header: "<unistd.h>".} proc fchdir*(a1: cint): cint {.importc, header: "<unistd.h>".} proc fdatasync*(a1: cint): cint {.importc, header: "<unistd.h>".} -proc fork*(): TPid {.importc, header: "<unistd.h>".} +proc fork*(): Pid {.importc, header: "<unistd.h>".} proc fpathconf*(a1, a2: cint): int {.importc, header: "<unistd.h>".} proc fsync*(a1: cint): cint {.importc, header: "<unistd.h>".} -proc ftruncate*(a1: cint, a2: TOff): cint {.importc, header: "<unistd.h>".} +proc ftruncate*(a1: cint, a2: Off): cint {.importc, header: "<unistd.h>".} proc getcwd*(a1: cstring, a2: int): cstring {.importc, header: "<unistd.h>".} -proc getegid*(): TGid {.importc, header: "<unistd.h>".} -proc geteuid*(): Tuid {.importc, header: "<unistd.h>".} -proc getgid*(): TGid {.importc, header: "<unistd.h>".} +proc getegid*(): Gid {.importc, header: "<unistd.h>".} +proc geteuid*(): Uid {.importc, header: "<unistd.h>".} +proc getgid*(): Gid {.importc, header: "<unistd.h>".} -proc getgroups*(a1: cint, a2: ptr array[0..255, TGid]): cint {. +proc getgroups*(a1: cint, a2: ptr array[0..255, Gid]): cint {. importc, header: "<unistd.h>".} proc gethostid*(): int {.importc, header: "<unistd.h>".} proc gethostname*(a1: cstring, a2: int): cint {.importc, header: "<unistd.h>".} @@ -2110,120 +2136,120 @@ proc getlogin_r*(a1: cstring, a2: int): cint {.importc, header: "<unistd.h>".} proc getopt*(a1: cint, a2: cstringArray, a3: cstring): cint {. importc, header: "<unistd.h>".} -proc getpgid*(a1: TPid): TPid {.importc, header: "<unistd.h>".} -proc getpgrp*(): TPid {.importc, header: "<unistd.h>".} -proc getpid*(): TPid {.importc, header: "<unistd.h>".} -proc getppid*(): TPid {.importc, header: "<unistd.h>".} -proc getsid*(a1: TPid): TPid {.importc, header: "<unistd.h>".} -proc getuid*(): Tuid {.importc, header: "<unistd.h>".} +proc getpgid*(a1: Pid): Pid {.importc, header: "<unistd.h>".} +proc getpgrp*(): Pid {.importc, header: "<unistd.h>".} +proc getpid*(): Pid {.importc, header: "<unistd.h>".} +proc getppid*(): Pid {.importc, header: "<unistd.h>".} +proc getsid*(a1: Pid): Pid {.importc, header: "<unistd.h>".} +proc getuid*(): Uid {.importc, header: "<unistd.h>".} proc getwd*(a1: cstring): cstring {.importc, header: "<unistd.h>".} proc isatty*(a1: cint): cint {.importc, header: "<unistd.h>".} -proc lchown*(a1: cstring, a2: Tuid, a3: TGid): cint {.importc, header: "<unistd.h>".} +proc lchown*(a1: cstring, a2: Uid, a3: Gid): cint {.importc, header: "<unistd.h>".} proc link*(a1, a2: cstring): cint {.importc, header: "<unistd.h>".} -proc lockf*(a1, a2: cint, a3: TOff): cint {.importc, header: "<unistd.h>".} -proc lseek*(a1: cint, a2: TOff, a3: cint): TOff {.importc, header: "<unistd.h>".} +proc lockf*(a1, a2: cint, a3: Off): cint {.importc, header: "<unistd.h>".} +proc lseek*(a1: cint, a2: Off, a3: cint): Off {.importc, header: "<unistd.h>".} proc nice*(a1: cint): cint {.importc, header: "<unistd.h>".} proc pathconf*(a1: cstring, a2: cint): int {.importc, header: "<unistd.h>".} proc pause*(): cint {.importc, header: "<unistd.h>".} proc pipe*(a: array[0..1, cint]): cint {.importc, header: "<unistd.h>".} -proc pread*(a1: cint, a2: pointer, a3: int, a4: TOff): int {. +proc pread*(a1: cint, a2: pointer, a3: int, a4: Off): int {. importc, header: "<unistd.h>".} -proc pwrite*(a1: cint, a2: pointer, a3: int, a4: TOff): int {. +proc pwrite*(a1: cint, a2: pointer, a3: int, a4: Off): int {. importc, header: "<unistd.h>".} proc read*(a1: cint, a2: pointer, a3: int): int {.importc, header: "<unistd.h>".} proc readlink*(a1, a2: cstring, a3: int): int {.importc, header: "<unistd.h>".} proc rmdir*(a1: cstring): cint {.importc, header: "<unistd.h>".} -proc setegid*(a1: TGid): cint {.importc, header: "<unistd.h>".} -proc seteuid*(a1: Tuid): cint {.importc, header: "<unistd.h>".} -proc setgid*(a1: TGid): cint {.importc, header: "<unistd.h>".} - -proc setpgid*(a1, a2: TPid): cint {.importc, header: "<unistd.h>".} -proc setpgrp*(): TPid {.importc, header: "<unistd.h>".} -proc setregid*(a1, a2: TGid): cint {.importc, header: "<unistd.h>".} -proc setreuid*(a1, a2: Tuid): cint {.importc, header: "<unistd.h>".} -proc setsid*(): TPid {.importc, header: "<unistd.h>".} -proc setuid*(a1: Tuid): cint {.importc, header: "<unistd.h>".} +proc setegid*(a1: Gid): cint {.importc, header: "<unistd.h>".} +proc seteuid*(a1: Uid): cint {.importc, header: "<unistd.h>".} +proc setgid*(a1: Gid): cint {.importc, header: "<unistd.h>".} + +proc setpgid*(a1, a2: Pid): cint {.importc, header: "<unistd.h>".} +proc setpgrp*(): Pid {.importc, header: "<unistd.h>".} +proc setregid*(a1, a2: Gid): cint {.importc, header: "<unistd.h>".} +proc setreuid*(a1, a2: Uid): cint {.importc, header: "<unistd.h>".} +proc setsid*(): Pid {.importc, header: "<unistd.h>".} +proc setuid*(a1: Uid): cint {.importc, header: "<unistd.h>".} proc sleep*(a1: cint): cint {.importc, header: "<unistd.h>".} proc swab*(a1, a2: pointer, a3: int) {.importc, header: "<unistd.h>".} proc symlink*(a1, a2: cstring): cint {.importc, header: "<unistd.h>".} proc sync*() {.importc, header: "<unistd.h>".} proc sysconf*(a1: cint): int {.importc, header: "<unistd.h>".} -proc tcgetpgrp*(a1: cint): TPid {.importc, header: "<unistd.h>".} -proc tcsetpgrp*(a1: cint, a2: TPid): cint {.importc, header: "<unistd.h>".} -proc truncate*(a1: cstring, a2: TOff): cint {.importc, header: "<unistd.h>".} +proc tcgetpgrp*(a1: cint): Pid {.importc, header: "<unistd.h>".} +proc tcsetpgrp*(a1: cint, a2: Pid): cint {.importc, header: "<unistd.h>".} +proc truncate*(a1: cstring, a2: Off): cint {.importc, header: "<unistd.h>".} proc ttyname*(a1: cint): cstring {.importc, header: "<unistd.h>".} proc ttyname_r*(a1: cint, a2: cstring, a3: int): cint {. importc, header: "<unistd.h>".} -proc ualarm*(a1, a2: Tuseconds): Tuseconds {.importc, header: "<unistd.h>".} +proc ualarm*(a1, a2: Useconds): Useconds {.importc, header: "<unistd.h>".} proc unlink*(a1: cstring): cint {.importc, header: "<unistd.h>".} -proc usleep*(a1: Tuseconds): cint {.importc, header: "<unistd.h>".} -proc vfork*(): TPid {.importc, header: "<unistd.h>".} +proc usleep*(a1: Useconds): cint {.importc, header: "<unistd.h>".} +proc vfork*(): Pid {.importc, header: "<unistd.h>".} proc write*(a1: cint, a2: pointer, a3: int): int {.importc, header: "<unistd.h>".} -proc sem_close*(a1: ptr TSem): cint {.importc, header: "<semaphore.h>".} -proc sem_destroy*(a1: ptr TSem): cint {.importc, header: "<semaphore.h>".} -proc sem_getvalue*(a1: ptr TSem, a2: var cint): cint {. +proc sem_close*(a1: ptr Sem): cint {.importc, header: "<semaphore.h>".} +proc sem_destroy*(a1: ptr Sem): cint {.importc, header: "<semaphore.h>".} +proc sem_getvalue*(a1: ptr Sem, a2: var cint): cint {. importc, header: "<semaphore.h>".} -proc sem_init*(a1: ptr TSem, a2: cint, a3: cint): cint {. +proc sem_init*(a1: ptr Sem, a2: cint, a3: cint): cint {. importc, header: "<semaphore.h>".} -proc sem_open*(a1: cstring, a2: cint): ptr TSem {. +proc sem_open*(a1: cstring, a2: cint): ptr Sem {. varargs, importc, header: "<semaphore.h>".} -proc sem_post*(a1: ptr TSem): cint {.importc, header: "<semaphore.h>".} -proc sem_timedwait*(a1: ptr TSem, a2: ptr Ttimespec): cint {. +proc sem_post*(a1: ptr Sem): cint {.importc, header: "<semaphore.h>".} +proc sem_timedwait*(a1: ptr Sem, a2: ptr Timespec): cint {. importc, header: "<semaphore.h>".} -proc sem_trywait*(a1: ptr TSem): cint {.importc, header: "<semaphore.h>".} +proc sem_trywait*(a1: ptr Sem): cint {.importc, header: "<semaphore.h>".} proc sem_unlink*(a1: cstring): cint {.importc, header: "<semaphore.h>".} -proc sem_wait*(a1: ptr TSem): cint {.importc, header: "<semaphore.h>".} +proc sem_wait*(a1: ptr Sem): cint {.importc, header: "<semaphore.h>".} -proc ftok*(a1: cstring, a2: cint): TKey {.importc, header: "<sys/ipc.h>".} +proc ftok*(a1: cstring, a2: cint): Key {.importc, header: "<sys/ipc.h>".} -proc statvfs*(a1: cstring, a2: var TStatvfs): cint {. +proc statvfs*(a1: cstring, a2: var Statvfs): cint {. importc, header: "<sys/statvfs.h>".} -proc fstatvfs*(a1: cint, a2: var TStatvfs): cint {. +proc fstatvfs*(a1: cint, a2: var Statvfs): cint {. importc, header: "<sys/statvfs.h>".} -proc chmod*(a1: cstring, a2: TMode): cint {.importc, header: "<sys/stat.h>".} -proc fchmod*(a1: cint, a2: TMode): cint {.importc, header: "<sys/stat.h>".} -proc fstat*(a1: cint, a2: var TStat): cint {.importc, header: "<sys/stat.h>".} -proc lstat*(a1: cstring, a2: var TStat): cint {.importc, header: "<sys/stat.h>".} -proc mkdir*(a1: cstring, a2: TMode): cint {.importc, header: "<sys/stat.h>".} -proc mkfifo*(a1: cstring, a2: TMode): cint {.importc, header: "<sys/stat.h>".} -proc mknod*(a1: cstring, a2: TMode, a3: TDev): cint {. +proc chmod*(a1: cstring, a2: Mode): cint {.importc, header: "<sys/stat.h>".} +proc fchmod*(a1: cint, a2: Mode): cint {.importc, header: "<sys/stat.h>".} +proc fstat*(a1: cint, a2: var Stat): cint {.importc, header: "<sys/stat.h>".} +proc lstat*(a1: cstring, a2: var Stat): cint {.importc, header: "<sys/stat.h>".} +proc mkdir*(a1: cstring, a2: Mode): cint {.importc, header: "<sys/stat.h>".} +proc mkfifo*(a1: cstring, a2: Mode): cint {.importc, header: "<sys/stat.h>".} +proc mknod*(a1: cstring, a2: Mode, a3: Dev): cint {. importc, header: "<sys/stat.h>".} -proc stat*(a1: cstring, a2: var TStat): cint {.importc, header: "<sys/stat.h>".} -proc umask*(a1: TMode): TMode {.importc, header: "<sys/stat.h>".} +proc stat*(a1: cstring, a2: var Stat): cint {.importc, header: "<sys/stat.h>".} +proc umask*(a1: Mode): Mode {.importc, header: "<sys/stat.h>".} -proc S_ISBLK*(m: TMode): bool {.importc, header: "<sys/stat.h>".} +proc S_ISBLK*(m: Mode): bool {.importc, header: "<sys/stat.h>".} ## Test for a block special file. -proc S_ISCHR*(m: TMode): bool {.importc, header: "<sys/stat.h>".} +proc S_ISCHR*(m: Mode): bool {.importc, header: "<sys/stat.h>".} ## Test for a character special file. -proc S_ISDIR*(m: TMode): bool {.importc, header: "<sys/stat.h>".} +proc S_ISDIR*(m: Mode): bool {.importc, header: "<sys/stat.h>".} ## Test for a directory. -proc S_ISFIFO*(m: TMode): bool {.importc, header: "<sys/stat.h>".} +proc S_ISFIFO*(m: Mode): bool {.importc, header: "<sys/stat.h>".} ## Test for a pipe or FIFO special file. -proc S_ISREG*(m: TMode): bool {.importc, header: "<sys/stat.h>".} +proc S_ISREG*(m: Mode): bool {.importc, header: "<sys/stat.h>".} ## Test for a regular file. -proc S_ISLNK*(m: TMode): bool {.importc, header: "<sys/stat.h>".} +proc S_ISLNK*(m: Mode): bool {.importc, header: "<sys/stat.h>".} ## Test for a symbolic link. -proc S_ISSOCK*(m: TMode): bool {.importc, header: "<sys/stat.h>".} +proc S_ISSOCK*(m: Mode): bool {.importc, header: "<sys/stat.h>".} ## Test for a socket. -proc S_TYPEISMQ*(buf: var TStat): bool {.importc, header: "<sys/stat.h>".} +proc S_TYPEISMQ*(buf: var Stat): bool {.importc, header: "<sys/stat.h>".} ## Test for a message queue. -proc S_TYPEISSEM*(buf: var TStat): bool {.importc, header: "<sys/stat.h>".} +proc S_TYPEISSEM*(buf: var Stat): bool {.importc, header: "<sys/stat.h>".} ## Test for a semaphore. -proc S_TYPEISSHM*(buf: var TStat): bool {.importc, header: "<sys/stat.h>".} +proc S_TYPEISSHM*(buf: var Stat): bool {.importc, header: "<sys/stat.h>".} ## Test for a shared memory object. -proc S_TYPEISTMO*(buf: var TStat): bool {.importc, header: "<sys/stat.h>".} +proc S_TYPEISTMO*(buf: var Stat): bool {.importc, header: "<sys/stat.h>".} ## Test macro for a typed memory object. proc mlock*(a1: pointer, a2: int): cint {.importc, header: "<sys/mman.h>".} proc mlockall*(a1: cint): cint {.importc, header: "<sys/mman.h>".} -proc mmap*(a1: pointer, a2: int, a3, a4, a5: cint, a6: TOff): pointer {. +proc mmap*(a1: pointer, a2: int, a3, a4, a5: cint, a6: Off): pointer {. importc, header: "<sys/mman.h>".} proc mprotect*(a1: pointer, a2: int, a3: cint): cint {. importc, header: "<sys/mman.h>".} @@ -2233,119 +2259,119 @@ proc munlockall*(): cint {.importc, header: "<sys/mman.h>".} proc munmap*(a1: pointer, a2: int): cint {.importc, header: "<sys/mman.h>".} proc posix_madvise*(a1: pointer, a2: int, a3: cint): cint {. importc, header: "<sys/mman.h>".} -proc posix_mem_offset*(a1: pointer, a2: int, a3: var TOff, +proc posix_mem_offset*(a1: pointer, a2: int, a3: var Off, a4: var int, a5: var cint): cint {.importc, header: "<sys/mman.h>".} proc posix_typed_mem_get_info*(a1: cint, - a2: var Tposix_typed_mem_info): cint {.importc, header: "<sys/mman.h>".} + a2: var Posix_typed_mem_info): cint {.importc, header: "<sys/mman.h>".} proc posix_typed_mem_open*(a1: cstring, a2, a3: cint): cint {. importc, header: "<sys/mman.h>".} -proc shm_open*(a1: cstring, a2: cint, a3: TMode): cint {. +proc shm_open*(a1: cstring, a2: cint, a3: Mode): cint {. importc, header: "<sys/mman.h>".} proc shm_unlink*(a1: cstring): cint {.importc, header: "<sys/mman.h>".} -proc asctime*(a1: var Ttm): cstring{.importc, header: "<time.h>".} +proc asctime*(a1: var Tm): cstring{.importc, header: "<time.h>".} -proc asctime_r*(a1: var Ttm, a2: cstring): cstring {.importc, header: "<time.h>".} -proc clock*(): TClock {.importc, header: "<time.h>".} -proc clock_getcpuclockid*(a1: TPid, a2: var TClockId): cint {. +proc asctime_r*(a1: var Tm, a2: cstring): cstring {.importc, header: "<time.h>".} +proc clock*(): Clock {.importc, header: "<time.h>".} +proc clock_getcpuclockid*(a1: Pid, a2: var ClockId): cint {. importc, header: "<time.h>".} -proc clock_getres*(a1: TClockId, a2: var Ttimespec): cint {. +proc clock_getres*(a1: ClockId, a2: var Timespec): cint {. importc, header: "<time.h>".} -proc clock_gettime*(a1: TClockId, a2: var Ttimespec): cint {. +proc clock_gettime*(a1: ClockId, a2: var Timespec): cint {. importc, header: "<time.h>".} -proc clock_nanosleep*(a1: TClockId, a2: cint, a3: var Ttimespec, - a4: var Ttimespec): cint {.importc, header: "<time.h>".} -proc clock_settime*(a1: TClockId, a2: var Ttimespec): cint {. +proc clock_nanosleep*(a1: ClockId, a2: cint, a3: var Timespec, + a4: var Timespec): cint {.importc, header: "<time.h>".} +proc clock_settime*(a1: ClockId, a2: var Timespec): cint {. importc, header: "<time.h>".} proc ctime*(a1: var Time): cstring {.importc, header: "<time.h>".} proc ctime_r*(a1: var Time, a2: cstring): cstring {.importc, header: "<time.h>".} proc difftime*(a1, a2: Time): cdouble {.importc, header: "<time.h>".} -proc getdate*(a1: cstring): ptr Ttm {.importc, header: "<time.h>".} - -proc gmtime*(a1: var Time): ptr Ttm {.importc, header: "<time.h>".} -proc gmtime_r*(a1: var Time, a2: var Ttm): ptr Ttm {.importc, header: "<time.h>".} -proc localtime*(a1: var Time): ptr Ttm {.importc, header: "<time.h>".} -proc localtime_r*(a1: var Time, a2: var Ttm): ptr Ttm {.importc, header: "<time.h>".} -proc mktime*(a1: var Ttm): Time {.importc, header: "<time.h>".} -proc timegm*(a1: var Ttm): Time {.importc, header: "<time.h>".} -proc nanosleep*(a1, a2: var Ttimespec): cint {.importc, header: "<time.h>".} +proc getdate*(a1: cstring): ptr Tm {.importc, header: "<time.h>".} + +proc gmtime*(a1: var Time): ptr Tm {.importc, header: "<time.h>".} +proc gmtime_r*(a1: var Time, a2: var Tm): ptr Tm {.importc, header: "<time.h>".} +proc localtime*(a1: var Time): ptr Tm {.importc, header: "<time.h>".} +proc localtime_r*(a1: var Time, a2: var Tm): ptr Tm {.importc, header: "<time.h>".} +proc mktime*(a1: var Tm): Time {.importc, header: "<time.h>".} +proc timegm*(a1: var Tm): Time {.importc, header: "<time.h>".} +proc nanosleep*(a1, a2: var Timespec): cint {.importc, header: "<time.h>".} proc strftime*(a1: cstring, a2: int, a3: cstring, - a4: var Ttm): int {.importc, header: "<time.h>".} -proc strptime*(a1, a2: cstring, a3: var Ttm): cstring {.importc, header: "<time.h>".} + a4: var Tm): int {.importc, header: "<time.h>".} +proc strptime*(a1, a2: cstring, a3: var Tm): cstring {.importc, header: "<time.h>".} proc time*(a1: var Time): Time {.importc, header: "<time.h>".} -proc timer_create*(a1: var TClockId, a2: var TsigEvent, - a3: var Ttimer): cint {.importc, header: "<time.h>".} -proc timer_delete*(a1: var Ttimer): cint {.importc, header: "<time.h>".} -proc timer_gettime*(a1: Ttimer, a2: var titimerspec): cint {. +proc timer_create*(a1: var ClockId, a2: var SigEvent, + a3: var Timer): cint {.importc, header: "<time.h>".} +proc timer_delete*(a1: var Timer): cint {.importc, header: "<time.h>".} +proc timer_gettime*(a1: Timer, a2: var Itimerspec): cint {. importc, header: "<time.h>".} -proc timer_getoverrun*(a1: Ttimer): cint {.importc, header: "<time.h>".} -proc timer_settime*(a1: Ttimer, a2: cint, a3: var titimerspec, - a4: var titimerspec): cint {.importc, header: "<time.h>".} +proc timer_getoverrun*(a1: Timer): cint {.importc, header: "<time.h>".} +proc timer_settime*(a1: Timer, a2: cint, a3: var Itimerspec, + a4: var Itimerspec): cint {.importc, header: "<time.h>".} proc tzset*() {.importc, header: "<time.h>".} -proc wait*(a1: var cint): TPid {.importc, header: "<sys/wait.h>".} -proc waitid*(a1: cint, a2: Tid, a3: var TsigInfo, a4: cint): cint {. +proc wait*(a1: var cint): Pid {.importc, header: "<sys/wait.h>".} +proc waitid*(a1: cint, a2: Id, a3: var SigInfo, a4: cint): cint {. importc, header: "<sys/wait.h>".} -proc waitpid*(a1: TPid, a2: var cint, a3: cint): TPid {. +proc waitpid*(a1: Pid, a2: var cint, a3: cint): Pid {. importc, header: "<sys/wait.h>".} proc bsd_signal*(a1: cint, a2: proc (x: pointer) {.noconv.}) {. importc, header: "<signal.h>".} -proc kill*(a1: TPid, a2: cint): cint {.importc, header: "<signal.h>".} -proc killpg*(a1: TPid, a2: cint): cint {.importc, header: "<signal.h>".} -proc pthread_kill*(a1: Tpthread, a2: cint): cint {.importc, header: "<signal.h>".} -proc pthread_sigmask*(a1: cint, a2, a3: var Tsigset): cint {. +proc kill*(a1: Pid, a2: cint): cint {.importc, header: "<signal.h>".} +proc killpg*(a1: Pid, a2: cint): cint {.importc, header: "<signal.h>".} +proc pthread_kill*(a1: Pthread, a2: cint): cint {.importc, header: "<signal.h>".} +proc pthread_sigmask*(a1: cint, a2, a3: var Sigset): cint {. importc, header: "<signal.h>".} proc `raise`*(a1: cint): cint {.importc, header: "<signal.h>".} -proc sigaction*(a1: cint, a2, a3: var TSigaction): cint {. +proc sigaction*(a1: cint, a2, a3: var Sigaction): cint {. importc, header: "<signal.h>".} -proc sigaddset*(a1: var Tsigset, a2: cint): cint {.importc, header: "<signal.h>".} -proc sigaltstack*(a1, a2: var TStack): cint {.importc, header: "<signal.h>".} -proc sigdelset*(a1: var Tsigset, a2: cint): cint {.importc, header: "<signal.h>".} -proc sigemptyset*(a1: var Tsigset): cint {.importc, header: "<signal.h>".} -proc sigfillset*(a1: var Tsigset): cint {.importc, header: "<signal.h>".} +proc sigaddset*(a1: var Sigset, a2: cint): cint {.importc, header: "<signal.h>".} +proc sigaltstack*(a1, a2: var Stack): cint {.importc, header: "<signal.h>".} +proc sigdelset*(a1: var Sigset, a2: cint): cint {.importc, header: "<signal.h>".} +proc sigemptyset*(a1: var Sigset): cint {.importc, header: "<signal.h>".} +proc sigfillset*(a1: var Sigset): cint {.importc, header: "<signal.h>".} proc sighold*(a1: cint): cint {.importc, header: "<signal.h>".} proc sigignore*(a1: cint): cint {.importc, header: "<signal.h>".} proc siginterrupt*(a1, a2: cint): cint {.importc, header: "<signal.h>".} -proc sigismember*(a1: var Tsigset, a2: cint): cint {.importc, header: "<signal.h>".} +proc sigismember*(a1: var Sigset, a2: cint): cint {.importc, header: "<signal.h>".} proc signal*(a1: cint, a2: proc (x: cint) {.noconv.}) {. importc, header: "<signal.h>".} proc sigpause*(a1: cint): cint {.importc, header: "<signal.h>".} -proc sigpending*(a1: var Tsigset): cint {.importc, header: "<signal.h>".} -proc sigprocmask*(a1: cint, a2, a3: var Tsigset): cint {. +proc sigpending*(a1: var Sigset): cint {.importc, header: "<signal.h>".} +proc sigprocmask*(a1: cint, a2, a3: var Sigset): cint {. importc, header: "<signal.h>".} -proc sigqueue*(a1: TPid, a2: cint, a3: TsigVal): cint {. +proc sigqueue*(a1: Pid, a2: cint, a3: SigVal): cint {. importc, header: "<signal.h>".} proc sigrelse*(a1: cint): cint {.importc, header: "<signal.h>".} proc sigset*(a1: int, a2: proc (x: cint) {.noconv.}) {. importc, header: "<signal.h>".} -proc sigsuspend*(a1: var Tsigset): cint {.importc, header: "<signal.h>".} -proc sigtimedwait*(a1: var Tsigset, a2: var TsigInfo, - a3: var Ttimespec): cint {.importc, header: "<signal.h>".} -proc sigwait*(a1: var Tsigset, a2: var cint): cint {. +proc sigsuspend*(a1: var Sigset): cint {.importc, header: "<signal.h>".} +proc sigtimedwait*(a1: var Sigset, a2: var SigInfo, + a3: var Timespec): cint {.importc, header: "<signal.h>".} +proc sigwait*(a1: var Sigset, a2: var cint): cint {. importc, header: "<signal.h>".} -proc sigwaitinfo*(a1: var Tsigset, a2: var TsigInfo): cint {. +proc sigwaitinfo*(a1: var Sigset, a2: var SigInfo): cint {. importc, header: "<signal.h>".} -proc catclose*(a1: Tnl_catd): cint {.importc, header: "<nl_types.h>".} -proc catgets*(a1: Tnl_catd, a2, a3: cint, a4: cstring): cstring {. +proc catclose*(a1: Nl_catd): cint {.importc, header: "<nl_types.h>".} +proc catgets*(a1: Nl_catd, a2, a3: cint, a4: cstring): cstring {. importc, header: "<nl_types.h>".} -proc catopen*(a1: cstring, a2: cint): Tnl_catd {. +proc catopen*(a1: cstring, a2: cint): Nl_catd {. importc, header: "<nl_types.h>".} proc sched_get_priority_max*(a1: cint): cint {.importc, header: "<sched.h>".} proc sched_get_priority_min*(a1: cint): cint {.importc, header: "<sched.h>".} -proc sched_getparam*(a1: TPid, a2: var Tsched_param): cint {. +proc sched_getparam*(a1: Pid, a2: var Sched_param): cint {. importc, header: "<sched.h>".} -proc sched_getscheduler*(a1: TPid): cint {.importc, header: "<sched.h>".} -proc sched_rr_get_interval*(a1: TPid, a2: var Ttimespec): cint {. +proc sched_getscheduler*(a1: Pid): cint {.importc, header: "<sched.h>".} +proc sched_rr_get_interval*(a1: Pid, a2: var Timespec): cint {. importc, header: "<sched.h>".} -proc sched_setparam*(a1: TPid, a2: var Tsched_param): cint {. +proc sched_setparam*(a1: Pid, a2: var Sched_param): cint {. importc, header: "<sched.h>".} -proc sched_setscheduler*(a1: TPid, a2: cint, a3: var Tsched_param): cint {. +proc sched_setscheduler*(a1: Pid, a2: cint, a3: var Sched_param): cint {. importc, header: "<sched.h>".} proc sched_yield*(): cint {.importc, header: "<sched.h>".} @@ -2359,13 +2385,13 @@ proc FD_SET*(a1: cint | SocketHandle, a2: var TFdSet) {. importc: "FD_SET", header: "<sys/select.h>".} proc FD_ZERO*(a1: var TFdSet) {.importc, header: "<sys/select.h>".} -proc pselect*(a1: cint, a2, a3, a4: ptr TFdSet, a5: ptr Ttimespec, - a6: var Tsigset): cint {.importc, header: "<sys/select.h>".} +proc pselect*(a1: cint, a2, a3, a4: ptr TFdSet, a5: ptr Timespec, + a6: var Sigset): cint {.importc, header: "<sys/select.h>".} proc select*(a1: cint | SocketHandle, a2, a3, a4: ptr TFdSet, a5: ptr Timeval): cint {. importc, header: "<sys/select.h>".} when hasSpawnH: - proc posix_spawn*(a1: var TPid, a2: cstring, + proc posix_spawn*(a1: var Pid, a2: cstring, a3: var Tposix_spawn_file_actions, a4: var Tposix_spawnattr, a5, a6: cstringArray): cint {.importc, header: "<spawn.h>".} @@ -2374,7 +2400,7 @@ when hasSpawnH: proc posix_spawn_file_actions_adddup2*(a1: var Tposix_spawn_file_actions, a2, a3: cint): cint {.importc, header: "<spawn.h>".} proc posix_spawn_file_actions_addopen*(a1: var Tposix_spawn_file_actions, - a2: cint, a3: cstring, a4: cint, a5: TMode): cint {. + a2: cint, a3: cstring, a4: cint, a5: Mode): cint {. importc, header: "<spawn.h>".} proc posix_spawn_file_actions_destroy*( a1: var Tposix_spawn_file_actions): cint {.importc, header: "<spawn.h>".} @@ -2383,48 +2409,48 @@ when hasSpawnH: proc posix_spawnattr_destroy*(a1: var Tposix_spawnattr): cint {. importc, header: "<spawn.h>".} proc posix_spawnattr_getsigdefault*(a1: var Tposix_spawnattr, - a2: var Tsigset): cint {.importc, header: "<spawn.h>".} + a2: var Sigset): cint {.importc, header: "<spawn.h>".} proc posix_spawnattr_getflags*(a1: var Tposix_spawnattr, a2: var cshort): cint {.importc, header: "<spawn.h>".} proc posix_spawnattr_getpgroup*(a1: var Tposix_spawnattr, - a2: var TPid): cint {.importc, header: "<spawn.h>".} + a2: var Pid): cint {.importc, header: "<spawn.h>".} proc posix_spawnattr_getschedparam*(a1: var Tposix_spawnattr, - a2: var Tsched_param): cint {.importc, header: "<spawn.h>".} + a2: var Sched_param): cint {.importc, header: "<spawn.h>".} proc posix_spawnattr_getschedpolicy*(a1: var Tposix_spawnattr, a2: var cint): cint {.importc, header: "<spawn.h>".} proc posix_spawnattr_getsigmask*(a1: var Tposix_spawnattr, - a2: var Tsigset): cint {.importc, header: "<spawn.h>".} + a2: var Sigset): cint {.importc, header: "<spawn.h>".} proc posix_spawnattr_init*(a1: var Tposix_spawnattr): cint {. importc, header: "<spawn.h>".} proc posix_spawnattr_setsigdefault*(a1: var Tposix_spawnattr, - a2: var Tsigset): cint {.importc, header: "<spawn.h>".} + a2: var Sigset): cint {.importc, header: "<spawn.h>".} proc posix_spawnattr_setflags*(a1: var Tposix_spawnattr, a2: cint): cint {. importc, header: "<spawn.h>".} - proc posix_spawnattr_setpgroup*(a1: var Tposix_spawnattr, a2: TPid): cint {. + proc posix_spawnattr_setpgroup*(a1: var Tposix_spawnattr, a2: Pid): cint {. importc, header: "<spawn.h>".} proc posix_spawnattr_setschedparam*(a1: var Tposix_spawnattr, - a2: var Tsched_param): cint {.importc, header: "<spawn.h>".} + a2: var Sched_param): cint {.importc, header: "<spawn.h>".} proc posix_spawnattr_setschedpolicy*(a1: var Tposix_spawnattr, a2: cint): cint {. importc, header: "<spawn.h>".} proc posix_spawnattr_setsigmask*(a1: var Tposix_spawnattr, - a2: var Tsigset): cint {.importc, header: "<spawn.h>".} - proc posix_spawnp*(a1: var TPid, a2: cstring, + a2: var Sigset): cint {.importc, header: "<spawn.h>".} + proc posix_spawnp*(a1: var Pid, a2: cstring, a3: var Tposix_spawn_file_actions, a4: var Tposix_spawnattr, a5, a6: cstringArray): cint {.importc, header: "<spawn.h>".} -proc getcontext*(a1: var Tucontext): cint {.importc, header: "<ucontext.h>".} -proc makecontext*(a1: var Tucontext, a4: proc (){.noconv.}, a3: cint) {. +proc getcontext*(a1: var Ucontext): cint {.importc, header: "<ucontext.h>".} +proc makecontext*(a1: var Ucontext, a4: proc (){.noconv.}, a3: cint) {. varargs, importc, header: "<ucontext.h>".} -proc setcontext*(a1: var Tucontext): cint {.importc, header: "<ucontext.h>".} -proc swapcontext*(a1, a2: var Tucontext): cint {.importc, header: "<ucontext.h>".} +proc setcontext*(a1: var Ucontext): cint {.importc, header: "<ucontext.h>".} +proc swapcontext*(a1, a2: var Ucontext): cint {.importc, header: "<ucontext.h>".} -proc readv*(a1: cint, a2: ptr TIOVec, a3: cint): int {. +proc readv*(a1: cint, a2: ptr IOVec, a3: cint): int {. importc, header: "<sys/uio.h>".} -proc writev*(a1: cint, a2: ptr TIOVec, a3: cint): int {. +proc writev*(a1: cint, a2: ptr IOVec, a3: cint): int {. importc, header: "<sys/uio.h>".} proc CMSG_DATA*(cmsg: ptr Tcmsghdr): cstring {. @@ -2491,40 +2517,40 @@ proc if_indextoname*(a1: cint, a2: cstring): cstring {. proc if_nameindex*(): ptr Tif_nameindex {.importc, header: "<net/if.h>".} proc if_freenameindex*(a1: ptr Tif_nameindex) {.importc, header: "<net/if.h>".} -proc IN6_IS_ADDR_UNSPECIFIED* (a1: ptr TIn6Addr): cint {. +proc IN6_IS_ADDR_UNSPECIFIED* (a1: ptr In6Addr): cint {. importc, header: "<netinet/in.h>".} ## Unspecified address. -proc IN6_IS_ADDR_LOOPBACK* (a1: ptr TIn6Addr): cint {. +proc IN6_IS_ADDR_LOOPBACK* (a1: ptr In6Addr): cint {. importc, header: "<netinet/in.h>".} ## Loopback address. -proc IN6_IS_ADDR_MULTICAST* (a1: ptr TIn6Addr): cint {. +proc IN6_IS_ADDR_MULTICAST* (a1: ptr In6Addr): cint {. importc, header: "<netinet/in.h>".} ## Multicast address. -proc IN6_IS_ADDR_LINKLOCAL* (a1: ptr TIn6Addr): cint {. +proc IN6_IS_ADDR_LINKLOCAL* (a1: ptr In6Addr): cint {. importc, header: "<netinet/in.h>".} ## Unicast link-local address. -proc IN6_IS_ADDR_SITELOCAL* (a1: ptr TIn6Addr): cint {. +proc IN6_IS_ADDR_SITELOCAL* (a1: ptr In6Addr): cint {. importc, header: "<netinet/in.h>".} ## Unicast site-local address. -proc IN6_IS_ADDR_V4MAPPED* (a1: ptr TIn6Addr): cint {. +proc IN6_IS_ADDR_V4MAPPED* (a1: ptr In6Addr): cint {. importc, header: "<netinet/in.h>".} ## IPv4 mapped address. -proc IN6_IS_ADDR_V4COMPAT* (a1: ptr TIn6Addr): cint {. +proc IN6_IS_ADDR_V4COMPAT* (a1: ptr In6Addr): cint {. importc, header: "<netinet/in.h>".} ## IPv4-compatible address. -proc IN6_IS_ADDR_MC_NODELOCAL* (a1: ptr TIn6Addr): cint {. +proc IN6_IS_ADDR_MC_NODELOCAL* (a1: ptr In6Addr): cint {. importc, header: "<netinet/in.h>".} ## Multicast node-local address. -proc IN6_IS_ADDR_MC_LINKLOCAL* (a1: ptr TIn6Addr): cint {. +proc IN6_IS_ADDR_MC_LINKLOCAL* (a1: ptr In6Addr): cint {. importc, header: "<netinet/in.h>".} ## Multicast link-local address. -proc IN6_IS_ADDR_MC_SITELOCAL* (a1: ptr TIn6Addr): cint {. +proc IN6_IS_ADDR_MC_SITELOCAL* (a1: ptr In6Addr): cint {. importc, header: "<netinet/in.h>".} ## Multicast site-local address. -proc IN6_IS_ADDR_MC_ORGLOCAL* (a1: ptr TIn6Addr): cint {. +proc IN6_IS_ADDR_MC_ORGLOCAL* (a1: ptr In6Addr): cint {. importc, header: "<netinet/in.h>".} ## Multicast organization-local address. -proc IN6_IS_ADDR_MC_GLOBAL* (a1: ptr TIn6Addr): cint {. +proc IN6_IS_ADDR_MC_GLOBAL* (a1: ptr In6Addr): cint {. importc, header: "<netinet/in.h>".} ## Multicast global address. @@ -2552,9 +2578,9 @@ proc getnetbyaddr*(a1: int32, a2: cint): ptr Tnetent {.importc, header: "<netdb. proc getnetbyname*(a1: cstring): ptr Tnetent {.importc, header: "<netdb.h>".} proc getnetent*(): ptr Tnetent {.importc, header: "<netdb.h>".} -proc getprotobyname*(a1: cstring): ptr TProtoent {.importc, header: "<netdb.h>".} -proc getprotobynumber*(a1: cint): ptr TProtoent {.importc, header: "<netdb.h>".} -proc getprotoent*(): ptr TProtoent {.importc, header: "<netdb.h>".} +proc getprotobyname*(a1: cstring): ptr Protoent {.importc, header: "<netdb.h>".} +proc getprotobynumber*(a1: cint): ptr Protoent {.importc, header: "<netdb.h>".} +proc getprotoent*(): ptr Protoent {.importc, header: "<netdb.h>".} proc getservbyname*(a1, a2: cstring): ptr Servent {.importc, header: "<netdb.h>".} proc getservbyport*(a1: cint, a2: cstring): ptr Servent {. diff --git a/lib/posix/termios.nim b/lib/posix/termios.nim index 710b2fa6b..44f029039 100644 --- a/lib/posix/termios.nim +++ b/lib/posix/termios.nim @@ -12,17 +12,18 @@ import posix type Speed* = cuint - Tcflag* = cuint + Cflag* = cuint +{.deprecated: [Tcflag: Cflag].} const NCCS* = 32 type Termios* {.importc: "struct termios", header: "<termios.h>".} = object - c_iflag*: Tcflag # input mode flags - c_oflag*: Tcflag # output mode flags - c_cflag*: Tcflag # control mode flags - c_lflag*: Tcflag # local mode flags + c_iflag*: Cflag # input mode flags + c_oflag*: Cflag # output mode flags + c_cflag*: Cflag # control mode flags + c_lflag*: Cflag # local mode flags c_line*: cuchar # line discipline c_cc*: array[NCCS, cuchar] # control characters @@ -258,4 +259,4 @@ proc tcFlow*(fd: cint; action: cint): cint {.importc: "tcflow", header: "<termios.h>".} # Get process group ID for session leader for controlling terminal FD. -proc tcGetSid*(fd: cint): TPid {.importc: "tcgetsid", header: "<termios.h>".} +proc tcGetSid*(fd: cint): Pid {.importc: "tcgetsid", header: "<termios.h>".} diff --git a/lib/pure/actors.nim b/lib/pure/actors.nim index 294c24741..da9037285 100644 --- a/lib/pure/actors.nim +++ b/lib/pure/actors.nim @@ -16,7 +16,7 @@ ## .. code-block:: nim ## ## var -## a: TActorPool[int, void] +## a: ActorPool[int, void] ## createActorPool(a) ## for i in 0 .. < 300: ## a.spawn(i, proc (x: int) {.thread.} = echo x) @@ -30,75 +30,76 @@ from os import sleep type - TTask*[TIn, TOut] = object{.pure, final.} ## a task - when TOut isnot void: - receiver*: ptr TChannel[TOut] ## the receiver channel of the response - action*: proc (x: TIn): TOut {.thread.} ## action to execute; + Task*[In, Out] = object{.pure, final.} ## a task + when Out isnot void: + receiver*: ptr Channel[Out] ## the receiver channel of the response + action*: proc (x: In): Out {.thread.} ## action to execute; ## sometimes useful shutDown*: bool ## set to tell an actor to shut-down - data*: TIn ## the data to process + data*: In ## the data to process - TActor[TIn, TOut] = object{.pure, final.} - i: TChannel[TTask[TIn, TOut]] - t: TThread[ptr TActor[TIn, TOut]] + Actor[In, Out] = object{.pure, final.} + i: Channel[Task[In, Out]] + t: TThread[ptr Actor[In, Out]] - PActor*[TIn, TOut] = ptr TActor[TIn, TOut] ## an actor - -proc spawn*[TIn, TOut](action: proc( - self: PActor[TIn, TOut]){.thread.}): PActor[TIn, TOut] = + PActor*[In, Out] = ptr Actor[In, Out] ## an actor +{.deprecated: [TTask: Task, TActor: Actor].} + +proc spawn*[In, Out](action: proc( + self: PActor[In, Out]){.thread.}): PActor[In, Out] = ## creates an actor; that is a thread with an inbox. The caller MUST call ## ``join`` because that also frees the actor's associated resources. - result = cast[PActor[TIn, TOut]](allocShared0(sizeof(result[]))) + result = cast[PActor[In, Out]](allocShared0(sizeof(result[]))) open(result.i) createThread(result.t, action, result) -proc inbox*[TIn, TOut](self: PActor[TIn, TOut]): ptr TChannel[TIn] = +proc inbox*[In, Out](self: PActor[In, Out]): ptr Channel[In] = ## gets a pointer to the associated inbox of the actor `self`. result = addr(self.i) -proc running*[TIn, TOut](a: PActor[TIn, TOut]): bool = +proc running*[In, Out](a: PActor[In, Out]): bool = ## returns true if the actor `a` is running. result = running(a.t) -proc ready*[TIn, TOut](a: PActor[TIn, TOut]): bool = +proc ready*[In, Out](a: PActor[In, Out]): bool = ## returns true if the actor `a` is ready to process new messages. result = ready(a.i) -proc join*[TIn, TOut](a: PActor[TIn, TOut]) = +proc join*[In, Out](a: PActor[In, Out]) = ## joins an actor. joinThread(a.t) close(a.i) deallocShared(a) -proc recv*[TIn, TOut](a: PActor[TIn, TOut]): TTask[TIn, TOut] = +proc recv*[In, Out](a: PActor[In, Out]): Task[In, Out] = ## receives a task from `a`'s inbox. result = recv(a.i) -proc send*[TIn, TOut, X, Y](receiver: PActor[TIn, TOut], msg: TIn, +proc send*[In, Out, X, Y](receiver: PActor[In, Out], msg: In, sender: PActor[X, Y]) = ## sends a message to `a`'s inbox. - var t: TTask[TIn, TOut] + var t: Task[In, Out] t.receiver = addr(sender.i) shallowCopy(t.data, msg) send(receiver.i, t) -proc send*[TIn, TOut](receiver: PActor[TIn, TOut], msg: TIn, - sender: ptr TChannel[TOut] = nil) = +proc send*[In, Out](receiver: PActor[In, Out], msg: In, + sender: ptr Channel[Out] = nil) = ## sends a message to `receiver`'s inbox. - var t: TTask[TIn, TOut] + var t: Task[In, Out] t.receiver = sender shallowCopy(t.data, msg) send(receiver.i, t) -proc sendShutdown*[TIn, TOut](receiver: PActor[TIn, TOut]) = +proc sendShutdown*[In, Out](receiver: PActor[In, Out]) = ## send a shutdown message to `receiver`. - var t: TTask[TIn, TOut] + var t: Task[In, Out] t.shutdown = true send(receiver.i, t) -proc reply*[TIn, TOut](t: TTask[TIn, TOut], m: TOut) = +proc reply*[In, Out](t: Task[In, Out], m: Out) = ## sends a message to io's output message box. - when TOut is void: + when Out is void: {.error: "you cannot reply to a void outbox".} assert t.receiver != nil send(t.receiver[], m) @@ -107,34 +108,35 @@ proc reply*[TIn, TOut](t: TTask[TIn, TOut], m: TOut) = # ----------------- actor pools ---------------------------------------------- type - TActorPool*[TIn, TOut] = object{.pure, final.} ## an actor pool - actors: seq[PActor[TIn, TOut]] - when TOut isnot void: - outputs: TChannel[TOut] + ActorPool*[In, Out] = object{.pure, final.} ## an actor pool + actors: seq[PActor[In, Out]] + when Out isnot void: + outputs: Channel[Out] +{.deprecated: [TActorPool: ActorPool].} -proc `^`*[T](f: ptr TChannel[T]): T = +proc `^`*[T](f: ptr Channel[T]): T = ## alias for 'recv'. result = recv(f[]) -proc poolWorker[TIn, TOut](self: PActor[TIn, TOut]) {.thread.} = +proc poolWorker[In, Out](self: PActor[In, Out]) {.thread.} = while true: var m = self.recv if m.shutDown: break - when TOut is void: + when Out is void: m.action(m.data) else: send(m.receiver[], m.action(m.data)) #self.reply() -proc createActorPool*[TIn, TOut](a: var TActorPool[TIn, TOut], poolSize = 4) = +proc createActorPool*[In, Out](a: var ActorPool[In, Out], poolSize = 4) = ## creates an actor pool. newSeq(a.actors, poolSize) - when TOut isnot void: + when Out isnot void: open(a.outputs) for i in 0 .. < a.actors.len: - a.actors[i] = spawn(poolWorker[TIn, TOut]) + a.actors[i] = spawn(poolWorker[In, Out]) -proc sync*[TIn, TOut](a: var TActorPool[TIn, TOut], polling=50) = +proc sync*[In, Out](a: var ActorPool[In, Out], polling=50) = ## waits for every actor of `a` to finish with its work. Currently this is ## implemented as polling every `polling` ms and has a slight chance ## of failing since we check for every actor to be in `ready` state and not @@ -157,18 +159,18 @@ proc sync*[TIn, TOut](a: var TActorPool[TIn, TOut], polling=50) = if allReadyCount > 1: break sleep(polling) -proc terminate*[TIn, TOut](a: var TActorPool[TIn, TOut]) = +proc terminate*[In, Out](a: var ActorPool[In, Out]) = ## terminates each actor in the actor pool `a` and frees the ## resources attached to `a`. - var t: TTask[TIn, TOut] + var t: Task[In, Out] t.shutdown = true for i in 0.. <a.actors.len: send(a.actors[i].i, t) for i in 0.. <a.actors.len: join(a.actors[i]) - when TOut isnot void: + when Out isnot void: close(a.outputs) a.actors = nil -proc join*[TIn, TOut](a: var TActorPool[TIn, TOut]) = +proc join*[In, Out](a: var ActorPool[In, Out]) = ## short-cut for `sync` and then `terminate`. sync(a) terminate(a) @@ -202,28 +204,28 @@ template schedule = else: raise newException(DeadThreadError, "cannot send message; thread died") -proc spawn*[TIn, TOut](p: var TActorPool[TIn, TOut], input: TIn, - action: proc (input: TIn): TOut {.thread.} - ): ptr TChannel[TOut] = +proc spawn*[In, Out](p: var ActorPool[In, Out], input: In, + action: proc (input: In): Out {.thread.} + ): ptr Channel[Out] = ## uses the actor pool to run ``action(input)`` concurrently. ## `spawn` is guaranteed to not block. - var t: TTask[TIn, TOut] + var t: Task[In, Out] setupTask() result = addr(p.outputs) t.receiver = result schedule() -proc spawn*[TIn](p: var TActorPool[TIn, void], input: TIn, - action: proc (input: TIn) {.thread.}) = +proc spawn*[In](p: var ActorPool[In, void], input: In, + action: proc (input: In) {.thread.}) = ## uses the actor pool to run ``action(input)`` concurrently. ## `spawn` is guaranteed to not block. - var t: TTask[TIn, void] + var t: Task[In, void] setupTask() schedule() when not defined(testing) and isMainModule: var - a: TActorPool[int, void] + a: ActorPool[int, void] createActorPool(a) for i in 0 .. < 300: a.spawn(i, proc (x: int) {.thread.} = echo x) diff --git a/lib/pure/algorithm.nim b/lib/pure/algorithm.nim index f7ccb9234..c9f779018 100644 --- a/lib/pure/algorithm.nim +++ b/lib/pure/algorithm.nim @@ -24,6 +24,17 @@ proc `*`*(x: int, order: SortOrder): int {.inline.} = var y = order.ord - 1 result = (x xor y) - y +proc fill*[T](a: var openArray[T], first, last: Natural, value: T) = + ## fills the array ``a[first..last]`` with `value`. + var x = first + while x <= last: + a[x] = value + inc(x) + +proc fill*[T](a: var openArray[T], value: T) = + ## fills the array `a` with `value`. + fill(a, 0, a.high, value) + proc reverse*[T](a: var openArray[T], first, last: Natural) = ## reverses the array ``a[first..last]``. var x = first @@ -88,16 +99,13 @@ proc lowerBound*[T](a: openArray[T], key: T, cmp: proc(x,y: T): int {.closure.}) ## arr.insert(4, arr.lowerBound(4)) ## `after running the above arr is `[1,2,3,4,5,6,7,8,9]` result = a.low - var pos = result - var count, step: int - count = a.high - a.low + 1 + var count = a.high - a.low + 1 + var step, pos: int while count != 0: - pos = result step = count div 2 - pos += step + pos = result + step if cmp(a[pos], key) < 0: - pos.inc - result = pos + result = pos + 1 count -= step + 1 else: count = step @@ -210,8 +218,7 @@ template sortedByIt*(seq1, op: expr): expr = ## p2: Person = (name: "p2", age: 20) ## p3: Person = (name: "p3", age: 30) ## p4: Person = (name: "p4", age: 30) - ## - ## people = @[p1,p2,p4,p3] + ## people = @[p1,p2,p4,p3] ## ## echo people.sortedByIt(it.name) ## @@ -233,7 +240,7 @@ template sortedByIt*(seq1, op: expr): expr = proc product*[T](x: openArray[seq[T]]): seq[seq[T]] = ## produces the Cartesian product of the array. Warning: complexity ## may explode. - result = @[] + result = newSeq[seq[T]]() if x.len == 0: return if x.len == 1: @@ -243,8 +250,7 @@ proc product*[T](x: openArray[seq[T]]): seq[seq[T]] = indexes = newSeq[int](x.len) initial = newSeq[int](x.len) index = 0 - # replace with newSeq as soon as #853 is fixed - var next: seq[T] = @[] + var next = newSeq[T]() next.setLen(x.len) for i in 0..(x.len-1): if len(x[i]) == 0: return @@ -322,3 +328,16 @@ proc prevPermutation*[T](x: var openarray[T]): bool {.discardable.} = swap x[i-1], x[j] result = true + +when isMainModule: + # Tests for lowerBound + var arr = @[1,2,3,5,6,7,8,9] + assert arr.lowerBound(0) == 0 + assert arr.lowerBound(4) == 3 + assert arr.lowerBound(5) == 3 + assert arr.lowerBound(10) == 8 + arr = @[1,5,10] + assert arr.lowerBound(4) == 1 + assert arr.lowerBound(5) == 1 + assert arr.lowerBound(6) == 2 + diff --git a/lib/pure/asyncdispatch.nim b/lib/pure/asyncdispatch.nim index a4d7a1632..550b82f49 100644 --- a/lib/pure/asyncdispatch.nim +++ b/lib/pure/asyncdispatch.nim @@ -323,32 +323,34 @@ proc processTimers(p: PDispatcherBase) = when defined(windows) or defined(nimdoc): import winlean, sets, hashes type - TCompletionKey = Dword + CompletionKey = Dword - TCompletionData* = object - fd*: TAsyncFD # TODO: Rename this. - cb*: proc (fd: TAsyncFD, bytesTransferred: Dword, + CompletionData* = object + fd*: AsyncFD # TODO: Rename this. + cb*: proc (fd: AsyncFD, bytesTransferred: Dword, errcode: OSErrorCode) {.closure,gcsafe.} PDispatcher* = ref object of PDispatcherBase - ioPort: THandle - handles: HashSet[TAsyncFD] + ioPort: Handle + handles: HashSet[AsyncFD] - TCustomOverlapped = object of TOVERLAPPED - data*: TCompletionData + CustomOverlapped = object of TOVERLAPPED + data*: CompletionData - PCustomOverlapped* = ref TCustomOverlapped + PCustomOverlapped* = ref CustomOverlapped - TAsyncFD* = distinct int + AsyncFD* = distinct int + {.deprecated: [TCompletionKey: CompletionKey, TAsyncFD: AsyncFD, + TCustomOverlapped: CustomOverlapped, TCompletionData: CompletionData].} - proc hash(x: TAsyncFD): THash {.borrow.} - proc `==`*(x: TAsyncFD, y: TAsyncFD): bool {.borrow.} + proc hash(x: AsyncFD): Hash {.borrow.} + proc `==`*(x: AsyncFD, y: AsyncFD): bool {.borrow.} proc newDispatcher*(): PDispatcher = ## Creates a new Dispatcher instance. new result result.ioPort = createIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 1) - result.handles = initSet[TAsyncFD]() + result.handles = initSet[AsyncFD]() result.timers = @[] var gDisp{.threadvar.}: PDispatcher ## Global dispatcher @@ -357,15 +359,15 @@ when defined(windows) or defined(nimdoc): if gDisp.isNil: gDisp = newDispatcher() result = gDisp - proc register*(fd: TAsyncFD) = + proc register*(fd: AsyncFD) = ## Registers ``fd`` with the dispatcher. let p = getGlobalDispatcher() - if createIoCompletionPort(fd.THandle, p.ioPort, - cast[TCompletionKey](fd), 1) == 0: + if createIoCompletionPort(fd.Handle, p.ioPort, + cast[CompletionKey](fd), 1) == 0: raiseOSError(osLastError()) p.handles.incl(fd) - proc verifyPresence(fd: TAsyncFD) = + proc verifyPresence(fd: AsyncFD) = ## Ensures that file descriptor has been registered with the dispatcher. let p = getGlobalDispatcher() if fd notin p.handles: @@ -394,7 +396,7 @@ when defined(windows) or defined(nimdoc): # TODO: http://www.serverframework.com/handling-multiple-pending-socket-read-and-write-operations.html if res: # This is useful for ensuring the reliability of the overlapped struct. - assert customOverlapped.data.fd == lpCompletionKey.TAsyncFD + assert customOverlapped.data.fd == lpCompletionKey.AsyncFD customOverlapped.data.cb(customOverlapped.data.fd, lpNumberOfBytesTransferred, OSErrorCode(-1)) @@ -402,7 +404,7 @@ when defined(windows) or defined(nimdoc): else: let errCode = osLastError() if customOverlapped != nil: - assert customOverlapped.data.fd == lpCompletionKey.TAsyncFD + assert customOverlapped.data.fd == lpCompletionKey.AsyncFD customOverlapped.data.cb(customOverlapped.data.fd, lpNumberOfBytesTransferred, errCode) GC_unref(customOverlapped) @@ -480,7 +482,7 @@ when defined(windows) or defined(nimdoc): dwRemoteAddressLength, LocalSockaddr, LocalSockaddrLength, RemoteSockaddr, RemoteSockaddrLength) - proc connect*(socket: TAsyncFD, address: string, port: Port, + proc connect*(socket: AsyncFD, address: string, port: Port, af = AF_INET): Future[void] = ## Connects ``socket`` to server at ``address:port``. ## @@ -506,8 +508,8 @@ when defined(windows) or defined(nimdoc): # http://blogs.msdn.com/b/oldnewthing/archive/2011/02/02/10123392.aspx var ol = PCustomOverlapped() GC_ref(ol) - ol.data = TCompletionData(fd: socket, cb: - proc (fd: TAsyncFD, bytesCount: Dword, errcode: OSErrorCode) = + ol.data = CompletionData(fd: socket, cb: + proc (fd: AsyncFD, bytesCount: Dword, errcode: OSErrorCode) = if not retFuture.finished: if errcode == OSErrorCode(-1): retFuture.complete() @@ -542,7 +544,7 @@ when defined(windows) or defined(nimdoc): retFuture.fail(newException(OSError, osErrorMsg(lastError))) return retFuture - proc recv*(socket: TAsyncFD, size: int, + proc recv*(socket: AsyncFD, size: int, flags = {SocketFlag.SafeDisconn}): Future[string] = ## Reads **up to** ``size`` bytes from ``socket``. Returned future will ## complete once all the data requested is read, a part of the data has been @@ -570,8 +572,8 @@ when defined(windows) or defined(nimdoc): var flagsio = flags.toOSFlags().Dword var ol = PCustomOverlapped() GC_ref(ol) - ol.data = TCompletionData(fd: socket, cb: - proc (fd: TAsyncFD, bytesCount: Dword, errcode: OSErrorCode) = + ol.data = CompletionData(fd: socket, cb: + proc (fd: AsyncFD, bytesCount: Dword, errcode: OSErrorCode) = if not retFuture.finished: if errcode == OSErrorCode(-1): if bytesCount == 0 and dataBuf.buf[0] == '\0': @@ -634,7 +636,7 @@ when defined(windows) or defined(nimdoc): # free ``ol``. return retFuture - proc recvInto*(socket: TAsyncFD, buf: cstring, size: int, + proc recvInto*(socket: AsyncFD, buf: cstring, size: int, flags = {SocketFlag.SafeDisconn}): Future[int] = ## Reads **up to** ``size`` bytes from ``socket`` into ``buf``, which must ## at least be of that size. Returned future will complete once all the @@ -665,8 +667,8 @@ when defined(windows) or defined(nimdoc): var flagsio = flags.toOSFlags().Dword var ol = PCustomOverlapped() GC_ref(ol) - ol.data = TCompletionData(fd: socket, cb: - proc (fd: TAsyncFD, bytesCount: Dword, errcode: OSErrorCode) = + ol.data = CompletionData(fd: socket, cb: + proc (fd: AsyncFD, bytesCount: Dword, errcode: OSErrorCode) = if not retFuture.finished: if errcode == OSErrorCode(-1): if bytesCount == 0 and dataBuf.buf[0] == '\0': @@ -721,7 +723,7 @@ when defined(windows) or defined(nimdoc): # free ``ol``. return retFuture - proc send*(socket: TAsyncFD, data: string, + proc send*(socket: AsyncFD, data: string, flags = {SocketFlag.SafeDisconn}): Future[void] = ## Sends ``data`` to ``socket``. The returned future will complete once all ## data has been sent. @@ -735,8 +737,8 @@ when defined(windows) or defined(nimdoc): var bytesReceived, lowFlags: Dword var ol = PCustomOverlapped() GC_ref(ol) - ol.data = TCompletionData(fd: socket, cb: - proc (fd: TAsyncFD, bytesCount: Dword, errcode: OSErrorCode) = + ol.data = CompletionData(fd: socket, cb: + proc (fd: AsyncFD, bytesCount: Dword, errcode: OSErrorCode) = if not retFuture.finished: if errcode == OSErrorCode(-1): retFuture.complete() @@ -764,8 +766,8 @@ when defined(windows) or defined(nimdoc): # free ``ol``. return retFuture - proc acceptAddr*(socket: TAsyncFD, flags = {SocketFlag.SafeDisconn}): - Future[tuple[address: string, client: TAsyncFD]] = + proc acceptAddr*(socket: AsyncFD, flags = {SocketFlag.SafeDisconn}): + Future[tuple[address: string, client: AsyncFD]] = ## Accepts a new connection. Returns a future containing the client socket ## corresponding to that connection and the remote address of the client. ## The future will complete when the connection is successfully accepted. @@ -778,7 +780,7 @@ when defined(windows) or defined(nimdoc): ## flag is specified then this error will not be raised and instead ## accept will be called again. verifyPresence(socket) - var retFuture = newFuture[tuple[address: string, client: TAsyncFD]]("acceptAddr") + var retFuture = newFuture[tuple[address: string, client: AsyncFD]]("acceptAddr") var clientSock = newRawSocket() if clientSock == osInvalidSocket: raiseOSError(osLastError()) @@ -803,11 +805,11 @@ when defined(windows) or defined(nimdoc): dwLocalAddressLength, dwRemoteAddressLength, addr localSockaddr, addr localLen, addr remoteSockaddr, addr remoteLen) - register(clientSock.TAsyncFD) + register(clientSock.AsyncFD) # TODO: IPv6. Check ``sa_family``. http://stackoverflow.com/a/9212542/492186 retFuture.complete( (address: $inet_ntoa(cast[ptr Sockaddr_in](remoteSockAddr).sin_addr), - client: clientSock.TAsyncFD) + client: clientSock.AsyncFD) ) template failAccept(errcode): stmt = @@ -824,8 +826,8 @@ when defined(windows) or defined(nimdoc): var ol = PCustomOverlapped() GC_ref(ol) - ol.data = TCompletionData(fd: socket, cb: - proc (fd: TAsyncFD, bytesCount: Dword, errcode: OSErrorCode) = + ol.data = CompletionData(fd: socket, cb: + proc (fd: AsyncFD, bytesCount: Dword, errcode: OSErrorCode) = if not retFuture.finished: if errcode == OSErrorCode(-1): completeAccept() @@ -853,26 +855,26 @@ when defined(windows) or defined(nimdoc): return retFuture - proc newAsyncRawSocket*(domain, typ, protocol: cint): TAsyncFD = + proc newAsyncRawSocket*(domain, typ, protocol: cint): AsyncFD = ## Creates a new socket and registers it with the dispatcher implicitly. - result = newRawSocket(domain, typ, protocol).TAsyncFD + result = newRawSocket(domain, typ, protocol).AsyncFD result.SocketHandle.setBlocking(false) register(result) proc newAsyncRawSocket*(domain: Domain = AF_INET, typ: SockType = SOCK_STREAM, - protocol: Protocol = IPPROTO_TCP): TAsyncFD = + protocol: Protocol = IPPROTO_TCP): AsyncFD = ## Creates a new socket and registers it with the dispatcher implicitly. - result = newRawSocket(domain, typ, protocol).TAsyncFD + result = newRawSocket(domain, typ, protocol).AsyncFD result.SocketHandle.setBlocking(false) register(result) - proc closeSocket*(socket: TAsyncFD) = + proc closeSocket*(socket: AsyncFD) = ## Closes a socket and ensures that it is unregistered. socket.SocketHandle.close() getGlobalDispatcher().handles.excl(socket) - proc unregister*(fd: TAsyncFD) = + proc unregister*(fd: AsyncFD) = ## Unregisters ``fd``. getGlobalDispatcher().handles.excl(fd) @@ -892,18 +894,19 @@ else: MSG_NOSIGNAL type - TAsyncFD* = distinct cint - TCallback = proc (fd: TAsyncFD): bool {.closure,gcsafe.} + AsyncFD* = distinct cint + Callback = proc (fd: AsyncFD): bool {.closure,gcsafe.} PData* = ref object of RootRef - fd: TAsyncFD - readCBs: seq[TCallback] - writeCBs: seq[TCallback] + fd: AsyncFD + readCBs: seq[Callback] + writeCBs: seq[Callback] PDispatcher* = ref object of PDispatcherBase selector: Selector + {.deprecated: [TAsyncFD: AsyncFD, TCallback: Callback].} - proc `==`*(x, y: TAsyncFD): bool {.borrow.} + proc `==`*(x, y: AsyncFD): bool {.borrow.} proc newDispatcher*(): PDispatcher = new result @@ -915,18 +918,18 @@ else: if gDisp.isNil: gDisp = newDispatcher() result = gDisp - proc update(fd: TAsyncFD, events: set[Event]) = + proc update(fd: AsyncFD, events: set[Event]) = let p = getGlobalDispatcher() assert fd.SocketHandle in p.selector discard p.selector.update(fd.SocketHandle, events) - proc register*(fd: TAsyncFD) = + proc register*(fd: AsyncFD) = let p = getGlobalDispatcher() var data = PData(fd: fd, readCBs: @[], writeCBs: @[]) p.selector.register(fd.SocketHandle, {}, data.RootRef) - proc newAsyncRawSocket*(domain: cint, typ: cint, protocol: cint): TAsyncFD = - result = newRawSocket(domain, typ, protocol).TAsyncFD + proc newAsyncRawSocket*(domain: cint, typ: cint, protocol: cint): AsyncFD = + result = newRawSocket(domain, typ, protocol).AsyncFD result.SocketHandle.setBlocking(false) when defined(macosx): result.SocketHandle.setSockOptInt(SOL_SOCKET, SO_NOSIGPIPE, 1) @@ -934,29 +937,29 @@ else: proc newAsyncRawSocket*(domain: Domain = AF_INET, typ: SockType = SOCK_STREAM, - protocol: Protocol = IPPROTO_TCP): TAsyncFD = - result = newRawSocket(domain, typ, protocol).TAsyncFD + protocol: Protocol = IPPROTO_TCP): AsyncFD = + result = newRawSocket(domain, typ, protocol).AsyncFD result.SocketHandle.setBlocking(false) when defined(macosx): result.SocketHandle.setSockOptInt(SOL_SOCKET, SO_NOSIGPIPE, 1) register(result) - proc closeSocket*(sock: TAsyncFD) = + proc closeSocket*(sock: AsyncFD) = let disp = getGlobalDispatcher() sock.SocketHandle.close() disp.selector.unregister(sock.SocketHandle) - proc unregister*(fd: TAsyncFD) = + proc unregister*(fd: AsyncFD) = getGlobalDispatcher().selector.unregister(fd.SocketHandle) - proc addRead*(fd: TAsyncFD, cb: TCallback) = + proc addRead*(fd: AsyncFD, cb: Callback) = let p = getGlobalDispatcher() if fd.SocketHandle notin p.selector: raise newException(ValueError, "File descriptor not registered.") p.selector[fd.SocketHandle].data.PData.readCBs.add(cb) update(fd, p.selector[fd.SocketHandle].events + {EvRead}) - proc addWrite*(fd: TAsyncFD, cb: TCallback) = + proc addWrite*(fd: AsyncFD, cb: Callback) = let p = getGlobalDispatcher() if fd.SocketHandle notin p.selector: raise newException(ValueError, "File descriptor not registered.") @@ -967,7 +970,7 @@ else: let p = getGlobalDispatcher() for info in p.selector.select(timeout): let data = PData(info.key.data) - assert data.fd == info.key.fd.TAsyncFD + assert data.fd == info.key.fd.AsyncFD #echo("In poll ", data.fd.cint) if EvError in info.events: closeSocket(data.fd) @@ -1005,11 +1008,11 @@ else: processTimers(p) - proc connect*(socket: TAsyncFD, address: string, port: Port, + proc connect*(socket: AsyncFD, address: string, port: Port, af = AF_INET): Future[void] = var retFuture = newFuture[void]("connect") - proc cb(fd: TAsyncFD): bool = + proc cb(fd: AsyncFD): bool = # We have connected. retFuture.complete() return true @@ -1040,13 +1043,13 @@ else: retFuture.fail(newException(OSError, osErrorMsg(lastError))) return retFuture - proc recv*(socket: TAsyncFD, size: int, + proc recv*(socket: AsyncFD, size: int, flags = {SocketFlag.SafeDisconn}): Future[string] = var retFuture = newFuture[string]("recv") var readBuffer = newString(size) - proc cb(sock: TAsyncFD): bool = + proc cb(sock: AsyncFD): bool = result = true let res = recv(sock.SocketHandle, addr readBuffer[0], size.cint, flags.toOSFlags()) @@ -1070,11 +1073,11 @@ else: addRead(socket, cb) return retFuture - proc recvInto*(socket: TAsyncFD, buf: cstring, size: int, + proc recvInto*(socket: AsyncFD, buf: cstring, size: int, flags = {SocketFlag.SafeDisconn}): Future[int] = var retFuture = newFuture[int]("recvInto") - proc cb(sock: TAsyncFD): bool = + proc cb(sock: AsyncFD): bool = result = true let res = recv(sock.SocketHandle, buf, size.cint, flags.toOSFlags()) @@ -1094,13 +1097,13 @@ else: addRead(socket, cb) return retFuture - proc send*(socket: TAsyncFD, data: string, + proc send*(socket: AsyncFD, data: string, flags = {SocketFlag.SafeDisconn}): Future[void] = var retFuture = newFuture[void]("send") var written = 0 - proc cb(sock: TAsyncFD): bool = + proc cb(sock: AsyncFD): bool = result = true let netSize = data.len-written var d = data.cstring @@ -1126,11 +1129,11 @@ else: addWrite(socket, cb) return retFuture - proc acceptAddr*(socket: TAsyncFD, flags = {SocketFlag.SafeDisconn}): - Future[tuple[address: string, client: TAsyncFD]] = + proc acceptAddr*(socket: AsyncFD, flags = {SocketFlag.SafeDisconn}): + Future[tuple[address: string, client: AsyncFD]] = var retFuture = newFuture[tuple[address: string, - client: TAsyncFD]]("acceptAddr") - proc cb(sock: TAsyncFD): bool = + client: AsyncFD]]("acceptAddr") + proc cb(sock: AsyncFD): bool = result = true var sockAddress: SockAddr_in var addrLen = sizeof(sockAddress).Socklen @@ -1147,28 +1150,28 @@ else: else: retFuture.fail(newException(OSError, osErrorMsg(lastError))) else: - register(client.TAsyncFD) - retFuture.complete(($inet_ntoa(sockAddress.sin_addr), client.TAsyncFD)) + register(client.AsyncFD) + retFuture.complete(($inet_ntoa(sockAddress.sin_addr), client.AsyncFD)) addRead(socket, cb) return retFuture proc sleepAsync*(ms: int): Future[void] = ## Suspends the execution of the current async procedure for the next - ## ``ms`` miliseconds. + ## ``ms`` milliseconds. var retFuture = newFuture[void]("sleepAsync") let p = getGlobalDispatcher() p.timers.add((epochTime() + (ms / 1000), retFuture)) return retFuture -proc accept*(socket: TAsyncFD, - flags = {SocketFlag.SafeDisconn}): Future[TAsyncFD] = +proc accept*(socket: AsyncFD, + flags = {SocketFlag.SafeDisconn}): Future[AsyncFD] = ## Accepts a new connection. Returns a future containing the client socket ## corresponding to that connection. ## The future will complete when the connection is successfully accepted. - var retFut = newFuture[TAsyncFD]("accept") + var retFut = newFuture[AsyncFD]("accept") var fut = acceptAddr(socket, flags) fut.callback = - proc (future: Future[tuple[address: string, client: TAsyncFD]]) = + proc (future: Future[tuple[address: string, client: AsyncFD]]) = assert future.finished if future.failed: retFut.fail(future.error) @@ -1328,7 +1331,7 @@ proc processBody(node, retFutureSym: NimNode, else: discard of nnkDiscardStmt: # discard await x - if node[0].kind != nnkEmpty and node[0][0].kind == nnkIdent and + if node[0].kind == nnkCommand and node[0][0].kind == nnkIdent and node[0][0].ident == !"await": var newDiscard = node result.createVar("futureDiscard_" & $toStrLit(node[0][1]), node[0][1], @@ -1495,7 +1498,7 @@ macro async*(prc: stmt): stmt {.immediate.} = #if prc[0].getName == "test": # echo(toStrLit(result)) -proc recvLine*(socket: TAsyncFD): Future[string] {.async.} = +proc recvLine*(socket: AsyncFD): Future[string] {.async.} = ## Reads a line of data from ``socket``. Returned future will complete once ## a full line is read or an error occurs. ## diff --git a/lib/pure/asyncfile.nim b/lib/pure/asyncfile.nim index 25e121183..ece9b4dfb 100644 --- a/lib/pure/asyncfile.nim +++ b/lib/pure/asyncfile.nim @@ -31,7 +31,7 @@ else: type AsyncFile* = ref object - fd: TAsyncFd + fd: AsyncFd offset: int64 when defined(windows) or defined(nimdoc): @@ -72,7 +72,7 @@ proc getFileSize(f: AsyncFile): int64 = ## Retrieves the specified file's size. when defined(windows) or defined(nimdoc): var high: DWord - let low = getFileSize(f.fd.THandle, addr high) + let low = getFileSize(f.fd.Handle, addr high) if low == INVALID_FILE_SIZE: raiseOSError(osLastError()) return (high shl 32) or low @@ -88,13 +88,13 @@ proc openAsync*(filename: string, mode = fmRead): AsyncFile = when useWinUnicode: result.fd = createFileW(newWideCString(filename), desiredAccess, FILE_SHARE_READ, - nil, creationDisposition, flags, 0).TAsyncFd + nil, creationDisposition, flags, 0).AsyncFd else: result.fd = createFileA(filename, desiredAccess, FILE_SHARE_READ, - nil, creationDisposition, flags, 0).TAsyncFd + nil, creationDisposition, flags, 0).AsyncFd - if result.fd.THandle == INVALID_HANDLE_VALUE: + if result.fd.Handle == INVALID_HANDLE_VALUE: raiseOSError(osLastError()) register(result.fd) @@ -106,7 +106,7 @@ proc openAsync*(filename: string, mode = fmRead): AsyncFile = let flags = getPosixFlags(mode) # RW (Owner), RW (Group), R (Other) let perm = S_IRUSR or S_IWUSR or S_IRGRP or S_IWGRP or S_IROTH - result.fd = open(filename, flags, perm).TAsyncFD + result.fd = open(filename, flags, perm).AsyncFD if result.fd.cint == -1: raiseOSError(osLastError()) @@ -125,8 +125,8 @@ proc read*(f: AsyncFile, size: int): Future[string] = var ol = PCustomOverlapped() GC_ref(ol) - ol.data = TCompletionData(fd: f.fd, cb: - proc (fd: TAsyncFD, bytesCount: Dword, errcode: OSErrorCode) = + ol.data = CompletionData(fd: f.fd, cb: + proc (fd: AsyncFD, bytesCount: Dword, errcode: OSErrorCode) = if not retFuture.finished: if errcode == OSErrorCode(-1): assert bytesCount > 0 @@ -148,7 +148,7 @@ proc read*(f: AsyncFile, size: int): Future[string] = ol.offsetHigh = DWord(f.offset shr 32) # According to MSDN we're supposed to pass nil to lpNumberOfBytesRead. - let ret = readFile(f.fd.THandle, buffer, size.int32, nil, + let ret = readFile(f.fd.Handle, buffer, size.int32, nil, cast[POVERLAPPED](ol)) if not ret.bool: let err = osLastError() @@ -161,7 +161,7 @@ proc read*(f: AsyncFile, size: int): Future[string] = else: # Request completed immediately. var bytesRead: DWord - let overlappedRes = getOverlappedResult(f.fd.THandle, + let overlappedRes = getOverlappedResult(f.fd.Handle, cast[POverlapped](ol)[], bytesRead, false.WinBool) if not overlappedRes.bool: let err = osLastError() @@ -179,7 +179,7 @@ proc read*(f: AsyncFile, size: int): Future[string] = else: var readBuffer = newString(size) - proc cb(fd: TAsyncFD): bool = + proc cb(fd: AsyncFD): bool = result = true let res = read(fd.cint, addr readBuffer[0], size.cint) if res < 0: @@ -251,8 +251,8 @@ proc write*(f: AsyncFile, data: string): Future[void] = var ol = PCustomOverlapped() GC_ref(ol) - ol.data = TCompletionData(fd: f.fd, cb: - proc (fd: TAsyncFD, bytesCount: DWord, errcode: OSErrorCode) = + ol.data = CompletionData(fd: f.fd, cb: + proc (fd: AsyncFD, bytesCount: DWord, errcode: OSErrorCode) = if not retFuture.finished: if errcode == OSErrorCode(-1): assert bytesCount == data.len.int32 @@ -268,7 +268,7 @@ proc write*(f: AsyncFile, data: string): Future[void] = ol.offsetHigh = DWord(f.offset shr 32) # According to MSDN we're supposed to pass nil to lpNumberOfBytesWritten. - let ret = writeFile(f.fd.THandle, buffer, data.len.int32, nil, + let ret = writeFile(f.fd.Handle, buffer, data.len.int32, nil, cast[POVERLAPPED](ol)) if not ret.bool: let err = osLastError() @@ -281,7 +281,7 @@ proc write*(f: AsyncFile, data: string): Future[void] = else: # Request completed immediately. var bytesWritten: DWord - let overlappedRes = getOverlappedResult(f.fd.THandle, + let overlappedRes = getOverlappedResult(f.fd.Handle, cast[POverlapped](ol)[], bytesWritten, false.WinBool) if not overlappedRes.bool: retFuture.fail(newException(OSError, osErrorMsg(osLastError()))) @@ -292,7 +292,7 @@ proc write*(f: AsyncFile, data: string): Future[void] = else: var written = 0 - proc cb(fd: TAsyncFD): bool = + proc cb(fd: AsyncFD): bool = result = true let remainderSize = data.len-written let res = write(fd.cint, addr copy[written], remainderSize.cint) @@ -317,7 +317,7 @@ proc write*(f: AsyncFile, data: string): Future[void] = proc close*(f: AsyncFile) = ## Closes the file specified. when defined(windows) or defined(nimdoc): - if not closeHandle(f.fd.THandle).bool: + if not closeHandle(f.fd.Handle).bool: raiseOSError(osLastError()) else: if close(f.fd.cint) == -1: diff --git a/lib/pure/asynchttpserver.nim b/lib/pure/asynchttpserver.nim index 279cedb5d..9e036443c 100644 --- a/lib/pure/asynchttpserver.nim +++ b/lib/pure/asynchttpserver.nim @@ -210,6 +210,7 @@ proc processClient(client: AsyncSocket, address: string, var contentLength = 0 if parseInt(request.headers["Content-Length"], contentLength) == 0: await request.respond(Http400, "Bad Request. Invalid Content-Length.") + continue else: request.body = await client.recv(contentLength) assert request.body.len == contentLength diff --git a/lib/pure/asyncio.nim b/lib/pure/asyncio.nim index 6ae2c608b..5fd45b215 100644 --- a/lib/pure/asyncio.nim +++ b/lib/pure/asyncio.nim @@ -188,8 +188,8 @@ proc asyncSocket*(domain: Domain = AF_INET, typ: SockType = SOCK_STREAM, result.socket.setBlocking(false) proc toAsyncSocket*(sock: Socket, state: SocketStatus = SockConnected): AsyncSocket = - ## Wraps an already initialized ``TSocket`` into a AsyncSocket. - ## This is useful if you want to use an already connected TSocket as an + ## Wraps an already initialized ``Socket`` into a AsyncSocket. + ## This is useful if you want to use an already connected Socket as an ## asynchronous AsyncSocket in asyncio's event loop. ## ## ``state`` may be overriden, i.e. if ``sock`` is not connected it should be diff --git a/lib/pure/asyncnet.nim b/lib/pure/asyncnet.nim index aadbde824..01c28a13a 100644 --- a/lib/pure/asyncnet.nim +++ b/lib/pure/asyncnet.nim @@ -91,13 +91,13 @@ type # TODO: Save AF, domain etc info and reuse it in procs which need it like connect. -proc newAsyncSocket*(fd: TAsyncFD, isBuff: bool): AsyncSocket = +proc newAsyncSocket*(fd: AsyncFD, buffered = true): AsyncSocket = ## Creates a new ``AsyncSocket`` based on the supplied params. - assert fd != osInvalidSocket.TAsyncFD + assert fd != osInvalidSocket.AsyncFD new(result) result.fd = fd.SocketHandle - result.isBuffered = isBuff - if isBuff: + result.isBuffered = buffered + if buffered: result.currPos = 0 proc newAsyncSocket*(domain: Domain = AF_INET, typ: SockType = SOCK_STREAM, @@ -142,7 +142,7 @@ when defined(ssl): if read < 0: raiseSslError() data.setLen(read) - await socket.fd.TAsyncFd.send(data, flags) + await socket.fd.AsyncFd.send(data, flags) proc appeaseSsl(socket: AsyncSocket, flags: set[SocketFlag], sslError: cint) {.async.} = @@ -150,7 +150,7 @@ when defined(ssl): of SSL_ERROR_WANT_WRITE: await sendPendingSslData(socket, flags) of SSL_ERROR_WANT_READ: - var data = await recv(socket.fd.TAsyncFD, BufferSize, flags) + var data = await recv(socket.fd.AsyncFD, BufferSize, flags) let ret = bioWrite(socket.bioIn, addr data[0], data.len.cint) if ret < 0: raiseSSLError() @@ -175,7 +175,7 @@ proc connect*(socket: AsyncSocket, address: string, port: Port, ## ## Returns a ``Future`` which will complete when the connection succeeds ## or an error occurs. - await connect(socket.fd.TAsyncFD, address, port, af) + await connect(socket.fd.AsyncFD, address, port, af) if socket.isSsl: when defined(ssl): let flags = {SocketFlag.SafeDisconn} @@ -194,7 +194,7 @@ template readInto(buf: cstring, size: int, socket: AsyncSocket, sslRead(socket.sslHandle, buf, size.cint)) res = opResult else: - var recvIntoFut = recvInto(socket.fd.TAsyncFD, buf, size, flags) + var recvIntoFut = recvInto(socket.fd.AsyncFD, buf, size, flags) yield recvIntoFut # Not in SSL mode. res = recvIntoFut.read() @@ -271,7 +271,7 @@ proc send*(socket: AsyncSocket, data: string, sslWrite(socket.sslHandle, addr copy[0], copy.len.cint)) await sendPendingSslData(socket, flags) else: - await send(socket.fd.TAsyncFD, data, flags) + await send(socket.fd.AsyncFD, data, flags) proc acceptAddr*(socket: AsyncSocket, flags = {SocketFlag.SafeDisconn}): Future[tuple[address: string, client: AsyncSocket]] = @@ -279,9 +279,9 @@ proc acceptAddr*(socket: AsyncSocket, flags = {SocketFlag.SafeDisconn}): ## corresponding to that connection and the remote address of the client. ## The future will complete when the connection is successfully accepted. var retFuture = newFuture[tuple[address: string, client: AsyncSocket]]("asyncnet.acceptAddr") - var fut = acceptAddr(socket.fd.TAsyncFD, flags) + var fut = acceptAddr(socket.fd.AsyncFD, flags) fut.callback = - proc (future: Future[tuple[address: string, client: TAsyncFD]]) = + proc (future: Future[tuple[address: string, client: AsyncFD]]) = assert future.finished if future.failed: retFuture.fail(future.readError) @@ -445,7 +445,7 @@ proc bindAddr*(socket: AsyncSocket, port = Port(0), address = "") {. proc close*(socket: AsyncSocket) = ## Closes the socket. defer: - socket.fd.TAsyncFD.closeSocket() + socket.fd.AsyncFD.closeSocket() when defined(ssl): if socket.isSSL: let res = SslShutdown(socket.sslHandle) diff --git a/lib/pure/basic2d.nim b/lib/pure/basic2d.nim index a344cd053..d18e73c16 100644 --- a/lib/pure/basic2d.nim +++ b/lib/pure/basic2d.nim @@ -20,20 +20,20 @@ import strutils ## ## # Create a matrix which first rotates, then scales and at last translates ## -## var m:TMatrix2d=rotate(DEG90) & scale(2.0) & move(100.0,200.0) +## var m:Matrix2d=rotate(DEG90) & scale(2.0) & move(100.0,200.0) ## ## # Create a 2d point at (100,0) and a vector (5,2) ## -## var pt:TPoint2d=point2d(100.0,0.0) +## var pt:Point2d=point2d(100.0,0.0) ## -## var vec:TVector2d=vector2d(5.0,2.0) +## var vec:Vector2d=vector2d(5.0,2.0) ## ## ## pt &= m # transforms pt in place ## -## var pt2:TPoint2d=pt & m #concatenates pt with m and returns a new point +## var pt2:Point2d=pt & m #concatenates pt with m and returns a new point ## -## var vec2:TVector2d=vec & m #concatenates vec with m and returns a new vector +## var vec2:Vector2d=vec & m #concatenates vec with m and returns a new vector const @@ -57,46 +57,46 @@ const ## used internally by DegToRad and RadToDeg type - TMatrix2d* = object + Matrix2d* = object ## Implements a row major 2d matrix, which means ## transformations are applied the order they are concatenated. ## The rightmost column of the 3x3 matrix is left out since normally ## not used for geometric transformations in 2d. ax*,ay*,bx*,by*,tx*,ty*:float - TPoint2d* = object + Point2d* = object ## Implements a non-homegeneous 2d point stored as ## an `x` coordinate and an `y` coordinate. x*,y*:float - TVector2d* = object + Vector2d* = object ## Implements a 2d **direction vector** stored as ## an `x` coordinate and an `y` coordinate. Direction vector means, ## that when transforming a vector with a matrix, the translational ## part of the matrix is ignored. x*,y*:float - +{.deprecated: [TMatrix2d: Matrix2d, TPoint2d: Point2d, TVector2d: Vector2d].} # Some forward declarations... -proc matrix2d*(ax,ay,bx,by,tx,ty:float):TMatrix2d {.noInit.} +proc matrix2d*(ax,ay,bx,by,tx,ty:float):Matrix2d {.noInit.} ## Creates a new matrix. ## `ax`,`ay` is the local x axis ## `bx`,`by` is the local y axis ## `tx`,`ty` is the translation -proc vector2d*(x,y:float):TVector2d {.noInit,inline.} +proc vector2d*(x,y:float):Vector2d {.noInit,inline.} ## Returns a new vector (`x`,`y`) -proc point2d*(x,y:float):TPoint2d {.noInit,inline.} +proc point2d*(x,y:float):Point2d {.noInit,inline.} ## Returns a new point (`x`,`y`) let - IDMATRIX*:TMatrix2d=matrix2d(1.0,0.0,0.0,1.0,0.0,0.0) + IDMATRIX*:Matrix2d=matrix2d(1.0,0.0,0.0,1.0,0.0,0.0) ## Quick access to an identity matrix - ORIGO*:TPoint2d=point2d(0.0,0.0) + ORIGO*:Point2d=point2d(0.0,0.0) ## Quick acces to point (0,0) - XAXIS*:TVector2d=vector2d(1.0,0.0) + XAXIS*:Vector2d=vector2d(1.0,0.0) ## Quick acces to an 2d x-axis unit vector - YAXIS*:TVector2d=vector2d(0.0,1.0) + YAXIS*:Vector2d=vector2d(0.0,1.0) ## Quick acces to an 2d y-axis unit vector @@ -116,21 +116,21 @@ proc safeArccos(v:float):float= template makeBinOpVector(s:expr)= ## implements binary operators + , - , * and / for vectors - proc s*(a,b:TVector2d):TVector2d {.inline,noInit.} = vector2d(s(a.x,b.x),s(a.y,b.y)) - proc s*(a:TVector2d,b:float):TVector2d {.inline,noInit.} = vector2d(s(a.x,b),s(a.y,b)) - proc s*(a:float,b:TVector2d):TVector2d {.inline,noInit.} = vector2d(s(a,b.x),s(a,b.y)) + proc s*(a,b:Vector2d):Vector2d {.inline,noInit.} = vector2d(s(a.x,b.x),s(a.y,b.y)) + proc s*(a:Vector2d,b:float):Vector2d {.inline,noInit.} = vector2d(s(a.x,b),s(a.y,b)) + proc s*(a:float,b:Vector2d):Vector2d {.inline,noInit.} = vector2d(s(a,b.x),s(a,b.y)) template makeBinOpAssignVector(s:expr)= ## implements inplace binary operators += , -= , /= and *= for vectors - proc s*(a:var TVector2d,b:TVector2d) {.inline.} = s(a.x,b.x) ; s(a.y,b.y) - proc s*(a:var TVector2d,b:float) {.inline.} = s(a.x,b) ; s(a.y,b) + proc s*(a:var Vector2d,b:Vector2d) {.inline.} = s(a.x,b.x) ; s(a.y,b.y) + proc s*(a:var Vector2d,b:float) {.inline.} = s(a.x,b) ; s(a.y,b) # *************************************** -# TMatrix2d implementation +# Matrix2d implementation # *************************************** -proc setElements*(t:var TMatrix2d,ax,ay,bx,by,tx,ty:float) {.inline.}= +proc setElements*(t:var Matrix2d,ax,ay,bx,by,tx,ty:float) {.inline.}= ## Sets arbitrary elements in an existing matrix. t.ax=ax t.ay=ay @@ -139,10 +139,10 @@ proc setElements*(t:var TMatrix2d,ax,ay,bx,by,tx,ty:float) {.inline.}= t.tx=tx t.ty=ty -proc matrix2d*(ax,ay,bx,by,tx,ty:float):TMatrix2d = +proc matrix2d*(ax,ay,bx,by,tx,ty:float):Matrix2d = result.setElements(ax,ay,bx,by,tx,ty) -proc `&`*(a,b:TMatrix2d):TMatrix2d {.noInit.} = #concatenate matrices +proc `&`*(a,b:Matrix2d):Matrix2d {.noInit.} = #concatenate matrices ## Concatenates matrices returning a new matrix. # | a.AX a.AY 0 | | b.AX b.AY 0 | @@ -157,34 +157,34 @@ proc `&`*(a,b:TMatrix2d):TMatrix2d {.noInit.} = #concatenate matrices a.tx * b.ay + a.ty * b.by + b.ty) -proc scale*(s:float):TMatrix2d {.noInit.} = +proc scale*(s:float):Matrix2d {.noInit.} = ## Returns a new scale matrix. result.setElements(s,0,0,s,0,0) -proc scale*(s:float,org:TPoint2d):TMatrix2d {.noInit.} = +proc scale*(s:float,org:Point2d):Matrix2d {.noInit.} = ## Returns a new scale matrix using, `org` as scale origin. result.setElements(s,0,0,s,org.x-s*org.x,org.y-s*org.y) -proc stretch*(sx,sy:float):TMatrix2d {.noInit.} = +proc stretch*(sx,sy:float):Matrix2d {.noInit.} = ## Returns new a stretch matrix, which is a ## scale matrix with non uniform scale in x and y. result.setElements(sx,0,0,sy,0,0) -proc stretch*(sx,sy:float,org:TPoint2d):TMatrix2d {.noInit.} = +proc stretch*(sx,sy:float,org:Point2d):Matrix2d {.noInit.} = ## Returns a new stretch matrix, which is a ## scale matrix with non uniform scale in x and y. ## `org` is used as stretch origin. result.setElements(sx,0,0,sy,org.x-sx*org.x,org.y-sy*org.y) -proc move*(dx,dy:float):TMatrix2d {.noInit.} = +proc move*(dx,dy:float):Matrix2d {.noInit.} = ## Returns a new translation matrix. result.setElements(1,0,0,1,dx,dy) -proc move*(v:TVector2d):TMatrix2d {.noInit.} = +proc move*(v:Vector2d):Matrix2d {.noInit.} = ## Returns a new translation matrix from a vector. result.setElements(1,0,0,1,v.x,v.y) -proc rotate*(rad:float):TMatrix2d {.noInit.} = +proc rotate*(rad:float):Matrix2d {.noInit.} = ## Returns a new rotation matrix, which ## represents a rotation by `rad` radians let @@ -192,7 +192,7 @@ proc rotate*(rad:float):TMatrix2d {.noInit.} = c=cos(rad) result.setElements(c,s,-s,c,0,0) -proc rotate*(rad:float,org:TPoint2d):TMatrix2d {.noInit.} = +proc rotate*(rad:float,org:Point2d):Matrix2d {.noInit.} = ## Returns a new rotation matrix, which ## represents a rotation by `rad` radians around ## the origin `org` @@ -201,7 +201,7 @@ proc rotate*(rad:float,org:TPoint2d):TMatrix2d {.noInit.} = c=cos(rad) result.setElements(c,s,-s,c,org.x+s*org.y-c*org.x,org.y-c*org.y-s*org.x) -proc mirror*(v:TVector2d):TMatrix2d {.noInit.} = +proc mirror*(v:Vector2d):Matrix2d {.noInit.} = ## Returns a new mirror matrix, mirroring ## around the line that passes through origo and ## has the direction of `v` @@ -220,7 +220,7 @@ proc mirror*(v:TVector2d):TMatrix2d {.noInit.} = xy2,-sqd, 0.0,0.0) -proc mirror*(org:TPoint2d,v:TVector2d):TMatrix2d {.noInit.} = +proc mirror*(org:Point2d,v:Vector2d):Matrix2d {.noInit.} = ## Returns a new mirror matrix, mirroring ## around the line that passes through `org` and ## has the direction of `v` @@ -241,20 +241,20 @@ proc mirror*(org:TPoint2d,v:TVector2d):TMatrix2d {.noInit.} = -proc skew*(xskew,yskew:float):TMatrix2d {.noInit.} = +proc skew*(xskew,yskew:float):Matrix2d {.noInit.} = ## Returns a new skew matrix, which has its ## x axis rotated `xskew` radians from the local x axis, and ## y axis rotated `yskew` radians from the local y axis result.setElements(cos(yskew),sin(yskew),-sin(xskew),cos(xskew),0,0) -proc `$`* (t:TMatrix2d):string {.noInit.} = +proc `$`* (t:Matrix2d):string {.noInit.} = ## Returns a string representation of the matrix return rtos(t.ax) & "," & rtos(t.ay) & "," & rtos(t.bx) & "," & rtos(t.by) & "," & rtos(t.tx) & "," & rtos(t.ty) -proc isUniform*(t:TMatrix2d,tol=1.0e-6):bool= +proc isUniform*(t:Matrix2d,tol=1.0e-6):bool= ## Checks if the transform is uniform, that is ## perpendicular axes of equal length, which means (for example) ## it cannot transform a circle into an ellipse. @@ -268,18 +268,18 @@ proc isUniform*(t:TMatrix2d,tol=1.0e-6):bool= return true return false -proc determinant*(t:TMatrix2d):float= +proc determinant*(t:Matrix2d):float= ## Computes the determinant of the matrix. #NOTE: equivalent with perp.dot product for two 2d vectors return t.ax*t.by-t.bx*t.ay -proc isMirroring* (m:TMatrix2d):bool= +proc isMirroring* (m:Matrix2d):bool= ## Checks if the `m` is a mirroring matrix, ## which means it will reverse direction of a curve transformed with it return m.determinant<0.0 -proc inverse*(m:TMatrix2d):TMatrix2d {.noInit.} = +proc inverse*(m:Matrix2d):Matrix2d {.noInit.} = ## Returns a new matrix, which is the inverse of the matrix ## If the matrix is not invertible (determinant=0), an EDivByZero ## will be raised. @@ -293,7 +293,7 @@ proc inverse*(m:TMatrix2d):TMatrix2d {.noInit.} = (m.bx*m.ty-m.by*m.tx)/d, (m.ay*m.tx-m.ax*m.ty)/d) -proc equals*(m1:TMatrix2d,m2:TMatrix2d,tol=1.0e-6):bool= +proc equals*(m1:Matrix2d,m2:Matrix2d,tol=1.0e-6):bool= ## Checks if all elements of `m1`and `m2` is equal within ## a given tolerance `tol`. return @@ -304,17 +304,17 @@ proc equals*(m1:TMatrix2d,m2:TMatrix2d,tol=1.0e-6):bool= abs(m1.tx-m2.tx)<=tol and abs(m1.ty-m2.ty)<=tol -proc `=~`*(m1,m2:TMatrix2d):bool= +proc `=~`*(m1,m2:Matrix2d):bool= ## Checks if `m1`and `m2` is approximately equal, using a ## tolerance of 1e-6. equals(m1,m2) -proc isIdentity*(m:TMatrix2d,tol=1.0e-6):bool= +proc isIdentity*(m:Matrix2d,tol=1.0e-6):bool= ## Checks is a matrix is approximately an identity matrix, ## using `tol` as tolerance for each element. return equals(m,IDMATRIX,tol) -proc apply*(m:TMatrix2d,x,y:var float,translate=false)= +proc apply*(m:Matrix2d,x,y:var float,translate=false)= ## Applies transformation `m` onto `x`,`y`, optionally ## using the translation part of the matrix. if translate: # positional style transform @@ -329,29 +329,29 @@ proc apply*(m:TMatrix2d,x,y:var float,translate=false)= # *************************************** -# TVector2d implementation +# Vector2d implementation # *************************************** -proc vector2d*(x,y:float):TVector2d = #forward decl. +proc vector2d*(x,y:float):Vector2d = #forward decl. result.x=x result.y=y -proc polarVector2d*(ang:float,len:float):TVector2d {.noInit.} = +proc polarVector2d*(ang:float,len:float):Vector2d {.noInit.} = ## Returns a new vector with angle `ang` and magnitude `len` result.x=cos(ang)*len result.y=sin(ang)*len -proc slopeVector2d*(slope:float,len:float):TVector2d {.noInit.} = +proc slopeVector2d*(slope:float,len:float):Vector2d {.noInit.} = ## Returns a new vector having slope (dy/dx) given by ## `slope`, and a magnitude of `len` let ang=arctan(slope) result.x=cos(ang)*len result.y=sin(ang)*len -proc len*(v:TVector2d):float {.inline.}= +proc len*(v:Vector2d):float {.inline.}= ## Returns the length of the vector. sqrt(v.x*v.x+v.y*v.y) -proc `len=`*(v:var TVector2d,newlen:float) {.noInit.} = +proc `len=`*(v:var Vector2d,newlen:float) {.noInit.} = ## Sets the length of the vector, keeping its angle. let fac=newlen/v.len @@ -369,25 +369,25 @@ proc `len=`*(v:var TVector2d,newlen:float) {.noInit.} = v.x*=fac v.y*=fac -proc sqrLen*(v:TVector2d):float {.inline.}= +proc sqrLen*(v:Vector2d):float {.inline.}= ## Computes the squared length of the vector, which is ## faster than computing the absolute length. v.x*v.x+v.y*v.y -proc angle*(v:TVector2d):float= +proc angle*(v:Vector2d):float= ## Returns the angle of the vector. ## (The counter clockwise plane angle between posetive x axis and `v`) result=arctan2(v.y,v.x) if result<0.0: result+=DEG360 -proc `$` *(v:TVector2d):string= +proc `$` *(v:Vector2d):string= ## String representation of `v` result=rtos(v.x) result.add(",") result.add(rtos(v.y)) -proc `&` *(v:TVector2d,m:TMatrix2d):TVector2d {.noInit.} = +proc `&` *(v:Vector2d,m:Matrix2d):Vector2d {.noInit.} = ## Concatenate vector `v` with a transformation matrix. ## Transforming a vector ignores the translational part ## of the matrix. @@ -399,7 +399,7 @@ proc `&` *(v:TVector2d,m:TMatrix2d):TVector2d {.noInit.} = result.y=v.x*m.ay+v.y*m.by -proc `&=`*(v:var TVector2d,m:TMatrix2d) {.inline.}= +proc `&=`*(v:var Vector2d,m:Matrix2d) {.inline.}= ## Applies transformation `m` onto `v` in place. ## Transforming a vector ignores the translational part ## of the matrix. @@ -412,7 +412,7 @@ proc `&=`*(v:var TVector2d,m:TMatrix2d) {.inline.}= v.x=newx -proc tryNormalize*(v:var TVector2d):bool= +proc tryNormalize*(v:var Vector2d):bool= ## Modifies `v` to have a length of 1.0, keeping its angle. ## If `v` has zero length (and thus no angle), it is left unmodified and ## false is returned, otherwise true is returned. @@ -427,13 +427,13 @@ proc tryNormalize*(v:var TVector2d):bool= return true -proc normalize*(v:var TVector2d) {.inline.}= +proc normalize*(v:var Vector2d) {.inline.}= ## Modifies `v` to have a length of 1.0, keeping its angle. ## If `v` has zero length, an EDivByZero will be raised. if not tryNormalize(v): raise newException(DivByZeroError,"Cannot normalize zero length vector") -proc transformNorm*(v:var TVector2d,t:TMatrix2d)= +proc transformNorm*(v:var Vector2d,t:Matrix2d)= ## Applies a normal direction transformation `t` onto `v` in place. ## The resulting vector is *not* normalized. Transforming a vector ignores the ## translational part of the matrix. If the matrix is not invertible @@ -452,7 +452,7 @@ proc transformNorm*(v:var TVector2d,t:TMatrix2d)= v.y = (t.ax*v.y-t.bx*v.x)/d v.x = newx -proc transformInv*(v:var TVector2d,t:TMatrix2d)= +proc transformInv*(v:var Vector2d,t:Matrix2d)= ## Applies inverse of a transformation `t` to `v` in place. ## This is faster than creating an inverse matrix and apply() it. ## Transforming a vector ignores the translational part @@ -467,7 +467,7 @@ proc transformInv*(v:var TVector2d,t:TMatrix2d)= v.y = (t.ax*v.y-t.ay*v.x)/d v.x = newx -proc transformNormInv*(v:var TVector2d,t:TMatrix2d)= +proc transformNormInv*(v:var Vector2d,t:Matrix2d)= ## Applies an inverse normal direction transformation `t` onto `v` in place. ## This is faster than creating an inverse ## matrix and transformNorm(...) it. Transforming a vector ignores the @@ -484,25 +484,25 @@ proc transformNormInv*(v:var TVector2d,t:TMatrix2d)= v.y=t.by*v.y+t.bx*v.x v.x=newx -proc rotate90*(v:var TVector2d) {.inline.}= +proc rotate90*(v:var Vector2d) {.inline.}= ## Quickly rotates vector `v` 90 degrees counter clockwise, ## without using any trigonometrics. swap(v.x,v.y) v.x= -v.x -proc rotate180*(v:var TVector2d){.inline.}= +proc rotate180*(v:var Vector2d){.inline.}= ## Quickly rotates vector `v` 180 degrees counter clockwise, ## without using any trigonometrics. v.x= -v.x v.y= -v.y -proc rotate270*(v:var TVector2d) {.inline.}= +proc rotate270*(v:var Vector2d) {.inline.}= ## Quickly rotates vector `v` 270 degrees counter clockwise, ## without using any trigonometrics. swap(v.x,v.y) v.y= -v.y -proc rotate*(v:var TVector2d,rad:float) = +proc rotate*(v:var Vector2d,rad:float) = ## Rotates vector `v` `rad` radians in place. let s=sin(rad) @@ -511,18 +511,18 @@ proc rotate*(v:var TVector2d,rad:float) = v.y=c*v.y+s*v.x v.x=newx -proc scale*(v:var TVector2d,fac:float){.inline.}= +proc scale*(v:var Vector2d,fac:float){.inline.}= ## Scales vector `v` `rad` radians in place. v.x*=fac v.y*=fac -proc stretch*(v:var TVector2d,facx,facy:float){.inline.}= +proc stretch*(v:var Vector2d,facx,facy:float){.inline.}= ## Stretches vector `v` `facx` times horizontally, ## and `facy` times vertically. v.x*=facx v.y*=facy -proc mirror*(v:var TVector2d,mirrvec:TVector2d)= +proc mirror*(v:var Vector2d,mirrvec:Vector2d)= ## Mirrors vector `v` using `mirrvec` as mirror direction. let sqx=mirrvec.x*mirrvec.x @@ -539,7 +539,7 @@ proc mirror*(v:var TVector2d,mirrvec:TVector2d)= v.x=newx -proc `-` *(v:TVector2d):TVector2d= +proc `-` *(v:Vector2d):Vector2d= ## Negates a vector result.x= -v.x result.y= -v.y @@ -555,27 +555,27 @@ makeBinOpAssignVector(`*=`) makeBinOpAssignVector(`/=`) -proc dot*(v1,v2:TVector2d):float= +proc dot*(v1,v2:Vector2d):float= ## Computes the dot product of two vectors. ## Returns 0.0 if the vectors are perpendicular. return v1.x*v2.x+v1.y*v2.y -proc cross*(v1,v2:TVector2d):float= +proc cross*(v1,v2:Vector2d):float= ## Computes the cross product of two vectors, also called ## the 'perpendicular dot product' in 2d. Returns 0.0 if the vectors ## are parallel. return v1.x*v2.y-v1.y*v2.x -proc equals*(v1,v2:TVector2d,tol=1.0e-6):bool= +proc equals*(v1,v2:Vector2d,tol=1.0e-6):bool= ## Checks if two vectors approximately equals with a tolerance. return abs(v2.x-v1.x)<=tol and abs(v2.y-v1.y)<=tol -proc `=~` *(v1,v2:TVector2d):bool= +proc `=~` *(v1,v2:Vector2d):bool= ## Checks if two vectors approximately equals with a ## hardcoded tolerance 1e-6 equals(v1,v2) -proc angleTo*(v1,v2:TVector2d):float= +proc angleTo*(v1,v2:Vector2d):float= ## Returns the smallest of the two possible angles ## between `v1` and `v2` in radians. var @@ -585,7 +585,7 @@ proc angleTo*(v1,v2:TVector2d):float= return 0.0 # zero length vector has zero angle to any other vector return safeArccos(dot(nv1,nv2)) -proc angleCCW*(v1,v2:TVector2d):float= +proc angleCCW*(v1,v2:Vector2d):float= ## Returns the counter clockwise plane angle from `v1` to `v2`, ## in range 0 - 2*PI let a=v1.angleTo(v2) @@ -593,7 +593,7 @@ proc angleCCW*(v1,v2:TVector2d):float= return a return DEG360-a -proc angleCW*(v1,v2:TVector2d):float= +proc angleCW*(v1,v2:Vector2d):float= ## Returns the clockwise plane angle from `v1` to `v2`, ## in range 0 - 2*PI let a=v1.angleTo(v2) @@ -601,7 +601,7 @@ proc angleCW*(v1,v2:TVector2d):float= return a return DEG360-a -proc turnAngle*(v1,v2:TVector2d):float= +proc turnAngle*(v1,v2:Vector2d):float= ## Returns the amount v1 should be rotated (in radians) to equal v2, ## in range -PI to PI let a=v1.angleTo(v2) @@ -609,7 +609,7 @@ proc turnAngle*(v1,v2:TVector2d):float= return -a return a -proc bisect*(v1,v2:TVector2d):TVector2d {.noInit.}= +proc bisect*(v1,v2:Vector2d):Vector2d {.noInit.}= ## Computes the bisector between v1 and v2 as a normalized vector. ## If one of the input vectors has zero length, a normalized version ## of the other is returned. If both input vectors has zero length, @@ -645,24 +645,24 @@ proc bisect*(v1,v2:TVector2d):TVector2d {.noInit.}= # *************************************** -# TPoint2d implementation +# Point2d implementation # *************************************** -proc point2d*(x,y:float):TPoint2d = +proc point2d*(x,y:float):Point2d = result.x=x result.y=y -proc sqrDist*(a,b:TPoint2d):float= +proc sqrDist*(a,b:Point2d):float= ## Computes the squared distance between `a` and `b` let dx=b.x-a.x let dy=b.y-a.y result=dx*dx+dy*dy -proc dist*(a,b:TPoint2d):float {.inline.}= +proc dist*(a,b:Point2d):float {.inline.}= ## Computes the absolute distance between `a` and `b` result=sqrt(sqrDist(a,b)) -proc angle*(a,b:TPoint2d):float= +proc angle*(a,b:Point2d):float= ## Computes the angle of the vector `b`-`a` let dx=b.x-a.x let dy=b.y-a.y @@ -670,13 +670,13 @@ proc angle*(a,b:TPoint2d):float= if result<0: result += DEG360 -proc `$` *(p:TPoint2d):string= +proc `$` *(p:Point2d):string= ## String representation of `p` result=rtos(p.x) result.add(",") result.add(rtos(p.y)) -proc `&`*(p:TPoint2d,t:TMatrix2d):TPoint2d {.noInit,inline.} = +proc `&`*(p:Point2d,t:Matrix2d):Point2d {.noInit,inline.} = ## Concatenates a point `p` with a transform `t`, ## resulting in a new, transformed point. @@ -686,14 +686,14 @@ proc `&`*(p:TPoint2d,t:TMatrix2d):TPoint2d {.noInit,inline.} = result.x=p.x*t.ax+p.y*t.bx+t.tx result.y=p.x*t.ay+p.y*t.by+t.ty -proc `&=` *(p:var TPoint2d,t:TMatrix2d) {.inline.}= +proc `&=` *(p:var Point2d,t:Matrix2d) {.inline.}= ## Applies transformation `t` onto `p` in place. let newx=p.x*t.ax+p.y*t.bx+t.tx p.y=p.x*t.ay+p.y*t.by+t.ty p.x=newx -proc transformInv*(p:var TPoint2d,t:TMatrix2d){.inline.}= +proc transformInv*(p:var Point2d,t:Matrix2d){.inline.}= ## Applies the inverse of transformation `t` onto `p` in place. ## If the matrix is not invertable (determinant=0) , EDivByZero will ## be raised. @@ -710,48 +710,48 @@ proc transformInv*(p:var TPoint2d,t:TMatrix2d){.inline.}= p.x=newx -proc `+`*(p:TPoint2d,v:TVector2d):TPoint2d {.noInit,inline.} = +proc `+`*(p:Point2d,v:Vector2d):Point2d {.noInit,inline.} = ## Adds a vector `v` to a point `p`, resulting ## in a new point. result.x=p.x+v.x result.y=p.y+v.y -proc `+=`*(p:var TPoint2d,v:TVector2d) {.noInit,inline.} = +proc `+=`*(p:var Point2d,v:Vector2d) {.noInit,inline.} = ## Adds a vector `v` to a point `p` in place. p.x+=v.x p.y+=v.y -proc `-`*(p:TPoint2d,v:TVector2d):TPoint2d {.noInit,inline.} = +proc `-`*(p:Point2d,v:Vector2d):Point2d {.noInit,inline.} = ## Subtracts a vector `v` from a point `p`, resulting ## in a new point. result.x=p.x-v.x result.y=p.y-v.y -proc `-`*(p1,p2:TPoint2d):TVector2d {.noInit,inline.} = +proc `-`*(p1,p2:Point2d):Vector2d {.noInit,inline.} = ## Subtracts `p2`from `p1` resulting in a difference vector. result.x=p1.x-p2.x result.y=p1.y-p2.y -proc `-=`*(p:var TPoint2d,v:TVector2d) {.noInit,inline.} = +proc `-=`*(p:var Point2d,v:Vector2d) {.noInit,inline.} = ## Subtracts a vector `v` from a point `p` in place. p.x-=v.x p.y-=v.y -proc equals(p1,p2:TPoint2d,tol=1.0e-6):bool {.inline.}= +proc equals(p1,p2:Point2d,tol=1.0e-6):bool {.inline.}= ## Checks if two points approximately equals with a tolerance. return abs(p2.x-p1.x)<=tol and abs(p2.y-p1.y)<=tol -proc `=~`*(p1,p2:TPoint2d):bool {.inline.}= +proc `=~`*(p1,p2:Point2d):bool {.inline.}= ## Checks if two vectors approximately equals with a ## hardcoded tolerance 1e-6 equals(p1,p2) -proc polar*(p:TPoint2d,ang,dist:float):TPoint2d {.noInit.} = +proc polar*(p:Point2d,ang,dist:float):Point2d {.noInit.} = ## Returns a point with a given angle and distance away from `p` result.x=p.x+cos(ang)*dist result.y=p.y+sin(ang)*dist -proc rotate*(p:var TPoint2d,rad:float)= +proc rotate*(p:var Point2d,rad:float)= ## Rotates a point in place `rad` radians around origo. let c=cos(rad) @@ -760,7 +760,7 @@ proc rotate*(p:var TPoint2d,rad:float)= p.y=p.y*c+p.x*s p.x=newx -proc rotate*(p:var TPoint2d,rad:float,org:TPoint2d)= +proc rotate*(p:var Point2d,rad:float,org:Point2d)= ## Rotates a point in place `rad` radians using `org` as ## center of rotation. let @@ -770,50 +770,50 @@ proc rotate*(p:var TPoint2d,rad:float,org:TPoint2d)= p.y=(p.y - org.y) * c + (p.x - org.x) * s + org.y p.x=newx -proc scale*(p:var TPoint2d,fac:float) {.inline.}= +proc scale*(p:var Point2d,fac:float) {.inline.}= ## Scales a point in place `fac` times with world origo as origin. p.x*=fac p.y*=fac -proc scale*(p:var TPoint2d,fac:float,org:TPoint2d){.inline.}= +proc scale*(p:var Point2d,fac:float,org:Point2d){.inline.}= ## Scales the point in place `fac` times with `org` as origin. p.x=(p.x - org.x) * fac + org.x p.y=(p.y - org.y) * fac + org.y -proc stretch*(p:var TPoint2d,facx,facy:float){.inline.}= +proc stretch*(p:var Point2d,facx,facy:float){.inline.}= ## Scales a point in place non uniformly `facx` and `facy` times with ## world origo as origin. p.x*=facx p.y*=facy -proc stretch*(p:var TPoint2d,facx,facy:float,org:TPoint2d){.inline.}= +proc stretch*(p:var Point2d,facx,facy:float,org:Point2d){.inline.}= ## Scales the point in place non uniformly `facx` and `facy` times with ## `org` as origin. p.x=(p.x - org.x) * facx + org.x p.y=(p.y - org.y) * facy + org.y -proc move*(p:var TPoint2d,dx,dy:float){.inline.}= +proc move*(p:var Point2d,dx,dy:float){.inline.}= ## Translates a point `dx`, `dy` in place. p.x+=dx p.y+=dy -proc move*(p:var TPoint2d,v:TVector2d){.inline.}= +proc move*(p:var Point2d,v:Vector2d){.inline.}= ## Translates a point with vector `v` in place. p.x+=v.x p.y+=v.y -proc sgnArea*(a,b,c:TPoint2d):float= +proc sgnArea*(a,b,c:Point2d):float= ## Computes the signed area of the triangle thru points `a`,`b` and `c` ## result>0.0 for counter clockwise triangle ## result<0.0 for clockwise triangle ## This is commonly used to determinate side of a point with respect to a line. return ((b.x - c.x) * (b.y - a.y)-(b.y - c.y) * (b.x - a.x))*0.5 -proc area*(a,b,c:TPoint2d):float= +proc area*(a,b,c:Point2d):float= ## Computes the area of the triangle thru points `a`,`b` and `c` return abs(sgnArea(a,b,c)) -proc closestPoint*(p:TPoint2d,pts:varargs[TPoint2d]):TPoint2d= +proc closestPoint*(p:Point2d,pts:varargs[Point2d]):Point2d= ## Returns a point selected from `pts`, that has the closest ## euclidean distance to `p` assert(pts.len>0) # must have at least one point diff --git a/lib/pure/basic3d.nim b/lib/pure/basic3d.nim index 5a943dd05..b99357e3a 100644 --- a/lib/pure/basic3d.nim +++ b/lib/pure/basic3d.nim @@ -25,25 +25,25 @@ import times ## ## # Create a matrix which first rotates, then scales and at last translates ## -## var m:TMatrix3d=rotate(PI,vector3d(1,1,2.5)) & scale(2.0) & move(100.0,200.0,300.0) +## var m:Matrix3d=rotate(PI,vector3d(1,1,2.5)) & scale(2.0) & move(100.0,200.0,300.0) ## ## # Create a 3d point at (100,150,200) and a vector (5,2,3) ## -## var pt:TPoint3d=point3d(100.0,150.0,200.0) +## var pt:Point3d=point3d(100.0,150.0,200.0) ## -## var vec:TVector3d=vector3d(5.0,2.0,3.0) +## var vec:Vector3d=vector3d(5.0,2.0,3.0) ## ## ## pt &= m # transforms pt in place ## -## var pt2:TPoint3d=pt & m #concatenates pt with m and returns a new point +## var pt2:Point3d=pt & m #concatenates pt with m and returns a new point ## -## var vec2:TVector3d=vec & m #concatenates vec with m and returns a new vector +## var vec2:Vector3d=vec & m #concatenates vec with m and returns a new vector type - TMatrix3d* =object + Matrix3d* =object ## Implements a row major 3d matrix, which means ## transformations are applied the order they are concatenated. ## This matrix is stored as an 4x4 matrix: @@ -52,31 +52,31 @@ type ## [ cx cy cz cw ] ## [ tx ty tz tw ] ax*,ay*,az*,aw*, bx*,by*,bz*,bw*, cx*,cy*,cz*,cw*, tx*,ty*,tz*,tw*:float - TPoint3d* = object + Point3d* = object ## Implements a non-homegeneous 2d point stored as ## an `x` , `y` and `z` coordinate. x*,y*,z*:float - TVector3d* = object + Vector3d* = object ## Implements a 3d **direction vector** stored as ## an `x` , `y` and `z` coordinate. Direction vector means, ## that when transforming a vector with a matrix, the translational ## part of the matrix is ignored. x*,y*,z*:float - +{.deprecated: [TMatrix3d: Matrix3d, TPoint3d: Point3d, TVector3d: Vector3d].} # Some forward declarations -proc matrix3d*(ax,ay,az,aw,bx,by,bz,bw,cx,cy,cz,cw,tx,ty,tz,tw:float):TMatrix3d {.noInit.} +proc matrix3d*(ax,ay,az,aw,bx,by,bz,bw,cx,cy,cz,cw,tx,ty,tz,tw:float):Matrix3d {.noInit.} ## Creates a new 4x4 3d transformation matrix. ## `ax` , `ay` , `az` is the local x axis. ## `bx` , `by` , `bz` is the local y axis. ## `cx` , `cy` , `cz` is the local z axis. ## `tx` , `ty` , `tz` is the translation. -proc vector3d*(x,y,z:float):TVector3d {.noInit,inline.} +proc vector3d*(x,y,z:float):Vector3d {.noInit,inline.} ## Returns a new 3d vector (`x`,`y`,`z`) -proc point3d*(x,y,z:float):TPoint3d {.noInit,inline.} +proc point3d*(x,y,z:float):Point3d {.noInit,inline.} ## Returns a new 4d point (`x`,`y`,`z`) -proc tryNormalize*(v:var TVector3d):bool +proc tryNormalize*(v:var Vector3d):bool ## Modifies `v` to have a length of 1.0, keeping its angle. ## If `v` has zero length (and thus no angle), it is left unmodified and false is ## returned, otherwise true is returned. @@ -84,19 +84,19 @@ proc tryNormalize*(v:var TVector3d):bool let - IDMATRIX*:TMatrix3d=matrix3d( + IDMATRIX*:Matrix3d=matrix3d( 1.0,0.0,0.0,0.0, 0.0,1.0,0.0,0.0, 0.0,0.0,1.0,0.0, 0.0,0.0,0.0,1.0) ## Quick access to a 3d identity matrix - ORIGO*:TPoint3d=point3d(0.0,0.0,0.0) + ORIGO*:Point3d=point3d(0.0,0.0,0.0) ## Quick access to point (0,0) - XAXIS*:TVector3d=vector3d(1.0,0.0,0.0) + XAXIS*:Vector3d=vector3d(1.0,0.0,0.0) ## Quick access to an 3d x-axis unit vector - YAXIS*:TVector3d=vector3d(0.0,1.0,0.0) + YAXIS*:Vector3d=vector3d(0.0,1.0,0.0) ## Quick access to an 3d y-axis unit vector - ZAXIS*:TVector3d=vector3d(0.0,0.0,1.0) + ZAXIS*:Vector3d=vector3d(0.0,0.0,1.0) ## Quick access to an 3d z-axis unit vector @@ -116,27 +116,27 @@ proc safeArccos(v:float):float= template makeBinOpVector(s:expr)= ## implements binary operators + , - , * and / for vectors - proc s*(a,b:TVector3d):TVector3d {.inline,noInit.} = + proc s*(a,b:Vector3d):Vector3d {.inline,noInit.} = vector3d(s(a.x,b.x),s(a.y,b.y),s(a.z,b.z)) - proc s*(a:TVector3d,b:float):TVector3d {.inline,noInit.} = + proc s*(a:Vector3d,b:float):Vector3d {.inline,noInit.} = vector3d(s(a.x,b),s(a.y,b),s(a.z,b)) - proc s*(a:float,b:TVector3d):TVector3d {.inline,noInit.} = + proc s*(a:float,b:Vector3d):Vector3d {.inline,noInit.} = vector3d(s(a,b.x),s(a,b.y),s(a,b.z)) template makeBinOpAssignVector(s:expr)= ## implements inplace binary operators += , -= , /= and *= for vectors - proc s*(a:var TVector3d,b:TVector3d) {.inline.} = + proc s*(a:var Vector3d,b:Vector3d) {.inline.} = s(a.x,b.x) ; s(a.y,b.y) ; s(a.z,b.z) - proc s*(a:var TVector3d,b:float) {.inline.} = + proc s*(a:var Vector3d,b:float) {.inline.} = s(a.x,b) ; s(a.y,b) ; s(a.z,b) # *************************************** -# TMatrix3d implementation +# Matrix3d implementation # *************************************** -proc setElements*(t:var TMatrix3d,ax,ay,az,aw,bx,by,bz,bw,cx,cy,cz,cw,tx,ty,tz,tw:float) {.inline.}= +proc setElements*(t:var Matrix3d,ax,ay,az,aw,bx,by,bz,bw,cx,cy,cz,cw,tx,ty,tz,tw:float) {.inline.}= ## Sets arbitrary elements in an exisitng matrix. t.ax=ax t.ay=ay @@ -155,10 +155,10 @@ proc setElements*(t:var TMatrix3d,ax,ay,az,aw,bx,by,bz,bw,cx,cy,cz,cw,tx,ty,tz,t t.tz=tz t.tw=tw -proc matrix3d*(ax,ay,az,aw,bx,by,bz,bw,cx,cy,cz,cw,tx,ty,tz,tw:float):TMatrix3d = +proc matrix3d*(ax,ay,az,aw,bx,by,bz,bw,cx,cy,cz,cw,tx,ty,tz,tw:float):Matrix3d = result.setElements(ax,ay,az,aw,bx,by,bz,bw,cx,cy,cz,cw,tx,ty,tz,tw) -proc `&`*(a,b:TMatrix3d):TMatrix3d {.noinit.} = +proc `&`*(a,b:Matrix3d):Matrix3d {.noinit.} = ## Concatenates matrices returning a new matrix. result.setElements( a.aw*b.tx+a.az*b.cx+a.ay*b.bx+a.ax*b.ax, @@ -182,36 +182,36 @@ proc `&`*(a,b:TMatrix3d):TMatrix3d {.noinit.} = a.tw*b.tw+a.tz*b.cw+a.ty*b.bw+a.tx*b.aw) -proc scale*(s:float):TMatrix3d {.noInit.} = +proc scale*(s:float):Matrix3d {.noInit.} = ## Returns a new scaling matrix. result.setElements(s,0,0,0, 0,s,0,0, 0,0,s,0, 0,0,0,1) -proc scale*(s:float,org:TPoint3d):TMatrix3d {.noInit.} = +proc scale*(s:float,org:Point3d):Matrix3d {.noInit.} = ## Returns a new scaling matrix using, `org` as scale origin. result.setElements(s,0,0,0, 0,s,0,0, 0,0,s,0, org.x-s*org.x,org.y-s*org.y,org.z-s*org.z,1.0) -proc stretch*(sx,sy,sz:float):TMatrix3d {.noInit.} = +proc stretch*(sx,sy,sz:float):Matrix3d {.noInit.} = ## Returns new a stretch matrix, which is a ## scale matrix with non uniform scale in x,y and z. result.setElements(sx,0,0,0, 0,sy,0,0, 0,0,sz,0, 0,0,0,1) -proc stretch*(sx,sy,sz:float,org:TPoint3d):TMatrix3d {.noInit.} = +proc stretch*(sx,sy,sz:float,org:Point3d):Matrix3d {.noInit.} = ## Returns a new stretch matrix, which is a ## scale matrix with non uniform scale in x,y and z. ## `org` is used as stretch origin. result.setElements(sx,0,0,0, 0,sy,0,0, 0,0,sz,0, org.x-sx*org.x,org.y-sy*org.y,org.z-sz*org.z,1) -proc move*(dx,dy,dz:float):TMatrix3d {.noInit.} = +proc move*(dx,dy,dz:float):Matrix3d {.noInit.} = ## Returns a new translation matrix. result.setElements(1,0,0,0, 0,1,0,0, 0,0,1,0, dx,dy,dz,1) -proc move*(v:TVector3d):TMatrix3d {.noInit.} = +proc move*(v:Vector3d):Matrix3d {.noInit.} = ## Returns a new translation matrix from a vector. result.setElements(1,0,0,0, 0,1,0,0, 0,0,1,0, v.x,v.y,v.z,1) -proc rotate*(angle:float,axis:TVector3d):TMatrix3d {.noInit.}= +proc rotate*(angle:float,axis:Vector3d):Matrix3d {.noInit.}= ## Creates a rotation matrix that rotates `angle` radians over ## `axis`, which passes through origo. @@ -242,7 +242,7 @@ proc rotate*(angle:float,axis:TVector3d):TMatrix3d {.noInit.}= uwomc+vsi, vwomc-usi, w2+(1.0-w2)*cs, 0.0, 0.0,0.0,0.0,1.0) -proc rotate*(angle:float,org:TPoint3d,axis:TVector3d):TMatrix3d {.noInit.}= +proc rotate*(angle:float,org:Point3d,axis:Vector3d):Matrix3d {.noInit.}= ## Creates a rotation matrix that rotates `angle` radians over ## `axis`, which passes through `org`. @@ -282,7 +282,7 @@ proc rotate*(angle:float,org:TPoint3d,axis:TVector3d):TMatrix3d {.noInit.}= (c*(u2+v2)-w*(a*u+b*v))*omc+(a*v-b*u)*si,1.0) -proc rotateX*(angle:float):TMatrix3d {.noInit.}= +proc rotateX*(angle:float):Matrix3d {.noInit.}= ## Creates a matrix that rotates around the x-axis with `angle` radians, ## which is also called a 'roll' matrix. let @@ -294,7 +294,7 @@ proc rotateX*(angle:float):TMatrix3d {.noInit.}= 0,-s,c,0, 0,0,0,1) -proc rotateY*(angle:float):TMatrix3d {.noInit.}= +proc rotateY*(angle:float):Matrix3d {.noInit.}= ## Creates a matrix that rotates around the y-axis with `angle` radians, ## which is also called a 'pitch' matrix. let @@ -306,7 +306,7 @@ proc rotateY*(angle:float):TMatrix3d {.noInit.}= s,0,c,0, 0,0,0,1) -proc rotateZ*(angle:float):TMatrix3d {.noInit.}= +proc rotateZ*(angle:float):Matrix3d {.noInit.}= ## Creates a matrix that rotates around the z-axis with `angle` radians, ## which is also called a 'yaw' matrix. let @@ -318,7 +318,7 @@ proc rotateZ*(angle:float):TMatrix3d {.noInit.}= 0,0,1,0, 0,0,0,1) -proc isUniform*(m:TMatrix3d,tol=1.0e-6):bool= +proc isUniform*(m:Matrix3d,tol=1.0e-6):bool= ## Checks if the transform is uniform, that is ## perpendicular axes of equal length, which means (for example) ## it cannot transform a sphere into an ellipsoid. @@ -341,7 +341,7 @@ proc isUniform*(m:TMatrix3d,tol=1.0e-6):bool= -proc mirror*(planeperp:TVector3d):TMatrix3d {.noInit.}= +proc mirror*(planeperp:Vector3d):Matrix3d {.noInit.}= ## Creates a matrix that mirrors over the plane that has `planeperp` as normal, ## and passes through origo. `planeperp` does not need to be normalized. @@ -365,7 +365,7 @@ proc mirror*(planeperp:TVector3d):TMatrix3d {.noInit.}= 0,0,0,1) -proc mirror*(org:TPoint3d,planeperp:TVector3d):TMatrix3d {.noInit.}= +proc mirror*(org:Point3d,planeperp:Vector3d):Matrix3d {.noInit.}= ## Creates a matrix that mirrors over the plane that has `planeperp` as normal, ## and passes through `org`. `planeperp` does not need to be normalized. @@ -400,7 +400,7 @@ proc mirror*(org:TPoint3d,planeperp:TVector3d):TMatrix3d {.noInit.}= 2*(cc*tz+bc*ty+ac*tx) ,1) -proc determinant*(m:TMatrix3d):float= +proc determinant*(m:Matrix3d):float= ## Computes the determinant of matrix `m`. # This computation is gotten from ratsimp(optimize(determinant(m))) @@ -419,7 +419,7 @@ proc determinant*(m:TMatrix3d):float= (O3*m.az-O5*m.ay+O6*m.ax)*m.bw -proc inverse*(m:TMatrix3d):TMatrix3d {.noInit.}= +proc inverse*(m:Matrix3d):Matrix3d {.noInit.}= ## Computes the inverse of matrix `m`. If the matrix ## determinant is zero, thus not invertible, a EDivByZero ## will be raised. @@ -461,7 +461,7 @@ proc inverse*(m:TMatrix3d):TMatrix3d {.noInit.}= (-m.ax*O7+m.ay*O14-m.az*O18)/det , (m.ax*O10-m.ay*O16+m.az*O19)/det) -proc equals*(m1:TMatrix3d,m2:TMatrix3d,tol=1.0e-6):bool= +proc equals*(m1:Matrix3d,m2:Matrix3d,tol=1.0e-6):bool= ## Checks if all elements of `m1`and `m2` is equal within ## a given tolerance `tol`. return @@ -482,42 +482,42 @@ proc equals*(m1:TMatrix3d,m2:TMatrix3d,tol=1.0e-6):bool= abs(m1.tz-m2.tz)<=tol and abs(m1.tw-m2.tw)<=tol -proc `=~`*(m1,m2:TMatrix3d):bool= +proc `=~`*(m1,m2:Matrix3d):bool= ## Checks if `m1` and `m2` is approximately equal, using a ## tolerance of 1e-6. equals(m1,m2) -proc transpose*(m:TMatrix3d):TMatrix3d {.noInit.}= +proc transpose*(m:Matrix3d):Matrix3d {.noInit.}= ## Returns the transpose of `m` result.setElements(m.ax,m.bx,m.cx,m.tx,m.ay,m.by,m.cy,m.ty,m.az,m.bz,m.cz,m.tz,m.aw,m.bw,m.cw,m.tw) -proc getXAxis*(m:TMatrix3d):TVector3d {.noInit.}= +proc getXAxis*(m:Matrix3d):Vector3d {.noInit.}= ## Gets the local x axis of `m` result.x=m.ax result.y=m.ay result.z=m.az -proc getYAxis*(m:TMatrix3d):TVector3d {.noInit.}= +proc getYAxis*(m:Matrix3d):Vector3d {.noInit.}= ## Gets the local y axis of `m` result.x=m.bx result.y=m.by result.z=m.bz -proc getZAxis*(m:TMatrix3d):TVector3d {.noInit.}= +proc getZAxis*(m:Matrix3d):Vector3d {.noInit.}= ## Gets the local y axis of `m` result.x=m.cx result.y=m.cy result.z=m.cz -proc `$`*(m:TMatrix3d):string= +proc `$`*(m:Matrix3d):string= ## String representation of `m` return rtos(m.ax) & "," & rtos(m.ay) & "," & rtos(m.az) & "," & rtos(m.aw) & "\n" & rtos(m.bx) & "," & rtos(m.by) & "," & rtos(m.bz) & "," & rtos(m.bw) & "\n" & rtos(m.cx) & "," & rtos(m.cy) & "," & rtos(m.cz) & "," & rtos(m.cw) & "\n" & rtos(m.tx) & "," & rtos(m.ty) & "," & rtos(m.tz) & "," & rtos(m.tw) -proc apply*(m:TMatrix3d, x,y,z:var float, translate=false)= +proc apply*(m:Matrix3d, x,y,z:var float, translate=false)= ## Applies transformation `m` onto `x` , `y` , `z` , optionally ## using the translation part of the matrix. let @@ -535,18 +535,18 @@ proc apply*(m:TMatrix3d, x,y,z:var float, translate=false)= z+=m.tz # *************************************** -# TVector3d implementation +# Vector3d implementation # *************************************** -proc vector3d*(x,y,z:float):TVector3d= +proc vector3d*(x,y,z:float):Vector3d= result.x=x result.y=y result.z=z -proc len*(v:TVector3d):float= +proc len*(v:Vector3d):float= ## Returns the length of the vector `v`. sqrt(v.x*v.x+v.y*v.y+v.z*v.z) -proc `len=`*(v:var TVector3d,newlen:float) {.noInit.} = +proc `len=`*(v:var Vector3d,newlen:float) {.noInit.} = ## Sets the length of the vector, keeping its direction. ## If the vector has zero length before changing it's length, ## an arbitrary vector of the requested length is returned. @@ -571,12 +571,12 @@ proc `len=`*(v:var TVector3d,newlen:float) {.noInit.} = v.z*=fac -proc sqrLen*(v:TVector3d):float {.inline.}= +proc sqrLen*(v:Vector3d):float {.inline.}= ## Computes the squared length of the vector, which is ## faster than computing the absolute length. return v.x*v.x+v.y*v.y+v.z*v.z -proc `$` *(v:TVector3d):string= +proc `$` *(v:Vector3d):string= ## String representation of `v` result=rtos(v.x) result.add(",") @@ -584,7 +584,7 @@ proc `$` *(v:TVector3d):string= result.add(",") result.add(rtos(v.z)) -proc `&` *(v:TVector3d,m:TMatrix3d):TVector3d {.noInit.} = +proc `&` *(v:Vector3d,m:Matrix3d):Vector3d {.noInit.} = ## Concatenate vector `v` with a transformation matrix. ## Transforming a vector ignores the translational part ## of the matrix. @@ -601,7 +601,7 @@ proc `&` *(v:TVector3d,m:TMatrix3d):TVector3d {.noInit.} = result.x=newx -proc `&=` *(v:var TVector3d,m:TMatrix3d) {.noInit.} = +proc `&=` *(v:var Vector3d,m:Matrix3d) {.noInit.} = ## Applies transformation `m` onto `v` in place. ## Transforming a vector ignores the translational part ## of the matrix. @@ -618,7 +618,7 @@ proc `&=` *(v:var TVector3d,m:TMatrix3d) {.noInit.} = v.y=newy v.x=newx -proc transformNorm*(v:var TVector3d,m:TMatrix3d)= +proc transformNorm*(v:var Vector3d,m:Matrix3d)= ## Applies a normal direction transformation `m` onto `v` in place. ## The resulting vector is *not* normalized. Transforming a vector ignores the ## translational part of the matrix. If the matrix is not invertible @@ -631,7 +631,7 @@ proc transformNorm*(v:var TVector3d,m:TMatrix3d)= # (possibly by hardware) as well as having a consistent API with the 2d version. v&=transpose(inverse(m)) -proc transformInv*(v:var TVector3d,m:TMatrix3d)= +proc transformInv*(v:var Vector3d,m:Matrix3d)= ## Applies the inverse of `m` on vector `v`. Transforming a vector ignores ## the translational part of the matrix. Transforming a vector ignores the ## translational part of the matrix. @@ -642,7 +642,7 @@ proc transformInv*(v:var TVector3d,m:TMatrix3d)= # (possibly by hardware) as well as having a consistent API with the 2d version. v&=m.inverse -proc transformNormInv*(vec:var TVector3d,m:TMatrix3d)= +proc transformNormInv*(vec:var Vector3d,m:Matrix3d)= ## Applies an inverse normal direction transformation `m` onto `v` in place. ## This is faster than creating an inverse ## matrix and transformNorm(...) it. Transforming a vector ignores the @@ -651,7 +651,7 @@ proc transformNormInv*(vec:var TVector3d,m:TMatrix3d)= # see vector2d:s equivalent for a deeper look how/why this works vec&=m.transpose -proc tryNormalize*(v:var TVector3d):bool= +proc tryNormalize*(v:var Vector3d):bool= ## Modifies `v` to have a length of 1.0, keeping its angle. ## If `v` has zero length (and thus no angle), it is left unmodified and false is ## returned, otherwise true is returned. @@ -666,13 +666,13 @@ proc tryNormalize*(v:var TVector3d):bool= return true -proc normalize*(v:var TVector3d) {.inline.}= +proc normalize*(v:var Vector3d) {.inline.}= ## Modifies `v` to have a length of 1.0, keeping its angle. ## If `v` has zero length, an EDivByZero will be raised. if not tryNormalize(v): raise newException(DivByZeroError,"Cannot normalize zero length vector") -proc rotate*(vec:var TVector3d,angle:float,axis:TVector3d)= +proc rotate*(vec:var Vector3d,angle:float,axis:Vector3d)= ## Rotates `vec` in place, with `angle` radians over `axis`, which passes ## through origo. @@ -699,19 +699,19 @@ proc rotate*(vec:var TVector3d,angle:float,axis:TVector3d)= vec.y=v*uxyzomc+y*cs+(w*x-u*z)*si vec.z=w*uxyzomc+z*cs+(u*y-v*x)*si -proc scale*(v:var TVector3d,s:float)= +proc scale*(v:var Vector3d,s:float)= ## Scales the vector in place with factor `s` v.x*=s v.y*=s v.z*=s -proc stretch*(v:var TVector3d,sx,sy,sz:float)= +proc stretch*(v:var Vector3d,sx,sy,sz:float)= ## Scales the vector non uniformly with factors `sx` , `sy` , `sz` v.x*=sx v.y*=sy v.z*=sz -proc mirror*(v:var TVector3d,planeperp:TVector3d)= +proc mirror*(v:var Vector3d,planeperp:Vector3d)= ## Computes the mirrored vector of `v` over the plane ## that has `planeperp` as normal direction. ## `planeperp` does not need to be normalized. @@ -735,7 +735,7 @@ proc mirror*(v:var TVector3d,planeperp:TVector3d)= v.z= -2*(c*c*z+bc*y+ac*x)+z -proc `-` *(v:TVector3d):TVector3d= +proc `-` *(v:Vector3d):Vector3d= ## Negates a vector result.x= -v.x result.y= -v.y @@ -751,12 +751,12 @@ makeBinOpAssignVector(`-=`) makeBinOpAssignVector(`*=`) makeBinOpAssignVector(`/=`) -proc dot*(v1,v2:TVector3d):float {.inline.}= +proc dot*(v1,v2:Vector3d):float {.inline.}= ## Computes the dot product of two vectors. ## Returns 0.0 if the vectors are perpendicular. return v1.x*v2.x+v1.y*v2.y+v1.z*v2.z -proc cross*(v1,v2:TVector3d):TVector3d {.inline.}= +proc cross*(v1,v2:Vector3d):Vector3d {.inline.}= ## Computes the cross product of two vectors. ## The result is a vector which is perpendicular ## to the plane of `v1` and `v2`, which means @@ -766,16 +766,16 @@ proc cross*(v1,v2:TVector3d):TVector3d {.inline.}= result.y = (v1.z * v2.x) - (v2.z * v1.x) result.z = (v1.x * v2.y) - (v2.x * v1.y) -proc equals*(v1,v2:TVector3d,tol=1.0e-6):bool= +proc equals*(v1,v2:Vector3d,tol=1.0e-6):bool= ## Checks if two vectors approximately equals with a tolerance. return abs(v2.x-v1.x)<=tol and abs(v2.y-v1.y)<=tol and abs(v2.z-v1.z)<=tol -proc `=~` *(v1,v2:TVector3d):bool= +proc `=~` *(v1,v2:Vector3d):bool= ## Checks if two vectors approximately equals with a ## hardcoded tolerance 1e-6 equals(v1,v2) -proc angleTo*(v1,v2:TVector3d):float= +proc angleTo*(v1,v2:Vector3d):float= ## Returns the smallest angle between v1 and v2, ## which is in range 0-PI var @@ -785,13 +785,13 @@ proc angleTo*(v1,v2:TVector3d):float= return 0.0 # zero length vector has zero angle to any other vector return safeArccos(dot(nv1,nv2)) -proc arbitraryAxis*(norm:TVector3d):TMatrix3d {.noInit.}= +proc arbitraryAxis*(norm:Vector3d):Matrix3d {.noInit.}= ## Computes the rotation matrix that would transform ## world z vector into `norm`. The inverse of this matrix ## is useful to transform a planar 3d object to 2d space. ## This is the same algorithm used to interpret DXF and DWG files. const lim=1.0/64.0 - var ax,ay,az:TVector3d + var ax,ay,az:Vector3d if abs(norm.x)<lim and abs(norm.y)<lim: ax=cross(YAXIS,norm) else: @@ -808,7 +808,7 @@ proc arbitraryAxis*(norm:TVector3d):TMatrix3d {.noInit.}= az.x,az.y,az.z,0.0, 0.0,0.0,0.0,1.0) -proc bisect*(v1,v2:TVector3d):TVector3d {.noInit.}= +proc bisect*(v1,v2:Vector3d):Vector3d {.noInit.}= ## Computes the bisector between v1 and v2 as a normalized vector. ## If one of the input vectors has zero length, a normalized version ## of the other is returned. If both input vectors has zero length, @@ -851,25 +851,25 @@ proc bisect*(v1,v2:TVector3d):TVector3d {.noInit.}= # *************************************** -# TPoint3d implementation +# Point3d implementation # *************************************** -proc point3d*(x,y,z:float):TPoint3d= +proc point3d*(x,y,z:float):Point3d= result.x=x result.y=y result.z=z -proc sqrDist*(a,b:TPoint3d):float= +proc sqrDist*(a,b:Point3d):float= ## Computes the squared distance between `a`and `b` let dx=b.x-a.x let dy=b.y-a.y let dz=b.z-a.z result=dx*dx+dy*dy+dz*dz -proc dist*(a,b:TPoint3d):float {.inline.}= +proc dist*(a,b:Point3d):float {.inline.}= ## Computes the absolute distance between `a`and `b` result=sqrt(sqrDist(a,b)) -proc `$` *(p:TPoint3d):string= +proc `$` *(p:Point3d):string= ## String representation of `p` result=rtos(p.x) result.add(",") @@ -877,14 +877,14 @@ proc `$` *(p:TPoint3d):string= result.add(",") result.add(rtos(p.z)) -proc `&`*(p:TPoint3d,m:TMatrix3d):TPoint3d= +proc `&`*(p:Point3d,m:Matrix3d):Point3d= ## Concatenates a point `p` with a transform `m`, ## resulting in a new, transformed point. result.z=m.cz*p.z+m.bz*p.y+m.az*p.x+m.tz result.y=m.cy*p.z+m.by*p.y+m.ay*p.x+m.ty result.x=m.cx*p.z+m.bx*p.y+m.ax*p.x+m.tx -proc `&=` *(p:var TPoint3d,m:TMatrix3d)= +proc `&=` *(p:var Point3d,m:Matrix3d)= ## Applies transformation `m` onto `p` in place. let x=p.x @@ -894,7 +894,7 @@ proc `&=` *(p:var TPoint3d,m:TMatrix3d)= p.y=m.cy*z+m.by*y+m.ay*x+m.ty p.z=m.cz*z+m.bz*y+m.az*x+m.tz -proc transformInv*(p:var TPoint3d,m:TMatrix3d)= +proc transformInv*(p:var Point3d,m:Matrix3d)= ## Applies the inverse of transformation `m` onto `p` in place. ## If the matrix is not invertable (determinant=0) , EDivByZero will ## be raised. @@ -903,48 +903,48 @@ proc transformInv*(p:var TPoint3d,m:TMatrix3d)= p&=inverse(m) -proc `+`*(p:TPoint3d,v:TVector3d):TPoint3d {.noInit,inline.} = +proc `+`*(p:Point3d,v:Vector3d):Point3d {.noInit,inline.} = ## Adds a vector `v` to a point `p`, resulting ## in a new point. result.x=p.x+v.x result.y=p.y+v.y result.z=p.z+v.z -proc `+=`*(p:var TPoint3d,v:TVector3d) {.noInit,inline.} = +proc `+=`*(p:var Point3d,v:Vector3d) {.noInit,inline.} = ## Adds a vector `v` to a point `p` in place. p.x+=v.x p.y+=v.y p.z+=v.z -proc `-`*(p:TPoint3d,v:TVector3d):TPoint3d {.noInit,inline.} = +proc `-`*(p:Point3d,v:Vector3d):Point3d {.noInit,inline.} = ## Subtracts a vector `v` from a point `p`, resulting ## in a new point. result.x=p.x-v.x result.y=p.y-v.y result.z=p.z-v.z -proc `-`*(p1,p2:TPoint3d):TVector3d {.noInit,inline.} = +proc `-`*(p1,p2:Point3d):Vector3d {.noInit,inline.} = ## Subtracts `p2`from `p1` resulting in a difference vector. result.x=p1.x-p2.x result.y=p1.y-p2.y result.z=p1.z-p2.z -proc `-=`*(p:var TPoint3d,v:TVector3d) {.noInit,inline.} = +proc `-=`*(p:var Point3d,v:Vector3d) {.noInit,inline.} = ## Subtracts a vector `v` from a point `p` in place. p.x-=v.x p.y-=v.y p.z-=v.z -proc equals(p1,p2:TPoint3d,tol=1.0e-6):bool {.inline.}= +proc equals(p1,p2:Point3d,tol=1.0e-6):bool {.inline.}= ## Checks if two points approximately equals with a tolerance. return abs(p2.x-p1.x)<=tol and abs(p2.y-p1.y)<=tol and abs(p2.z-p1.z)<=tol -proc `=~`*(p1,p2:TPoint3d):bool {.inline.}= +proc `=~`*(p1,p2:Point3d):bool {.inline.}= ## Checks if two vectors approximately equals with a ## hardcoded tolerance 1e-6 equals(p1,p2) -proc rotate*(p:var TPoint3d,rad:float,axis:TVector3d)= +proc rotate*(p:var Point3d,rad:float,axis:Vector3d)= ## Rotates point `p` in place `rad` radians about an axis ## passing through origo. @@ -954,7 +954,7 @@ proc rotate*(p:var TPoint3d,rad:float,axis:TVector3d)= p.y=v.y p.z=v.z -proc rotate*(p:var TPoint3d,angle:float,org:TPoint3d,axis:TVector3d)= +proc rotate*(p:var Point3d,angle:float,org:Point3d,axis:Vector3d)= ## Rotates point `p` in place `rad` radians about an axis ## passing through `org` @@ -992,26 +992,26 @@ proc rotate*(p:var TPoint3d,angle:float,org:TPoint3d,axis:TVector3d)= p.y=(b*(uu+ww)-v*(au+cw-uxmvymwz))*omc + y*cs + (c*u-a*w+w*x-u*z)*si p.z=(c*(uu+vv)-w*(au+bv-uxmvymwz))*omc + z*cs + (a*v+u*y-b*u-v*x)*si -proc scale*(p:var TPoint3d,fac:float) {.inline.}= +proc scale*(p:var Point3d,fac:float) {.inline.}= ## Scales a point in place `fac` times with world origo as origin. p.x*=fac p.y*=fac p.z*=fac -proc scale*(p:var TPoint3d,fac:float,org:TPoint3d){.inline.}= +proc scale*(p:var Point3d,fac:float,org:Point3d){.inline.}= ## Scales the point in place `fac` times with `org` as origin. p.x=(p.x - org.x) * fac + org.x p.y=(p.y - org.y) * fac + org.y p.z=(p.z - org.z) * fac + org.z -proc stretch*(p:var TPoint3d,facx,facy,facz:float){.inline.}= +proc stretch*(p:var Point3d,facx,facy,facz:float){.inline.}= ## Scales a point in place non uniformly `facx` , `facy` , `facz` times ## with world origo as origin. p.x*=facx p.y*=facy p.z*=facz -proc stretch*(p:var TPoint3d,facx,facy,facz:float,org:TPoint3d){.inline.}= +proc stretch*(p:var Point3d,facx,facy,facz:float,org:Point3d){.inline.}= ## Scales the point in place non uniformly `facx` , `facy` , `facz` times ## with `org` as origin. p.x=(p.x - org.x) * facx + org.x @@ -1019,19 +1019,19 @@ proc stretch*(p:var TPoint3d,facx,facy,facz:float,org:TPoint3d){.inline.}= p.z=(p.z - org.z) * facz + org.z -proc move*(p:var TPoint3d,dx,dy,dz:float){.inline.}= +proc move*(p:var Point3d,dx,dy,dz:float){.inline.}= ## Translates a point `dx` , `dy` , `dz` in place. p.x+=dx p.y+=dy p.z+=dz -proc move*(p:var TPoint3d,v:TVector3d){.inline.}= +proc move*(p:var Point3d,v:Vector3d){.inline.}= ## Translates a point with vector `v` in place. p.x+=v.x p.y+=v.y p.z+=v.z -proc area*(a,b,c:TPoint3d):float {.inline.}= +proc area*(a,b,c:Point3d):float {.inline.}= ## Computes the area of the triangle thru points `a` , `b` and `c` # The area of a planar 3d quadliteral is the magnitude of the cross diff --git a/lib/pure/collections/LockFreeHash.nim b/lib/pure/collections/LockFreeHash.nim index 0df97c685..1758c5b1a 100644 --- a/lib/pure/collections/LockFreeHash.nim +++ b/lib/pure/collections/LockFreeHash.nim @@ -46,24 +46,25 @@ const when sizeof(int) == 4: # 32bit type - TRaw = range[0..1073741823] + Raw = range[0..1073741823] ## The range of uint values that can be stored directly in a value slot ## when on a 32 bit platform - + {.deprecated: [TRaw: Raw].} elif sizeof(int) == 8: # 64bit type - TRaw = range[0..4611686018427387903] + Raw = range[0..4611686018427387903] ## The range of uint values that can be stored directly in a value slot ## when on a 64 bit platform + {.deprecated: [TRaw: Raw].} else: {.error: "unsupported platform".} type - TEntry = tuple + Entry = tuple key: int value: int - TEntryArr = ptr array[0..10_000_000, TEntry] + EntryArr = ptr array[0..10_000_000, Entry] PConcTable[K,V] = ptr object {.pure.} len: int @@ -72,8 +73,8 @@ type copyIdx: int copyDone: int next: PConcTable[K,V] - data: TEntryArr - + data: EntryArr +{.deprecated: [TEntry: Entry, TEntryArr: EntryArr.} proc setVal[K,V](table: var PConcTable[K,V], key: int, val: int, expVal: int, match: bool): int @@ -84,7 +85,7 @@ proc setVal[K,V](table: var PConcTable[K,V], key: int, val: int, proc newLFTable*[K,V](size: int = minTableSize): PConcTable[K,V] = let dataLen = max(nextPowerOfTwo(size), minTableSize) - dataSize = dataLen*sizeof(TEntry) + dataSize = dataLen*sizeof(Entry) dataMem = allocShared0(dataSize) tableSize = 7 * intSize tableMem = allocShared0(tableSize) @@ -95,7 +96,7 @@ proc newLFTable*[K,V](size: int = minTableSize): PConcTable[K,V] = table.copyIdx = 0 table.copyDone = 0 table.next = nil - table.data = cast[TEntryArr](dataMem) + table.data = cast[EntryArr](dataMem) result = table #------------------------------------------------------------------------------ @@ -107,7 +108,7 @@ proc deleteConcTable[K,V](tbl: PConcTable[K,V]) = #------------------------------------------------------------------------------ -proc `[]`[K,V](table: var PConcTable[K,V], i: int): var TEntry {.inline.} = +proc `[]`[K,V](table: var PConcTable[K,V], i: int): var Entry {.inline.} = table.data[i] #------------------------------------------------------------------------------ @@ -191,7 +192,7 @@ proc resize[K,V](self: PConcTable[K,V]): PConcTable[K,V] = #proc keyEQ[K](key1: ptr K, key2: ptr K): bool {.inline.} = proc keyEQ[K](key1: int, key2: int): bool {.inline.} = result = false - when K is TRaw: + when K is Raw: if key1 == key2: result = true else: @@ -236,7 +237,7 @@ proc copySlot[K,V](idx: int, oldTbl: var PConcTable[K,V], newTbl: var PConcTable break #echo("oldVal was = ", oldVal, " set it to prime ", box) if isPrime(oldVal) and isTomb(oldVal): - #when not (K is TRaw): + #when not (K is Raw): # deallocShared(popPtr[K](oldKey)) return false if isTomb(oldVal): @@ -343,7 +344,7 @@ proc helpCopy[K,V](table: var PConcTable[K,V]): PConcTable[K,V] = proc setVal[K,V](table: var PConcTable[K,V], key: int, val: int, expVal: int, match: bool): int = #echo("-try set- in table ", " key = ", (popPtr[K](key)[]), " val = ", val) - when K is TRaw: + when K is Raw: var idx = hashInt(key) else: var idx = popPtr[K](key)[].hash @@ -428,7 +429,7 @@ proc setVal[K,V](table: var PConcTable[K,V], key: int, val: int, proc getVal[K,V](table: var PConcTable[K,V], key: int): int = #echo("-try get- key = " & $key) - when K is TRaw: + when K is Raw: var idx = hashInt(key) else: var idx = popPtr[K](key)[].hash @@ -468,37 +469,37 @@ proc getVal[K,V](table: var PConcTable[K,V], key: int): int = #------------------------------------------------------------------------------ -#proc set*(table: var PConcTable[TRaw,TRaw], key: TRaw, val: TRaw) = +#proc set*(table: var PConcTable[Raw,Raw], key: Raw, val: Raw) = # discard setVal(table, pack(key), pack(key), 0, false) -#proc set*[V](table: var PConcTable[TRaw,V], key: TRaw, val: ptr V) = +#proc set*[V](table: var PConcTable[Raw,V], key: Raw, val: ptr V) = # discard setVal(table, pack(key), cast[int](val), 0, false) proc set*[K,V](table: var PConcTable[K,V], key: var K, val: var V) = - when not (K is TRaw): + when not (K is Raw): var newKey = cast[int](copyShared(key)) else: var newKey = pack(key) - when not (V is TRaw): + when not (V is Raw): var newVal = cast[int](copyShared(val)) else: var newVal = pack(val) var oldPtr = pop(setVal(table, newKey, newVal, 0, false)) #echo("oldPtr = ", cast[int](oldPtr), " newPtr = ", cast[int](newPtr)) - when not (V is TRaw): + when not (V is Raw): if newVal != oldPtr and oldPtr != 0: deallocShared(cast[ptr V](oldPtr)) proc get*[K,V](table: var PConcTable[K,V], key: var K): V = - when not (V is TRaw): - when not (K is TRaw): + when not (V is Raw): + when not (K is Raw): return popPtr[V](getVal(table, cast[int](key.addr)))[] else: return popPtr[V](getVal(table, pack(key)))[] else: - when not (K is TRaw): + when not (K is Raw): return popRaw(getVal(table, cast[int](key.addr))) else: return popRaw(getVal(table, pack(key))) @@ -535,23 +536,24 @@ when not defined(testing) and isMainModule: type - TTestObj = tuple + TestObj = tuple thr: int f0: int f1: int - TData = tuple[k: string,v: TTestObj] - PDataArr = array[0..numTests-1, TData] - Dict = PConcTable[string,TTestObj] + Data = tuple[k: string,v: TestObj] + PDataArr = array[0..numTests-1, Data] + Dict = PConcTable[string,TestObj] + {.deprecated: [TTestObj: TestObj, TData: Data].} var - thr: array[0..numThreads-1, TThread[Dict]] + thr: array[0..numThreads-1, Thread[Dict]] - table = newLFTable[string,TTestObj](8) + table = newLFTable[string,TestObj](8) rand = newMersenneTwister(2525) proc createSampleData(len: int): PDataArr = - #result = cast[PDataArr](allocShared0(sizeof(TData)*numTests)) + #result = cast[PDataArr](allocShared0(sizeof(Data)*numTests)) for i in 0..len-1: result[i].k = "mark" & $(i+1) #echo("mark" & $(i+1), " ", hash("mark" & $(i+1))) diff --git a/lib/pure/collections/intsets.nim b/lib/pure/collections/intsets.nim index 25f6616a6..38bc9d462 100644 --- a/lib/pure/collections/intsets.nim +++ b/lib/pure/collections/intsets.nim @@ -30,25 +30,25 @@ const IntMask = 1 shl IntShift - 1 type - PTrunk = ref TTrunk - TTrunk {.final.} = object + PTrunk = ref Trunk + Trunk {.final.} = object next: PTrunk # all nodes are connected with this pointer key: int # start address at bit 0 bits: array[0..IntsPerTrunk - 1, BitScalar] # a bit vector - TTrunkSeq = seq[PTrunk] + TrunkSeq = seq[PTrunk] IntSet* = object ## an efficient set of 'int' implemented as a sparse bit set counter, max: int head: PTrunk - data: TTrunkSeq + data: TrunkSeq -{.deprecated: [TIntSet: IntSet].} +{.deprecated: [TIntSet: IntSet, TTrunk: Trunk, TTrunkSeq: TrunkSeq].} proc mustRehash(length, counter: int): bool {.inline.} = assert(length > counter) result = (length * 2 < counter * 3) or (length - counter < 4) -proc nextTry(h, maxHash: THash): THash {.inline.} = +proc nextTry(h, maxHash: Hash): Hash {.inline.} = result = ((5 * h) + 1) and maxHash proc intSetGet(t: IntSet, key: int): PTrunk = @@ -59,7 +59,7 @@ proc intSetGet(t: IntSet, key: int): PTrunk = h = nextTry(h, t.max) result = nil -proc intSetRawInsert(t: IntSet, data: var TTrunkSeq, desc: PTrunk) = +proc intSetRawInsert(t: IntSet, data: var TrunkSeq, desc: PTrunk) = var h = desc.key and t.max while data[h] != nil: assert(data[h] != desc) @@ -68,7 +68,7 @@ proc intSetRawInsert(t: IntSet, data: var TTrunkSeq, desc: PTrunk) = data[h] = desc proc intSetEnlarge(t: var IntSet) = - var n: TTrunkSeq + var n: TrunkSeq var oldMax = t.max t.max = ((t.max + 1) * 2) - 1 newSeq(n, t.max + 1) diff --git a/lib/pure/collections/sets.nim b/lib/pure/collections/sets.nim index 280e0eeba..3d4de8fdc 100644 --- a/lib/pure/collections/sets.nim +++ b/lib/pure/collections/sets.nim @@ -29,7 +29,7 @@ when not defined(nimhygiene): # codes should never be needed, and this can pack more entries per cache-line. # Losing hcode entirely is also possible - if some element value is forbidden. type - KeyValuePair[A] = tuple[hcode: THash, key: A] + KeyValuePair[A] = tuple[hcode: Hash, key: A] KeyValuePairSeq[A] = seq[KeyValuePair[A]] HashSet* {.myShallow.}[A] = object ## \ ## A generic hash set. @@ -43,10 +43,10 @@ type # hcode for real keys cannot be zero. hcode==0 signifies an empty slot. These # two procs retain clarity of that encoding without the space cost of an enum. -proc isEmpty(hcode: THash): bool {.inline.} = +proc isEmpty(hcode: Hash): bool {.inline.} = result = hcode == 0 -proc isFilled(hcode: THash): bool {.inline.} = +proc isFilled(hcode: Hash): bool {.inline.} = result = hcode != 0 proc isValid*[A](s: HashSet[A]): bool = @@ -58,7 +58,7 @@ proc isValid*[A](s: HashSet[A]): bool = ## initialized. Example: ## ## .. code-block :: - ## proc savePreferences(options: TSet[string]) = + ## proc savePreferences(options: Set[string]) = ## assert options.isValid, "Pass an initialized set!" ## # Do stuff here, may crash in release builds! result = not s.data.isNil @@ -72,7 +72,7 @@ proc len*[A](s: HashSet[A]): int = ## ## .. code-block:: ## - ## var values: TSet[int] + ## var values: Set[int] ## assert(not values.isValid) ## assert values.len == 0 result = s.counter @@ -123,15 +123,15 @@ proc rightSize*(count: Natural): int {.inline.} = ## Internally, we want mustRehash(rightSize(x), x) == false. result = nextPowerOfTwo(count * 3 div 2 + 4) -proc nextTry(h, maxHash: THash): THash {.inline.} = +proc nextTry(h, maxHash: Hash): Hash {.inline.} = result = (h + 1) and maxHash template rawGetKnownHCImpl() {.dirty.} = - var h: THash = hc and high(s.data) # start with real hash value + var h: Hash = hc and high(s.data) # start with real hash value while isFilled(s.data[h].hcode): # Compare hc THEN key with boolean short circuit. This makes the common case # zero ==key's for missing (e.g.inserts) and exactly one ==key for present. - # It does slow down succeeding lookups by one extra THash cmp&and..usually + # It does slow down succeeding lookups by one extra Hash cmp&and..usually # just a few clock cycles, generally worth it for any non-integer-like A. if s.data[h].hcode == hc and s.data[h].key == key: # compare hc THEN key return h @@ -148,10 +148,10 @@ template rawInsertImpl() {.dirty.} = data[h].key = key data[h].hcode = hc -proc rawGetKnownHC[A](s: HashSet[A], key: A, hc: THash): int {.inline.} = +proc rawGetKnownHC[A](s: HashSet[A], key: A, hc: Hash): int {.inline.} = rawGetKnownHCImpl() -proc rawGet[A](s: HashSet[A], key: A, hc: var THash): int {.inline.} = +proc rawGet[A](s: HashSet[A], key: A, hc: var Hash): int {.inline.} = rawGetImpl() proc mget*[A](s: var HashSet[A], key: A): var A = @@ -160,7 +160,7 @@ proc mget*[A](s: var HashSet[A], key: A): var A = ## when one overloaded 'hash' and '==' but still needs reference semantics ## for sharing. assert s.isValid, "The set needs to be initialized." - var hc: THash + var hc: Hash var index = rawGet(s, key, hc) if index >= 0: result = s.data[index].key else: raise newException(KeyError, "key not found: " & $key) @@ -178,12 +178,12 @@ proc contains*[A](s: HashSet[A], key: A): bool = ## values.excl(2) ## assert(not values.contains(2)) assert s.isValid, "The set needs to be initialized." - var hc: THash + var hc: Hash var index = rawGet(s, key, hc) result = index >= 0 proc rawInsert[A](s: var HashSet[A], data: var KeyValuePairSeq[A], key: A, - hc: THash, h: THash) = + hc: Hash, h: Hash) = rawInsertImpl() proc enlarge[A](s: var HashSet[A]) = @@ -196,7 +196,7 @@ proc enlarge[A](s: var HashSet[A]) = rawInsert(s, s.data, n[i].key, n[i].hcode, j) template inclImpl() {.dirty.} = - var hc: THash + var hc: Hash var index = rawGet(s, key, hc) if index < 0: if mustRehash(len(s.data), s.counter): @@ -206,7 +206,7 @@ template inclImpl() {.dirty.} = inc(s.counter) template containsOrInclImpl() {.dirty.} = - var hc: THash + var hc: Hash var index = rawGet(s, key, hc) if index >= 0: result = true @@ -261,7 +261,7 @@ proc excl*[A](s: var HashSet[A], key: A) = ## s.excl(2) ## assert s.len == 3 assert s.isValid, "The set needs to be initialized." - var hc: THash + var hc: Hash var i = rawGet(s, key, hc) var msk = high(s.data) if i >= 0: @@ -323,7 +323,7 @@ proc init*[A](s: var HashSet[A], initialSize=64) = ## existing values and calling `excl() <#excl,TSet[A],A>`_ on them. Example: ## ## .. code-block :: - ## var a: TSet[int] + ## var a: Set[int] ## a.init(4) ## a.incl(2) ## a.init @@ -552,7 +552,7 @@ proc map*[A, B](data: HashSet[A], op: proc (x: A): B {.closure.}): HashSet[B] = type OrderedKeyValuePair[A] = tuple[ - hcode: THash, next: int, key: A] + hcode: Hash, next: int, key: A] OrderedKeyValuePairSeq[A] = seq[OrderedKeyValuePair[A]] OrderedSet* {.myShallow.}[A] = object ## \ ## A generic hash set that remembers insertion order. @@ -574,7 +574,7 @@ proc isValid*[A](s: OrderedSet[A]): bool = ## correctly initialized. Example: ## ## .. code-block:: - ## proc saveTarotCards(cards: TOrderedSet[int]) = + ## proc saveTarotCards(cards: OrderedSet[int]) = ## assert cards.isValid, "Pass an initialized set!" ## # Do stuff here, may crash in release builds! result = not s.data.isNil @@ -588,7 +588,7 @@ proc len*[A](s: OrderedSet[A]): int {.inline.} = ## ## .. code-block:: ## - ## var values: TOrderedSet[int] + ## var values: OrderedSet[int] ## assert(not values.isValid) ## assert values.len == 0 result = s.counter @@ -629,10 +629,10 @@ iterator items*[A](s: OrderedSet[A]): A = forAllOrderedPairs: yield s.data[h].key -proc rawGetKnownHC[A](s: OrderedSet[A], key: A, hc: THash): int {.inline.} = +proc rawGetKnownHC[A](s: OrderedSet[A], key: A, hc: Hash): int {.inline.} = rawGetKnownHCImpl() -proc rawGet[A](s: OrderedSet[A], key: A, hc: var THash): int {.inline.} = +proc rawGet[A](s: OrderedSet[A], key: A, hc: var Hash): int {.inline.} = rawGetImpl() proc contains*[A](s: OrderedSet[A], key: A): bool = @@ -646,12 +646,12 @@ proc contains*[A](s: OrderedSet[A], key: A): bool = ## values.incl(2) ## assert values.contains(2) assert s.isValid, "The set needs to be initialized." - var hc: THash + var hc: Hash var index = rawGet(s, key, hc) result = index >= 0 proc rawInsert[A](s: var OrderedSet[A], data: var OrderedKeyValuePairSeq[A], - key: A, hc: THash, h: THash) = + key: A, hc: Hash, h: Hash) = rawInsertImpl() data[h].next = -1 if s.first < 0: s.first = h @@ -729,7 +729,7 @@ proc init*[A](s: var OrderedSet[A], initialSize=64) = ## from an ordered hash set. Example: ## ## .. code-block :: - ## var a: TOrderedSet[int] + ## var a: OrderedSet[int] ## a.init(4) ## a.incl(2) ## a.init diff --git a/lib/pure/collections/tables.nim b/lib/pure/collections/tables.nim index 232e52c89..c44adfc82 100644 --- a/lib/pure/collections/tables.nim +++ b/lib/pure/collections/tables.nim @@ -24,13 +24,13 @@ ## ## Error: type mismatch: got (Person) ## but expected one of: -## hashes.hash(x: openarray[A]): THash -## hashes.hash(x: int): THash -## hashes.hash(x: float): THash +## hashes.hash(x: openarray[A]): Hash +## hashes.hash(x: int): Hash +## hashes.hash(x: float): Hash ## … ## ## What is happening here is that the types used for table keys require to have -## a ``hash()`` proc which will convert them to a `THash <hashes.html#THash>`_ +## a ``hash()`` proc which will convert them to a `Hash <hashes.html#Hash>`_ ## value, and the compiler is listing all the hash functions it knows. ## Additionally there has to be a ``==`` operator that provides the same ## semantics as its corresponding ``hash`` proc. @@ -46,7 +46,7 @@ ## Person = object ## firstName, lastName: string ## -## proc hash(x: Person): THash = +## proc hash(x: Person): Hash = ## ## Piggyback on the already available string hash proc. ## ## ## ## Without this proc nothing works! @@ -71,7 +71,7 @@ import {.pragma: myShallow.} type - KeyValuePair[A, B] = tuple[hcode: THash, key: A, val: B] + KeyValuePair[A, B] = tuple[hcode: Hash, key: A, val: B] KeyValuePairSeq[A, B] = seq[KeyValuePair[A, B]] Table* {.myShallow.}[A, B] = object ## generic hash table data: KeyValuePairSeq[A, B] @@ -85,10 +85,10 @@ when not defined(nimhygiene): # hcode for real keys cannot be zero. hcode==0 signifies an empty slot. These # two procs retain clarity of that encoding without the space cost of an enum. -proc isEmpty(hcode: THash): bool {.inline.} = +proc isEmpty(hcode: Hash): bool {.inline.} = result = hcode == 0 -proc isFilled(hcode: THash): bool {.inline.} = +proc isFilled(hcode: Hash): bool {.inline.} = result = hcode != 0 proc len*[A, B](t: Table[A, B]): int = @@ -137,15 +137,15 @@ proc rightSize*(count: Natural): int {.inline.} = ## Internally, we want mustRehash(rightSize(x), x) == false. result = nextPowerOfTwo(count * 3 div 2 + 4) -proc nextTry(h, maxHash: THash): THash {.inline.} = +proc nextTry(h, maxHash: Hash): Hash {.inline.} = result = (h + 1) and maxHash template rawGetKnownHCImpl() {.dirty.} = - var h: THash = hc and high(t.data) # start with real hash value + var h: Hash = hc and high(t.data) # start with real hash value while isFilled(t.data[h].hcode): # Compare hc THEN key with boolean short circuit. This makes the common case # zero ==key's for missing (e.g.inserts) and exactly one ==key for present. - # It does slow down succeeding lookups by one extra THash cmp&and..usually + # It does slow down succeeding lookups by one extra Hash cmp&and..usually # just a few clock cycles, generally worth it for any non-integer-like A. if t.data[h].hcode == hc and t.data[h].key == key: return h @@ -162,7 +162,7 @@ template rawGetDeepImpl() {.dirty.} = # Search algo for unconditional add hc = hash(key) if hc == 0: hc = 314159265 - var h: THash = hc and high(t.data) + var h: Hash = hc and high(t.data) while isFilled(t.data[h].hcode): h = nextTry(h, high(t.data)) result = h @@ -172,13 +172,13 @@ template rawInsertImpl() {.dirty.} = data[h].val = val data[h].hcode = hc -proc rawGetKnownHC[A, B](t: Table[A, B], key: A, hc: THash): int {.inline.} = +proc rawGetKnownHC[A, B](t: Table[A, B], key: A, hc: Hash): int {.inline.} = rawGetKnownHCImpl() -proc rawGetDeep[A, B](t: Table[A, B], key: A, hc: var THash): int {.inline.} = +proc rawGetDeep[A, B](t: Table[A, B], key: A, hc: var Hash): int {.inline.} = rawGetDeepImpl() -proc rawGet[A, B](t: Table[A, B], key: A, hc: var THash): int {.inline.} = +proc rawGet[A, B](t: Table[A, B], key: A, hc: var Hash): int {.inline.} = rawGetImpl() proc `[]`*[A, B](t: Table[A, B], key: A): B = @@ -186,14 +186,14 @@ proc `[]`*[A, B](t: Table[A, B], key: A): B = ## default empty value for the type `B` is returned ## and no exception is raised. One can check with ``hasKey`` whether the key ## exists. - var hc: THash + var hc: Hash var index = rawGet(t, key, hc) if index >= 0: result = t.data[index].val proc mget*[A, B](t: var Table[A, B], key: A): var B = ## retrieves the value at ``t[key]``. The value can be modified. ## If `key` is not in `t`, the ``KeyError`` exception is raised. - var hc: THash + var hc: Hash var index = rawGet(t, key, hc) if index >= 0: result = t.data[index].val else: @@ -204,7 +204,7 @@ proc mget*[A, B](t: var Table[A, B], key: A): var B = iterator allValues*[A, B](t: Table[A, B]; key: A): B = ## iterates over any value in the table `t` that belongs to the given `key`. - var h: THash = hash(key) and high(t.data) + var h: Hash = hash(key) and high(t.data) while isFilled(t.data[h].hcode): if t.data[h].key == key: yield t.data[h].val @@ -212,11 +212,15 @@ iterator allValues*[A, B](t: Table[A, B]; key: A): B = proc hasKey*[A, B](t: Table[A, B], key: A): bool = ## returns true iff `key` is in the table `t`. - var hc: THash + var hc: Hash result = rawGet(t, key, hc) >= 0 +proc contains*[A, B](t: Table[A, B], key: A): bool = + ## alias of `hasKey` for use with the `in` operator. + return hasKey[A, B](t, key) + proc rawInsert[A, B](t: var Table[A, B], data: var KeyValuePairSeq[A, B], - key: A, val: B, hc: THash, h: THash) = + key: A, val: B, hc: Hash, h: Hash) = rawInsertImpl() proc enlarge[A, B](t: var Table[A, B]) = @@ -230,7 +234,7 @@ proc enlarge[A, B](t: var Table[A, B]) = template addImpl() {.dirty.} = if mustRehash(len(t.data), t.counter): enlarge(t) - var hc: THash + var hc: Hash var j = rawGetDeep(t, key, hc) rawInsert(t, t.data, key, val, hc, j) inc(t.counter) @@ -244,19 +248,19 @@ template maybeRehashPutImpl() {.dirty.} = inc(t.counter) template putImpl() {.dirty.} = - var hc: THash + var hc: Hash var index = rawGet(t, key, hc) if index >= 0: t.data[index].val = val else: maybeRehashPutImpl() template mgetOrPutImpl() {.dirty.} = - var hc: THash + var hc: Hash var index = rawGet(t, key, hc) if index < 0: maybeRehashPutImpl() # not present: insert (flipping index) result = t.data[index].val # either way return modifiable val template hasKeyOrPutImpl() {.dirty.} = - var hc: THash + var hc: Hash var index = rawGet(t, key, hc) if index < 0: result = false @@ -287,7 +291,7 @@ template doWhile(a: expr, b: stmt): stmt = proc del*[A, B](t: var Table[A, B], key: A) = ## deletes `key` from hash table `t`. - var hc: THash + var hc: Hash var i = rawGet(t, key, hc) let msk = high(t.data) if i >= 0: @@ -411,6 +415,10 @@ proc hasKey*[A, B](t: TableRef[A, B], key: A): bool = ## returns true iff `key` is in the table `t`. result = t[].hasKey(key) +proc contains*[A, B](t: TableRef[A, B], key: A): bool = + ## alias of `hasKey` for use with the `in` operator. + return hasKey[A, B](t, key) + proc `[]=`*[A, B](t: TableRef[A, B], key: A, val: B) = ## puts a (key, value)-pair into `t`. t[][key] = val @@ -452,7 +460,7 @@ proc newTableFrom*[A, B, C](collection: A, index: proc(x: B): C): TableRef[C, B] type OrderedKeyValuePair[A, B] = tuple[ - hcode: THash, next: int, key: A, val: B] + hcode: Hash, next: int, key: A, val: B] OrderedKeyValuePairSeq[A, B] = seq[OrderedKeyValuePair[A, B]] OrderedTable* {. myShallow.}[A, B] = object ## table that remembers insertion order @@ -501,13 +509,13 @@ iterator mvalues*[A, B](t: var OrderedTable[A, B]): var B = forAllOrderedPairs: yield t.data[h].val -proc rawGetKnownHC[A, B](t: OrderedTable[A, B], key: A, hc: THash): int = +proc rawGetKnownHC[A, B](t: OrderedTable[A, B], key: A, hc: Hash): int = rawGetKnownHCImpl() -proc rawGetDeep[A, B](t: OrderedTable[A, B], key: A, hc: var THash): int {.inline.} = +proc rawGetDeep[A, B](t: OrderedTable[A, B], key: A, hc: var Hash): int {.inline.} = rawGetDeepImpl() -proc rawGet[A, B](t: OrderedTable[A, B], key: A, hc: var THash): int = +proc rawGet[A, B](t: OrderedTable[A, B], key: A, hc: var Hash): int = rawGetImpl() proc `[]`*[A, B](t: OrderedTable[A, B], key: A): B = @@ -515,26 +523,30 @@ proc `[]`*[A, B](t: OrderedTable[A, B], key: A): B = ## default empty value for the type `B` is returned ## and no exception is raised. One can check with ``hasKey`` whether the key ## exists. - var hc: THash + var hc: Hash var index = rawGet(t, key, hc) if index >= 0: result = t.data[index].val proc mget*[A, B](t: var OrderedTable[A, B], key: A): var B = ## retrieves the value at ``t[key]``. The value can be modified. ## If `key` is not in `t`, the ``EInvalidKey`` exception is raised. - var hc: THash + var hc: Hash var index = rawGet(t, key, hc) if index >= 0: result = t.data[index].val else: raise newException(KeyError, "key not found: " & $key) proc hasKey*[A, B](t: OrderedTable[A, B], key: A): bool = ## returns true iff `key` is in the table `t`. - var hc: THash + var hc: Hash result = rawGet(t, key, hc) >= 0 +proc contains*[A, B](t: OrderedTable[A, B], key: A): bool = + ## alias of `hasKey` for use with the `in` operator. + return hasKey[A, B](t, key) + proc rawInsert[A, B](t: var OrderedTable[A, B], data: var OrderedKeyValuePairSeq[A, B], - key: A, val: B, hc: THash, h: THash) = + key: A, val: B, hc: Hash, h: Hash) = rawInsertImpl() data[h].next = -1 if t.first < 0: t.first = h @@ -704,6 +716,10 @@ proc hasKey*[A, B](t: OrderedTableRef[A, B], key: A): bool = ## returns true iff `key` is in the table `t`. result = t[].hasKey(key) +proc contains*[A, B](t: OrderedTableRef[A, B], key: A): bool = + ## alias of `hasKey` for use with the `in` operator. + return hasKey[A, B](t, key) + proc `[]=`*[A, B](t: OrderedTableRef[A, B], key: A, val: B) = ## puts a (key, value)-pair into `t`. t[][key] = val @@ -780,7 +796,7 @@ iterator mvalues*[A](t: CountTable[A]): var int = if t.data[h].val != 0: yield t.data[h].val proc rawGet[A](t: CountTable[A], key: A): int = - var h: THash = hash(key) and high(t.data) # start with real hash value + var h: Hash = hash(key) and high(t.data) # start with real hash value while t.data[h].val != 0: if t.data[h].key == key: return h h = nextTry(h, high(t.data)) @@ -804,9 +820,13 @@ proc hasKey*[A](t: CountTable[A], key: A): bool = ## returns true iff `key` is in the table `t`. result = rawGet(t, key) >= 0 +proc contains*[A](t: CountTable[A], key: A): bool = + ## alias of `hasKey` for use with the `in` operator. + return hasKey[A](t, key) + proc rawInsert[A](t: CountTable[A], data: var seq[tuple[key: A, val: int]], key: A, val: int) = - var h: THash = hash(key) and high(data) + var h: Hash = hash(key) and high(data) while data[h].val != 0: h = nextTry(h, high(data)) data[h].key = key data[h].val = val @@ -819,15 +839,18 @@ proc enlarge[A](t: var CountTable[A]) = swap(t.data, n) proc `[]=`*[A](t: var CountTable[A], key: A, val: int) = - ## puts a (key, value)-pair into `t`. `val` has to be positive. + ## puts a (key, value)-pair into `t`. assert val > 0 var h = rawGet(t, key) if h >= 0: t.data[h].val = val else: - h = -1 - h - t.data[h].key = key - t.data[h].val = val + if mustRehash(len(t.data), t.counter): enlarge(t) + rawInsert(t, t.data, key, val) + inc(t.counter) + #h = -1 - h + #t.data[h].key = key + #t.data[h].val = val proc initCountTable*[A](initialSize=64): CountTable[A] = ## creates a new count table that is empty. @@ -942,6 +965,10 @@ proc hasKey*[A](t: CountTableRef[A], key: A): bool = ## returns true iff `key` is in the table `t`. result = t[].hasKey(key) +proc contains*[A](t: CountTableRef[A], key: A): bool = + ## alias of `hasKey` for use with the `in` operator. + return hasKey[A](t, key) + proc `[]=`*[A](t: CountTableRef[A], key: A, val: int) = ## puts a (key, value)-pair into `t`. `val` has to be positive. assert val > 0 @@ -1005,7 +1032,7 @@ when isMainModule: Person = object firstName, lastName: string - proc hash(x: Person): THash = + proc hash(x: Person): Hash = ## Piggyback on the already available string hash proc. ## ## Without this proc nothing works! diff --git a/lib/pure/concurrency/cpuload.nim b/lib/pure/concurrency/cpuload.nim index 7ce5e01b7..22598b5c9 100644 --- a/lib/pure/concurrency/cpuload.nim +++ b/lib/pure/concurrency/cpuload.nim @@ -13,7 +13,7 @@ when defined(windows): import winlean, os, strutils, math - proc `-`(a, b: TFILETIME): int64 = a.rdFileTime - b.rdFileTime + proc `-`(a, b: FILETIME): int64 = a.rdFileTime - b.rdFileTime elif defined(linux): from cpuinfo import countProcessors @@ -25,16 +25,16 @@ type ThreadPoolState* = object when defined(windows): - prevSysKernel, prevSysUser, prevProcKernel, prevProcUser: TFILETIME + prevSysKernel, prevSysUser, prevProcKernel, prevProcUser: FILETIME calls*: int proc advice*(s: var ThreadPoolState): ThreadPoolAdvice = when defined(windows): var sysIdle, sysKernel, sysUser, - procCreation, procExit, procKernel, procUser: TFILETIME + procCreation, procExit, procKernel, procUser: FILETIME if getSystemTimes(sysIdle, sysKernel, sysUser) == 0 or - getProcessTimes(THandle(-1), procCreation, procExit, + getProcessTimes(Handle(-1), procCreation, procExit, procKernel, procUser) == 0: return doNothing if s.calls > 0: @@ -57,7 +57,7 @@ proc advice*(s: var ThreadPoolState): ThreadPoolAdvice = s.prevProcKernel = procKernel s.prevProcUser = procUser elif defined(linux): - proc fscanf(c: File, frmt: cstring) {.varargs, importc, + proc fscanf(c: File, frmt: cstring) {.varargs, importc, header: "<stdio.h>".} var f = open("/proc/loadavg") diff --git a/lib/pure/concurrency/threadpool.nim b/lib/pure/concurrency/threadpool.nim index 9f1e53fb8..749a2fa2d 100644 --- a/lib/pure/concurrency/threadpool.nim +++ b/lib/pure/concurrency/threadpool.nim @@ -18,8 +18,8 @@ import cpuinfo, cpuload, locks type Semaphore = object - c: TCond - L: TLock + c: Cond + L: Lock counter: int proc createSemaphore(): Semaphore = @@ -113,7 +113,7 @@ type ToFreeQueue = object len: int - lock: TLock + lock: Lock empty: Semaphore data: array[128, pointer] @@ -221,11 +221,17 @@ proc awaitAndThen*[T](fv: FlowVar[T]; action: proc (x: T) {.closure.}) = action(fv.blob) finished(fv) -proc `^`*[T](fv: FlowVar[ref T]): foreign ptr T = +proc unsafeRead*[T](fv: FlowVar[ref T]): foreign ptr T = ## blocks until the value is available and then returns this value. await(fv) result = cast[foreign ptr T](fv.data) +proc `^`*[T](fv: FlowVar[ref T]): ref T = + ## blocks until the value is available and then returns this value. + await(fv) + let src = cast[ref T](fv.data) + deepCopy result, src + proc `^`*[T](fv: FlowVar[T]): T = ## blocks until the value is available and then returns this value. await(fv) @@ -300,7 +306,7 @@ proc setMinPoolSize*(size: range[1..MaxThreadPoolSize]) = minPoolSize = size proc setMaxPoolSize*(size: range[1..MaxThreadPoolSize]) = - ## sets the minimal thread pool size. The default value of this + ## sets the maximal thread pool size. The default value of this ## is ``MaxThreadPoolSize``. maxPoolSize = size if currentPoolSize > maxPoolSize: @@ -349,7 +355,7 @@ proc parallel*(body: stmt) {.magic: "Parallel".} var state: ThreadPoolState - stateLock: TLock + stateLock: Lock initLock stateLock diff --git a/lib/pure/encodings.nim b/lib/pure/encodings.nim index 2a6134615..e427b585d 100644 --- a/lib/pure/encodings.nim +++ b/lib/pure/encodings.nim @@ -211,12 +211,13 @@ when defined(windows): when false: # not needed yet: type - TCpInfo = object + CpInfo = object maxCharSize: int32 defaultChar: array[0..1, char] leadByte: array[0..12-1, char] + {.deprecated: [TCpInfo: CpInfo].} - proc getCPInfo(codePage: CodePage, lpCPInfo: var TCpInfo): int32 {. + proc getCPInfo(codePage: CodePage, lpCPInfo: var CpInfo): int32 {. stdcall, importc: "GetCPInfo", dynlib: "kernel32".} proc nameToCodePage(name: string): CodePage = @@ -262,7 +263,7 @@ else: else: const iconvDll = "(libc.so.6|libiconv.so)" - when defined(macosx) and defined(powerpc): + when defined(macosx): const prefix = "lib" else: const prefix = "" diff --git a/lib/pure/etcpriv.nim b/lib/pure/etcpriv.nim new file mode 100644 index 000000000..e7a525e4d --- /dev/null +++ b/lib/pure/etcpriv.nim @@ -0,0 +1,23 @@ +# +# +# Nim's Runtime Library +# (c) Copyright 2015 Nim Authors +# +# See the file "copying.txt", included in this +# distribution, for details about the copyright. +# + +## This module contains utils that are less then easy to categorize and +## don't really warrant a specific module. They are private to compiler +## and stdlib usage, and should not be used outside of that - they may +## change or disappear at any time. + + +# Used by pure/hashes.nim, and the compiler parsing +const magicIdentSeparatorRuneByteWidth* = 3 + +# Used by pure/hashes.nim, and the compiler parsing +proc isMagicIdentSeparatorRune*(cs: cstring, i: int): bool {. inline } = + result = cs[i] == '\226' and + cs[i + 1] == '\128' and + cs[i + 2] == '\147' # en-dash # 145 = nb-hyphen diff --git a/lib/pure/fsmonitor.nim b/lib/pure/fsmonitor.nim index 83779eb9c..229df80b5 100644 --- a/lib/pure/fsmonitor.nim +++ b/lib/pure/fsmonitor.nim @@ -108,7 +108,7 @@ proc del*(monitor: FSMonitor, wd: cint) = proc getEvent(m: FSMonitor, fd: cint): seq[MonitorEvent] = result = @[] - let size = (sizeof(TINotifyEvent)+2000)*MaxEvents + let size = (sizeof(INotifyEvent)+2000)*MaxEvents var buffer = newString(size) let le = read(fd, addr(buffer[0]), size) @@ -117,7 +117,7 @@ proc getEvent(m: FSMonitor, fd: cint): seq[MonitorEvent] = var i = 0 while i < le: - var event = cast[ptr TINotifyEvent](addr(buffer[i])) + var event = cast[ptr INotifyEvent](addr(buffer[i])) var mev: MonitorEvent mev.wd = event.wd if event.len.int != 0: @@ -129,7 +129,7 @@ proc getEvent(m: FSMonitor, fd: cint): seq[MonitorEvent] = if (event.mask.int and IN_MOVED_FROM) != 0: # Moved from event, add to m's collection movedFrom.add(event.cookie.cint, (mev.wd, mev.name)) - inc(i, sizeof(TINotifyEvent) + event.len.int) + inc(i, sizeof(INotifyEvent) + event.len.int) continue elif (event.mask.int and IN_MOVED_TO) != 0: mev.kind = MonitorMoved @@ -159,7 +159,7 @@ proc getEvent(m: FSMonitor, fd: cint): seq[MonitorEvent] = mev.fullname = "" result.add(mev) - inc(i, sizeof(TINotifyEvent) + event.len.int) + inc(i, sizeof(INotifyEvent) + event.len.int) # If movedFrom events have not been matched with a moveTo. File has # been moved to an unwatched location, emit a MonitorDelete. diff --git a/lib/pure/gentabs.nim b/lib/pure/gentabs.nim index 84d0a44de..e6a05ec63 100644 --- a/lib/pure/gentabs.nim +++ b/lib/pure/gentabs.nim @@ -18,20 +18,22 @@ import os, hashes, strutils type - TGenTableMode* = enum ## describes the table's key matching mode + GenTableMode* = enum ## describes the table's key matching mode modeCaseSensitive, ## case sensitive matching of keys modeCaseInsensitive, ## case insensitive matching of keys modeStyleInsensitive ## style sensitive matching of keys - TGenKeyValuePair[T] = tuple[key: string, val: T] - TGenKeyValuePairSeq[T] = seq[TGenKeyValuePair[T]] - TGenTable*[T] = object of RootObj + GenKeyValuePair[T] = tuple[key: string, val: T] + GenKeyValuePairSeq[T] = seq[GenKeyValuePair[T]] + GenTable*[T] = object of RootObj counter: int - data: TGenKeyValuePairSeq[T] - mode: TGenTableMode + data: GenKeyValuePairSeq[T] + mode: GenTableMode - PGenTable*[T] = ref TGenTable[T] ## use this type to declare hash tables + PGenTable*[T] = ref GenTable[T] ## use this type to declare hash tables +{.deprecated: [TGenTableMode: GenTableMode, TGenKeyValuePair: GenKeyValuePair, + TGenKeyValuePairSeq: GenKeyValuePairSeq, TGenTable: GenTable].} const growthFactor = 2 @@ -48,7 +50,7 @@ iterator pairs*[T](tbl: PGenTable[T]): tuple[key: string, value: T] = if not isNil(tbl.data[h].key): yield (tbl.data[h].key, tbl.data[h].val) -proc myhash[T](tbl: PGenTable[T], key: string): THash = +proc myhash[T](tbl: PGenTable[T], key: string): Hash = case tbl.mode of modeCaseSensitive: result = hashes.hash(key) of modeCaseInsensitive: result = hashes.hashIgnoreCase(key) @@ -64,18 +66,18 @@ proc mustRehash(length, counter: int): bool = assert(length > counter) result = (length * 2 < counter * 3) or (length - counter < 4) -proc newGenTable*[T](mode: TGenTableMode): PGenTable[T] = +proc newGenTable*[T](mode: GenTableMode): PGenTable[T] = ## creates a new generic hash table that is empty. new(result) result.mode = mode result.counter = 0 newSeq(result.data, startSize) -proc nextTry(h, maxHash: THash): THash {.inline.} = +proc nextTry(h, maxHash: Hash): Hash {.inline.} = result = ((5 * h) + 1) and maxHash proc rawGet[T](tbl: PGenTable[T], key: string): int = - var h: THash + var h: Hash h = myhash(tbl, key) and high(tbl.data) # start with real hash value while not isNil(tbl.data[h].key): if myCmp(tbl, tbl.data[h].key, key): @@ -83,9 +85,9 @@ proc rawGet[T](tbl: PGenTable[T], key: string): int = h = nextTry(h, high(tbl.data)) result = - 1 -proc rawInsert[T](tbl: PGenTable[T], data: var TGenKeyValuePairSeq[T], +proc rawInsert[T](tbl: PGenTable[T], data: var GenKeyValuePairSeq[T], key: string, val: T) = - var h: THash + var h: Hash h = myhash(tbl, key) and high(data) while not isNil(data[h].key): h = nextTry(h, high(data)) @@ -93,7 +95,7 @@ proc rawInsert[T](tbl: PGenTable[T], data: var TGenKeyValuePairSeq[T], data[h].val = val proc enlarge[T](tbl: PGenTable[T]) = - var n: TGenKeyValuePairSeq[T] + var n: GenKeyValuePairSeq[T] newSeq(n, len(tbl.data) * growthFactor) for i in countup(0, high(tbl.data)): if not isNil(tbl.data[i].key): @@ -146,19 +148,20 @@ when isMainModule: # Verify a table of user-defined types # type - TMyType = tuple[first, second: string] # a pair of strings + MyType = tuple[first, second: string] # a pair of strings + {.deprecated: [TMyType: MyType].} - var y = newGenTable[TMyType](modeCaseInsensitive) # hash table where each - # value is TMyType tuple + var y = newGenTable[MyType](modeCaseInsensitive) # hash table where each + # value is MyType tuple - #var junk: TMyType = ("OK", "Here") + #var junk: MyType = ("OK", "Here") #echo junk.first, " ", junk.second y["Hello"] = ("Hello", "World") y["Goodbye"] = ("Goodbye", "Everyone") - #y["Hello"] = TMyType( ("Hello", "World") ) - #y["Goodbye"] = TMyType( ("Goodbye", "Everyone") ) + #y["Hello"] = MyType( ("Hello", "World") ) + #y["Goodbye"] = MyType( ("Goodbye", "Everyone") ) assert( not isNil(y["Hello"].first) ) assert( y["Hello"].first == "Hello" ) diff --git a/lib/pure/hashes.nim b/lib/pure/hashes.nim index a16342d44..c303c7b4b 100644 --- a/lib/pure/hashes.nim +++ b/lib/pure/hashes.nim @@ -15,9 +15,9 @@ ## code: ## ## .. code-block:: Nim -## proc hash(x: Something): THash = -## ## Computes a THash from `x`. -## var h: THash = 0 +## proc hash(x: Something): Hash = +## ## Computes a Hash from `x`. +## var h: Hash = 0 ## # Iterate over parts of `x`. ## for xAtom in x: ## # Mix the atom with the partial hash. @@ -30,38 +30,39 @@ ## together the hash value of the individual fields: ## ## .. code-block:: Nim -## proc hash(x: Something): THash = -## ## Computes a THash from `x`. -## var h: THash = 0 +## proc hash(x: Something): Hash = +## ## Computes a Hash from `x`. +## var h: Hash = 0 ## h = h !& hash(x.foo) ## h = h !& hash(x.bar) ## result = !$h -import - strutils +import + strutils, etcpriv -type - THash* = int ## a hash value; hash tables using these values should +type + Hash* = int ## a hash value; hash tables using these values should ## always have a size of a power of two and can use the ``and`` ## operator instead of ``mod`` for truncation of the hash value. +{.deprecated: [THash: Hash].} -proc `!&`*(h: THash, val: int): THash {.inline.} = +proc `!&`*(h: Hash, val: int): Hash {.inline.} = ## mixes a hash value `h` with `val` to produce a new hash value. This is ## only needed if you need to implement a hash proc for a new datatype. result = h +% val result = result +% result shl 10 result = result xor (result shr 6) -proc `!$`*(h: THash): THash {.inline.} = +proc `!$`*(h: Hash): Hash {.inline.} = ## finishes the computation of the hash value. This is ## only needed if you need to implement a hash proc for a new datatype. result = h +% h shl 3 result = result xor (result shr 11) result = result +% result shl 15 -proc hashData*(data: pointer, size: int): THash = +proc hashData*(data: pointer, size: int): Hash = ## hashes an array of bytes of size `size` - var h: THash = 0 + var h: Hash = 0 when defined(js): var p: cstring asm """`p` = `Data`;""" @@ -69,7 +70,7 @@ proc hashData*(data: pointer, size: int): THash = var p = cast[cstring](data) var i = 0 var s = size - while s > 0: + while s > 0: h = h !& ord(p[i]) inc(i) dec(s) @@ -78,7 +79,7 @@ proc hashData*(data: pointer, size: int): THash = when defined(js): var objectID = 0 -proc hash*(x: pointer): THash {.inline.} = +proc hash*(x: pointer): Hash {.inline.} = ## efficient hashing of pointers when defined(js): asm """ @@ -92,71 +93,86 @@ proc hash*(x: pointer): THash {.inline.} = } """ else: - result = (cast[THash](x)) shr 3 # skip the alignment - + result = (cast[Hash](x)) shr 3 # skip the alignment + when not defined(booting): - proc hash*[T: proc](x: T): THash {.inline.} = + proc hash*[T: proc](x: T): Hash {.inline.} = ## efficient hashing of proc vars; closures are supported too. when T is "closure": result = hash(rawProc(x)) !& hash(rawEnv(x)) else: result = hash(pointer(x)) - -proc hash*(x: int): THash {.inline.} = + +proc hash*(x: int): Hash {.inline.} = ## efficient hashing of integers result = x -proc hash*(x: int64): THash {.inline.} = +proc hash*(x: int64): Hash {.inline.} = ## efficient hashing of integers result = toU32(x) -proc hash*(x: char): THash {.inline.} = +proc hash*(x: char): Hash {.inline.} = ## efficient hashing of characters result = ord(x) -proc hash*(x: string): THash = +proc hash*(x: string): Hash = ## efficient hashing of strings - var h: THash = 0 - for i in 0..x.len-1: + var h: Hash = 0 + for i in 0..x.len-1: h = h !& ord(x[i]) result = !$h - -proc hashIgnoreStyle*(x: string): THash = + +proc hashIgnoreStyle*(x: string): Hash = ## efficient hashing of strings; style is ignored - var h: THash = 0 - for i in 0..x.len-1: + var h: Hash = 0 + var i = 0 + let xLen = x.len + while i < xLen: var c = x[i] - if c == '_': - continue # skip _ - if c in {'A'..'Z'}: - c = chr(ord(c) + (ord('a') - ord('A'))) # toLower() - h = h !& ord(c) + if c == '_': + inc(i) + elif isMagicIdentSeparatorRune(cstring(x), i): + inc(i, magicIdentSeparatorRuneByteWidth) + else: + if c in {'A'..'Z'}: + c = chr(ord(c) + (ord('a') - ord('A'))) # toLower() + h = h !& ord(c) + inc(i) + result = !$h -proc hashIgnoreCase*(x: string): THash = +proc hashIgnoreCase*(x: string): Hash = ## efficient hashing of strings; case is ignored - var h: THash = 0 - for i in 0..x.len-1: + var h: Hash = 0 + for i in 0..x.len-1: var c = x[i] - if c in {'A'..'Z'}: + if c in {'A'..'Z'}: c = chr(ord(c) + (ord('a') - ord('A'))) # toLower() h = h !& ord(c) result = !$h - -proc hash*[T: tuple](x: T): THash = + +proc hash*(x: float): Hash {.inline.} = + var y = x + 1.0 + result = cast[ptr Hash](addr(y))[] + + +# Forward declarations before methods that hash containers. This allows +# containers to contain other containers +proc hash*[A](x: openArray[A]): Hash +proc hash*[A](x: set[A]): Hash + + +proc hash*[T: tuple](x: T): Hash = ## efficient hashing of tuples. for f in fields(x): result = result !& hash(f) result = !$result -proc hash*(x: float): THash {.inline.} = - var y = x + 1.0 - result = cast[ptr THash](addr(y))[] - -proc hash*[A](x: openArray[A]): THash = +proc hash*[A](x: openArray[A]): Hash = for it in items(x): result = result !& hash(it) result = !$result -proc hash*[A](x: set[A]): THash = +proc hash*[A](x: set[A]): Hash = for it in items(x): result = result !& hash(it) result = !$result + diff --git a/lib/pure/htmlparser.nim b/lib/pure/htmlparser.nim index 9719181b8..a0e2ecd9b 100644 --- a/lib/pure/htmlparser.nim +++ b/lib/pure/htmlparser.nim @@ -52,7 +52,7 @@ import strutils, streams, parsexml, xmltree, unicode, strtabs type - THtmlTag* = enum ## list of all supported HTML tags; order will always be + HtmlTag* = enum ## list of all supported HTML tags; order will always be ## alphabetically tagUnknown, ## unknown HTML element tagA, ## the HTML ``a`` element @@ -178,6 +178,7 @@ type tagVar, ## the HTML ``var`` element tagVideo, ## the HTML ``video`` element tagWbr ## the HTML ``wbr`` element +{.deprecated: [THtmlTag: HtmlTag].} const tagToStr* = [ @@ -295,7 +296,7 @@ proc allLower(s: string): bool = if c < 'a' or c > 'z': return false return true -proc toHtmlTag(s: string): THtmlTag = +proc toHtmlTag(s: string): HtmlTag = case s of "a": tagA of "abbr": tagAbbr @@ -422,14 +423,14 @@ proc toHtmlTag(s: string): THtmlTag = of "wbr": tagWbr else: tagUnknown -proc htmlTag*(n: XmlNode): THtmlTag = - ## gets `n`'s tag as a ``THtmlTag``. +proc htmlTag*(n: XmlNode): HtmlTag = + ## gets `n`'s tag as a ``HtmlTag``. if n.clientData == 0: n.clientData = toHtmlTag(n.tag).ord - result = THtmlTag(n.clientData) + result = HtmlTag(n.clientData) -proc htmlTag*(s: string): THtmlTag = - ## converts `s` to a ``THtmlTag``. If `s` is no HTML tag, ``tagUnknown`` is +proc htmlTag*(s: string): HtmlTag = + ## converts `s` to a ``HtmlTag``. If `s` is no HTML tag, ``tagUnknown`` is ## returned. let s = if allLower(s): s else: s.toLower result = toHtmlTag(s) diff --git a/lib/pure/httpclient.nim b/lib/pure/httpclient.nim index 9c27ecdab..e083d44ea 100644 --- a/lib/pure/httpclient.nim +++ b/lib/pure/httpclient.nim @@ -64,7 +64,7 @@ ## ======== ## Currently all functions support an optional timeout, by default the timeout is set to ## `-1` which means that the function will never time out. The timeout is -## measured in miliseconds, once it is set any call on a socket which may +## measured in milliseconds, once it is set any call on a socket which may ## block will be susceptible to this timeout, however please remember that the ## function as a whole can take longer than the specified timeout, only ## individual internal calls on the socket are affected. In practice this means @@ -386,7 +386,7 @@ proc request*(url: string, httpMethod: string, extraHeaders = "", ## | Requests ``url`` with the custom method string specified by the ## | ``httpMethod`` parameter. ## | Extra headers can be specified and must be separated by ``\c\L`` - ## | An optional timeout can be specified in miliseconds, if reading from the + ## | An optional timeout can be specified in milliseconds, if reading from the ## server takes longer than specified an ETimeout exception will be raised. var r = if proxy == nil: parseUri(url) else: proxy.url var headers = substr(httpMethod, len("http")) @@ -440,7 +440,7 @@ proc request*(url: string, httpMethod = httpGET, extraHeaders = "", userAgent = defUserAgent, proxy: Proxy = nil): Response = ## | Requests ``url`` with the specified ``httpMethod``. ## | Extra headers can be specified and must be separated by ``\c\L`` - ## | An optional timeout can be specified in miliseconds, if reading from the + ## | An optional timeout can be specified in milliseconds, if reading from the ## server takes longer than specified an ETimeout exception will be raised. result = request(url, $httpMethod, extraHeaders, body, sslContext, timeout, userAgent, proxy) @@ -467,7 +467,7 @@ proc get*(url: string, extraHeaders = "", maxRedirects = 5, ## | GETs the ``url`` and returns a ``Response`` object ## | This proc also handles redirection ## | Extra headers can be specified and must be separated by ``\c\L``. - ## | An optional timeout can be specified in miliseconds, if reading from the + ## | An optional timeout can be specified in milliseconds, if reading from the ## server takes longer than specified an ETimeout exception will be raised. result = request(url, httpGET, extraHeaders, "", sslContext, timeout, userAgent, proxy) @@ -486,7 +486,7 @@ proc getContent*(url: string, extraHeaders = "", maxRedirects = 5, ## | GETs the body and returns it as a string. ## | Raises exceptions for the status codes ``4xx`` and ``5xx`` ## | Extra headers can be specified and must be separated by ``\c\L``. - ## | An optional timeout can be specified in miliseconds, if reading from the + ## | An optional timeout can be specified in milliseconds, if reading from the ## server takes longer than specified an ETimeout exception will be raised. var r = get(url, extraHeaders, maxRedirects, sslContext, timeout, userAgent, proxy) @@ -505,7 +505,7 @@ proc post*(url: string, extraHeaders = "", body = "", ## | This proc adds the necessary Content-Length header. ## | This proc also handles redirection. ## | Extra headers can be specified and must be separated by ``\c\L``. - ## | An optional timeout can be specified in miliseconds, if reading from the + ## | An optional timeout can be specified in milliseconds, if reading from the ## server takes longer than specified an ETimeout exception will be raised. ## | The optional ``multipart`` parameter can be used to create ## ``multipart/form-data`` POSTs comfortably. @@ -542,7 +542,7 @@ proc postContent*(url: string, extraHeaders = "", body = "", ## | POSTs ``body`` to ``url`` and returns the response's body as a string ## | Raises exceptions for the status codes ``4xx`` and ``5xx`` ## | Extra headers can be specified and must be separated by ``\c\L``. - ## | An optional timeout can be specified in miliseconds, if reading from the + ## | An optional timeout can be specified in milliseconds, if reading from the ## server takes longer than specified an ETimeout exception will be raised. ## | The optional ``multipart`` parameter can be used to create ## ``multipart/form-data`` POSTs comfortably. @@ -558,7 +558,7 @@ proc downloadFile*(url: string, outputFilename: string, timeout = -1, userAgent = defUserAgent, proxy: Proxy = nil) = ## | Downloads ``url`` and saves it to ``outputFilename`` - ## | An optional timeout can be specified in miliseconds, if reading from the + ## | An optional timeout can be specified in milliseconds, if reading from the ## server takes longer than specified an ETimeout exception will be raised. var f: File if open(f, outputFilename, fmWrite): diff --git a/lib/pure/httpserver.nim b/lib/pure/httpserver.nim index dc76c9228..981891227 100644 --- a/lib/pure/httpserver.nim +++ b/lib/pure/httpserver.nim @@ -106,9 +106,10 @@ proc serveFile*(client: Socket, filename: string) = when false: # TODO: Fix this, or get rid of it. type - TRequestMethod = enum reqGet, reqPost + RequestMethod = enum reqGet, reqPost + {.deprecated: [TRequestMethod: RequestMethod].} - proc executeCgi(client: Socket, path, query: string, meth: TRequestMethod) = + proc executeCgi(client: Socket, path, query: string, meth: RequestMethod) = var env = newStringTable(modeCaseInsensitive) var contentLength = -1 case meth @@ -208,7 +209,7 @@ when false: executeCgi(client, path, query, meth) type - TServer* = object of RootObj ## contains the current server state + Server* = object of RootObj ## contains the current server state socket: Socket port: Port client*: Socket ## the socket to write the file data to @@ -218,11 +219,12 @@ type body*: string ## only set with POST requests ip*: string ## ip address of the requesting client - PAsyncHTTPServer* = ref TAsyncHTTPServer - TAsyncHTTPServer = object of TServer + PAsyncHTTPServer* = ref AsyncHTTPServer + AsyncHTTPServer = object of Server asyncSocket: AsyncSocket +{.deprecated: [TAsyncHTTPServer: AsyncHTTPServer, TServer: Server].} -proc open*(s: var TServer, port = Port(80), reuseAddr = false) = +proc open*(s: var Server, port = Port(80), reuseAddr = false) = ## creates a new server at port `port`. If ``port == 0`` a free port is ## acquired that can be accessed later by the ``port`` proc. s.socket = socket(AF_INET) @@ -243,11 +245,11 @@ proc open*(s: var TServer, port = Port(80), reuseAddr = false) = s.query = "" s.headers = {:}.newStringTable() -proc port*(s: var TServer): Port = +proc port*(s: var Server): Port = ## get the port number the server has acquired. result = s.port -proc next*(s: var TServer) = +proc next*(s: var Server) = ## proceed to the first/next request. var client: Socket new(client) @@ -354,7 +356,7 @@ proc next*(s: var TServer) = s.query = "" s.path = data.substr(i, last-1) -proc close*(s: TServer) = +proc close*(s: Server) = ## closes the server (and the socket the server uses). close(s.socket) @@ -362,7 +364,7 @@ proc run*(handleRequest: proc (client: Socket, path, query: string): bool {.closure.}, port = Port(80)) = ## encapsulates the server object and main loop - var s: TServer + var s: Server open(s, port, reuseAddr = true) #echo("httpserver running on port ", s.port) while true: @@ -517,7 +519,7 @@ proc close*(h: PAsyncHTTPServer) = when not defined(testing) and isMainModule: var counter = 0 - var s: TServer + var s: Server open(s, Port(0)) echo("httpserver running on port ", s.port) while true: diff --git a/lib/pure/json.nim b/lib/pure/json.nim index 5d824d6f8..49915b7e9 100644 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -68,7 +68,7 @@ type jsonArrayStart, ## start of an array: the ``[`` token jsonArrayEnd ## start of an array: the ``]`` token - TTokKind = enum # must be synchronized with TJsonEventKind! + TokKind = enum # must be synchronized with TJsonEventKind! tkError, tkEof, tkString, @@ -103,14 +103,14 @@ type JsonParser* = object of BaseLexer ## the parser object. a: string - tok: TTokKind + tok: TokKind kind: JsonEventKind err: JsonError state: seq[ParserState] filename: string {.deprecated: [TJsonEventKind: JsonEventKind, TJsonError: JsonError, - TJsonParser: JsonParser].} + TJsonParser: JsonParser, TTokKind: TokKind].} const errorMessages: array [JsonError, string] = [ @@ -126,7 +126,7 @@ const "EOF expected", "expression expected" ] - tokToStr: array [TTokKind, string] = [ + tokToStr: array [TokKind, string] = [ "invalid token", "EOF", "string literal", @@ -203,7 +203,7 @@ proc handleHexChar(c: char, x: var int): bool = of 'A'..'F': x = (x shl 4) or (ord(c) - ord('A') + 10) else: result = false # error -proc parseString(my: var JsonParser): TTokKind = +proc parseString(my: var JsonParser): TokKind = result = tkString var pos = my.bufpos + 1 var buf = my.buf @@ -359,7 +359,7 @@ proc parseName(my: var JsonParser) = inc(pos) my.bufpos = pos -proc getTok(my: var JsonParser): TTokKind = +proc getTok(my: var JsonParser): TokKind = setLen(my.a, 0) skip(my) # skip whitespace, comments case my.buf[my.bufpos] @@ -734,7 +734,7 @@ proc `==`* (a,b: JsonNode): bool = of JObject: a.fields == b.fields -proc hash* (n:JsonNode): THash = +proc hash* (n:JsonNode): Hash = ## Compute the hash for a JSON node case n.kind of JArray: @@ -761,7 +761,7 @@ proc len*(n: JsonNode): int = of JObject: result = n.fields.len else: discard -proc `[]`*(node: JsonNode, name: string): JsonNode = +proc `[]`*(node: JsonNode, name: string): JsonNode {.inline.} = ## Gets a field from a `JObject`, which must not be nil. ## If the value at `name` does not exist, returns nil assert(not isNil(node)) @@ -771,7 +771,7 @@ proc `[]`*(node: JsonNode, name: string): JsonNode = return item return nil -proc `[]`*(node: JsonNode, index: int): JsonNode = +proc `[]`*(node: JsonNode, index: int): JsonNode {.inline.} = ## Gets the node at `index` in an Array. Result is undefined if `index` ## is out of bounds assert(not isNil(node)) @@ -799,7 +799,7 @@ proc add*(obj: JsonNode, key: string, val: JsonNode) = assert obj.kind == JObject obj.fields.add((key, val)) -proc `[]=`*(obj: JsonNode, key: string, val: JsonNode) = +proc `[]=`*(obj: JsonNode, key: string, val: JsonNode) {.inline.} = ## Sets a field from a `JObject`. Performs a check for duplicate keys. assert(obj.kind == JObject) for i in 0..obj.fields.len-1: @@ -815,7 +815,7 @@ proc `{}`*(node: JsonNode, keys: varargs[string]): JsonNode = result = node for key in keys: if isNil(result) or result.kind!=JObject: - return nil + return nil result=result[key] proc `{}=`*(node: JsonNode, keys: varargs[string], value: JsonNode) = @@ -949,10 +949,46 @@ proc pretty*(node: JsonNode, indent = 2): string = result = "" toPretty(result, node, indent) +proc toUgly*(result: var string, node: JsonNode) = + ## Converts `node` to its JSON Representation, without + ## regard for human readability. Meant to improve ``$`` string + ## conversion performance. + ## + ## This provides higher efficiency than the ``toPretty`` procedure as it + ## does **not** attempt to format the resulting JSON to make it human readable. + var comma = false + case node.kind: + of JArray: + result.add "[" + for child in node.elems: + if comma: result.add "," + else: comma = true + result.toUgly child + result.add "]" + of JObject: + result.add "{" + for key, value in items(node.fields): + if comma: result.add "," + else: comma = true + result.add key.escapeJson() + result.add ":" + result.toUgly value + result.add "}" + of JString: + result.add node.str.escapeJson() + of JInt: + result.add($node.num) + of JFloat: + result.add($node.fnum) + of JBool: + result.add(if node.bval: "true" else: "false") + of JNull: + result.add "null" + proc `$`*(node: JsonNode): string = ## Converts `node` to its JSON Representation on one line. - result = "" - toPretty(result, node, 0, false) + result = newStringOfCap(node.len shl 1) + toUgly(result, node) iterator items*(node: JsonNode): JsonNode = ## Iterator for the items of `node`. `node` has to be a JArray. @@ -980,7 +1016,7 @@ iterator mpairs*(node: var JsonNode): var tuple[key: string, val: JsonNode] = for keyVal in mitems(node.fields): yield keyVal -proc eat(p: var JsonParser, tok: TTokKind) = +proc eat(p: var JsonParser, tok: TokKind) = if p.tok == tok: discard getTok(p) else: raiseParseErr(p, tokToStr[tok]) @@ -1055,8 +1091,10 @@ when not defined(js): else: from math import `mod` type - TJSObject = object - proc parseNativeJson(x: cstring): TJSObject {.importc: "JSON.parse".} + JSObject = object + {.deprecated: [TJSObject: JSObject].} + + proc parseNativeJson(x: cstring): JSObject {.importc: "JSON.parse".} proc getVarType(x): JsonNodeKind = result = JNull @@ -1075,25 +1113,25 @@ else: of "[object String]": return JString else: assert false - proc len(x: TJSObject): int = + proc len(x: JSObject): int = assert x.getVarType == JArray asm """ return `x`.length; """ - proc `[]`(x: TJSObject, y: string): TJSObject = + proc `[]`(x: JSObject, y: string): JSObject = assert x.getVarType == JObject asm """ return `x`[`y`]; """ - proc `[]`(x: TJSObject, y: int): TJSObject = + proc `[]`(x: JSObject, y: int): JSObject = assert x.getVarType == JArray asm """ return `x`[`y`]; """ - proc convertObject(x: TJSObject): JsonNode = + proc convertObject(x: JSObject): JsonNode = case getVarType(x) of JArray: result = newJArray() @@ -1105,7 +1143,7 @@ else: if (`x`.hasOwnProperty(property)) { """ var nimProperty: cstring - var nimValue: TJSObject + var nimValue: JSObject asm "`nimProperty` = property; `nimValue` = `x`[property];" result[$nimProperty] = nimValue.convertObject() asm "}}" @@ -1151,24 +1189,13 @@ when false: # To get that we shall use, obj["json"] when isMainModule: - #var node = parse("{ \"test\": null }") - #echo(node.existsKey("test56")) - var parsed = parseFile("tests/testdata/jsontest.json") var parsed2 = parseFile("tests/testdata/jsontest2.json") - when not defined(testing): - echo(parsed) - echo() - echo(pretty(parsed, 2)) - echo() - echo(parsed["keyÄÖöoßß"]) - echo() - echo(pretty(parsed2)) - try: - echo(parsed["key2"][12123]) - raise newException(ValueError, "That line was expected to fail") - except IndexError: echo() + try: + discard parsed["key2"][12123] + assert(false) + except IndexError: assert(true) let testJson = parseJson"""{ "a": [1, 2, 3, 4], "b": "asd" }""" # nil passthrough @@ -1176,6 +1203,11 @@ when isMainModule: testJson{["c", "d"]} = %true assert(testJson["c"]["d"].bval) + # test `$` + let stringified = $testJson + let parsedAgain = parseJson(stringified) + assert(parsedAgain["b"].str == "asd") + # Bounds checking try: let a = testJson["a"][9] @@ -1192,17 +1224,17 @@ when isMainModule: except: assert(false, "EInvalidIndex thrown for valid index") - assert(testJson{"b"}.str=="asd", "Couldn't fetch a singly nested key with {}") - assert(isNil(testJson{"nonexistent"}), "Non-existent keys should return nil") + assert(testJson{"b"}.str=="asd", "Couldn't fetch a singly nested key with {}") + assert(isNil(testJson{"nonexistent"}), "Non-existent keys should return nil") assert(parsed2{"repository", "description"}.str=="IRC Library for Haskell", "Couldn't fetch via multiply nested key using {}") assert(isNil(testJson{"a", "b"}), "Indexing through a list should return nil") assert(isNil(testJson{"a", "b"}), "Indexing through a list should return nil") assert(testJson{"a"}==parseJson"[1, 2, 3, 4]", "Didn't return a non-JObject when there was one to be found") assert(isNil(parseJson("[1, 2, 3]"){"foo"}), "Indexing directly into a list should return nil") - + # Generator: var j = %* [{"name": "John", "age": 30}, {"name": "Susan", "age": 31}] - assert j == %[%{"name": %"John", "age": %30}, %{"name": %"Susan", "age": %31}] + assert j == %[%{"name": %"John", "age": %30}, %{"name": %"Susan", "age": %31}] var j2 = %* [ @@ -1230,13 +1262,3 @@ when isMainModule: } ] assert j3 == %[%{"name": %"John", "age": %30}, %{"name": %"Susan", "age": %31}] - - when not defined(testing): - discard """ - while true: - var json = stdin.readLine() - var node = parse(json) - echo(node) - echo() - echo() - """ diff --git a/lib/pure/lexbase.nim b/lib/pure/lexbase.nim index 23a87d9f8..585ba87f5 100644 --- a/lib/pure/lexbase.nim +++ b/lib/pure/lexbase.nim @@ -39,7 +39,7 @@ type {.deprecated: [TBaseLexer: BaseLexer].} proc open*(L: var BaseLexer, input: Stream, bufLen: int = 8192) - ## inits the TBaseLexer with a stream to read from + ## inits the BaseLexer with a stream to read from proc close*(L: var BaseLexer) ## closes the base lexer. This closes `L`'s associated stream too. diff --git a/lib/pure/logging.nim b/lib/pure/logging.nim index a2ea53472..379c18e9d 100644 --- a/lib/pure/logging.nim +++ b/lib/pure/logging.nim @@ -66,7 +66,7 @@ type Logger* = ref object of RootObj ## abstract logger; the base type of all loggers levelThreshold*: Level ## only messages of level >= levelThreshold ## should be processed - fmtStr: string ## = defaultFmtStr by default, see substituteLog for $date etc. + fmtStr*: string ## = defaultFmtStr by default, see substituteLog for $date etc. ConsoleLogger* = ref object of Logger ## logger that writes the messages to the ## console @@ -82,6 +82,7 @@ type baseName: string # initial filename baseMode: FileMode # initial file mode logFiles: int # how many log files already created, e.g. basename.1, basename.2... + bufSize: int # size of output buffer (-1: use system defaults, 0: unbuffered, >0: fixed buffer size) {.deprecated: [TLevel: Level, PLogger: Logger, PConsoleLogger: ConsoleLogger, PFileLogger: FileLogger, PRollingFileLogger: RollingFileLogger].} @@ -112,27 +113,22 @@ proc substituteLog(frmt: string): string = of "appname": result.add(app.splitFile.name) else: discard -method log*(logger: Logger, level: Level, - frmt: string, args: varargs[string, `$`]) {. +method log*(logger: Logger, level: Level, args: varargs[string, `$`]) {. raises: [Exception], tags: [TimeEffect, WriteIOEffect, ReadIOEffect].} = ## Override this method in custom loggers. Default implementation does ## nothing. discard -method log*(logger: ConsoleLogger, level: Level, - frmt: string, args: varargs[string, `$`]) = +method log*(logger: ConsoleLogger, level: Level, args: varargs[string, `$`]) = ## Logs to the console using ``logger`` only. if level >= logger.levelThreshold: - writeln(stdout, LevelNames[level], " ", substituteLog(logger.fmtStr), - frmt % args) + writeln(stdout, LevelNames[level], " ", substituteLog(logger.fmtStr), args) -method log*(logger: FileLogger, level: Level, - frmt: string, args: varargs[string, `$`]) = +method log*(logger: FileLogger, level: Level, args: varargs[string, `$`]) = ## Logs to a file using ``logger`` only. if level >= logger.levelThreshold: - writeln(logger.f, LevelNames[level], " ", - substituteLog(logger.fmtStr), frmt % args) + writeln(logger.f, LevelNames[level], " ", substituteLog(logger.fmtStr), args) proc defaultFilename*(): string = ## Returns the default filename for a logger. @@ -148,11 +144,14 @@ proc newConsoleLogger*(levelThreshold = lvlAll, fmtStr = defaultFmtStr): Console proc newFileLogger*(filename = defaultFilename(), mode: FileMode = fmAppend, levelThreshold = lvlAll, - fmtStr = defaultFmtStr): FileLogger = + fmtStr = defaultFmtStr, + bufSize: int = -1): FileLogger = ## Creates a new file logger. This logger logs to a file. + ## Use ``bufSize`` as size of the output buffer when writing the file + ## (-1: use system defaults, 0: unbuffered, >0: fixed buffer size). new(result) result.levelThreshold = levelThreshold - result.f = open(filename, mode) + result.f = open(filename, mode, bufSize = bufSize) result.fmtStr = fmtStr # ------ @@ -181,14 +180,18 @@ proc newRollingFileLogger*(filename = defaultFilename(), mode: FileMode = fmReadWrite, levelThreshold = lvlAll, fmtStr = defaultFmtStr, - maxLines = 1000): RollingFileLogger = + maxLines = 1000, + bufSize: int = -1): RollingFileLogger = ## Creates a new rolling file logger. Once a file reaches ``maxLines`` lines ## a new log file will be started and the old will be renamed. + ## Use ``bufSize`` as size of the output buffer when writing the file + ## (-1: use system defaults, 0: unbuffered, >0: fixed buffer size). new(result) result.levelThreshold = levelThreshold result.fmtStr = fmtStr result.maxLines = maxLines - result.f = open(filename, mode) + result.bufSize = bufSize + result.f = open(filename, mode, bufSize=result.bufSize) result.curLine = 0 result.baseName = filename result.baseMode = mode @@ -206,8 +209,7 @@ proc rotate(logger: RollingFileLogger) = moveFile(dir / (name & ext & srcSuff), dir / (name & ext & ExtSep & $(i+1))) -method log*(logger: RollingFileLogger, level: Level, - frmt: string, args: varargs[string, `$`]) = +method log*(logger: RollingFileLogger, level: Level, args: varargs[string, `$`]) = ## Logs to a file using rolling ``logger`` only. if level >= logger.levelThreshold: if logger.curLine >= logger.maxLines: @@ -215,9 +217,9 @@ method log*(logger: RollingFileLogger, level: Level, rotate(logger) logger.logFiles.inc logger.curLine = 0 - logger.f = open(logger.baseName, logger.baseMode) + logger.f = open(logger.baseName, logger.baseMode, bufSize = logger.bufSize) - writeln(logger.f, LevelNames[level], " ",substituteLog(logger.fmtStr), frmt % args) + writeln(logger.f, LevelNames[level], " ", substituteLog(logger.fmtStr), args) logger.curLine.inc # -------- @@ -225,39 +227,39 @@ method log*(logger: RollingFileLogger, level: Level, var level {.threadvar.}: Level ## global log filter var handlers {.threadvar.}: seq[Logger] ## handlers with their own log levels -proc logLoop(level: Level, frmt: string, args: varargs[string, `$`]) = +proc logLoop(level: Level, args: varargs[string, `$`]) = for logger in items(handlers): if level >= logger.levelThreshold: - log(logger, level, frmt, args) + log(logger, level, args) -template log*(level: Level, frmt: string, args: varargs[string, `$`]) = +template log*(level: Level, args: varargs[string, `$`]) = ## Logs a message to all registered handlers at the given level. bind logLoop bind `%` bind logging.level if level >= logging.level: - logLoop(level, frmt, args) + logLoop(level, args) -template debug*(frmt: string, args: varargs[string, `$`]) = +template debug*(args: varargs[string, `$`]) = ## Logs a debug message to all registered handlers. - log(lvlDebug, frmt, args) + log(lvlDebug, args) -template info*(frmt: string, args: varargs[string, `$`]) = +template info*(args: varargs[string, `$`]) = ## Logs an info message to all registered handlers. - log(lvlInfo, frmt, args) + log(lvlInfo, args) -template warn*(frmt: string, args: varargs[string, `$`]) = +template warn*(args: varargs[string, `$`]) = ## Logs a warning message to all registered handlers. - log(lvlWarn, frmt, args) + log(lvlWarn, args) -template error*(frmt: string, args: varargs[string, `$`]) = +template error*(args: varargs[string, `$`]) = ## Logs an error message to all registered handlers. - log(lvlError, frmt, args) + log(lvlError, args) -template fatal*(frmt: string, args: varargs[string, `$`]) = +template fatal*(args: varargs[string, `$`]) = ## Logs a fatal error message to all registered handlers. - log(lvlFatal, frmt, args) + log(lvlFatal, args) proc addHandler*(handler: Logger) = ## Adds ``handler`` to the list of handlers. @@ -286,6 +288,4 @@ when not defined(testing) and isMainModule: addHandler(fL) addHandler(rL) for i in 0 .. 25: - info("hello" & $i, []) - - + info("hello", i) diff --git a/lib/pure/marshal.nim b/lib/pure/marshal.nim index e0092f314..49f049e46 100644 --- a/lib/pure/marshal.nim +++ b/lib/pure/marshal.nim @@ -17,13 +17,13 @@ ## .. code-block:: nim ## ## type -## TA = object -## TB = object of TA +## A = object +## B = object of A ## f: int ## ## var -## a: ref TA -## b: ref TB +## a: ref A +## b: ref B ## ## new(b) ## a = b @@ -36,7 +36,7 @@ import streams, typeinfo, json, intsets, tables proc ptrToInt(x: pointer): int {.inline.} = result = cast[int](x) # don't skip alignment -proc storeAny(s: Stream, a: TAny, stored: var IntSet) = +proc storeAny(s: Stream, a: Any, stored: var IntSet) = case a.kind of akNone: assert false of akBool: s.write($getBool(a)) @@ -96,7 +96,7 @@ proc storeAny(s: Stream, a: TAny, stored: var IntSet) = of akInt..akInt64, akUInt..akUInt64: s.write($getBiggestInt(a)) of akFloat..akFloat128: s.write($getBiggestFloat(a)) -proc loadAny(p: var JsonParser, a: TAny, t: var Table[BiggestInt, pointer]) = +proc loadAny(p: var JsonParser, a: Any, t: var Table[BiggestInt, pointer]) = case a.kind of akNone: assert false of akBool: @@ -222,7 +222,7 @@ proc loadAny(p: var JsonParser, a: TAny, t: var Table[BiggestInt, pointer]) = raiseParseErr(p, "float expected") of akRange: loadAny(p, a.skipRange, t) -proc loadAny(s: Stream, a: TAny, t: var Table[BiggestInt, pointer]) = +proc loadAny(s: Stream, a: Any, t: var Table[BiggestInt, pointer]) = var p: JsonParser open(p, s, "unknown file") next(p) @@ -278,10 +278,11 @@ when not defined(testing) and isMainModule: else: nil - PNode = ref TNode - TNode = object + PNode = ref Node + Node = object next, prev: PNode data: string + {.deprecated: [TNode: Node].} proc buildList(): PNode = new(result) @@ -317,14 +318,15 @@ when not defined(testing) and isMainModule: testit(test7) type - TA {.inheritable.} = object - TB = object of TA + A {.inheritable.} = object + B = object of A f: int var - a: ref TA - b: ref TB + a: ref A + b: ref B new(b) a = b echo($$a[]) # produces "{}", not "{f: 0}" + diff --git a/lib/pure/math.nim b/lib/pure/math.nim index daa108460..a9e9010f6 100644 --- a/lib/pure/math.nim +++ b/lib/pure/math.nim @@ -85,7 +85,7 @@ proc fac*(n: int): int {.noSideEffect.} = proc isPowerOfTwo*(x: int): bool {.noSideEffect.} = ## returns true, if `x` is a power of two, false otherwise. ## Zero and negative numbers are not a power of two. - return (x != 0) and ((x and (x - 1)) == 0) + return (x > 0) and ((x and (x - 1)) == 0) proc nextPowerOfTwo*(x: int): int {.noSideEffect.} = ## returns `x` rounded up to the nearest power of two. @@ -114,18 +114,23 @@ proc sum*[T](x: openArray[T]): T {.noSideEffect.} = ## If `x` is empty, 0 is returned. for i in items(x): result = result + i -proc mean*(x: openArray[float]): float {.noSideEffect.} = - ## computes the mean of the elements in `x`. +template toFloat(f: float): float = f + +proc mean*[T](x: openArray[T]): float {.noSideEffect.} = + ## computes the mean of the elements in `x`, which are first converted to floats. ## If `x` is empty, NaN is returned. - result = sum(x) / toFloat(len(x)) + ## ``toFloat(x: T): float`` must be defined. + for i in items(x): result = result + toFloat(i) + result = result / toFloat(len(x)) -proc variance*(x: openArray[float]): float {.noSideEffect.} = +proc variance*[T](x: openArray[T]): float {.noSideEffect.} = ## computes the variance of the elements in `x`. ## If `x` is empty, NaN is returned. + ## ``toFloat(x: T): float`` must be defined. result = 0.0 var m = mean(x) - for i in 0 .. high(x): - var diff = x[i] - m + for i in items(x): + var diff = toFloat(i) - m result = result + diff*diff result = result / toFloat(len(x)) @@ -347,6 +352,9 @@ proc `^`*[T](x, y: T): T = proc gcd*[T](x, y: T): T = ## Computes the greatest common divisor of ``x`` and ``y``. + ## Note that for floats, the result cannot always be interpreted as + ## "greatest decimal `z` such that ``z*N == x and z*M == y`` + ## where N and M are positive integers." var (x,y) = (x,y) while y != 0: x = x mod y diff --git a/lib/pure/memfiles.nim b/lib/pure/memfiles.nim index d49dfae9f..76ff6a8e1 100644 --- a/lib/pure/memfiles.nim +++ b/lib/pure/memfiles.nim @@ -196,7 +196,7 @@ proc open*(filename: string, mode: FileMode = fmRead, if mappedSize != -1: result.size = mappedSize else: - var stat: TStat + var stat: Stat if fstat(result.handle, stat) != -1: # XXX: Hmm, this could be unsafe # Why is mmap taking int anyway? diff --git a/lib/pure/net.nim b/lib/pure/net.nim index ffbc6e320..9ce0669bc 100644 --- a/lib/pure/net.nim +++ b/lib/pure/net.nim @@ -86,7 +86,7 @@ type IPv6, ## IPv6 address IPv4 ## IPv4 address - TIpAddress* = object ## stores an arbitrary IP address + IpAddress* = object ## stores an arbitrary IP address case family*: IpAddressFamily ## the type of the IP address (IPv4 or IPv6) of IpAddressFamily.IPv6: address_v6*: array[0..15, uint8] ## Contains the IP address in bytes in @@ -94,9 +94,10 @@ type of IpAddressFamily.IPv4: address_v4*: array[0..3, uint8] ## Contains the IP address in bytes in ## case of IPv4 +{.deprecated: [TIpAddress: IpAddress].} proc isIpAddress*(address_str: string): bool {.tags: [].} -proc parseIpAddress*(address_str: string): TIpAddress +proc parseIpAddress*(address_str: string): IpAddress proc isDisconnectionError*(flags: set[SocketFlag], lastError: OSErrorCode): bool = @@ -118,13 +119,13 @@ proc toOSFlags*(socketFlags: set[SocketFlag]): cint = result = result or MSG_PEEK of SocketFlag.SafeDisconn: continue -proc newSocket(fd: SocketHandle, isBuff: bool): Socket = +proc newSocket*(fd: SocketHandle, buffered = true): Socket = ## Creates a new socket as specified by the params. assert fd != osInvalidSocket new(result) result.fd = fd - result.isBuffered = isBuff - if isBuff: + result.isBuffered = buffered + if buffered: result.currPos = 0 proc newSocket*(domain, typ, protocol: cint, buffered = true): Socket = @@ -395,7 +396,7 @@ proc acceptAddr*(server: Socket, client: var Socket, address: var string, when false: #defined(ssl): proc acceptAddrSSL*(server: Socket, client: var Socket, - address: var string): TSSLAcceptResult {. + address: var string): SSLAcceptResult {. tags: [ReadIOEffect].} = ## This procedure should only be used for non-blocking **SSL** sockets. ## It will immediately return with one of the following values: @@ -704,7 +705,7 @@ proc waitFor(socket: Socket, waited: var float, timeout, size: int, proc recv*(socket: Socket, data: pointer, size: int, timeout: int): int {. tags: [ReadIOEffect, TimeEffect].} = - ## overload with a ``timeout`` parameter in miliseconds. + ## overload with a ``timeout`` parameter in milliseconds. var waited = 0.0 # number of seconds already waited var read = 0 @@ -729,7 +730,7 @@ proc recv*(socket: Socket, data: var string, size: int, timeout = -1, ## This function will throw an EOS exception when an error occurs. A value ## lower than 0 is never returned. ## - ## A timeout may be specified in miliseconds, if enough data is not received + ## A timeout may be specified in milliseconds, if enough data is not received ## within the time specified an ETimeout exception will be raised. ## ## **Note**: ``data`` must be initialised. @@ -777,7 +778,7 @@ proc readLine*(socket: Socket, line: var TaintedString, timeout = -1, ## ## An EOS exception will be raised in the case of a socket error. ## - ## A timeout can be specified in miliseconds, if data is not received within + ## A timeout can be specified in milliseconds, if data is not received within ## the specified time an ETimeout exception will be raised. ## ## **Warning**: Only the ``SafeDisconn`` flag is currently supported. @@ -844,7 +845,7 @@ proc recvFrom*(socket: Socket, data: var string, length: int, proc skip*(socket: Socket, size: int, timeout = -1) = ## Skips ``size`` amount of bytes. ## - ## An optional timeout can be specified in miliseconds, if skipping the + ## An optional timeout can be specified in milliseconds, if skipping the ## bytes takes longer than specified an ETimeout exception will be raised. ## ## Returns the number of skipped bytes. @@ -967,7 +968,7 @@ proc connect*(socket: Socket, address: string, port = Port(0), timeout: int, af: Domain = AF_INET) {.tags: [ReadIOEffect, WriteIOEffect].} = ## Connects to server as specified by ``address`` on port specified by ``port``. ## - ## The ``timeout`` paremeter specifies the time in miliseconds to allow for + ## The ``timeout`` paremeter specifies the time in milliseconds to allow for ## the connection to the server to be made. socket.fd.setBlocking(false) @@ -992,39 +993,39 @@ proc isSsl*(socket: Socket): bool = proc getFd*(socket: Socket): SocketHandle = return socket.fd ## Returns the socket's file descriptor -proc IPv4_any*(): TIpAddress = +proc IPv4_any*(): IpAddress = ## Returns the IPv4 any address, which can be used to listen on all available ## network adapters - result = TIpAddress( + result = IpAddress( family: IpAddressFamily.IPv4, address_v4: [0'u8, 0, 0, 0]) -proc IPv4_loopback*(): TIpAddress = +proc IPv4_loopback*(): IpAddress = ## Returns the IPv4 loopback address (127.0.0.1) - result = TIpAddress( + result = IpAddress( family: IpAddressFamily.IPv4, address_v4: [127'u8, 0, 0, 1]) -proc IPv4_broadcast*(): TIpAddress = +proc IPv4_broadcast*(): IpAddress = ## Returns the IPv4 broadcast address (255.255.255.255) - result = TIpAddress( + result = IpAddress( family: IpAddressFamily.IPv4, address_v4: [255'u8, 255, 255, 255]) -proc IPv6_any*(): TIpAddress = +proc IPv6_any*(): IpAddress = ## Returns the IPv6 any address (::0), which can be used ## to listen on all available network adapters - result = TIpAddress( + result = IpAddress( family: IpAddressFamily.IPv6, address_v6: [0'u8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) -proc IPv6_loopback*(): TIpAddress = +proc IPv6_loopback*(): IpAddress = ## Returns the IPv6 loopback address (::1) - result = TIpAddress( + result = IpAddress( family: IpAddressFamily.IPv6, address_v6: [0'u8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) -proc `==`*(lhs, rhs: TIpAddress): bool = +proc `==`*(lhs, rhs: IpAddress): bool = ## Compares two IpAddresses for Equality. Returns two if the addresses are equal if lhs.family != rhs.family: return false if lhs.family == IpAddressFamily.IPv4: @@ -1035,8 +1036,8 @@ proc `==`*(lhs, rhs: TIpAddress): bool = if lhs.address_v6[i] != rhs.address_v6[i]: return false return true -proc `$`*(address: TIpAddress): string = - ## Converts an TIpAddress into the textual representation +proc `$`*(address: IpAddress): string = + ## Converts an IpAddress into the textual representation result = "" case address.family of IpAddressFamily.IPv4: @@ -1095,7 +1096,7 @@ proc `$`*(address: TIpAddress): string = mask = mask shr 4 printedLastGroup = true -proc parseIPv4Address(address_str: string): TIpAddress = +proc parseIPv4Address(address_str: string): IpAddress = ## Parses IPv4 adresses ## Raises EInvalidValue on errors var @@ -1129,7 +1130,7 @@ proc parseIPv4Address(address_str: string): TIpAddress = raise newException(ValueError, "Invalid IP Address") result.address_v4[byteCount] = cast[uint8](currentByte) -proc parseIPv6Address(address_str: string): TIpAddress = +proc parseIPv6Address(address_str: string): IpAddress = ## Parses IPv6 adresses ## Raises EInvalidValue on errors result.family = IpAddressFamily.IPv6 @@ -1250,7 +1251,7 @@ proc parseIPv6Address(address_str: string): TIpAddress = raise newException(ValueError, "Invalid IP Address. The address consists of too many groups") -proc parseIpAddress(address_str: string): TIpAddress = +proc parseIpAddress(address_str: string): IpAddress = ## Parses an IP address ## Raises EInvalidValue on error if address_str == nil: diff --git a/lib/pure/nimprof.nim b/lib/pure/nimprof.nim index cce2a20ae..765d1e341 100644 --- a/lib/pure/nimprof.nim +++ b/lib/pure/nimprof.nim @@ -26,17 +26,19 @@ const withThreads = compileOption("threads") tickCountCorrection = 50_000 -when not declared(system.TStackTrace): - type TStackTrace = array [0..20, cstring] +when not declared(system.StackTrace): + type StackTrace = array [0..20, cstring] + {.deprecated: [TStackTrace: StackTrace].} # We use a simple hash table of bounded size to keep track of the stack traces: type - TProfileEntry = object + ProfileEntry = object total: int - st: TStackTrace - TProfileData = array [0..64*1024-1, ptr TProfileEntry] + st: StackTrace + ProfileData = array [0..64*1024-1, ptr ProfileEntry] +{.deprecated: [TProfileEntry: ProfileEntry, TProfileData: ProfileData].} -proc `==`(a, b: TStackTrace): bool = +proc `==`(a, b: StackTrace): bool = for i in 0 .. high(a): if a[i] != b[i]: return false result = true @@ -44,13 +46,13 @@ proc `==`(a, b: TStackTrace): bool = # XXX extract this data structure; it is generally useful ;-) # However a chain length of over 3000 is suspicious... var - profileData: TProfileData + profileData: ProfileData emptySlots = profileData.len * 3 div 2 maxChainLen = 0 totalCalls = 0 when not defined(memProfiler): - var interval: TNanos = 5_000_000 - tickCountCorrection # 5ms + var interval: Nanos = 5_000_000 - tickCountCorrection # 5ms proc setSamplingFrequency*(intervalInUs: int) = ## set this to change the sampling frequency. Default value is 5ms. @@ -62,11 +64,11 @@ when not defined(memProfiler): when withThreads: import locks var - profilingLock: TLock + profilingLock: Lock initLock profilingLock -proc hookAux(st: TStackTrace, costs: int) = +proc hookAux(st: StackTrace, costs: int) = # this is quite performance sensitive! when withThreads: acquire profilingLock inc totalCalls @@ -94,8 +96,8 @@ proc hookAux(st: TStackTrace, costs: int) = var chain = 0 while true: if profileData[h] == nil: - profileData[h] = cast[ptr TProfileEntry]( - allocShared0(sizeof(TProfileEntry))) + profileData[h] = cast[ptr ProfileEntry]( + allocShared0(sizeof(ProfileEntry))) profileData[h].total = costs profileData[h].st = st dec emptySlots @@ -115,7 +117,7 @@ when defined(memProfiler): var gTicker {.threadvar.}: int - proc hook(st: TStackTrace, size: int) {.nimcall.} = + proc hook(st: StackTrace, size: int) {.nimcall.} = if gTicker == 0: gTicker = -1 when defined(ignoreAllocationSize): @@ -127,26 +129,26 @@ when defined(memProfiler): else: var - t0 {.threadvar.}: TTicks + t0 {.threadvar.}: Ticks - proc hook(st: TStackTrace) {.nimcall.} = + proc hook(st: StackTrace) {.nimcall.} = if interval == 0: hookAux(st, 1) elif int64(t0) == 0 or getTicks() - t0 > interval: hookAux(st, 1) t0 = getTicks() -proc getTotal(x: ptr TProfileEntry): int = +proc getTotal(x: ptr ProfileEntry): int = result = if isNil(x): 0 else: x.total -proc cmpEntries(a, b: ptr TProfileEntry): int = +proc cmpEntries(a, b: ptr ProfileEntry): int = result = b.getTotal - a.getTotal proc `//`(a, b: int): string = result = format("$1/$2 = $3%", a, b, formatFloat(a / b * 100.0, ffDefault, 2)) proc writeProfile() {.noconv.} = - when declared(system.TStackTrace): + when declared(system.StackTrace): system.profilerHook = nil const filename = "profile_results.txt" echo "writing " & filename & "..." @@ -161,7 +163,7 @@ proc writeProfile() {.noconv.} = var perProc = initCountTable[string]() for i in 0..entries-1: var dups = initSet[string]() - for ii in 0..high(TStackTrace): + for ii in 0..high(StackTrace): let procname = profileData[i].st[ii] if isNil(procname): break let p = $procname @@ -176,7 +178,7 @@ proc writeProfile() {.noconv.} = writeln(f, "Entry: ", i+1, "/", entries, " Calls: ", profileData[i].total // totalCalls, " [sum: ", sum, "; ", sum // totalCalls, "]") - for ii in 0..high(TStackTrace): + for ii in 0..high(StackTrace): let procname = profileData[i].st[ii] if isNil(procname): break writeln(f, " ", procname, " ", perProc[$procname] // totalCalls) @@ -189,16 +191,16 @@ var disabled: int proc disableProfiling*() = - when declared(system.TStackTrace): + when declared(system.StackTrace): atomicDec disabled system.profilerHook = nil proc enableProfiling*() = - when declared(system.TStackTrace): + when declared(system.StackTrace): if atomicInc(disabled) >= 0: system.profilerHook = hook -when declared(system.TStackTrace): +when declared(system.StackTrace): system.profilerHook = hook addQuitProc(writeProfile) diff --git a/lib/pure/options.nim b/lib/pure/options.nim new file mode 100644 index 000000000..ef01e1260 --- /dev/null +++ b/lib/pure/options.nim @@ -0,0 +1,160 @@ +# +# +# Nim's Runtime Library +# (c) Copyright 2015 Nim Contributors +# +# See the file "copying.txt", included in this +# distribution, for details about the copyright. +# + +## Abstract +## ======== +## +## This module implements types which encapsulate an optional value. +## +## A value of type ``Option[T]`` either contains a value `x` (represented as +## ``some(x)``) or is empty (``none(T)``). +## +## This can be useful when you have a value that can be present or not. The +## absence of a value is often represented by ``nil``, but it is not always +## available, nor is it always a good solution. +## +## +## Tutorial +## ======== +## +## Let's start with an example: a procedure that finds the index of a character +## in a string. +## +## .. code-block:: nim +## +## import optionals +## +## proc find(haystack: string, needle: char): Option[int] = +## for i, c in haystack: +## if c == needle: +## return some(i) +## return none(int) # This line is actually optional, +## # because the default is empty +## +## .. code-block:: nim +## +## try: +## assert("abc".find('c').get() == 2) # Immediately extract the value +## except UnpackError: # If there is no value +## assert false # This will not be reached, because the value is present +## +## The ``get`` operation demonstrated above returns the underlying value, or +## raises ``UnpackError`` if there is no value. There is another option for +## obtaining the value: ``unsafeGet``, but you must only use it when you are +## absolutely sure the value is present (e.g. after checking ``isSome``). If +## you do not care about the tiny overhead that ``get`` causes, you should +## simply never use ``unsafeGet``. +## +## How to deal with an absence of a value: +## +## .. code-block:: nim +## +## let result = "team".find('i') +## +## # Nothing was found, so the result is `none`. +## assert(result == none(int)) +## # It has no value: +## assert(result.isNone) +## +## try: +## echo result.get() +## assert(false) # This will not be reached +## except UnpackError: # Because an exception is raised +## discard + +import typetraits + + +type + Option*[T] = object + ## An optional type that stores its value and state separately in a boolean. + val: T + has: bool + UnpackError* = ref object of ValueError + + +proc some*[T](val: T): Option[T] = + ## Returns a ``Option`` that has this value. + result.has = true + result.val = val + +proc none*(T: typedesc): Option[T] = + ## Returns a ``Option`` for this type that has no value. + result.has = false + + +proc isSome*[T](self: Option[T]): bool = + self.has + +proc isNone*[T](self: Option[T]): bool = + not self.has + + +proc unsafeGet*[T](self: Option[T]): T = + ## Returns the value of a ``some``. Behavior is undefined for ``none``. + assert self.isSome + self.val + +proc get*[T](self: Option[T]): T = + ## Returns contents of the Option. If it is none, then an exception is + ## thrown. + if self.isNone: + raise UnpackError(msg : "Can't obtain a value from a `none`") + self.val + + +proc `==`*(a, b: Option): bool = + ## Returns ``true`` if both ``Option``s are ``none``, + ## or if they have equal values + (a.has and b.has and a.val == b.val) or (not a.has and not b.has) + + +when isMainModule: + import unittest + + suite "optionals": + # work around a bug in unittest + let intNone = none(int) + let stringNone = none(string) + + test "example": + proc find(haystack: string, needle: char): Option[int] = + for i, c in haystack: + if c == needle: + return some i + + check("abc".find('c').get() == 2) + + let result = "team".find('i') + + check result == intNone + check result.isNone + + test "some": + check some(6).get() == 6 + check some("a").unsafeGet() == "a" + check some(6).isSome + check some("a").isSome + + test "none": + expect UnpackError: + discard none(int).get() + check(none(int).isNone) + check(not none(string).isSome) + + test "equality": + check some("a") == some("a") + check some(7) != some(6) + check some("a") != stringNone + check intNone == intNone + + when compiles(some("a") == some(5)): + check false + when compiles(none(string) == none(int)): + check false diff --git a/lib/pure/os.nim b/lib/pure/os.nim index f53abe81d..4deb79f86 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -41,7 +41,7 @@ type OSErrorCode* = distinct int32 ## Specifies an OS Error Code. -{.deprecated: [FReadEnv: ReadEnvEffect, FWriteEnv: WriteEnvEffect, +{.deprecated: [FReadEnv: ReadEnvEffect, FWriteEnv: WriteEnvEffect, FReadDir: ReadDirEffect, FWriteDir: WriteDirEffect, TOSErrorCode: OSErrorCode @@ -359,7 +359,7 @@ when defined(windows): template wrapBinary(varname, winApiProc, arg, arg2: expr) {.immediate.} = var varname = winApiProc(newWideCString(arg), arg2) - proc findFirstFile(a: string, b: var TWIN32_FIND_DATA): THandle = + proc findFirstFile(a: string, b: var WIN32_FIND_DATA): Handle = result = findFirstFileW(newWideCString(a), b) template findNextFile(a, b: expr): expr = findNextFileW(a, b) template getCommandLine(): expr = getCommandLineW() @@ -373,7 +373,7 @@ when defined(windows): template getFilename(f: expr): expr = $f.cFilename - proc skipFindData(f: TWIN32_FIND_DATA): bool {.inline.} = + proc skipFindData(f: WIN32_FIND_DATA): bool {.inline.} = # Note - takes advantage of null delimiter in the cstring const dot = ord('.') result = f.cFileName[0].int == dot and (f.cFileName[1].int == 0 or @@ -390,7 +390,7 @@ proc existsFile*(filename: string): bool {.rtl, extern: "nos$1", if a != -1'i32: result = (a and FILE_ATTRIBUTE_DIRECTORY) == 0'i32 else: - var res: TStat + var res: Stat return stat(filename, res) >= 0'i32 and S_ISREG(res.st_mode) proc existsDir*(dir: string): bool {.rtl, extern: "nos$1", tags: [ReadDirEffect].} = @@ -404,7 +404,7 @@ proc existsDir*(dir: string): bool {.rtl, extern: "nos$1", tags: [ReadDirEffect] if a != -1'i32: result = (a and FILE_ATTRIBUTE_DIRECTORY) != 0'i32 else: - var res: TStat + var res: Stat return stat(dir, res) >= 0'i32 and S_ISDIR(res.st_mode) proc symlinkExists*(link: string): bool {.rtl, extern: "nos$1", @@ -419,7 +419,7 @@ proc symlinkExists*(link: string): bool {.rtl, extern: "nos$1", if a != -1'i32: result = (a and FILE_ATTRIBUTE_REPARSE_POINT) != 0'i32 else: - var res: TStat + var res: Stat return lstat(link, res) >= 0'i32 and S_ISLNK(res.st_mode) proc fileExists*(filename: string): bool {.inline.} = @@ -433,11 +433,11 @@ proc dirExists*(dir: string): bool {.inline.} = proc getLastModificationTime*(file: string): Time {.rtl, extern: "nos$1".} = ## Returns the `file`'s last modification time. when defined(posix): - var res: TStat + var res: Stat if stat(file, res) < 0'i32: raiseOSError(osLastError()) return res.st_mtime else: - var f: TWIN32_FIND_DATA + var f: WIN32_FIND_DATA var h = findFirstFile(file, f) if h == -1'i32: raiseOSError(osLastError()) result = winTimeToUnixTime(rdFileTime(f.ftLastWriteTime)) @@ -446,11 +446,11 @@ proc getLastModificationTime*(file: string): Time {.rtl, extern: "nos$1".} = proc getLastAccessTime*(file: string): Time {.rtl, extern: "nos$1".} = ## Returns the `file`'s last read or write access time. when defined(posix): - var res: TStat + var res: Stat if stat(file, res) < 0'i32: raiseOSError(osLastError()) return res.st_atime else: - var f: TWIN32_FIND_DATA + var f: WIN32_FIND_DATA var h = findFirstFile(file, f) if h == -1'i32: raiseOSError(osLastError()) result = winTimeToUnixTime(rdFileTime(f.ftLastAccessTime)) @@ -461,11 +461,11 @@ proc getCreationTime*(file: string): Time {.rtl, extern: "nos$1".} = ## Note that under posix OS's, the returned time may actually be the time at ## which the file's attribute's were last modified. when defined(posix): - var res: TStat + var res: Stat if stat(file, res) < 0'i32: raiseOSError(osLastError()) return res.st_ctime else: - var f: TWIN32_FIND_DATA + var f: WIN32_FIND_DATA var h = findFirstFile(file, f) if h == -1'i32: raiseOSError(osLastError()) result = winTimeToUnixTime(rdFileTime(f.ftCreationTime)) @@ -794,20 +794,20 @@ proc isAbsolute*(path: string): bool {.rtl, noSideEffect, extern: "nos$1".} = result = path[0] == '/' when defined(Windows): - proc openHandle(path: string, followSymlink=true): THandle = + proc openHandle(path: string, followSymlink=true): Handle = var flags = FILE_FLAG_BACKUP_SEMANTICS or FILE_ATTRIBUTE_NORMAL if not followSymlink: flags = flags or FILE_FLAG_OPEN_REPARSE_POINT when useWinUnicode: result = createFileW( - newWideCString(path), 0'i32, + newWideCString(path), 0'i32, FILE_SHARE_DELETE or FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, flags, 0 ) else: result = createFileA( - path, 0'i32, + path, 0'i32, FILE_SHARE_DELETE or FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, flags, 0 ) @@ -827,7 +827,7 @@ proc sameFile*(path1, path2: string): bool {.rtl, extern: "nos$1", var lastErr: OSErrorCode if f1 != INVALID_HANDLE_VALUE and f2 != INVALID_HANDLE_VALUE: - var fi1, fi2: TBY_HANDLE_FILE_INFORMATION + var fi1, fi2: BY_HANDLE_FILE_INFORMATION if getFileInformationByHandle(f1, addr(fi1)) != 0 and getFileInformationByHandle(f2, addr(fi2)) != 0: @@ -846,7 +846,7 @@ proc sameFile*(path1, path2: string): bool {.rtl, extern: "nos$1", if not success: raiseOSError(lastErr) else: - var a, b: TStat + var a, b: Stat if stat(path1, a) < 0'i32 or stat(path2, b) < 0'i32: raiseOSError(osLastError()) else: @@ -903,7 +903,7 @@ proc getFilePermissions*(filename: string): set[FilePermission] {. ## an error. On Windows, only the ``readonly`` flag is checked, every other ## permission is available in any case. when defined(posix): - var a: TStat + var a: Stat if stat(filename, a) < 0'i32: raiseOSError(osLastError()) result = {} if (a.st_mode and S_IRUSR) != 0'i32: result.incl(fpUserRead) @@ -924,11 +924,11 @@ proc getFilePermissions*(filename: string): set[FilePermission] {. var res = getFileAttributesA(filename) if res == -1'i32: raiseOSError(osLastError()) if (res and FILE_ATTRIBUTE_READONLY) != 0'i32: - result = {fpUserExec, fpUserRead, fpGroupExec, fpGroupRead, + result = {fpUserExec, fpUserRead, fpGroupExec, fpGroupRead, fpOthersExec, fpOthersRead} else: result = {fpUserExec..fpOthersRead} - + proc setFilePermissions*(filename: string, permissions: set[FilePermission]) {. rtl, extern: "nos$1", tags: [WriteDirEffect].} = ## sets the file permissions for `filename`. `OSError` is raised in case of @@ -939,15 +939,15 @@ proc setFilePermissions*(filename: string, permissions: set[FilePermission]) {. if fpUserRead in permissions: p = p or S_IRUSR if fpUserWrite in permissions: p = p or S_IWUSR if fpUserExec in permissions: p = p or S_IXUSR - + if fpGroupRead in permissions: p = p or S_IRGRP if fpGroupWrite in permissions: p = p or S_IWGRP if fpGroupExec in permissions: p = p or S_IXGRP - + if fpOthersRead in permissions: p = p or S_IROTH if fpOthersWrite in permissions: p = p or S_IWOTH if fpOthersExec in permissions: p = p or S_IXOTH - + if chmod(filename, p) != 0: raiseOSError(osLastError()) else: when useWinUnicode: @@ -955,7 +955,7 @@ proc setFilePermissions*(filename: string, permissions: set[FilePermission]) {. else: var res = getFileAttributesA(filename) if res == -1'i32: raiseOSError(osLastError()) - if fpUserWrite in permissions: + if fpUserWrite in permissions: res = res and not FILE_ATTRIBUTE_READONLY else: res = res or FILE_ATTRIBUTE_READONLY @@ -1030,11 +1030,11 @@ when not declared(ENOENT) and not defined(Windows): when defined(Windows): when useWinUnicode: template deleteFile(file: expr): expr {.immediate.} = deleteFileW(file) - template setFileAttributes(file, attrs: expr): expr {.immediate.} = + template setFileAttributes(file, attrs: expr): expr {.immediate.} = setFileAttributesW(file, attrs) else: template deleteFile(file: expr): expr {.immediate.} = deleteFileA(file) - template setFileAttributes(file, attrs: expr): expr {.immediate.} = + template setFileAttributes(file, attrs: expr): expr {.immediate.} = setFileAttributesA(file, attrs) proc removeFile*(file: string) {.rtl, extern: "nos$1", tags: [WriteDirEffect].} = @@ -1047,7 +1047,7 @@ proc removeFile*(file: string) {.rtl, extern: "nos$1", tags: [WriteDirEffect].} else: let f = file if deleteFile(f) == 0: - if getLastError() == ERROR_ACCESS_DENIED: + if getLastError() == ERROR_ACCESS_DENIED: if setFileAttributes(f, FILE_ATTRIBUTE_NORMAL) == 0: raiseOSError(osLastError()) if deleteFile(f) == 0: @@ -1220,7 +1220,7 @@ iterator walkFiles*(pattern: string): string {.tags: [ReadDirEffect].} = ## notation is supported. when defined(windows): var - f: TWIN32_FIND_DATA + f: WIN32_FIND_DATA res: int res = findFirstFile(pattern, f) if res != -1: @@ -1232,7 +1232,7 @@ iterator walkFiles*(pattern: string): string {.tags: [ReadDirEffect].} = findClose(res) else: # here we use glob var - f: TGlob + f: Glob res: int f.gl_offs = 0 f.gl_pathc = 0 @@ -1276,7 +1276,7 @@ iterator walkDir*(dir: string): tuple[kind: PathComponent, path: string] {. ## dirA/fileA1.txt ## dirA/fileA2.txt when defined(windows): - var f: TWIN32_FIND_DATA + var f: WIN32_FIND_DATA var h = findFirstFile(dir / "*", f) if h != -1: while true: @@ -1297,7 +1297,7 @@ iterator walkDir*(dir: string): tuple[kind: PathComponent, path: string] {. if x == nil: break var y = $x.d_name if y != "." and y != "..": - var s: TStat + var s: Stat y = dir / y var k = pcFile @@ -1319,9 +1319,9 @@ iterator walkDirRec*(dir: string, filter={pcFile, pcDir}): string {. ## walks over the directory `dir` and yields for each file in `dir`. The ## full path for each file is returned. ## **Warning**: - ## Modifying the directory structure while the iterator - ## is traversing may result in undefined behavior! - ## + ## Modifying the directory structure while the iterator + ## is traversing may result in undefined behavior! + ## ## Walking is recursive. `filter` controls the behaviour of the iterator: ## ## --------------------- --------------------------------------------- @@ -1424,7 +1424,7 @@ proc createSymlink*(src, dest: string) = ## by `src`. On most operating systems, will fail if a lonk ## ## **Warning**: - ## Some OS's (such as Microsoft Windows) restrict the creation + ## Some OS's (such as Microsoft Windows) restrict the creation ## of symlinks to root users (administrators). when defined(Windows): let flag = dirExists(src).int32 @@ -1444,7 +1444,7 @@ proc createHardlink*(src, dest: string) = ## Create a hard link at `dest` which points to the item specified ## by `src`. ## - ## **Warning**: Most OS's restrict the creation of hard links to + ## **Warning**: Most OS's restrict the creation of hard links to ## root users (administrators) . when defined(Windows): when useWinUnicode: @@ -1548,7 +1548,7 @@ proc parseCmdLine*(c: string): seq[string] {. add(a, c[i]) inc(i) add(result, a) - + proc copyFileWithPermissions*(source, dest: string, ignorePermissionErrors = true) = ## Copies a file from `source` to `dest` preserving file permissions. @@ -1842,7 +1842,7 @@ proc sleep*(milsecs: int) {.rtl, extern: "nos$1", tags: [TimeEffect].} = when defined(windows): winlean.sleep(int32(milsecs)) else: - var a, b: Ttimespec + var a, b: Timespec a.tv_sec = Time(milsecs div 1000) a.tv_nsec = (milsecs mod 1000) * 1000 * 1000 discard posix.nanosleep(a, b) @@ -1851,7 +1851,7 @@ proc getFileSize*(file: string): BiggestInt {.rtl, extern: "nos$1", tags: [ReadIOEffect].} = ## returns the file size of `file`. Can raise ``OSError``. when defined(windows): - var a: TWIN32_FIND_DATA + var a: WIN32_FIND_DATA var resA = findFirstFile(file, a) if resA == -1: raiseOSError(osLastError()) result = rdFileSize(a) @@ -1907,8 +1907,8 @@ when defined(Windows): FileId* = int64 else: type - DeviceId* = TDev - FileId* = Tino + DeviceId* = Dev + FileId* = Ino type FileInfo* = object @@ -1925,7 +1925,7 @@ type template rawToFormalFileInfo(rawInfo, formalInfo): expr = ## Transforms the native file info structure into the one nim uses. ## 'rawInfo' is either a 'TBY_HANDLE_FILE_INFORMATION' structure on Windows, - ## or a 'TStat' structure on posix + ## or a 'Stat' structure on posix when defined(Windows): template toTime(e): expr = winTimeToUnixTime(rdFileTime(e)) template merge(a, b): expr = a or (b shl 32) @@ -1936,10 +1936,10 @@ template rawToFormalFileInfo(rawInfo, formalInfo): expr = formalInfo.lastAccessTime = toTime(rawInfo.ftLastAccessTime) formalInfo.lastWriteTime = toTime(rawInfo.ftLastWriteTime) formalInfo.creationTime = toTime(rawInfo.ftCreationTime) - + # Retrieve basic permissions if (rawInfo.dwFileAttributes and FILE_ATTRIBUTE_READONLY) != 0'i32: - formalInfo.permissions = {fpUserExec, fpUserRead, fpGroupExec, + formalInfo.permissions = {fpUserExec, fpUserRead, fpGroupExec, fpGroupRead, fpOthersExec, fpOthersRead} else: result.permissions = {fpUserExec..fpOthersRead} @@ -1953,7 +1953,7 @@ template rawToFormalFileInfo(rawInfo, formalInfo): expr = else: - template checkAndIncludeMode(rawMode, formalMode: expr) = + template checkAndIncludeMode(rawMode, formalMode: expr) = if (rawInfo.st_mode and rawMode) != 0'i32: formalInfo.permissions.incl(formalMode) formalInfo.id = (rawInfo.st_dev, rawInfo.st_ino) @@ -1988,7 +1988,7 @@ proc getFileInfo*(handle: FileHandle): FileInfo = ## is invalid, an error will be thrown. # Done: ID, Kind, Size, Permissions, Link Count when defined(Windows): - var rawInfo: TBY_HANDLE_FILE_INFORMATION + var rawInfo: BY_HANDLE_FILE_INFORMATION # We have to use the super special '_get_osfhandle' call (wrapped above) # To transform the C file descripter to a native file handle. var realHandle = get_osfhandle(handle) @@ -1996,7 +1996,7 @@ proc getFileInfo*(handle: FileHandle): FileInfo = raiseOSError(osLastError()) rawToFormalFileInfo(rawInfo, result) else: - var rawInfo: TStat + var rawInfo: Stat if fstat(handle, rawInfo) < 0'i32: raiseOSError(osLastError()) rawToFormalFileInfo(rawInfo, result) @@ -2008,22 +2008,22 @@ proc getFileInfo*(file: File): FileInfo = proc getFileInfo*(path: string, followSymlink = true): FileInfo = ## Retrieves file information for the file object pointed to by `path`. - ## + ## ## Due to intrinsic differences between operating systems, the information ## contained by the returned `FileInfo` structure will be slightly different ## across platforms, and in some cases, incomplete or inaccurate. - ## + ## ## When `followSymlink` is true, symlinks are followed and the information ## retrieved is information related to the symlink's target. Otherwise, ## information on the symlink itself is retrieved. - ## + ## ## If the information cannot be retrieved, such as when the path doesn't ## exist, or when permission restrictions prevent the program from retrieving ## file information, an error will be thrown. when defined(Windows): - var + var handle = openHandle(path, followSymlink) - rawInfo: TBY_HANDLE_FILE_INFORMATION + rawInfo: BY_HANDLE_FILE_INFORMATION if handle == INVALID_HANDLE_VALUE: raiseOSError(osLastError()) if getFileInformationByHandle(handle, addr rawInfo) == 0: @@ -2031,12 +2031,12 @@ proc getFileInfo*(path: string, followSymlink = true): FileInfo = rawToFormalFileInfo(rawInfo, result) discard closeHandle(handle) else: - var rawInfo: TStat + var rawInfo: Stat if followSymlink: - if lstat(path, rawInfo) < 0'i32: + if stat(path, rawInfo) < 0'i32: raiseOSError(osLastError()) else: - if stat(path, rawInfo) < 0'i32: + if lstat(path, rawInfo) < 0'i32: raiseOSError(osLastError()) rawToFormalFileInfo(rawInfo, result) @@ -2044,7 +2044,7 @@ proc isHidden*(path: string): bool = ## Determines whether a given path is hidden or not. Returns false if the ## file doesn't exist. The given path must be accessible from the current ## working directory of the program. - ## + ## ## On Windows, a file is hidden if the file's 'hidden' attribute is set. ## On Unix-like systems, a file is hidden if it starts with a '.' (period) ## and is not *just* '.' or '..' ' ." diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim index dce0673ba..33f5419d5 100644 --- a/lib/pure/osproc.nim +++ b/lib/pure/osproc.nim @@ -26,13 +26,13 @@ when defined(linux): type ProcessObj = object of RootObj when defined(windows): - fProcessHandle: THandle + fProcessHandle: Handle inHandle, outHandle, errHandle: FileHandle - id: THandle + id: Handle else: inHandle, outHandle, errHandle: FileHandle inStream, outStream, errStream: Stream - id: TPid + id: Pid exitCode: cint Process* = ref ProcessObj ## represents an operating system process @@ -195,43 +195,43 @@ proc peekExitCode*(p: Process): int {.tags: [].} proc inputStream*(p: Process): Stream {.rtl, extern: "nosp$1", tags: [].} ## returns ``p``'s input stream for writing to. ## - ## **Warning**: The returned `PStream` should not be closed manually as it - ## is closed when closing the PProcess ``p``. + ## **Warning**: The returned `Stream` should not be closed manually as it + ## is closed when closing the Process ``p``. proc outputStream*(p: Process): Stream {.rtl, extern: "nosp$1", tags: [].} ## returns ``p``'s output stream for reading from. ## - ## **Warning**: The returned `PStream` should not be closed manually as it - ## is closed when closing the PProcess ``p``. + ## **Warning**: The returned `Stream` should not be closed manually as it + ## is closed when closing the Process ``p``. proc errorStream*(p: Process): Stream {.rtl, extern: "nosp$1", tags: [].} ## returns ``p``'s error stream for reading from. ## - ## **Warning**: The returned `PStream` should not be closed manually as it - ## is closed when closing the PProcess ``p``. + ## **Warning**: The returned `Stream` should not be closed manually as it + ## is closed when closing the Process ``p``. proc inputHandle*(p: Process): FileHandle {.rtl, extern: "nosp$1", tags: [].} = ## returns ``p``'s input file handle for writing to. ## - ## **Warning**: The returned `TFileHandle` should not be closed manually as - ## it is closed when closing the PProcess ``p``. + ## **Warning**: The returned `FileHandle` should not be closed manually as + ## it is closed when closing the Process ``p``. result = p.inHandle proc outputHandle*(p: Process): FileHandle {.rtl, extern: "nosp$1", tags: [].} = ## returns ``p``'s output file handle for reading from. ## - ## **Warning**: The returned `TFileHandle` should not be closed manually as - ## it is closed when closing the PProcess ``p``. + ## **Warning**: The returned `FileHandle` should not be closed manually as + ## it is closed when closing the Process ``p``. result = p.outHandle proc errorHandle*(p: Process): FileHandle {.rtl, extern: "nosp$1", tags: [].} = ## returns ``p``'s error file handle for reading from. ## - ## **Warning**: The returned `TFileHandle` should not be closed manually as - ## it is closed when closing the PProcess ``p``. + ## **Warning**: The returned `FileHandle` should not be closed manually as + ## it is closed when closing the Process ``p``. result = p.errHandle proc countProcessors*(): int {.rtl, extern: "nosp$1".} = @@ -303,7 +303,7 @@ proc execProcesses*(cmds: openArray[string], close(p) proc select*(readfds: var seq[Process], timeout = 500): int - ## `select` with a sensible Nim interface. `timeout` is in miliseconds. + ## `select` with a sensible Nim interface. `timeout` is in milliseconds. ## Specify -1 for no timeout. Returns the number of processes that are ## ready to read from. The processes that are ready to be read from are ## removed from `readfds`. @@ -334,10 +334,11 @@ when not defined(useNimRtl): when defined(Windows) and not defined(useNimRtl): # We need to implement a handle stream for Windows: type - PFileHandleStream = ref TFileHandleStream - TFileHandleStream = object of StreamObj - handle: THandle + PFileHandleStream = ref FileHandleStream + FileHandleStream = object of StreamObj + handle: Handle atTheEnd: bool + {.deprecated: [TFileHandleStream: FileHandleStream].} proc hsClose(s: Stream) = discard # nothing to do here proc hsAtEnd(s: Stream): bool = return PFileHandleStream(s).atTheEnd @@ -361,7 +362,7 @@ when defined(Windows) and not defined(useNimRtl): addr bytesWritten, nil) if a == 0: raiseOSError(osLastError()) - proc newFileHandleStream(handle: THandle): PFileHandleStream = + proc newFileHandleStream(handle: Handle): PFileHandleStream = new(result) result.handle = handle result.closeImpl = hsClose @@ -387,22 +388,22 @@ when defined(Windows) and not defined(useNimRtl): copyMem(addr(result[L]), cstring(x), x.len+1) # copy \0 inc(L, x.len+1) - #proc open_osfhandle(osh: THandle, mode: int): int {. + #proc open_osfhandle(osh: Handle, mode: int): int {. # importc: "_open_osfhandle", header: "<fcntl.h>".} #var # O_WRONLY {.importc: "_O_WRONLY", header: "<fcntl.h>".}: int # O_RDONLY {.importc: "_O_RDONLY", header: "<fcntl.h>".}: int - proc createPipeHandles(rdHandle, wrHandle: var THandle) = - var piInheritablePipe: TSECURITY_ATTRIBUTES - piInheritablePipe.nLength = sizeof(TSECURITY_ATTRIBUTES).cint + proc createPipeHandles(rdHandle, wrHandle: var Handle) = + var piInheritablePipe: SECURITY_ATTRIBUTES + piInheritablePipe.nLength = sizeof(SECURITY_ATTRIBUTES).cint piInheritablePipe.lpSecurityDescriptor = nil piInheritablePipe.bInheritHandle = 1 if createPipe(rdHandle, wrHandle, piInheritablePipe, 1024) == 0'i32: raiseOSError(osLastError()) - proc fileClose(h: THandle) {.inline.} = + proc fileClose(h: Handle) {.inline.} = if h > 4: discard closeHandle(h) proc startProcess(command: string, @@ -411,10 +412,10 @@ when defined(Windows) and not defined(useNimRtl): env: StringTableRef = nil, options: set[ProcessOption] = {poStdErrToStdOut}): Process = var - si: TSTARTUPINFO - procInfo: TPROCESS_INFORMATION + si: STARTUPINFO + procInfo: PROCESS_INFORMATION success: int - hi, ho, he: THandle + hi, ho, he: Handle new(result) si.cb = sizeof(si).cint if poParentStreams notin options: @@ -525,9 +526,9 @@ when defined(Windows) and not defined(useNimRtl): proc execCmd(command: string): int = var - si: TSTARTUPINFO - procInfo: TPROCESS_INFORMATION - process: THandle + si: STARTUPINFO + procInfo: PROCESS_INFORMATION + process: Handle L: int32 si.cb = sizeof(si).cint si.hStdError = getStdHandle(STD_ERROR_HANDLE) @@ -554,7 +555,7 @@ when defined(Windows) and not defined(useNimRtl): proc select(readfds: var seq[Process], timeout = 500): int = assert readfds.len <= MAXIMUM_WAIT_OBJECTS - var rfds: TWOHandleArray + var rfds: WOHandleArray for i in 0..readfds.len()-1: rfds[i] = readfds[i].fProcessHandle @@ -595,7 +596,7 @@ elif not defined(useNimRtl): copyMem(result[i], addr(x[0]), x.len+1) inc(i) - type TStartProcessData = object + type StartProcessData = object sysCommand: cstring sysArgs: cstringArray sysEnv: cstringArray @@ -604,14 +605,15 @@ elif not defined(useNimRtl): optionPoUsePath: bool optionPoParentStreams: bool optionPoStdErrToStdOut: bool + {.deprecated: [TStartProcessData: StartProcessData].} when not defined(useFork): - proc startProcessAuxSpawn(data: TStartProcessData): TPid {. + proc startProcessAuxSpawn(data: StartProcessData): Pid {. tags: [ExecIOEffect, ReadEnvEffect], gcsafe.} - proc startProcessAuxFork(data: TStartProcessData): TPid {. + proc startProcessAuxFork(data: StartProcessData): Pid {. tags: [ExecIOEffect, ReadEnvEffect], gcsafe.} {.push stacktrace: off, profiler: off.} - proc startProcessAfterFork(data: ptr TStartProcessData) {. + proc startProcessAfterFork(data: ptr StartProcessData) {. tags: [ExecIOEffect, ReadEnvEffect], cdecl, gcsafe.} {.pop.} @@ -641,7 +643,7 @@ elif not defined(useNimRtl): for arg in args.items: sysArgsRaw.add arg - var pid: TPid + var pid: Pid var sysArgs = allocCStringArray(sysArgsRaw) defer: deallocCStringArray(sysArgs) @@ -653,7 +655,7 @@ elif not defined(useNimRtl): defer: deallocCStringArray(sysEnv) - var data: TStartProcessData + var data: StartProcessData data.sysCommand = sysCommand data.sysArgs = sysArgs data.sysEnv = sysEnv @@ -698,7 +700,7 @@ elif not defined(useNimRtl): discard close(pStdout[writeIdx]) when not defined(useFork): - proc startProcessAuxSpawn(data: TStartProcessData): TPid = + proc startProcessAuxSpawn(data: StartProcessData): Pid = var attr: Tposix_spawnattr var fops: Tposix_spawn_file_actions @@ -708,7 +710,7 @@ elif not defined(useNimRtl): chck posix_spawn_file_actions_init(fops) chck posix_spawnattr_init(attr) - var mask: Tsigset + var mask: Sigset chck sigemptyset(mask) chck posix_spawnattr_setsigmask(attr, mask) chck posix_spawnattr_setpgroup(attr, 0'i32) @@ -732,7 +734,7 @@ elif not defined(useNimRtl): # FIXME: chdir is global to process if data.workingDir.len > 0: setCurrentDir($data.workingDir) - var pid: TPid + var pid: Pid if data.optionPoUsePath: res = posix_spawnp(pid, data.sysCommand, fops, attr, data.sysArgs, data.sysEnv) @@ -744,14 +746,14 @@ elif not defined(useNimRtl): chck res return pid - proc startProcessAuxFork(data: TStartProcessData): TPid = + proc startProcessAuxFork(data: StartProcessData): Pid = if pipe(data.pErrorPipe) != 0: raiseOSError(osLastError()) defer: discard close(data.pErrorPipe[readIdx]) - var pid: TPid + var pid: Pid var dataCopy = data when defined(useClone): @@ -781,7 +783,7 @@ elif not defined(useNimRtl): return pid {.push stacktrace: off, profiler: off.} - proc startProcessFail(data: ptr TStartProcessData) = + proc startProcessFail(data: ptr StartProcessData) = var error: cint = errno discard write(data.pErrorPipe[writeIdx], addr error, sizeof(error)) exitnow(1) @@ -789,7 +791,7 @@ elif not defined(useNimRtl): when defined(macosx) or defined(freebsd): var environ {.importc.}: cstringArray - proc startProcessAfterFork(data: ptr TStartProcessData) = + proc startProcessAfterFork(data: ptr StartProcessData) = # Warning: no GC here! # Or anything that touches global structures - all called nim procs # must be marked with stackTrace:off. Inspect C code after making changes. diff --git a/lib/pure/parseopt.nim b/lib/pure/parseopt.nim index 4c92a7cdf..e9d10b51a 100644 --- a/lib/pure/parseopt.nim +++ b/lib/pure/parseopt.nim @@ -133,7 +133,7 @@ proc cmdLineRest*(p: OptParser): TaintedString {.rtl, extern: "npo$1".} = when declared(initOptParser): iterator getopt*(): tuple[kind: CmdLineKind, key, val: TaintedString] = ## This is an convenience iterator for iterating over the command line. - ## This uses the TOptParser object. Example: + ## This uses the OptParser object. Example: ## ## .. code-block:: nim ## var diff --git a/lib/pure/pegs.nim b/lib/pure/pegs.nim index 39f0bfa95..ce837d9d1 100644 --- a/lib/pure/pegs.nim +++ b/lib/pure/pegs.nim @@ -74,8 +74,8 @@ type line: int ## line the symbol has been declared/used in col: int ## column the symbol has been declared/used in flags: set[NonTerminalFlag] ## the nonterminal's flags - rule: TNode ## the rule that the symbol refers to - TNode {.shallow.} = object + rule: Node ## the rule that the symbol refers to + Node {.shallow.} = object case kind: PegKind of pkEmpty..pkWhitespace: nil of pkTerminal, pkTerminalIgnoreCase, pkTerminalIgnoreStyle: term: string @@ -83,12 +83,12 @@ type of pkCharChoice, pkGreedyRepSet: charChoice: ref set[char] of pkNonTerminal: nt: NonTerminal of pkBackRef..pkBackRefIgnoreStyle: index: range[0..MaxSubpatterns] - else: sons: seq[TNode] + else: sons: seq[Node] NonTerminal* = ref NonTerminalObj - Peg* = TNode ## type that represents a PEG + Peg* = Node ## type that represents a PEG -{.deprecated: [TPeg: Peg].} +{.deprecated: [TPeg: Peg, TNode: Node].} proc term*(t: string): Peg {.nosideEffect, rtl, extern: "npegs$1Str".} = ## constructs a PEG from a terminal string @@ -1014,12 +1014,12 @@ proc split*(s: string, sep: Peg): seq[string] {. # ------------------- scanner ------------------------------------------------- type - TModifier = enum + Modifier = enum modNone, modVerbatim, modIgnoreCase, modIgnoreStyle - TTokKind = enum ## enumeration of all tokens + TokKind = enum ## enumeration of all tokens tkInvalid, ## invalid token tkEof, ## end of file reached tkAny, ## . @@ -1046,9 +1046,9 @@ type tkDollar, ## '$' tkHat ## '^' - TToken {.final.} = object ## a token - kind: TTokKind ## the type of the token - modifier: TModifier + Token {.final.} = object ## a token + kind: TokKind ## the type of the token + modifier: Modifier literal: string ## the parsed (string) literal charset: set[char] ## if kind == tkCharSet index: int ## if kind == tkBackref @@ -1060,9 +1060,10 @@ type lineStart: int ## index of last line start in buffer colOffset: int ## column to add filename: string +{.deprecated: [TTokKind: TokKind, TToken: Token, TModifier: Modifier].} const - tokKindToStr: array[TTokKind, string] = [ + tokKindToStr: array[TokKind, string] = [ "invalid", "[EOF]", ".", "_", "identifier", "string literal", "character set", "(", ")", "{", "}", "{@}", "<-", "/", "*", "+", "&", "!", "?", @@ -1114,7 +1115,7 @@ proc handleHexChar(c: var PegLexer, xi: var int) = inc(c.bufpos) else: discard -proc getEscapedChar(c: var PegLexer, tok: var TToken) = +proc getEscapedChar(c: var PegLexer, tok: var Token) = inc(c.bufpos) case c.buf[c.bufpos] of 'r', 'R', 'c', 'C': @@ -1185,7 +1186,7 @@ proc skip(c: var PegLexer) = break # EndOfFile also leaves the loop c.bufpos = pos -proc getString(c: var PegLexer, tok: var TToken) = +proc getString(c: var PegLexer, tok: var Token) = tok.kind = tkStringLit var pos = c.bufpos + 1 var buf = c.buf @@ -1207,7 +1208,7 @@ proc getString(c: var PegLexer, tok: var TToken) = inc(pos) c.bufpos = pos -proc getDollar(c: var PegLexer, tok: var TToken) = +proc getDollar(c: var PegLexer, tok: var Token) = var pos = c.bufpos + 1 var buf = c.buf if buf[pos] in {'0'..'9'}: @@ -1220,7 +1221,7 @@ proc getDollar(c: var PegLexer, tok: var TToken) = tok.kind = tkDollar c.bufpos = pos -proc getCharSet(c: var PegLexer, tok: var TToken) = +proc getCharSet(c: var PegLexer, tok: var Token) = tok.kind = tkCharSet tok.charset = {} var pos = c.bufpos + 1 @@ -1271,7 +1272,7 @@ proc getCharSet(c: var PegLexer, tok: var TToken) = c.bufpos = pos if caret: tok.charset = {'\1'..'\xFF'} - tok.charset -proc getSymbol(c: var PegLexer, tok: var TToken) = +proc getSymbol(c: var PegLexer, tok: var Token) = var pos = c.bufpos var buf = c.buf while true: @@ -1281,7 +1282,7 @@ proc getSymbol(c: var PegLexer, tok: var TToken) = c.bufpos = pos tok.kind = tkIdentifier -proc getBuiltin(c: var PegLexer, tok: var TToken) = +proc getBuiltin(c: var PegLexer, tok: var Token) = if c.buf[c.bufpos+1] in strutils.Letters: inc(c.bufpos) getSymbol(c, tok) @@ -1290,7 +1291,7 @@ proc getBuiltin(c: var PegLexer, tok: var TToken) = tok.kind = tkEscaped getEscapedChar(c, tok) # may set tok.kind to tkInvalid -proc getTok(c: var PegLexer, tok: var TToken) = +proc getTok(c: var PegLexer, tok: var Token) = tok.kind = tkInvalid tok.modifier = modNone setLen(tok.literal, 0) @@ -1408,9 +1409,9 @@ type EInvalidPeg* = object of ValueError ## raised if an invalid ## PEG has been detected PegParser = object of PegLexer ## the PEG parser object - tok: TToken + tok: Token nonterms: seq[NonTerminal] - modifier: TModifier + modifier: Modifier captures: int identIsVerbatim: bool skip: Peg @@ -1425,7 +1426,7 @@ proc getTok(p: var PegParser) = getTok(p, p.tok) if p.tok.kind == tkInvalid: pegError(p, "invalid token") -proc eat(p: var PegParser, kind: TTokKind) = +proc eat(p: var PegParser, kind: TokKind) = if p.tok.kind == kind: getTok(p) else: pegError(p, tokKindToStr[kind] & " expected") @@ -1439,13 +1440,13 @@ proc getNonTerminal(p: var PegParser, name: string): NonTerminal = result = newNonTerminal(name, getLine(p), getColumn(p)) add(p.nonterms, result) -proc modifiedTerm(s: string, m: TModifier): Peg = +proc modifiedTerm(s: string, m: Modifier): Peg = case m of modNone, modVerbatim: result = term(s) of modIgnoreCase: result = termIgnoreCase(s) of modIgnoreStyle: result = termIgnoreStyle(s) -proc modifiedBackref(s: int, m: TModifier): Peg = +proc modifiedBackref(s: int, m: Modifier): Peg = case m of modNone, modVerbatim: result = backref(s) of modIgnoreCase: result = backrefIgnoreCase(s) diff --git a/lib/pure/rationals.nim b/lib/pure/rationals.nim index 3b68a2381..8e1dbe464 100644 --- a/lib/pure/rationals.nim +++ b/lib/pure/rationals.nim @@ -206,13 +206,13 @@ proc abs*[T](x: Rational[T]): Rational[T] = result.num = abs x.num result.den = abs x.den -proc hash*[T](x: Rational[T]): THash = +proc hash*[T](x: Rational[T]): Hash = ## Computes hash for rational `x` # reduce first so that hash(x) == hash(y) for x == y var copy = x reduce(copy) - var h: THash = 0 + var h: Hash = 0 h = h !& hash(copy.num) h = h !& hash(copy.den) result = !$h diff --git a/lib/pure/rawsockets.nim b/lib/pure/rawsockets.nim index a30c23ada..6d656c983 100644 --- a/lib/pure/rawsockets.nim +++ b/lib/pure/rawsockets.nim @@ -106,13 +106,13 @@ proc `$`*(p: Port): string {.borrow.} ## returns the port number as a string proc toInt*(domain: Domain): cint - ## Converts the TDomain enum to a platform-dependent ``cint``. + ## Converts the Domain enum to a platform-dependent ``cint``. proc toInt*(typ: SockType): cint - ## Converts the TType enum to a platform-dependent ``cint``. + ## Converts the SockType enum to a platform-dependent ``cint``. proc toInt*(p: Protocol): cint - ## Converts the TProtocol enum to a platform-dependent ``cint``. + ## Converts the Protocol enum to a platform-dependent ``cint``. when not useWinVersion: proc toInt(domain: Domain): cint = @@ -392,7 +392,7 @@ proc select*(readfds: var seq[SocketHandle], timeout = 500): int = ## Traditional select function. This function will return the number of ## sockets that are ready to be read from, written to, or which have errors. ## If there are none; 0 is returned. - ## ``Timeout`` is in miliseconds and -1 can be specified for no timeout. + ## ``Timeout`` is in milliseconds and -1 can be specified for no timeout. ## ## A socket is removed from the specific ``seq`` when it has data waiting to ## be read/written to or has errors (``exceptfds``). @@ -416,7 +416,7 @@ proc selectWrite*(writefds: var seq[SocketHandle], ## written to. The sockets which can be written to will also be removed ## from ``writefds``. ## - ## ``timeout`` is specified in miliseconds and ``-1`` can be specified for + ## ``timeout`` is specified in milliseconds and ``-1`` can be specified for ## an unlimited time. var tv {.noInit.}: Timeval = timeValFromMilliseconds(timeout) diff --git a/lib/pure/redis.nim b/lib/pure/redis.nim index aa2e0f9bd..b738e4094 100644 --- a/lib/pure/redis.nim +++ b/lib/pure/redis.nim @@ -10,8 +10,8 @@ ## This module implements a redis client. It allows you to connect to a ## redis-server instance, send commands and receive replies. ## -## **Beware**: Most (if not all) functions that return a ``TRedisString`` may -## return ``redisNil``, and functions which return a ``TRedisList`` +## **Beware**: Most (if not all) functions that return a ``RedisString`` may +## return ``redisNil``, and functions which return a ``RedisList`` ## may return ``nil``. import sockets, os, strutils, parseutils @@ -843,27 +843,27 @@ proc pfmerge*(r: Redis, destination: string, sources: varargs[string]) = # TODO: pub/sub -- I don't think this will work synchronously. discard """ -proc psubscribe*(r: TRedis, pattern: openarray[string]): ???? = +proc psubscribe*(r: Redis, pattern: openarray[string]): ???? = ## Listen for messages published to channels matching the given patterns r.socket.send("PSUBSCRIBE $#\c\L" % pattern) return ??? -proc publish*(r: TRedis, channel: string, message: string): TRedisInteger = +proc publish*(r: Redis, channel: string, message: string): RedisInteger = ## Post a message to a channel r.socket.send("PUBLISH $# $#\c\L" % [channel, message]) return r.readInteger() -proc punsubscribe*(r: TRedis, [pattern: openarray[string], : string): ???? = +proc punsubscribe*(r: Redis, [pattern: openarray[string], : string): ???? = ## Stop listening for messages posted to channels matching the given patterns r.socket.send("PUNSUBSCRIBE $# $#\c\L" % [[pattern.join(), ]) return ??? -proc subscribe*(r: TRedis, channel: openarray[string]): ???? = +proc subscribe*(r: Redis, channel: openarray[string]): ???? = ## Listen for messages published to the given channels r.socket.send("SUBSCRIBE $#\c\L" % channel.join) return ??? -proc unsubscribe*(r: TRedis, [channel: openarray[string], : string): ???? = +proc unsubscribe*(r: Redis, [channel: openarray[string], : string): ???? = ## Stop listening for messages posted to the given channels r.socket.send("UNSUBSCRIBE $# $#\c\L" % [[channel.join(), ]) return ??? @@ -991,7 +991,7 @@ proc lastsave*(r: Redis): RedisInteger = return r.readInteger() discard """ -proc monitor*(r: TRedis) = +proc monitor*(r: Redis) = ## Listen for all requests received by the server in real time r.socket.send("MONITOR\c\L") raiseNoOK(r.readStatus(), r.pipeline.enabled) diff --git a/lib/pure/scgi.nim b/lib/pure/scgi.nim index f3e2b583c..3de422c87 100644 --- a/lib/pure/scgi.nim +++ b/lib/pure/scgi.nim @@ -126,7 +126,7 @@ proc close*(s: var ScgiState) = s.server.close() proc next*(s: var ScgiState, timeout: int = -1): bool = - ## proceed to the first/next request. Waits ``timeout`` miliseconds for a + ## proceed to the first/next request. Waits ``timeout`` milliseconds for a ## request, if ``timeout`` is `-1` then this function will never time out. ## Returns `true` if a new request has been processed. var rsocks = @[s.server] diff --git a/lib/pure/selectors.nim b/lib/pure/selectors.nim index 6901ecf58..e44b87051 100644 --- a/lib/pure/selectors.nim +++ b/lib/pure/selectors.nim @@ -18,7 +18,7 @@ elif defined(windows): else: import posix -proc hash*(x: SocketHandle): THash {.borrow.} +proc hash*(x: SocketHandle): Hash {.borrow.} proc `$`*(x: SocketHandle): string {.borrow.} type @@ -41,7 +41,7 @@ when defined(nimdoc): proc register*(s: Selector, fd: SocketHandle, events: set[Event], data: RootRef): SelectorKey {.discardable.} = - ## Registers file descriptor ``fd`` to selector ``s`` with a set of TEvent + ## Registers file descriptor ``fd`` to selector ``s`` with a set of Event ## ``events``. proc update*(s: Selector, fd: SocketHandle, diff --git a/lib/pure/sockets.nim b/lib/pure/sockets.nim index 3afb545c8..a10255e5b 100644 --- a/lib/pure/sockets.nim +++ b/lib/pure/sockets.nim @@ -75,7 +75,7 @@ const BufferSize*: int = 4000 ## size of a buffered socket's buffer type - TSocketImpl = object ## socket type + SocketImpl = object ## socket type fd: SocketHandle case isBuffered: bool # determines whether this socket is buffered. of true: @@ -94,7 +94,7 @@ type of false: nil nonblocking: bool - Socket* = ref TSocketImpl + Socket* = ref SocketImpl Port* = distinct uint16 ## port type @@ -146,8 +146,9 @@ type {.deprecated: [TSocket: Socket, TType: SockType, TPort: Port, TDomain: Domain, TProtocol: Protocol, TServent: Servent, THostent: Hostent, - TSOBool: SOBool, TRecvLineResult: RecvLineResult, - TReadLineResult: ReadLineResult, ETimeout: TimeoutError].} + TSOBool: SOBool, TRecvLineResult: RecvLineResult, + TReadLineResult: ReadLineResult, ETimeout: TimeoutError, + TSocketImpl: SocketImpl].} when defined(booting): let invalidSocket*: Socket = nil ## invalid socket @@ -986,7 +987,7 @@ proc select*(readfds, writefds, exceptfds: var seq[Socket], ## Traditional select function. This function will return the number of ## sockets that are ready to be read from, written to, or which have errors. ## If there are none; 0 is returned. - ## ``Timeout`` is in miliseconds and -1 can be specified for no timeout. + ## ``Timeout`` is in milliseconds and -1 can be specified for no timeout. ## ## Sockets which are **not** ready for reading, writing or which don't have ## errors waiting on them are removed from the ``readfds``, ``writefds``, @@ -1040,7 +1041,7 @@ proc selectWrite*(writefds: var seq[Socket], ## written to. The sockets which **cannot** be written to will also be removed ## from ``writefds``. ## - ## ``timeout`` is specified in miliseconds and ``-1`` can be specified for + ## ``timeout`` is specified in milliseconds and ``-1`` can be specified for ## an unlimited time. var tv {.noInit.}: Timeval = timeValFromMilliseconds(timeout) @@ -1174,7 +1175,7 @@ proc waitFor(socket: Socket, waited: var float, timeout, size: int, proc recv*(socket: Socket, data: pointer, size: int, timeout: int): int {. tags: [ReadIOEffect, TimeEffect].} = - ## overload with a ``timeout`` parameter in miliseconds. + ## overload with a ``timeout`` parameter in milliseconds. var waited = 0.0 # number of seconds already waited var read = 0 @@ -1197,7 +1198,7 @@ proc recv*(socket: Socket, data: var string, size: int, timeout = -1): int = ## This function will throw an EOS exception when an error occurs. A value ## lower than 0 is never returned. ## - ## A timeout may be specified in miliseconds, if enough data is not received + ## A timeout may be specified in milliseconds, if enough data is not received ## within the time specified an ETimeout exception will be raised. ## ## **Note**: ``data`` must be initialised. @@ -1258,7 +1259,7 @@ proc recvLine*(socket: Socket, line: var TaintedString, timeout = -1): bool {. ## If the socket is disconnected, ``line`` will be set to ``""`` and ``True`` ## will be returned. ## - ## A timeout can be specified in miliseconds, if data is not received within + ## A timeout can be specified in milliseconds, if data is not received within ## the specified time an ETimeout exception will be raised. ## ## **Deprecated since version 0.9.2**: This function has been deprecated in @@ -1302,7 +1303,7 @@ proc readLine*(socket: Socket, line: var TaintedString, timeout = -1) {. ## ## An EOS exception will be raised in the case of a socket error. ## - ## A timeout can be specified in miliseconds, if data is not received within + ## A timeout can be specified in milliseconds, if data is not received within ## the specified time an ETimeout exception will be raised. template addNLIfEmpty(): stmt = @@ -1433,7 +1434,7 @@ proc recv*(socket: Socket): TaintedString {.tags: [ReadIOEffect], deprecated.} = proc recvTimeout*(socket: Socket, timeout: int): TaintedString {. tags: [ReadIOEffect], deprecated.} = ## overloaded variant to support a ``timeout`` parameter, the ``timeout`` - ## parameter specifies the amount of miliseconds to wait for data on the + ## parameter specifies the amount of milliseconds to wait for data on the ## socket. ## ## **Deprecated since version 0.9.2**: This function is not safe for use. @@ -1554,7 +1555,7 @@ proc skip*(socket: Socket) {.tags: [ReadIOEffect], deprecated.} = proc skip*(socket: Socket, size: int, timeout = -1) = ## Skips ``size`` amount of bytes. ## - ## An optional timeout can be specified in miliseconds, if skipping the + ## An optional timeout can be specified in milliseconds, if skipping the ## bytes takes longer than specified an ETimeout exception will be raised. ## ## Returns the number of skipped bytes. @@ -1708,7 +1709,7 @@ proc connect*(socket: Socket, address: string, port = Port(0), timeout: int, af: Domain = AF_INET) {.tags: [ReadIOEffect, WriteIOEffect].} = ## Connects to server as specified by ``address`` on port specified by ``port``. ## - ## The ``timeout`` paremeter specifies the time in miliseconds to allow for + ## The ``timeout`` paremeter specifies the time in milliseconds to allow for ## the connection to the server to be made. let originalStatus = not socket.nonblocking socket.setBlocking(false) diff --git a/lib/pure/streams.nim b/lib/pure/streams.nim index e706f2016..e6004b5d0 100644 --- a/lib/pure/streams.nim +++ b/lib/pure/streams.nim @@ -1,7 +1,7 @@ # # # Nim's Runtime Library -# (c) Copyright 2012 Andreas Rumpf +# (c) Copyright 2015 Andreas Rumpf # # See the file "copying.txt", included in this # distribution, for details about the copyright. @@ -31,6 +31,8 @@ type getPositionImpl*: proc (s: Stream): int {.nimcall, tags: [], gcsafe.} readDataImpl*: proc (s: Stream, buffer: pointer, bufLen: int): int {.nimcall, tags: [ReadIOEffect], gcsafe.} + peekDataImpl*: proc (s: Stream, buffer: pointer, + bufLen: int): int {.nimcall, tags: [ReadIOEffect], gcsafe.} writeDataImpl*: proc (s: Stream, buffer: pointer, bufLen: int) {.nimcall, tags: [WriteIOEffect], gcsafe.} flushImpl*: proc (s: Stream) {.nimcall, tags: [WriteIOEffect], gcsafe.} @@ -79,23 +81,28 @@ proc readData*(s: Stream, buffer: pointer, bufLen: int): int = ## low level proc that reads data into an untyped `buffer` of `bufLen` size. result = s.readDataImpl(s, buffer, bufLen) -proc readData*(s, unused: Stream, buffer: pointer, +proc readData*(s, unused: Stream, buffer: pointer, bufLen: int): int {.deprecated.} = ## low level proc that reads data into an untyped `buffer` of `bufLen` size. result = s.readDataImpl(s, buffer, bufLen) +proc peekData*(s: Stream, buffer: pointer, bufLen: int): int = + ## low level proc that reads data into an untyped `buffer` of `bufLen` size + ## without moving stream position + result = s.peekDataImpl(s, buffer, bufLen) + proc writeData*(s: Stream, buffer: pointer, bufLen: int) = ## low level proc that writes an untyped `buffer` of `bufLen` size ## to the stream `s`. s.writeDataImpl(s, buffer, bufLen) -proc writeData*(s, unused: Stream, buffer: pointer, +proc writeData*(s, unused: Stream, buffer: pointer, bufLen: int) {.deprecated.} = ## low level proc that writes an untyped `buffer` of `bufLen` size ## to the stream `s`. s.writeDataImpl(s, buffer, bufLen) -proc write*[T](s: Stream, x: T) = +proc write*[T](s: Stream, x: T) = ## generic write procedure. Writes `x` to the stream `s`. Implementation: ## ## .. code-block:: Nim @@ -105,8 +112,8 @@ proc write*[T](s: Stream, x: T) = shallowCopy(y, x) writeData(s, addr(y), sizeof(y)) -proc write*(s: Stream, x: string) = - ## writes the string `x` to the the stream `s`. No length field or +proc write*(s: Stream, x: string) = + ## writes the string `x` to the the stream `s`. No length field or ## terminating zero is written. writeData(s, cstring(x), x.len) @@ -116,51 +123,96 @@ proc writeln*(s: Stream, args: varargs[string, `$`]) = for str in args: write(s, str) write(s, "\n") -proc read[T](s: Stream, result: var T) = +proc read[T](s: Stream, result: var T) = ## generic read procedure. Reads `result` from the stream `s`. if readData(s, addr(result), sizeof(T)) != sizeof(T): raise newEIO("cannot read from stream") +proc peek[T](s: Stream, result: var T) = + ## generic peek procedure. Peeks `result` from the stream `s`. + if peekData(s, addr(result), sizeof(T)) != sizeof(T): + raise newEIO("cannot read from stream") + proc readChar*(s: Stream): char = ## reads a char from the stream `s`. Raises `EIO` if an error occurred. ## Returns '\0' as an EOF marker. if readData(s, addr(result), sizeof(result)) != 1: result = '\0' -proc readBool*(s: Stream): bool = +proc peekChar*(s: Stream): char = + ## peeks a char from the stream `s`. Raises `EIO` if an error occurred. + ## Returns '\0' as an EOF marker. + if peekData(s, addr(result), sizeof(result)) != 1: result = '\0' + +proc readBool*(s: Stream): bool = ## reads a bool from the stream `s`. Raises `EIO` if an error occurred. read(s, result) -proc readInt8*(s: Stream): int8 = +proc peekBool*(s: Stream): bool = + ## peeks a bool from the stream `s`. Raises `EIO` if an error occured. + peek(s, result) + +proc readInt8*(s: Stream): int8 = ## reads an int8 from the stream `s`. Raises `EIO` if an error occurred. read(s, result) -proc readInt16*(s: Stream): int16 = +proc peekInt8*(s: Stream): int8 = + ## peeks an int8 from the stream `s`. Raises `EIO` if an error occurred. + peek(s, result) + +proc readInt16*(s: Stream): int16 = ## reads an int16 from the stream `s`. Raises `EIO` if an error occurred. read(s, result) -proc readInt32*(s: Stream): int32 = +proc peekInt16*(s: Stream): int16 = + ## peeks an int16 from the stream `s`. Raises `EIO` if an error occurred. + peek(s, result) + +proc readInt32*(s: Stream): int32 = ## reads an int32 from the stream `s`. Raises `EIO` if an error occurred. read(s, result) -proc readInt64*(s: Stream): int64 = +proc peekInt32*(s: Stream): int32 = + ## peeks an int32 from the stream `s`. Raises `EIO` if an error occurred. + peek(s, result) + +proc readInt64*(s: Stream): int64 = ## reads an int64 from the stream `s`. Raises `EIO` if an error occurred. read(s, result) -proc readFloat32*(s: Stream): float32 = +proc peekInt64*(s: Stream): int64 = + ## peeks an int64 from the stream `s`. Raises `EIO` if an error occurred. + peek(s, result) + +proc readFloat32*(s: Stream): float32 = ## reads a float32 from the stream `s`. Raises `EIO` if an error occurred. read(s, result) -proc readFloat64*(s: Stream): float64 = +proc peekFloat32*(s: Stream): float32 = + ## peeks a float32 from the stream `s`. Raises `EIO` if an error occurred. + peek(s, result) + +proc readFloat64*(s: Stream): float64 = ## reads a float64 from the stream `s`. Raises `EIO` if an error occurred. read(s, result) -proc readStr*(s: Stream, length: int): TaintedString = - ## reads a string of length `length` from the stream `s`. Raises `EIO` if +proc peekFloat64*(s: Stream): float64 = + ## peeks a float64 from the stream `s`. Raises `EIO` if an error occurred. + peek(s, result) + +proc readStr*(s: Stream, length: int): TaintedString = + ## reads a string of length `length` from the stream `s`. Raises `EIO` if ## an error occurred. result = newString(length).TaintedString var L = readData(s, addr(string(result)[0]), length) if L != length: setLen(result.string, L) +proc peekStr*(s: Stream, length: int): TaintedString = + ## peeks a string of length `length` from the stream `s`. Raises `EIO` if + ## an error occurred. + result = newString(length).TaintedString + var L = peekData(s, addr(string(result)[0]), length) + if L != length: setLen(result.string, L) + proc readLine*(s: Stream, line: var TaintedString): bool = ## reads a line of text from the stream `s` into `line`. `line` must not be ## ``nil``! May throw an IO exception. @@ -171,7 +223,7 @@ proc readLine*(s: Stream, line: var TaintedString): bool = line.string.setLen(0) while true: var c = readChar(s) - if c == '\c': + if c == '\c': c = readChar(s) break elif c == '\L': break @@ -181,13 +233,24 @@ proc readLine*(s: Stream, line: var TaintedString): bool = line.string.add(c) result = true +proc peekLine*(s: Stream, line: var TaintedString): bool = + ## peeks a line of text from the stream `s` into `line`. `line` must not be + ## ``nil``! May throw an IO exception. + ## A line of text may be delimited by ``CR``, ``LF`` or + ## ``CRLF``. The newline character(s) are not part of the returned string. + ## Returns ``false`` if the end of the file has been reached, ``true`` + ## otherwise. If ``false`` is returned `line` contains no new data. + let pos = getPosition(s) + defer: setPosition(s, pos) + result = readLine(s, line) + proc readLine*(s: Stream): TaintedString = - ## Reads a line from a stream `s`. Note: This is not very efficient. Raises + ## Reads a line from a stream `s`. Note: This is not very efficient. Raises ## `EIO` if an error occurred. result = TaintedString"" while true: var c = readChar(s) - if c == '\c': + if c == '\c': c = readChar(s) break if c == '\L' or c == '\0': @@ -195,6 +258,13 @@ proc readLine*(s: Stream): TaintedString = else: result.string.add(c) +proc peekLine*(s: Stream): TaintedString = + ## Peeks a line from a stream `s`. Note: This is not very efficient. Raises + ## `EIO` if an error occurred. + let pos = getPosition(s) + defer: setPosition(s, pos) + result = readLine(s) + type StringStream* = ref StringStreamObj ## a stream that encapsulates a string StringStreamObj* = object of StreamObj @@ -206,8 +276,8 @@ type proc ssAtEnd(s: Stream): bool = var s = StringStream(s) return s.pos >= s.data.len - -proc ssSetPosition(s: Stream, pos: int) = + +proc ssSetPosition(s: Stream, pos: int) = var s = StringStream(s) s.pos = clamp(pos, 0, s.data.high) @@ -218,11 +288,17 @@ proc ssGetPosition(s: Stream): int = proc ssReadData(s: Stream, buffer: pointer, bufLen: int): int = var s = StringStream(s) result = min(bufLen, s.data.len - s.pos) - if result > 0: + if result > 0: copyMem(buffer, addr(s.data[s.pos]), result) inc(s.pos, result) -proc ssWriteData(s: Stream, buffer: pointer, bufLen: int) = +proc ssPeekData(s: Stream, buffer: pointer, bufLen: int): int = + var s = StringStream(s) + result = min(bufLen, s.data.len - s.pos) + if result > 0: + copyMem(buffer, addr(s.data[s.pos]), result) + +proc ssWriteData(s: Stream, buffer: pointer, bufLen: int) = var s = StringStream(s) if bufLen <= 0: return @@ -235,7 +311,7 @@ proc ssClose(s: Stream) = var s = StringStream(s) s.data = nil -proc newStringStream*(s: string = ""): StringStream = +proc newStringStream*(s: string = ""): StringStream = ## creates a new stream from the string `s`. new(result) result.data = s @@ -245,12 +321,13 @@ proc newStringStream*(s: string = ""): StringStream = result.setPositionImpl = ssSetPosition result.getPositionImpl = ssGetPosition result.readDataImpl = ssReadData + result.peekDataImpl = ssPeekData result.writeDataImpl = ssWriteData when not defined(js): type - FileStream* = ref FileStreamObj ## a stream that encapsulates a `TFile` + FileStream* = ref FileStreamObj ## a stream that encapsulates a `File` FileStreamObj* = object of Stream f: File {.deprecated: [PFileStream: FileStream, TFileStream: FileStreamObj].} @@ -267,6 +344,11 @@ when not defined(js): proc fsReadData(s: Stream, buffer: pointer, bufLen: int): int = result = readBuffer(FileStream(s).f, buffer, bufLen) + proc fsPeekData(s: Stream, buffer: pointer, bufLen: int): int = + let pos = fsGetPosition(s) + defer: fsSetPosition(s, pos) + result = readBuffer(FileStream(s).f, buffer, bufLen) + proc fsWriteData(s: Stream, buffer: pointer, bufLen: int) = if writeBuffer(FileStream(s).f, buffer, bufLen) != bufLen: raise newEIO("cannot write to stream") @@ -280,6 +362,7 @@ when not defined(js): result.setPositionImpl = fsSetPosition result.getPositionImpl = fsGetPosition result.readDataImpl = fsReadData + result.peekDataImpl = fsPeekData result.writeDataImpl = fsWriteData result.flushImpl = fsFlush @@ -300,14 +383,14 @@ else: handle*: FileHandle pos: int - {.deprecated: [PFileHandleStream: FileHandleStream, + {.deprecated: [PFileHandleStream: FileHandleStream, TFileHandleStream: FileHandleStreamObj].} proc newEOS(msg: string): ref OSError = new(result) result.msg = msg - proc hsGetPosition(s: FileHandleStream): int = + proc hsGetPosition(s: FileHandleStream): int = return s.pos when defined(windows): @@ -315,27 +398,30 @@ else: discard else: import posix - - proc hsSetPosition(s: FileHandleStream, pos: int) = + + proc hsSetPosition(s: FileHandleStream, pos: int) = discard lseek(s.handle, pos, SEEK_SET) proc hsClose(s: FileHandleStream) = discard close(s.handle) - proc hsAtEnd(s: FileHandleStream): bool = + proc hsAtEnd(s: FileHandleStream): bool = var pos = hsGetPosition(s) var theEnd = lseek(s.handle, 0, SEEK_END) result = pos >= theEnd hsSetPosition(s, pos) # set position back - proc hsReadData(s: FileHandleStream, buffer: pointer, bufLen: int): int = + proc hsReadData(s: FileHandleStream, buffer: pointer, bufLen: int): int = result = posix.read(s.handle, buffer, bufLen) inc(s.pos, result) - - proc hsWriteData(s: FileHandleStream, buffer: pointer, bufLen: int) = - if posix.write(s.handle, buffer, bufLen) != bufLen: + + proc hsPeekData(s: FileHandleStream, buffer: pointer, bufLen: int): int = + result = posix.read(s.handle, buffer, bufLen) + + proc hsWriteData(s: FileHandleStream, buffer: pointer, bufLen: int) = + if posix.write(s.handle, buffer, bufLen) != bufLen: raise newEIO("cannot write to stream") inc(s.pos, bufLen) - proc newFileHandleStream*(handle: FileHandle): FileHandleStream = + proc newFileHandleStream*(handle: FileHandle): FileHandleStream = new(result) result.handle = handle result.pos = 0 @@ -344,10 +430,11 @@ else: result.setPosition = hsSetPosition result.getPosition = hsGetPosition result.readData = hsReadData + result.peekData = hsPeekData result.writeData = hsWriteData - proc newFileHandleStream*(filename: string, - mode: FileMode): FileHandleStream = + proc newFileHandleStream*(filename: string, + mode: FileMode): FileHandleStream = when defined(windows): discard else: @@ -361,3 +448,17 @@ else: var handle = open(filename, flags) if handle < 0: raise newEOS("posix.open() call failed") result = newFileHandleStream(handle) + +when isMainModule and defined(testing): + var ss = newStringStream("The quick brown fox jumped over the lazy dog.\nThe lazy dog ran") + assert(ss.getPosition == 0) + assert(ss.peekStr(5) == "The q") + assert(ss.getPosition == 0) # haven't moved + assert(ss.readStr(5) == "The q") + assert(ss.getPosition == 5) # did move + assert(ss.peekLine() == "uick brown fox jumped over the lazy dog.") + assert(ss.getPosition == 5) # haven't moved + var str = newString(100) + assert(ss.peekLine(str)) + assert(str == "uick brown fox jumped over the lazy dog.") + assert(ss.getPosition == 5) # haven't moved diff --git a/lib/pure/strtabs.nim b/lib/pure/strtabs.nim index 7fdd994f2..86f81aa43 100644 --- a/lib/pure/strtabs.nim +++ b/lib/pure/strtabs.nim @@ -74,7 +74,7 @@ const growthFactor = 2 startSize = 64 -proc myhash(t: StringTableRef, key: string): THash = +proc myhash(t: StringTableRef, key: string): Hash = case t.mode of modeCaseSensitive: result = hashes.hash(key) of modeCaseInsensitive: result = hashes.hashIgnoreCase(key) @@ -90,11 +90,11 @@ proc mustRehash(length, counter: int): bool = assert(length > counter) result = (length * 2 < counter * 3) or (length - counter < 4) -proc nextTry(h, maxHash: THash): THash {.inline.} = +proc nextTry(h, maxHash: Hash): Hash {.inline.} = result = ((5 * h) + 1) and maxHash proc rawGet(t: StringTableRef, key: string): int = - var h: THash = myhash(t, key) and high(t.data) # start with real hash value + var h: Hash = myhash(t, key) and high(t.data) # start with real hash value while not isNil(t.data[h].key): if myCmp(t, t.data[h].key, key): return h @@ -122,7 +122,7 @@ proc hasKey*(t: StringTableRef, key: string): bool {.rtl, extern: "nst$1".} = result = rawGet(t, key) >= 0 proc rawInsert(t: StringTableRef, data: var KeyValuePairSeq, key, val: string) = - var h: THash = myhash(t, key) and high(data) + var h: Hash = myhash(t, key) and high(data) while not isNil(data[h].key): h = nextTry(h, high(data)) data[h].key = key diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim index 59cebf7fa..317da9a0a 100644 --- a/lib/pure/strutils.nim +++ b/lib/pure/strutils.nim @@ -23,7 +23,8 @@ import parseutils include "system/inclrtl" type - TCharSet* {.deprecated.} = set[char] # for compatibility with Nim + CharSet* {.deprecated.} = set[char] # for compatibility with Nim +{.deprecated: [TCharSet: CharSet].} const Whitespace* = {' ', '\t', '\v', '\r', '\l', '\f'} @@ -169,14 +170,12 @@ proc cmpIgnoreStyle*(a, b: string): int {.noSideEffect, {.pop.} -proc strip*(s: string, leading = true, trailing = true): string {.noSideEffect, - rtl, extern: "nsuStrip".} = - ## Strips whitespace from `s` and returns the resulting string. +proc strip*(s: string, leading = true, trailing = true, chars: set[char] = Whitespace): string + {.noSideEffect, rtl, extern: "nsuStrip".} = + ## Strips `chars` from `s` and returns the resulting string. ## - ## If `leading` is true, leading whitespace is stripped. - ## If `trailing` is true, trailing whitespace is stripped. - const - chars: set[char] = Whitespace + ## If `leading` is true, leading `chars` are stripped. + ## If `trailing` is true, trailing `chars` are stripped. var first = 0 last = len(s)-1 @@ -1433,3 +1432,11 @@ when isMainModule: doAssert count("foofoofoo", "foofoo", overlapping = true) == 2 doAssert count("foofoofoo", 'f') == 3 doAssert count("foofoofoobar", {'f','b'}) == 4 + + doAssert strip(" foofoofoo ") == "foofoofoo" + doAssert strip("sfoofoofoos", chars = {'s'}) == "foofoofoo" + doAssert strip("barfoofoofoobar", chars = {'b', 'a', 'r'}) == "foofoofoo" + doAssert strip("stripme but don't strip this stripme", + chars = {'s', 't', 'r', 'i', 'p', 'm', 'e'}) == " but don't strip this " + doAssert strip("sfoofoofoos", leading = false, chars = {'s'}) == "sfoofoofoo" + doAssert strip("sfoofoofoos", trailing = false, chars = {'s'}) == "foofoofoos" diff --git a/lib/pure/subexes.nim b/lib/pure/subexes.nim index d213c99e6..46824645d 100644 --- a/lib/pure/subexes.nim +++ b/lib/pure/subexes.nim @@ -37,13 +37,14 @@ proc raiseInvalidFormat(msg: string) {.noinline.} = raise newException(SubexError, "invalid format string: " & msg) type - TFormatParser = object {.pure, final.} + FormatParser = object {.pure, final.} when defined(js): f: string # we rely on the '\0' terminator # which JS's native string doesn't have else: f: cstring num, i, lineLen: int +{.deprecated: [TFormatParser: FormatParser].} template call(x: stmt) {.immediate.} = p.i = i @@ -57,7 +58,7 @@ template callNoLineLenTracking(x: stmt) {.immediate.} = i = p.i p.lineLen = oldLineLen -proc getFormatArg(p: var TFormatParser, a: openArray[string]): int = +proc getFormatArg(p: var FormatParser, a: openArray[string]): int = const PatternChars = {'a'..'z', 'A'..'Z', '0'..'9', '\128'..'\255', '_'} var i = p.i var f = p.f @@ -90,22 +91,22 @@ proc getFormatArg(p: var TFormatParser, a: openArray[string]): int = if result >=% a.len: raiseInvalidFormat("index out of bounds: " & $result) p.i = i -proc scanDollar(p: var TFormatParser, a: openarray[string], s: var string) {. +proc scanDollar(p: var FormatParser, a: openarray[string], s: var string) {. noSideEffect.} -proc emitChar(p: var TFormatParser, x: var string, ch: char) {.inline.} = +proc emitChar(p: var FormatParser, x: var string, ch: char) {.inline.} = x.add(ch) if ch == '\L': p.lineLen = 0 else: inc p.lineLen -proc emitStrLinear(p: var TFormatParser, x: var string, y: string) {.inline.} = +proc emitStrLinear(p: var FormatParser, x: var string, y: string) {.inline.} = for ch in items(y): emitChar(p, x, ch) -proc emitStr(p: var TFormatParser, x: var string, y: string) {.inline.} = +proc emitStr(p: var FormatParser, x: var string, y: string) {.inline.} = x.add(y) inc p.lineLen, y.len -proc scanQuote(p: var TFormatParser, x: var string, toAdd: bool) = +proc scanQuote(p: var FormatParser, x: var string, toAdd: bool) = var i = p.i+1 var f = p.f while true: @@ -120,7 +121,7 @@ proc scanQuote(p: var TFormatParser, x: var string, toAdd: bool) = inc i p.i = i -proc scanBranch(p: var TFormatParser, a: openArray[string], +proc scanBranch(p: var FormatParser, a: openArray[string], x: var string, choice: int) = var i = p.i var f = p.f @@ -167,7 +168,7 @@ proc scanBranch(p: var TFormatParser, a: openArray[string], i = last p.i = i+1 -proc scanSlice(p: var TFormatParser, a: openarray[string]): tuple[x, y: int] = +proc scanSlice(p: var FormatParser, a: openarray[string]): tuple[x, y: int] = var slice = false var i = p.i var f = p.f @@ -193,7 +194,7 @@ proc scanSlice(p: var TFormatParser, a: openarray[string]): tuple[x, y: int] = inc i p.i = i -proc scanDollar(p: var TFormatParser, a: openarray[string], s: var string) = +proc scanDollar(p: var FormatParser, a: openarray[string], s: var string) = var i = p.i var f = p.f case f[i] @@ -312,7 +313,7 @@ proc subex*(s: string): Subex = proc addf*(s: var string, formatstr: Subex, a: varargs[string, `$`]) {. noSideEffect, rtl, extern: "nfrmtAddf".} = ## The same as ``add(s, formatstr % a)``, but more efficient. - var p: TFormatParser + var p: FormatParser p.f = formatstr.string var i = 0 while i < len(formatstr.string): @@ -386,10 +387,10 @@ when isMainModule: longishA, longish)""" - assert "type TMyEnum* = enum\n $', '2i'\n '{..}" % ["fieldA", + assert "type MyEnum* = enum\n $', '2i'\n '{..}" % ["fieldA", "fieldB", "FiledClkad", "fieldD", "fieldE", "longishFieldName"] == strutils.unindent """ - type TMyEnum* = enum + type MyEnum* = enum fieldA, fieldB, FiledClkad, fieldD, fieldE, longishFieldName""" @@ -400,11 +401,11 @@ when isMainModule: doAssert subex"$['''|'|''''|']']#" % "0" == "'|" - assert subex("type\n TEnum = enum\n $', '40c'\n '{..}") % [ + assert subex("type\n Enum = enum\n $', '40c'\n '{..}") % [ "fieldNameA", "fieldNameB", "fieldNameC", "fieldNameD"] == strutils.unindent """ type - TEnum = enum + Enum = enum fieldNameA, fieldNameB, fieldNameC, fieldNameD""" diff --git a/lib/pure/terminal.nim b/lib/pure/terminal.nim index 29f700db5..1e9c40f06 100644 --- a/lib/pure/terminal.nim +++ b/lib/pure/terminal.nim @@ -20,7 +20,7 @@ when defined(windows): import windows, os var - conHandle: THandle + conHandle: Handle # = createFile("CONOUT$", GENERIC_WRITE, 0, nil, OPEN_ALWAYS, 0, 0) block: @@ -30,13 +30,13 @@ when defined(windows): raiseOSError(osLastError()) proc getCursorPos(): tuple [x,y: int] = - var c: TCONSOLESCREENBUFFERINFO + var c: CONSOLESCREENBUFFERINFO if GetConsoleScreenBufferInfo(conHandle, addr(c)) == 0: raiseOSError(osLastError()) return (int(c.dwCursorPosition.X), int(c.dwCursorPosition.Y)) proc getAttributes(): int16 = - var c: TCONSOLESCREENBUFFERINFO + var c: CONSOLESCREENBUFFERINFO # workaround Windows bugs: try several times if GetConsoleScreenBufferInfo(conHandle, addr(c)) != 0: return c.wAttributes @@ -51,11 +51,11 @@ else: proc setRaw(fd: FileHandle, time: cint = TCSAFLUSH) = var mode: Termios discard fd.tcgetattr(addr mode) - mode.c_iflag = mode.c_iflag and not Tcflag(BRKINT or ICRNL or INPCK or + mode.c_iflag = mode.c_iflag and not Cflag(BRKINT or ICRNL or INPCK or ISTRIP or IXON) - mode.c_oflag = mode.c_oflag and not Tcflag(OPOST) - mode.c_cflag = (mode.c_cflag and not Tcflag(CSIZE or PARENB)) or CS8 - mode.c_lflag = mode.c_lflag and not Tcflag(ECHO or ICANON or IEXTEN or ISIG) + mode.c_oflag = mode.c_oflag and not Cflag(OPOST) + mode.c_cflag = (mode.c_cflag and not Cflag(CSIZE or PARENB)) or CS8 + mode.c_lflag = mode.c_lflag and not Cflag(ECHO or ICANON or IEXTEN or ISIG) mode.c_cc[VMIN] = 1.cuchar mode.c_cc[VTIME] = 0.cuchar discard fd.tcsetattr(time, addr mode) @@ -64,7 +64,7 @@ proc setCursorPos*(x, y: int) = ## sets the terminal's cursor to the (x,y) position. (0,0) is the ## upper left of the screen. when defined(windows): - var c: TCOORD + var c: COORD c.X = int16(x) c.Y = int16(y) if SetConsoleCursorPosition(conHandle, c) == 0: raiseOSError(osLastError()) @@ -75,7 +75,7 @@ proc setCursorXPos*(x: int) = ## sets the terminal's cursor to the x position. The y position is ## not changed. when defined(windows): - var scrbuf: TCONSOLESCREENBUFFERINFO + var scrbuf: CONSOLESCREENBUFFERINFO var hStdout = conHandle if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0: raiseOSError(osLastError()) @@ -91,7 +91,7 @@ when defined(windows): ## sets the terminal's cursor to the y position. The x position is ## not changed. **Warning**: This is not supported on UNIX! when defined(windows): - var scrbuf: TCONSOLESCREENBUFFERINFO + var scrbuf: CONSOLESCREENBUFFERINFO var hStdout = conHandle if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0: raiseOSError(osLastError()) @@ -172,7 +172,7 @@ else: proc eraseLine* = ## Erases the entire current line. when defined(windows): - var scrbuf: TCONSOLESCREENBUFFERINFO + var scrbuf: CONSOLESCREENBUFFERINFO var numwrote: DWORD var hStdout = conHandle if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0: @@ -196,9 +196,9 @@ proc eraseLine* = proc eraseScreen* = ## Erases the screen with the background colour and moves the cursor to home. when defined(windows): - var scrbuf: TCONSOLESCREENBUFFERINFO + var scrbuf: CONSOLESCREENBUFFERINFO var numwrote: DWORD - var origin: TCOORD # is inititalized to 0, 0 + var origin: COORD # is inititalized to 0, 0 var hStdout = conHandle if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0: @@ -364,7 +364,13 @@ macro styledEcho*(m: varargs[expr]): stmt = result.add(newCall(bindSym"write", bindSym"stdout", newStrLitNode("\n"))) result.add(newCall(bindSym"resetAttributes")) -when not defined(windows): +when defined(nimdoc): + proc getch*(): char = + ## Read a single character from the terminal, blocking until it is entered. + ## The character is not printed to the terminal. This is not available for + ## Windows. + discard +elif not defined(windows): proc getch*(): char = ## Read a single character from the terminal, blocking until it is entered. ## The character is not printed to the terminal. This is not available for diff --git a/lib/pure/times.nim b/lib/pure/times.nim index 5f8835c6a..597488782 100644 --- a/lib/pure/times.nim +++ b/lib/pure/times.nim @@ -119,7 +119,7 @@ type ## in the range 0 to 23. monthday*: range[1..31] ## The day of the month, in the range 1 to 31. month*: Month ## The current month. - year*: range[-10_000..10_000] ## The current year. + year*: int ## The current year. weekday*: WeekDay ## The current day of the week. yearday*: range[0..365] ## The number of days since January 1, ## in the range 0 to 365. @@ -134,7 +134,7 @@ type ## everything should be positive or everything negative. Zero is ## fine too. Mixed signs will lead to unexpected results. TimeInterval* = object ## a time interval - miliseconds*: int ## The number of miliseconds + milliseconds*: int ## The number of milliseconds seconds*: int ## The number of seconds minutes*: int ## The number of minutes hours*: int ## The number of hours @@ -145,6 +145,11 @@ type {.deprecated: [TMonth: Month, TWeekDay: WeekDay, TTime: Time, TTimeInterval: TimeInterval, TTimeInfo: TimeInfo].} +proc miliseconds*(t: TimeInterval): int {.deprecated.} = t.milliseconds + +proc `miliseconds=`*(t:var TimeInterval, milliseconds: int) {.deprecated.} = + t.milliseconds = milliseconds + proc getTime*(): Time {.tags: [TimeEffect], benign.} ## gets the current calendar time as a UNIX epoch value (number of seconds ## elapsed since 1970) with integer precission. Use epochTime for higher @@ -208,13 +213,13 @@ proc getTimezone*(): int {.tags: [TimeEffect], raises: [], benign.} ## returns the offset of the local (non-DST) timezone in seconds west of UTC. proc getStartMilsecs*(): int {.deprecated, tags: [TimeEffect], benign.} - ## get the miliseconds from the start of the program. **Deprecated since + ## get the milliseconds from the start of the program. **Deprecated since ## version 0.8.10.** Use ``epochTime`` or ``cpuTime`` instead. -proc initInterval*(miliseconds, seconds, minutes, hours, days, months, +proc initInterval*(milliseconds, seconds, minutes, hours, days, months, years: int = 0): TimeInterval = ## creates a new ``TimeInterval``. - result.miliseconds = miliseconds + result.milliseconds = milliseconds result.seconds = seconds result.minutes = minutes result.hours = hours @@ -264,7 +269,7 @@ proc toSeconds(a: TimeInfo, interval: TimeInterval): float = result += float(newinterv.hours * 60 * 60) result += float(newinterv.minutes * 60) result += float(newinterv.seconds) - result += newinterv.miliseconds / 1000 + result += newinterv.milliseconds / 1000 proc `+`*(a: TimeInfo, interval: TimeInterval): TimeInfo = ## adds ``interval`` time. @@ -379,7 +384,7 @@ when not defined(JS): result.hour = t.hour result.monthday = t.monthday result.month = ord(t.month) - result.year = t.year - 1900 + result.year = cint(t.year - 1900) result.weekday = weekDays[t.weekday] result.yearday = t.yearday result.isdst = if t.isDST: 1 else: 0 @@ -465,7 +470,7 @@ when not defined(JS): posix_gettimeofday(a) result = toFloat(a.tv_sec) + toFloat(a.tv_usec)*0.00_0001 elif defined(windows): - var f: winlean.TFILETIME + var f: winlean.FILETIME getSystemTimeAsFileTime(f) var i64 = rdFileTime(f) - epochDiff var secs = i64 div rateDiff @@ -530,7 +535,7 @@ elif defined(JS): startMilsecs = getTime() proc getStartMilsecs(): int = - ## get the miliseconds from the start of the program + ## get the milliseconds from the start of the program return int(getTime() - startMilsecs) proc valueOf(time: Time): float {.importcpp: "getTime", tags:[]} diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim index 3bf4724b9..dbbd3cabc 100644 --- a/lib/pure/unittest.nim +++ b/lib/pure/unittest.nim @@ -99,8 +99,9 @@ template test*(name: expr, body: stmt): stmt {.immediate, dirty.} = body except: - checkpoint("Unhandled exception: " & getCurrentExceptionMsg()) - echo getCurrentException().getStackTrace() + when not defined(js): + checkpoint("Unhandled exception: " & getCurrentExceptionMsg()) + echo getCurrentException().getStackTrace() fail() finally: @@ -114,9 +115,7 @@ proc checkpoint*(msg: string) = template fail* = bind checkpoints for msg in items(checkpoints): - # this used to be 'echo' which now breaks due to a bug. XXX will revisit - # this issue later. - stdout.writeln msg + echo msg when not defined(ECMAScript): if abortOnError: quit(1) @@ -157,12 +156,13 @@ macro check*(conditions: stmt): stmt {.immediate.} = # Ident !"v" # IntLit 2 paramAst = exp[i][1] - argsAsgns.add getAst(asgn(arg, paramAst)) - argsPrintOuts.add getAst(print(argStr, arg)) - if exp[i].kind != nnkExprEqExpr: - exp[i] = arg - else: - exp[i][1] = arg + if exp[i].typekind notin {ntyTypeDesc}: + argsAsgns.add getAst(asgn(arg, paramAst)) + argsPrintOuts.add getAst(print(argStr, arg)) + if exp[i].kind != nnkExprEqExpr: + exp[i] = arg + else: + exp[i][1] = arg case checked.kind of nnkCallKinds: diff --git a/lib/pure/xmltree.nim b/lib/pure/xmltree.nim index 7526a989a..bbe3c05b7 100644 --- a/lib/pure/xmltree.nim +++ b/lib/pure/xmltree.nim @@ -337,8 +337,7 @@ proc findAll*(n: XmlNode, tag: string, result: var seq[XmlNode]) = continue if child.tag == tag: result.add(child) - elif child.k == xnElement: - child.findAll(tag, result) + child.findAll(tag, result) proc findAll*(n: XmlNode, tag: string): seq[XmlNode] = ## Shortcut version to assign in let blocks. Example: diff --git a/lib/system.nim b/lib/system.nim index 33eee42f0..90587f306 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -61,7 +61,7 @@ const on* = true ## alias for ``true`` off* = false ## alias for ``false`` -{.push warning[GcMem]: off.} +{.push warning[GcMem]: off, warning[Uninit]: off.} {.push hints: off.} type @@ -249,7 +249,7 @@ when defined(nimNewShared): guarded* {.magic: "Guarded".} # comparison operators: -proc `==` *[TEnum: enum](x, y: TEnum): bool {.magic: "EqEnum", noSideEffect.} +proc `==` *[Enum: enum](x, y: Enum): bool {.magic: "EqEnum", noSideEffect.} proc `==` *(x, y: pointer): bool {.magic: "EqRef", noSideEffect.} proc `==` *(x, y: string): bool {.magic: "EqStr", noSideEffect.} proc `==` *(x, y: cstring): bool {.magic: "EqCString", noSideEffect.} @@ -260,7 +260,7 @@ proc `==` *[T](x, y: ref T): bool {.magic: "EqRef", noSideEffect.} proc `==` *[T](x, y: ptr T): bool {.magic: "EqRef", noSideEffect.} proc `==` *[T: proc](x, y: T): bool {.magic: "EqProc", noSideEffect.} -proc `<=` *[TEnum: enum](x, y: TEnum): bool {.magic: "LeEnum", noSideEffect.} +proc `<=` *[Enum: enum](x, y: Enum): bool {.magic: "LeEnum", noSideEffect.} proc `<=` *(x, y: string): bool {.magic: "LeStr", noSideEffect.} proc `<=` *(x, y: char): bool {.magic: "LeCh", noSideEffect.} proc `<=` *[T](x, y: set[T]): bool {.magic: "LeSet", noSideEffect.} @@ -268,7 +268,7 @@ proc `<=` *(x, y: bool): bool {.magic: "LeB", noSideEffect.} proc `<=` *[T](x, y: ref T): bool {.magic: "LePtr", noSideEffect.} proc `<=` *(x, y: pointer): bool {.magic: "LePtr", noSideEffect.} -proc `<` *[TEnum: enum](x, y: TEnum): bool {.magic: "LtEnum", noSideEffect.} +proc `<` *[Enum: enum](x, y: Enum): bool {.magic: "LtEnum", noSideEffect.} proc `<` *(x, y: string): bool {.magic: "LtStr", noSideEffect.} proc `<` *(x, y: char): bool {.magic: "LtCh", noSideEffect.} proc `<` *[T](x, y: set[T]): bool {.magic: "LtSet", noSideEffect.} @@ -332,7 +332,7 @@ type RootObj* {.exportc: "TNimObject", inheritable.} = object ## the root of Nim's object hierarchy. Objects should - ## inherit from TObject or one of its descendants. However, + ## inherit from RootObj or one of its descendants. However, ## objects that have no ancestor are allowed. RootRef* = ref RootObj ## reference to RootObj @@ -1110,7 +1110,7 @@ var programResult* {.exportc: "nim_program_result".}: int ## prematurely using ``quit``, this value is ignored. proc quit*(errorcode: int = QuitSuccess) {. - magic: "Exit", importc: "exit", header: "<stdlib.h>", noReturn.} + magic: "Exit", importc: "exit", header: "<stdlib.h>", noreturn.} ## Stops the program immediately with an exit code. ## ## Before stopping the program the "quit procedures" are called in the @@ -1505,7 +1505,7 @@ proc `$` *(x: string): string {.magic: "StrToStr", noSideEffect.} ## as it is. This operator is useful for generic code, so ## that ``$expr`` also works if ``expr`` is already a string. -proc `$` *[TEnum: enum](x: TEnum): string {.magic: "EnumToStr", noSideEffect.} +proc `$` *[Enum: enum](x: Enum): string {.magic: "EnumToStr", noSideEffect.} ## The stringify operator for an enumeration argument. This works for ## any enumeration type thanks to compiler magic. If ## a ``$`` operator for a concrete enumeration is provided, this is @@ -1535,7 +1535,7 @@ const NimMinor*: int = 11 ## is the minor number of Nim's version. - NimPatch*: int = 0 + NimPatch*: int = 3 ## is the patch number of Nim's version. NimVersion*: string = $NimMajor & "." & $NimMinor & "." & $NimPatch @@ -1578,7 +1578,7 @@ else: type IntLikeForCount = int|int8|int16|int32|char|bool|uint8|uint16|enum iterator countdown*[T](a, b: T, step = 1): T {.inline.} = - ## Counts from ordinal value `a` down to `b` with the given + ## Counts from ordinal value `a` down to `b` (inclusive) with the given ## step count. `T` may be any ordinal type, `step` may only ## be positive. **Note**: This fails to count to ``low(int)`` if T = int for ## efficiency reasons. @@ -1606,7 +1606,7 @@ template countupImpl(incr: stmt) {.immediate, dirty.} = incr iterator countup*[S, T](a: S, b: T, step = 1): T {.inline.} = - ## Counts from ordinal value `a` up to `b` with the given + ## Counts from ordinal value `a` up to `b` (inclusive) with the given ## step count. `S`, `T` may be any ordinal type, `step` may only ## be positive. **Note**: This fails to count to ``high(int)`` if T = int for ## efficiency reasons. @@ -2213,6 +2213,7 @@ type filename*: cstring ## filename of the proc that is currently executing len*: int16 ## length of the inspectable slots calldepth*: int16 ## used for max call depth checking +#{.deprecated: [TFrame: Frame].} when defined(JS): proc add*(x: var string, y: cstring) {.asmNoStackFrame.} = @@ -2248,14 +2249,14 @@ proc echo*(x: varargs[expr, `$`]) {.magic: "Echo", tags: [WriteIOEffect], ## Unlike other IO operations this is guaranteed to be thread-safe as ## ``echo`` is very often used for debugging convenience. If you want to use ## ``echo`` inside a `proc without side effects - ## <manual.html#nosideeffect-pragma>`_ you can use `debugEcho <#debugEcho>`_ + ## <manual.html#pragmas-nosideeffect-pragma>`_ you can use `debugEcho <#debugEcho>`_ ## instead. proc debugEcho*(x: varargs[expr, `$`]) {.magic: "Echo", noSideEffect, tags: [], raises: [].} ## Same as `echo <#echo>`_, but as a special semantic rule, ``debugEcho`` ## pretends to be free of side effects, so that it can be used for debugging - ## routines marked as `noSideEffect <manual.html#nosideeffect-pragma>`_. + ## routines marked as `noSideEffect <manual.html#pragmas-nosideeffect-pragma>`_. template newException*(exceptn: typedesc, message: string): expr = ## creates an exception object of type ``exceptn`` and sets its ``msg`` field @@ -2270,20 +2271,21 @@ when hostOS == "standalone": include panicoverride when not declared(sysFatal): - template sysFatal(exceptn: typedesc, message: string) = - when hostOS == "standalone": + when hostOS == "standalone": + proc sysFatal(exceptn: typedesc, message: string) {.inline.} = panic(message) - else: + + proc sysFatal(exceptn: typedesc, message, arg: string) {.inline.} = + rawoutput(message) + panic(arg) + else: + proc sysFatal(exceptn: typedesc, message: string) {.inline, noReturn.} = var e: ref exceptn new(e) e.msg = message raise e - template sysFatal(exceptn: typedesc, message, arg: string) = - when hostOS == "standalone": - rawoutput(message) - panic(arg) - else: + proc sysFatal(exceptn: typedesc, message, arg: string) {.inline, noReturn.} = var e: ref exceptn new(e) e.msg = message & arg @@ -2413,7 +2415,7 @@ when not defined(JS): #and not defined(NimrodVM): proc open*(f: var File, filehandle: FileHandle, mode: FileMode = fmRead): bool {.tags: [], benign.} - ## Creates a ``TFile`` from a `filehandle` with given `mode`. + ## Creates a ``File`` from a `filehandle` with given `mode`. ## ## Default mode is readonly. Returns true iff the file could be opened. @@ -2603,6 +2605,8 @@ when not defined(JS): #and not defined(NimrodVM): context: C_JmpBuf hasRaiseAction: bool raiseAction: proc (e: ref Exception): bool {.closure.} + SafePoint = TSafePoint +# {.deprecated: [TSafePoint: SafePoint].} when declared(initAllocator): initAllocator() @@ -3053,9 +3057,10 @@ proc raiseAssert*(msg: string) {.noinline.} = proc failedAssertImpl*(msg: string) {.raises: [], tags: [].} = # trick the compiler to not list ``AssertionError`` when called # by ``assert``. - type THide = proc (msg: string) {.noinline, raises: [], noSideEffect, + type Hide = proc (msg: string) {.noinline, raises: [], noSideEffect, tags: [].} - THide(raiseAssert)(msg) + {.deprecated: [THide: Hide].} + Hide(raiseAssert)(msg) template assert*(cond: bool, msg = "") = ## Raises ``AssertionError`` with `msg` if `cond` is false. Note @@ -3272,4 +3277,4 @@ proc xlen*[T](x: seq[T]): int {.magic: "XLenSeq", noSideEffect.} = ## This is an optimization that rarely makes sense. discard -{.pop.} #{.push warning[GcMem]: off.} +{.pop.} #{.push warning[GcMem]: off, warning[Uninit]: off.} diff --git a/lib/system/alloc.nim b/lib/system/alloc.nim index ad3419808..76232499e 100644 --- a/lib/system/alloc.nim +++ b/lib/system/alloc.nim @@ -98,46 +98,49 @@ const SmallChunkSize = PageSize type - PTrunk = ptr TTrunk - TTrunk {.final.} = object + PTrunk = ptr Trunk + Trunk {.final.} = object next: PTrunk # all nodes are connected with this pointer key: int # start address at bit 0 bits: array[0..IntsPerTrunk-1, int] # a bit vector - TTrunkBuckets = array[0..255, PTrunk] - TIntSet {.final.} = object - data: TTrunkBuckets + TrunkBuckets = array[0..255, PTrunk] + IntSet {.final.} = object + data: TrunkBuckets +{.deprecated: [TIntSet: IntSet, TTrunk: Trunk, TTrunkBuckets: TrunkBuckets].} type - TAlignType = BiggestFloat - TFreeCell {.final, pure.} = object - next: ptr TFreeCell # next free cell in chunk (overlaid with refcount) + AlignType = BiggestFloat + FreeCell {.final, pure.} = object + next: ptr FreeCell # next free cell in chunk (overlaid with refcount) zeroField: int # 0 means cell is not used (overlaid with typ field) # 1 means cell is manually managed pointer # otherwise a PNimType is stored in there - PChunk = ptr TBaseChunk - PBigChunk = ptr TBigChunk - PSmallChunk = ptr TSmallChunk - TBaseChunk {.pure, inheritable.} = object + PChunk = ptr BaseChunk + PBigChunk = ptr BigChunk + PSmallChunk = ptr SmallChunk + BaseChunk {.pure, inheritable.} = object prevSize: int # size of previous chunk; for coalescing size: int # if < PageSize it is a small chunk used: bool # later will be optimized into prevSize... - TSmallChunk = object of TBaseChunk + SmallChunk = object of BaseChunk next, prev: PSmallChunk # chunks of the same size - freeList: ptr TFreeCell + freeList: ptr FreeCell free: int # how many bytes remain acc: int # accumulator for small object allocation - data: TAlignType # start of usable memory + data: AlignType # start of usable memory - TBigChunk = object of TBaseChunk # not necessarily > PageSize! + BigChunk = object of BaseChunk # not necessarily > PageSize! next, prev: PBigChunk # chunks of the same (or bigger) size align: int - data: TAlignType # start of usable memory + data: AlignType # start of usable memory +{.deprecated: [TAlignType: AlignType, TFreeCell: FreeCell, TBaseChunk: BaseChunk, + TBigChunk: BigChunk, TSmallChunk: SmallChunk].} -template smallChunkOverhead(): expr = sizeof(TSmallChunk)-sizeof(TAlignType) -template bigChunkOverhead(): expr = sizeof(TBigChunk)-sizeof(TAlignType) +template smallChunkOverhead(): expr = sizeof(SmallChunk)-sizeof(AlignType) +template bigChunkOverhead(): expr = sizeof(BigChunk)-sizeof(AlignType) proc roundup(x, v: int): int {.inline.} = result = (x + (v-1)) and not (v-1) @@ -156,31 +159,32 @@ sysAssert(roundup(65, 8) == 72, "roundup broken 2") # to the OS), a fixed size array can be used. type - PLLChunk = ptr TLLChunk - TLLChunk {.pure.} = object ## *low-level* chunk + PLLChunk = ptr LLChunk + LLChunk {.pure.} = object ## *low-level* chunk size: int # remaining size acc: int # accumulator next: PLLChunk # next low-level chunk; only needed for dealloc - PAvlNode = ptr TAvlNode - TAvlNode {.pure, final.} = object + PAvlNode = ptr AvlNode + AvlNode {.pure, final.} = object link: array[0..1, PAvlNode] # Left (0) and right (1) links key, upperBound: int level: int - TMemRegion {.final, pure.} = object + MemRegion {.final, pure.} = object minLargeObj, maxLargeObj: int freeSmallChunks: array[0..SmallChunkSize div MemAlign-1, PSmallChunk] llmem: PLLChunk currMem, maxMem, freeMem: int # memory sizes (allocated from OS) lastSize: int # needed for the case that OS gives us pages linearly freeChunksList: PBigChunk # XXX make this a datastructure with O(1) access - chunkStarts: TIntSet + chunkStarts: IntSet root, deleted, last, freeAvlNodes: PAvlNode +{.deprecated: [TLLChunk: LLChunk, TAvlNode: AvlNode, TMemRegion: MemRegion].} # shared: var - bottomData: TAvlNode + bottomData: AvlNode bottom: PAvlNode {.push stack_trace: off.} @@ -191,44 +195,44 @@ proc initAllocator() = bottom.link[1] = bottom {.pop.} -proc incCurrMem(a: var TMemRegion, bytes: int) {.inline.} = +proc incCurrMem(a: var MemRegion, bytes: int) {.inline.} = inc(a.currMem, bytes) -proc decCurrMem(a: var TMemRegion, bytes: int) {.inline.} = +proc decCurrMem(a: var MemRegion, bytes: int) {.inline.} = a.maxMem = max(a.maxMem, a.currMem) dec(a.currMem, bytes) -proc getMaxMem(a: var TMemRegion): int = +proc getMaxMem(a: var MemRegion): int = # Since we update maxPagesCount only when freeing pages, # maxPagesCount may not be up to date. Thus we use the # maximum of these both values here: result = max(a.currMem, a.maxMem) -proc llAlloc(a: var TMemRegion, size: int): pointer = +proc llAlloc(a: var MemRegion, size: int): pointer = # *low-level* alloc for the memory managers data structures. Deallocation # is done at he end of the allocator's life time. if a.llmem == nil or size > a.llmem.size: - # the requested size is ``roundup(size+sizeof(TLLChunk), PageSize)``, but + # the requested size is ``roundup(size+sizeof(LLChunk), PageSize)``, but # since we know ``size`` is a (small) constant, we know the requested size # is one page: - sysAssert roundup(size+sizeof(TLLChunk), PageSize) == PageSize, "roundup 6" + sysAssert roundup(size+sizeof(LLChunk), PageSize) == PageSize, "roundup 6" var old = a.llmem # can be nil and is correct with nil a.llmem = cast[PLLChunk](osAllocPages(PageSize)) incCurrMem(a, PageSize) - a.llmem.size = PageSize - sizeof(TLLChunk) - a.llmem.acc = sizeof(TLLChunk) + a.llmem.size = PageSize - sizeof(LLChunk) + a.llmem.acc = sizeof(LLChunk) a.llmem.next = old result = cast[pointer](cast[ByteAddress](a.llmem) + a.llmem.acc) dec(a.llmem.size, size) inc(a.llmem.acc, size) zeroMem(result, size) -proc allocAvlNode(a: var TMemRegion, key, upperBound: int): PAvlNode = +proc allocAvlNode(a: var MemRegion, key, upperBound: int): PAvlNode = if a.freeAvlNodes != nil: result = a.freeAvlNodes a.freeAvlNodes = a.freeAvlNodes.link[0] else: - result = cast[PAvlNode](llAlloc(a, sizeof(TAvlNode))) + result = cast[PAvlNode](llAlloc(a, sizeof(AvlNode))) result.key = key result.upperBound = upperBound result.link[0] = bottom @@ -238,13 +242,13 @@ proc allocAvlNode(a: var TMemRegion, key, upperBound: int): PAvlNode = sysAssert(bottom.link[0] == bottom, "bottom link[0]") sysAssert(bottom.link[1] == bottom, "bottom link[1]") -proc deallocAvlNode(a: var TMemRegion, n: PAvlNode) {.inline.} = +proc deallocAvlNode(a: var MemRegion, n: PAvlNode) {.inline.} = n.link[0] = a.freeAvlNodes a.freeAvlNodes = n include "system/avltree" -proc llDeallocAll(a: var TMemRegion) = +proc llDeallocAll(a: var MemRegion) = var it = a.llmem while it != nil: # we know each block in the list has the size of 1 page: @@ -252,14 +256,14 @@ proc llDeallocAll(a: var TMemRegion) = osDeallocPages(it, PageSize) it = next -proc intSetGet(t: TIntSet, key: int): PTrunk = +proc intSetGet(t: IntSet, key: int): PTrunk = var it = t.data[key and high(t.data)] while it != nil: if it.key == key: return it it = it.next result = nil -proc intSetPut(a: var TMemRegion, t: var TIntSet, key: int): PTrunk = +proc intSetPut(a: var MemRegion, t: var IntSet, key: int): PTrunk = result = intSetGet(t, key) if result == nil: result = cast[PTrunk](llAlloc(a, sizeof(result[]))) @@ -267,7 +271,7 @@ proc intSetPut(a: var TMemRegion, t: var TIntSet, key: int): PTrunk = t.data[key and high(t.data)] = result result.key = key -proc contains(s: TIntSet, key: int): bool = +proc contains(s: IntSet, key: int): bool = var t = intSetGet(s, key shr TrunkShift) if t != nil: var u = key and TrunkMask @@ -275,19 +279,19 @@ proc contains(s: TIntSet, key: int): bool = else: result = false -proc incl(a: var TMemRegion, s: var TIntSet, key: int) = +proc incl(a: var MemRegion, s: var IntSet, key: int) = var t = intSetPut(a, s, key shr TrunkShift) var u = key and TrunkMask t.bits[u shr IntShift] = t.bits[u shr IntShift] or (1 shl (u and IntMask)) -proc excl(s: var TIntSet, key: int) = +proc excl(s: var IntSet, key: int) = var t = intSetGet(s, key shr TrunkShift) if t != nil: var u = key and TrunkMask t.bits[u shr IntShift] = t.bits[u shr IntShift] and not (1 shl (u and IntMask)) -iterator elements(t: TIntSet): int {.inline.} = +iterator elements(t: IntSet): int {.inline.} = # while traversing it is forbidden to change the set! for h in 0..high(t.data): var r = t.data[h] @@ -311,7 +315,7 @@ proc isSmallChunk(c: PChunk): bool {.inline.} = proc chunkUnused(c: PChunk): bool {.inline.} = result = not c.used -iterator allObjects(m: TMemRegion): pointer {.inline.} = +iterator allObjects(m: MemRegion): pointer {.inline.} = for s in elements(m.chunkStarts): # we need to check here again as it could have been modified: if s in m.chunkStarts: @@ -331,7 +335,7 @@ iterator allObjects(m: TMemRegion): pointer {.inline.} = yield addr(c.data) proc isCell(p: pointer): bool {.inline.} = - result = cast[ptr TFreeCell](p).zeroField >% 1 + result = cast[ptr FreeCell](p).zeroField >% 1 # ------------- chunk management ---------------------------------------------- proc pageIndex(c: PChunk): int {.inline.} = @@ -344,7 +348,7 @@ proc pageAddr(p: pointer): PChunk {.inline.} = result = cast[PChunk](cast[ByteAddress](p) and not PageMask) #sysAssert(Contains(allocator.chunkStarts, pageIndex(result))) -proc requestOsChunks(a: var TMemRegion, size: int): PBigChunk = +proc requestOsChunks(a: var MemRegion, size: int): PBigChunk = incCurrMem(a, size) inc(a.freeMem, size) result = cast[PBigChunk](osAllocPages(size)) @@ -373,7 +377,7 @@ proc requestOsChunks(a: var TMemRegion, size: int): PBigChunk = result.prevSize = 0 # unknown a.lastSize = size # for next request -proc freeOsChunks(a: var TMemRegion, p: pointer, size: int) = +proc freeOsChunks(a: var MemRegion, p: pointer, size: int) = # update next.prevSize: var c = cast[PChunk](p) var nxt = cast[ByteAddress](p) +% c.size @@ -387,7 +391,7 @@ proc freeOsChunks(a: var TMemRegion, p: pointer, size: int) = dec(a.freeMem, size) #c_fprintf(c_stdout, "[Alloc] back to OS: %ld\n", size) -proc isAccessible(a: TMemRegion, p: pointer): bool {.inline.} = +proc isAccessible(a: MemRegion, p: pointer): bool {.inline.} = result = contains(a.chunkStarts, pageIndex(p)) proc contains[T](list, x: T): bool = @@ -396,7 +400,7 @@ proc contains[T](list, x: T): bool = if it == x: return true it = it.next -proc writeFreeList(a: TMemRegion) = +proc writeFreeList(a: MemRegion) = var it = a.freeChunksList c_fprintf(c_stdout, "freeChunksList: %p\n", it) while it != nil: @@ -427,14 +431,14 @@ proc listRemove[T](head: var T, c: T) {.inline.} = c.next = nil c.prev = nil -proc updatePrevSize(a: var TMemRegion, c: PBigChunk, +proc updatePrevSize(a: var MemRegion, c: PBigChunk, prevSize: int) {.inline.} = var ri = cast[PChunk](cast[ByteAddress](c) +% c.size) sysAssert((cast[ByteAddress](ri) and PageMask) == 0, "updatePrevSize") if isAccessible(a, ri): ri.prevSize = prevSize -proc freeBigChunk(a: var TMemRegion, c: PBigChunk) = +proc freeBigChunk(a: var MemRegion, c: PBigChunk) = var c = c sysAssert(c.size >= PageSize, "freeBigChunk") inc(a.freeMem, c.size) @@ -467,7 +471,7 @@ proc freeBigChunk(a: var TMemRegion, c: PBigChunk) = else: freeOsChunks(a, c, c.size) -proc splitChunk(a: var TMemRegion, c: PBigChunk, size: int) = +proc splitChunk(a: var MemRegion, c: PBigChunk, size: int) = var rest = cast[PBigChunk](cast[ByteAddress](c) +% size) sysAssert(rest notin a.freeChunksList, "splitChunk") rest.size = c.size - size @@ -480,7 +484,7 @@ proc splitChunk(a: var TMemRegion, c: PBigChunk, size: int) = incl(a, a.chunkStarts, pageIndex(rest)) listAdd(a.freeChunksList, rest) -proc getBigChunk(a: var TMemRegion, size: int): PBigChunk = +proc getBigChunk(a: var MemRegion, size: int): PBigChunk = # use first fit for now: sysAssert((size and PageMask) == 0, "getBigChunk 1") sysAssert(size > 0, "getBigChunk 2") @@ -507,16 +511,16 @@ proc getBigChunk(a: var TMemRegion, size: int): PBigChunk = incl(a, a.chunkStarts, pageIndex(result)) dec(a.freeMem, size) -proc getSmallChunk(a: var TMemRegion): PSmallChunk = +proc getSmallChunk(a: var MemRegion): PSmallChunk = var res = getBigChunk(a, PageSize) sysAssert res.prev == nil, "getSmallChunk 1" sysAssert res.next == nil, "getSmallChunk 2" result = cast[PSmallChunk](res) # ----------------------------------------------------------------------------- -proc isAllocatedPtr(a: TMemRegion, p: pointer): bool {.benign.} +proc isAllocatedPtr(a: MemRegion, p: pointer): bool {.benign.} -proc allocInv(a: TMemRegion): bool = +proc allocInv(a: MemRegion): bool = ## checks some (not all yet) invariants of the allocator's data structures. for s in low(a.freeSmallChunks)..high(a.freeSmallChunks): var c = a.freeSmallChunks[s] @@ -537,10 +541,10 @@ proc allocInv(a: TMemRegion): bool = c = c.next result = true -proc rawAlloc(a: var TMemRegion, requestedSize: int): pointer = +proc rawAlloc(a: var MemRegion, requestedSize: int): pointer = sysAssert(allocInv(a), "rawAlloc: begin") sysAssert(roundup(65, 8) == 72, "rawAlloc: roundup broken") - sysAssert(requestedSize >= sizeof(TFreeCell), "rawAlloc: requested size too small") + sysAssert(requestedSize >= sizeof(FreeCell), "rawAlloc: requested size too small") var size = roundup(requestedSize, MemAlign) sysAssert(size >= requestedSize, "insufficient allocated size!") #c_fprintf(c_stdout, "alloc; size: %ld; %ld\n", requestedSize, size) @@ -601,11 +605,11 @@ proc rawAlloc(a: var TMemRegion, requestedSize: int): pointer = sysAssert(allocInv(a), "rawAlloc: end") when logAlloc: cprintf("rawAlloc: %ld %p\n", requestedSize, result) -proc rawAlloc0(a: var TMemRegion, requestedSize: int): pointer = +proc rawAlloc0(a: var MemRegion, requestedSize: int): pointer = result = rawAlloc(a, requestedSize) zeroMem(result, requestedSize) -proc rawDealloc(a: var TMemRegion, p: pointer) = +proc rawDealloc(a: var MemRegion, p: pointer) = #sysAssert(isAllocatedPtr(a, p), "rawDealloc: no allocated pointer") sysAssert(allocInv(a), "rawDealloc: begin") var c = pageAddr(p) @@ -615,7 +619,7 @@ proc rawDealloc(a: var TMemRegion, p: pointer) = var s = c.size sysAssert(((cast[ByteAddress](p) and PageMask) - smallChunkOverhead()) %% s == 0, "rawDealloc 3") - var f = cast[ptr TFreeCell](p) + var f = cast[ptr FreeCell](p) #echo("setting to nil: ", $cast[TAddress](addr(f.zeroField))) sysAssert(f.zeroField != 0, "rawDealloc 1") f.zeroField = 0 @@ -623,8 +627,8 @@ proc rawDealloc(a: var TMemRegion, p: pointer) = c.freeList = f when overwriteFree: # set to 0xff to check for usage after free bugs: - c_memset(cast[pointer](cast[int](p) +% sizeof(TFreeCell)), -1'i32, - s -% sizeof(TFreeCell)) + c_memset(cast[pointer](cast[int](p) +% sizeof(FreeCell)), -1'i32, + s -% sizeof(FreeCell)) # check if it is not in the freeSmallChunks[s] list: if c.free < s: # add it to the freeSmallChunks[s] array: @@ -649,7 +653,7 @@ proc rawDealloc(a: var TMemRegion, p: pointer) = sysAssert(allocInv(a), "rawDealloc: end") when logAlloc: cprintf("rawDealloc: %p\n", p) -proc isAllocatedPtr(a: TMemRegion, p: pointer): bool = +proc isAllocatedPtr(a: MemRegion, p: pointer): bool = if isAccessible(a, p): var c = pageAddr(p) if not chunkUnused(c): @@ -658,16 +662,16 @@ proc isAllocatedPtr(a: TMemRegion, p: pointer): bool = var offset = (cast[ByteAddress](p) and (PageSize-1)) -% smallChunkOverhead() result = (c.acc >% offset) and (offset %% c.size == 0) and - (cast[ptr TFreeCell](p).zeroField >% 1) + (cast[ptr FreeCell](p).zeroField >% 1) else: var c = cast[PBigChunk](c) - result = p == addr(c.data) and cast[ptr TFreeCell](p).zeroField >% 1 + result = p == addr(c.data) and cast[ptr FreeCell](p).zeroField >% 1 -proc prepareForInteriorPointerChecking(a: var TMemRegion) {.inline.} = +proc prepareForInteriorPointerChecking(a: var MemRegion) {.inline.} = a.minLargeObj = lowGauge(a.root) a.maxLargeObj = highGauge(a.root) -proc interiorAllocatedPtr(a: TMemRegion, p: pointer): pointer = +proc interiorAllocatedPtr(a: MemRegion, p: pointer): pointer = if isAccessible(a, p): var c = pageAddr(p) if not chunkUnused(c): @@ -678,7 +682,7 @@ proc interiorAllocatedPtr(a: TMemRegion, p: pointer): pointer = if c.acc >% offset: sysAssert(cast[ByteAddress](addr(c.data)) +% offset == cast[ByteAddress](p), "offset is not what you think it is") - var d = cast[ptr TFreeCell](cast[ByteAddress](addr(c.data)) +% + var d = cast[ptr FreeCell](cast[ByteAddress](addr(c.data)) +% offset -% (offset %% c.size)) if d.zeroField >% 1: result = d @@ -686,7 +690,7 @@ proc interiorAllocatedPtr(a: TMemRegion, p: pointer): pointer = else: var c = cast[PBigChunk](c) var d = addr(c.data) - if p >= d and cast[ptr TFreeCell](d).zeroField >% 1: + if p >= d and cast[ptr FreeCell](d).zeroField >% 1: result = d sysAssert isAllocatedPtr(a, result), " result wrong pointer!" else: @@ -699,38 +703,38 @@ proc interiorAllocatedPtr(a: TMemRegion, p: pointer): pointer = var k = cast[pointer](avlNode.key) var c = cast[PBigChunk](pageAddr(k)) sysAssert(addr(c.data) == k, " k is not the same as addr(c.data)!") - if cast[ptr TFreeCell](k).zeroField >% 1: + if cast[ptr FreeCell](k).zeroField >% 1: result = k sysAssert isAllocatedPtr(a, result), " result wrong pointer!" proc ptrSize(p: pointer): int = - var x = cast[pointer](cast[ByteAddress](p) -% sizeof(TFreeCell)) + var x = cast[pointer](cast[ByteAddress](p) -% sizeof(FreeCell)) var c = pageAddr(p) sysAssert(not chunkUnused(c), "ptrSize") - result = c.size -% sizeof(TFreeCell) + result = c.size -% sizeof(FreeCell) if not isSmallChunk(c): dec result, bigChunkOverhead() -proc alloc(allocator: var TMemRegion, size: Natural): pointer = - result = rawAlloc(allocator, size+sizeof(TFreeCell)) - cast[ptr TFreeCell](result).zeroField = 1 # mark it as used +proc alloc(allocator: var MemRegion, size: Natural): pointer = + result = rawAlloc(allocator, size+sizeof(FreeCell)) + cast[ptr FreeCell](result).zeroField = 1 # mark it as used sysAssert(not isAllocatedPtr(allocator, result), "alloc") - result = cast[pointer](cast[ByteAddress](result) +% sizeof(TFreeCell)) + result = cast[pointer](cast[ByteAddress](result) +% sizeof(FreeCell)) -proc alloc0(allocator: var TMemRegion, size: Natural): pointer = +proc alloc0(allocator: var MemRegion, size: Natural): pointer = result = alloc(allocator, size) zeroMem(result, size) -proc dealloc(allocator: var TMemRegion, p: pointer) = +proc dealloc(allocator: var MemRegion, p: pointer) = sysAssert(p != nil, "dealloc 0") - var x = cast[pointer](cast[ByteAddress](p) -% sizeof(TFreeCell)) + var x = cast[pointer](cast[ByteAddress](p) -% sizeof(FreeCell)) sysAssert(x != nil, "dealloc 1") sysAssert(isAccessible(allocator, x), "is not accessible") - sysAssert(cast[ptr TFreeCell](x).zeroField == 1, "dealloc 2") + sysAssert(cast[ptr FreeCell](x).zeroField == 1, "dealloc 2") rawDealloc(allocator, x) sysAssert(not isAllocatedPtr(allocator, x), "dealloc 3") -proc realloc(allocator: var TMemRegion, p: pointer, newsize: Natural): pointer = +proc realloc(allocator: var MemRegion, p: pointer, newsize: Natural): pointer = if newsize > 0: result = alloc0(allocator, newsize) if p != nil: @@ -739,7 +743,7 @@ proc realloc(allocator: var TMemRegion, p: pointer, newsize: Natural): pointer = elif p != nil: dealloc(allocator, p) -proc deallocOsPages(a: var TMemRegion) = +proc deallocOsPages(a: var MemRegion) = # we free every 'ordinarily' allocated page by iterating over the page bits: for p in elements(a.chunkStarts): var page = cast[PChunk](p shl PageShift) @@ -756,9 +760,9 @@ proc deallocOsPages(a: var TMemRegion) = # And then we free the pages that are in use for the page bits: llDeallocAll(a) -proc getFreeMem(a: TMemRegion): int {.inline.} = result = a.freeMem -proc getTotalMem(a: TMemRegion): int {.inline.} = result = a.currMem -proc getOccupiedMem(a: TMemRegion): int {.inline.} = +proc getFreeMem(a: MemRegion): int {.inline.} = result = a.freeMem +proc getTotalMem(a: MemRegion): int {.inline.} = result = a.currMem +proc getOccupiedMem(a: MemRegion): int {.inline.} = result = a.currMem - a.freeMem # ---------------------- thread memory region ------------------------------- @@ -769,7 +773,7 @@ template instantiateForRegion(allocator: expr) = result = interiorAllocatedPtr(allocator, p) proc isAllocatedPtr*(p: pointer): bool = - let p = cast[pointer](cast[ByteAddress](p)-%ByteAddress(sizeof(TCell))) + let p = cast[pointer](cast[ByteAddress](p)-%ByteAddress(sizeof(Cell))) result = isAllocatedPtr(allocator, p) proc deallocOsPages = deallocOsPages(allocator) @@ -803,8 +807,8 @@ template instantiateForRegion(allocator: expr) = # -------------------- shared heap region ---------------------------------- when hasThreadSupport: - var sharedHeap: TMemRegion - var heapLock: TSysLock + var sharedHeap: MemRegion + var heapLock: SysLock initSysLock(heapLock) proc allocShared(size: Natural): pointer = diff --git a/lib/system/arithm.nim b/lib/system/arithm.nim index f68e2dcd9..907907e24 100644 --- a/lib/system/arithm.nim +++ b/lib/system/arithm.nim @@ -10,24 +10,121 @@ # simple integer arithmetic with overflow checking -proc raiseOverflow {.compilerproc, noinline, noreturn.} = +proc raiseOverflow {.compilerproc, noinline.} = # a single proc to reduce code size to a minimum sysFatal(OverflowError, "over- or underflow") -proc raiseDivByZero {.compilerproc, noinline, noreturn.} = +proc raiseDivByZero {.compilerproc, noinline.} = sysFatal(DivByZeroError, "division by zero") -proc addInt64(a, b: int64): int64 {.compilerProc, inline.} = - result = a +% b - if (result xor a) >= int64(0) or (result xor b) >= int64(0): - return result - raiseOverflow() +when defined(builtinOverflow): +# Builtin compiler functions for improved performance + when sizeof(clong) == 8: + proc addInt64Overflow[T: int64|int](a, b: T, c: var T): bool {. + importc: "__builtin_saddl_overflow", nodecl, nosideeffect.} -proc subInt64(a, b: int64): int64 {.compilerProc, inline.} = - result = a -% b - if (result xor a) >= int64(0) or (result xor not b) >= int64(0): - return result - raiseOverflow() + proc subInt64Overflow[T: int64|int](a, b: T, c: var T): bool {. + importc: "__builtin_ssubl_overflow", nodecl, nosideeffect.} + + proc mulInt64Overflow[T: int64|int](a, b: T, c: var T): bool {. + importc: "__builtin_smull_overflow", nodecl, nosideeffect.} + + elif sizeof(clonglong) == 8: + proc addInt64Overflow[T: int64|int](a, b: T, c: var T): bool {. + importc: "__builtin_saddll_overflow", nodecl, nosideeffect.} + + proc subInt64Overflow[T: int64|int](a, b: T, c: var T): bool {. + importc: "__builtin_ssubll_overflow", nodecl, nosideeffect.} + + proc mulInt64Overflow[T: int64|int](a, b: T, c: var T): bool {. + importc: "__builtin_smulll_overflow", nodecl, nosideeffect.} + + when sizeof(int) == 8: + proc addIntOverflow(a, b: int, c: var int): bool {.inline.} = + addInt64Overflow(a, b, c) + + proc subIntOverflow(a, b: int, c: var int): bool {.inline.} = + subInt64Overflow(a, b, c) + + proc mulIntOverflow(a, b: int, c: var int): bool {.inline.} = + mulInt64Overflow(a, b, c) + + elif sizeof(int) == 4 and sizeof(cint) == 4: + proc addIntOverflow(a, b: int, c: var int): bool {. + importc: "__builtin_sadd_overflow", nodecl, nosideeffect.} + + proc subIntOverflow(a, b: int, c: var int): bool {. + importc: "__builtin_ssub_overflow", nodecl, nosideeffect.} + + proc mulIntOverflow(a, b: int, c: var int): bool {. + importc: "__builtin_smul_overflow", nodecl, nosideeffect.} + + proc addInt64(a, b: int64): int64 {.compilerProc, inline.} = + if addInt64Overflow(a, b, result): + raiseOverflow() + + proc subInt64(a, b: int64): int64 {.compilerProc, inline.} = + if subInt64Overflow(a, b, result): + raiseOverflow() + + proc mulInt64(a, b: int64): int64 {.compilerproc, inline.} = + if mulInt64Overflow(a, b, result): + raiseOverflow() +else: + proc addInt64(a, b: int64): int64 {.compilerProc, inline.} = + result = a +% b + if (result xor a) >= int64(0) or (result xor b) >= int64(0): + return result + raiseOverflow() + + proc subInt64(a, b: int64): int64 {.compilerProc, inline.} = + result = a -% b + if (result xor a) >= int64(0) or (result xor not b) >= int64(0): + return result + raiseOverflow() + + # + # This code has been inspired by Python's source code. + # The native int product x*y is either exactly right or *way* off, being + # just the last n bits of the true product, where n is the number of bits + # in an int (the delivered product is the true product plus i*2**n for + # some integer i). + # + # The native float64 product x*y is subject to three + # rounding errors: on a sizeof(int)==8 box, each cast to double can lose + # info, and even on a sizeof(int)==4 box, the multiplication can lose info. + # But, unlike the native int product, it's not in *range* trouble: even + # if sizeof(int)==32 (256-bit ints), the product easily fits in the + # dynamic range of a float64. So the leading 50 (or so) bits of the float64 + # product are correct. + # + # We check these two ways against each other, and declare victory if they're + # approximately the same. Else, because the native int product is the only + # one that can lose catastrophic amounts of information, it's the native int + # product that must have overflowed. + # + proc mulInt64(a, b: int64): int64 {.compilerproc.} = + var + resAsFloat, floatProd: float64 + result = a *% b + floatProd = toBiggestFloat(a) # conversion + floatProd = floatProd * toBiggestFloat(b) + resAsFloat = toBiggestFloat(result) + + # Fast path for normal case: small multiplicands, and no info + # is lost in either method. + if resAsFloat == floatProd: return result + + # Somebody somewhere lost info. Close enough, or way off? Note + # that a != 0 and b != 0 (else resAsFloat == floatProd == 0). + # The difference either is or isn't significant compared to the + # true value (of which floatProd is a good approximation). + + # abs(diff)/abs(prod) <= 1/32 iff + # 32 * abs(diff) <= abs(prod) -- 5 good bits is "close enough" + if 32.0 * abs(resAsFloat - floatProd) <= abs(floatProd): + return result + raiseOverflow() proc negInt64(a: int64): int64 {.compilerProc, inline.} = if a != low(int64): return -a @@ -51,50 +148,6 @@ proc modInt64(a, b: int64): int64 {.compilerProc, inline.} = raiseDivByZero() return a mod b -# -# This code has been inspired by Python's source code. -# The native int product x*y is either exactly right or *way* off, being -# just the last n bits of the true product, where n is the number of bits -# in an int (the delivered product is the true product plus i*2**n for -# some integer i). -# -# The native float64 product x*y is subject to three -# rounding errors: on a sizeof(int)==8 box, each cast to double can lose -# info, and even on a sizeof(int)==4 box, the multiplication can lose info. -# But, unlike the native int product, it's not in *range* trouble: even -# if sizeof(int)==32 (256-bit ints), the product easily fits in the -# dynamic range of a float64. So the leading 50 (or so) bits of the float64 -# product are correct. -# -# We check these two ways against each other, and declare victory if they're -# approximately the same. Else, because the native int product is the only -# one that can lose catastrophic amounts of information, it's the native int -# product that must have overflowed. -# -proc mulInt64(a, b: int64): int64 {.compilerproc.} = - var - resAsFloat, floatProd: float64 - result = a *% b - floatProd = toBiggestFloat(a) # conversion - floatProd = floatProd * toBiggestFloat(b) - resAsFloat = toBiggestFloat(result) - - # Fast path for normal case: small multiplicands, and no info - # is lost in either method. - if resAsFloat == floatProd: return result - - # Somebody somewhere lost info. Close enough, or way off? Note - # that a != 0 and b != 0 (else resAsFloat == floatProd == 0). - # The difference either is or isn't significant compared to the - # true value (of which floatProd is a good approximation). - - # abs(diff)/abs(prod) <= 1/32 iff - # 32 * abs(diff) <= abs(prod) -- 5 good bits is "close enough" - if 32.0 * abs(resAsFloat - floatProd) <= abs(floatProd): - return result - raiseOverflow() - - proc absInt(a: int): int {.compilerProc, inline.} = if a != low(int): if a >= 0: return a @@ -246,6 +299,21 @@ elif false: # asmVersion and (defined(gcc) or defined(llvm_gcc)): :"%edx" """ +when not declared(addInt) and defined(builtinOverflow): + proc addInt(a, b: int): int {.compilerProc, inline.} = + if addIntOverflow(a, b, result): + raiseOverflow() + +when not declared(subInt) and defined(builtinOverflow): + proc subInt(a, b: int): int {.compilerProc, inline.} = + if subIntOverflow(a, b, result): + raiseOverflow() + +when not declared(mulInt) and defined(builtinOverflow): + proc mulInt(a, b: int): int {.compilerProc, inline.} = + if mulIntOverflow(a, b, result): + raiseOverflow() + # Platform independent versions of the above (slower!) when not declared(addInt): proc addInt(a, b: int): int {.compilerProc, inline.} = @@ -327,13 +395,13 @@ when not declared(mulInt): # We avoid setting the FPU control word here for compatibility with libraries # written in other languages. -proc raiseFloatInvalidOp {.noinline, noreturn.} = +proc raiseFloatInvalidOp {.noinline.} = sysFatal(FloatInvalidOpError, "FPU operation caused a NaN result") proc nanCheck(x: float64) {.compilerProc, inline.} = if x != x: raiseFloatInvalidOp() -proc raiseFloatOverflow(x: float64) {.noinline, noreturn.} = +proc raiseFloatOverflow(x: float64) {.noinline.} = if x > 0.0: sysFatal(FloatOverflowError, "FPU operation caused an overflow") else: diff --git a/lib/system/atomics.nim b/lib/system/atomics.nim index c97d2fc7f..0b16b63bf 100644 --- a/lib/system/atomics.nim +++ b/lib/system/atomics.nim @@ -37,39 +37,40 @@ when someGcc and hasThreadSupport: ## and release stores in all threads. type - TAtomType* = SomeNumber|pointer|ptr|char|bool + AtomType* = SomeNumber|pointer|ptr|char|bool ## Type Class representing valid types for use with atomic procs + {.deprecated: [TAtomType: AtomType].} - proc atomicLoadN*[T: TAtomType](p: ptr T, mem: AtomMemModel): T {. + proc atomicLoadN*[T: AtomType](p: ptr T, mem: AtomMemModel): T {. importc: "__atomic_load_n", nodecl.} ## This proc implements an atomic load operation. It returns the contents at p. ## ATOMIC_RELAXED, ATOMIC_SEQ_CST, ATOMIC_ACQUIRE, ATOMIC_CONSUME. - proc atomicLoad*[T: TAtomType](p, ret: ptr T, mem: AtomMemModel) {. + proc atomicLoad*[T: AtomType](p, ret: ptr T, mem: AtomMemModel) {. importc: "__atomic_load", nodecl.} ## This is the generic version of an atomic load. It returns the contents at p in ret. - proc atomicStoreN*[T: TAtomType](p: ptr T, val: T, mem: AtomMemModel) {. + proc atomicStoreN*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel) {. importc: "__atomic_store_n", nodecl.} ## This proc implements an atomic store operation. It writes val at p. ## ATOMIC_RELAXED, ATOMIC_SEQ_CST, and ATOMIC_RELEASE. - proc atomicStore*[T: TAtomType](p, val: ptr T, mem: AtomMemModel) {. + proc atomicStore*[T: AtomType](p, val: ptr T, mem: AtomMemModel) {. importc: "__atomic_store", nodecl.} ## This is the generic version of an atomic store. It stores the value of val at p - proc atomicExchangeN*[T: TAtomType](p: ptr T, val: T, mem: AtomMemModel): T {. + proc atomicExchangeN*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {. importc: "__atomic_exchange_n", nodecl.} ## This proc implements an atomic exchange operation. It writes val at p, ## and returns the previous contents at p. ## ATOMIC_RELAXED, ATOMIC_SEQ_CST, ATOMIC_ACQUIRE, ATOMIC_RELEASE, ATOMIC_ACQ_REL - proc atomicExchange*[T: TAtomType](p, val, ret: ptr T, mem: AtomMemModel) {. + proc atomicExchange*[T: AtomType](p, val, ret: ptr T, mem: AtomMemModel) {. importc: "__atomic_exchange", nodecl.} ## This is the generic version of an atomic exchange. It stores the contents at val at p. ## The original value at p is copied into ret. - proc atomicCompareExchangeN*[T: TAtomType](p, expected: ptr T, desired: T, + proc atomicCompareExchangeN*[T: AtomType](p, expected: ptr T, desired: T, weak: bool, success_memmodel: AtomMemModel, failure_memmodel: AtomMemModel): bool {. importc: "__atomic_compare_exchange_n ", nodecl.} ## This proc implements an atomic compare and exchange operation. This compares the @@ -85,7 +86,7 @@ when someGcc and hasThreadSupport: ## cannot be __ATOMIC_RELEASE nor __ATOMIC_ACQ_REL. It also cannot be a stronger model ## than that specified by success_memmodel. - proc atomicCompareExchange*[T: TAtomType](p, expected, desired: ptr T, + proc atomicCompareExchange*[T: AtomType](p, expected, desired: ptr T, weak: bool, success_memmodel: AtomMemModel, failure_memmodel: AtomMemModel): bool {. importc: "__atomic_compare_exchange", nodecl.} ## This proc implements the generic version of atomic_compare_exchange. @@ -93,31 +94,31 @@ when someGcc and hasThreadSupport: ## value is also a pointer. ## Perform the operation return the new value, all memory models are valid - proc atomicAddFetch*[T: TAtomType](p: ptr T, val: T, mem: AtomMemModel): T {. + proc atomicAddFetch*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {. importc: "__atomic_add_fetch", nodecl.} - proc atomicSubFetch*[T: TAtomType](p: ptr T, val: T, mem: AtomMemModel): T {. + proc atomicSubFetch*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {. importc: "__atomic_sub_fetch", nodecl.} - proc atomicOrFetch*[T: TAtomType](p: ptr T, val: T, mem: AtomMemModel): T {. + proc atomicOrFetch*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {. importc: "__atomic_or_fetch ", nodecl.} - proc atomicAndFetch*[T: TAtomType](p: ptr T, val: T, mem: AtomMemModel): T {. + proc atomicAndFetch*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {. importc: "__atomic_and_fetch", nodecl.} - proc atomicXorFetch*[T: TAtomType](p: ptr T, val: T, mem: AtomMemModel): T {. + proc atomicXorFetch*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {. importc: "__atomic_xor_fetch", nodecl.} - proc atomicNandFetch*[T: TAtomType](p: ptr T, val: T, mem: AtomMemModel): T {. + proc atomicNandFetch*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {. importc: "__atomic_nand_fetch ", nodecl.} ## Perform the operation return the old value, all memory models are valid - proc atomicFetchAdd*[T: TAtomType](p: ptr T, val: T, mem: AtomMemModel): T {. + proc atomicFetchAdd*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {. importc: "__atomic_fetch_add", nodecl.} - proc atomicFetchSub*[T: TAtomType](p: ptr T, val: T, mem: AtomMemModel): T {. + proc atomicFetchSub*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {. importc: "__atomic_fetch_sub", nodecl.} - proc atomicFetchOr*[T: TAtomType](p: ptr T, val: T, mem: AtomMemModel): T {. + proc atomicFetchOr*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {. importc: "__atomic_fetch_or", nodecl.} - proc atomicFetchAnd*[T: TAtomType](p: ptr T, val: T, mem: AtomMemModel): T {. + proc atomicFetchAnd*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {. importc: "__atomic_fetch_and", nodecl.} - proc atomicFetchXor*[T: TAtomType](p: ptr T, val: T, mem: AtomMemModel): T {. + proc atomicFetchXor*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {. importc: "__atomic_fetch_xor", nodecl.} - proc atomicFetchNand*[T: TAtomType](p: ptr T, val: T, mem: AtomMemModel): T {. + proc atomicFetchNand*[T: AtomType](p: ptr T, val: T, mem: AtomMemModel): T {. importc: "__atomic_fetch_nand", nodecl.} proc atomicTestAndSet*(p: pointer, mem: AtomMemModel): bool {. diff --git a/lib/system/avltree.nim b/lib/system/avltree.nim index 292097062..5ee37d3eb 100644 --- a/lib/system/avltree.nim +++ b/lib/system/avltree.nim @@ -51,7 +51,7 @@ proc split(t: var PAvlNode) = t.link[0] = temp inc t.level -proc add(a: var TMemRegion, t: var PAvlNode, key, upperBound: int) {.benign.} = +proc add(a: var MemRegion, t: var PAvlNode, key, upperBound: int) {.benign.} = if t == bottom: t = allocAvlNode(a, key, upperBound) else: @@ -64,7 +64,7 @@ proc add(a: var TMemRegion, t: var PAvlNode, key, upperBound: int) {.benign.} = skew(t) split(t) -proc del(a: var TMemRegion, t: var PAvlNode, x: int) {.benign.} = +proc del(a: var MemRegion, t: var PAvlNode, x: int) {.benign.} = if t == bottom: return a.last = t if x <% t.key: diff --git a/lib/system/cellsets.nim b/lib/system/cellsets.nim index 0e3a01eba..93c49483b 100644 --- a/lib/system/cellsets.nim +++ b/lib/system/cellsets.nim @@ -10,10 +10,10 @@ # Efficient set of pointers for the GC (and repr) type - TRefCount = int + RefCount = int - TCell {.pure.} = object - refcount: TRefCount # the refcount and some flags + Cell {.pure.} = object + refcount: RefCount # the refcount and some flags typ: PNimType when trackAllocationSource: filename: cstring @@ -21,34 +21,35 @@ type when useCellIds: id: int - PCell = ptr TCell + PCell = ptr Cell - PPageDesc = ptr TPageDesc - TBitIndex = range[0..UnitsPerPage-1] - TPageDesc {.final, pure.} = object + PPageDesc = ptr PageDesc + BitIndex = range[0..UnitsPerPage-1] + PageDesc {.final, pure.} = object next: PPageDesc # all nodes are connected with this pointer key: ByteAddress # start address at bit 0 - bits: array[TBitIndex, int] # a bit vector + bits: array[BitIndex, int] # a bit vector PPageDescArray = ptr array[0..1000_000, PPageDesc] - TCellSet {.final, pure.} = object + CellSet {.final, pure.} = object counter, max: int head: PPageDesc data: PPageDescArray PCellArray = ptr array[0..100_000_000, PCell] - TCellSeq {.final, pure.} = object + CellSeq {.final, pure.} = object len, cap: int d: PCellArray - +{.deprecated: [TCell: Cell, TBitIndex: BitIndex, TPageDesc: PageDesc, + TRefCount: RefCount, TCellSet: CellSet, TCellSeq: CellSeq].} # ------------------- cell seq handling --------------------------------------- -proc contains(s: TCellSeq, c: PCell): bool {.inline.} = +proc contains(s: CellSeq, c: PCell): bool {.inline.} = for i in 0 .. s.len-1: if s.d[i] == c: return true return false -proc add(s: var TCellSeq, c: PCell) {.inline.} = +proc add(s: var CellSeq, c: PCell) {.inline.} = if s.len >= s.cap: s.cap = s.cap * 3 div 2 var d = cast[PCellArray](alloc(s.cap * sizeof(PCell))) @@ -59,12 +60,12 @@ proc add(s: var TCellSeq, c: PCell) {.inline.} = s.d[s.len] = c inc(s.len) -proc init(s: var TCellSeq, cap: int = 1024) = +proc init(s: var CellSeq, cap: int = 1024) = s.len = 0 s.cap = cap s.d = cast[PCellArray](alloc0(cap * sizeof(PCell))) -proc deinit(s: var TCellSeq) = +proc deinit(s: var CellSeq) = dealloc(s.d) s.d = nil s.len = 0 @@ -75,13 +76,13 @@ proc deinit(s: var TCellSeq) = const InitCellSetSize = 1024 # must be a power of two! -proc init(s: var TCellSet) = +proc init(s: var CellSet) = s.data = cast[PPageDescArray](alloc0(InitCellSetSize * sizeof(PPageDesc))) s.max = InitCellSetSize-1 s.counter = 0 s.head = nil -proc deinit(s: var TCellSet) = +proc deinit(s: var CellSet) = var it = s.head while it != nil: var n = it.next @@ -98,14 +99,14 @@ proc nextTry(h, maxHash: int): int {.inline.} = # generates each int in range(maxHash) exactly once (see any text on # random-number generation for proof). -proc cellSetGet(t: TCellSet, key: ByteAddress): PPageDesc = +proc cellSetGet(t: CellSet, key: ByteAddress): PPageDesc = var h = cast[int](key) and t.max while t.data[h] != nil: if t.data[h].key == key: return t.data[h] h = nextTry(h, t.max) return nil -proc cellSetRawInsert(t: TCellSet, data: PPageDescArray, desc: PPageDesc) = +proc cellSetRawInsert(t: CellSet, data: PPageDescArray, desc: PPageDesc) = var h = cast[int](desc.key) and t.max while data[h] != nil: sysAssert(data[h] != desc, "CellSetRawInsert 1") @@ -113,7 +114,7 @@ proc cellSetRawInsert(t: TCellSet, data: PPageDescArray, desc: PPageDesc) = sysAssert(data[h] == nil, "CellSetRawInsert 2") data[h] = desc -proc cellSetEnlarge(t: var TCellSet) = +proc cellSetEnlarge(t: var CellSet) = var oldMax = t.max t.max = ((t.max+1)*2)-1 var n = cast[PPageDescArray](alloc0((t.max + 1) * sizeof(PPageDesc))) @@ -123,7 +124,7 @@ proc cellSetEnlarge(t: var TCellSet) = dealloc(t.data) t.data = n -proc cellSetPut(t: var TCellSet, key: ByteAddress): PPageDesc = +proc cellSetPut(t: var CellSet, key: ByteAddress): PPageDesc = var h = cast[int](key) and t.max while true: var x = t.data[h] @@ -138,7 +139,7 @@ proc cellSetPut(t: var TCellSet, key: ByteAddress): PPageDesc = while t.data[h] != nil: h = nextTry(h, t.max) sysAssert(t.data[h] == nil, "CellSetPut") # the new page descriptor goes into result - result = cast[PPageDesc](alloc0(sizeof(TPageDesc))) + result = cast[PPageDesc](alloc0(sizeof(PageDesc))) result.next = t.head result.key = key t.head = result @@ -146,7 +147,7 @@ proc cellSetPut(t: var TCellSet, key: ByteAddress): PPageDesc = # ---------- slightly higher level procs -------------------------------------- -proc contains(s: TCellSet, cell: PCell): bool = +proc contains(s: CellSet, cell: PCell): bool = var u = cast[ByteAddress](cell) var t = cellSetGet(s, u shr PageShift) if t != nil: @@ -155,13 +156,13 @@ proc contains(s: TCellSet, cell: PCell): bool = else: result = false -proc incl(s: var TCellSet, cell: PCell) {.noinline.} = +proc incl(s: var CellSet, cell: PCell) {.noinline.} = var u = cast[ByteAddress](cell) var t = cellSetPut(s, u shr PageShift) u = (u %% PageSize) /% MemAlign t.bits[u shr IntShift] = t.bits[u shr IntShift] or (1 shl (u and IntMask)) -proc excl(s: var TCellSet, cell: PCell) = +proc excl(s: var CellSet, cell: PCell) = var u = cast[ByteAddress](cell) var t = cellSetGet(s, u shr PageShift) if t != nil: @@ -169,7 +170,7 @@ proc excl(s: var TCellSet, cell: PCell) = t.bits[u shr IntShift] = (t.bits[u shr IntShift] and not (1 shl (u and IntMask))) -proc containsOrIncl(s: var TCellSet, cell: PCell): bool = +proc containsOrIncl(s: var CellSet, cell: PCell): bool = var u = cast[ByteAddress](cell) var t = cellSetGet(s, u shr PageShift) if t != nil: @@ -182,7 +183,7 @@ proc containsOrIncl(s: var TCellSet, cell: PCell): bool = incl(s, cell) result = false -iterator elements(t: TCellSet): PCell {.inline.} = +iterator elements(t: CellSet): PCell {.inline.} = # while traversing it is forbidden to add pointers to the tree! var r = t.head while r != nil: @@ -200,7 +201,7 @@ iterator elements(t: TCellSet): PCell {.inline.} = inc(i) r = r.next -iterator elementsExcept(t, s: TCellSet): PCell {.inline.} = +iterator elementsExcept(t, s: CellSet): PCell {.inline.} = var r = t.head while r != nil: let ss = cellSetGet(s, r.key) diff --git a/lib/system/cgprocs.nim b/lib/system/cgprocs.nim index f3acc81f2..6cd2ef08c 100644 --- a/lib/system/cgprocs.nim +++ b/lib/system/cgprocs.nim @@ -12,12 +12,13 @@ proc addChar(s: NimString, c: char): NimString {.compilerProc, benign.} type - TLibHandle = pointer # private type - TProcAddr = pointer # library loading and loading of procs: + LibHandle = pointer # private type + ProcAddr = pointer # library loading and loading of procs: +{.deprecated: [TLibHandle: LibHandle, TProcAddr: ProcAddr].} -proc nimLoadLibrary(path: string): TLibHandle {.compilerproc.} -proc nimUnloadLibrary(lib: TLibHandle) {.compilerproc.} -proc nimGetProcAddr(lib: TLibHandle, name: cstring): TProcAddr {.compilerproc.} +proc nimLoadLibrary(path: string): LibHandle {.compilerproc.} +proc nimUnloadLibrary(lib: LibHandle) {.compilerproc.} +proc nimGetProcAddr(lib: LibHandle, name: cstring): ProcAddr {.compilerproc.} proc nimLoadLibraryError(path: string) {.compilerproc, noinline.} diff --git a/lib/system/channels.nim b/lib/system/channels.nim index ebd30c353..6739fb83e 100644 --- a/lib/system/channels.nim +++ b/lib/system/channels.nim @@ -19,18 +19,20 @@ when not declared(NimString): type pbytes = ptr array[0.. 0xffff, byte] - TRawChannel {.pure, final.} = object ## msg queue for a thread + RawChannel {.pure, final.} = object ## msg queue for a thread rd, wr, count, mask: int data: pbytes - lock: TSysLock - cond: TSysCond + lock: SysLock + cond: SysCond elemType: PNimType ready: bool - region: TMemRegion - PRawChannel = ptr TRawChannel - TLoadStoreMode = enum mStore, mLoad - TChannel* {.gcsafe.}[TMsg] = TRawChannel ## a channel for thread communication - + region: MemRegion + PRawChannel = ptr RawChannel + LoadStoreMode = enum mStore, mLoad + Channel* {.gcsafe.}[TMsg] = RawChannel ## a channel for thread communication +{.deprecated: [TRawChannel: RawChannel, TLoadStoreMode: LoadStoreMode, + TChannel: Channel].} + const ChannelDeadMask = -2 proc initRawChannel(p: pointer) = @@ -49,9 +51,9 @@ proc deinitRawChannel(p: pointer) = deinitSysCond(c.cond) proc storeAux(dest, src: pointer, mt: PNimType, t: PRawChannel, - mode: TLoadStoreMode) {.benign.} + mode: LoadStoreMode) {.benign.} proc storeAux(dest, src: pointer, n: ptr TNimNode, t: PRawChannel, - mode: TLoadStoreMode) {.benign.} = + mode: LoadStoreMode) {.benign.} = var d = cast[ByteAddress](dest) s = cast[ByteAddress](src) @@ -68,7 +70,7 @@ proc storeAux(dest, src: pointer, n: ptr TNimNode, t: PRawChannel, of nkNone: sysAssert(false, "storeAux") proc storeAux(dest, src: pointer, mt: PNimType, t: PRawChannel, - mode: TLoadStoreMode) = + mode: LoadStoreMode) = var d = cast[ByteAddress](dest) s = cast[ByteAddress](src) @@ -202,7 +204,7 @@ template sendImpl(q: expr) {.immediate.} = releaseSys(q.lock) signalSysCond(q.cond) -proc send*[TMsg](c: var TChannel[TMsg], msg: TMsg) = +proc send*[TMsg](c: var Channel[TMsg], msg: TMsg) = ## sends a message to a thread. `msg` is deeply copied. var q = cast[PRawChannel](addr(c)) sendImpl(q) @@ -218,7 +220,7 @@ proc llRecv(q: PRawChannel, res: pointer, typ: PNimType) = sysFatal(ValueError, "cannot receive message of wrong type") rawRecv(q, res, typ) -proc recv*[TMsg](c: var TChannel[TMsg]): TMsg = +proc recv*[TMsg](c: var Channel[TMsg]): TMsg = ## receives a message from the channel `c`. This blocks until ## a message has arrived! You may use ``peek`` to avoid the blocking. var q = cast[PRawChannel](addr(c)) @@ -226,7 +228,7 @@ proc recv*[TMsg](c: var TChannel[TMsg]): TMsg = llRecv(q, addr(result), cast[PNimType](getTypeInfo(result))) releaseSys(q.lock) -proc tryRecv*[TMsg](c: var TChannel[TMsg]): tuple[dataAvailable: bool, +proc tryRecv*[TMsg](c: var Channel[TMsg]): tuple[dataAvailable: bool, msg: TMsg] = ## try to receives a message from the channel `c` if available. Otherwise ## it returns ``(false, default(msg))``. @@ -238,7 +240,7 @@ proc tryRecv*[TMsg](c: var TChannel[TMsg]): tuple[dataAvailable: bool, result.dataAvailable = true releaseSys(q.lock) -proc peek*[TMsg](c: var TChannel[TMsg]): int = +proc peek*[TMsg](c: var Channel[TMsg]): int = ## returns the current number of messages in the channel `c`. Returns -1 ## if the channel has been closed. **Note**: This is dangerous to use ## as it encourages races. It's much better to use ``tryRecv`` instead. @@ -249,15 +251,15 @@ proc peek*[TMsg](c: var TChannel[TMsg]): int = else: result = -1 -proc open*[TMsg](c: var TChannel[TMsg]) = +proc open*[TMsg](c: var Channel[TMsg]) = ## opens a channel `c` for inter thread communication. initRawChannel(addr(c)) -proc close*[TMsg](c: var TChannel[TMsg]) = +proc close*[TMsg](c: var Channel[TMsg]) = ## closes a channel `c` and frees its associated resources. deinitRawChannel(addr(c)) -proc ready*[TMsg](c: var TChannel[TMsg]): bool = +proc ready*[TMsg](c: var Channel[TMsg]): bool = ## returns true iff some thread is waiting on the channel `c` for ## new messages. var q = cast[PRawChannel](addr(c)) diff --git a/lib/system/chcks.nim b/lib/system/chcks.nim index 2f6d25a12..6caf99d27 100644 --- a/lib/system/chcks.nim +++ b/lib/system/chcks.nim @@ -9,16 +9,16 @@ # Implementation of some runtime checks. -proc raiseRangeError(val: BiggestInt) {.compilerproc, noreturn, noinline.} = +proc raiseRangeError(val: BiggestInt) {.compilerproc, noinline.} = when hostOS == "standalone": sysFatal(RangeError, "value out of range") else: sysFatal(RangeError, "value out of range: ", $val) -proc raiseIndexError() {.compilerproc, noreturn, noinline.} = +proc raiseIndexError() {.compilerproc, noinline.} = sysFatal(IndexError, "index out of bounds") -proc raiseFieldError(f: string) {.compilerproc, noreturn, noinline.} = +proc raiseFieldError(f: string) {.compilerproc, noinline.} = sysFatal(FieldError, f, " is not accessible") proc chckIndx(i, a, b: int): int = diff --git a/lib/system/debugger.nim b/lib/system/debugger.nim index 7b5169344..63ccd770b 100644 --- a/lib/system/debugger.nim +++ b/lib/system/debugger.nim @@ -10,22 +10,23 @@ ## This file implements basic features for any debugger. type - TVarSlot* {.compilerproc, final.} = object ## a slot in a frame + VarSlot* {.compilerproc, final.} = object ## a slot in a frame address*: pointer ## the variable's address typ*: PNimType ## the variable's type name*: cstring ## the variable's name; for globals this is "module.name" - PExtendedFrame = ptr TExtendedFrame - TExtendedFrame = object # If the debugger is enabled the compiler + PExtendedFrame = ptr ExtendedFrame + ExtendedFrame = object # If the debugger is enabled the compiler # provides an extended frame. Of course # only slots that are # needed are allocated and not 10_000, # except for the global data description. - f: TFrame - slots: array[0..10_000, TVarSlot] + f: Frame + slots: array[0..10_000, VarSlot] +{.deprecated: [TVarSlot: VarSlot, TExtendedFrame: ExtendedFrame].} var - dbgGlobalData: TExtendedFrame # this reserves much space, but + dbgGlobalData: ExtendedFrame # this reserves much space, but # for now it is the most practical way proc dbgRegisterGlobal(name: cstring, address: pointer, @@ -39,7 +40,7 @@ proc dbgRegisterGlobal(name: cstring, address: pointer, dbgGlobalData.slots[i].address = address inc(dbgGlobalData.f.len) -proc getLocal*(frame: PFrame; slot: int): TVarSlot {.inline.} = +proc getLocal*(frame: PFrame; slot: int): VarSlot {.inline.} = ## retrieves the meta data for the local variable at `slot`. CAUTION: An ## invalid `slot` value causes a corruption! result = cast[PExtendedFrame](frame).slots[slot] @@ -48,7 +49,7 @@ proc getGlobalLen*(): int {.inline.} = ## gets the number of registered globals. result = dbgGlobalData.f.len -proc getGlobal*(slot: int): TVarSlot {.inline.} = +proc getGlobal*(slot: int): VarSlot {.inline.} = ## retrieves the meta data for the global variable at `slot`. CAUTION: An ## invalid `slot` value causes a corruption! result = dbgGlobalData.slots[slot] @@ -56,13 +57,13 @@ proc getGlobal*(slot: int): TVarSlot {.inline.} = # ------------------- breakpoint support ------------------------------------ type - TBreakpoint* = object ## represents a break point + Breakpoint* = object ## represents a break point low*, high*: int ## range from low to high; if disabled ## both low and high are set to their negative values filename*: cstring ## the filename of the breakpoint var - dbgBP: array[0..127, TBreakpoint] # breakpoints + dbgBP: array[0..127, Breakpoint] # breakpoints dbgBPlen: int dbgBPbloom: int64 # we use a bloom filter to speed up breakpoint checking @@ -131,16 +132,16 @@ proc canonFilename*(filename: cstring): cstring = if fileMatches(result, filename): return result result = nil -iterator listBreakpoints*(): ptr TBreakpoint = +iterator listBreakpoints*(): ptr Breakpoint = ## lists all breakpoints. for i in 0..dbgBPlen-1: yield addr(dbgBP[i]) -proc isActive*(b: ptr TBreakpoint): bool = b.low > 0 -proc flip*(b: ptr TBreakpoint) = +proc isActive*(b: ptr Breakpoint): bool = b.low > 0 +proc flip*(b: ptr Breakpoint) = ## enables or disables 'b' depending on its current state. b.low = -b.low; b.high = -b.high -proc checkBreakpoints*(filename: cstring, line: int): ptr TBreakpoint = +proc checkBreakpoints*(filename: cstring, line: int): ptr Breakpoint = ## in which breakpoint (if any) we are. if (dbgBPbloom and line) != line: return nil for b in listBreakpoints(): @@ -149,29 +150,30 @@ proc checkBreakpoints*(filename: cstring, line: int): ptr TBreakpoint = # ------------------- watchpoint support ------------------------------------ type - THash = int - TWatchpoint {.pure, final.} = object + Hash = int + Watchpoint {.pure, final.} = object name: cstring address: pointer typ: PNimType - oldValue: THash + oldValue: Hash +{.deprecated: [THash: Hash, TWatchpoint: Watchpoint].} var - watchpoints: array [0..99, TWatchpoint] + watchpoints: array [0..99, Watchpoint] watchpointsLen: int -proc `!&`(h: THash, val: int): THash {.inline.} = +proc `!&`(h: Hash, val: int): Hash {.inline.} = result = h +% val result = result +% result shl 10 result = result xor (result shr 6) -proc `!$`(h: THash): THash {.inline.} = +proc `!$`(h: Hash): Hash {.inline.} = result = h +% h shl 3 result = result xor (result shr 11) result = result +% result shl 15 -proc hash(data: pointer, size: int): THash = - var h: THash = 0 +proc hash(data: pointer, size: int): Hash = + var h: Hash = 0 var p = cast[cstring](data) var i = 0 var s = size @@ -181,14 +183,14 @@ proc hash(data: pointer, size: int): THash = dec(s) result = !$h -proc hashGcHeader(data: pointer): THash = +proc hashGcHeader(data: pointer): Hash = const headerSize = sizeof(int)*2 result = hash(cast[pointer](cast[int](data) -% headerSize), headerSize) proc genericHashAux(dest: pointer, mt: PNimType, shallow: bool, - h: THash): THash + h: Hash): Hash proc genericHashAux(dest: pointer, n: ptr TNimNode, shallow: bool, - h: THash): THash = + h: Hash): Hash = var d = cast[ByteAddress](dest) case n.kind of nkSlot: @@ -204,7 +206,7 @@ proc genericHashAux(dest: pointer, n: ptr TNimNode, shallow: bool, of nkNone: sysAssert(false, "genericHashAux") proc genericHashAux(dest: pointer, mt: PNimType, shallow: bool, - h: THash): THash = + h: Hash): Hash = sysAssert(mt != nil, "genericHashAux 2") case mt.kind of tyString: diff --git a/lib/system/dyncalls.nim b/lib/system/dyncalls.nim index 44f7b67c3..8ef583482 100644 --- a/lib/system/dyncalls.nim +++ b/lib/system/dyncalls.nim @@ -15,7 +15,7 @@ {.push stack_trace: off.} const - NilLibHandle: TLibHandle = nil + NilLibHandle: LibHandle = nil proc rawWrite(f: File, s: string) = # we cannot throw an exception here! @@ -55,22 +55,22 @@ when defined(posix): var RTLD_NOW {.importc: "RTLD_NOW", header: "<dlfcn.h>".}: int - proc dlclose(lib: TLibHandle) {.importc, header: "<dlfcn.h>".} - proc dlopen(path: cstring, mode: int): TLibHandle {. + proc dlclose(lib: LibHandle) {.importc, header: "<dlfcn.h>".} + proc dlopen(path: cstring, mode: int): LibHandle {. importc, header: "<dlfcn.h>".} - proc dlsym(lib: TLibHandle, name: cstring): TProcAddr {. + proc dlsym(lib: LibHandle, name: cstring): ProcAddr {. importc, header: "<dlfcn.h>".} proc dlerror(): cstring {.importc, header: "<dlfcn.h>".} - proc nimUnloadLibrary(lib: TLibHandle) = + proc nimUnloadLibrary(lib: LibHandle) = dlclose(lib) - proc nimLoadLibrary(path: string): TLibHandle = + proc nimLoadLibrary(path: string): LibHandle = result = dlopen(path, RTLD_NOW) #c_fprintf(c_stdout, "%s\n", dlerror()) - proc nimGetProcAddr(lib: TLibHandle, name: cstring): TProcAddr = + proc nimGetProcAddr(lib: LibHandle, name: cstring): ProcAddr = result = dlsym(lib, name) if result == nil: procAddrError(name) @@ -84,12 +84,12 @@ elif defined(windows) or defined(dos): type THINSTANCE {.importc: "HINSTANCE".} = object x: pointer - proc getProcAddress(lib: THINSTANCE, name: cstring): TProcAddr {. + proc getProcAddress(lib: THINSTANCE, name: cstring): ProcAddr {. importcpp: "(void*)GetProcAddress(@)", header: "<windows.h>", stdcall.} else: type THINSTANCE {.importc: "HINSTANCE".} = pointer - proc getProcAddress(lib: THINSTANCE, name: cstring): TProcAddr {. + proc getProcAddress(lib: THINSTANCE, name: cstring): ProcAddr {. importc: "GetProcAddress", header: "<windows.h>", stdcall.} proc freeLibrary(lib: THINSTANCE) {. @@ -97,13 +97,13 @@ elif defined(windows) or defined(dos): proc winLoadLibrary(path: cstring): THINSTANCE {. importc: "LoadLibraryA", header: "<windows.h>", stdcall.} - proc nimUnloadLibrary(lib: TLibHandle) = + proc nimUnloadLibrary(lib: LibHandle) = freeLibrary(cast[THINSTANCE](lib)) - proc nimLoadLibrary(path: string): TLibHandle = - result = cast[TLibHandle](winLoadLibrary(path)) + proc nimLoadLibrary(path: string): LibHandle = + result = cast[LibHandle](winLoadLibrary(path)) - proc nimGetProcAddr(lib: TLibHandle, name: cstring): TProcAddr = + proc nimGetProcAddr(lib: LibHandle, name: cstring): ProcAddr = result = getProcAddress(cast[THINSTANCE](lib), name) if result == nil: procAddrError(name) @@ -115,13 +115,13 @@ elif defined(mac): # {.error: "no implementation for dyncalls yet".} - proc nimUnloadLibrary(lib: TLibHandle) = + proc nimUnloadLibrary(lib: LibHandle) = NSUnLinkModule(NSModule(lib), NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES) var dyld_present {.importc: "_dyld_present", header: "<dyld.h>".}: int - proc nimLoadLibrary(path: string): TLibHandle = + proc nimLoadLibrary(path: string): LibHandle = var img: NSObjectFileImage ret: NSObjectFileImageReturnCode @@ -134,13 +134,13 @@ elif defined(mac): modul = NSLinkModule(img, path, NSLINKMODULE_OPTION_PRIVATE or NSLINKMODULE_OPTION_RETURN_ON_ERROR) NSDestroyObjectFileImage(img) - result = TLibHandle(modul) + result = LibHandle(modul) - proc nimGetProcAddr(lib: TLibHandle, name: cstring): TProcAddr = + proc nimGetProcAddr(lib: LibHandle, name: cstring): ProcAddr = var nss: NSSymbol nss = NSLookupSymbolInModule(NSModule(lib), name) - result = TProcAddr(NSAddressOfSymbol(nss)) + result = ProcAddr(NSAddressOfSymbol(nss)) if result == nil: ProcAddrError(name) else: diff --git a/lib/system/endb.nim b/lib/system/endb.nim index 003698421..ef2664796 100644 --- a/lib/system/endb.nim +++ b/lib/system/endb.nim @@ -20,63 +20,65 @@ const EndbEnd = "***\n" type - TStaticStr = object + StaticStr = object len: int data: array[0..100, char] - TBreakpointFilename = object - b: ptr TBreakpoint - filename: TStaticStr + BreakpointFilename = object + b: ptr Breakpoint + filename: StaticStr - TDbgState = enum + DbgState = enum dbOff, # debugger is turned off dbStepInto, # debugger is in tracing mode dbStepOver, dbSkipCurrent, dbQuiting, # debugger wants to quit dbBreakpoints # debugger is only interested in breakpoints +{.deprecated: [TStaticStr: StaticStr, TBreakpointFilename: BreakpointFilename, + TDbgState: DbgState].} var - dbgUser: TStaticStr # buffer for user input; first command is ``step_into`` + dbgUser: StaticStr # buffer for user input; first command is ``step_into`` # needs to be global cause we store the last command # in it - dbgState: TDbgState # state of debugger + dbgState: DbgState # state of debugger dbgSkipToFrame: PFrame # frame to be skipped to maxDisplayRecDepth: int = 5 # do not display too much data! - brkPoints: array[0..127, TBreakpointFilename] + brkPoints: array[0..127, BreakpointFilename] -proc setLen(s: var TStaticStr, newLen=0) = +proc setLen(s: var StaticStr, newLen=0) = s.len = newLen s.data[newLen] = '\0' -proc add(s: var TStaticStr, c: char) = +proc add(s: var StaticStr, c: char) = if s.len < high(s.data)-1: s.data[s.len] = c s.data[s.len+1] = '\0' inc s.len -proc add(s: var TStaticStr, c: cstring) = +proc add(s: var StaticStr, c: cstring) = var i = 0 while c[i] != '\0': add s, c[i] inc i -proc assign(s: var TStaticStr, c: cstring) = +proc assign(s: var StaticStr, c: cstring) = setLen(s) add s, c -proc `==`(a, b: TStaticStr): bool = +proc `==`(a, b: StaticStr): bool = if a.len == b.len: for i in 0 .. a.len-1: if a.data[i] != b.data[i]: return false return true -proc `==`(a: TStaticStr, b: cstring): bool = +proc `==`(a: StaticStr, b: cstring): bool = result = c_strcmp(a.data, b) == 0 -proc write(f: TFile, s: TStaticStr) = +proc write(f: File, s: StaticStr) = write(f, cstring(s.data)) proc listBreakPoints() = @@ -95,14 +97,14 @@ proc listBreakPoints() = write(stdout, "\n") write(stdout, EndbEnd) -proc openAppend(filename: cstring): TFile = +proc openAppend(filename: cstring): File = var p: pointer = fopen(filename, "ab") if p != nil: - result = cast[TFile](p) + result = cast[File](p) write(result, "----------------------------------------\n") proc dbgRepr(p: pointer, typ: PNimType): string = - var cl: TReprClosure + var cl: ReprClosure initReprClosure(cl) cl.recDepth = maxDisplayRecDepth # locks for the GC turned out to be a bad idea... @@ -112,12 +114,12 @@ proc dbgRepr(p: pointer, typ: PNimType): string = # dec(recGcLock) deinitReprClosure(cl) -proc writeVariable(stream: TFile, slot: TVarSlot) = +proc writeVariable(stream: File, slot: VarSlot) = write(stream, slot.name) write(stream, " = ") writeln(stream, dbgRepr(slot.address, slot.typ)) -proc listFrame(stream: TFile, f: PFrame) = +proc listFrame(stream: File, f: PFrame) = write(stream, EndbBeg) write(stream, "| Frame (") write(stream, f.len) @@ -126,7 +128,7 @@ proc listFrame(stream: TFile, f: PFrame) = writeln(stream, getLocal(f, i).name) write(stream, EndbEnd) -proc listLocals(stream: TFile, f: PFrame) = +proc listLocals(stream: File, f: PFrame) = write(stream, EndbBeg) write(stream, "| Frame (") write(stream, f.len) @@ -135,7 +137,7 @@ proc listLocals(stream: TFile, f: PFrame) = writeVariable(stream, getLocal(f, i)) write(stream, EndbEnd) -proc listGlobals(stream: TFile) = +proc listGlobals(stream: File) = write(stream, EndbBeg) write(stream, "| Globals:\n") for i in 0 .. getGlobalLen()-1: @@ -172,7 +174,7 @@ proc dbgShowExecutionPoint() = write(stdout, framePtr.procname) write(stdout, " ***\n") -proc scanAndAppendWord(src: cstring, a: var TStaticStr, start: int): int = +proc scanAndAppendWord(src: cstring, a: var StaticStr, start: int): int = result = start # skip whitespace: while src[result] in {'\t', ' '}: inc(result) @@ -184,11 +186,11 @@ proc scanAndAppendWord(src: cstring, a: var TStaticStr, start: int): int = else: break inc(result) -proc scanWord(src: cstring, a: var TStaticStr, start: int): int = +proc scanWord(src: cstring, a: var StaticStr, start: int): int = setlen(a) result = scanAndAppendWord(src, a, start) -proc scanFilename(src: cstring, a: var TStaticStr, start: int): int = +proc scanFilename(src: cstring, a: var StaticStr, start: int): int = result = start setLen a while src[result] in {'\t', ' '}: inc(result) @@ -250,8 +252,8 @@ proc hasExt(s: cstring): bool = if s[i] == '.': return true inc i -proc parseBreakpoint(s: cstring, start: int): TBreakpoint = - var dbgTemp: TStaticStr +proc parseBreakpoint(s: cstring, start: int): Breakpoint = + var dbgTemp: StaticStr var i = scanNumber(s, result.low, start) if result.low == 0: result.low = framePtr.line i = scanNumber(s, result.high, i) @@ -279,11 +281,11 @@ proc breakpointToggle(s: cstring, start: int) = if not b.isNil: b.flip else: debugOut("[Warning] unknown breakpoint ") -proc dbgEvaluate(stream: TFile, s: cstring, start: int, f: PFrame) = - var dbgTemp: TStaticStr +proc dbgEvaluate(stream: File, s: cstring, start: int, f: PFrame) = + var dbgTemp: StaticStr var i = scanWord(s, dbgTemp, start) while s[i] in {' ', '\t'}: inc(i) - var v: TVarSlot + var v: VarSlot if s[i] == '.': inc(i) add(dbgTemp, '.') @@ -299,7 +301,7 @@ proc dbgEvaluate(stream: TFile, s: cstring, start: int, f: PFrame) = writeVariable(stream, v) proc dbgOut(s: cstring, start: int, currFrame: PFrame) = - var dbgTemp: TStaticStr + var dbgTemp: StaticStr var i = scanFilename(s, dbgTemp, start) if dbgTemp.len == 0: invalidCommand() @@ -312,7 +314,7 @@ proc dbgOut(s: cstring, start: int, currFrame: PFrame) = close(stream) proc dbgStackFrame(s: cstring, start: int, currFrame: PFrame) = - var dbgTemp: TStaticStr + var dbgTemp: StaticStr var i = scanFilename(s, dbgTemp, start) if dbgTemp.len == 0: # just write it to stdout: @@ -325,7 +327,7 @@ proc dbgStackFrame(s: cstring, start: int, currFrame: PFrame) = listFrame(stream, currFrame) close(stream) -proc readLine(f: TFile, line: var TStaticStr): bool = +proc readLine(f: File, line: var StaticStr): bool = while true: var c = fgetc(f) if c < 0'i32: @@ -358,7 +360,7 @@ proc commandPrompt() = again = true dbgFramePtr = framePtr # for going down and up the stack dbgDown = 0 # how often we did go down - dbgTemp: TStaticStr + dbgTemp: StaticStr while again: write(stdout, "*** endb| >>") diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim index 189d52f57..f157f428c 100644 --- a/lib/system/excpt.nim +++ b/lib/system/excpt.nim @@ -365,5 +365,6 @@ when not defined(noSignalHandler): proc setControlCHook(hook: proc () {.noconv.} not nil) = # ugly cast, but should work on all architectures: - type TSignalHandler = proc (sig: cint) {.noconv, benign.} - c_signal(SIGINT, cast[TSignalHandler](hook)) + type SignalHandler = proc (sig: cint) {.noconv, benign.} + {.deprecated: [TSignalHandler: SignalHandler].} + c_signal(SIGINT, cast[SignalHandler](hook)) diff --git a/lib/system/gc.nim b/lib/system/gc.nim index c4374d00c..ae8bb724f 100644 --- a/lib/system/gc.nim +++ b/lib/system/gc.nim @@ -45,17 +45,17 @@ const rcShift = 3 # shift by rcShift to get the reference counter colorMask = 0b011 type - TWalkOp = enum + WalkOp = enum waMarkGlobal, # part of the backup/debug mark&sweep waMarkPrecise, # part of the backup/debug mark&sweep waZctDecRef, waPush, waCycleDecRef, waMarkGray, waScan, waScanBlack, waCollectWhite #, waDebug - TFinalizer {.compilerproc.} = proc (self: pointer) {.nimcall, benign.} + Finalizer {.compilerproc.} = proc (self: pointer) {.nimcall, benign.} # A ref type can have a finalizer that is called before the object's # storage is freed. - TGcStat {.final, pure.} = object + GcStat {.final, pure.} = object stackScans: int # number of performed stack scans (for statistics) cycleCollections: int # number of performed full collections maxThreshold: int # max threshold that has been set @@ -64,35 +64,36 @@ type cycleTableSize: int # max entries in cycle table maxPause: int64 # max measured GC pause in nanoseconds - TGcHeap {.final, pure.} = object # this contains the zero count and + GcHeap {.final, pure.} = object # this contains the zero count and # non-zero count table stackBottom: pointer cycleThreshold: int when useCellIds: idGenerator: int - zct: TCellSeq # the zero count table - decStack: TCellSeq # cells in the stack that are to decref again - cycleRoots: TCellSet - tempStack: TCellSeq # temporary stack for recursion elimination + zct: CellSeq # the zero count table + decStack: CellSeq # cells in the stack that are to decref again + cycleRoots: CellSet + tempStack: CellSeq # temporary stack for recursion elimination recGcLock: int # prevent recursion via finalizers; no thread lock when withRealTime: - maxPause: TNanos # max allowed pause in nanoseconds; active if > 0 - region: TMemRegion # garbage collected region - stat: TGcStat + maxPause: Nanos # max allowed pause in nanoseconds; active if > 0 + region: MemRegion # garbage collected region + stat: GcStat when useMarkForDebug or useBackupGc: - marked: TCellSet - + marked: CellSet +{.deprecated: [TWalkOp: WalkOp, TFinalizer: Finalizer, TGcHeap: GcHeap, + TGcStat: GcStat].} var - gch {.rtlThreadVar.}: TGcHeap + gch {.rtlThreadVar.}: GcHeap when not defined(useNimRtl): instantiateForRegion(gch.region) -template acquire(gch: TGcHeap) = +template acquire(gch: GcHeap) = when hasThreadSupport and hasSharedHeap: acquireSys(HeapLock) -template release(gch: TGcHeap) = +template release(gch: GcHeap) = when hasThreadSupport and hasSharedHeap: releaseSys(HeapLock) @@ -104,18 +105,18 @@ template gcAssert(cond: bool, msg: string) = writeStackTrace() quit 1 -proc addZCT(s: var TCellSeq, c: PCell) {.noinline.} = +proc addZCT(s: var CellSeq, c: PCell) {.noinline.} = if (c.refcount and ZctFlag) == 0: c.refcount = c.refcount or ZctFlag add(s, c) proc cellToUsr(cell: PCell): pointer {.inline.} = # convert object (=pointer to refcount) to pointer to userdata - result = cast[pointer](cast[ByteAddress](cell)+%ByteAddress(sizeof(TCell))) + result = cast[pointer](cast[ByteAddress](cell)+%ByteAddress(sizeof(Cell))) proc usrToCell(usr: pointer): PCell {.inline.} = # convert pointer to userdata to object (=pointer to refcount) - result = cast[PCell](cast[ByteAddress](usr)-%ByteAddress(sizeof(TCell))) + result = cast[PCell](cast[ByteAddress](usr)-%ByteAddress(sizeof(Cell))) proc canBeCycleRoot(c: PCell): bool {.inline.} = result = ntfAcyclic notin c.typ.flags @@ -152,11 +153,11 @@ template gcTrace(cell, state: expr): stmt {.immediate.} = when traceGC: traceCell(cell, state) # forward declarations: -proc collectCT(gch: var TGcHeap) {.benign.} +proc collectCT(gch: var GcHeap) {.benign.} proc isOnStack*(p: pointer): bool {.noinline, benign.} -proc forAllChildren(cell: PCell, op: TWalkOp) {.benign.} -proc doOperation(p: pointer, op: TWalkOp) {.benign.} -proc forAllChildrenAux(dest: pointer, mt: PNimType, op: TWalkOp) {.benign.} +proc forAllChildren(cell: PCell, op: WalkOp) {.benign.} +proc doOperation(p: pointer, op: WalkOp) {.benign.} +proc forAllChildrenAux(dest: pointer, mt: PNimType, op: WalkOp) {.benign.} # we need the prototype here for debugging purposes when hasThreadSupport and hasSharedHeap: @@ -178,7 +179,7 @@ proc prepareDealloc(cell: PCell) = # prevend recursive entering here by a lock. # XXX: we should set the cell's children to nil! inc(gch.recGcLock) - (cast[TFinalizer](cell.typ.finalizer))(cellToUsr(cell)) + (cast[Finalizer](cell.typ.finalizer))(cellToUsr(cell)) dec(gch.recGcLock) proc rtlAddCycleRoot(c: PCell) {.rtl, inl.} = @@ -276,7 +277,7 @@ proc unsureAsgnRef(dest: PPointer, src: pointer) {.compilerProc.} = proc initGC() = when not defined(useNimRtl): when traceGC: - for i in low(TCellState)..high(TCellState): init(states[i]) + for i in low(CellState)..high(CellState): init(states[i]) gch.cycleThreshold = InitialCycleThreshold gch.stat.stackScans = 0 gch.stat.cycleCollections = 0 @@ -308,12 +309,13 @@ proc setupForeignThreadGc*() = when useMarkForDebug or useBackupGc: type - TGlobalMarkerProc = proc () {.nimcall, benign.} + GlobalMarkerProc = proc () {.nimcall, benign.} + {.deprecated: [TGlobalMarkerProc: GlobalMarkerProc].} var globalMarkersLen: int - globalMarkers: array[0.. 7_000, TGlobalMarkerProc] + globalMarkers: array[0.. 7_000, GlobalMarkerProc] - proc nimRegisterGlobalMarker(markerProc: TGlobalMarkerProc) {.compilerProc.} = + proc nimRegisterGlobalMarker(markerProc: GlobalMarkerProc) {.compilerProc.} = if globalMarkersLen <= high(globalMarkers): globalMarkers[globalMarkersLen] = markerProc inc globalMarkersLen @@ -321,11 +323,11 @@ when useMarkForDebug or useBackupGc: echo "[GC] cannot register global variable; too many global variables" quit 1 -proc cellsetReset(s: var TCellSet) = +proc cellsetReset(s: var CellSet) = deinit(s) init(s) -proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: TWalkOp) {.benign.} = +proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: WalkOp) {.benign.} = var d = cast[ByteAddress](dest) case n.kind of nkSlot: forAllChildrenAux(cast[pointer](d +% n.offset), n.typ, op) @@ -345,7 +347,7 @@ proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: TWalkOp) {.benign.} = if m != nil: forAllSlotsAux(dest, m, op) of nkNone: sysAssert(false, "forAllSlotsAux") -proc forAllChildrenAux(dest: pointer, mt: PNimType, op: TWalkOp) = +proc forAllChildrenAux(dest: pointer, mt: PNimType, op: WalkOp) = var d = cast[ByteAddress](dest) if dest == nil: return # nothing to do if ntfNoRefs notin mt.flags: @@ -359,7 +361,7 @@ proc forAllChildrenAux(dest: pointer, mt: PNimType, op: TWalkOp) = forAllChildrenAux(cast[pointer](d +% i *% mt.base.size), mt.base, op) else: discard -proc forAllChildren(cell: PCell, op: TWalkOp) = +proc forAllChildren(cell: PCell, op: WalkOp) = gcAssert(cell != nil, "forAllChildren: 1") gcAssert(isAllocatedPtr(gch.region, cell), "forAllChildren: 2") gcAssert(cell.typ != nil, "forAllChildren: 3") @@ -380,7 +382,7 @@ proc forAllChildren(cell: PCell, op: TWalkOp) = GenericSeqSize), cell.typ.base, op) else: discard -proc addNewObjToZCT(res: PCell, gch: var TGcHeap) {.inline.} = +proc addNewObjToZCT(res: PCell, gch: var GcHeap) {.inline.} = # we check the last 8 entries (cache line) for a slot that could be reused. # In 63% of all cases we succeed here! But we have to optimize the heck # out of this small linear search so that ``newObj`` is not slowed down. @@ -431,13 +433,13 @@ proc gcInvariant*() = markForDebug(gch) {.pop.} -proc rawNewObj(typ: PNimType, size: int, gch: var TGcHeap): pointer = +proc rawNewObj(typ: PNimType, size: int, gch: var GcHeap): pointer = # generates a new object and sets its reference counter to 0 sysAssert(allocInv(gch.region), "rawNewObj begin") acquire(gch) gcAssert(typ.kind in {tyRef, tyString, tySequence}, "newObj: 1") collectCT(gch) - var res = cast[PCell](rawAlloc(gch.region, size + sizeof(TCell))) + var res = cast[PCell](rawAlloc(gch.region, size + sizeof(Cell))) gcAssert((cast[ByteAddress](res) and (MemAlign-1)) == 0, "newObj: 2") # now it is buffered in the ZCT res.typ = typ @@ -486,7 +488,7 @@ proc newObjRC1(typ: PNimType, size: int): pointer {.compilerRtl.} = collectCT(gch) sysAssert(allocInv(gch.region), "newObjRC1 after collectCT") - var res = cast[PCell](rawAlloc(gch.region, size + sizeof(TCell))) + var res = cast[PCell](rawAlloc(gch.region, size + sizeof(Cell))) sysAssert(allocInv(gch.region), "newObjRC1 after rawAlloc") sysAssert((cast[ByteAddress](res) and (MemAlign-1)) == 0, "newObj: 2") # now it is buffered in the ZCT @@ -515,7 +517,7 @@ proc newSeqRC1(typ: PNimType, len: int): pointer {.compilerRtl.} = cast[PGenericSeq](result).reserved = len when defined(memProfiler): nimProfile(size) -proc growObj(old: pointer, newsize: int, gch: var TGcHeap): pointer = +proc growObj(old: pointer, newsize: int, gch: var GcHeap): pointer = acquire(gch) collectCT(gch) var ol = usrToCell(old) @@ -523,13 +525,13 @@ proc growObj(old: pointer, newsize: int, gch: var TGcHeap): pointer = gcAssert(ol.typ.kind in {tyString, tySequence}, "growObj: 2") sysAssert(allocInv(gch.region), "growObj begin") - var res = cast[PCell](rawAlloc(gch.region, newsize + sizeof(TCell))) + var res = cast[PCell](rawAlloc(gch.region, newsize + sizeof(Cell))) var elemSize = 1 if ol.typ.kind != tyString: elemSize = ol.typ.base.size var oldsize = cast[PGenericSeq](old).len*elemSize + GenericSeqSize - copyMem(res, ol, oldsize + sizeof(TCell)) - zeroMem(cast[pointer](cast[ByteAddress](res)+% oldsize +% sizeof(TCell)), + copyMem(res, ol, oldsize + sizeof(Cell)) + zeroMem(cast[pointer](cast[ByteAddress](res)+% oldsize +% sizeof(Cell)), newsize-oldsize) sysAssert((cast[ByteAddress](res) and (MemAlign-1)) == 0, "growObj: 3") # This can be wrong for intermediate temps that are nevertheless on the @@ -564,7 +566,7 @@ proc growObj(old: pointer, newsize: int, gch: var TGcHeap): pointer = decRef(ol) else: sysAssert(ol.typ != nil, "growObj: 5") - zeroMem(ol, sizeof(TCell)) + zeroMem(ol, sizeof(Cell)) release(gch) when useCellIds: inc gch.idGenerator @@ -580,7 +582,7 @@ proc growObj(old: pointer, newsize: int): pointer {.rtl.} = # ---------------- cycle collector ------------------------------------------- -proc freeCyclicCell(gch: var TGcHeap, c: PCell) = +proc freeCyclicCell(gch: var GcHeap, c: PCell) = prepareDealloc(c) gcTrace(c, csCycFreed) when logGC: writeCell("cycle collector dealloc cell", c) @@ -589,7 +591,7 @@ proc freeCyclicCell(gch: var TGcHeap, c: PCell) = rawDealloc(gch.region, c) else: gcAssert(c.typ != nil, "freeCyclicCell") - zeroMem(c, sizeof(TCell)) + zeroMem(c, sizeof(Cell)) proc markGray(s: PCell) = if s.color != rcGray: @@ -620,7 +622,7 @@ proc collectWhite(s: PCell) = forAllChildren(s, waCollectWhite) freeCyclicCell(gch, s) -proc markRoots(gch: var TGcHeap) = +proc markRoots(gch: var GcHeap) = var tabSize = 0 for s in elements(gch.cycleRoots): #writeCell("markRoot", s) @@ -635,7 +637,7 @@ proc markRoots(gch: var TGcHeap) = gch.stat.cycleTableSize = max(gch.stat.cycleTableSize, tabSize) when useBackupGc: - proc sweep(gch: var TGcHeap) = + proc sweep(gch: var GcHeap) = for x in allObjects(gch.region): if isCell(x): # cast to PCell is correct here: @@ -643,7 +645,7 @@ when useBackupGc: if c notin gch.marked: freeCyclicCell(gch, c) when useMarkForDebug or useBackupGc: - proc markS(gch: var TGcHeap, c: PCell) = + proc markS(gch: var GcHeap, c: PCell) = incl(gch.marked, c) gcAssert gch.tempStack.len == 0, "stack not empty!" forAllChildren(c, waMarkPrecise) @@ -653,10 +655,10 @@ when useMarkForDebug or useBackupGc: if not containsOrIncl(gch.marked, d): forAllChildren(d, waMarkPrecise) - proc markGlobals(gch: var TGcHeap) = + proc markGlobals(gch: var GcHeap) = for i in 0 .. < globalMarkersLen: globalMarkers[i]() - proc stackMarkS(gch: var TGcHeap, p: pointer) {.inline.} = + proc stackMarkS(gch: var GcHeap, p: pointer) {.inline.} = # the addresses are not as cells on the stack, so turn them to cells: var cell = usrToCell(p) var c = cast[TAddress](cell) @@ -688,7 +690,7 @@ when logGC: forAllChildren(s, waDebug) c_fprintf(c_stdout, "}\n") -proc doOperation(p: pointer, op: TWalkOp) = +proc doOperation(p: pointer, op: WalkOp) = if p == nil: return var c: PCell = usrToCell(p) gcAssert(c != nil, "doOperation: 1") @@ -733,19 +735,19 @@ proc doOperation(p: pointer, op: TWalkOp) = #of waDebug: debugGraph(c) proc nimGCvisit(d: pointer, op: int) {.compilerRtl.} = - doOperation(d, TWalkOp(op)) + doOperation(d, WalkOp(op)) -proc collectZCT(gch: var TGcHeap): bool {.benign.} +proc collectZCT(gch: var GcHeap): bool {.benign.} when useMarkForDebug or useBackupGc: - proc markStackAndRegistersForSweep(gch: var TGcHeap) {.noinline, cdecl, + proc markStackAndRegistersForSweep(gch: var GcHeap) {.noinline, cdecl, benign.} -proc collectRoots(gch: var TGcHeap) = +proc collectRoots(gch: var GcHeap) = for s in elements(gch.cycleRoots): collectWhite(s) -proc collectCycles(gch: var TGcHeap) = +proc collectCycles(gch: var GcHeap) = # ensure the ZCT 'color' is not used: while gch.zct.len > 0: discard collectZCT(gch) when useBackupGc: @@ -778,7 +780,7 @@ proc collectCycles(gch: var TGcHeap) = if cycleRootsLen != 0: cfprintf(cstdout, "cycle roots: %ld\n", cycleRootsLen) -proc gcMark(gch: var TGcHeap, p: pointer) {.inline.} = +proc gcMark(gch: var GcHeap, p: pointer) {.inline.} = # the addresses are not as cells on the stack, so turn them to cells: sysAssert(allocInv(gch.region), "gcMark begin") var cell = usrToCell(p) @@ -798,7 +800,7 @@ proc gcMark(gch: var TGcHeap, p: pointer) {.inline.} = add(gch.decStack, cell) sysAssert(allocInv(gch.region), "gcMark end") -proc markThreadStacks(gch: var TGcHeap) = +proc markThreadStacks(gch: var GcHeap) = when hasThreadSupport and hasSharedHeap: {.error: "not fully implemented".} var it = threadList @@ -887,7 +889,7 @@ elif stackIncreases: var jmpbufSize {.importc: "sizeof(jmp_buf)", nodecl.}: int - # a little hack to get the size of a TJmpBuf in the generated C code + # a little hack to get the size of a JmpBuf in the generated C code # in a platform independent way template forEachStackSlot(gch, gcMark: expr) {.immediate, dirty.} = @@ -922,6 +924,15 @@ else: if c_setjmp(registers) == 0'i32: # To fill the C stack with registers. var max = cast[ByteAddress](gch.stackBottom) var sp = cast[ByteAddress](addr(registers)) + when defined(amd64): + # words within the jmp_buf structure may not be properly aligned. + let regEnd = sp +% sizeof(registers) + while sp <% regEnd: + gcMark(gch, cast[PPointer](sp)[]) + gcMark(gch, cast[PPointer](sp +% sizeof(pointer) div 2)[]) + sp = sp +% sizeof(pointer) + # Make sure sp is word-aligned + sp = sp and not (sizeof(pointer) - 1) # loop unrolled: while sp <% max - 8*sizeof(pointer): gcMark(gch, cast[PStackSlice](sp)[0]) @@ -938,18 +949,18 @@ else: gcMark(gch, cast[PPointer](sp)[]) sp = sp +% sizeof(pointer) -proc markStackAndRegisters(gch: var TGcHeap) {.noinline, cdecl.} = +proc markStackAndRegisters(gch: var GcHeap) {.noinline, cdecl.} = forEachStackSlot(gch, gcMark) when useMarkForDebug or useBackupGc: - proc markStackAndRegistersForSweep(gch: var TGcHeap) = + proc markStackAndRegistersForSweep(gch: var GcHeap) = forEachStackSlot(gch, stackMarkS) # ---------------------------------------------------------------------------- # end of non-portable code # ---------------------------------------------------------------------------- -proc collectZCT(gch: var TGcHeap): bool = +proc collectZCT(gch: var GcHeap): bool = # Note: Freeing may add child objects to the ZCT! So essentially we do # deep freeing, which is bad for incremental operation. In order to # avoid a deep stack, we move objects to keep the ZCT small. @@ -959,7 +970,7 @@ proc collectZCT(gch: var TGcHeap): bool = when withRealTime: var steps = workPackage - var t0: TTicks + var t0: Ticks if gch.maxPause > 0: t0 = getticks() while L[] > 0: var c = gch.zct.d[0] @@ -992,7 +1003,7 @@ proc collectZCT(gch: var TGcHeap): bool = rawDealloc(gch.region, c) else: sysAssert(c.typ != nil, "collectZCT 2") - zeroMem(c, sizeof(TCell)) + zeroMem(c, sizeof(Cell)) when withRealTime: if steps == 0: steps = workPackage @@ -1005,7 +1016,7 @@ proc collectZCT(gch: var TGcHeap): bool = return false result = true -proc unmarkStackAndRegisters(gch: var TGcHeap) = +proc unmarkStackAndRegisters(gch: var GcHeap) = var d = gch.decStack.d for i in 0..gch.decStack.len-1: sysAssert isAllocatedPtr(gch.region, d[i]), "unmarkStackAndRegisters" @@ -1017,7 +1028,7 @@ proc unmarkStackAndRegisters(gch: var TGcHeap) = #sysAssert c.typ != nil, "unmarkStackAndRegisters 2" gch.decStack.len = 0 -proc collectCTBody(gch: var TGcHeap) = +proc collectCTBody(gch: var GcHeap) = when withRealTime: let t0 = getticks() sysAssert(allocInv(gch.region), "collectCT: begin") @@ -1049,11 +1060,11 @@ proc collectCTBody(gch: var TGcHeap) = c_fprintf(c_stdout, "[GC] missed deadline: %ld\n", duration) when useMarkForDebug or useBackupGc: - proc markForDebug(gch: var TGcHeap) = + proc markForDebug(gch: var GcHeap) = markStackAndRegistersForSweep(gch) markGlobals(gch) -proc collectCT(gch: var TGcHeap) = +proc collectCT(gch: var GcHeap) = # stackMarkCosts prevents some pathological behaviour: Stack marking # becomes more expensive with large stacks and large stacks mean that # cells with RC=0 are more likely to be kept alive by the stack. @@ -1068,13 +1079,13 @@ proc collectCT(gch: var TGcHeap) = collectCTBody(gch) when withRealTime: - proc toNano(x: int): TNanos {.inline.} = + proc toNano(x: int): Nanos {.inline.} = result = x * 1000 proc GC_setMaxPause*(MaxPauseInUs: int) = gch.maxPause = MaxPauseInUs.toNano - proc GC_step(gch: var TGcHeap, us: int, strongAdvice: bool) = + proc GC_step(gch: var GcHeap, us: int, strongAdvice: bool) = acquire(gch) gch.maxPause = us.toNano if (gch.zct.len >= ZctThreshold or (cycleGC and diff --git a/lib/system/gc2.nim b/lib/system/gc2.nim index 4e3dee51c..015e08c9e 100644 --- a/lib/system/gc2.nim +++ b/lib/system/gc2.nim @@ -54,7 +54,7 @@ const # was replaced by a resize operation. # see growObj for details - rcColorMask = TRefCount(0b00111) + rcColorMask = RefCount(0b00111) rcZct = 0b01000 # already added to ZCT rcInCycleRoots = 0b10000 # already buffered as cycle candidate @@ -97,14 +97,14 @@ const CollectCyclesStats = false type - TWalkOp = enum + WalkOp = enum waPush - TFinalizer {.compilerproc.} = proc (self: pointer) {.nimcall.} + Finalizer {.compilerproc.} = proc (self: pointer) {.nimcall.} # A ref type can have a finalizer that is called before the object's # storage is freed. - TGcStat {.final, pure.} = object + GcStat {.final, pure.} = object stackScans: int # number of performed stack scans (for statistics) cycleCollections: int # number of performed full collections maxThreshold: int # max threshold that has been set @@ -113,16 +113,16 @@ type cycleTableSize: int # max entries in cycle table maxPause: int64 # max measured GC pause in nanoseconds - TGcHeap {.final, pure.} = object # this contains the zero count and + GcHeap {.final, pure.} = object # this contains the zero count and # non-zero count table stackBottom: pointer stackTop: pointer cycleThreshold: int - zct: TCellSeq # the zero count table - decStack: TCellSeq # cells in the stack that are to decref again - cycleRoots: TCellSeq - tempStack: TCellSeq # temporary stack for recursion elimination - freeStack: TCellSeq # objects ready to be freed + zct: CellSeq # the zero count table + decStack: CellSeq # cells in the stack that are to decref again + cycleRoots: CellSeq + tempStack: CellSeq # temporary stack for recursion elimination + freeStack: CellSeq # objects ready to be freed recGcLock: int # prevent recursion via finalizers; no thread lock cycleRootsTrimIdx: int # Trimming is a light-weight collection of the # cycle roots table that uses a cheap linear scan @@ -132,21 +132,22 @@ type # This index indicates the start of the range of # such new objects within the table. when withRealTime: - maxPause: TNanos # max allowed pause in nanoseconds; active if > 0 - region: TMemRegion # garbage collected region - stat: TGcStat - + maxPause: Nanos # max allowed pause in nanoseconds; active if > 0 + region: MemRegion # garbage collected region + stat: GcStat +{.deprecated: [TWalkOp: WalkOp, TFinalizer: Finalizer, TGcStat: GcStat, + TGcHeap: GcHeap].} var - gch* {.rtlThreadVar.}: TGcHeap + gch* {.rtlThreadVar.}: GcHeap when not defined(useNimRtl): instantiateForRegion(gch.region) -template acquire(gch: TGcHeap) = +template acquire(gch: GcHeap) = when hasThreadSupport and hasSharedHeap: AcquireSys(HeapLock) -template release(gch: TGcHeap) = +template release(gch: GcHeap) = when hasThreadSupport and hasSharedHeap: releaseSys(HeapLock) @@ -169,7 +170,7 @@ template isDead(c: Pcell): expr = c.isBitUp(rcReallyDead) # also covers rcRetiredBuffer template clearBit(c: PCell, bit): expr = - c.refcount = c.refcount and (not TRefCount(bit)) + c.refcount = c.refcount and (not RefCount(bit)) when debugGC: var gcCollectionIdx = 0 @@ -206,7 +207,7 @@ when debugGC: c_fprintf(c_stdout, "[GC] %s: %p %d rc=%ld\n", msg, c, kind, c.refcount shr rcShift) -proc addZCT(zct: var TCellSeq, c: PCell) {.noinline.} = +proc addZCT(zct: var CellSeq, c: PCell) {.noinline.} = if c.isBitDown(rcZct): c.setBit rcZct zct.add c @@ -221,7 +222,7 @@ template setStackTop(gch) = var stackTop {.volatile.}: pointer gch.stackTop = addr(stackTop) -template addCycleRoot(cycleRoots: var TCellSeq, c: PCell) = +template addCycleRoot(cycleRoots: var CellSeq, c: PCell) = if c.color != rcCycleCandidate: c.setColor rcCycleCandidate @@ -233,11 +234,11 @@ template addCycleRoot(cycleRoots: var TCellSeq, c: PCell) = proc cellToUsr(cell: PCell): pointer {.inline.} = # convert object (=pointer to refcount) to pointer to userdata - result = cast[pointer](cast[ByteAddress](cell)+%ByteAddress(sizeof(TCell))) + result = cast[pointer](cast[ByteAddress](cell)+%ByteAddress(sizeof(Cell))) proc usrToCell*(usr: pointer): PCell {.inline.} = # convert pointer to userdata to object (=pointer to refcount) - result = cast[PCell](cast[ByteAddress](usr)-%ByteAddress(sizeof(TCell))) + result = cast[PCell](cast[ByteAddress](usr)-%ByteAddress(sizeof(Cell))) proc canbeCycleRoot(c: PCell): bool {.inline.} = result = ntfAcyclic notin c.typ.flags @@ -254,11 +255,11 @@ when BitsPerPage mod (sizeof(int)*8) != 0: {.error: "(BitsPerPage mod BitsPerUnit) should be zero!".} # forward declarations: -proc collectCT(gch: var TGcHeap) +proc collectCT(gch: var GcHeap) proc isOnStack*(p: pointer): bool {.noinline.} -proc forAllChildren(cell: PCell, op: TWalkOp) -proc doOperation(p: pointer, op: TWalkOp) -proc forAllChildrenAux(dest: pointer, mt: PNimType, op: TWalkOp) +proc forAllChildren(cell: PCell, op: WalkOp) +proc doOperation(p: pointer, op: WalkOp) +proc forAllChildrenAux(dest: pointer, mt: PNimType, op: WalkOp) # we need the prototype here for debugging purposes proc prepareDealloc(cell: PCell) = @@ -269,18 +270,19 @@ proc prepareDealloc(cell: PCell) = # prevend recursive entering here by a lock. # XXX: we should set the cell's children to nil! inc(gch.recGcLock) - (cast[TFinalizer](cell.typ.finalizer))(cellToUsr(cell)) + (cast[Finalizer](cell.typ.finalizer))(cellToUsr(cell)) dec(gch.recGcLock) when traceGC: # traceGC is a special switch to enable extensive debugging type - TCellState = enum + CellState = enum csAllocated, csFreed + {.deprecated: [TCellState: CellState].} var - states: array[TCellState, TCellSet] + states: array[CellState, CellSet] - proc traceCell(c: PCell, state: TCellState) = + proc traceCell(c: PCell, state: CellState) = case state of csAllocated: if c in states[csAllocated]: @@ -300,7 +302,7 @@ when traceGC: incl(states[state], c) proc computeCellWeight(c: PCell): int = - var x: TCellSet + var x: CellSet x.init let startLen = gch.tempStack.len @@ -363,30 +365,32 @@ proc rtlAddZCT(c: PCell) {.rtl, inl.} = WithHeapLock: addZCT(gch.zct, c) type - TCyclicMode = enum + CyclicMode = enum Cyclic, Acyclic, MaybeCyclic - TReleaseType = enum + ReleaseType = enum AddToZTC FreeImmediately - THeapType = enum + HeapType = enum LocalHeap SharedHeap +{.deprecated: [TCyclicMode: CyclicMode, TReleaseType: ReleaseType, + THeapType: HeapType].} -template `++` (rc: TRefCount, heapType: THeapType): stmt = +template `++` (rc: RefCount, heapType: HeapType): stmt = when heapType == SharedHeap: discard atomicInc(rc, rcIncrement) else: inc rc, rcIncrement -template `--`(rc: TRefCount): expr = +template `--`(rc: RefCount): expr = dec rc, rcIncrement rc <% rcIncrement -template `--` (rc: TRefCount, heapType: THeapType): expr = +template `--` (rc: RefCount, heapType: HeapType): expr = (when heapType == SharedHeap: atomicDec(rc, rcIncrement) <% rcIncrement else: --rc) template doDecRef(cc: PCell, @@ -479,7 +483,7 @@ when hasThreadSupport and hasSharedHeap: proc initGC() = when not defined(useNimRtl): when traceGC: - for i in low(TCellState)..high(TCellState): init(states[i]) + for i in low(CellState)..high(CellState): init(states[i]) gch.cycleThreshold = InitialCycleThreshold gch.stat.stackScans = 0 gch.stat.cycleCollections = 0 @@ -494,7 +498,7 @@ proc initGC() = init(gch.cycleRoots) init(gch.decStack) -proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: TWalkOp) = +proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: WalkOp) = var d = cast[ByteAddress](dest) case n.kind of nkSlot: forAllChildrenAux(cast[pointer](d +% n.offset), n.typ, op) @@ -514,7 +518,7 @@ proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: TWalkOp) = if m != nil: forAllSlotsAux(dest, m, op) of nkNone: sysAssert(false, "forAllSlotsAux") -proc forAllChildrenAux(dest: pointer, mt: PNimType, op: TWalkOp) = +proc forAllChildrenAux(dest: pointer, mt: PNimType, op: WalkOp) = var d = cast[ByteAddress](dest) if dest == nil: return # nothing to do if ntfNoRefs notin mt.flags: @@ -528,7 +532,7 @@ proc forAllChildrenAux(dest: pointer, mt: PNimType, op: TWalkOp) = forAllChildrenAux(cast[pointer](d +% i *% mt.base.size), mt.base, op) else: discard -proc forAllChildren(cell: PCell, op: TWalkOp) = +proc forAllChildren(cell: PCell, op: WalkOp) = sysAssert(cell != nil, "forAllChildren: 1") sysAssert(cell.typ != nil, "forAllChildren: 2") sysAssert cell.typ.kind in {tyRef, tySequence, tyString}, "forAllChildren: 3" @@ -549,7 +553,7 @@ proc forAllChildren(cell: PCell, op: TWalkOp) = cell.typ.base, op) else: discard -proc addNewObjToZCT(res: PCell, gch: var TGcHeap) {.inline.} = +proc addNewObjToZCT(res: PCell, gch: var GcHeap) {.inline.} = # we check the last 8 entries (cache line) for a slot that could be reused. # In 63% of all cases we succeed here! But we have to optimize the heck # out of this small linear search so that ``newObj`` is not slowed down. @@ -593,7 +597,7 @@ proc addNewObjToZCT(res: PCell, gch: var TGcHeap) {.inline.} = return add(gch.zct, res) -proc rawNewObj(typ: PNimType, size: int, gch: var TGcHeap, rc1 = false): pointer = +proc rawNewObj(typ: PNimType, size: int, gch: var GcHeap, rc1 = false): pointer = # generates a new object and sets its reference counter to 0 acquire(gch) sysAssert(allocInv(gch.region), "rawNewObj begin") @@ -602,7 +606,7 @@ proc rawNewObj(typ: PNimType, size: int, gch: var TGcHeap, rc1 = false): pointer collectCT(gch) sysAssert(allocInv(gch.region), "rawNewObj after collect") - var res = cast[PCell](rawAlloc(gch.region, size + sizeof(TCell))) + var res = cast[PCell](rawAlloc(gch.region, size + sizeof(Cell))) sysAssert(allocInv(gch.region), "rawNewObj after rawAlloc") sysAssert((cast[ByteAddress](res) and (MemAlign-1)) == 0, "newObj: 2") @@ -638,20 +642,20 @@ proc rawNewObj(typ: PNimType, size: int, gch: var TGcHeap, rc1 = false): pointer {.pop.} -proc freeCell(gch: var TGcHeap, c: PCell) = +proc freeCell(gch: var GcHeap, c: PCell) = # prepareDealloc(c) gcTrace(c, csFreed) when reallyDealloc: rawDealloc(gch.region, c) else: sysAssert(c.typ != nil, "collectCycles") - zeroMem(c, sizeof(TCell)) + zeroMem(c, sizeof(Cell)) -template eraseAt(cells: var TCellSeq, at: int): stmt = +template eraseAt(cells: var CellSeq, at: int): stmt = cells.d[at] = cells.d[cells.len - 1] dec cells.len -template trimAt(roots: var TCellSeq, at: int): stmt = +template trimAt(roots: var CellSeq, at: int): stmt = # This will remove a cycle root candidate during trimming. # a candidate is removed either because it received a refup and # it's no longer a candidate or because it received further refdowns @@ -696,7 +700,7 @@ proc newSeqRC1(typ: PNimType, len: int): pointer {.compilerRtl.} = cast[PGenericSeq](result).len = len cast[PGenericSeq](result).reserved = len -proc growObj(old: pointer, newsize: int, gch: var TGcHeap): pointer = +proc growObj(old: pointer, newsize: int, gch: var GcHeap): pointer = acquire(gch) collectCT(gch) var ol = usrToCell(old) @@ -704,7 +708,7 @@ proc growObj(old: pointer, newsize: int, gch: var TGcHeap): pointer = sysAssert(ol.typ.kind in {tyString, tySequence}, "growObj: 2") sysAssert(allocInv(gch.region), "growObj begin") - var res = cast[PCell](rawAlloc(gch.region, newsize + sizeof(TCell))) + var res = cast[PCell](rawAlloc(gch.region, newsize + sizeof(Cell))) var elemSize = if ol.typ.kind != tyString: ol.typ.base.size else: 1 @@ -713,8 +717,8 @@ proc growObj(old: pointer, newsize: int, gch: var TGcHeap): pointer = # XXX: This should happen outside # call user-defined move code # call user-defined default constructor - copyMem(res, ol, oldsize + sizeof(TCell)) - zeroMem(cast[pointer](cast[ByteAddress](res)+% oldsize +% sizeof(TCell)), + copyMem(res, ol, oldsize + sizeof(Cell)) + zeroMem(cast[pointer](cast[ByteAddress](res)+% oldsize +% sizeof(Cell)), newsize-oldsize) sysAssert((cast[ByteAddress](res) and (MemAlign-1)) == 0, "growObj: 3") @@ -778,26 +782,27 @@ proc growObj(old: pointer, newsize: int): pointer {.rtl.} = # ---------------- cycle collector ------------------------------------------- -proc doOperation(p: pointer, op: TWalkOp) = +proc doOperation(p: pointer, op: WalkOp) = if p == nil: return var c: PCell = usrToCell(p) sysAssert(c != nil, "doOperation: 1") gch.tempStack.add c proc nimGCvisit(d: pointer, op: int) {.compilerRtl.} = - doOperation(d, TWalkOp(op)) + doOperation(d, WalkOp(op)) type - TRecursionType = enum + RecursionType = enum FromChildren, FromRoot +{.deprecated: [TRecursionType: RecursionType].} -proc collectZCT(gch: var TGcHeap): bool +proc collectZCT(gch: var GcHeap): bool -template pseudoRecursion(typ: TRecursionType, body: stmt): stmt = +template pseudoRecursion(typ: RecursionType, body: stmt): stmt = discard -proc trimCycleRoots(gch: var TGcHeap, startIdx = gch.cycleRootsTrimIdx) = +proc trimCycleRoots(gch: var GcHeap, startIdx = gch.cycleRootsTrimIdx) = var i = startIdx while i < gch.cycleRoots.len: if gch.cycleRoots.d[i].color != rcCycleCandidate: @@ -808,7 +813,7 @@ proc trimCycleRoots(gch: var TGcHeap, startIdx = gch.cycleRootsTrimIdx) = gch.cycleRootsTrimIdx = gch.cycleRoots.len # we now use a much simpler and non-recursive algorithm for cycle removal -proc collectCycles(gch: var TGcHeap) = +proc collectCycles(gch: var GcHeap) = if gch.cycleRoots.len == 0: return gch.stat.cycleTableSize = max(gch.stat.cycleTableSize, gch.cycleRoots.len) @@ -990,7 +995,7 @@ var gcDebugging* = false var seqdbg* : proc (s: PGenericSeq) {.cdecl.} -proc gcMark(gch: var TGcHeap, p: pointer) {.inline.} = +proc gcMark(gch: var GcHeap, p: pointer) {.inline.} = # the addresses are not as cells on the stack, so turn them to cells: sysAssert(allocInv(gch.region), "gcMark begin") var cell = usrToCell(p) @@ -1025,7 +1030,7 @@ proc gcMark(gch: var TGcHeap, p: pointer) {.inline.} = add(gch.decStack, cell) sysAssert(allocInv(gch.region), "gcMark end") -proc markThreadStacks(gch: var TGcHeap) = +proc markThreadStacks(gch: var GcHeap) = when hasThreadSupport and hasSharedHeap: {.error: "not fully implemented".} var it = threadList @@ -1074,7 +1079,7 @@ proc stackSize(): int {.noinline.} = var jmpbufSize {.importc: "sizeof(jmp_buf)", nodecl.}: int - # a little hack to get the size of a TJmpBuf in the generated C code + # a little hack to get the size of a JmpBuf in the generated C code # in a platform independent way when defined(sparc): # For SPARC architecture. @@ -1086,7 +1091,7 @@ when defined(sparc): # For SPARC architecture. var x = cast[ByteAddress](p) result = a <=% x and x <=% b - proc markStackAndRegisters(gch: var TGcHeap) {.noinline, cdecl.} = + proc markStackAndRegisters(gch: var GcHeap) {.noinline, cdecl.} = when defined(sparcv9): asm """"flushw \n" """ else: @@ -1117,7 +1122,7 @@ elif stackIncreases: var x = cast[ByteAddress](p) result = a <=% x and x <=% b - proc markStackAndRegisters(gch: var TGcHeap) {.noinline, cdecl.} = + proc markStackAndRegisters(gch: var GcHeap) {.noinline, cdecl.} = var registers: C_JmpBuf if c_setjmp(registers) == 0'i32: # To fill the C stack with registers. var max = cast[ByteAddress](gch.stackBottom) @@ -1140,7 +1145,7 @@ else: var x = cast[ByteAddress](p) result = a <=% x and x <=% b - proc markStackAndRegisters(gch: var TGcHeap) {.noinline, cdecl.} = + proc markStackAndRegisters(gch: var GcHeap) {.noinline, cdecl.} = # We use a jmp_buf buffer that is in the C stack. # Used to traverse the stack and registers assuming # that 'setjmp' will save registers in the C stack. @@ -1181,7 +1186,7 @@ else: # end of non-portable code # ---------------------------------------------------------------------------- -proc releaseCell(gch: var TGcHeap, cell: PCell) = +proc releaseCell(gch: var GcHeap, cell: PCell) = if cell.color != rcReallyDead: prepareDealloc(cell) cell.setColor rcReallyDead @@ -1210,13 +1215,13 @@ proc releaseCell(gch: var TGcHeap, cell: PCell) = # recursion). # We can ignore it now as the ZCT cleaner will reach it soon. -proc collectZCT(gch: var TGcHeap): bool = +proc collectZCT(gch: var GcHeap): bool = const workPackage = 100 var L = addr(gch.zct.len) when withRealtime: var steps = workPackage - var t0: TTicks + var t0: Ticks if gch.maxPause > 0: t0 = getticks() while L[] > 0: @@ -1257,7 +1262,7 @@ proc collectZCT(gch: var TGcHeap): bool = #deInit(gch.zct) #init(gch.zct) -proc unmarkStackAndRegisters(gch: var TGcHeap) = +proc unmarkStackAndRegisters(gch: var GcHeap) = var d = gch.decStack.d for i in 0 .. <gch.decStack.len: sysAssert isAllocatedPtr(gch.region, d[i]), "unmarkStackAndRegisters" @@ -1283,7 +1288,7 @@ proc unmarkStackAndRegisters(gch: var TGcHeap) = gch.decStack.len = 0 -proc collectCTBody(gch: var TGcHeap) = +proc collectCTBody(gch: var GcHeap) = when withRealtime: let t0 = getticks() when debugGC: inc gcCollectionIdx @@ -1315,20 +1320,20 @@ proc collectCTBody(gch: var TGcHeap) = if gch.maxPause > 0 and duration > gch.maxPause: c_fprintf(c_stdout, "[GC] missed deadline: %ld\n", duration) -proc collectCT(gch: var TGcHeap) = +proc collectCT(gch: var GcHeap) = if (gch.zct.len >= ZctThreshold or (cycleGC and getOccupiedMem(gch.region)>=gch.cycleThreshold) or alwaysGC) and gch.recGcLock == 0: collectCTBody(gch) when withRealtime: - proc toNano(x: int): TNanos {.inline.} = + proc toNano(x: int): Nanos {.inline.} = result = x * 1000 proc GC_setMaxPause*(MaxPauseInUs: int) = gch.maxPause = MaxPauseInUs.toNano - proc GC_step(gch: var TGcHeap, us: int, strongAdvice: bool) = + proc GC_step(gch: var GcHeap, us: int, strongAdvice: bool) = acquire(gch) gch.maxPause = us.toNano if (gch.zct.len >= ZctThreshold or (cycleGC and diff --git a/lib/system/gc_ms.nim b/lib/system/gc_ms.nim index e287bf5d9..ee80c61e9 100644 --- a/lib/system/gc_ms.nim +++ b/lib/system/gc_ms.nim @@ -26,49 +26,50 @@ when defined(memProfiler): proc nimProfile(requestedSize: int) type - TWalkOp = enum + WalkOp = enum waMarkGlobal, # we need to mark conservatively for global marker procs # as these may refer to a global var and not to a thread # local waMarkPrecise # fast precise marking - TFinalizer {.compilerproc.} = proc (self: pointer) {.nimcall, benign.} + Finalizer {.compilerproc.} = proc (self: pointer) {.nimcall, benign.} # A ref type can have a finalizer that is called before the object's # storage is freed. - TGlobalMarkerProc = proc () {.nimcall, benign.} + GlobalMarkerProc = proc () {.nimcall, benign.} - TGcStat = object + GcStat = object collections: int # number of performed full collections maxThreshold: int # max threshold that has been set maxStackSize: int # max stack size freedObjects: int # max entries in cycle table - TGcHeap = object # this contains the zero count and + GcHeap = object # this contains the zero count and # non-zero count table stackBottom: pointer cycleThreshold: int when useCellIds: idGenerator: int when withBitvectors: - allocated, marked: TCellSet - tempStack: TCellSeq # temporary stack for recursion elimination + allocated, marked: CellSet + tempStack: CellSeq # temporary stack for recursion elimination recGcLock: int # prevent recursion via finalizers; no thread lock - region: TMemRegion # garbage collected region - stat: TGcStat - additionalRoots: TCellSeq # dummy roots for GC_ref/unref - + region: MemRegion # garbage collected region + stat: GcStat + additionalRoots: CellSeq # dummy roots for GC_ref/unref +{.deprecated: [TWalkOp: WalkOp, TFinalizer: Finalizer, TGcStat: GcStat, + TGlobalMarkerProc: GlobalMarkerProc, TGcHeap: GcHeap].} var - gch {.rtlThreadVar.}: TGcHeap + gch {.rtlThreadVar.}: GcHeap when not defined(useNimRtl): instantiateForRegion(gch.region) -template acquire(gch: TGcHeap) = +template acquire(gch: GcHeap) = when hasThreadSupport and hasSharedHeap: acquireSys(HeapLock) -template release(gch: TGcHeap) = +template release(gch: GcHeap) = when hasThreadSupport and hasSharedHeap: releaseSys(HeapLock) @@ -80,11 +81,11 @@ template gcAssert(cond: bool, msg: string) = proc cellToUsr(cell: PCell): pointer {.inline.} = # convert object (=pointer to refcount) to pointer to userdata - result = cast[pointer](cast[ByteAddress](cell)+%ByteAddress(sizeof(TCell))) + result = cast[pointer](cast[ByteAddress](cell)+%ByteAddress(sizeof(Cell))) proc usrToCell(usr: pointer): PCell {.inline.} = # convert pointer to userdata to object (=pointer to refcount) - result = cast[PCell](cast[ByteAddress](usr)-%ByteAddress(sizeof(TCell))) + result = cast[PCell](cast[ByteAddress](usr)-%ByteAddress(sizeof(Cell))) proc canbeCycleRoot(c: PCell): bool {.inline.} = result = ntfAcyclic notin c.typ.flags @@ -101,9 +102,9 @@ proc internRefcount(p: pointer): int {.exportc: "getRefcount".} = var globalMarkersLen: int - globalMarkers: array[0.. 7_000, TGlobalMarkerProc] + globalMarkers: array[0.. 7_000, GlobalMarkerProc] -proc nimRegisterGlobalMarker(markerProc: TGlobalMarkerProc) {.compilerProc.} = +proc nimRegisterGlobalMarker(markerProc: GlobalMarkerProc) {.compilerProc.} = if globalMarkersLen <= high(globalMarkers): globalMarkers[globalMarkersLen] = markerProc inc globalMarkersLen @@ -116,11 +117,11 @@ when BitsPerPage mod (sizeof(int)*8) != 0: {.error: "(BitsPerPage mod BitsPerUnit) should be zero!".} # forward declarations: -proc collectCT(gch: var TGcHeap) {.benign.} +proc collectCT(gch: var GcHeap) {.benign.} proc isOnStack*(p: pointer): bool {.noinline, benign.} -proc forAllChildren(cell: PCell, op: TWalkOp) {.benign.} -proc doOperation(p: pointer, op: TWalkOp) {.benign.} -proc forAllChildrenAux(dest: pointer, mt: PNimType, op: TWalkOp) {.benign.} +proc forAllChildren(cell: PCell, op: WalkOp) {.benign.} +proc doOperation(p: pointer, op: WalkOp) {.benign.} +proc forAllChildrenAux(dest: pointer, mt: PNimType, op: WalkOp) {.benign.} # we need the prototype here for debugging purposes proc prepareDealloc(cell: PCell) = @@ -131,7 +132,7 @@ proc prepareDealloc(cell: PCell) = # prevend recursive entering here by a lock. # XXX: we should set the cell's children to nil! inc(gch.recGcLock) - (cast[TFinalizer](cell.typ.finalizer))(cellToUsr(cell)) + (cast[Finalizer](cell.typ.finalizer))(cellToUsr(cell)) dec(gch.recGcLock) proc nimGCref(p: pointer) {.compilerProc.} = @@ -182,7 +183,7 @@ proc setupForeignThreadGc*() = setStackBottom(addr(stackTop)) initGC() -proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: TWalkOp) {.benign.} = +proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: WalkOp) {.benign.} = var d = cast[ByteAddress](dest) case n.kind of nkSlot: forAllChildrenAux(cast[pointer](d +% n.offset), n.typ, op) @@ -194,7 +195,7 @@ proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: TWalkOp) {.benign.} = if m != nil: forAllSlotsAux(dest, m, op) of nkNone: sysAssert(false, "forAllSlotsAux") -proc forAllChildrenAux(dest: pointer, mt: PNimType, op: TWalkOp) = +proc forAllChildrenAux(dest: pointer, mt: PNimType, op: WalkOp) = var d = cast[ByteAddress](dest) if dest == nil: return # nothing to do if ntfNoRefs notin mt.flags: @@ -208,7 +209,7 @@ proc forAllChildrenAux(dest: pointer, mt: PNimType, op: TWalkOp) = forAllChildrenAux(cast[pointer](d +% i *% mt.base.size), mt.base, op) else: discard -proc forAllChildren(cell: PCell, op: TWalkOp) = +proc forAllChildren(cell: PCell, op: WalkOp) = gcAssert(cell != nil, "forAllChildren: 1") gcAssert(cell.typ != nil, "forAllChildren: 2") gcAssert cell.typ.kind in {tyRef, tySequence, tyString}, "forAllChildren: 3" @@ -228,12 +229,12 @@ proc forAllChildren(cell: PCell, op: TWalkOp) = GenericSeqSize), cell.typ.base, op) else: discard -proc rawNewObj(typ: PNimType, size: int, gch: var TGcHeap): pointer = +proc rawNewObj(typ: PNimType, size: int, gch: var GcHeap): pointer = # generates a new object and sets its reference counter to 0 acquire(gch) gcAssert(typ.kind in {tyRef, tyString, tySequence}, "newObj: 1") collectCT(gch) - var res = cast[PCell](rawAlloc(gch.region, size + sizeof(TCell))) + var res = cast[PCell](rawAlloc(gch.region, size + sizeof(Cell))) gcAssert((cast[ByteAddress](res) and (MemAlign-1)) == 0, "newObj: 2") # now it is buffered in the ZCT res.typ = typ @@ -285,20 +286,20 @@ proc newSeqRC1(typ: PNimType, len: int): pointer {.compilerRtl.} = cast[PGenericSeq](result).reserved = len when defined(memProfiler): nimProfile(size) -proc growObj(old: pointer, newsize: int, gch: var TGcHeap): pointer = +proc growObj(old: pointer, newsize: int, gch: var GcHeap): pointer = acquire(gch) collectCT(gch) var ol = usrToCell(old) sysAssert(ol.typ != nil, "growObj: 1") gcAssert(ol.typ.kind in {tyString, tySequence}, "growObj: 2") - var res = cast[PCell](rawAlloc(gch.region, newsize + sizeof(TCell))) + var res = cast[PCell](rawAlloc(gch.region, newsize + sizeof(Cell))) var elemSize = 1 if ol.typ.kind != tyString: elemSize = ol.typ.base.size var oldsize = cast[PGenericSeq](old).len*elemSize + GenericSeqSize - copyMem(res, ol, oldsize + sizeof(TCell)) - zeroMem(cast[pointer](cast[ByteAddress](res)+% oldsize +% sizeof(TCell)), + copyMem(res, ol, oldsize + sizeof(Cell)) + zeroMem(cast[pointer](cast[ByteAddress](res)+% oldsize +% sizeof(Cell)), newsize-oldsize) sysAssert((cast[ByteAddress](res) and (MemAlign-1)) == 0, "growObj: 3") when false: @@ -306,7 +307,7 @@ proc growObj(old: pointer, newsize: int, gch: var TGcHeap): pointer = when withBitvectors: excl(gch.allocated, ol) when reallyDealloc: rawDealloc(gch.region, ol) else: - zeroMem(ol, sizeof(TCell)) + zeroMem(ol, sizeof(Cell)) when withBitvectors: incl(gch.allocated, res) when useCellIds: inc gch.idGenerator @@ -322,7 +323,7 @@ proc growObj(old: pointer, newsize: int): pointer {.rtl.} = # ----------------- collector ----------------------------------------------- -proc mark(gch: var TGcHeap, c: PCell) = +proc mark(gch: var GcHeap, c: PCell) = when withBitvectors: incl(gch.marked, c) gcAssert gch.tempStack.len == 0, "stack not empty!" @@ -344,7 +345,7 @@ proc mark(gch: var TGcHeap, c: PCell) = d.refCount = rcBlack forAllChildren(d, waMarkPrecise) -proc doOperation(p: pointer, op: TWalkOp) = +proc doOperation(p: pointer, op: WalkOp) = if p == nil: return var c: PCell = usrToCell(p) gcAssert(c != nil, "doOperation: 1") @@ -359,17 +360,17 @@ proc doOperation(p: pointer, op: TWalkOp) = of waMarkPrecise: add(gch.tempStack, c) proc nimGCvisit(d: pointer, op: int) {.compilerRtl.} = - doOperation(d, TWalkOp(op)) + doOperation(d, WalkOp(op)) -proc freeCyclicCell(gch: var TGcHeap, c: PCell) = +proc freeCyclicCell(gch: var GcHeap, c: PCell) = inc gch.stat.freedObjects prepareDealloc(c) when reallyDealloc: rawDealloc(gch.region, c) else: gcAssert(c.typ != nil, "freeCyclicCell") - zeroMem(c, sizeof(TCell)) + zeroMem(c, sizeof(Cell)) -proc sweep(gch: var TGcHeap) = +proc sweep(gch: var GcHeap) = when withBitvectors: for c in gch.allocated.elementsExcept(gch.marked): gch.allocated.excl(c) @@ -391,12 +392,12 @@ when false: writeStackTrace() quit 1 -proc markGlobals(gch: var TGcHeap) = +proc markGlobals(gch: var GcHeap) = for i in 0 .. < globalMarkersLen: globalMarkers[i]() let d = gch.additionalRoots.d for i in 0 .. < gch.additionalRoots.len: mark(gch, d[i]) -proc gcMark(gch: var TGcHeap, p: pointer) {.inline.} = +proc gcMark(gch: var GcHeap, p: pointer) {.inline.} = # the addresses are not as cells on the stack, so turn them to cells: var cell = usrToCell(p) var c = cast[ByteAddress](cell) @@ -446,7 +447,7 @@ when defined(sparc): # For SPARC architecture. var x = cast[ByteAddress](p) result = a <=% x and x <=% b - proc markStackAndRegisters(gch: var TGcHeap) {.noinline, cdecl.} = + proc markStackAndRegisters(gch: var GcHeap) {.noinline, cdecl.} = when defined(sparcv9): asm """"flushw \n" """ else: @@ -479,10 +480,10 @@ elif stackIncreases: var jmpbufSize {.importc: "sizeof(jmp_buf)", nodecl.}: int - # a little hack to get the size of a TJmpBuf in the generated C code + # a little hack to get the size of a JmpBuf in the generated C code # in a platform independent way - proc markStackAndRegisters(gch: var TGcHeap) {.noinline, cdecl.} = + proc markStackAndRegisters(gch: var GcHeap) {.noinline, cdecl.} = var registers: C_JmpBuf if c_setjmp(registers) == 0'i32: # To fill the C stack with registers. var max = cast[ByteAddress](gch.stackBottom) @@ -505,7 +506,7 @@ else: var x = cast[ByteAddress](p) result = a <=% x and x <=% b - proc markStackAndRegisters(gch: var TGcHeap) {.noinline, cdecl.} = + proc markStackAndRegisters(gch: var GcHeap) {.noinline, cdecl.} = # We use a jmp_buf buffer that is in the C stack. # Used to traverse the stack and registers assuming # that 'setjmp' will save registers in the C stack. @@ -514,6 +515,15 @@ else: if c_setjmp(registers) == 0'i32: # To fill the C stack with registers. var max = cast[ByteAddress](gch.stackBottom) var sp = cast[ByteAddress](addr(registers)) + when defined(amd64): + # words within the jmp_buf structure may not be properly aligned. + let regEnd = sp +% sizeof(registers) + while sp <% regEnd: + gcMark(gch, cast[PPointer](sp)[]) + gcMark(gch, cast[PPointer](sp +% sizeof(pointer) div 2)[]) + sp = sp +% sizeof(pointer) + # Make sure sp is word-aligned + sp = sp and not (sizeof(pointer) - 1) # loop unrolled: while sp <% max - 8*sizeof(pointer): gcMark(gch, cast[PStackSlice](sp)[0]) @@ -534,7 +544,7 @@ else: # end of non-portable code # ---------------------------------------------------------------------------- -proc collectCTBody(gch: var TGcHeap) = +proc collectCTBody(gch: var GcHeap) = gch.stat.maxStackSize = max(gch.stat.maxStackSize, stackSize()) prepareForInteriorPointerChecking(gch.region) markStackAndRegisters(gch) @@ -549,7 +559,7 @@ proc collectCTBody(gch: var TGcHeap) = gch.stat.maxThreshold = max(gch.stat.maxThreshold, gch.cycleThreshold) sysAssert(allocInv(gch.region), "collectCT: end") -proc collectCT(gch: var TGcHeap) = +proc collectCT(gch: var GcHeap) = if getOccupiedMem(gch.region) >= gch.cycleThreshold and gch.recGcLock == 0: collectCTBody(gch) diff --git a/lib/system/jssys.nim b/lib/system/jssys.nim index 3b55f62ca..4a26e1e08 100644 --- a/lib/system/jssys.nim +++ b/lib/system/jssys.nim @@ -15,13 +15,13 @@ else: proc log*(s: cstring) {.importc: "console.log", varargs, nodecl.} type - PSafePoint = ptr TSafePoint - TSafePoint {.compilerproc, final.} = object + PSafePoint = ptr SafePoint + SafePoint {.compilerproc, final.} = object prev: PSafePoint # points to next safe point exc: ref Exception - PCallFrame = ptr TCallFrame - TCallFrame {.importc, nodecl, final.} = object + PCallFrame = ptr CallFrame + CallFrame {.importc, nodecl, final.} = object prev: PCallFrame procname: cstring line: int # current line number @@ -33,6 +33,7 @@ type lineNumber {.importc.}: int message {.importc.}: cstring stack {.importc.}: cstring +{.deprecated: [TSafePoint: SafePoint, TCallFrame: CallFrame].} var framePtr {.importc, nodecl, volatile.}: PCallFrame @@ -60,12 +61,13 @@ proc getCurrentExceptionMsg*(): string = proc auxWriteStackTrace(f: PCallFrame): string = type - TTempFrame = tuple[procname: cstring, line: int] + TempFrame = tuple[procname: cstring, line: int] + {.deprecated: [TTempFrame: TempFrame].} var it = f i = 0 total = 0 - tempFrames: array [0..63, TTempFrame] + tempFrames: array [0..63, TempFrame] while it != nil and i <= high(tempFrames): tempFrames[i].procname = it.procname tempFrames[i].line = it.line @@ -260,17 +262,17 @@ proc eqStrings(a, b: string): bool {.asmNoStackFrame, compilerProc.} = """ type - TDocument {.importc.} = object of RootObj + Document {.importc.} = object of RootObj write: proc (text: cstring) {.nimcall.} writeln: proc (text: cstring) {.nimcall.} - createAttribute: proc (identifier: cstring): ref TNode {.nimcall.} - createElement: proc (identifier: cstring): ref TNode {.nimcall.} - createTextNode: proc (identifier: cstring): ref TNode {.nimcall.} - getElementById: proc (id: cstring): ref TNode {.nimcall.} - getElementsByName: proc (name: cstring): seq[ref TNode] {.nimcall.} - getElementsByTagName: proc (name: cstring): seq[ref TNode] {.nimcall.} - - TNodeType* = enum + createAttribute: proc (identifier: cstring): ref Node {.nimcall.} + createElement: proc (identifier: cstring): ref Node {.nimcall.} + createTextNode: proc (identifier: cstring): ref Node {.nimcall.} + getElementById: proc (id: cstring): ref Node {.nimcall.} + getElementsByName: proc (name: cstring): seq[ref Node] {.nimcall.} + getElementsByTagName: proc (name: cstring): seq[ref Node] {.nimcall.} + + NodeType* = enum ElementNode = 1, AttributeNode, TextNode, @@ -283,35 +285,36 @@ type DocumentTypeNode, DocumentFragmentNode, NotationNode - TNode* {.importc.} = object of RootObj - attributes*: seq[ref TNode] - childNodes*: seq[ref TNode] + Node* {.importc.} = object of RootObj + attributes*: seq[ref Node] + childNodes*: seq[ref Node] data*: cstring - firstChild*: ref TNode - lastChild*: ref TNode - nextSibling*: ref TNode + firstChild*: ref Node + lastChild*: ref Node + nextSibling*: ref Node nodeName*: cstring - nodeType*: TNodeType + nodeType*: NodeType nodeValue*: cstring - parentNode*: ref TNode - previousSibling*: ref TNode - appendChild*: proc (child: ref TNode) {.nimcall.} + parentNode*: ref Node + previousSibling*: ref Node + appendChild*: proc (child: ref Node) {.nimcall.} appendData*: proc (data: cstring) {.nimcall.} cloneNode*: proc (copyContent: bool) {.nimcall.} deleteData*: proc (start, len: int) {.nimcall.} getAttribute*: proc (attr: cstring): cstring {.nimcall.} - getAttributeNode*: proc (attr: cstring): ref TNode {.nimcall.} - getElementsByTagName*: proc (): seq[ref TNode] {.nimcall.} + getAttributeNode*: proc (attr: cstring): ref Node {.nimcall.} + getElementsByTagName*: proc (): seq[ref Node] {.nimcall.} hasChildNodes*: proc (): bool {.nimcall.} - insertBefore*: proc (newNode, before: ref TNode) {.nimcall.} + insertBefore*: proc (newNode, before: ref Node) {.nimcall.} insertData*: proc (position: int, data: cstring) {.nimcall.} removeAttribute*: proc (attr: cstring) {.nimcall.} - removeAttributeNode*: proc (attr: ref TNode) {.nimcall.} - removeChild*: proc (child: ref TNode) {.nimcall.} - replaceChild*: proc (newNode, oldNode: ref TNode) {.nimcall.} + removeAttributeNode*: proc (attr: ref Node) {.nimcall.} + removeChild*: proc (child: ref Node) {.nimcall.} + replaceChild*: proc (newNode, oldNode: ref Node) {.nimcall.} replaceData*: proc (start, len: int, text: cstring) {.nimcall.} setAttribute*: proc (name, value: cstring) {.nimcall.} - setAttributeNode*: proc (attr: ref TNode) {.nimcall.} + setAttributeNode*: proc (attr: ref Node) {.nimcall.} +{.deprecated: [TNode: Node, TNodeType: NodeType, TDocument: Document].} when defined(kwin): proc rawEcho {.compilerproc, asmNoStackFrame.} = @@ -337,7 +340,7 @@ elif defined(nodejs): else: var - document {.importc, nodecl.}: ref TDocument + document {.importc, nodecl.}: ref Document proc ewriteln(x: cstring) = var node = document.getElementsByTagName("body")[0] diff --git a/lib/system/mmdisp.nim b/lib/system/mmdisp.nim index a378f86e7..86d834ceb 100644 --- a/lib/system/mmdisp.nim +++ b/lib/system/mmdisp.nim @@ -34,9 +34,10 @@ const type PPointer = ptr pointer - TByteArray = array[0..1000_0000, byte] - PByte = ptr TByteArray + ByteArray = array[0..1000_0000, byte] + PByte = ptr ByteArray PString = ptr string +{.deprecated: [TByteArray: ByteArray].} # Page size of the system; in most cases 4096 bytes. For exotic OS or # CPU this needs to be changed: @@ -70,7 +71,7 @@ when defined(boehmgc): elif defined(macosx): const boehmLib = "libgc.dylib" else: - const boehmLib = "/usr/lib/libgc.so.1" + const boehmLib = "libgc.so.1" proc boehmGCinit {.importc: "GC_init", dynlib: boehmLib.} proc boehmGC_disable {.importc: "GC_disable", dynlib: boehmLib.} @@ -180,16 +181,17 @@ when defined(boehmgc): dest[] = src type - TMemRegion = object {.final, pure.} + MemRegion = object {.final, pure.} + {.deprecated: [TMemRegion: MemRegion].} - proc alloc(r: var TMemRegion, size: int): pointer = + proc alloc(r: var MemRegion, size: int): pointer = result = boehmAlloc(size) if result == nil: raiseOutOfMem() - proc alloc0(r: var TMemRegion, size: int): pointer = + proc alloc0(r: var MemRegion, size: int): pointer = result = alloc(size) zeroMem(result, size) - proc dealloc(r: var TMemRegion, p: pointer) = boehmDealloc(p) - proc deallocOsPages(r: var TMemRegion) {.inline.} = discard + proc dealloc(r: var MemRegion, p: pointer) = boehmDealloc(p) + proc deallocOsPages(r: var MemRegion) {.inline.} = discard proc deallocOsPages() {.inline.} = discard include "system/cellsets" @@ -257,14 +259,15 @@ elif defined(nogc) and defined(useMalloc): dest[] = src type - TMemRegion = object {.final, pure.} + MemRegion = object {.final, pure.} + {.deprecated: [TMemRegion: MemRegion].} - proc alloc(r: var TMemRegion, size: int): pointer = + proc alloc(r: var MemRegion, size: int): pointer = result = alloc(size) - proc alloc0(r: var TMemRegion, size: int): pointer = + proc alloc0(r: var MemRegion, size: int): pointer = result = alloc0(size) - proc dealloc(r: var TMemRegion, p: pointer) = dealloc(p) - proc deallocOsPages(r: var TMemRegion) {.inline.} = discard + proc dealloc(r: var MemRegion, p: pointer) = dealloc(p) + proc deallocOsPages(r: var MemRegion) {.inline.} = discard proc deallocOsPages() {.inline.} = discard elif defined(nogc): @@ -313,7 +316,7 @@ elif defined(nogc): proc asgnRefNoCycle(dest: PPointer, src: pointer) {.compilerproc, inline.} = dest[] = src - var allocator {.rtlThreadVar.}: TMemRegion + var allocator {.rtlThreadVar.}: MemRegion instantiateForRegion(allocator) include "system/cellsets" @@ -323,7 +326,7 @@ else: include "system/cellsets" when not leakDetector: - sysAssert(sizeof(TCell) == sizeof(TFreeCell), "sizeof TFreeCell") + sysAssert(sizeof(Cell) == sizeof(FreeCell), "sizeof FreeCell") when compileOption("gc", "v2"): include "system/gc2" elif defined(gcMarkAndSweep): @@ -335,4 +338,3 @@ else: include "system/gc" {.pop.} - diff --git a/lib/system/profiler.nim b/lib/system/profiler.nim index 6d6863caa..c93456fb3 100644 --- a/lib/system/profiler.nim +++ b/lib/system/profiler.nim @@ -19,10 +19,11 @@ const MaxTraceLen = 20 # tracking the last 20 calls is enough type - TStackTrace* = array [0..MaxTraceLen-1, cstring] - TProfilerHook* = proc (st: TStackTrace) {.nimcall.} + StackTrace* = array [0..MaxTraceLen-1, cstring] + ProfilerHook* = proc (st: StackTrace) {.nimcall.} +{.deprecated: [TStackTrace: StackTrace, TProfilerHook: ProfilerHook].} -proc captureStackTrace(f: PFrame, st: var TStackTrace) = +proc captureStackTrace(f: PFrame, st: var StackTrace) = const firstCalls = 5 var @@ -51,14 +52,15 @@ proc captureStackTrace(f: PFrame, st: var TStackTrace) = when defined(memProfiler): type - TMemProfilerHook* = proc (st: TStackTrace, requestedSize: int) {.nimcall, benign.} + MemProfilerHook* = proc (st: StackTrace, requestedSize: int) {.nimcall, benign.} + {.deprecated: [TMemProfilerHook: MemProfilerHook].} var - profilerHook*: TMemProfilerHook + profilerHook*: MemProfilerHook ## set this variable to provide a procedure that implements a profiler in ## user space. See the `nimprof` module for a reference implementation. - proc callProfilerHook(hook: TMemProfilerHook, requestedSize: int) = - var st: TStackTrace + proc callProfilerHook(hook: MemProfilerHook, requestedSize: int) = + var st: StackTrace captureStackTrace(framePtr, st) hook(st, requestedSize) @@ -70,15 +72,15 @@ else: SamplingInterval = 50_000 # set this to change the default sampling interval var - profilerHook*: TProfilerHook + profilerHook*: ProfilerHook ## set this variable to provide a procedure that implements a profiler in ## user space. See the `nimprof` module for a reference implementation. gTicker {.threadvar.}: int - proc callProfilerHook(hook: TProfilerHook) {.noinline.} = + proc callProfilerHook(hook: ProfilerHook) {.noinline.} = # 'noinline' so that 'nimProfile' does not perform the stack allocation # in the common case. - var st: TStackTrace + var st: StackTrace captureStackTrace(framePtr, st) hook(st) diff --git a/lib/system/repr.nim b/lib/system/repr.nim index f1029ff6a..f3b69954a 100644 --- a/lib/system/repr.nim +++ b/lib/system/repr.nim @@ -121,38 +121,39 @@ proc reprSet(p: pointer, typ: PNimType): string {.compilerRtl.} = reprSetAux(result, p, typ) type - TReprClosure {.final.} = object # we cannot use a global variable here + ReprClosure {.final.} = object # we cannot use a global variable here # as this wouldn't be thread-safe - when declared(TCellSet): - marked: TCellSet + when declared(CellSet): + marked: CellSet recdepth: int # do not recurse endlessly indent: int # indentation +{.deprecated: [TReprClosure: ReprClosure].} when not defined(useNimRtl): - proc initReprClosure(cl: var TReprClosure) = + proc initReprClosure(cl: var ReprClosure) = # Important: cellsets does not lock the heap when doing allocations! We # have to do it here ... when hasThreadSupport and hasSharedHeap and declared(heapLock): AcquireSys(HeapLock) - when declared(TCellSet): + when declared(CellSet): init(cl.marked) cl.recdepth = -1 # default is to display everything! cl.indent = 0 - proc deinitReprClosure(cl: var TReprClosure) = - when declared(TCellSet): deinit(cl.marked) + proc deinitReprClosure(cl: var ReprClosure) = + when declared(CellSet): deinit(cl.marked) when hasThreadSupport and hasSharedHeap and declared(heapLock): ReleaseSys(HeapLock) - proc reprBreak(result: var string, cl: TReprClosure) = + proc reprBreak(result: var string, cl: ReprClosure) = add result, "\n" for i in 0..cl.indent-1: add result, ' ' proc reprAux(result: var string, p: pointer, typ: PNimType, - cl: var TReprClosure) {.benign.} + cl: var ReprClosure) {.benign.} proc reprArray(result: var string, p: pointer, typ: PNimType, - cl: var TReprClosure) = + cl: var ReprClosure) = add result, "[" var bs = typ.base.size for i in 0..typ.size div bs - 1: @@ -161,7 +162,7 @@ when not defined(useNimRtl): add result, "]" proc reprSequence(result: var string, p: pointer, typ: PNimType, - cl: var TReprClosure) = + cl: var ReprClosure) = if p == nil: add result, "nil" return @@ -174,7 +175,7 @@ when not defined(useNimRtl): add result, "]" proc reprRecordAux(result: var string, p: pointer, n: ptr TNimNode, - cl: var TReprClosure) {.benign.} = + cl: var ReprClosure) {.benign.} = case n.kind of nkNone: sysAssert(false, "reprRecordAux") of nkSlot: @@ -191,7 +192,7 @@ when not defined(useNimRtl): if m != nil: reprRecordAux(result, p, m, cl) proc reprRecord(result: var string, p: pointer, typ: PNimType, - cl: var TReprClosure) = + cl: var ReprClosure) = add result, "[" let oldLen = result.len reprRecordAux(result, p, typ.node, cl) @@ -201,9 +202,9 @@ when not defined(useNimRtl): add result, "]" proc reprRef(result: var string, p: pointer, typ: PNimType, - cl: var TReprClosure) = + cl: var ReprClosure) = # we know that p is not nil here: - when declared(TCellSet): + when declared(CellSet): when defined(boehmGC) or defined(nogc): var cell = cast[PCell](p) else: @@ -216,7 +217,7 @@ when not defined(useNimRtl): reprAux(result, p, typ.base, cl) proc reprAux(result: var string, p: pointer, typ: PNimType, - cl: var TReprClosure) = + cl: var ReprClosure) = if cl.recdepth == 0: add result, "..." return @@ -261,7 +262,7 @@ when not defined(useNimRtl): proc reprOpenArray(p: pointer, length: int, elemtyp: PNimType): string {. compilerRtl.} = var - cl: TReprClosure + cl: ReprClosure initReprClosure(cl) result = "[" var bs = elemtyp.size @@ -274,7 +275,7 @@ proc reprOpenArray(p: pointer, length: int, elemtyp: PNimType): string {. when not defined(useNimRtl): proc reprAny(p: pointer, typ: PNimType): string = var - cl: TReprClosure + cl: ReprClosure initReprClosure(cl) result = "" if typ.kind in {tyObject, tyTuple, tyArray, tyArrayConstr, tySet}: diff --git a/lib/system/sets.nim b/lib/system/sets.nim index 626d43c33..22d6d57c0 100644 --- a/lib/system/sets.nim +++ b/lib/system/sets.nim @@ -10,7 +10,8 @@ # set handling type - TNimSet = array [0..4*2048-1, uint8] + NimSet = array [0..4*2048-1, uint8] +{.deprecated: [TNimSet: NimSet].} proc countBits32(n: int32): int {.compilerproc.} = var v = n @@ -22,7 +23,7 @@ proc countBits64(n: int64): int {.compilerproc.} = result = countBits32(toU32(n and 0xffff'i64)) + countBits32(toU32(n shr 16'i64)) -proc cardSet(s: TNimSet, len: int): int {.compilerproc.} = +proc cardSet(s: NimSet, len: int): int {.compilerproc.} = result = 0 for i in countup(0, len-1): inc(result, countBits32(int32(s[i]))) diff --git a/lib/system/syslocks.nim b/lib/system/syslocks.nim index 8b38f34f3..ec8c26275 100644 --- a/lib/system/syslocks.nim +++ b/lib/system/syslocks.nim @@ -11,8 +11,8 @@ when defined(Windows): type - THandle = int - TSysLock {.final, pure.} = object # CRITICAL_SECTION in WinApi + Handle = int + SysLock {.final, pure.} = object # CRITICAL_SECTION in WinApi DebugInfo: pointer LockCount: int32 RecursionCount: int32 @@ -20,85 +20,87 @@ when defined(Windows): LockSemaphore: int Reserved: int32 - TSysCond = THandle + SysCond = Handle + + {.deprecated: [THandle: Handle, TSysLock: SysLock, TSysCond: SysCond].} - proc initSysLock(L: var TSysLock) {.stdcall, noSideEffect, + proc initSysLock(L: var SysLock) {.stdcall, noSideEffect, dynlib: "kernel32", importc: "InitializeCriticalSection".} ## Initializes the lock `L`. - proc tryAcquireSysAux(L: var TSysLock): int32 {.stdcall, noSideEffect, + proc tryAcquireSysAux(L: var SysLock): int32 {.stdcall, noSideEffect, dynlib: "kernel32", importc: "TryEnterCriticalSection".} ## Tries to acquire the lock `L`. - proc tryAcquireSys(L: var TSysLock): bool {.inline.} = + proc tryAcquireSys(L: var SysLock): bool {.inline.} = result = tryAcquireSysAux(L) != 0'i32 - proc acquireSys(L: var TSysLock) {.stdcall, noSideEffect, + proc acquireSys(L: var SysLock) {.stdcall, noSideEffect, dynlib: "kernel32", importc: "EnterCriticalSection".} ## Acquires the lock `L`. - proc releaseSys(L: var TSysLock) {.stdcall, noSideEffect, + proc releaseSys(L: var SysLock) {.stdcall, noSideEffect, dynlib: "kernel32", importc: "LeaveCriticalSection".} ## Releases the lock `L`. - proc deinitSys(L: var TSysLock) {.stdcall, noSideEffect, + proc deinitSys(L: var SysLock) {.stdcall, noSideEffect, dynlib: "kernel32", importc: "DeleteCriticalSection".} proc createEvent(lpEventAttributes: pointer, bManualReset, bInitialState: int32, - lpName: cstring): TSysCond {.stdcall, noSideEffect, + lpName: cstring): SysCond {.stdcall, noSideEffect, dynlib: "kernel32", importc: "CreateEventA".} - proc closeHandle(hObject: THandle) {.stdcall, noSideEffect, + proc closeHandle(hObject: Handle) {.stdcall, noSideEffect, dynlib: "kernel32", importc: "CloseHandle".} - proc waitForSingleObject(hHandle: THandle, dwMilliseconds: int32): int32 {. + proc waitForSingleObject(hHandle: Handle, dwMilliseconds: int32): int32 {. stdcall, dynlib: "kernel32", importc: "WaitForSingleObject", noSideEffect.} - proc signalSysCond(hEvent: TSysCond) {.stdcall, noSideEffect, + proc signalSysCond(hEvent: SysCond) {.stdcall, noSideEffect, dynlib: "kernel32", importc: "SetEvent".} - proc initSysCond(cond: var TSysCond) {.inline.} = + proc initSysCond(cond: var SysCond) {.inline.} = cond = createEvent(nil, 0'i32, 0'i32, nil) - proc deinitSysCond(cond: var TSysCond) {.inline.} = + proc deinitSysCond(cond: var SysCond) {.inline.} = closeHandle(cond) - proc waitSysCond(cond: var TSysCond, lock: var TSysLock) = + proc waitSysCond(cond: var SysCond, lock: var SysLock) = releaseSys(lock) discard waitForSingleObject(cond, -1'i32) acquireSys(lock) - proc waitSysCondWindows(cond: var TSysCond) = + proc waitSysCondWindows(cond: var SysCond) = discard waitForSingleObject(cond, -1'i32) else: type - TSysLock {.importc: "pthread_mutex_t", pure, final, + SysLock {.importc: "pthread_mutex_t", pure, final, header: "<sys/types.h>".} = object - TSysCond {.importc: "pthread_cond_t", pure, final, + SysCond {.importc: "pthread_cond_t", pure, final, header: "<sys/types.h>".} = object - proc initSysLock(L: var TSysLock, attr: pointer = nil) {. + proc initSysLock(L: var SysLock, attr: pointer = nil) {. importc: "pthread_mutex_init", header: "<pthread.h>", noSideEffect.} - proc acquireSys(L: var TSysLock) {.noSideEffect, + proc acquireSys(L: var SysLock) {.noSideEffect, importc: "pthread_mutex_lock", header: "<pthread.h>".} - proc tryAcquireSysAux(L: var TSysLock): cint {.noSideEffect, + proc tryAcquireSysAux(L: var SysLock): cint {.noSideEffect, importc: "pthread_mutex_trylock", header: "<pthread.h>".} - proc tryAcquireSys(L: var TSysLock): bool {.inline.} = + proc tryAcquireSys(L: var SysLock): bool {.inline.} = result = tryAcquireSysAux(L) == 0'i32 - proc releaseSys(L: var TSysLock) {.noSideEffect, + proc releaseSys(L: var SysLock) {.noSideEffect, importc: "pthread_mutex_unlock", header: "<pthread.h>".} - proc deinitSys(L: var TSysLock) {.noSideEffect, + proc deinitSys(L: var SysLock) {.noSideEffect, importc: "pthread_mutex_destroy", header: "<pthread.h>".} - proc initSysCond(cond: var TSysCond, cond_attr: pointer = nil) {. + proc initSysCond(cond: var SysCond, cond_attr: pointer = nil) {. importc: "pthread_cond_init", header: "<pthread.h>", noSideEffect.} - proc waitSysCond(cond: var TSysCond, lock: var TSysLock) {. + proc waitSysCond(cond: var SysCond, lock: var SysLock) {. importc: "pthread_cond_wait", header: "<pthread.h>", noSideEffect.} - proc signalSysCond(cond: var TSysCond) {. + proc signalSysCond(cond: var SysCond) {. importc: "pthread_cond_signal", header: "<pthread.h>", noSideEffect.} - proc deinitSysCond(cond: var TSysCond) {.noSideEffect, + proc deinitSysCond(cond: var SysCond) {.noSideEffect, importc: "pthread_cond_destroy", header: "<pthread.h>".} diff --git a/lib/system/sysspawn.nim b/lib/system/sysspawn.nim index 6f45f1509..5f8f2b2c5 100644 --- a/lib/system/sysspawn.nim +++ b/lib/system/sysspawn.nim @@ -19,9 +19,9 @@ when not declared(NimString): type CondVar = object - c: TSysCond + c: SysCond when defined(posix): - stupidLock: TSysLock + stupidLock: SysLock counter: int proc createCondVar(): CondVar = diff --git a/lib/system/threads.nim b/lib/system/threads.nim index d8e011ecb..865271a50 100644 --- a/lib/system/threads.nim +++ b/lib/system/threads.nim @@ -24,8 +24,8 @@ ## import locks ## ## var -## thr: array [0..4, TThread[tuple[a,b: int]]] -## L: TLock +## thr: array [0..4, Thread[tuple[a,b: int]]] +## L: Lock ## ## proc threadFunc(interval: tuple[a,b: int]) {.thread.} = ## for i in interval.a..interval.b: @@ -51,40 +51,41 @@ const when defined(windows): type - TSysThread = THandle - TWinThreadProc = proc (x: pointer): int32 {.stdcall.} + SysThread = Handle + WinThreadProc = proc (x: pointer): int32 {.stdcall.} + {.deprecated: [TSysThread: SysThread, TWinThreadProc: WinThreadProc].} proc createThread(lpThreadAttributes: pointer, dwStackSize: int32, - lpStartAddress: TWinThreadProc, + lpStartAddress: WinThreadProc, lpParameter: pointer, dwCreationFlags: int32, - lpThreadId: var int32): TSysThread {. + lpThreadId: var int32): SysThread {. stdcall, dynlib: "kernel32", importc: "CreateThread".} - proc winSuspendThread(hThread: TSysThread): int32 {. + proc winSuspendThread(hThread: SysThread): int32 {. stdcall, dynlib: "kernel32", importc: "SuspendThread".} - proc winResumeThread(hThread: TSysThread): int32 {. + proc winResumeThread(hThread: SysThread): int32 {. stdcall, dynlib: "kernel32", importc: "ResumeThread".} proc waitForMultipleObjects(nCount: int32, - lpHandles: ptr TSysThread, + lpHandles: ptr SysThread, bWaitAll: int32, dwMilliseconds: int32): int32 {. stdcall, dynlib: "kernel32", importc: "WaitForMultipleObjects".} - proc terminateThread(hThread: TSysThread, dwExitCode: int32): int32 {. + proc terminateThread(hThread: SysThread, dwExitCode: int32): int32 {. stdcall, dynlib: "kernel32", importc: "TerminateThread".} type - TThreadVarSlot = distinct int32 + ThreadVarSlot = distinct int32 when true: - proc threadVarAlloc(): TThreadVarSlot {. + proc threadVarAlloc(): ThreadVarSlot {. importc: "TlsAlloc", stdcall, header: "<windows.h>".} - proc threadVarSetValue(dwTlsIndex: TThreadVarSlot, lpTlsValue: pointer) {. + proc threadVarSetValue(dwTlsIndex: ThreadVarSlot, lpTlsValue: pointer) {. importc: "TlsSetValue", stdcall, header: "<windows.h>".} - proc tlsGetValue(dwTlsIndex: TThreadVarSlot): pointer {. + proc tlsGetValue(dwTlsIndex: ThreadVarSlot): pointer {. importc: "TlsGetValue", stdcall, header: "<windows.h>".} proc getLastError(): uint32 {. @@ -92,16 +93,16 @@ when defined(windows): proc setLastError(x: uint32) {. importc: "SetLastError", stdcall, header: "<windows.h>".} - proc threadVarGetValue(dwTlsIndex: TThreadVarSlot): pointer = + proc threadVarGetValue(dwTlsIndex: ThreadVarSlot): pointer = let realLastError = getLastError() result = tlsGetValue(dwTlsIndex) setLastError(realLastError) else: - proc threadVarAlloc(): TThreadVarSlot {. + proc threadVarAlloc(): ThreadVarSlot {. importc: "TlsAlloc", stdcall, dynlib: "kernel32".} - proc threadVarSetValue(dwTlsIndex: TThreadVarSlot, lpTlsValue: pointer) {. + proc threadVarSetValue(dwTlsIndex: ThreadVarSlot, lpTlsValue: pointer) {. importc: "TlsSetValue", stdcall, dynlib: "kernel32".} - proc threadVarGetValue(dwTlsIndex: TThreadVarSlot): pointer {. + proc threadVarGetValue(dwTlsIndex: ThreadVarSlot): pointer {. importc: "TlsGetValue", stdcall, dynlib: "kernel32".} else: @@ -111,55 +112,58 @@ else: {.passC: "-pthread".} type - TSysThread {.importc: "pthread_t", header: "<sys/types.h>", + SysThread {.importc: "pthread_t", header: "<sys/types.h>", final, pure.} = object - Tpthread_attr {.importc: "pthread_attr_t", + Pthread_attr {.importc: "pthread_attr_t", header: "<sys/types.h>", final, pure.} = object - Ttimespec {.importc: "struct timespec", + Timespec {.importc: "struct timespec", header: "<time.h>", final, pure.} = object tv_sec: int tv_nsec: int + {.deprecated: [TSysThread: SysThread, Tpthread_attr: PThreadAttr, + Ttimespec: Timespec].} - proc pthread_attr_init(a1: var TPthread_attr) {. + proc pthread_attr_init(a1: var PthreadAttr) {. importc, header: "<pthread.h>".} - proc pthread_attr_setstacksize(a1: var TPthread_attr, a2: int) {. + proc pthread_attr_setstacksize(a1: var PthreadAttr, a2: int) {. importc, header: "<pthread.h>".} - proc pthread_create(a1: var TSysThread, a2: var TPthread_attr, + proc pthread_create(a1: var SysThread, a2: var PthreadAttr, a3: proc (x: pointer): pointer {.noconv.}, a4: pointer): cint {.importc: "pthread_create", header: "<pthread.h>".} - proc pthread_join(a1: TSysThread, a2: ptr pointer): cint {. + proc pthread_join(a1: SysThread, a2: ptr pointer): cint {. importc, header: "<pthread.h>".} - proc pthread_cancel(a1: TSysThread): cint {. + proc pthread_cancel(a1: SysThread): cint {. importc: "pthread_cancel", header: "<pthread.h>".} type - TThreadVarSlot {.importc: "pthread_key_t", pure, final, + ThreadVarSlot {.importc: "pthread_key_t", pure, final, header: "<sys/types.h>".} = object + {.deprecated: [TThreadVarSlot: ThreadVarSlot].} - proc pthread_getspecific(a1: TThreadVarSlot): pointer {. + proc pthread_getspecific(a1: ThreadVarSlot): pointer {. importc: "pthread_getspecific", header: "<pthread.h>".} - proc pthread_key_create(a1: ptr TThreadVarSlot, + proc pthread_key_create(a1: ptr ThreadVarSlot, destruct: proc (x: pointer) {.noconv.}): int32 {. importc: "pthread_key_create", header: "<pthread.h>".} - proc pthread_key_delete(a1: TThreadVarSlot): int32 {. + proc pthread_key_delete(a1: ThreadVarSlot): int32 {. importc: "pthread_key_delete", header: "<pthread.h>".} - proc pthread_setspecific(a1: TThreadVarSlot, a2: pointer): int32 {. + proc pthread_setspecific(a1: ThreadVarSlot, a2: pointer): int32 {. importc: "pthread_setspecific", header: "<pthread.h>".} - proc threadVarAlloc(): TThreadVarSlot {.inline.} = + proc threadVarAlloc(): ThreadVarSlot {.inline.} = discard pthread_key_create(addr(result), nil) - proc threadVarSetValue(s: TThreadVarSlot, value: pointer) {.inline.} = + proc threadVarSetValue(s: ThreadVarSlot, value: pointer) {.inline.} = discard pthread_setspecific(s, value) - proc threadVarGetValue(s: TThreadVarSlot): pointer {.inline.} = + proc threadVarGetValue(s: ThreadVarSlot): pointer {.inline.} = result = pthread_getspecific(s) when useStackMaskHack: - proc pthread_attr_setstack(attr: var TPthread_attr, stackaddr: pointer, + proc pthread_attr_setstack(attr: var PthreadAttr, stackaddr: pointer, size: int): cint {. importc: "pthread_attr_setstack", header: "<pthread.h>".} @@ -175,13 +179,13 @@ when emulatedThreadVars: # allocations are needed. Currently less than 7K are used on a 64bit machine. # We use ``float`` for proper alignment: type - TThreadLocalStorage = array [0..1_000, float] + ThreadLocalStorage = array [0..1_000, float] - PGcThread = ptr TGcThread - TGcThread {.pure, inheritable.} = object - sys: TSysThread + PGcThread = ptr GcThread + GcThread {.pure, inheritable.} = object + sys: SysThread when emulatedThreadVars and not useStackMaskHack: - tls: TThreadLocalStorage + tls: ThreadLocalStorage else: nil when hasSharedHeap: @@ -190,15 +194,16 @@ type stackSize: int else: nil +{.deprecated: [TThreadLocalStorage: ThreadLocalStorage, TGcThread: GcThread].} # XXX it'd be more efficient to not use a global variable for the # thread storage slot, but to rely on the implementation to assign slot X # for us... ;-) -var globalsSlot: TThreadVarSlot +var globalsSlot: ThreadVarSlot when not defined(useNimRtl): when not useStackMaskHack: - var mainThread: TGcThread + var mainThread: GcThread proc initThreadVarsEmulation() {.compilerProc, inline.} = when not defined(useNimRtl): @@ -206,7 +211,7 @@ proc initThreadVarsEmulation() {.compilerProc, inline.} = when declared(mainThread): threadVarSetValue(globalsSlot, addr(mainThread)) -#const globalsSlot = TThreadVarSlot(0) +#const globalsSlot = ThreadVarSlot(0) #sysAssert checkSlot.int == globalsSlot.int when emulatedThreadVars: @@ -228,7 +233,7 @@ when not defined(useNimRtl): initGC() when emulatedThreadVars: - if nimThreadVarsSize() > sizeof(TThreadLocalStorage): + if nimThreadVarsSize() > sizeof(ThreadLocalStorage): echo "too large thread local storage size requested" quit 1 @@ -269,26 +274,27 @@ when not defined(useNimRtl): # use ``stdcall`` since it is mapped to ``noconv`` on UNIX anyway. type - TThread* {.pure, final.}[TArg] = - object of TGcThread ## Nim thread. A thread is a heavy object (~14K) + Thread* {.pure, final.}[TArg] = + object of GcThread ## Nim thread. A thread is a heavy object (~14K) ## that **must not** be part of a message! Use - ## a ``TThreadId`` for that. + ## a ``ThreadId`` for that. when TArg is void: dataFn: proc () {.nimcall, gcsafe.} else: dataFn: proc (m: TArg) {.nimcall, gcsafe.} data: TArg - TThreadId*[TArg] = ptr TThread[TArg] ## the current implementation uses + ThreadId*[TArg] = ptr Thread[TArg] ## the current implementation uses ## a pointer as a thread ID. +{.deprecated: [TThread: Thread, TThreadId: ThreadId].} when not defined(boehmgc) and not hasSharedHeap: proc deallocOsPages() template threadProcWrapperBody(closure: expr) {.immediate.} = when declared(globalsSlot): threadVarSetValue(globalsSlot, closure) - var t = cast[ptr TThread[TArg]](closure) + var t = cast[ptr Thread[TArg]](closure) when useStackMaskHack: - var tls: TThreadLocalStorage + var tls: ThreadLocalStorage when not defined(boehmgc) and not defined(nogc) and not hasSharedHeap: # init the GC for this thread: setStackBottom(addr(t)) @@ -319,35 +325,35 @@ else: threadProcWrapperBody(closure) {.pop.} -proc running*[TArg](t: TThread[TArg]): bool {.inline.} = +proc running*[TArg](t: Thread[TArg]): bool {.inline.} = ## returns true if `t` is running. result = t.dataFn != nil when hostOS == "windows": - proc joinThread*[TArg](t: TThread[TArg]) {.inline.} = + proc joinThread*[TArg](t: Thread[TArg]) {.inline.} = ## waits for the thread `t` to finish. discard waitForSingleObject(t.sys, -1'i32) - proc joinThreads*[TArg](t: varargs[TThread[TArg]]) = + proc joinThreads*[TArg](t: varargs[Thread[TArg]]) = ## waits for every thread in `t` to finish. - var a: array[0..255, TSysThread] + var a: array[0..255, SysThread] sysAssert a.len >= t.len, "a.len >= t.len" for i in 0..t.high: a[i] = t[i].sys discard waitForMultipleObjects(t.len.int32, - cast[ptr TSysThread](addr(a)), 1, -1) + cast[ptr SysThread](addr(a)), 1, -1) else: - proc joinThread*[TArg](t: TThread[TArg]) {.inline.} = + proc joinThread*[TArg](t: Thread[TArg]) {.inline.} = ## waits for the thread `t` to finish. discard pthread_join(t.sys, nil) - proc joinThreads*[TArg](t: varargs[TThread[TArg]]) = + proc joinThreads*[TArg](t: varargs[Thread[TArg]]) = ## waits for every thread in `t` to finish. for i in 0..t.high: joinThread(t[i]) when false: # XXX a thread should really release its heap here somehow: - proc destroyThread*[TArg](t: var TThread[TArg]) = + proc destroyThread*[TArg](t: var Thread[TArg]) = ## forces the thread `t` to terminate. This is potentially dangerous if ## you don't have full control over `t` and its acquired resources. when hostOS == "windows": @@ -358,7 +364,7 @@ when false: t.dataFn = nil when hostOS == "windows": - proc createThread*[TArg](t: var TThread[TArg], + proc createThread*[TArg](t: var Thread[TArg], tp: proc (arg: TArg) {.thread.}, param: TArg) = ## creates a new thread `t` and starts its execution. Entry point is the @@ -373,7 +379,7 @@ when hostOS == "windows": if t.sys <= 0: raise newException(ResourceExhaustedError, "cannot create thread") else: - proc createThread*[TArg](t: var TThread[TArg], + proc createThread*[TArg](t: var Thread[TArg], tp: proc (arg: TArg) {.thread.}, param: TArg) = ## creates a new thread `t` and starts its execution. Entry point is the @@ -382,29 +388,29 @@ else: when TArg isnot void: t.data = param t.dataFn = tp when hasSharedHeap: t.stackSize = ThreadStackSize - var a {.noinit.}: Tpthread_attr + var a {.noinit.}: PthreadAttr pthread_attr_init(a) pthread_attr_setstacksize(a, ThreadStackSize) if pthread_create(t.sys, a, threadProcWrapper[TArg], addr(t)) != 0: raise newException(ResourceExhaustedError, "cannot create thread") -proc threadId*[TArg](t: var TThread[TArg]): TThreadId[TArg] {.inline.} = +proc threadId*[TArg](t: var Thread[TArg]): ThreadId[TArg] {.inline.} = ## returns the thread ID of `t`. result = addr(t) -proc myThreadId*[TArg](): TThreadId[TArg] = +proc myThreadId*[TArg](): ThreadId[TArg] = ## returns the thread ID of the thread that calls this proc. This is unsafe ## because the type ``TArg`` is not checked for consistency! - result = cast[TThreadId[TArg]](threadVarGetValue(globalsSlot)) + result = cast[ThreadId[TArg]](threadVarGetValue(globalsSlot)) when false: - proc mainThreadId*[TArg](): TThreadId[TArg] = + proc mainThreadId*[TArg](): ThreadId[TArg] = ## returns the thread ID of the main thread. - result = cast[TThreadId[TArg]](addr(mainThread)) + result = cast[ThreadId[TArg]](addr(mainThread)) when useStackMaskHack: proc runMain(tp: proc () {.thread.}) {.compilerproc.} = - var mainThread: TThread[pointer] + var mainThread: Thread[pointer] createThread(mainThread, tp) joinThread(mainThread) diff --git a/lib/system/timers.nim b/lib/system/timers.nim index e5de791ac..74748c541 100644 --- a/lib/system/timers.nim +++ b/lib/system/timers.nim @@ -11,83 +11,86 @@ ## `<https://github.com/jckarter/clay/blob/master/compiler/src/hirestimer.cpp>`_ type - TTicks = distinct int64 - TNanos = int64 + Ticks = distinct int64 + Nanos = int64 +{.deprecated: [TTicks: Ticks, TNanos: Nanos].} when defined(windows): - proc QueryPerformanceCounter(res: var TTicks) {. + proc QueryPerformanceCounter(res: var Ticks) {. importc: "QueryPerformanceCounter", stdcall, dynlib: "kernel32".} proc QueryPerformanceFrequency(res: var int64) {. importc: "QueryPerformanceFrequency", stdcall, dynlib: "kernel32".} - proc getTicks(): TTicks {.inline.} = + proc getTicks(): Ticks {.inline.} = QueryPerformanceCounter(result) - proc `-`(a, b: TTicks): TNanos = + proc `-`(a, b: Ticks): Nanos = var frequency: int64 QueryPerformanceFrequency(frequency) var performanceCounterRate = 1e+9'f64 / float64(frequency) - result = TNanos(float64(a.int64 - b.int64) * performanceCounterRate) + result = Nanos(float64(a.int64 - b.int64) * performanceCounterRate) elif defined(macosx): type - TMachTimebaseInfoData {.pure, final, + MachTimebaseInfoData {.pure, final, importc: "mach_timebase_info_data_t", header: "<mach/mach_time.h>".} = object numer, denom: int32 + {.deprecated: [TMachTimebaseInfoData: MachTimebaseInfoData].} proc mach_absolute_time(): int64 {.importc, header: "<mach/mach.h>".} - proc mach_timebase_info(info: var TMachTimebaseInfoData) {.importc, + proc mach_timebase_info(info: var MachTimebaseInfoData) {.importc, header: "<mach/mach_time.h>".} - proc getTicks(): TTicks {.inline.} = - result = TTicks(mach_absolute_time()) + proc getTicks(): Ticks {.inline.} = + result = Ticks(mach_absolute_time()) - var timeBaseInfo: TMachTimebaseInfoData + var timeBaseInfo: MachTimebaseInfoData mach_timebase_info(timeBaseInfo) - proc `-`(a, b: TTicks): TNanos = + proc `-`(a, b: Ticks): Nanos = result = (a.int64 - b.int64) * timeBaseInfo.numer div timeBaseInfo.denom elif defined(posixRealtime): type - TClockid {.importc: "clockid_t", header: "<time.h>", final.} = object + Clockid {.importc: "clockid_t", header: "<time.h>", final.} = object - TTimeSpec {.importc: "struct timespec", header: "<time.h>", + TimeSpec {.importc: "struct timespec", header: "<time.h>", final, pure.} = object ## struct timespec tv_sec: int ## Seconds. tv_nsec: int ## Nanoseconds. + {.deprecated: [TClockid: Clickid, TTimeSpec: TimeSpec].} var - CLOCK_REALTIME {.importc: "CLOCK_REALTIME", header: "<time.h>".}: TClockid + CLOCK_REALTIME {.importc: "CLOCK_REALTIME", header: "<time.h>".}: Clockid - proc clock_gettime(clkId: TClockid, tp: var TTimespec) {. + proc clock_gettime(clkId: Clockid, tp: var Timespec) {. importc: "clock_gettime", header: "<time.h>".} - proc getTicks(): TTicks = - var t: TTimespec + proc getTicks(): Ticks = + var t: Timespec clock_gettime(CLOCK_REALTIME, t) - result = TTicks(int64(t.tv_sec) * 1000000000'i64 + int64(t.tv_nsec)) + result = Ticks(int64(t.tv_sec) * 1000000000'i64 + int64(t.tv_nsec)) - proc `-`(a, b: TTicks): TNanos {.borrow.} + proc `-`(a, b: Ticks): Nanos {.borrow.} else: # fallback Posix implementation: type - Ttimeval {.importc: "struct timeval", header: "<sys/select.h>", + Timeval {.importc: "struct timeval", header: "<sys/select.h>", final, pure.} = object ## struct timeval tv_sec: int ## Seconds. tv_usec: int ## Microseconds. - - proc posix_gettimeofday(tp: var Ttimeval, unused: pointer = nil) {. + {.deprecated: [Ttimeval: Timeval].} + proc posix_gettimeofday(tp: var Timeval, unused: pointer = nil) {. importc: "gettimeofday", header: "<sys/time.h>".} - proc getTicks(): TTicks = - var t: Ttimeval + proc getTicks(): Ticks = + var t: Timeval posix_gettimeofday(t) - result = TTicks(int64(t.tv_sec) * 1000_000_000'i64 + + result = Ticks(int64(t.tv_sec) * 1000_000_000'i64 + int64(t.tv_usec) * 1000'i64) - proc `-`(a, b: TTicks): TNanos {.borrow.} + proc `-`(a, b: Ticks): Nanos {.borrow.} diff --git a/lib/system/widestrs.nim b/lib/system/widestrs.nim index 1e8bc6791..e7b7f3972 100644 --- a/lib/system/widestrs.nim +++ b/lib/system/widestrs.nim @@ -14,8 +14,9 @@ when not declared(NimString): {.error: "You must not import this module explicitly".} type - TUtf16Char* = distinct int16 - WideCString* = ref array[0.. 1_000_000, TUtf16Char] + Utf16Char* = distinct int16 + WideCString* = ref array[0.. 1_000_000, Utf16Char] +{.deprecated: [TUtf16Char: Utf16Char].} proc len*(w: WideCString): int = ## returns the length of a widestring. This traverses the whole string to @@ -23,7 +24,7 @@ proc len*(w: WideCString): int = while int16(w[result]) != 0'i16: inc result const - UNI_REPLACEMENT_CHAR = TUtf16Char(0xFFFD'i16) + UNI_REPLACEMENT_CHAR = Utf16Char(0xFFFD'i16) UNI_MAX_BMP = 0x0000FFFF UNI_MAX_UTF16 = 0x0010FFFF UNI_MAX_UTF32 = 0x7FFFFFFF @@ -89,16 +90,16 @@ proc newWideCString*(source: cstring, L: int): WideCString = if ch >=% UNI_SUR_HIGH_START and ch <=% UNI_SUR_LOW_END: result[d] = UNI_REPLACEMENT_CHAR else: - result[d] = TUtf16Char(toU16(ch)) + result[d] = Utf16Char(toU16(ch)) elif ch >% UNI_MAX_UTF16: result[d] = UNI_REPLACEMENT_CHAR else: let ch = ch -% halfBase - result[d] = TUtf16Char(toU16((ch shr halfShift) +% UNI_SUR_HIGH_START)) + result[d] = Utf16Char(toU16((ch shr halfShift) +% UNI_SUR_HIGH_START)) inc d - result[d] = TUtf16Char(toU16((ch and halfMask) +% UNI_SUR_LOW_START)) + result[d] = Utf16Char(toU16((ch and halfMask) +% UNI_SUR_LOW_START)) inc d - result[d] = TUtf16Char(0'i16) + result[d] = Utf16Char(0'i16) proc newWideCString*(s: cstring): WideCString = if s.isNil: return nil diff --git a/lib/windows/mmsystem.nim b/lib/windows/mmsystem.nim index 45613d8e2..9bc6a873f 100644 --- a/lib/windows/mmsystem.nim +++ b/lib/windows/mmsystem.nim @@ -29,12 +29,12 @@ import type MMRESULT* = uint32 MMVERSION* = uint32 - HWAVEOUT* = THandle + HWAVEOUT* = Handle LPHWAVEOUT* = ptr HWAVEOUT - HWAVEIN* = THandle + HWAVEIN* = Handle LPHWAVEIN* = ptr HWAVEOUT - HWAVE* = THandle - LPHWAVE* = ptr THandle + HWAVE* = Handle + LPHWAVE* = ptr Handle LPUINT* = ptr uint32 const @@ -151,7 +151,7 @@ const CALLBACK_FUNCTION* = 0x00030000 type - HDRVR* = THandle + HDRVR* = Handle const DRV_LOAD* = 1 @@ -178,7 +178,7 @@ const DRV_MCI_LAST* = (DRV_RESERVED + 0x00000FFF) type - PDRVCALLBACK* = proc (hdrvr: THandle, uMsg: uint32, dwUser, dw1, dw2: DWORD){. + PDRVCALLBACK* = proc (hdrvr: Handle, uMsg: uint32, dwUser, dw1, dw2: DWORD){. stdcall.} proc sndPlaySoundA*(Name: LPCSTR, flags: uint32): bool{.stdcall, @@ -991,7 +991,6 @@ type NPMMTIME* = ptr MMTIME LPMMTIME* = ptr MMTIME PWAVEHDR* = ptr WAVEHDR - TMMTime* = MMTIME WAVEHDR* {.final.} = object lpData*: cstring dwBufferLength*: DWORD @@ -1002,7 +1001,6 @@ type lpNext*: PWAVEHDR reserved*: DWORD - TWAVEHDR* = WAVEHDR NPWAVEHDR* = ptr WAVEHDR LPWAVEHDR* = ptr WAVEHDR WAVEOUTCAPSA* {.final.} = object @@ -1015,7 +1013,6 @@ type wReserved1*: int16 dwSupport*: DWORD - TWAVEOUTCAPSA* = WAVEOUTCAPSA PWAVEOUTCAPSA* = ptr WAVEOUTCAPSA NPWAVEOUTCAPSA* = ptr WAVEOUTCAPSA LPWAVEOUTCAPSA* = ptr WAVEOUTCAPSA @@ -1032,7 +1029,8 @@ type PWAVEOUTCAPSW* = ptr WAVEOUTCAPSW NPWAVEOUTCAPSW* = ptr WAVEOUTCAPSW LPWAVEOUTCAPSW* = ptr WAVEOUTCAPSW - TWAVEOUTCAPSW* = WAVEOUTCAPSW +{.deprecated: [Twavehdr: Wavehdr, Tmmtime: Mmtime, Twaveoutcapsa: Waveoutcapsa, + Twaveoutcapsw: Waveoutcapsw].} when defined(UNICODE): type @@ -1127,10 +1125,10 @@ type LPWAVEFORMATEX* = ptr WAVEFORMATEX LPCWAVEFORMATEX* = ptr WAVEFORMATEX TWAVEFORMATEX* = WAVEFORMATEX - HMIDI* = THandle - HMIDIIN* = THandle - HMIDIOUT* = THandle - HMIDISTRM* = THandle + HMIDI* = Handle + HMIDIIN* = Handle + HMIDIOUT* = Handle + HMIDISTRM* = Handle LPHMIDI* = ptr HMIDI LPHMIDIIN* = ptr HMIDIIN LPHMIDIOUT* = ptr HMIDIOUT @@ -1299,9 +1297,9 @@ else: LPAUXCAPS* = LPAUXCAPSA type TAUXCAPS* = AUXCAPS - HMIXEROBJ* = THandle + HMIXEROBJ* = Handle LPHMIXEROBJ* = ptr HMIXEROBJ - HMIXER* = THandle + HMIXER* = Handle LPHMIXER* = ptr HMIXER proc mixerGetNumDevs*(): uint32{.stdcall, dynlib: "winmm.dll", @@ -1647,7 +1645,7 @@ type TJOYINFOEX* = JOYINFOEX FOURCC* = DWORD HPSTR* = cstring - HMMIO* = THandle + HMMIO* = Handle LPMMIOPROC* = proc (x1: LPSTR, x2: uint32, x3, x4: LPARAM): LRESULT{.stdcall.} TMMIOPROC* = LPMMIOPROC MMIOINFO* {.final.} = object @@ -2096,14 +2094,14 @@ else: type MCI_ANIM_RECT_PARMS* {.final.} = object dwCallback*: DWORD - rc*: TRECT + rc*: RECT PMCI_ANIM_RECT_PARMS* = ptr MCI_ANIM_RECT_PARMS LPMCI_ANIM_RECT_PARMS* = ptr MCI_ANIM_RECT_PARMS TMCI_ANIM_RECT_PARMS* = MCI_ANIM_RECT_PARMS MCI_ANIM_UPDATE_PARMS* {.final.} = object dwCallback*: DWORD - rc*: TRECT + rc*: RECT hDC*: HDC PMCI_ANIM_UPDATE_PARMS* = ptr MCI_ANIM_UPDATE_PARMS @@ -2179,7 +2177,7 @@ type TMCI_OVLY_WINDOW_PARMS* = MCI_OVLY_WINDOW_PARMSW MCI_OVLY_RECT_PARMS* {.final.} = object dwCallback*: DWORD - rc*: TRECT + rc*: RECT PMCI_OVLY_RECT_PARMS* = ptr MCI_OVLY_RECT_PARMS LPMCI_OVLY_RECT_PARMS* = ptr MCI_OVLY_RECT_PARMS @@ -2187,7 +2185,7 @@ type MCI_OVLY_SAVE_PARMSA* {.final.} = object dwCallback*: DWORD lpfilename*: LPCSTR - rc*: TRECT + rc*: RECT PMCI_OVLY_SAVE_PARMSA* = ptr MCI_OVLY_SAVE_PARMSA LPMCI_OVLY_SAVE_PARMSA* = ptr MCI_OVLY_SAVE_PARMSA @@ -2195,7 +2193,7 @@ type MCI_OVLY_SAVE_PARMSW* {.final.} = object dwCallback*: DWORD lpfilename*: LPCWSTR - rc*: TRECT + rc*: RECT PMCI_OVLY_SAVE_PARMSW* = ptr MCI_OVLY_SAVE_PARMSW LPMCI_OVLY_SAVE_PARMSW* = ptr MCI_OVLY_SAVE_PARMSW @@ -2216,7 +2214,7 @@ type MCI_OVLY_LOAD_PARMSA* {.final.} = object dwCallback*: DWORD lpfilename*: LPCSTR - rc*: TRECT + rc*: RECT PMCI_OVLY_LOAD_PARMSA* = ptr MCI_OVLY_LOAD_PARMSA LPMCI_OVLY_LOAD_PARMSA* = ptr MCI_OVLY_LOAD_PARMSA @@ -2224,7 +2222,7 @@ type MCI_OVLY_LOAD_PARMSW* {.final.} = object dwCallback*: DWORD lpfilename*: LPCWSTR - rc*: TRECT + rc*: RECT PMCI_OVLY_LOAD_PARMSW* = ptr MCI_OVLY_LOAD_PARMSW LPMCI_OVLY_LOAD_PARMSW* = ptr MCI_OVLY_LOAD_PARMSW diff --git a/lib/windows/nb30.nim b/lib/windows/nb30.nim index 2e0c679ae..820e0b7a3 100644 --- a/lib/windows/nb30.nim +++ b/lib/windows/nb30.nim @@ -20,9 +20,9 @@ const MAX_LANA* = 254 # lana's in range 0 to MAX_LANA inclusive type # Network Control Block - PNCB* = ptr TNCB - TNCBPostProc* = proc (P: PNCB) {.stdcall.} - TNCB* {.final.} = object # Structure returned to the NCB command NCBASTAT is ADAPTER_STATUS followed + PNCB* = ptr NCB + NCBPostProc* = proc (P: PNCB) {.stdcall.} + NCB* {.final.} = object # Structure returned to the NCB command NCBASTAT is ADAPTER_STATUS followed # by an array of NAME_BUFFER structures. ncb_command*: char # command code ncb_retcode*: char # return code @@ -34,17 +34,17 @@ type # Network Control Block ncb_name*: array[0..NCBNAMSZ - 1, char] # our blank-padded netname ncb_rto*: char # rcv timeout/retry count ncb_sto*: char # send timeout/sys timeout - ncb_post*: TNCBPostProc # POST routine address + ncb_post*: NCBPostProc # POST routine address ncb_lana_num*: char # lana (adapter) number ncb_cmd_cplt*: char # 0xff => commmand pending ncb_reserve*: array[0..9, char] # reserved, used by BIOS - ncb_event*: THandle # HANDLE to Win32 event which + ncb_event*: Handle # HANDLE to Win32 event which # will be set to the signalled # state when an ASYNCH command # completes - PAdapterStatus* = ptr TAdapterStatus - TAdapterStatus* {.final.} = object + PAdapterStatus* = ptr AdapterStatus + AdapterStatus* {.final.} = object adapter_address*: array[0..5, char] rev_major*: char reserved0*: char @@ -73,11 +73,13 @@ type # Network Control Block max_sess_pkt_size*: int16 name_count*: int16 - PNameBuffer* = ptr TNameBuffer - TNameBuffer* {.final.} = object + PNameBuffer* = ptr NameBuffer + NameBuffer* {.final.} = object name*: array[0..NCBNAMSZ - 1, char] name_num*: char name_flags*: char +{.deprecated: [TNCB: NCB, TNCBPostProc: NCBPostProc, + TAdapterStatus: AdapterStatus, TNameBuffer: NameBuffer].} const # values for name_flags bits. @@ -94,21 +96,22 @@ type # Structure returned to the NCB command NCBSSTAT is SESSION_HEADER followed # by an array of SESSION_BUFFER structures. If the NCB_NAME starts with an # asterisk then an array of these structures is returned containing the # status for all names. - PSessionHeader* = ptr TSessionHeader - TSessionHeader* {.final.} = object + PSessionHeader* = ptr SessionHeader + SessionHeader* {.final.} = object sess_name*: char num_sess*: char rcv_dg_outstanding*: char rcv_any_outstanding*: char - PSessionBuffer* = ptr TSessionBuffer - TSessionBuffer* {.final.} = object + PSessionBuffer* = ptr SessionBuffer + SessionBuffer* {.final.} = object lsn*: char state*: char local_name*: array[0..NCBNAMSZ - 1, char] remote_name*: array[0..NCBNAMSZ - 1, char] rcvs_outstanding*: char sends_outstanding*: char +{.deprecated: [TSessionHeader: SessionHeader, TSessionBuffer: SessionBuffer].} const # Values for state @@ -128,14 +131,14 @@ type # Structure returned to the NCB command NCBENUM. len*: char # Number of valid entries in lana[] lana*: array[0..MAX_LANA, char] - PFindNameHeader* = ptr TFindNameHeader - TFindNameHeader* {.final.} = object + PFindNameHeader* = ptr FindNameHeader + FindNameHeader* {.final.} = object node_count*: int16 reserved*: char unique_group*: char - PFindNameBuffer* = ptr TFindNameBuffer - TFindNameBuffer* {.final.} = object # Structure provided with NCBACTION. The purpose of NCBACTION is to provide + PFindNameBuffer* = ptr FindNameBuffer + FindNameBuffer* {.final.} = object # Structure provided with NCBACTION. The purpose of NCBACTION is to provide # transport specific extensions to netbios. len*: char access_control*: char @@ -144,12 +147,13 @@ type # Structure returned to the NCB command NCBENUM. source_addr*: array[0..5, char] routing_info*: array[0..17, char] - PActionHeader* = ptr TActionHeader - TActionHeader* {.final.} = object + PActionHeader* = ptr ActionHeader + ActionHeader* {.final.} = object transport_id*: int32 action_code*: int16 reserved*: int16 - +{.deprecated: [TFindNameHeader: FindNameHeader, TFindNameBuffer: FindNameBuffer, + TActionHeader: ActionHeader].} const # Values for transport_id ALL_TRANSPORTS* = "M\0\0\0" diff --git a/lib/windows/shellapi.nim b/lib/windows/shellapi.nim index 079257680..0f8bc5ea3 100644 --- a/lib/windows/shellapi.nim +++ b/lib/windows/shellapi.nim @@ -31,7 +31,7 @@ import windows type - HDROP* = THandle + HDROP* = Handle UINT_PTR* = ptr uint32 DWORD_PTR* = ptr DWORD PHICON* = ptr HICON @@ -57,8 +57,8 @@ type hStdError*: HANDLE LPSTARTUPINFOW* = ptr STARTUPINFOW - TSTARTUPINFOW* = STARTUPINFOW PSTARTUPINFOW* = ptr STARTUPINFOW #unicode +{.deprecated: [TSTARTUPINFOW: STARTUPINFOW].} proc DragQueryFileA*(arg1: HDROP, arg2: uint32, arg3: LPSTR, arg4: uint32): uint32{. stdcall, dynlib: "shell32.dll", importc: "DragQueryFileA".} @@ -132,7 +132,6 @@ type # init with sizeof(DRAGINFO) lpFileList*: LPSTR grfKeyState*: DWORD - TDRAGINFOA* = DRAGINFOA LPDRAGINFOA* = ptr DRAGINFOA # init with sizeof(DRAGINFO) DRAGINFOW* {.final.} = object uSize*: uint32 @@ -141,19 +140,19 @@ type # init with sizeof(DRAGINFO) lpFileList*: LPWSTR grfKeyState*: DWORD - TDRAGINFOW* = DRAGINFOW LPDRAGINFOW* = ptr DRAGINFOW +{.deprecated: [TDRAGINFOA: DRAGINFOA, TDRAGINFOW: DRAGINFOW].} when defined(UNICODE): type DRAGINFO* = DRAGINFOW - TDRAGINFO* = DRAGINFOW LPDRAGINFO* = LPDRAGINFOW + {.deprecated: [TDRAGINFO: DRAGINFOW].} else: type DRAGINFO* = DRAGINFOA - TDRAGINFO* = DRAGINFOW LPDRAGINFO* = LPDRAGINFOA + {.deprecated: [TDRAGINFO: DRAGINFOW].} const ABM_NEW* = 0x00000000 ABM_REMOVE* = 0x00000001 @@ -189,8 +188,8 @@ type rc*: RECT lParam*: LPARAM # message specific - TAPPBARDATA* = AppBarData PAPPBARDATA* = ptr AppBarData +{.deprecated: [TAPPBARDATA: AppBarData].} proc SHAppBarMessage*(dwMessage: DWORD, pData: APPBARDATA): UINT_PTR{.stdcall, dynlib: "shell32.dll", importc: "SHAppBarMessage".} @@ -299,7 +298,6 @@ type hNameMappings*: LPVOID lpszProgressTitle*: LPCSTR # only used if FOF_SIMPLEPROGRESS - TSHFILEOPSTRUCTA* = SHFILEOPSTRUCTA LPSHFILEOPSTRUCTA* = ptr SHFILEOPSTRUCTA SHFILEOPSTRUCTW* {.final.} = object hwnd*: HWND @@ -311,19 +309,21 @@ type hNameMappings*: LPVOID lpszProgressTitle*: LPCWSTR - TSHFILEOPSTRUCTW* = SHFILEOPSTRUCTW LPSHFILEOPSTRUCTW* = ptr SHFILEOPSTRUCTW +{.deprecated: [TSHFILEOPSTRUCTA: SHFILEOPSTRUCTA, + TSHFILEOPSTRUCTW: SHFILEOPSTRUCTW].} when defined(UNICODE): type SHFILEOPSTRUCT* = SHFILEOPSTRUCTW - TSHFILEOPSTRUCT* = SHFILEOPSTRUCTW LPSHFILEOPSTRUCT* = LPSHFILEOPSTRUCTW + {.deprecated: [TSHFILEOPSTRUCT: SHFILEOPSTRUCTW].} else: type SHFILEOPSTRUCT* = SHFILEOPSTRUCTA - TSHFILEOPSTRUCT* = SHFILEOPSTRUCTA LPSHFILEOPSTRUCT* = LPSHFILEOPSTRUCTA + {.deprecated: [TSHFILEOPSTRUCT: SHFILEOPSTRUCTA].} + proc SHFileOperationA*(lpFileOp: LPSHFILEOPSTRUCTA): int32{.stdcall, dynlib: "shell32.dll", importc: "SHFileOperationA".} proc SHFileOperationW*(lpFileOp: LPSHFILEOPSTRUCTW): int32{.stdcall, @@ -332,7 +332,7 @@ proc SHFileOperation*(lpFileOp: LPSHFILEOPSTRUCTA): int32{.stdcall, dynlib: "shell32.dll", importc: "SHFileOperationA".} proc SHFileOperation*(lpFileOp: LPSHFILEOPSTRUCTW): int32{.stdcall, dynlib: "shell32.dll", importc: "SHFileOperationW".} -proc SHFreeNameMappings*(hNameMappings: THandle){.stdcall, +proc SHFreeNameMappings*(hNameMappings: Handle){.stdcall, dynlib: "shell32.dll", importc: "SHFreeNameMappings".} type SHNAMEMAPPINGA* {.final.} = object @@ -341,7 +341,6 @@ type cchOldPath*: int32 cchNewPath*: int32 - TSHNAMEMAPPINGA* = SHNAMEMAPPINGA LPSHNAMEMAPPINGA* = ptr SHNAMEMAPPINGA SHNAMEMAPPINGW* {.final.} = object pszOldPath*: LPWSTR @@ -349,19 +348,20 @@ type cchOldPath*: int32 cchNewPath*: int32 - TSHNAMEMAPPINGW* = SHNAMEMAPPINGW LPSHNAMEMAPPINGW* = ptr SHNAMEMAPPINGW +{.deprecated: [TSHNAMEMAPPINGA: SHNAMEMAPPINGA, + TSHNAMEMAPPINGW: SHNAMEMAPPINGW].} when not(defined(UNICODE)): type SHNAMEMAPPING* = SHNAMEMAPPINGW - TSHNAMEMAPPING* = SHNAMEMAPPINGW LPSHNAMEMAPPING* = LPSHNAMEMAPPINGW + {.deprecated: [TSHNAMEMAPPING: SHNAMEMAPPINGW].} else: type SHNAMEMAPPING* = SHNAMEMAPPINGA - TSHNAMEMAPPING* = SHNAMEMAPPINGA LPSHNAMEMAPPING* = LPSHNAMEMAPPINGA + {.deprecated: [TSHNAMEMAPPING: SHNAMEMAPPINGA].} # # End Shell File Operations # @@ -424,7 +424,6 @@ type hMonitor*: HANDLE # also: hIcon hProcess*: HANDLE - TSHELLEXECUTEINFOA* = SHELLEXECUTEINFOA LPSHELLEXECUTEINFOA* = ptr SHELLEXECUTEINFOA SHELLEXECUTEINFOW* {.final.} = object cbSize*: DWORD @@ -443,19 +442,21 @@ type hMonitor*: HANDLE # also: hIcon hProcess*: HANDLE - TSHELLEXECUTEINFOW* = SHELLEXECUTEINFOW LPSHELLEXECUTEINFOW* = ptr SHELLEXECUTEINFOW +{.deprecated: [TSHELLEXECUTEINFOA: SHELLEXECUTEINFOA, + TSHELLEXECUTEINFOW: SHELLEXECUTEINFOW].} when defined(UNICODE): type SHELLEXECUTEINFO* = SHELLEXECUTEINFOW - TSHELLEXECUTEINFO* = SHELLEXECUTEINFOW LPSHELLEXECUTEINFO* = LPSHELLEXECUTEINFOW + {.deprecated: [TSHELLEXECUTEINFO: SHELLEXECUTEINFOW].} else: type SHELLEXECUTEINFO* = SHELLEXECUTEINFOA - TSHELLEXECUTEINFO* = SHELLEXECUTEINFOA LPSHELLEXECUTEINFO* = LPSHELLEXECUTEINFOA + {.deprecated: [TSHELLEXECUTEINFO: SHELLEXECUTEINFOA].} + proc ShellExecuteExA*(lpExecInfo: LPSHELLEXECUTEINFOA): bool{.stdcall, dynlib: "shell32.dll", importc: "ShellExecuteExA".} proc ShellExecuteExW*(lpExecInfo: LPSHELLEXECUTEINFOW): bool{.stdcall, @@ -492,8 +493,8 @@ type lpStartupInfo*: LPSTARTUPINFOW lpProcessInformation*: LPPROCESS_INFORMATION - TSHCREATEPROCESSINFOW* = SHCREATEPROCESSINFOW PSHCREATEPROCESSINFOW* = ptr SHCREATEPROCESSINFOW +{.deprecated: [TSHCREATEPROCESSINFOW: SHCREATEPROCESSINFOW].} proc SHCreateProcessAsUserW*(pscpi: PSHCREATEPROCESSINFOW): bool{.stdcall, dynlib: "shell32.dll", importc: "SHCreateProcessAsUserW".} @@ -510,8 +511,8 @@ type i64Size*: int64 i64NumItems*: int64 - TSHQUERYRBINFO* = SHQUERYRBINFO LPSHQUERYRBINFO* = ptr SHQUERYRBINFO # flags for SHEmptyRecycleBin +{.deprecated: [TSHQUERYRBINFO: SHQUERYRBINFO].} const SHERB_NOCONFIRMATION* = 0x00000001 @@ -555,9 +556,8 @@ type uTimeout*: uint32 # also: uVersion szInfoTitle*: array[0..63, char] dwInfoFlags*: DWORD - guidItem*: TGUID + guidItem*: GUID - TNOTIFYICONDATAA* = NOTIFYICONDATAA PNOTIFYICONDATAA* = ptr NOTIFYICONDATAA NOTIFYICONDATAW* {.final.} = object cbSize*: DWORD @@ -573,21 +573,22 @@ type uTimeout*: uint32 # also uVersion : UINT szInfoTitle*: array[0..63, char] dwInfoFlags*: DWORD - guidItem*: TGUID + guidItem*: GUID - TNOTIFYICONDATAW* = NOTIFYICONDATAW PNOTIFYICONDATAW* = ptr NOTIFYICONDATAW +{.deprecated: [TNOTIFYICONDATAA: NOTIFYICONDATAA, + TNOTIFYICONDATAW: NOTIFYICONDATAW].} when defined(UNICODE): type NOTIFYICONDATA* = NOTIFYICONDATAW - TNOTIFYICONDATA* = NOTIFYICONDATAW PNOTIFYICONDATA* = PNOTIFYICONDATAW + {.deprecated: [TNOTIFYICONDATA: NOTIFYICONDATAW].} else: type NOTIFYICONDATA* = NOTIFYICONDATAA - TNOTIFYICONDATA* = NOTIFYICONDATAA PNOTIFYICONDATA* = PNOTIFYICONDATAA + {.deprecated: [TNOTIFYICONDATA: NOTIFYICONDATAA].} const NIN_SELECT* = WM_USER + 0 NINF_KEY* = 0x00000001 @@ -655,7 +656,6 @@ type szDisplayName*: array[0..(MAX_PATH) - 1, char] # out: display name (or path) szTypeName*: array[0..79, char] # out: type name - TSHFILEINFOA* = SHFILEINFOA PSHFILEINFOA* = ptr SHFILEINFOA SHFILEINFOW* {.final.} = object hIcon*: HICON # out: icon @@ -664,19 +664,19 @@ type szDisplayName*: array[0..(MAX_PATH) - 1, Wchar] # out: display name (or path) szTypeName*: array[0..79, Wchar] # out: type name - TSHFILEINFOW* = SHFILEINFOW PSHFILEINFOW* = ptr SHFILEINFOW +{.deprecated: [TSHFILEINFOA: SHFILEINFOA, TSHFILEINFOW: SHFILEINFOW].} when defined(UNICODE): type SHFILEINFO* = SHFILEINFOW - TSHFILEINFO* = SHFILEINFOW pFILEINFO* = SHFILEINFOW + {.deprecated: [TSHFILEINFO: SHFILEINFOW].} else: type SHFILEINFO* = SHFILEINFOA - TSHFILEINFO* = SHFILEINFOA pFILEINFO* = SHFILEINFOA + {.deprecated: [TSHFILEINFO: SHFILEINFOA].} # NOTE: This is also in shlwapi.h. Please keep in synch. const @@ -710,16 +710,16 @@ proc SHGetFileInfo*(pszPath: LPCSTR, dwFileAttributes: DWORD, psfi: PSHFILEINFOA, cbFileInfo, UFlags: uint32): DWORD{. stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoA".} proc SHGetFileInfoA*(pszPath: LPCSTR, dwFileAttributes: DWORD, - psfi: var TSHFILEINFOA, cbFileInfo, UFlags: uint32): DWORD{. + psfi: var SHFILEINFOA, cbFileInfo, UFlags: uint32): DWORD{. stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoA".} proc SHGetFileInfoW*(pszPath: LPCWSTR, dwFileAttributes: DWORD, - psfi: var TSHFILEINFOW, cbFileInfo, UFlags: uint32): DWORD{. + psfi: var SHFILEINFOW, cbFileInfo, UFlags: uint32): DWORD{. stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoW".} proc SHGetFileInfo*(pszPath: LPCSTR, dwFileAttributes: DWORD, - psfi: var TSHFILEINFOA, cbFileInfo, UFlags: uint32): DWORD{. + psfi: var SHFILEINFOA, cbFileInfo, UFlags: uint32): DWORD{. stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoA".} proc SHGetFileInfo*(pszPath: LPCWSTR, dwFileAttributes: DWORD, - psfi: var TSHFILEINFOW, cbFileInfo, UFlags: uint32): DWORD{. + psfi: var SHFILEINFOW, cbFileInfo, UFlags: uint32): DWORD{. stdcall, dynlib: "shell32.dll", importc: "SHGetFileInfoW".} proc SHGetDiskFreeSpaceExA*(pszDirectoryName: LPCSTR, pulFreeBytesAvailableToCaller: PULARGE_INTEGER, diff --git a/lib/windows/shfolder.nim b/lib/windows/shfolder.nim index 886d757eb..99cdf6cf5 100644 --- a/lib/windows/shfolder.nim +++ b/lib/windows/shfolder.nim @@ -72,22 +72,22 @@ const CSIDL_FLAG_CREATE* = 0x00008000 # (force creation of requested folder if it doesn't exist yet) # Original entry points -proc SHGetFolderPathA*(Ahwnd: HWND, Csidl: int, Token: THandle, Flags: DWord, +proc SHGetFolderPathA*(Ahwnd: HWND, Csidl: int, Token: Handle, Flags: DWord, Path: cstring): HRESULT{.stdcall, dynlib: LibName, importc: "SHGetFolderPathA".} -proc SHGetFolderPathW*(Ahwnd: HWND, Csidl: int, Token: THandle, Flags: DWord, +proc SHGetFolderPathW*(Ahwnd: HWND, Csidl: int, Token: Handle, Flags: DWord, Path: cstring): HRESULT{.stdcall, dynlib: LibName, importc: "SHGetFolderPathW".} -proc SHGetFolderPath*(Ahwnd: HWND, Csidl: int, Token: THandle, Flags: DWord, +proc SHGetFolderPath*(Ahwnd: HWND, Csidl: int, Token: Handle, Flags: DWord, Path: cstring): HRESULT{.stdcall, dynlib: LibName, importc: "SHGetFolderPathA".} type - PFNSHGetFolderPathA* = proc (Ahwnd: HWND, Csidl: int, Token: THandle, + PFNSHGetFolderPathA* = proc (Ahwnd: HWND, Csidl: int, Token: Handle, Flags: DWord, Path: cstring): HRESULT{.stdcall.} - PFNSHGetFolderPathW* = proc (Ahwnd: HWND, Csidl: int, Token: THandle, + PFNSHGetFolderPathW* = proc (Ahwnd: HWND, Csidl: int, Token: Handle, Flags: DWord, Path: cstring): HRESULT{.stdcall.} PFNSHGetFolderPath* = PFNSHGetFolderPathA - TSHGetFolderPathA* = PFNSHGetFolderPathA - TSHGetFolderPathW* = PFNSHGetFolderPathW - TSHGetFolderPath* = TSHGetFolderPathA - + +{.deprecated: [TSHGetFolderPathA: PFNSHGetFolderPathA, + TSHGetFolderPathW: PFNSHGetFolderPathW, + TSHGetFolderPath: SHGetFolderPathA].} diff --git a/lib/windows/windows.nim b/lib/windows/windows.nim index b76dea6c5..bddb4cef7 100644 --- a/lib/windows/windows.nim +++ b/lib/windows/windows.nim @@ -98,9 +98,8 @@ type # WinDef.h -- Basic Windows Type Definitions LRESULT* = LONG_PTR ATOM* = int16 - TAtom* = ATOM HANDLE* = int - THandle* = HANDLE +# Handle* = HANDLE PHANDLE* = ptr HANDLE LPHANDLE* = ptr HANDLE HWND* = HANDLE @@ -150,11 +149,8 @@ type # WinDef.h -- Basic Windows Type Definitions y*: LONG PPOINTL* = ptr POINTL - TPOINT* = POINT - TPOINTL* = POINTL - RECT* {.final, pure.} = object - TopLeft*, BottomRight*: TPoint + TopLeft*, BottomRight*: Point PRECT* = ptr RECT LPRECT* = ptr RECT @@ -179,19 +175,14 @@ type # WinDef.h -- Basic Windows Type Definitions y*: SHORT PPOINTS* = ptr POINTS - TRECT* = RECT - TRECTL* = RECTL - TSIZE* = SIZE - TSIZEL* = SIZE - TPOINTS* = POINTS - FILETIME* {.final, pure.} = object dwLowDateTime*: DWORD dwHighDateTime*: DWORD PFILETIME* = ptr FILETIME LPFILETIME* = ptr FILETIME - - TFILETIME* = FILETIME +{.deprecated: [THandle: Handle, TAtom: ATOM, TFILETIME: FILETIME, TRECT: RECT, + TRECTL: RECTL, TSIZE: SIZE, TSIZEL: SIZE, TPOINTS: POINTS, + TPOINT: POINT, TPOINTL: POINTL].} const MAX_PATH* = 260 @@ -238,7 +229,6 @@ type CALTYPE* = int CALID* = int CCHAR* = char - TCOLORREF* = COLORREF WINT* = int32 PINTEGER* = ptr int32 PBOOL* = ptr WINBOOL @@ -269,6 +259,7 @@ type LCTYPE* = DWORD LP* = ptr int16 LPBOOL* = ptr WINBOOL +{.deprecated: [TCOLORREF: COLORREF].} when defined(winUnicode): type @@ -316,14 +307,16 @@ type when defined(winUnicode): type - TBYTE* = uint16 - TCHAR* = widechar + BYTE* = uint16 + CHAR* = widechar BCHAR* = int16 + {.deprecated: [TBYTE: BYTE, TCHAR: CHAR].} else: type - TBYTE* = uint8 - TCHAR* = char + BYTE* = uint8 + CHAR* = char BCHAR* = int8 + {.deprecated: [TBYTE: BYTE, TCHAR: CHAR].} type WCHAR* = WideChar PLPSTR* = ptr LPSTR @@ -367,7 +360,7 @@ type TokenUser = 1, TokenGroups, TokenPrivileges, TokenOwner, TokenPrimaryGroup, TokenDefaultDacl, TokenSource, TokenType, TokenImpersonationLevel, TokenStatistics - TTOKEN_TYPE* = enum + TTOKEN_TYPE* = enum # Name conflict if we drop the `T` TokenPrimary = 1, TokenImpersonation MakeIntResourceA* = cstring MakeIntResourceW* = PWideChar @@ -405,8 +398,7 @@ type WNDPROC* = proc (para1: HWND, para2: WINUINT, para3: WPARAM, para4: LPARAM): LRESULT{. stdcall.} FARPROC* = pointer - TFarProc* = FARPROC - TProc* = pointer + Proc* = pointer ENUMRESTYPEPROC* = proc (para1: HANDLE, para2: LPTSTR, para3: LONG): WINBOOL{. stdcall.} ENUMRESNAMEPROC* = proc (para1: HANDLE, para2: LPCTSTR, para3: LPTSTR, @@ -431,7 +423,7 @@ type stdcall.} ENUMOBJECTSPROC* = proc (para1: LPVOID, para2: LPARAM){.stdcall.} LINEDDAPROC* = proc (para1: int32, para2: int32, para3: LPARAM){.stdcall.} - TABORTPROC* = proc (para1: HDC, para2: int32): WINBOOL{.stdcall.} + ABORTPROC* = proc (para1: HDC, para2: int32): WINBOOL{.stdcall.} LPPAGEPAINTHOOK* = proc (para1: HWND, para2: WINUINT, para3: WPARAM, para4: LPARAM): WINUINT{.stdcall.} LPPAGESETUPHOOK* = proc (para1: HWND, para2: WINUINT, para3: WPARAM, @@ -454,6 +446,7 @@ type stdcall.} PFNPROCESSPOLICIES* = proc (para1: HWND, para2: LPCTSTR, para3: LPCTSTR, para4: LPCTSTR, para5: DWORD): WINBOOL{.stdcall.} +{.deprecated: [TFarProc: FARPROC, TProc: Proc, TABORTPROC: ABORTPROC].} const SE_CREATE_TOKEN_NAME* = "SeCreateTokenPrivilege" @@ -5385,9 +5378,10 @@ const # TV_INSERTSTRUCT structure type - TTREEITEM* {.final, pure.} = object - HTREEITEM* = ptr TTREEITEM - PTREEITEM* = ptr TTREEITEM + TREEITEM* {.final, pure.} = object + HTREEITEM* = ptr TREEITEM + PTREEITEM* = ptr TREEITEM +{.deprecated: [TTREEITEM: TREEITEM].} const TVI_ROOT* = cast[HTREEITEM](0xFFFF0000) @@ -6870,32 +6864,31 @@ type # va_list is just a dummy record # MvdV: Nevertheless it should be a pointer type, not a record va_list* = cstring - TABC* {.final, pure.} = object + ABC* {.final, pure.} = object abcA*: int32 abcB*: WINUINT abcC*: int32 - LPABC* = ptr TABC - PABC* = ptr TABC - TABCFLOAT* {.final, pure.} = object + LPABC* = ptr ABC + PABC* = ptr ABC + ABCFLOAT* {.final, pure.} = object abcfA*: float32 abcfB*: float32 abcfC*: float32 - LPABCFLOAT* = ptr TABCFLOAT - PABCFLOAT* = ptr TABCFLOAT + LPABCFLOAT* = ptr ABCFLOAT + PABCFLOAT* = ptr ABCFLOAT - TACCEL* {.final, pure.} = object + ACCEL* {.final, pure.} = object fVirt*: int8 key*: int16 cmd*: int16 - LPACCEL* = ptr TACCEL - PACCEL* = ptr TACCEL + LPACCEL* = ptr ACCEL + PACCEL* = ptr ACCEL ACE_HEADER* {.final, pure.} = object AceType*: int8 AceFlags*: int8 AceSize*: int16 - TACE_HEADER* = ACE_HEADER PACE_HEADER* = ptr ACE_HEADER ACCESS_MASK* = DWORD REGSAM* = ACCESS_MASK @@ -6904,20 +6897,17 @@ type Mask*: ACCESS_MASK SidStart*: DWORD - TACCESS_ALLOWED_ACE* = ACCESS_ALLOWED_ACE PACCESS_ALLOWED_ACE* = ptr ACCESS_ALLOWED_ACE ACCESS_DENIED_ACE* {.final, pure.} = object Header*: ACE_HEADER Mask*: ACCESS_MASK SidStart*: DWORD - TACCESS_DENIED_ACE* = ACCESS_DENIED_ACE ACCESSTIMEOUT* {.final, pure.} = object cbSize*: WINUINT dwFlags*: DWORD iTimeOutMSec*: DWORD - TACCESSTIMEOUT* = ACCESSTIMEOUT PACCESSTIMEOUT* = ptr ACCESSTIMEOUT ACL* {.final, pure.} = object AclRevision*: int8 @@ -6927,12 +6917,11 @@ type Sbz2*: int16 PACL* = ptr ACL - TACL* = ACL - TACL_REVISION_INFORMATION* {.final, pure.} = object + TACL_REVISION_INFORMATION* {.final, pure.} = object # Name conflit if we drop the `T` AclRevision*: DWORD PACLREVISIONINFORMATION* = ptr TACL_REVISION_INFORMATION - TACL_SIZE_INFORMATION* {.final, pure.} = object + TACL_SIZE_INFORMATION* {.final, pure.} = object # Name conflict if we drop the `T` AceCount*: DWORD AclBytesInUse*: DWORD AclBytesFree*: DWORD @@ -6942,7 +6931,6 @@ type action_code*: USHORT reserved*: USHORT - TACTIONHEADER* = ACTION_HEADER PACTIONHEADER* = ptr ACTION_HEADER ADAPTER_STATUS* {.final, pure.} = object adapter_address*: array[0..5, UCHAR] @@ -6973,20 +6961,17 @@ type max_sess_pkt_size*: int16 name_count*: int16 - TADAPTERSTATUS* = ADAPTER_STATUS PADAPTERSTATUS* = ptr ADAPTER_STATUS ADDJOB_INFO_1* {.final, pure.} = object Path*: LPTSTR JobId*: DWORD - TADDJOB_INFO_1* = ADDJOB_INFO_1 PADDJOB_INFO_1* = ptr ADDJOB_INFO_1 ANIMATIONINFO* {.final, pure.} = object cbSize*: WINUINT iMinAnimate*: int32 LPANIMATIONINFO* = ptr ANIMATIONINFO - TANIMATIONINFO* = ANIMATIONINFO PANIMATIONINFO* = ptr ANIMATIONINFO APPBARDATA* {.final, pure.} = object @@ -6997,7 +6982,6 @@ type rc*: RECT lParam*: LPARAM - TAppBarData* = APPBARDATA PAppBarData* = ptr APPBARDATA BITMAP* {.final, pure.} = object bmType*: LONG @@ -7011,7 +6995,6 @@ type PBITMAP* = ptr BITMAP NPBITMAP* = ptr BITMAP LPBITMAP* = ptr BITMAP - TBITMAP* = BITMAP BITMAPCOREHEADER* {.final, pure.} = object bcSize*: DWORD bcWidth*: int16 @@ -7019,14 +7002,12 @@ type bcPlanes*: int16 bcBitCount*: int16 - TBITMAPCOREHEADER* = BITMAPCOREHEADER PBITMAPCOREHEADER* = ptr BITMAPCOREHEADER RGBTRIPLE* {.final, pure.} = object rgbtBlue*: int8 rgbtGreen*: int8 rgbtRed*: int8 - TRGBTRIPLE* = RGBTRIPLE PRGBTRIPLE* = ptr RGBTRIPLE BITMAPCOREINFO* {.final, pure.} = object bmciHeader*: BITMAPCOREHEADER @@ -7034,7 +7015,7 @@ type PBITMAPCOREINFO* = ptr BITMAPCOREINFO LPBITMAPCOREINFO* = ptr BITMAPCOREINFO - TBITMAPCOREINFO* = BITMAPCOREINFO # error +# TBITMAPCOREINFO* = BITMAPCOREINFO # error # WORD bfReserved1; # WORD bfReserved2; # in declarator_list @@ -7052,7 +7033,6 @@ type biClrImportant*: DWORD LPBITMAPINFOHEADER* = ptr BITMAPINFOHEADER - TBITMAPINFOHEADER* = BITMAPINFOHEADER PBITMAPINFOHEADER* = ptr BITMAPINFOHEADER RGBQUAD* {.final, pure.} = object rgbBlue*: int8 @@ -7060,7 +7040,6 @@ type rgbRed*: int8 rgbReserved*: int8 - TRGBQUAD* = RGBQUAD PRGBQUAD* = ptr RGBQUAD BITMAPINFO* {.final, pure.} = object bmiHeader*: BITMAPINFOHEADER @@ -7068,7 +7047,6 @@ type LPBITMAPINFO* = ptr BITMAPINFO PBITMAPINFO* = ptr BITMAPINFO - TBITMAPINFO* = BITMAPINFO FXPT2DOT30* = int32 LPFXPT2DOT30* = ptr FXPT2DOT30 TPFXPT2DOT30* = FXPT2DOT30 @@ -7079,7 +7057,6 @@ type ciexyzZ*: FXPT2DOT30 LPCIEXYZ* = ptr CIEXYZ - TPCIEXYZ* = CIEXYZ PCIEXYZ* = ptr CIEXYZ CIEXYZTRIPLE* {.final, pure.} = object ciexyzRed*: CIEXYZ @@ -7087,7 +7064,6 @@ type ciexyzBlue*: CIEXYZ LPCIEXYZTRIPLE* = ptr CIEXYZTRIPLE - TCIEXYZTRIPLE* = CIEXYZTRIPLE PCIEXYZTRIPLE* = ptr CIEXYZTRIPLE BITMAPV4HEADER* {.final, pure.} = object bV4Size*: DWORD @@ -7112,7 +7088,6 @@ type bV4GammaBlue*: DWORD LPBITMAPV4HEADER* = ptr BITMAPV4HEADER - TBITMAPV4HEADER* = BITMAPV4HEADER PBITMAPV4HEADER* = ptr BITMAPV4HEADER BITMAPFILEHEADER* {.final, pure.} = object bfType*: int16 @@ -7125,7 +7100,6 @@ type cbSize*: ULONG pBlobData*: ptr int8 - TBLOB* = BLOB PBLOB* = ptr BLOB SHITEMID* {.final, pure.} = object cb*: USHORT @@ -7133,14 +7107,12 @@ type LPSHITEMID* = ptr SHITEMID LPCSHITEMID* = ptr SHITEMID - TSHITEMID* = SHITEMID PSHITEMID* = ptr SHITEMID ITEMIDLIST* {.final, pure.} = object mkid*: SHITEMID LPITEMIDLIST* = ptr ITEMIDLIST LPCITEMIDLIST* = ptr ITEMIDLIST - TITEMIDLIST* = ITEMIDLIST PITEMIDLIST* = ptr ITEMIDLIST BROWSEINFO* {.final, pure.} = object hwndOwner*: HWND @@ -7153,7 +7125,6 @@ type iImage*: int32 LPBROWSEINFO* = ptr BROWSEINFO - Tbrowseinfo* = BROWSEINFO PBROWSEINFO* = ptr BROWSEINFO BY_HANDLE_FILE_INFORMATION* {.final, pure.} = object @@ -7169,22 +7140,19 @@ type nFileIndexLow*: DWORD LPBY_HANDLE_FILE_INFORMATION* = ptr BY_HANDLE_FILE_INFORMATION - TBYHANDLEFILEINFORMATION* = BY_HANDLE_FILE_INFORMATION PBYHANDLEFILEINFORMATION* = ptr BY_HANDLE_FILE_INFORMATION FIXED* {.final, pure.} = object fract*: int16 value*: SHORT - TFIXED* = FIXED PFIXED* = ptr FIXED POINTFX* {.final, pure.} = object x*: FIXED y*: FIXED - TPOINTFX* = POINTFX PPOINTFX* = ptr POINTFX - TSmallPoint* {.final, pure.} = object + SmallPoint* {.final, pure.} = object X*, Y*: SHORT CANDIDATEFORM* {.final, pure.} = object @@ -7194,7 +7162,6 @@ type rcArea*: RECT LPCANDIDATEFORM* = ptr CANDIDATEFORM - TCANDIDATEFORM* = CANDIDATEFORM PCANDIDATEFORM* = ptr CANDIDATEFORM CANDIDATELIST* {.final, pure.} = object dwSize*: DWORD @@ -7206,7 +7173,6 @@ type dwOffset*: array[0..0, DWORD] LPCANDIDATELIST* = ptr CANDIDATELIST - TCANDIDATELIST* = CANDIDATELIST PCANDIDATELIST* = ptr CANDIDATELIST CREATESTRUCT* {.final, pure.} = object lpCreateParams*: LPVOID @@ -7223,25 +7189,21 @@ type dwExStyle*: DWORD LPCREATESTRUCT* = ptr CREATESTRUCT - TCREATESTRUCT* = CREATESTRUCT PCREATESTRUCT* = ptr CREATESTRUCT CBT_CREATEWND* {.final, pure.} = object lpcs*: LPCREATESTRUCT hwndInsertAfter*: HWND - TCBT_CREATEWND* = CBT_CREATEWND PCBT_CREATEWND* = ptr CBT_CREATEWND CBTACTIVATESTRUCT* {.final, pure.} = object fMouse*: WINBOOL hWndActive*: HWND - TCBTACTIVATESTRUCT* = CBTACTIVATESTRUCT PCBTACTIVATESTRUCT* = ptr CBTACTIVATESTRUCT CHAR_INFO* {.final, pure.} = object UnicodeChar*: WCHAR Attributes*: int16 # other union part: AsciiChar : CHAR - TCHAR_INFO* = CHAR_INFO PCHAR_INFO* = ptr CHAR_INFO CHARFORMAT* {.final, pure.} = object cbSize*: WINUINT @@ -7252,28 +7214,24 @@ type crTextColor*: COLORREF bCharSet*: int8 bPitchAndFamily*: int8 - szFaceName*: array[0..(LF_FACESIZE) - 1, TCHAR] + szFaceName*: array[0..(LF_FACESIZE) - 1, CHAR] - Tcharformat* = CHARFORMAT Pcharformat* = ptr CHARFORMAT CHARRANGE* {.final, pure.} = object cpMin*: LONG cpMax*: LONG - Tcharrange* = CHARRANGE Pcharrange* = ptr CHARRANGE CHARSET* {.final, pure.} = object aflBlock*: array[0..2, DWORD] flLang*: DWORD - TCHARSET* = CHARSET PCHARSET* = ptr CHARSET FONTSIGNATURE* {.final, pure.} = object fsUsb*: array[0..3, DWORD] fsCsb*: array[0..1, DWORD] LPFONTSIGNATURE* = ptr FONTSIGNATURE - TFONTSIGNATURE* = FONTSIGNATURE PFONTSIGNATURE* = ptr FONTSIGNATURE CHARSETINFO* {.final, pure.} = object ciCharset*: WINUINT @@ -7281,7 +7239,6 @@ type fs*: FONTSIGNATURE LPCHARSETINFO* = ptr CHARSETINFO - TCHARSETINFO* = CHARSETINFO PCHARSETINFO* = ptr CHARSETINFO #CHOOSECOLOR = record confilcts with function ChooseColor TCHOOSECOLOR* {.final, pure.} = object @@ -7311,11 +7268,9 @@ type lfClipPrecision*: int8 lfQuality*: int8 lfPitchAndFamily*: int8 - lfFaceName*: array[0..(LF_FACESIZE) - 1, TCHAR] + lfFaceName*: array[0..(LF_FACESIZE) - 1, CHAR] LPLOGFONT* = ptr LOGFONT - TLOGFONT* = LOGFONT - TLOGFONTA* = LOGFONT PLOGFONT* = ptr LOGFONT PLOGFONTA* = PLOGFONT LOGFONTW* {.final, pure.} = object @@ -7336,9 +7291,8 @@ type LPLOGFONTW* = ptr LOGFONTW NPLOGFONTW* = ptr LOGFONTW - TLogFontW* = LOGFONTW - PLogFontW* = ptr TLogFontW - TCHOOSEFONT* {.final, pure.} = object + PLogFontW* = ptr LogFontW + TCHOOSEFONT* {.final, pure.} = object # Name conflict if we drop the `T` lStructSize*: DWORD hwndOwner*: HWND hDC*: HDC @@ -7363,14 +7317,12 @@ type aoffset*: array[0..0, WINUINT] LPIDA* = ptr CIDA - TIDA* = CIDA PIDA* = ptr CIDA CLIENTCREATESTRUCT* {.final, pure.} = object hWindowMenu*: HANDLE idFirstChild*: WINUINT LPCLIENTCREATESTRUCT* = ptr CLIENTCREATESTRUCT - TCLIENTCREATESTRUCT* = CLIENTCREATESTRUCT PCLIENTCREATESTRUCT* = ptr CLIENTCREATESTRUCT CMINVOKECOMMANDINFO* {.final, pure.} = object cbSize*: DWORD @@ -7384,7 +7336,6 @@ type hIcon*: HANDLE LPCMINVOKECOMMANDINFO* = ptr CMINVOKECOMMANDINFO - TCMInvokeCommandInfo* = CMINVOKECOMMANDINFO PCMInvokeCommandInfo* = ptr CMINVOKECOMMANDINFO COLORADJUSTMENT* {.final, pure.} = object caSize*: int16 @@ -7401,14 +7352,12 @@ type caRedGreenTint*: SHORT LPCOLORADJUSTMENT* = ptr COLORADJUSTMENT - TCOLORADJUSTMENT* = COLORADJUSTMENT PCOLORADJUSTMENT* = ptr COLORADJUSTMENT COLORMAP* {.final, pure.} = object `from`*: COLORREF `to`*: COLORREF # XXX! LPCOLORMAP* = ptr COLORMAP - TCOLORMAP* = COLORMAP PCOLORMAP* = ptr COLORMAP DCB* {.final, pure.} = object DCBlength*: DWORD @@ -7428,8 +7377,28 @@ type wReserved1*: int16 LPDCB* = ptr DCB - TDCB* = DCB PDCB* = ptr DCB +{.deprecated: [TABC: ABC, TABCFLOAT: ABCFLOAT, TACCEL: ACCEL, TACE_HEADER: ACE_HEADER, + TACCESS_ALLOWED_ACE: ACCESS_ALLOWED_ACE, TACCESS_DENIED_ACE: ACCESS_DENIED_ACE, + TACCESSTIMEOUT: ACCESSTIMEOUT, TACL: ACL, TACTIONHEADER: ACTION_HEADER, + TADAPTERSTATUS: ADAPTER_STATUS, TADDJOB_INFO_1: ADDJOB_INFO_1, + TANIMATIONINFO: ANIMATIONINFO, TAppBarData: APPBARDATA, TBITMAP: BITMAP, + TBITMAPCOREHEADER: BITMAPCOREHEADER, TRGBTRIPLE: RGBTRIPLE, + TBITMAPCOREINFO: BITMAPCOREINFO, TBITMAPINFOHEADER: BITMAPINFOHEADER, + TRGBQUAD: RGBQUAD, TBITMAPINFO: BITMAPINFO, TPCIEXYZ: CIEXYZ, + TCIEXYZTRIPLE: CIEXYZTRIPLE, TBITMAPV4HEADER: BITMAPV4HEADER, TBLOB: BLOB, + TSHITEMID: SHITEMID, TITEMIDLIST: ITEMIDLIST, Tbrowseinfo: BROWSEINFO, + TBYHANDLEFILEINFORMATION: BY_HANDLE_FILE_INFORMATION, TFIXED: FIXED, + TPOINTFX: POINTFX, TSmallPoint: SmallPoint, TCANDIDATEFORM: CANDIDATEFORM, + TCANDIDATELIST: CANDIDATELIST, TCREATESTRUCT: CREATESTRUCT, + TCBT_CREATEWND: CBT_CREATEWND, TCBTACTIVATESTRUCT: CBTACTIVATESTRUCT, + TCHAR_INFO: CHAR_INFO, Tcharformat: CHARFORMAT, Tcharrange: CHARRANGE, + TCHARSET: CHARSET, TFONTSIGNATURE: FONTSIGNATURE, TCHARSETINFO: CHARSETINFO, + TLOGFONT: LOGFONT, TLOGFONTA: LOGFONT, TLogFontW: LOGFONTW, + TIDA: CIDA, TCLIENTCREATESTRUCT: CLIENTCREATESTRUCT, + TCMInvokeCommandInfo: CMINVOKECOMMANDINFO, TCOLORADJUSTMENT: COLORADJUSTMENT, + TCOLORMAP: COLORMAP, TDCB: DCB +].} const bm_DCB_fBinary* = 1 @@ -7501,7 +7470,6 @@ type wcProviderData*: array[0..0, WCHAR] LPCOMMCONFIG* = ptr COMMCONFIG - TCOMMCONFIG* = COMMCONFIG PCOMMCONFIG* = ptr COMMCONFIG COMMPROP* {.final, pure.} = object wPacketLength*: int16 @@ -7524,7 +7492,6 @@ type wcProvChar*: array[0..0, WCHAR] LPCOMMPROP* = ptr COMMPROP - TCOMMPROP* = COMMPROP PCOMMPROP* = ptr COMMPROP COMMTIMEOUTS* {.final, pure.} = object ReadIntervalTimeout*: DWORD @@ -7534,7 +7501,6 @@ type WriteTotalTimeoutConstant*: DWORD LPCOMMTIMEOUTS* = ptr COMMTIMEOUTS - TCOMMTIMEOUTS* = COMMTIMEOUTS PCOMMTIMEOUTS* = ptr COMMTIMEOUTS COMPAREITEMSTRUCT* {.final, pure.} = object CtlType*: WINUINT @@ -7545,14 +7511,12 @@ type itemID2*: WINUINT itemData2*: ULONG_PTR - TCOMPAREITEMSTRUCT* = COMPAREITEMSTRUCT PCOMPAREITEMSTRUCT* = ptr COMPAREITEMSTRUCT COMPCOLOR* {.final, pure.} = object crText*: COLORREF crBackground*: COLORREF dwEffects*: DWORD - TCOMPCOLOR* = COMPCOLOR PCOMPCOLOR* = ptr COMPCOLOR COMPOSITIONFORM* {.final, pure.} = object dwStyle*: DWORD @@ -7560,18 +7524,19 @@ type rcArea*: RECT LPCOMPOSITIONFORM* = ptr COMPOSITIONFORM - TCOMPOSITIONFORM* = COMPOSITIONFORM - PCOMPOSITIONFORM* = ptr COMPOSITIONFORM # TComStatFlags = set of (fCtsHold, fDsrHold, fRlsdHold , fXoffHold , + PCOMPOSITIONFORM* = ptr COMPOSITIONFORM # ComStatFlags = set of (fCtsHold, fDsrHold, fRlsdHold , fXoffHold , # fXoffSent , fEof , fTxim , fReserved); COMSTAT* {.final, pure.} = object - flag0*: DWORD # can't use tcomstatflags, set packing issues + flag0*: DWORD # can't use comstatflags, set packing issues # and conflicts with macro's cbInQue*: DWORD cbOutQue*: DWORD LPCOMSTAT* = ptr COMSTAT - TCOMSTAT* = COMSTAT PCOMSTAT* = ptr COMSTAT +{.deprecated: [TCOMSTAT: COMSTAT, TCOMPOSITIONFORM: COMPOSITIONFORM, + TCOMPCOLOR: COMPCOLOR, TCOMPAREITEMSTRUCT: COMPAREITEMSTRUCT, + TCOMMTIMEOUTS: COMMTIMEOUTS, TCOMMPROP: COMMPROP, TCOMMCONFIG: COMMCONFIG].} const bm_COMSTAT_fCtsHold* = 0x00000001 @@ -7614,13 +7579,10 @@ type bVisible*: WINBOOL PCONSOLE_CURSOR_INFO* = ptr CONSOLE_CURSOR_INFO - TCONSOLECURSORINFO* = CONSOLE_CURSOR_INFO - TCURSORINFO* = CONSOLE_CURSOR_INFO COORD* {.final, pure.} = object X*: SHORT Y*: SHORT - TCOORD* = COORD PCOORD* = ptr COORD SMALL_RECT* {.final, pure.} = object Left*: SHORT @@ -7628,7 +7590,6 @@ type Right*: SHORT Bottom*: SHORT - TSMALL_RECT* = SMALL_RECT PSMALL_RECT* = ptr SMALL_RECT CONSOLE_SCREEN_BUFFER_INFO* {.final, pure.} = object dwSize*: COORD @@ -7638,7 +7599,10 @@ type dwMaximumWindowSize*: COORD PCONSOLE_SCREEN_BUFFER_INFO* = ptr CONSOLE_SCREEN_BUFFER_INFO - TCONSOLESCREENBUFFERINFO* = CONSOLE_SCREEN_BUFFER_INFO + +{.deprecated: [TCONSOLECURSORINFO: CONSOLE_CURSOR_INFO, + TCURSORINFO: CONSOLE_CURSOR_INFO, TCOORD: COORD, TSMALL_RECT: SMALL_RECT, + TCONSOLESCREENBUFFERINFO: CONSOLE_SCREEN_BUFFER_INFO].} when defined(i386): type @@ -7653,7 +7617,6 @@ when defined(i386): RegisterArea*: array[0..79, int8] Cr0NpxState*: DWORD - TFLOATINGSAVEAREA* = FLOATING_SAVE_AREA PFLOATINGSAVEAREA* = ptr FLOATING_SAVE_AREA CONTEXT* {.final, pure.} = object ContextFlags*: DWORD @@ -7680,6 +7643,7 @@ when defined(i386): EFlags*: DWORD Esp*: DWORD SegSs*: DWORD + {.deprecated: [TFLOATINGSAVEAREA: FLOATING_SAVE_AREA].} elif defined(x86_64): # @@ -7690,8 +7654,7 @@ elif defined(x86_64): Low*: ULONGLONG High*: LONGLONG - TM128A* = M128A - PM128A* = TM128A #typedef struct _XMM_SAVE_AREA32 { + PM128A* = M128A #typedef struct _XMM_SAVE_AREA32 { XMM_SAVE_AREA32* {.final, pure.} = object ControlWord*: int16 StatusWord*: int16 @@ -7710,8 +7673,9 @@ elif defined(x86_64): XmmRegisters*: array[0..16, M128A] Reserved4*: array[0..95, int8] - TXmmSaveArea* = XMM_SAVE_AREA32 - PXmmSaveArea* = ptr TXmmSaveArea + PXmmSaveArea* = ptr XmmSaveArea32 + {.deprecated: [TM128A: M128A, TXmmSaveArea: XMM_SAVE_AREA32].} + type CONTEXT* {.final, pure.} = object P1Home*: DWORD64 @@ -7891,20 +7855,19 @@ else: type LPCONTEXT* = ptr CONTEXT - TCONTEXT* = CONTEXT PCONTEXT* = ptr CONTEXT +{.deprecated: [TCONTEXT: CONTEXT].} type LIST_ENTRY* {.final, pure.} = object Flink*: ptr LIST_ENTRY Blink*: ptr LIST_ENTRY - TLISTENTRY* = LIST_ENTRY PLISTENTRY* = ptr LIST_ENTRY CRITICAL_SECTION_DEBUG* {.final, pure.} = object `type`*: int16 CreatorBackTraceIndex*: int16 - CriticalSection*: ptr TCRITICAL_SECTION + CriticalSection*: ptr TRTL_CRITICAL_SECTION ProcessLocksList*: LIST_ENTRY EntryCount*: DWORD ContentionCount*: DWORD @@ -7923,8 +7886,6 @@ type LPCRITICAL_SECTION_DEBUG* = ptr CRITICAL_SECTION_DEBUG PCRITICAL_SECTION_DEBUG* = ptr CRITICAL_SECTION_DEBUG - TCRITICALSECTIONDEBUG* = CRITICAL_SECTION_DEBUG - TCRITICAL_SECTION* = TRTLCriticalSection PCRITICAL_SECTION* = PRTLCriticalSection LPCRITICAL_SECTION* = PRTLCriticalSection SECURITY_QUALITY_OF_SERVICE* {.final, pure.} = object @@ -7934,7 +7895,6 @@ type EffectiveOnly*: bool PSECURITY_QUALITY_OF_SERVICE* = ptr SECURITY_QUALITY_OF_SERVICE - TSECURITYQUALITYOFSERVICE* = SECURITY_QUALITY_OF_SERVICE CONVCONTEXT* {.final, pure.} = object cb*: WINUINT wFlags*: WINUINT @@ -7944,7 +7904,6 @@ type dwSecurity*: DWORD qos*: SECURITY_QUALITY_OF_SERVICE - TCONVCONTEXT* = CONVCONTEXT PCONVCONTEXT* = ptr CONVCONTEXT CONVINFO* {.final, pure.} = object cb*: DWORD @@ -7964,14 +7923,12 @@ type hwnd*: HWND hwndPartner*: HWND - TCONVINFO* = CONVINFO PCONVINFO* = ptr CONVINFO COPYDATASTRUCT* {.final, pure.} = object dwData*: DWORD cbData*: DWORD lpData*: PVOID - TCOPYDATASTRUCT* = COPYDATASTRUCT PCOPYDATASTRUCT* = ptr COPYDATASTRUCT CPINFO* {.final, pure.} = object MaxCharSize*: WINUINT @@ -7979,7 +7936,6 @@ type LeadByte*: array[0..(MAX_LEADBYTES) - 1, int8] LPCPINFO* = ptr CPINFO - Tcpinfo* = CPINFO Pcpinfo* = ptr CPINFO CPLINFO* {.final, pure.} = object idIcon*: int32 @@ -7987,7 +7943,6 @@ type idInfo*: int32 lData*: LONG - TCPLINFO* = CPLINFO PCPLINFO* = ptr CPLINFO CREATE_PROCESS_DEBUG_INFO* {.final, pure.} = object hFile*: HANDLE @@ -8001,14 +7956,12 @@ type lpImageName*: LPVOID fUnicode*: int16 - TCREATEPROCESSDEBUGINFO* = CREATE_PROCESS_DEBUG_INFO PCREATEPROCESSDEBUGINFO* = ptr CREATE_PROCESS_DEBUG_INFO CREATE_THREAD_DEBUG_INFO* {.final, pure.} = object hThread*: HANDLE lpThreadLocalBase*: LPVOID lpStartAddress*: LPTHREAD_START_ROUTINE - - TCREATETHREADDEBUGINFO* = CREATE_THREAD_DEBUG_INFO + PCREATETHREADDEBUGINFO* = ptr CREATE_THREAD_DEBUG_INFO CURRENCYFMT* {.final, pure.} = object @@ -8021,7 +7974,6 @@ type PositiveOrder*: WINUINT lpCurrencySymbol*: LPTSTR - Tcurrencyfmt* = CURRENCYFMT Pcurrencyfmt* = ptr CURRENCYFMT CURSORSHAPE* {.final, pure.} = object xHotSpot*: int32 @@ -8033,7 +7985,6 @@ type BitsPixel*: int8 LPCURSORSHAPE* = ptr CURSORSHAPE - TCURSORSHAPE* = CURSORSHAPE PCURSORSHAPE* = ptr CURSORSHAPE CWPRETSTRUCT* {.final, pure.} = object lResult*: LRESULT @@ -8042,7 +7993,6 @@ type message*: DWORD hwnd*: HWND - TCWPRETSTRUCT* = CWPRETSTRUCT PCWPRETSTRUCT* = ptr CWPRETSTRUCT CWPSTRUCT* {.final, pure.} = object lParam*: LPARAM @@ -8050,18 +8000,24 @@ type message*: WINUINT hwnd*: HWND - TCWPSTRUCT* = CWPSTRUCT PCWPSTRUCT* = ptr CWPSTRUCT DATATYPES_INFO_1* {.final, pure.} = object pName*: LPTSTR - TDATATYPESINFO1* = DATATYPES_INFO_1 PDATATYPESINFO1* = ptr DATATYPES_INFO_1 DDEACK* {.final, pure.} = object flag0*: int16 - TDDEACK* = DDEACK PDDEACK* = ptr DDEACK +{.deprecated: [TLISTENTRY: LIST_ENTRY, TDATATYPESINFO1: DATATYPES_INFO_1, + TCWPSTRUCT: CWPSTRUCT, TCWPRETSTRUCT: CWPRETSTRUCT, TCURSORSHAPE: CURSORSHAPE, + Tcurrencyfmt: CURRENCYFMT, TCREATETHREADDEBUGINFO: CREATE_THREAD_DEBUG_INFO, + TCREATEPROCESSDEBUGINFO: CREATE_PROCESS_DEBUG_INFO, TCPLINFO: CPLINFO, + Tcpinfo: CPINFO, TCOPYDATASTRUCT: COPYDATASTRUCT, TCONVINFO: CONVINFO, + TCONVCONTEXT: CONVCONTEXT, TSECURITYQUALITYOFSERVICE: SECURITY_QUALITY_OF_SERVICE, + TCRITICAL_SECTION: TRTLCriticalSection, TCRITICALSECTIONDEBUG: CRITICAL_SECTION_DEBUG, + TDDEACK: DDEACK +].} const bm_DDEACK_bAppReturnCode* = 0x000000FF'i16 @@ -8086,8 +8042,8 @@ type flag0*: int16 cfFormat*: SHORT - TDDEADVISE* = DDEADVISE PDDEADVISE* = ptr DDEADVISE +{.deprecated: [TDDEADVISE: DDEADVISE].} const bm_DDEADVISE_reserved* = 0x00003FFF'i16 @@ -8138,8 +8094,8 @@ type flag0*: int16 cfFormat*: SHORT - TDDELN* = DDELN PDDELN* = ptr DDELN +{.deprecated: [TDDELN: DDELN].} const bm_DDELN_unused* = 0x00001FFF'i16 @@ -8166,15 +8122,14 @@ type cbData*: DWORD Data*: array[0..7, DWORD] - TDDEMLMSGHOOKDATA* = DDEML_MSG_HOOK_DATA PDDEMLMSGHOOKDATA* = ptr DDEML_MSG_HOOK_DATA DDEPOKE* {.final, pure.} = object flag0*: int16 cfFormat*: SHORT Value*: array[0..0, int8] - TDDEPOKE* = DDEPOKE PDDEPOKE* = ptr DDEPOKE +{.deprecated: [TDDEMLMSGHOOKDATA: DDEML_MSG_HOOK_DATA, TDDEPOKE: DDEPOKE].} const bm_DDEPOKE_unused* = 0x00001FFF'i16 @@ -8196,8 +8151,8 @@ type cfFormat*: SHORT rgb*: array[0..0, int8] - TDDEUP* = DDEUP PDDEUP* = ptr DDEUP +{.deprecated: [TDDEUP: DDEUP].} const bm_DDEUP_unused* = 0x00000FFF'i16 @@ -8232,13 +8187,11 @@ type ULONG_PTR] PEXCEPTION_RECORD* = ptr EXCEPTION_RECORD - TEXCEPTIONRECORD* = EXCEPTION_RECORD EXCEPTION_DEBUG_INFO* {.final, pure.} = object ExceptionRecord*: EXCEPTION_RECORD dwFirstChance*: DWORD PEXCEPTION_DEBUG_INFO* = ptr EXCEPTION_DEBUG_INFO - TEXCEPTIONDEBUGINFO* = EXCEPTION_DEBUG_INFO EXCEPTION_RECORD32* {.final, pure.} = object ExceptionCode*: DWORD ExceptionFlags*: DWORD @@ -8248,13 +8201,11 @@ type ExceptionInformation*: array[0..(EXCEPTION_MAXIMUM_PARAMETERS) - 1, DWORD] PEXCEPTION_RECORD32* = ptr EXCEPTION_RECORD32 - TExceptionRecord32* = EXCEPTION_RECORD32 EXCEPTION_DEBUG_INFO32* {.final, pure.} = object ExceptionRecord*: EXCEPTION_RECORD32 dwFirstChance*: DWORD PEXCEPTION_DEBUG_INFO32* = ptr EXCEPTION_DEBUG_INFO32 - TExceptionDebugInfo32* = EXCEPTION_DEBUG_INFO32 EXCEPTION_RECORD64* {.final, pure.} = object ExceptionCode*: DWORD ExceptionFlags*: DWORD @@ -8265,22 +8216,18 @@ type ExceptionInformation*: array[0..(EXCEPTION_MAXIMUM_PARAMETERS) - 1, DWORD64] PEXCEPTION_RECORD64* = ptr EXCEPTION_RECORD64 - TExceptionRecord64* = EXCEPTION_RECORD64 EXCEPTION_DEBUG_INFO64* {.final, pure.} = object ExceptionRecord*: EXCEPTION_RECORD64 dwFirstChance*: DWORD PEXCEPTION_DEBUG_INFO64* = ptr EXCEPTION_DEBUG_INFO64 - TExceptionDebugInfo64* = EXCEPTION_DEBUG_INFO64 EXIT_PROCESS_DEBUG_INFO* {.final, pure.} = object dwExitCode*: DWORD - TEXITPROCESSDEBUGINFO* = EXIT_PROCESS_DEBUG_INFO PEXITPROCESSDEBUGINFO* = ptr EXIT_PROCESS_DEBUG_INFO EXIT_THREAD_DEBUG_INFO* {.final, pure.} = object dwExitCode*: DWORD - TEXITTHREADDEBUGINFO* = EXIT_THREAD_DEBUG_INFO PEXITTHREADDEBUGINFO* = ptr EXIT_THREAD_DEBUG_INFO LOAD_DLL_DEBUG_INFO* {.final, pure.} = object hFile*: HANDLE @@ -8290,25 +8237,21 @@ type lpImageName*: LPVOID fUnicode*: int16 - TLOADDLLDEBUGINFO* = LOAD_DLL_DEBUG_INFO PLOADDLLDEBUGINFO* = ptr LOAD_DLL_DEBUG_INFO UNLOAD_DLL_DEBUG_INFO* {.final, pure.} = object lpBaseOfDll*: LPVOID - TUNLOADDLLDEBUGINFO* = UNLOAD_DLL_DEBUG_INFO PUNLOADDLLDEBUGINFO* = ptr UNLOAD_DLL_DEBUG_INFO OUTPUT_DEBUG_STRING_INFO* {.final, pure.} = object lpDebugStringData*: LPSTR fUnicode*: int16 nDebugStringLength*: int16 - TOUTPUTDEBUGSTRINGINFO* = OUTPUT_DEBUG_STRING_INFO POUTPUTDEBUGSTRINGINFO* = ptr OUTPUT_DEBUG_STRING_INFO RIP_INFO* {.final, pure.} = object dwError*: DWORD dwType*: DWORD - TRIPINFO* = RIP_INFO PRIPINFO* = ptr RIP_INFO DEBUG_EVENT* {.final, pure.} = object dwDebugEventCode*: DWORD @@ -8317,7 +8260,6 @@ type data*: array[0..15, DWORD] LPDEBUG_EVENT* = ptr DEBUG_EVENT - TDEBUGEVENT* = DEBUG_EVENT PDEBUGEVENT* = ptr DEBUG_EVENT DEBUGHOOKINFO* {.final, pure.} = object idThread*: DWORD @@ -8326,7 +8268,6 @@ type wParam*: WPARAM code*: int32 - TDEBUGHOOKINFO* = DEBUGHOOKINFO PDEBUGHOOKINFO* = ptr DEBUGHOOKINFO DELETEITEMSTRUCT* {.final, pure.} = object CtlType*: WINUINT @@ -8335,7 +8276,6 @@ type hwndItem*: HWND itemData*: ULONG_PTR - TDELETEITEMSTRUCT* = DELETEITEMSTRUCT PDELETEITEMSTRUCT* = ptr DELETEITEMSTRUCT DEV_BROADCAST_HDR* {.final, pure.} = object dbch_size*: ULONG @@ -8343,7 +8283,6 @@ type dbch_reserved*: ULONG PDEV_BROADCAST_HDR* = ptr DEV_BROADCAST_HDR - TDEVBROADCASTHDR* = DEV_BROADCAST_HDR DEV_BROADCAST_OEM* {.final, pure.} = object dbco_size*: ULONG dbco_devicetype*: ULONG @@ -8352,7 +8291,6 @@ type dbco_suppfunc*: ULONG PDEV_BROADCAST_OEM* = ptr DEV_BROADCAST_OEM - TDEVBROADCASTOEM* = DEV_BROADCAST_OEM DEV_BROADCAST_PORT* {.final, pure.} = object dbcp_size*: ULONG dbcp_devicetype*: ULONG @@ -8360,13 +8298,11 @@ type dbcp_name*: array[0..0, char] PDEV_BROADCAST_PORT* = ptr DEV_BROADCAST_PORT - TDEVBROADCASTPORT* = DEV_BROADCAST_PORT DEV_BROADCAST_USERDEFINED* {.final, pure.} = object dbud_dbh*: DEV_BROADCAST_HDR dbud_szName*: array[0..0, char] dbud_rgbUserDefined*: array[0..0, int8] - TDEVBROADCASTUSERDEFINED* = DEV_BROADCAST_USERDEFINED PDEVBROADCASTUSERDEFINED* = ptr DEV_BROADCAST_USERDEFINED DEV_BROADCAST_VOLUME* {.final, pure.} = object dbcv_size*: ULONG @@ -8376,7 +8312,6 @@ type dbcv_flags*: USHORT PDEV_BROADCAST_VOLUME* = ptr DEV_BROADCAST_VOLUME - TDEVBROADCASTVOLUME* = DEV_BROADCAST_VOLUME DEVMODE* {.final, pure.} = object dmDeviceName*: array[0..(CCHDEVICENAME) - 1, BCHAR] dmSpecVersion*: int16 @@ -8416,11 +8351,8 @@ type LPDEVMODE* = ptr DEVMODE Devicemode* = DEVMODE - TDevicemode* = DEVMODE - TDevicemodeA* = DEVMODE PDeviceModeA* = LPDEVMODE PDeviceMode* = LPDEVMODE - TDEVMODE* = DEVMODE PDEVMODE* = LPDEVMODE DEVMODEW* {.final, pure.} = object dmDeviceName*: array[0..CCHDEVICENAME - 1, WCHAR] @@ -8460,9 +8392,7 @@ type LPDEVMODEW* = ptr DEVMODEW DevicemodeW* = DEVMODEW - TDeviceModeW* = DEVMODEW PDeviceModeW* = LPDEVMODEW - TDEVMODEW* = DEVMODEW PDEVMODEW* = LPDEVMODEW DEVNAMES* {.final, pure.} = object wDriverOffset*: int16 @@ -8471,7 +8401,6 @@ type wDefault*: int16 LPDEVNAMES* = ptr DEVNAMES - TDEVNAMES* = DEVNAMES PDEVNAMES* = ptr DEVNAMES DIBSECTION* {.final, pure.} = object dsBm*: BITMAP @@ -8480,7 +8409,6 @@ type dshSection*: HANDLE dsOffset*: DWORD - TDIBSECTION* = DIBSECTION PDIBSECTION* = ptr DIBSECTION # # LARGE_INTEGER = record # case byte of @@ -8497,9 +8425,7 @@ type LARGE_INTEGER* = int64 ULARGE_INTEGER* = int64 PLARGE_INTEGER* = ptr LARGE_INTEGER - TLargeInteger* = int64 PULARGE_INTEGER* = ptr ULARGE_INTEGER - TULargeInteger* = int64 DISK_GEOMETRY* {.final, pure.} = object Cylinders*: LARGE_INTEGER MediaType*: MEDIA_TYPE @@ -8507,7 +8433,6 @@ type SectorsPerTrack*: DWORD BytesPerSector*: DWORD - TDISKGEOMETRY* = DISK_GEOMETRY PDISKGEOMETRY* = ptr DISK_GEOMETRY DISK_PERFORMANCE* {.final, pure.} = object BytesRead*: LARGE_INTEGER @@ -8518,7 +8443,6 @@ type WriteCount*: DWORD QueueDepth*: DWORD - TDISKPERFORMANCE* = DISK_PERFORMANCE PDISKPERFORMANCE* = ptr DISK_PERFORMANCE DLGITEMTEMPLATE* {.final, pure.} = object style*: DWORD @@ -8530,7 +8454,6 @@ type id*: int16 LPDLGITEMTEMPLATE* = ptr DLGITEMTEMPLATE - TDLGITEMTEMPLATE* = DLGITEMTEMPLATE PDLGITEMTEMPLATE* = ptr DLGITEMTEMPLATE DLGTEMPLATE* {.final, pure.} = object style*: DWORD @@ -8543,14 +8466,12 @@ type LPDLGTEMPLATE* = ptr DLGTEMPLATE LPCDLGTEMPLATE* = ptr DLGTEMPLATE - TDLGTEMPLATE* = DLGTEMPLATE PDLGTEMPLATE* = ptr DLGTEMPLATE DOC_INFO_1* {.final, pure.} = object pDocName*: LPTSTR pOutputFile*: LPTSTR pDatatype*: LPTSTR - TDOCINFO1* = DOC_INFO_1 PDOCINFO1* = ptr DOC_INFO_1 DOC_INFO_2* {.final, pure.} = object pDocName*: LPTSTR @@ -8559,7 +8480,6 @@ type dwMode*: DWORD JobId*: DWORD - TDOCINFO2* = DOC_INFO_2 PDOCINFO2* = ptr DOC_INFO_2 DOCINFO* {.final, pure.} = object cbSize*: int32 @@ -8568,8 +8488,6 @@ type lpszDatatype*: LPCTSTR fwType*: DWORD - TDOCINFO* = DOCINFO - TDOCINFOA* = DOCINFO PDOCINFO* = ptr DOCINFO DRAGLISTINFO* {.final, pure.} = object uNotification*: WINUINT @@ -8577,7 +8495,6 @@ type ptCursor*: POINT LPDRAGLISTINFO* = ptr DRAGLISTINFO - TDRAGLISTINFO* = DRAGLISTINFO PDRAGLISTINFO* = ptr DRAGLISTINFO DRAWITEMSTRUCT* {.final, pure.} = object CtlType*: WINUINT @@ -8591,7 +8508,6 @@ type itemData*: ULONG_PTR LPDRAWITEMSTRUCT* = ptr DRAWITEMSTRUCT - TDRAWITEMSTRUCT* = DRAWITEMSTRUCT PDRAWITEMSTRUCT* = ptr DRAWITEMSTRUCT DRAWTEXTPARAMS* {.final, pure.} = object cbSize*: WINUINT @@ -8601,7 +8517,6 @@ type uiLengthDrawn*: WINUINT LPDRAWTEXTPARAMS* = ptr DRAWTEXTPARAMS - TDRAWTEXTPARAMS* = DRAWTEXTPARAMS PDRAWTEXTPARAMS* = ptr DRAWTEXTPARAMS PARTITION_INFORMATION* {.final, pure.} = object PartitionType*: int8 @@ -8612,19 +8527,16 @@ type PartitionLength*: LARGE_INTEGER HiddenSectors*: LARGE_INTEGER - TPARTITIONINFORMATION* = PARTITION_INFORMATION PPARTITIONINFORMATION* = ptr PARTITION_INFORMATION DRIVE_LAYOUT_INFORMATION* {.final, pure.} = object PartitionCount*: DWORD Signature*: DWORD PartitionEntry*: array[0..0, PARTITION_INFORMATION] - TDRIVELAYOUTINFORMATION* = DRIVE_LAYOUT_INFORMATION PDRIVELAYOUTINFORMATION* = ptr DRIVE_LAYOUT_INFORMATION DRIVER_INFO_1* {.final, pure.} = object pName*: LPTSTR - TDRIVERINFO1* = DRIVER_INFO_1 PDRIVERINFO1* = ptr DRIVER_INFO_1 DRIVER_INFO_2* {.final, pure.} = object cVersion*: DWORD @@ -8634,7 +8546,6 @@ type pDataFile*: LPTSTR pConfigFile*: LPTSTR - TDRIVERINFO2* = DRIVER_INFO_2 PDRIVERINFO2* = ptr DRIVER_INFO_2 DRIVER_INFO_3* {.final, pure.} = object cVersion*: DWORD @@ -8648,20 +8559,17 @@ type pMonitorName*: LPTSTR pDefaultDataType*: LPTSTR - TDRIVERINFO3* = DRIVER_INFO_3 PDRIVERINFO3* = ptr DRIVER_INFO_3 EDITSTREAM* {.final, pure.} = object dwCookie*: DWORD dwError*: DWORD pfnCallback*: EDITSTREAMCALLBACK - Teditstream* = EDITSTREAM Peditstream* = ptr EDITSTREAM EMR* {.final, pure.} = object iType*: DWORD nSize*: DWORD - TEMR* = EMR PEMR* = ptr EMR EMRANGLEARC* {.final, pure.} = object emr*: EMR @@ -8670,7 +8578,6 @@ type eStartAngle*: float32 eSweepAngle*: float32 - TEMRANGLEARC* = EMRANGLEARC PEMRANGLEARC* = ptr EMRANGLEARC EMRARC* {.final, pure.} = object emr*: EMR @@ -8678,16 +8585,12 @@ type ptlStart*: POINTL ptlEnd*: POINTL - TEMRARC* = EMRARC PEMRARC* = ptr EMRARC EMRARCTO* = EMRARC - TEMRARCTO* = EMRARC PEMRARCTO* = ptr EMRARC EMRCHORD* = EMRARC - TEMRCHORD* = EMRARC PEMRCHORD* = ptr EMRARC EMRPIE* = EMRARC - TEMRPIE* = EMRARC PEMRPIE* = ptr EMRARC XFORM* {.final, pure.} = object eM11*: float32 @@ -8698,7 +8601,6 @@ type eDy*: float32 LPXFORM* = ptr XFORM - TXFORM* = XFORM PXFORM* = ptr XFORM EMRBITBLT* {.final, pure.} = object emr*: EMR @@ -8717,21 +8619,18 @@ type offBitsSrc*: DWORD cbBitsSrc*: DWORD - TEMRBITBLT* = EMRBITBLT PEMRBITBLT* = ptr EMRBITBLT LOGBRUSH* {.final, pure.} = object lbStyle*: WINUINT lbColor*: COLORREF lbHatch*: LONG - TLOGBRUSH* = LOGBRUSH PLOGBRUSH* = ptr LOGBRUSH EMRCREATEBRUSHINDIRECT* {.final, pure.} = object emr*: EMR ihBrush*: DWORD lb*: LOGBRUSH - TEMRCREATEBRUSHINDIRECT* = EMRCREATEBRUSHINDIRECT PEMRCREATEBRUSHINDIRECT* = ptr EMRCREATEBRUSHINDIRECT LCSCSTYPE* = LONG LCSGAMUTMATCH* = LONG @@ -8745,18 +8644,15 @@ type lcsGammaRed*: DWORD lcsGammaGreen*: DWORD lcsGammaBlue*: DWORD - lcsFilename*: array[0..(MAX_PATH) - 1, TCHAR] + lcsFilename*: array[0..(MAX_PATH) - 1, CHAR] LPLOGCOLORSPACE* = ptr LOGCOLORSPACE - TLOGCOLORSPACE* = LOGCOLORSPACE - TLOGCOLORSPACEA* = LOGCOLORSPACE PLOGCOLORSPACE* = ptr LOGCOLORSPACE EMRCREATECOLORSPACE* {.final, pure.} = object emr*: EMR ihCS*: DWORD lcs*: LOGCOLORSPACE - TEMRCREATECOLORSPACE* = EMRCREATECOLORSPACE PEMRCREATECOLORSPACE* = ptr EMRCREATECOLORSPACE EMRCREATEDIBPATTERNBRUSHPT* {.final, pure.} = object emr*: EMR @@ -8767,7 +8663,6 @@ type offBits*: DWORD cbBits*: DWORD - TEMRCREATEDIBPATTERNBRUSHPT* = EMRCREATEDIBPATTERNBRUSHPT PEMRCREATEDIBPATTERNBRUSHPT* = EMRCREATEDIBPATTERNBRUSHPT EMRCREATEMONOBRUSH* {.final, pure.} = object emr*: EMR @@ -8778,7 +8673,6 @@ type offBits*: DWORD cbBits*: DWORD - TEMRCREATEMONOBRUSH* = EMRCREATEMONOBRUSH PEMRCREATEMONOBRUSH* = ptr EMRCREATEMONOBRUSH PALETTEENTRY* {.final, pure.} = object peRed*: int8 @@ -8787,7 +8681,6 @@ type peFlags*: int8 LPPALETTEENTRY* = ptr PALETTEENTRY - TPALETTEENTRY* = PALETTEENTRY PPALETTEENTRY* = ptr PALETTEENTRY LOGPALETTE* {.final, pure.} = object palVersion*: int16 @@ -8796,37 +8689,31 @@ type LPLOGPALETTE* = ptr LOGPALETTE NPLOGPALETTE* = ptr LOGPALETTE - TLOGPALETTE* = LOGPALETTE PLOGPALETTE* = ptr LOGPALETTE EMRCREATEPALETTE* {.final, pure.} = object emr*: EMR ihPal*: DWORD lgpl*: LOGPALETTE - TEMRCREATEPALETTE* = EMRCREATEPALETTE PEMRCREATEPALETTE* = ptr EMRCREATEPALETTE LOGPEN* {.final, pure.} = object lopnStyle*: WINUINT lopnWidth*: POINT lopnColor*: COLORREF - TLOGPEN* = LOGPEN PLOGPEN* = ptr LOGPEN EMRCREATEPEN* {.final, pure.} = object emr*: EMR ihPen*: DWORD lopn*: LOGPEN - TEMRCREATEPEN* = EMRCREATEPEN PEMRCREATEPEN* = ptr EMRCREATEPEN EMRELLIPSE* {.final, pure.} = object emr*: EMR rclBox*: RECTL - TEMRELLIPSE* = EMRELLIPSE PEMRELLIPSE* = ptr EMRELLIPSE EMRRECTANGLE* = EMRELLIPSE - TEMRRECTANGLE* = EMRELLIPSE PEMRRECTANGLE* = ptr EMRELLIPSE EMREOF* {.final, pure.} = object emr*: EMR @@ -8834,16 +8721,13 @@ type offPalEntries*: DWORD nSizeLast*: DWORD - TEMREOF* = EMREOF PEMREOF* = ptr EMREOF EMREXCLUDECLIPRECT* {.final, pure.} = object emr*: EMR rclClip*: RECTL - TEMREXCLUDECLIPRECT* = EMREXCLUDECLIPRECT PEMREXCLUDECLIPRECT* = ptr EMREXCLUDECLIPRECT EMRINTERSECTCLIPRECT* = EMREXCLUDECLIPRECT - TEMRINTERSECTCLIPRECT* = EMREXCLUDECLIPRECT PEMRINTERSECTCLIPRECT* = ptr EMREXCLUDECLIPRECT PANOSE* {.final, pure.} = object bFamilyType*: int8 @@ -8857,7 +8741,6 @@ type bMidline*: int8 bXHeight*: int8 - TPANOSE* = PANOSE PPANOSE* = ptr PANOSE EXTLOGFONT* {.final, pure.} = object elfLogFont*: LOGFONT @@ -8871,14 +8754,12 @@ type elfCulture*: DWORD elfPanose*: PANOSE - TEXTLOGFONT* = EXTLOGFONT PEXTLOGFONT* = ptr EXTLOGFONT EMREXTCREATEFONTINDIRECTW* {.final, pure.} = object emr*: EMR ihFont*: DWORD elfw*: EXTLOGFONT - TEMREXTCREATEFONTINDIRECTW* = EMREXTCREATEFONTINDIRECTW PEMREXTCREATEFONTINDIRECTW* = ptr EMREXTCREATEFONTINDIRECTW EXTLOGPEN* {.final, pure.} = object elpPenStyle*: WINUINT @@ -8889,7 +8770,6 @@ type elpNumEntries*: DWORD elpStyleEntry*: array[0..0, DWORD] - TEXTLOGPEN* = EXTLOGPEN PEXTLOGPEN* = ptr EXTLOGPEN EMREXTCREATEPEN* {.final, pure.} = object emr*: EMR @@ -8900,7 +8780,6 @@ type cbBits*: DWORD elp*: EXTLOGPEN - TEMREXTCREATEPEN* = EMREXTCREATEPEN PEMREXTCREATEPEN* = ptr EMREXTCREATEPEN EMREXTFLOODFILL* {.final, pure.} = object emr*: EMR @@ -8908,7 +8787,6 @@ type crColor*: COLORREF iMode*: DWORD - TEMREXTFLOODFILL* = EMREXTFLOODFILL PEMREXTFLOODFILL* = ptr EMREXTFLOODFILL EMREXTSELECTCLIPRGN* {.final, pure.} = object emr*: EMR @@ -8916,7 +8794,6 @@ type iMode*: DWORD RgnData*: array[0..0, int8] - TEMREXTSELECTCLIPRGN* = EMREXTSELECTCLIPRGN PEMREXTSELECTCLIPRGN* = ptr EMREXTSELECTCLIPRGN EMRTEXT* {.final, pure.} = object ptlReference*: POINTL @@ -8926,7 +8803,6 @@ type rcl*: RECTL offDx*: DWORD - TEMRTEXT* = EMRTEXT PEMRTEXT* = ptr EMRTEXT EMREXTTEXTOUTA* {.final, pure.} = object emr*: EMR @@ -8936,22 +8812,17 @@ type eyScale*: float32 emrtext*: EMRTEXT - TEMREXTTEXTOUTA* = EMREXTTEXTOUTA PEMREXTTEXTOUTA* = ptr EMREXTTEXTOUTA EMREXTTEXTOUTW* = EMREXTTEXTOUTA - TEMREXTTEXTOUTW* = EMREXTTEXTOUTA PEMREXTTEXTOUTW* = ptr EMREXTTEXTOUTA EMRFILLPATH* {.final, pure.} = object emr*: EMR rclBounds*: RECTL - TEMRFILLPATH* = EMRFILLPATH PEMRFILLPATH* = ptr EMRFILLPATH EMRSTROKEANDFILLPATH* = EMRFILLPATH - TEMRSTROKEANDFILLPATH* = EMRFILLPATH PEMRSTROKEANDFILLPATH* = ptr EMRFILLPATH EMRSTROKEPATH* = EMRFILLPATH - TEMRSTROKEPATH* = EMRFILLPATH PEMRSTROKEPATH* = ptr EMRFILLPATH EMRFILLRGN* {.final, pure.} = object emr*: EMR @@ -8960,7 +8831,6 @@ type ihBrush*: DWORD RgnData*: array[0..0, int8] - TEMRFILLRGN* = EMRFILLRGN PEMRFILLRGN* = ptr EMRFILLRGN EMRFORMAT* {.final, pure.} = object dSignature*: DWORD @@ -8968,7 +8838,6 @@ type cbData*: DWORD offData*: DWORD - TEMRFORMAT* = EMRFORMAT PEMRFORMAT* = ptr EMRFORMAT EMRFRAMERGN* {.final, pure.} = object @@ -8979,14 +8848,12 @@ type szlStroke*: SIZEL RgnData*: array[0..0, int8] - TEMRFRAMERGN* = EMRFRAMERGN PEMRFRAMERGN* = ptr EMRFRAMERGN EMRGDICOMMENT* {.final, pure.} = object emr*: EMR cbData*: DWORD Data*: array[0..0, int8] - TEMRGDICOMMENT* = EMRGDICOMMENT PEMRGDICOMMENT* = ptr EMRGDICOMMENT EMRINVERTRGN* {.final, pure.} = object emr*: EMR @@ -8994,19 +8861,15 @@ type cbRgnData*: DWORD RgnData*: array[0..0, int8] - TEMRINVERTRGN* = EMRINVERTRGN PEMRINVERTRGN* = ptr EMRINVERTRGN EMRPAINTRGN* = EMRINVERTRGN - TEMRPAINTRGN* = EMRINVERTRGN PEMRPAINTRGN* = ptr EMRINVERTRGN EMRLINETO* {.final, pure.} = object emr*: EMR ptl*: POINTL - TEMRLINETO* = EMRLINETO PEMRLINETO* = ptr EMRLINETO EMRMOVETOEX* = EMRLINETO - TEMRMOVETOEX* = EMRLINETO PEMRMOVETOEX* = ptr EMRLINETO EMRMASKBLT* {.final, pure.} = object emr*: EMR @@ -9033,20 +8896,17 @@ type offBitsMask*: DWORD cbBitsMask*: DWORD - TEMRMASKBLT* = EMRMASKBLT PEMRMASKBLT* = ptr EMRMASKBLT EMRMODIFYWORLDTRANSFORM* {.final, pure.} = object emr*: EMR xform*: XFORM iMode*: DWORD - TEMRMODIFYWORLDTRANSFORM* = EMRMODIFYWORLDTRANSFORM PEMRMODIFYWORLDTRANSFORM* = EMRMODIFYWORLDTRANSFORM EMROFFSETCLIPRGN* {.final, pure.} = object emr*: EMR ptlOffset*: POINTL - TEMROFFSETCLIPRGN* = EMROFFSETCLIPRGN PEMROFFSETCLIPRGN* = ptr EMROFFSETCLIPRGN EMRPLGBLT* {.final, pure.} = object emr*: EMR @@ -9071,7 +8931,6 @@ type offBitsMask*: DWORD cbBitsMask*: DWORD - TEMRPLGBLT* = EMRPLGBLT PEMRPLGBLT* = ptr EMRPLGBLT EMRPOLYDRAW* {.final, pure.} = object emr*: EMR @@ -9080,7 +8939,6 @@ type aptl*: array[0..0, POINTL] abTypes*: array[0..0, int8] - TEMRPOLYDRAW* = EMRPOLYDRAW PEMRPOLYDRAW* = ptr EMRPOLYDRAW EMRPOLYDRAW16* {.final, pure.} = object emr*: EMR @@ -9089,7 +8947,6 @@ type apts*: array[0..0, POINTS] abTypes*: array[0..0, int8] - TEMRPOLYDRAW16* = EMRPOLYDRAW16 PEMRPOLYDRAW16* = ptr EMRPOLYDRAW16 EMRPOLYLINE* {.final, pure.} = object emr*: EMR @@ -9097,19 +8954,14 @@ type cptl*: DWORD aptl*: array[0..0, POINTL] - TEMRPOLYLINE* = EMRPOLYLINE PEMRPOLYLINE* = ptr EMRPOLYLINE EMRPOLYBEZIER* = EMRPOLYLINE - TEMRPOLYBEZIER* = EMRPOLYLINE PEMRPOLYBEZIER* = ptr EMRPOLYLINE EMRPOLYGON* = EMRPOLYLINE - TEMRPOLYGON* = EMRPOLYLINE PEMRPOLYGON* = ptr EMRPOLYLINE EMRPOLYBEZIERTO* = EMRPOLYLINE - TEMRPOLYBEZIERTO* = EMRPOLYLINE PEMRPOLYBEZIERTO* = ptr EMRPOLYLINE EMRPOLYLINETO* = EMRPOLYLINE - TEMRPOLYLINETO* = EMRPOLYLINE PEMRPOLYLINETO* = ptr EMRPOLYLINE EMRPOLYLINE16* {.final, pure.} = object emr*: EMR @@ -9117,19 +8969,14 @@ type cpts*: DWORD apts*: array[0..0, POINTL] - TEMRPOLYLINE16* = EMRPOLYLINE16 PEMRPOLYLINE16* = ptr EMRPOLYLINE16 EMRPOLYBEZIER16* = EMRPOLYLINE16 - TEMRPOLYBEZIER16* = EMRPOLYLINE16 PEMRPOLYBEZIER16* = ptr EMRPOLYLINE16 EMRPOLYGON16* = EMRPOLYLINE16 - TEMRPOLYGON16* = EMRPOLYLINE16 PEMRPOLYGON16* = ptr EMRPOLYLINE16 EMRPOLYBEZIERTO16* = EMRPOLYLINE16 - TEMRPOLYBEZIERTO16* = EMRPOLYLINE16 PEMRPOLYBEZIERTO16* = ptr EMRPOLYLINE16 EMRPOLYLINETO16* = EMRPOLYLINE16 - TEMRPOLYLINETO16* = EMRPOLYLINE16 PEMRPOLYLINETO16* = ptr EMRPOLYLINE16 EMRPOLYPOLYLINE* {.final, pure.} = object emr*: EMR @@ -9139,10 +8986,8 @@ type aPolyCounts*: array[0..0, DWORD] aptl*: array[0..0, POINTL] - TEMRPOLYPOLYLINE* = EMRPOLYPOLYLINE PEMRPOLYPOLYLINE* = ptr EMRPOLYPOLYLINE EMRPOLYPOLYGON* = EMRPOLYPOLYLINE - TEMRPOLYPOLYGON* = EMRPOLYPOLYLINE PEMRPOLYPOLYGON* = ptr EMRPOLYPOLYLINE EMRPOLYPOLYLINE16* {.final, pure.} = object emr*: EMR @@ -9152,10 +8997,8 @@ type aPolyCounts*: array[0..0, DWORD] apts*: array[0..0, POINTS] - TEMRPOLYPOLYLINE16* = EMRPOLYPOLYLINE16 PEMRPOLYPOLYLINE16* = ptr EMRPOLYPOLYLINE16 EMRPOLYPOLYGON16* = EMRPOLYPOLYLINE16 - TEMRPOLYPOLYGON16* = EMRPOLYPOLYLINE16 PEMRPOLYPOLYGON16* = ptr EMRPOLYPOLYLINE16 EMRPOLYTEXTOUTA* {.final, pure.} = object emr*: EMR @@ -9166,30 +9009,25 @@ type cStrings*: LONG aemrtext*: array[0..0, EMRTEXT] - TEMRPOLYTEXTOUTA* = EMRPOLYTEXTOUTA PEMRPOLYTEXTOUTA* = ptr EMRPOLYTEXTOUTA EMRPOLYTEXTOUTW* = EMRPOLYTEXTOUTA - TEMRPOLYTEXTOUTW* = EMRPOLYTEXTOUTA PEMRPOLYTEXTOUTW* = ptr EMRPOLYTEXTOUTA EMRRESIZEPALETTE* {.final, pure.} = object emr*: EMR ihPal*: DWORD cEntries*: DWORD - TEMRRESIZEPALETTE* = EMRRESIZEPALETTE PEMRRESIZEPALETTE* = ptr EMRRESIZEPALETTE EMRRESTOREDC* {.final, pure.} = object emr*: EMR iRelative*: LONG - TEMRRESTOREDC* = EMRRESTOREDC PEMRRESTOREDC* = ptr EMRRESTOREDC EMRROUNDRECT* {.final, pure.} = object emr*: EMR rclBox*: RECTL szlCorner*: SIZEL - TEMRROUNDRECT* = EMRROUNDRECT PEMRROUNDRECT* = ptr EMRROUNDRECT EMRSCALEVIEWPORTEXTEX* {.final, pure.} = object emr*: EMR @@ -9198,56 +9036,45 @@ type yNum*: LONG yDenom*: LONG - TEMRSCALEVIEWPORTEXTEX* = EMRSCALEVIEWPORTEXTEX PEMRSCALEVIEWPORTEXTEX* = ptr EMRSCALEVIEWPORTEXTEX EMRSCALEWINDOWEXTEX* = EMRSCALEVIEWPORTEXTEX - TEMRSCALEWINDOWEXTEX* = EMRSCALEVIEWPORTEXTEX PEMRSCALEWINDOWEXTEX* = ptr EMRSCALEVIEWPORTEXTEX EMRSELECTCOLORSPACE* {.final, pure.} = object emr*: EMR ihCS*: DWORD - TEMRSELECTCOLORSPACE* = EMRSELECTCOLORSPACE PEMRSELECTCOLORSPACE* = ptr EMRSELECTCOLORSPACE EMRDELETECOLORSPACE* = EMRSELECTCOLORSPACE - TEMRDELETECOLORSPACE* = EMRSELECTCOLORSPACE PEMRDELETECOLORSPACE* = ptr EMRSELECTCOLORSPACE EMRSELECTOBJECT* {.final, pure.} = object emr*: EMR ihObject*: DWORD - TEMRSELECTOBJECT* = EMRSELECTOBJECT PEMRSELECTOBJECT* = ptr EMRSELECTOBJECT EMRDELETEOBJECT* = EMRSELECTOBJECT - TEMRDELETEOBJECT* = EMRSELECTOBJECT PEMRDELETEOBJECT* = ptr EMRSELECTOBJECT EMRSELECTPALETTE* {.final, pure.} = object emr*: EMR ihPal*: DWORD - TEMRSELECTPALETTE* = EMRSELECTPALETTE PEMRSELECTPALETTE* = ptr EMRSELECTPALETTE EMRSETARCDIRECTION* {.final, pure.} = object emr*: EMR iArcDirection*: DWORD - TEMRSETARCDIRECTION* = EMRSETARCDIRECTION PEMRSETARCDIRECTION* = ptr EMRSETARCDIRECTION EMRSETBKCOLOR* {.final, pure.} = object emr*: EMR crColor*: COLORREF - TEMRSETBKCOLOR* = EMRSETBKCOLOR PEMRSETBKCOLOR* = ptr EMRSETBKCOLOR EMRSETTEXTCOLOR* = EMRSETBKCOLOR - TEMRSETTEXTCOLOR* = EMRSETBKCOLOR PEMRSETTEXTCOLOR* = ptr EMRSETBKCOLOR EMRSETCOLORADJUSTMENT* {.final, pure.} = object emr*: EMR ColorAdjustment*: COLORADJUSTMENT - TEMRSETCOLORADJUSTMENT* = EMRSETCOLORADJUSTMENT PEMRSETCOLORADJUSTMENT* = ptr EMRSETCOLORADJUSTMENT EMRSETDIBITSTODEVICE* {.final, pure.} = object emr*: EMR @@ -9266,19 +9093,16 @@ type iStartScan*: DWORD cScans*: DWORD - TEMRSETDIBITSTODEVICE* = EMRSETDIBITSTODEVICE PEMRSETDIBITSTODEVICE* = ptr EMRSETDIBITSTODEVICE EMRSETMAPPERFLAGS* {.final, pure.} = object emr*: EMR dwFlags*: DWORD - TEMRSETMAPPERFLAGS* = EMRSETMAPPERFLAGS PEMRSETMAPPERFLAGS* = ptr EMRSETMAPPERFLAGS EMRSETMITERLIMIT* {.final, pure.} = object emr*: EMR eMiterLimit*: float32 - TEMRSETMITERLIMIT* = EMRSETMITERLIMIT PEMRSETMITERLIMIT* = ptr EMRSETMITERLIMIT EMRSETPALETTEENTRIES* {.final, pure.} = object emr*: EMR @@ -9287,41 +9111,33 @@ type cEntries*: DWORD aPalEntries*: array[0..0, PALETTEENTRY] - TEMRSETPALETTEENTRIES* = EMRSETPALETTEENTRIES PEMRSETPALETTEENTRIES* = ptr EMRSETPALETTEENTRIES EMRSETPIXELV* {.final, pure.} = object emr*: EMR ptlPixel*: POINTL crColor*: COLORREF - TEMRSETPIXELV* = EMRSETPIXELV PEMRSETPIXELV* = ptr EMRSETPIXELV EMRSETVIEWPORTEXTEX* {.final, pure.} = object emr*: EMR szlExtent*: SIZEL - TEMRSETVIEWPORTEXTEX* = EMRSETVIEWPORTEXTEX PEMRSETVIEWPORTEXTEX* = ptr EMRSETVIEWPORTEXTEX EMRSETWINDOWEXTEX* = EMRSETVIEWPORTEXTEX - TEMRSETWINDOWEXTEX* = EMRSETVIEWPORTEXTEX PEMRSETWINDOWEXTEX* = ptr EMRSETVIEWPORTEXTEX EMRSETVIEWPORTORGEX* {.final, pure.} = object emr*: EMR ptlOrigin*: POINTL - TEMRSETVIEWPORTORGEX* = EMRSETVIEWPORTORGEX PEMRSETVIEWPORTORGEX* = ptr EMRSETVIEWPORTORGEX EMRSETWINDOWORGEX* = EMRSETVIEWPORTORGEX - TEMRSETWINDOWORGEX* = EMRSETVIEWPORTORGEX PEMRSETWINDOWORGEX* = ptr EMRSETVIEWPORTORGEX EMRSETBRUSHORGEX* = EMRSETVIEWPORTORGEX - TEMRSETBRUSHORGEX* = EMRSETVIEWPORTORGEX PEMRSETBRUSHORGEX* = ptr EMRSETVIEWPORTORGEX EMRSETWORLDTRANSFORM* {.final, pure.} = object emr*: EMR xform*: XFORM - TEMRSETWORLDTRANSFORM* = EMRSETWORLDTRANSFORM PEMRSETWORLDTRANSFORM* = ptr EMRSETWORLDTRANSFORM EMRSTRETCHBLT* {.final, pure.} = object emr*: EMR @@ -9343,7 +9159,6 @@ type cxSrc*: LONG cySrc*: LONG - TEMRSTRETCHBLT* = EMRSTRETCHBLT PEMRSTRETCHBLT* = ptr EMRSTRETCHBLT EMRSTRETCHDIBITS* {.final, pure.} = object emr*: EMR @@ -9363,99 +9178,79 @@ type cxDest*: LONG cyDest*: LONG - TEMRSTRETCHDIBITS* = EMRSTRETCHDIBITS PEMRSTRETCHDIBITS* = ptr EMRSTRETCHDIBITS EMRABORTPATH* {.final, pure.} = object emr*: EMR - TEMRABORTPATH* = EMRABORTPATH PEMRABORTPATH* = ptr EMRABORTPATH - TABORTPATH* = EMRABORTPATH EMRBEGINPATH* = EMRABORTPATH - TEMRBEGINPATH* = EMRABORTPATH PEMRBEGINPATH* = ptr EMRABORTPATH EMRENDPATH* = EMRABORTPATH - TEMRENDPATH* = EMRABORTPATH PEMRENDPATH* = ptr EMRABORTPATH EMRCLOSEFIGURE* = EMRABORTPATH - TEMRCLOSEFIGURE* = EMRABORTPATH PEMRCLOSEFIGURE* = ptr EMRABORTPATH EMRFLATTENPATH* = EMRABORTPATH - TEMRFLATTENPATH* = EMRABORTPATH PEMRFLATTENPATH* = ptr EMRABORTPATH EMRWIDENPATH* = EMRABORTPATH - TEMRWIDENPATH* = EMRABORTPATH PEMRWIDENPATH* = ptr EMRABORTPATH EMRSETMETARGN* = EMRABORTPATH - TEMRSETMETARGN* = EMRABORTPATH PEMRSETMETARGN* = ptr EMRABORTPATH EMRSAVEDC* = EMRABORTPATH - TEMRSAVEDC* = EMRABORTPATH PEMRSAVEDC* = ptr EMRABORTPATH EMRREALIZEPALETTE* = EMRABORTPATH - TEMRREALIZEPALETTE* = EMRABORTPATH PEMRREALIZEPALETTE* = ptr EMRABORTPATH EMRSELECTCLIPPATH* {.final, pure.} = object emr*: EMR iMode*: DWORD - TEMRSELECTCLIPPATH* = EMRSELECTCLIPPATH PEMRSELECTCLIPPATH* = ptr EMRSELECTCLIPPATH EMRSETBKMODE* = EMRSELECTCLIPPATH - TEMRSETBKMODE* = EMRSELECTCLIPPATH PEMRSETBKMODE* = ptr EMRSELECTCLIPPATH EMRSETMAPMODE* = EMRSELECTCLIPPATH - TEMRSETMAPMODE* = EMRSELECTCLIPPATH PEMRSETMAPMODE* = ptr EMRSELECTCLIPPATH EMRSETPOLYFILLMODE* = EMRSELECTCLIPPATH - TEMRSETPOLYFILLMODE* = EMRSELECTCLIPPATH PEMRSETPOLYFILLMODE* = ptr EMRSELECTCLIPPATH EMRSETROP2* = EMRSELECTCLIPPATH - TEMRSETROP2* = EMRSELECTCLIPPATH PEMRSETROP2* = ptr EMRSELECTCLIPPATH EMRSETSTRETCHBLTMODE* = EMRSELECTCLIPPATH - TEMRSETSTRETCHBLTMODE* = EMRSELECTCLIPPATH PEMRSETSTRETCHBLTMODE* = ptr EMRSELECTCLIPPATH EMRSETTEXTALIGN* = EMRSELECTCLIPPATH - TEMRSETTEXTALIGN* = EMRSELECTCLIPPATH PEMRSETTEXTALIGN* = ptr EMRSELECTCLIPPATH EMRENABLEICM* = EMRSELECTCLIPPATH - TEMRENABLEICM* = EMRSELECTCLIPPATH PEMRENABLEICM* = ptr EMRSELECTCLIPPATH NMHDR* {.final, pure.} = object hwndFrom*: HWND idFrom*: WINUINT code*: WINUINT - TNMHDR* = NMHDR PNMHDR* = ptr NMHDR - TENCORRECTTEXT* {.final, pure.} = object + TENCORRECTTEXT* {.final, pure.} = object # Name conflict if we drop the `T` nmhdr*: NMHDR chrg*: CHARRANGE seltyp*: int16 Pencorrecttext* = ptr TENCORRECTTEXT - TENDROPFILES* {.final, pure.} = object + TENDROPFILES* {.final, pure.} = object # Name conflict if we drop the `T` nmhdr*: NMHDR hDrop*: HANDLE cp*: LONG fProtected*: WINBOOL Pendropfiles* = ptr TENDROPFILES - TENSAVECLIPBOARD* {.final, pure.} = object + TENSAVECLIPBOARD* {.final, pure.} = object # Name conflict if we drop the `T` nmhdr*: NMHDR cObjectCount*: LONG cch*: LONG PENSAVECLIPBOARD* = ptr TENSAVECLIPBOARD - TENOLEOPFAILED* {.final, pure.} = object + TENOLEOPFAILED* {.final, pure.} = object # Name conflict if we drop the `T` nmhdr*: NMHDR iob*: LONG lOper*: LONG hr*: HRESULT PENOLEOPFAILED* = ptr TENOLEOPFAILED - TENHMETAHEADER* {.final, pure.} = object + ENHMETAHEADER* {.final, pure.} = object iType*: DWORD nSize*: DWORD rclBounds*: RECTL @@ -9472,16 +9267,16 @@ type szlDevice*: SIZEL szlMillimeters*: SIZEL - LPENHMETAHEADER* = ptr TENHMETAHEADER - PENHMETAHEADER* = ptr TENHMETAHEADER - TENHMETARECORD* {.final, pure.} = object + LPENHMETAHEADER* = ptr ENHMETAHEADER + PENHMETAHEADER* = ptr ENHMETAHEADER + ENHMETARECORD* {.final, pure.} = object iType*: DWORD nSize*: DWORD dParm*: array[0..0, DWORD] - LPENHMETARECORD* = ptr TENHMETARECORD - PENHMETARECORD* = ptr TENHMETARECORD - TENPROTECTED* {.final, pure.} = object + LPENHMETARECORD* = ptr ENHMETARECORD + PENHMETARECORD* = ptr ENHMETARECORD + TENPROTECTED* {.final, pure.} = object # Name conflict if we drop the `T` nmhdr*: NMHDR msg*: WINUINT wParam*: WPARAM @@ -9499,7 +9294,6 @@ type dwWaitHint*: DWORD LPSERVICE_STATUS* = ptr SERVICE_STATUS - TSERVICESTATUS* = SERVICE_STATUS PSERVICESTATUS* = ptr SERVICE_STATUS ENUM_SERVICE_STATUS* {.final, pure.} = object lpServiceName*: LPTSTR @@ -9507,14 +9301,12 @@ type ServiceStatus*: SERVICE_STATUS LPENUM_SERVICE_STATUS* = ptr ENUM_SERVICE_STATUS - TENUMSERVICESTATUS* = ENUM_SERVICE_STATUS PENUMSERVICESTATUS* = ptr ENUM_SERVICE_STATUS ENUMLOGFONT* {.final, pure.} = object elfLogFont*: LOGFONT elfFullName*: array[0..(LF_FULLFACESIZE) - 1, BCHAR] elfStyle*: array[0..(LF_FACESIZE) - 1, BCHAR] - TENUMLOGFONT* = ENUMLOGFONT PENUMLOGFONT* = ptr ENUMLOGFONT ENUMLOGFONTEX* {.final, pure.} = object elfLogFont*: LOGFONT @@ -9522,7 +9314,6 @@ type elfStyle*: array[0..(LF_FACESIZE) - 1, BCHAR] elfScript*: array[0..(LF_FACESIZE) - 1, BCHAR] - TENUMLOGFONTEX* = ENUMLOGFONTEX PENUMLOGFONTEX* = ptr ENUMLOGFONTEX EVENTLOGRECORD* {.final, pure.} = object @@ -9543,7 +9334,6 @@ type DataLength*: DWORD DataOffset*: DWORD - TEVENTLOGRECORD* = EVENTLOGRECORD PEVENTLOGRECORD* = ptr EVENTLOGRECORD EVENTMSG* {.final, pure.} = object message*: WINUINT @@ -9552,7 +9342,6 @@ type time*: DWORD hwnd*: HWND - TEVENTMSG* = EVENTMSG PEVENTMSG* = ptr EVENTMSG EXCEPTION_POINTERS* {.final, pure.} = object ExceptionRecord*: PEXCEPTION_RECORD @@ -9560,14 +9349,12 @@ type LPEXCEPTION_POINTERS* = ptr EXCEPTION_POINTERS PEXCEPTION_POINTERS* = ptr EXCEPTION_POINTERS - TEXCEPTIONPOINTERS* = EXCEPTION_POINTERS EXT_BUTTON* {.final, pure.} = object idCommand*: int16 idsHelp*: int16 fsStyle*: int16 LPEXT_BUTTON* = ptr EXT_BUTTON - TEXTBUTTON* = EXT_BUTTON PEXTBUTTON* = ptr EXT_BUTTON FILTERKEYS* {.final, pure.} = object cbSize*: WINUINT @@ -9577,7 +9364,6 @@ type iRepeatMSec*: DWORD iBounceMSec*: DWORD - TFILTERKEYS* = FILTERKEYS PFILTERKEYS* = ptr FILTERKEYS FIND_NAME_BUFFER* {.final, pure.} = object len*: UCHAR @@ -9587,14 +9373,12 @@ type source_addr*: array[0..5, UCHAR] routing_info*: array[0..17, UCHAR] - TFINDNAMEBUFFER* = FIND_NAME_BUFFER PFINDNAMEBUFFER* = ptr FIND_NAME_BUFFER FIND_NAME_HEADER* {.final, pure.} = object node_count*: int16 reserved*: UCHAR unique_group*: UCHAR - TFINDNAMEHEADER* = FIND_NAME_HEADER PFINDNAMEHEADER* = ptr FIND_NAME_HEADER FINDREPLACE* {.final, pure.} = object lStructSize*: DWORD @@ -9610,7 +9394,6 @@ type lpTemplateName*: LPCTSTR LPFINDREPLACE* = ptr FINDREPLACE - TFINDREPLACE* = FINDREPLACE PFINDREPLACE* = ptr FINDREPLACE #FINDTEXT = record conflicts with FindText function TFINDTEXT* {.final, pure.} = object @@ -9623,32 +9406,28 @@ type lpstrText*: LPSTR chrgText*: CHARRANGE - Tfindtextex* = FINDTEXTEX Pfindtextex* = ptr FINDTEXTEX FMS_GETDRIVEINFO* {.final, pure.} = object dwTotalSpace*: DWORD dwFreeSpace*: DWORD - szPath*: array[0..259, TCHAR] - szVolume*: array[0..13, TCHAR] - szShare*: array[0..127, TCHAR] + szPath*: array[0..259, CHAR] + szVolume*: array[0..13, CHAR] + szShare*: array[0..127, CHAR] - TFMSGETDRIVEINFO* = FMS_GETDRIVEINFO PFMSGETDRIVEINFO* = ptr FMS_GETDRIVEINFO FMS_GETFILESEL* {.final, pure.} = object ftTime*: FILETIME dwSize*: DWORD bAttr*: int8 - szName*: array[0..259, TCHAR] + szName*: array[0..259, CHAR] - TFMSGETFILESEL* = FMS_GETFILESEL PFMSGETFILESEL* = ptr FMS_GETFILESEL FMS_LOAD* {.final, pure.} = object dwSize*: DWORD - szMenuName*: array[0..(MENU_TEXT_LEN) - 1, TCHAR] + szMenuName*: array[0..(MENU_TEXT_LEN) - 1, CHAR] hMenu*: HMENU wMenuDelta*: WINUINT - TFMSLOAD* = FMS_LOAD PFMSLOAD* = ptr FMS_LOAD FMS_TOOLBARLOAD* {.final, pure.} = object dwSize*: DWORD @@ -9658,12 +9437,10 @@ type idBitmap*: int16 hBitmap*: HBITMAP - TFMSTOOLBARLOAD* = FMS_TOOLBARLOAD PFMSTOOLBARLOAD* = ptr FMS_TOOLBARLOAD FOCUS_EVENT_RECORD* {.final, pure.} = object bSetFocus*: WINBOOL - TFOCUSEVENTRECORD* = FOCUS_EVENT_RECORD PFOCUSEVENTRECORD* = ptr FOCUS_EVENT_RECORD FORM_INFO_1* {.final, pure.} = object Flags*: DWORD @@ -9671,7 +9448,6 @@ type Size*: SIZEL ImageableArea*: RECTL - TFORMINFO1* = FORM_INFO_1 PFORMINFO1* = ptr FORM_INFO_1 FORMAT_PARAMETERS* {.final, pure.} = object MediaType*: MEDIA_TYPE @@ -9680,7 +9456,6 @@ type StartHeadNumber*: DWORD EndHeadNumber*: DWORD - TFORMATPARAMETERS* = FORMAT_PARAMETERS PFORMATPARAMETERS* = ptr FORMAT_PARAMETERS FORMATRANGE* {.final, pure.} = object hdc*: HDC @@ -9689,7 +9464,6 @@ type rcPage*: RECT chrg*: CHARRANGE - Tformatrange* = FORMATRANGE Pformatrange* = ptr FORMATRANGE GCP_RESULTS* {.final, pure.} = object lStructSize*: DWORD @@ -9703,7 +9477,6 @@ type nMaxFit*: WINUINT LPGCP_RESULTS* = ptr GCP_RESULTS - TGCPRESULTS* = GCP_RESULTS PGCPRESULTS* = ptr GCP_RESULTS GENERIC_MAPPING* {.final, pure.} = object GenericRead*: ACCESS_MASK @@ -9712,7 +9485,6 @@ type GenericAll*: ACCESS_MASK PGENERIC_MAPPING* = ptr GENERIC_MAPPING - TGENERICMAPPING* = GENERIC_MAPPING GLYPHMETRICS* {.final, pure.} = object gmBlackBoxX*: WINUINT gmBlackBoxY*: WINUINT @@ -9721,19 +9493,16 @@ type gmCellIncY*: SHORT LPGLYPHMETRICS* = ptr GLYPHMETRICS - TGLYPHMETRICS* = GLYPHMETRICS PGLYPHMETRICS* = ptr GLYPHMETRICS HANDLETABLE* {.final, pure.} = object objectHandle*: array[0..0, HGDIOBJ] - THANDLETABLE* = HANDLETABLE LPHANDLETABLE* = ptr HANDLETABLE HD_HITTESTINFO* {.final, pure.} = object pt*: POINT flags*: WINUINT iItem*: int32 - THDHITTESTINFO* = HD_HITTESTINFO PHDHITTESTINFO* = ptr HD_HITTESTINFO HD_ITEM* {.final, pure.} = object mask*: WINUINT @@ -9744,7 +9513,6 @@ type fmt*: int32 lParam*: LPARAM - THDITEM* = HD_ITEM PHDITEM* = ptr HD_ITEM WINDOWPOS* {.final, pure.} = object hwnd*: HWND @@ -9756,13 +9524,11 @@ type flags*: WINUINT LPWINDOWPOS* = ptr WINDOWPOS - TWINDOWPOS* = WINDOWPOS PWINDOWPOS* = ptr WINDOWPOS HD_LAYOUT* {.final, pure.} = object prc*: ptr RECT pwpos*: ptr WINDOWPOS - THDLAYOUT* = HD_LAYOUT PHDLAYOUT* = ptr HD_LAYOUT HD_NOTIFY* {.final, pure.} = object hdr*: NMHDR @@ -9770,7 +9536,6 @@ type iButton*: int32 pitem*: ptr HD_ITEM - THDNOTIFY* = HD_NOTIFY PHDNOTIFY* = ptr HD_NOTIFY HELPINFO* {.final, pure.} = object cbSize*: WINUINT @@ -9781,7 +9546,6 @@ type MousePos*: POINT LPHELPINFO* = ptr HELPINFO - THELPINFO* = HELPINFO PHELPINFO* = ptr HELPINFO HELPWININFO* {.final, pure.} = object wStructSize*: int32 @@ -9790,9 +9554,8 @@ type dx*: int32 dy*: int32 wMax*: int32 - rgchMember*: array[0..1, TCHAR] + rgchMember*: array[0..1, CHAR] - THELPWININFO* = HELPWININFO PHELPWININFO* = ptr HELPWININFO HIGHCONTRAST* {.final, pure.} = object cbSize*: WINUINT @@ -9800,13 +9563,11 @@ type lpszDefaultScheme*: LPTSTR LPHIGHCONTRAST* = ptr HIGHCONTRAST - THIGHCONTRAST* = HIGHCONTRAST PHIGHCONTRAST* = ptr HIGHCONTRAST HSZPAIR* {.final, pure.} = object hszSvc*: HSZ hszTopic*: HSZ - THSZPAIR* = HSZPAIR PHSZPAIR* = ptr HSZPAIR ICONINFO* {.final, pure.} = object fIcon*: WINBOOL @@ -9815,7 +9576,6 @@ type hbmMask*: HBITMAP hbmColor*: HBITMAP - TICONINFO* = ICONINFO PICONINFO* = ptr ICONINFO ICONMETRICS* {.final, pure.} = object cbSize*: WINUINT @@ -9825,7 +9585,6 @@ type lfFont*: LOGFONT LPICONMETRICS* = ptr ICONMETRICS - TICONMETRICS* = ICONMETRICS PICONMETRICS* = ptr ICONMETRICS IMAGEINFO* {.final, pure.} = object hbmImage*: HBITMAP @@ -9834,7 +9593,6 @@ type Unused2*: int32 rcImage*: RECT - TIMAGEINFO* = IMAGEINFO PIMAGEINFO* = ptr IMAGEINFO KEY_EVENT_RECORD* {.final, pure.} = object bKeyDown*: WINBOOL @@ -9844,7 +9602,6 @@ type UnicodeChar*: WCHAR dwControlKeyState*: DWORD # other union part: AsciiChar: CHAR - TKEYEVENTRECORD* = KEY_EVENT_RECORD PKEYEVENTRECORD* = ptr KEY_EVENT_RECORD MOUSE_EVENT_RECORD* {.final, pure.} = object dwMousePosition*: COORD @@ -9852,25 +9609,21 @@ type dwControlKeyState*: DWORD dwEventFlags*: DWORD - TMOUSEEVENTRECORD* = MOUSE_EVENT_RECORD PMOUSEEVENTRECORD* = ptr MOUSE_EVENT_RECORD WINDOW_BUFFER_SIZE_RECORD* {.final, pure.} = object dwSize*: COORD - TWINDOWBUFFERSIZERECORD* = WINDOW_BUFFER_SIZE_RECORD PWINDOWBUFFERSIZERECORD* = ptr WINDOW_BUFFER_SIZE_RECORD MENU_EVENT_RECORD* {.final, pure.} = object dwCommandId*: WINUINT PMENU_EVENT_RECORD* = ptr MENU_EVENT_RECORD - TMENUEVENTRECORD* = MENU_EVENT_RECORD INPUT_RECORD* {.final, pure.} = object EventType*: int16 Reserved*: int16 event*: array[0..5, DWORD] PINPUT_RECORD* = ptr INPUT_RECORD - TINPUTRECORD* = INPUT_RECORD SYSTEMTIME* {.final, pure.} = object wYear*: int16 wMonth*: int16 @@ -9882,7 +9635,6 @@ type wMilliseconds*: int16 LPSYSTEMTIME* = ptr SYSTEMTIME - TSYSTEMTIME* = SYSTEMTIME PSYSTEMTIME* = ptr SYSTEMTIME JOB_INFO_1* {.final, pure.} = object JobId*: DWORD @@ -9899,25 +9651,21 @@ type PagesPrinted*: DWORD Submitted*: SYSTEMTIME - TJOBINFO1* = JOB_INFO_1 PJOBINFO1* = ptr JOB_INFO_1 SID_IDENTIFIER_AUTHORITY* {.final, pure.} = object Value*: array[0..5, int8] LPSID_IDENTIFIER_AUTHORITY* = ptr SID_IDENTIFIER_AUTHORITY PSID_IDENTIFIER_AUTHORITY* = ptr SID_IDENTIFIER_AUTHORITY - TSIDIDENTIFIERAUTHORITY* = SID_IDENTIFIER_AUTHORITY SID* {.final, pure.} = object Revision*: int8 SubAuthorityCount*: int8 IdentifierAuthority*: SID_IDENTIFIER_AUTHORITY SubAuthority*: array[0..(ANYSIZE_ARRAY) - 1, DWORD] - TSID* = SID PSID* = ptr SID SECURITY_DESCRIPTOR_CONTROL* = int16 PSECURITY_DESCRIPTOR_CONTROL* = ptr SECURITY_DESCRIPTOR_CONTROL - TSECURITYDESCRIPTORCONTROL* = SECURITY_DESCRIPTOR_CONTROL SECURITY_DESCRIPTOR* {.final, pure.} = object Revision*: int8 Sbz1*: int8 @@ -9928,7 +9676,6 @@ type Dacl*: PACL PSECURITY_DESCRIPTOR* = ptr SECURITY_DESCRIPTOR - TSECURITYDESCRIPTOR* = SECURITY_DESCRIPTOR JOB_INFO_2* {.final, pure.} = object JobId*: DWORD pPrinterName*: LPTSTR @@ -9954,7 +9701,6 @@ type Time*: DWORD PagesPrinted*: DWORD - TJOBINFO2* = JOB_INFO_2 PJOBINFO2* = ptr JOB_INFO_2 KERNINGPAIR* {.final, pure.} = object wFirst*: int16 @@ -9968,7 +9714,6 @@ type len*: UCHAR lana*: array[0..(MAX_LANA) - 1, UCHAR] - TLANAENUM* = LANA_ENUM PLANAENUM* = ptr LANA_ENUM LDT_ENTRY* {.final, pure.} = object LimitLow*: int16 @@ -9980,7 +9725,88 @@ type LPLDT_ENTRY* = ptr LDT_ENTRY PLDT_ENTRY* = ptr LDT_ENTRY - TLDTENTRY* = LDT_ENTRY + +{.deprecated: [TEXCEPTIONRECORD: EXCEPTION_RECORD, TEXCEPTIONDEBUGINFO: EXCEPTION_DEBUG_INFO, + TExceptionRecord32: EXCEPTION_RECORD32, TExceptionDebugInfo32: EXCEPTION_DEBUG_INFO32, + TExceptionRecord64: EXCEPTION_RECORD64, TExceptionDebugInfo64: EXCEPTION_DEBUG_INFO64, + TEXITPROCESSDEBUGINFO: EXIT_PROCESS_DEBUG_INFO, TEXITTHREADDEBUGINFO: EXIT_THREAD_DEBUG_INFO, + TLOADDLLDEBUGINFO: LOAD_DLL_DEBUG_INFO, TUNLOADDLLDEBUGINFO: UNLOAD_DLL_DEBUG_INFO, + TOUTPUTDEBUGSTRINGINFO: OUTPUT_DEBUG_STRING_INFO, TRIPINFO: RIP_INFO, TDEBUGEVENT: DEBUG_EVENT, + TDEBUGHOOKINFO: DEBUGHOOKINFO, TDELETEITEMSTRUCT: DELETEITEMSTRUCT, TDEVBROADCASTHDR: DEV_BROADCAST_HDR, + TDEVBROADCASTOEM: DEV_BROADCAST_OEM, TDEVBROADCASTPORT: DEV_BROADCAST_PORT, + TDEVBROADCASTUSERDEFINED: DEV_BROADCAST_USERDEFINED, TDEVBROADCASTVOLUME: DEV_BROADCAST_VOLUME, + TDevicemode: DEVMODE, TDevicemodeA: DEVMODE, TDEVMODE: DEVMODE, TDEVNAMES: DEVNAMES, TDEVMODEW: DEVMODEW, + TDeviceModeW: DEVMODEW, TDIBSECTION: DIBSECTION, TLargeInteger: LargeInteger, + TULargeInteger: ULargeInteger, TDISKPERFORMANCE: DISK_PERFORMANCE, TDISKGEOMETRY: DISK_GEOMETRY, + TDOCINFO1: DOC_INFO_1, TDLGTEMPLATE: DLGTEMPLATE, TDLGITEMTEMPLATE: DLGITEMTEMPLATE, + TDRAWTEXTPARAMS: DRAWTEXTPARAMS, TDRAWITEMSTRUCT: DRAWITEMSTRUCT, TDRAGLISTINFO: DRAGLISTINFO, + TDOCINFO: DOCINFO, TDOCINFOA: DOCINFO, TDOCINFO2: DOC_INFO_2, TPARTITIONINFORMATION: PARTITION_INFORMATION, + TDRIVELAYOUTINFORMATION: DRIVE_LAYOUT_INFORMATION, TEMRARC: EMRARC, TEMRANGLEARC: EMRANGLEARC, + TEMR: EMR, Teditstream: EDITSTREAM, TDRIVERINFO3: DRIVER_INFO_3, TDRIVERINFO2: DRIVER_INFO_2, + TDRIVERINFO1: DRIVER_INFO_1, TEMREXTCREATEFONTINDIRECTW: EMREXTCREATEFONTINDIRECTW].} + +{.deprecated: [TEXTLOGFONT: EXTLOGFONT, TPANOSE: PANOSE, TEMRINTERSECTCLIPRECT: EMREXCLUDECLIPRECT, + TEMREXCLUDECLIPRECT: EMREXCLUDECLIPRECT, TEMREOF: EMREOF, TEMRRECTANGLE: EMRELLIPSE, + TEMRELLIPSE: EMRELLIPSE, TEMRCREATEPEN: EMRCREATEPEN, TLOGPEN: LOGPEN, TEMRCREATEPALETTE: EMRCREATEPALETTE, + TLOGPALETTE: LOGPALETTE, TPALETTEENTRY: PALETTEENTRY, TEMRCREATEMONOBRUSH: EMRCREATEMONOBRUSH, + TEMRCREATEDIBPATTERNBRUSHPT: EMRCREATEDIBPATTERNBRUSHPT, TEMRCREATECOLORSPACE: EMRCREATECOLORSPACE, + TLOGCOLORSPACE: LOGCOLORSPACE, TLOGCOLORSPACEA: LOGCOLORSPACE, TEMRCREATEBRUSHINDIRECT: EMRCREATEBRUSHINDIRECT, + TLOGBRUSH: LOGBRUSH, TEMRBITBLT: EMRBITBLT, TXFORM: XFORM, TEMRPIE: EMRARC, TEMRCHORD: EMRARC, + TEMRARCTO: EMRARC, TSERVICESTATUS: SERVICE_STATUS, TENUMSERVICESTATUS: ENUM_SERVICE_STATUS, + TENUMLOGFONT: ENUMLOGFONT, TENUMLOGFONTEX: ENUMLOGFONTEX, TEVENTLOGRECORD: EVENTLOGRECORD, + TEVENTMSG: EVENTMSG, TEXCEPTIONPOINTERS: EXCEPTION_POINTERS, TEXTBUTTON: EXT_BUTTON, + TFILTERKEYS: FILTERKEYS, TFINDNAMEBUFFER: FIND_NAME_BUFFER, TFINDNAMEHEADER: FIND_NAME_HEADER, + TFINDREPLACE: FINDREPLACE, Tfindtextex: FINDTEXTEX, TFMSGETDRIVEINFO: FMS_GETDRIVEINFO, + TFMSGETFILESEL: FMS_GETFILESEL, TFMSLOAD: FMS_LOAD, TFMSTOOLBARLOAD: FMS_TOOLBARLOAD, + TFOCUSEVENTRECORD: FOCUS_EVENT_RECORD, TFORMINFO1: FORM_INFO_1, TFORMATPARAMETERS: FORMAT_PARAMETERS, + Tformatrange: FORMATRANGE, TGCPRESULTS: GCP_RESULTS, TGENERICMAPPING: GENERIC_MAPPING, + TGLYPHMETRICS: GLYPHMETRICS, THANDLETABLE: HANDLETABLE, THDHITTESTINFO: HD_HITTESTINFO, + THDITEM: HD_ITEM, TWINDOWPOS: WINDOWPOS, THDLAYOUT: HD_LAYOUT, THDNOTIFY: HD_NOTIFY, + THELPINFO: HELPINFO, THELPWININFO: HELPWININFO, THIGHCONTRAST: HIGHCONTRAST, THSZPAIR: HSZPAIR, + TICONINFO: ICONINFO, TICONMETRICS: ICONMETRICS, TIMAGEINFO: IMAGEINFO, TKEYEVENTRECORD: KEY_EVENT_RECORD, + TMOUSEEVENTRECORD: MOUSE_EVENT_RECORD, TWINDOWBUFFERSIZERECORD: WINDOW_BUFFER_SIZE_RECORD, + TMENUEVENTRECORD: MENU_EVENT_RECORD, TINPUTRECORD: INPUT_RECORD, TSYSTEMTIME: SYSTEMTIME, + TJOBINFO1: JOB_INFO_1].} + +{.deprecated: [TSIDIDENTIFIERAUTHORITY: SID_IDENTIFIER_AUTHORITY, TSID: SID, + TSECURITYDESCRIPTORCONTROL: SECURITY_DESCRIPTOR_CONTROL, TSECURITYDESCRIPTOR: SECURITY_DESCRIPTOR, + TJOBINFO2: JOB_INFO_2, TLANAENUM: LANA_ENUM, TLDTENTRY: LDT_ENTRY, TEMRPOLYPOLYGON: EMRPOLYPOLYLINE, + TEMRPOLYPOLYLINE: EMRPOLYPOLYLINE, TEMRPOLYLINETO16: EMRPOLYLINE16, TEMRPOLYBEZIERTO16: EMRPOLYLINE16, + TEMRPOLYGON16: EMRPOLYLINE16, TEMRPOLYBEZIER16: EMRPOLYLINE16, TEMRPOLYLINE16: EMRPOLYLINE16, + TEMRPOLYLINETO: EMRPOLYLINE, TEMRPOLYBEZIERTO: EMRPOLYLINE, TEMRPOLYGON: EMRPOLYLINE, + TEMRPOLYBEZIER: EMRPOLYLINE, TEMRPOLYLINE: EMRPOLYLINE, TEMRPOLYDRAW16: EMRPOLYDRAW16, + TEMRPOLYDRAW: EMRPOLYDRAW, TEMRPLGBLT: EMRPLGBLT, TEMROFFSETCLIPRGN: EMROFFSETCLIPRGN, + TEMRMODIFYWORLDTRANSFORM: EMRMODIFYWORLDTRANSFORM, TEMRMASKBLT: EMRMASKBLT, TEMRMOVETOEX: EMRLINETO, + TEMRLINETO: EMRLINETO, TEMRPAINTRGN: EMRINVERTRGN, TEMRINVERTRGN: EMRINVERTRGN, + TEMRGDICOMMENT: EMRGDICOMMENT, TEMRFRAMERGN: EMRFRAMERGN, TEMRFORMAT: EMRFORMAT, TEMRFILLRGN: EMRFILLRGN, + TEMRSTROKEPATH: EMRFILLPATH, TEMRSTROKEANDFILLPATH: EMRFILLPATH, TEMRFILLPATH: EMRFILLPATH, + TEMREXTTEXTOUTW: EMREXTTEXTOUTA, TEMREXTTEXTOUTA: EMREXTTEXTOUTA, TEMRTEXT: EMRTEXT, + TEMREXTSELECTCLIPRGN: EMREXTSELECTCLIPRGN, TEMREXTFLOODFILL: EMREXTFLOODFILL, + TEMREXTCREATEPEN: EMREXTCREATEPEN, TEXTLOGPEN: EXTLOGPEN, TNMHDR: NMHDR, TEMRENABLEICM: EMRSELECTCLIPPATH, + TEMRSETTEXTALIGN: EMRSELECTCLIPPATH, TEMRSETSTRETCHBLTMODE: EMRSELECTCLIPPATH, + TEMRSETROP2: EMRSELECTCLIPPATH, TEMRSETPOLYFILLMODE: EMRSELECTCLIPPATH, TEMRSETMAPMODE: EMRSELECTCLIPPATH, + TEMRSETBKMODE: EMRSELECTCLIPPATH, TEMRSELECTCLIPPATH: EMRSELECTCLIPPATH, TEMRREALIZEPALETTE: EMRABORTPATH, + TEMRSAVEDC: EMRABORTPATH, TEMRSETMETARGN: EMRABORTPATH, TEMRWIDENPATH: EMRABORTPATH].} + +{.deprecated: [TEMRFLATTENPATH: EMRABORTPATH, TEMRCLOSEFIGURE: EMRABORTPATH, TEMRENDPATH: EMRABORTPATH, + TEMRBEGINPATH: EMRABORTPATH, TABORTPATH: EMRABORTPATH, TEMRABORTPATH: EMRABORTPATH, + TEMRSTRETCHDIBITS: EMRSTRETCHDIBITS, TEMRSTRETCHBLT: EMRSTRETCHBLT, + TEMRSETWORLDTRANSFORM: EMRSETWORLDTRANSFORM, TEMRSETBRUSHORGEX: EMRSETVIEWPORTORGEX, + TEMRSETWINDOWORGEX: EMRSETVIEWPORTORGEX, TEMRSETVIEWPORTORGEX: EMRSETVIEWPORTORGEX, + TEMRSETWINDOWEXTEX: EMRSETVIEWPORTEXTEX, TEMRSETVIEWPORTEXTEX: EMRSETVIEWPORTEXTEX, + TEMRSETPIXELV: EMRSETPIXELV, TEMRSETPALETTEENTRIES: EMRSETPALETTEENTRIES, + TEMRSETMITERLIMIT: EMRSETMITERLIMIT, TEMRSETMAPPERFLAGS: EMRSETMAPPERFLAGS, + TEMRSETDIBITSTODEVICE: EMRSETDIBITSTODEVICE, TEMRSETCOLORADJUSTMENT: EMRSETCOLORADJUSTMENT, + TEMRSETTEXTCOLOR: EMRSETBKCOLOR, TEMRSETBKCOLOR: EMRSETBKCOLOR, TEMRSETARCDIRECTION: EMRSETARCDIRECTION, + TEMRSELECTPALETTE: EMRSELECTPALETTE, TEMRDELETEOBJECT: EMRSELECTOBJECT, TEMRSELECTOBJECT: EMRSELECTOBJECT, + TEMRDELETECOLORSPACE: EMRSELECTCOLORSPACE, TEMRSELECTCOLORSPACE: EMRSELECTCOLORSPACE, + TEMRSCALEWINDOWEXTEX: EMRSCALEVIEWPORTEXTEX, TEMRSCALEVIEWPORTEXTEX: EMRSCALEVIEWPORTEXTEX, + TEMRROUNDRECT: EMRROUNDRECT, TEMRRESTOREDC: EMRRESTOREDC, TEMRRESIZEPALETTE: EMRRESIZEPALETTE, + TEMRPOLYTEXTOUTW: EMRPOLYTEXTOUTA, TEMRPOLYTEXTOUTA: EMRPOLYTEXTOUTA, + TEMRPOLYPOLYGON16: EMRPOLYPOLYLINE16, TEMRPOLYPOLYLINE16: EMRPOLYPOLYLINE16, + TENHMETAHEADER: ENHMETAHEADER, TENHMETARECORD: ENHMETARECORD].} + + const bm_LDT_ENTRY_BaseMid* = 0x000000FF @@ -10010,34 +9836,27 @@ type lsCsbDefault*: array[0..1, DWORD] lsCsbSupported*: array[0..1, DWORD] - TLOCALESIGNATURE* = LOCALESIGNATURE PLOCALESIGNATURE* = ptr LOCALESIGNATURE LOCALGROUP_MEMBERS_INFO_0* {.final, pure.} = object lgrmi0_sid*: PSID - TLOCALGROUPMEMBERSINFO0* = LOCALGROUP_MEMBERS_INFO_0 PLOCALGROUPMEMBERSINFO0* = ptr LOCALGROUP_MEMBERS_INFO_0 LOCALGROUP_MEMBERS_INFO_3* {.final, pure.} = object lgrmi3_domainandname*: LPWSTR - TLOCALGROUPMEMBERSINFO3* = LOCALGROUP_MEMBERS_INFO_3 PLOCALGROUPMEMBERSINFO3* = ptr LOCALGROUP_MEMBERS_INFO_3 FXPT16DOT16* = int32 LPFXPT16DOT16* = ptr FXPT16DOT16 - TFXPT16DOT16* = FXPT16DOT16 PFXPT16DOT16* = ptr FXPT16DOT16 - LUID* = TlargeInteger - TLUID* = LUID + LUID* = LargeInteger PLUID* = ptr LUID LUID_AND_ATTRIBUTES* {.final, pure.} = object Luid*: LUID Attributes*: DWORD - TLUIDANDATTRIBUTES* = LUID_AND_ATTRIBUTES PLUIDANDATTRIBUTES* = ptr LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY* = array[0..(ANYSIZE_ARRAY) - 1, LUID_AND_ATTRIBUTES] PLUID_AND_ATTRIBUTES_ARRAY* = ptr LUID_AND_ATTRIBUTES_ARRAY - TLUIDANDATTRIBUTESARRAY* = LUID_AND_ATTRIBUTES_ARRAY LV_COLUMN* {.final, pure.} = object mask*: WINUINT fmt*: int32 @@ -10046,7 +9865,6 @@ type cchTextMax*: int32 iSubItem*: int32 - TLVCOLUMN* = LV_COLUMN PLVCOLUMN* = ptr LV_COLUMN LV_ITEM* {.final, pure.} = object mask*: WINUINT @@ -10059,13 +9877,11 @@ type iImage*: int32 lParam*: LPARAM - TLVITEM* = LV_ITEM PLVITEM* = ptr LV_ITEM LV_DISPINFO* {.final, pure.} = object hdr*: NMHDR item*: LV_ITEM - TLVDISPINFO* = LV_DISPINFO PLVDISPINFO* = ptr LV_DISPINFO LV_FINDINFO* {.final, pure.} = object flags*: WINUINT @@ -10074,21 +9890,18 @@ type pt*: POINT vkDirection*: WINUINT - TLVFINDINFO* = LV_FINDINFO PLVFINDINFO* = ptr LV_FINDINFO LV_HITTESTINFO* {.final, pure.} = object pt*: POINT flags*: WINUINT iItem*: int32 - TLVHITTESTINFO* = LV_HITTESTINFO PLVHITTESTINFO* = ptr LV_HITTESTINFO LV_KEYDOWN* {.final, pure.} = object hdr*: NMHDR wVKey*: int16 flags*: WINUINT - TLVKEYDOWN* = LV_KEYDOWN PLVKEYDOWN* = ptr LV_KEYDOWN MAT2* {.final, pure.} = object eM11*: FIXED @@ -10096,7 +9909,6 @@ type eM21*: FIXED eM22*: FIXED - TMAT2* = MAT2 PMAT2* = ptr MAT2 MDICREATESTRUCT* {.final, pure.} = object szClass*: LPCTSTR @@ -10110,7 +9922,6 @@ type lParam*: LPARAM LPMDICREATESTRUCT* = ptr MDICREATESTRUCT - TMDICREATESTRUCT* = MDICREATESTRUCT PMDICREATESTRUCT* = ptr MDICREATESTRUCT MEASUREITEMSTRUCT* {.final, pure.} = object CtlType*: WINUINT @@ -10121,7 +9932,6 @@ type itemData*: ULONG_PTR LPMEASUREITEMSTRUCT* = ptr MEASUREITEMSTRUCT - TMEASUREITEMSTRUCT* = MEASUREITEMSTRUCT PMEASUREITEMSTRUCT* = ptr MEASUREITEMSTRUCT MEMORY_BASIC_INFORMATION* {.final, pure.} = object BaseAddress*: PVOID @@ -10133,7 +9943,6 @@ type `type`*: DWORD PMEMORY_BASIC_INFORMATION* = ptr MEMORY_BASIC_INFORMATION - TMEMORYBASICINFORMATION* = MEMORY_BASIC_INFORMATION MEMORYSTATUS* {.final, pure.} = object dwLength*: DWORD dwMemoryLoad*: DWORD @@ -10144,21 +9953,19 @@ type dwTotalVirtual*: int dwAvailVirtual*: int - TGUID* {.final, pure.} = object + GUID* {.final, pure.} = object D1*: int32 D2*: int16 D3*: int16 D4*: array [0..7, int8] LPMEMORYSTATUS* = ptr MEMORYSTATUS - TMEMORYSTATUS* = MEMORYSTATUS PMEMORYSTATUS* = ptr MEMORYSTATUS MENUEX_TEMPLATE_HEADER* {.final, pure.} = object wVersion*: int16 wOffset*: int16 dwHelpId*: DWORD - TMENUXTEMPLATEHEADER* = MENUEX_TEMPLATE_HEADER PMENUXTEMPLATEHEADER* = ptr MENUEX_TEMPLATE_HEADER MENUEX_TEMPLATE_ITEM* {.final, pure.} = object dwType*: DWORD @@ -10168,7 +9975,6 @@ type szText*: array[0..0, WCHAR] dwHelpId*: DWORD - TMENUEXTEMPLATEITEM* = MENUEX_TEMPLATE_ITEM PMENUEXTEMPLATEITEM* = ptr MENUEX_TEMPLATE_ITEM MENUINFO* {.final, pure.} = object cbSize*: DWORD @@ -10181,7 +9987,6 @@ type LPMENUINFO* = ptr MENUINFO LPCMENUINFO* = ptr MENUINFO - TMENUINFO* = MENUINFO PMENUINFO* = ptr MENUINFO MENUITEMINFO* {.final, pure.} = object cbSize*: WINUINT @@ -10199,25 +10004,20 @@ type LPMENUITEMINFO* = ptr MENUITEMINFO LPCMENUITEMINFO* = ptr MENUITEMINFO - TMENUITEMINFO* = MENUITEMINFO - TMENUITEMINFOA* = MENUITEMINFO PMENUITEMINFO* = ptr MENUITEMINFO MENUITEMTEMPLATE* {.final, pure.} = object mtOption*: int16 mtID*: int16 mtString*: array[0..0, WCHAR] - TMENUITEMTEMPLATE* = MENUITEMTEMPLATE PMENUITEMTEMPLATE* = ptr MENUITEMTEMPLATE MENUITEMTEMPLATEHEADER* {.final, pure.} = object versionNumber*: int16 offset*: int16 - TMENUITEMTEMPLATEHEADER* = MENUITEMTEMPLATEHEADER PMENUITEMTEMPLATEHEADER* = ptr MENUITEMTEMPLATEHEADER MENUTEMPLATE* {.final, pure.} = object LPMENUTEMPLATE* = ptr MENUTEMPLATE - TMENUTEMPLATE* = MENUTEMPLATE PMENUTEMPLATE* = ptr MENUTEMPLATE METAFILEPICT* {.final, pure.} = object mm*: LONG @@ -10226,7 +10026,6 @@ type hMF*: HMETAFILE LPMETAFILEPICT* = ptr METAFILEPICT - TMETAFILEPICT* = METAFILEPICT PMETAFILEPICT* = ptr METAFILEPICT METAHEADER* {.final, pure.} = object mtType*: int16 @@ -10237,7 +10036,6 @@ type mtMaxRecord*: DWORD mtNoParameters*: int16 - TMETAHEADER* = METAHEADER PMETAHEADER* = ptr METAHEADER METARECORD* {.final, pure.} = object rdSize*: DWORD @@ -10245,7 +10043,6 @@ type rdParm*: array[0..0, int16] LPMETARECORD* = ptr METARECORD - TMETARECORD* = METARECORD PMETARECORD* = ptr METARECORD MINIMIZEDMETRICS* {.final, pure.} = object cbSize*: WINUINT @@ -10255,7 +10052,6 @@ type iArrange*: int32 LPMINIMIZEDMETRICS* = ptr MINIMIZEDMETRICS - TMINIMIZEDMETRICS* = MINIMIZEDMETRICS PMINIMIZEDMETRICS* = ptr MINIMIZEDMETRICS MINMAXINFO* {.final, pure.} = object ptReserved*: POINT @@ -10264,7 +10060,6 @@ type ptMinTrackSize*: POINT ptMaxTrackSize*: POINT - TMINMAXINFO* = MINMAXINFO PMINMAXINFO* = ptr MINMAXINFO MODEMDEVCAPS* {.final, pure.} = object dwActualSize*: DWORD @@ -10289,7 +10084,6 @@ type abVariablePortion*: array[0..0, int8] LPMODEMDEVCAPS* = ptr MODEMDEVCAPS - TMODEMDEVCAPS* = MODEMDEVCAPS PMODEMDEVCAPS* = ptr MODEMDEVCAPS MODEMSETTINGS* {.final, pure.} = object dwActualSize*: DWORD @@ -10306,7 +10100,6 @@ type abVariablePortion*: array[0..0, int8] LPMODEMSETTINGS* = ptr MODEMSETTINGS - TMODEMSETTINGS* = MODEMSETTINGS PMODEMSETTINGS* = ptr MODEMSETTINGS MONCBSTRUCT* {.final, pure.} = object cb*: WINUINT @@ -10325,7 +10118,6 @@ type cbData*: DWORD Data*: array[0..7, DWORD] - TMONCBSTRUCT* = MONCBSTRUCT PMONCBSTRUCT* = ptr MONCBSTRUCT MONCONVSTRUCT* {.final, pure.} = object cb*: WINUINT @@ -10337,7 +10129,6 @@ type hConvClient*: HCONV hConvServer*: HCONV - TMONCONVSTRUCT* = MONCONVSTRUCT PMONCONVSTRUCT* = ptr MONCONVSTRUCT MONERRSTRUCT* {.final, pure.} = object cb*: WINUINT @@ -10345,7 +10136,6 @@ type dwTime*: DWORD hTask*: HANDLE - TMONERRSTRUCT* = MONERRSTRUCT PMONERRSTRUCT* = ptr MONERRSTRUCT MONHSZSTRUCT* {.final, pure.} = object cb*: WINUINT @@ -10353,21 +10143,18 @@ type dwTime*: DWORD hsz*: HSZ hTask*: HANDLE - str*: array[0..0, TCHAR] + str*: array[0..0, CHAR] - TMONHSZSTRUCT* = MONHSZSTRUCT PMONHSZSTRUCT* = ptr MONHSZSTRUCT MONITOR_INFO_1* {.final, pure.} = object pName*: LPTSTR - TMONITORINFO1* = MONITOR_INFO_1 PMONITORINFO1* = ptr MONITOR_INFO_1 MONITOR_INFO_2* {.final, pure.} = object pName*: LPTSTR pEnvironment*: LPTSTR pDLLName*: LPTSTR - TMONITORINFO2* = MONITOR_INFO_2 PMONITORINFO2* = ptr MONITOR_INFO_2 MONLINKSTRUCT* {.final, pure.} = object cb*: WINUINT @@ -10383,7 +10170,6 @@ type hConvServer*: HCONV hConvClient*: HCONV - TMONLINKSTRUCT* = MONLINKSTRUCT PMONLINKSTRUCT* = ptr MONLINKSTRUCT MONMSGSTRUCT* {.final, pure.} = object cb*: WINUINT @@ -10395,7 +10181,6 @@ type lParam*: LPARAM dmhd*: DDEML_MSG_HOOK_DATA - TMONMSGSTRUCT* = MONMSGSTRUCT PMONMSGSTRUCT* = ptr MONMSGSTRUCT MOUSEHOOKSTRUCT* {.final, pure.} = object pt*: POINT @@ -10404,7 +10189,6 @@ type dwExtraInfo*: DWORD LPMOUSEHOOKSTRUCT* = ptr MOUSEHOOKSTRUCT - TMOUSEHOOKSTRUCT* = MOUSEHOOKSTRUCT PMOUSEHOOKSTRUCT* = ptr MOUSEHOOKSTRUCT MOUSEKEYS* {.final, pure.} = object cbSize*: DWORD @@ -10415,7 +10199,6 @@ type dwReserved1*: DWORD dwReserved2*: DWORD - TMOUSEKEYS* = MOUSEKEYS PMOUSEKEYS* = ptr MOUSEKEYS MSGBOXCALLBACK* = proc (lpHelpInfo: LPHELPINFO){.stdcall.} TMSGBOXCALLBACK* = MSGBOXCALLBACK @@ -10432,8 +10215,6 @@ type dwLanguageId*: DWORD LPMSGBOXPARAMS* = ptr MSGBOXPARAMS - TMSGBOXPARAMS* = MSGBOXPARAMS - TMSGBOXPARAMSA* = MSGBOXPARAMS PMSGBOXPARAMS* = ptr MSGBOXPARAMS MSGFILTER* {.final, pure.} = object nmhdr*: NMHDR @@ -10441,21 +10222,18 @@ type wParam*: WPARAM lParam*: LPARAM - Tmsgfilter* = MSGFILTER Pmsgfilter* = ptr MSGFILTER MULTIKEYHELP* {.final, pure.} = object mkSize*: DWORD - mkKeylist*: TCHAR - szKeyphrase*: array[0..0, TCHAR] + mkKeylist*: CHAR + szKeyphrase*: array[0..0, CHAR] - TMULTIKEYHELP* = MULTIKEYHELP PMULTIKEYHELP* = ptr MULTIKEYHELP NAME_BUFFER* {.final, pure.} = object name*: array[0..(NCBNAMSZ) - 1, UCHAR] name_num*: UCHAR name_flags*: UCHAR - TNAMEBUFFER* = NAME_BUFFER PNAMEBUFFER* = ptr NAME_BUFFER p_NCB* = ptr NCB NCB* {.final, pure.} = object @@ -10475,7 +10253,6 @@ type ncb_reserve*: array[0..9, UCHAR] ncb_event*: HANDLE - TNCB* = NCB NCCALCSIZE_PARAMS* {.final, pure.} = object rgrc*: array[0..2, RECT] lppos*: PWINDOWPOS @@ -10495,7 +10272,6 @@ type cNumItems*: LONG lpszItemList*: LPTSTR - TNDDESHAREINFO* = NDDESHAREINFO PNDDESHAREINFO* = ptr NDDESHAREINFO NETRESOURCE* {.final, pure.} = object dwScope*: DWORD @@ -10508,8 +10284,6 @@ type lpProvider*: LPTSTR LPNETRESOURCE* = ptr NETRESOURCE - TNETRESOURCE* = NETRESOURCE - TNETRESOURCEA* = NETRESOURCE PNETRESOURCE* = ptr NETRESOURCE PNETRESOURCEA* = ptr NETRESOURCE NEWCPLINFO* {.final, pure.} = object @@ -10518,11 +10292,10 @@ type dwHelpContext*: DWORD lData*: LONG hIcon*: HICON - szName*: array[0..31, TCHAR] - szInfo*: array[0..63, TCHAR] - szHelpFile*: array[0..127, TCHAR] + szName*: array[0..31, CHAR] + szInfo*: array[0..63, CHAR] + szHelpFile*: array[0..127, CHAR] - TNEWCPLINFO* = NEWCPLINFO PNEWCPLINFO* = ptr NEWCPLINFO NEWTEXTMETRIC* {.final, pure.} = object tmHeight*: LONG @@ -10550,13 +10323,11 @@ type ntmCellHeight*: WINUINT ntmAvgWidth*: WINUINT - TNEWTEXTMETRIC* = NEWTEXTMETRIC PNEWTEXTMETRIC* = ptr NEWTEXTMETRIC NEWTEXTMETRICEX* {.final, pure.} = object ntmentm*: NEWTEXTMETRIC ntmeFontSignature*: FONTSIGNATURE - TNEWTEXTMETRICEX* = NEWTEXTMETRICEX PNEWTEXTMETRICEX* = ptr NEWTEXTMETRICEX NM_LISTVIEW* {.final, pure.} = object hdr*: NMHDR @@ -10568,7 +10339,6 @@ type ptAction*: POINT lParam*: LPARAM - TNMLISTVIEW* = NM_LISTVIEW PNMLISTVIEW* = ptr NM_LISTVIEW TV_ITEM* {.final, pure.} = object mask*: WINUINT @@ -10583,7 +10353,6 @@ type lParam*: LPARAM LPTV_ITEM* = ptr TV_ITEM - TTVITEM* = TV_ITEM PTVITEM* = ptr TV_ITEM NM_TREEVIEW* {.final, pure.} = object hdr*: NMHDR @@ -10593,14 +10362,12 @@ type ptDrag*: POINT LPNM_TREEVIEW* = ptr NM_TREEVIEW - TNMTREEVIEW* = NM_TREEVIEW PNMTREEVIEW* = ptr NM_TREEVIEW NM_UPDOWNW* {.final, pure.} = object hdr*: NMHDR iPos*: int32 iDelta*: int32 - TNMUPDOWN* = NM_UPDOWNW PNMUPDOWN* = ptr NM_UPDOWNW NONCLIENTMETRICS* {.final, pure.} = object cbSize*: WINUINT @@ -10620,7 +10387,6 @@ type lfMessageFont*: LOGFONT LPNONCLIENTMETRICS* = ptr NONCLIENTMETRICS - TNONCLIENTMETRICS* = NONCLIENTMETRICS PNONCLIENTMETRICS* = ptr NONCLIENTMETRICS SERVICE_ADDRESS* {.final, pure.} = object dwAddressType*: DWORD @@ -10630,20 +10396,17 @@ type lpAddress*: ptr int8 lpPrincipal*: ptr int8 - TSERVICEADDRESS* = SERVICE_ADDRESS PSERVICEADDRESS* = ptr SERVICE_ADDRESS SERVICE_ADDRESSES* {.final, pure.} = object dwAddressCount*: DWORD Addresses*: array[0..0, SERVICE_ADDRESS] LPSERVICE_ADDRESSES* = ptr SERVICE_ADDRESSES - TSERVICEADDRESSES* = SERVICE_ADDRESSES PSERVICEADDRESSES* = ptr SERVICE_ADDRESSES - LPGUID* = ptr TGUID - PGUID* = ptr TGUID - CLSID* = TGUID + LPGUID* = ptr GUID + PGUID* = ptr GUID + CLSID* = GUID LPCLSID* = ptr CLSID - TCLSID* = CLSID PCLSID* = ptr CLSID SERVICE_INFO* {.final, pure.} = object lpServiceType*: LPGUID @@ -10657,13 +10420,11 @@ type lpServiceAddress*: LPSERVICE_ADDRESSES ServiceSpecificInfo*: BLOB - TSERVICEINFO* = SERVICE_INFO PSERVICEINFO* = ptr SERVICE_INFO NS_SERVICE_INFO* {.final, pure.} = object dwNameSpace*: DWORD ServiceInfo*: SERVICE_INFO - TNSSERVICEINFO* = NS_SERVICE_INFO PNSSERVICEINFO* = ptr NS_SERVICE_INFO NUMBERFMT* {.final, pure.} = object NumDigits*: WINUINT @@ -10673,7 +10434,6 @@ type lpThousandSep*: LPTSTR NegativeOrder*: WINUINT - Tnumberfmt* = NUMBERFMT Pnumberfmt* = ptr NUMBERFMT OFSTRUCT* {.final, pure.} = object cBytes*: int8 @@ -10684,7 +10444,6 @@ type szPathName*: array[0..(OFS_MAXPATHNAME) - 1, char] LPOFSTRUCT* = ptr OFSTRUCT - TOFSTRUCT* = OFSTRUCT POFSTRUCT* = ptr OFSTRUCT OPENFILENAME_NT4* {.final, pure.} = object lStructSize*: DWORD @@ -10709,9 +10468,8 @@ type lpTemplateName*: LPCTSTR LPOPENFILENAME_NT4* = ptr OPENFILENAME_NT4 - TOPENFILENAME_NT4* = OPENFILENAME_NT4 POPENFILENAME_NT4* = ptr OPENFILENAME_NT4 - TOPENFILENAME* {.final, pure.} = object + OPENFILENAME* {.final, pure.} = object lStructSize*: DWORD hwndOwner*: HWND hInstance*: HINST @@ -10736,17 +10494,16 @@ type dwreserved*: DWORD FlagsEx*: DWORD - LPOPENFILENAME* = ptr TOPENFILENAME - POPENFILENAME* = ptr TOPENFILENAME - OFN* = TOPENFILENAME - POFN* = ptr TOPENFILENAME + LPOPENFILENAME* = ptr OPENFILENAME + POPENFILENAME* = ptr OPENFILENAME + OFN* = OPENFILENAME + POFN* = ptr OPENFILENAME OFNOTIFY* {.final, pure.} = object hdr*: NMHDR lpOFN*: LPOPENFILENAME pszFile*: LPTSTR LPOFNOTIFY* = ptr OFNOTIFY - TOFNOTIFY* = OFNOTIFY POFNOTIFY* = ptr OFNOTIFY OSVERSIONINFO* {.final, pure.} = object dwOSVersionInfoSize*: DWORD @@ -10754,10 +10511,9 @@ type dwMinorVersion*: DWORD dwBuildNumber*: DWORD dwPlatformId*: DWORD - szCSDVersion*: array[0..127, TCHAR] + szCSDVersion*: array[0..127, CHAR] LPOSVERSIONINFO* = ptr OSVERSIONINFO - TOSVERSIONINFO* = OSVERSIONINFO POSVERSIONINFO* = ptr OSVERSIONINFO OSVERSIONINFOW* {.final, pure.} = object dwOSVersionInfoSize*: DWORD @@ -10768,7 +10524,6 @@ type szCSDVersion*: array[0..127, WCHAR] LPOSVERSIONINFOW* = ptr OSVERSIONINFOW - TOSVERSIONINFOW* = OSVERSIONINFOW POSVERSIONINFOW* = ptr OSVERSIONINFOW TEXTMETRIC* {.final, pure.} = object tmHeight*: LONG @@ -10793,7 +10548,6 @@ type tmCharSet*: int8 LPTEXTMETRIC* = ptr TEXTMETRIC - TTEXTMETRIC* = TEXTMETRIC PTEXTMETRIC* = ptr TEXTMETRIC TEXTMETRICW* {.final, pure.} = object tmHeight*: LONG @@ -10818,7 +10572,6 @@ type tmCharSet*: int8 LPTEXTMETRICW* = ptr TEXTMETRICW - TTEXTMETRICW* = TEXTMETRICW PTEXTMETRICW* = ptr TEXTMETRICW OUTLINETEXTMETRIC* {.final, pure.} = object otmSize*: WINUINT @@ -10855,7 +10608,6 @@ type otmpFullName*: PSTR LPOUTLINETEXTMETRIC* = ptr OUTLINETEXTMETRIC - TOUTLINETEXTMETRIC* = OUTLINETEXTMETRIC POUTLINETEXTMETRIC* = ptr OUTLINETEXTMETRIC OVERLAPPED* {.final, pure.} = object Internal*: DWORD @@ -10865,7 +10617,6 @@ type hEvent*: HANDLE LPOVERLAPPED* = ptr OVERLAPPED - TOVERLAPPED* = OVERLAPPED POVERLAPPED* = ptr OVERLAPPED #PAGESETUPDLG = record conflicts with function PageSetupDlg TPAGESETUPDLG* {.final, pure.} = object @@ -10886,7 +10637,6 @@ type LPPAGESETUPDLG* = ptr TPAGESETUPDLG PPAGESETUPDLG* = ptr TPAGESETUPDLG - TPSD* = TPAGESETUPDLG PPSD* = ptr TPAGESETUPDLG PAINTSTRUCT* {.final, pure.} = object hdc*: HDC @@ -10897,7 +10647,6 @@ type rgbReserved*: array[0..31, int8] LPPAINTSTRUCT* = ptr PAINTSTRUCT - TPAINTSTRUCT* = PAINTSTRUCT PPAINTSTRUCT* = ptr PAINTSTRUCT PARAFORMAT* {.final, pure.} = object cbSize*: WINUINT @@ -10911,12 +10660,10 @@ type cTabCount*: SHORT rgxTabs*: array[0..(MAX_TAB_STOPS) - 1, LONG] - Tparaformat* = PARAFORMAT Pparaformat* = ptr PARAFORMAT PERF_COUNTER_BLOCK* {.final, pure.} = object ByteLength*: DWORD - TPERFCOUNTERBLOCK* = PERF_COUNTER_BLOCK PPERFCOUNTERBLOCK* = ptr PERF_COUNTER_BLOCK PERF_COUNTER_DEFINITION* {.final, pure.} = object ByteLength*: DWORD @@ -10930,7 +10677,6 @@ type CounterSize*: DWORD CounterOffset*: DWORD - TPERFCOUNTERDEFINITION* = PERF_COUNTER_DEFINITION PPERFCOUNTERDEFINITION* = ptr PERF_COUNTER_DEFINITION PERF_DATA_BLOCK* {.final, pure.} = object Signature*: array[0..3, WCHAR] @@ -10948,7 +10694,6 @@ type SystemNameLength*: DWORD SystemNameOffset*: DWORD - TPERFDATABLOCK* = PERF_DATA_BLOCK PPERFDATABLOCK* = ptr PERF_DATA_BLOCK PERF_INSTANCE_DEFINITION* {.final, pure.} = object ByteLength*: DWORD @@ -10958,7 +10703,6 @@ type NameOffset*: DWORD NameLength*: DWORD - TPERFINSTANCEDEFINITION* = PERF_INSTANCE_DEFINITION PPERFINSTANCEDEFINITION* = PERF_INSTANCE_DEFINITION PERF_OBJECT_TYPE* {.final, pure.} = object TotalByteLength*: DWORD @@ -10976,7 +10720,6 @@ type PerfTime*: LARGE_INTEGER PerfFreq*: LARGE_INTEGER - TPERFOBJECTTYPE* = PERF_OBJECT_TYPE PPERFOBJECTTYPE* = ptr PERF_OBJECT_TYPE POLYTEXT* {.final, pure.} = object x*: int32 @@ -10987,12 +10730,10 @@ type rcl*: RECT pdx*: ptr int32 - TPOLYTEXT* = POLYTEXT PPOLYTEXT* = ptr POLYTEXT PORT_INFO_1* {.final, pure.} = object pName*: LPTSTR - TPORTINFO1* = PORT_INFO_1 PPORTINFO1* = ptr PORT_INFO_1 PORT_INFO_2* {.final, pure.} = object pPortName*: LPSTR @@ -11001,12 +10742,10 @@ type fPortType*: DWORD Reserved*: DWORD - TPORTINFO2* = PORT_INFO_2 PPORTINFO2* = ptr PORT_INFO_2 PREVENT_MEDIA_REMOVAL* {.final, pure.} = object PreventMediaRemoval*: bool - TPREVENTMEDIAREMOVAL* = PREVENT_MEDIA_REMOVAL PPREVENTMEDIAREMOVAL* = ptr PREVENT_MEDIA_REMOVAL #PRINTDLG = record conflicts with PrintDlg function TPRINTDLG* {.final, pure.} = object @@ -11032,14 +10771,12 @@ type LPPRINTDLG* = ptr TPRINTDLG PPRINTDLG* = ptr TPRINTDLG - TPD* = TPRINTDLG PPD* = ptr TPRINTDLG PRINTER_DEFAULTS* {.final, pure.} = object pDatatype*: LPTSTR pDevMode*: LPDEVMODE DesiredAccess*: ACCESS_MASK - TPRINTERDEFAULTS* = PRINTER_DEFAULTS PPRINTERDEFAULTS* = ptr PRINTER_DEFAULTS PRINTER_INFO_1* {.final, pure.} = object Flags*: DWORD @@ -11049,7 +10786,6 @@ type LPPRINTER_INFO_1* = ptr PRINTER_INFO_1 PPRINTER_INFO_1* = ptr PRINTER_INFO_1 - TPRINTERINFO1* = PRINTER_INFO_1 PRINTER_INFO_2* {.final, pure.} = object pServerName*: LPTSTR pPrinterName*: LPTSTR @@ -11073,19 +10809,16 @@ type cJobs*: DWORD AveragePPM*: DWORD - TPRINTERINFO2* = PRINTER_INFO_2 PPRINTERINFO2* = ptr PRINTER_INFO_2 PRINTER_INFO_3* {.final, pure.} = object pSecurityDescriptor*: PSECURITY_DESCRIPTOR - TPRINTERINFO3* = PRINTER_INFO_3 PPRINTERINFO3* = ptr PRINTER_INFO_3 PRINTER_INFO_4* {.final, pure.} = object pPrinterName*: LPTSTR pServerName*: LPTSTR Attributes*: DWORD - TPRINTERINFO4* = PRINTER_INFO_4 PPRINTERINFO4* = ptr PRINTER_INFO_4 PRINTER_INFO_5* {.final, pure.} = object pPrinterName*: LPTSTR @@ -11094,7 +10827,6 @@ type DeviceNotSelectedTimeout*: DWORD TransmissionRetryTimeout*: DWORD - TPRINTERINFO5* = PRINTER_INFO_5 PPRINTERINFO5* = ptr PRINTER_INFO_5 PRINTER_NOTIFY_INFO_DATA* {.final, pure.} = object `type`*: int16 @@ -11104,7 +10836,6 @@ type cbBuf*: DWORD pBuf*: LPVOID - TPRINTERNOTIFYINFODATA* = PRINTER_NOTIFY_INFO_DATA PPRINTERNOTIFYINFODATA* = ptr PRINTER_NOTIFY_INFO_DATA PRINTER_NOTIFY_INFO* {.final, pure.} = object Version*: DWORD @@ -11112,7 +10843,6 @@ type Count*: DWORD aData*: array[0..0, PRINTER_NOTIFY_INFO_DATA] - TPRINTERNOTIFYINFO* = PRINTER_NOTIFY_INFO PPRINTERNOTIFYINFO* = ptr PRINTER_NOTIFY_INFO PRINTER_NOTIFY_OPTIONS_TYPE* {.final, pure.} = object `type`*: int16 @@ -11123,19 +10853,16 @@ type pFields*: PWORD PPRINTER_NOTIFY_OPTIONS_TYPE* = ptr PRINTER_NOTIFY_OPTIONS_TYPE - TPRINTERNOTIFYOPTIONSTYPE* = PRINTER_NOTIFY_OPTIONS_TYPE PRINTER_NOTIFY_OPTIONS* {.final, pure.} = object Version*: DWORD Flags*: DWORD Count*: DWORD pTypes*: PPRINTER_NOTIFY_OPTIONS_TYPE - TPRINTERNOTIFYOPTIONS* = PRINTER_NOTIFY_OPTIONS PPRINTERNOTIFYOPTIONS* = ptr PRINTER_NOTIFY_OPTIONS PRINTPROCESSOR_INFO_1* {.final, pure.} = object pName*: LPTSTR - TPRINTPROCESSORINFO1* = PRINTPROCESSOR_INFO_1 PPRINTPROCESSORINFO1* = ptr PRINTPROCESSOR_INFO_1 PRIVILEGE_SET* {.final, pure.} = object PrivilegeCount*: DWORD @@ -11144,7 +10871,6 @@ type LPPRIVILEGE_SET* = ptr PRIVILEGE_SET PPRIVILEGE_SET* = ptr PRIVILEGE_SET - TPRIVILEGESET* = PRIVILEGE_SET PROCESS_HEAPENTRY* {.final, pure.} = object lpData*: PVOID cbData*: DWORD @@ -11158,7 +10884,6 @@ type hMem*: HANDLE LPPROCESS_HEAP_ENTRY* = ptr PROCESS_HEAPENTRY - TPROCESSHEAPENTRY* = PROCESS_HEAPENTRY PPROCESSHEAPENTRY* = ptr PROCESS_HEAPENTRY PROCESS_INFORMATION* {.final, pure.} = object hProcess*: HANDLE @@ -11167,11 +10892,9 @@ type dwThreadId*: DWORD LPPROCESS_INFORMATION* = ptr PROCESS_INFORMATION - TPROCESSINFORMATION* = PROCESS_INFORMATION PPROCESSINFORMATION* = ptr PROCESS_INFORMATION LPFNPSPCALLBACK* = proc (para1: HWND, para2: WINUINT, para3: LPVOID): WINUINT{. stdcall.} - TFNPSPCALLBACK* = LPFNPSPCALLBACK PROPSHEETPAGE* {.final, pure.} = object dwSize*: DWORD dwFlags*: DWORD @@ -11185,7 +10908,6 @@ type LPPROPSHEETPAGE* = ptr PROPSHEETPAGE LPCPROPSHEETPAGE* = ptr PROPSHEETPAGE - TPROPSHEETPAGE* = PROPSHEETPAGE PPROPSHEETPAGE* = ptr PROPSHEETPAGE emptyrecord* {.final, pure.} = object lpemptyrecord* = ptr emptyrecord @@ -11207,15 +10929,12 @@ type LPPROPSHEETHEADER* = ptr PROPSHEETHEADER LPCPROPSHEETHEADER* = ptr PROPSHEETHEADER - TPROPSHEETHEADER* = PROPSHEETHEADER PPROPSHEETHEADER* = ptr PROPSHEETHEADER # PropertySheet callbacks LPFNADDPROPSHEETPAGE* = proc (para1: HPROPSHEETPAGE, para2: LPARAM): WINBOOL{. stdcall.} - TFNADDPROPSHEETPAGE* = LPFNADDPROPSHEETPAGE LPFNADDPROPSHEETPAGES* = proc (para1: LPVOID, para2: LPFNADDPROPSHEETPAGE, para3: LPARAM): WINBOOL{.stdcall.} - TFNADDPROPSHEETPAGES* = LPFNADDPROPSHEETPAGES PROTOCOL_INFO* {.final, pure.} = object dwServiceFlags*: DWORD iAddressFamily*: WINT @@ -11226,29 +10945,25 @@ type dwMessageSize*: DWORD lpProtocol*: LPTSTR - TPROTOCOLINFO* = PROTOCOL_INFO PPROTOCOLINFO* = ptr PROTOCOL_INFO PROVIDOR_INFO_1* {.final, pure.} = object pName*: LPTSTR pEnvironment*: LPTSTR pDLLName*: LPTSTR - TPROVIDORINFO1* = PROVIDOR_INFO_1 PPROVIDORINFO1* = ptr PROVIDOR_INFO_1 PSHNOTIFY* {.final, pure.} = object hdr*: NMHDR lParam*: LPARAM LPPSHNOTIFY* = ptr PSHNOTIFY - TPSHNOTIFY* = PSHNOTIFY PPSHNOTIFY* = ptr PSHNOTIFY PUNCTUATION* {.final, pure.} = object iSize*: WINUINT szPunctuation*: LPSTR - Tpunctuation* = PUNCTUATION Ppunctuation* = ptr PUNCTUATION - TQUERY_SERVICE_CONFIG* {.final, pure.} = object + TQUERY_SERVICE_CONFIG* {.final, pure.} = object # Name conflict if we drop the `T` dwServiceType*: DWORD dwStartType*: DWORD dwErrorControl*: DWORD @@ -11261,7 +10976,7 @@ type LPQUERY_SERVICE_CONFIG* = ptr TQUERY_SERVICE_CONFIG PQUERYSERVICECONFIG* = ptr TQUERY_SERVICE_CONFIG - TQUERY_SERVICE_LOCK_STATUS* {.final, pure.} = object + TQUERY_SERVICE_LOCK_STATUS* {.final, pure.} = object # Name conflict if we drop the `T` fIsLocked*: DWORD lpLockOwner*: LPTSTR dwLockDuration*: DWORD @@ -11271,28 +10986,25 @@ type RASAMB* {.final, pure.} = object dwSize*: DWORD dwError*: DWORD - szNetBiosError*: array[0..(NETBIOS_NAME_LEN + 1) - 1, TCHAR] + szNetBiosError*: array[0..(NETBIOS_NAME_LEN + 1) - 1, CHAR] bLana*: int8 - TRASAMB* = RASAMB PRASAMB* = ptr RASAMB RASCONN* {.final, pure.} = object dwSize*: DWORD hrasconn*: HRASCONN - szEntryName*: array[0..(RAS_MaxEntryName + 1) - 1, TCHAR] + szEntryName*: array[0..(RAS_MaxEntryName + 1) - 1, CHAR] szDeviceType*: array[0..(RAS_MaxDeviceType + 1) - 1, char] szDeviceName*: array[0..(RAS_MaxDeviceName + 1) - 1, char] - TRASCONN* = RASCONN PRASCONN* = ptr RASCONN RASCONNSTATUS* {.final, pure.} = object dwSize*: DWORD rasconnstate*: RASCONNSTATE dwError*: DWORD - szDeviceType*: array[0..(RAS_MaxDeviceType + 1) - 1, TCHAR] - szDeviceName*: array[0..(RAS_MaxDeviceName + 1) - 1, TCHAR] + szDeviceType*: array[0..(RAS_MaxDeviceType + 1) - 1, CHAR] + szDeviceName*: array[0..(RAS_MaxDeviceName + 1) - 1, CHAR] - TRASCONNSTATUS* = RASCONNSTATUS PRASCONNSTATUS* = ptr RASCONNSTATUS RASDIALEXTENSIONS* {.final, pure.} = object dwSize*: DWORD @@ -11300,48 +11012,42 @@ type hwndParent*: HWND reserved*: DWORD - TRASDIALEXTENSIONS* = RASDIALEXTENSIONS PRASDIALEXTENSIONS* = ptr RASDIALEXTENSIONS RASDIALPARAMS* {.final, pure.} = object dwSize*: DWORD - szEntryName*: array[0..(RAS_MaxEntryName + 1) - 1, TCHAR] - szPhoneNumber*: array[0..(RAS_MaxPhoneNumber + 1) - 1, TCHAR] - szCallbackNumber*: array[0..(RAS_MaxCallbackNumber + 1) - 1, TCHAR] - szUserName*: array[0..(UNLEN + 1) - 1, TCHAR] - szPassword*: array[0..(PWLEN + 1) - 1, TCHAR] - szDomain*: array[0..(DNLEN + 1) - 1, TCHAR] - - TRASDIALPARAMS* = RASDIALPARAMS + szEntryName*: array[0..(RAS_MaxEntryName + 1) - 1, CHAR] + szPhoneNumber*: array[0..(RAS_MaxPhoneNumber + 1) - 1, CHAR] + szCallbackNumber*: array[0..(RAS_MaxCallbackNumber + 1) - 1, CHAR] + szUserName*: array[0..(UNLEN + 1) - 1, CHAR] + szPassword*: array[0..(PWLEN + 1) - 1, CHAR] + szDomain*: array[0..(DNLEN + 1) - 1, CHAR] + PRASDIALPARAMS* = ptr RASDIALPARAMS RASENTRYNAME* {.final, pure.} = object dwSize*: DWORD - szEntryName*: array[0..(RAS_MaxEntryName + 1) - 1, TCHAR] + szEntryName*: array[0..(RAS_MaxEntryName + 1) - 1, CHAR] - TRASENTRYNAME* = RASENTRYNAME PRASENTRYNAME* = ptr RASENTRYNAME RASPPPIP* {.final, pure.} = object dwSize*: DWORD dwError*: DWORD - szIpAddress*: array[0..(RAS_MaxIpAddress + 1) - 1, TCHAR] + szIpAddress*: array[0..(RAS_MaxIpAddress + 1) - 1, CHAR] - TRASPPPIP* = RASPPPIP PRASPPPIP* = ptr RASPPPIP RASPPPIPX* {.final, pure.} = object dwSize*: DWORD dwError*: DWORD - szIpxAddress*: array[0..(RAS_MaxIpxAddress + 1) - 1, TCHAR] + szIpxAddress*: array[0..(RAS_MaxIpxAddress + 1) - 1, CHAR] - TRASPPPIPX* = RASPPPIPX PRASPPPIPX* = ptr RASPPPIPX RASPPPNBF* {.final, pure.} = object dwSize*: DWORD dwError*: DWORD dwNetBiosError*: DWORD - szNetBiosError*: array[0..(NETBIOS_NAME_LEN + 1) - 1, TCHAR] - szWorkstationName*: array[0..(NETBIOS_NAME_LEN + 1) - 1, TCHAR] + szNetBiosError*: array[0..(NETBIOS_NAME_LEN + 1) - 1, CHAR] + szWorkstationName*: array[0..(NETBIOS_NAME_LEN + 1) - 1, CHAR] bLana*: int8 - TRASPPPNBF* = RASPPPNBF PRASPPPNBF* = ptr RASPPPNBF RASTERIZER_STATUS* {.final, pure.} = object nSize*: SHORT @@ -11349,34 +11055,29 @@ type nLanguageID*: SHORT LPRASTERIZER_STATUS* = ptr RASTERIZER_STATUS - TRASTERIZERSTATUS* = RASTERIZER_STATUS PRASTERIZERSTATUS* = ptr RASTERIZER_STATUS REASSIGN_BLOCKS* {.final, pure.} = object Reserved*: int16 Count*: int16 BlockNumber*: array[0..0, DWORD] - TREASSIGNBLOCKS* = REASSIGN_BLOCKS PREASSIGNBLOCKS* = ptr REASSIGN_BLOCKS REMOTE_NAME_INFO* {.final, pure.} = object lpUniversalName*: LPTSTR lpConnectionName*: LPTSTR lpRemainingPath*: LPTSTR - TREMOTENAMEINFO* = REMOTE_NAME_INFO PREMOTENAMEINFO* = ptr REMOTE_NAME_INFO REPASTESPECIAL* {.final, pure.} = object dwAspect*: DWORD dwParam*: DWORD - Trepastespecial* = REPASTESPECIAL Prepastespecial* = ptr REPASTESPECIAL REQRESIZE* {.final, pure.} = object nmhdr*: NMHDR rc*: RECT - Treqresize* = REQRESIZE Preqresize* = ptr REQRESIZE RGNDATAHEADER* {.final, pure.} = object dwSize*: DWORD @@ -11385,14 +11086,12 @@ type nRgnSize*: DWORD rcBound*: RECT - TRGNDATAHEADER* = RGNDATAHEADER PRGNDATAHEADER* = ptr RGNDATAHEADER RGNDATA* {.final, pure.} = object rdh*: RGNDATAHEADER Buffer*: array[0..0, char] LPRGNDATA* = ptr RGNDATA - TRGNDATA* = RGNDATA PRGNDATA* = ptr RGNDATA SCROLLINFO* {.final, pure.} = object cbSize*: WINUINT @@ -11405,7 +11104,6 @@ type LPSCROLLINFO* = ptr SCROLLINFO LPCSCROLLINFO* = ptr SCROLLINFO - TSCROLLINFO* = SCROLLINFO PSCROLLINFO* = ptr SCROLLINFO SECURITY_ATTRIBUTES* {.final, pure.} = object nLength*: DWORD @@ -11413,17 +11111,14 @@ type bInheritHandle*: WINBOOL LPSECURITY_ATTRIBUTES* = ptr SECURITY_ATTRIBUTES - TSECURITYATTRIBUTES* = SECURITY_ATTRIBUTES PSECURITYATTRIBUTES* = ptr SECURITY_ATTRIBUTES SECURITY_INFORMATION* = DWORD PSECURITY_INFORMATION* = ptr SECURITY_INFORMATION - TSECURITYINFORMATION* = SECURITY_INFORMATION SELCHANGE* {.final, pure.} = object nmhdr*: NMHDR chrg*: CHARRANGE seltyp*: int16 - Tselchange* = SELCHANGE Pselchange* = ptr SELCHANGE SERIALKEYS* {.final, pure.} = object cbSize*: DWORD @@ -11434,14 +11129,12 @@ type iPortState*: DWORD LPSERIALKEYS* = ptr SERIALKEYS - TSERIALKEYS* = SERIALKEYS PSERIALKEYS* = ptr SERIALKEYS SERVICE_TABLE_ENTRY* {.final, pure.} = object lpServiceName*: LPTSTR lpServiceProc*: LPSERVICE_MAIN_FUNCTION LPSERVICE_TABLE_ENTRY* = ptr SERVICE_TABLE_ENTRY - TSERVICETABLEENTRY* = SERVICE_TABLE_ENTRY PSERVICETABLEENTRY* = ptr SERVICE_TABLE_ENTRY SERVICE_TYPE_VALUE_ABS* {.final, pure.} = object dwNameSpace*: DWORD @@ -11450,14 +11143,12 @@ type lpValueName*: LPTSTR lpValue*: PVOID - TSERVICETYPEVALUEABS* = SERVICE_TYPE_VALUE_ABS PSERVICETYPEVALUEABS* = ptr SERVICE_TYPE_VALUE_ABS SERVICE_TYPE_INFO_ABS* {.final, pure.} = object lpTypeName*: LPTSTR dwValueCount*: DWORD Values*: array[0..0, SERVICE_TYPE_VALUE_ABS] - TSERVICETYPEINFOABS* = SERVICE_TYPE_INFO_ABS PSERVICETYPEINFOABS* = ptr SERVICE_TYPE_INFO_ABS SESSION_BUFFER* {.final, pure.} = object lsn*: UCHAR @@ -11467,7 +11158,6 @@ type rcvs_outstanding*: UCHAR sends_outstanding*: UCHAR - TSESSIONBUFFER* = SESSION_BUFFER PSESSIONBUFFER* = ptr SESSION_BUFFER SESSION_HEADER* {.final, pure.} = object sess_name*: UCHAR @@ -11475,16 +11165,13 @@ type rcv_dg_outstanding*: UCHAR rcv_any_outstanding*: UCHAR - TSESSIONHEADER* = SESSION_HEADER PSESSIONHEADER* = ptr SESSION_HEADER SET_PARTITION_INFORMATION* {.final, pure.} = object PartitionType*: int8 - TSETPARTITIONINFORMATION* = SET_PARTITION_INFORMATION PSETPARTITIONINFORMATION* = ptr SET_PARTITION_INFORMATION SHCONTF* = enum SHCONTF_FOLDERS = 32, SHCONTF_NONFOLDERS = 64, SHCONTF_INCLUDEHIDDEN = 128 - TSHCONTF* = SHCONTF SHFILEINFO* {.final, pure.} = object hIcon*: HICON iIcon*: int32 @@ -11492,10 +11179,8 @@ type szDisplayName*: array[0..(MAX_PATH) - 1, char] szTypeName*: array[0..79, char] - TSHFILEINFO* = SHFILEINFO PSHFILEINFO* = ptr SHFILEINFO FILEOP_FLAGS* = int16 - TFILEOPFLAGS* = FILEOP_FLAGS PFILEOPFLAGS* = ptr FILEOP_FLAGS SHFILEOPSTRUCT* {.final, pure.} = object hwnd*: HWND @@ -11508,11 +11193,9 @@ type lpszProgressTitle*: LPCSTR LPSHFILEOPSTRUCT* = ptr SHFILEOPSTRUCT - TSHFILEOPSTRUCT* = SHFILEOPSTRUCT PSHFILEOPSTRUCT* = ptr SHFILEOPSTRUCT SHGNO* = enum SHGDN_NORMAL = 0, SHGDN_INFOLDER = 1, SHGDN_FORPARSING = 0x00008000 - TSHGDN* = SHGNO SHNAMEMAPPING* {.final, pure.} = object pszOldPath*: LPSTR pszNewPath*: LPSTR @@ -11520,21 +11203,17 @@ type cchNewPath*: int32 LPSHNAMEMAPPING* = ptr SHNAMEMAPPING - TSHNAMEMAPPING* = SHNAMEMAPPING PSHNAMEMAPPING* = ptr SHNAMEMAPPING SID_AND_ATTRIBUTES* {.final, pure.} = object Sid*: PSID Attributes*: DWORD - TSIDANDATTRIBUTES* = SID_AND_ATTRIBUTES PSIDANDATTRIBUTES* = ptr SID_AND_ATTRIBUTES SID_AND_ATTRIBUTES_ARRAY* = array[0..(ANYSIZE_ARRAY) - 1, SID_AND_ATTRIBUTES] PSID_AND_ATTRIBUTES_ARRAY* = ptr SID_AND_ATTRIBUTES_ARRAY - TSIDANDATTRIBUTESARRAY* = SID_AND_ATTRIBUTES_ARRAY SINGLE_LIST_ENTRY* {.final, pure.} = object Next*: ptr SINGLE_LIST_ENTRY - TSINGLELISTENTRY* = SINGLE_LIST_ENTRY PSINGLELISTENTRY* = ptr SINGLE_LIST_ENTRY SOUNDSENTRY* {.final, pure.} = object cbSize*: WINUINT @@ -11551,7 +11230,6 @@ type iWindowsEffectOrdinal*: DWORD LPSOUNDSENTRY* = ptr SOUNDSENTRY - TSOUNDSENTRY* = SOUNDSENTRY PSOUNDSENTRY* = ptr SOUNDSENTRY STARTUPINFO* {.final, pure.} = object cb*: DWORD @@ -11574,42 +11252,36 @@ type hStdError*: HANDLE LPSTARTUPINFO* = ptr STARTUPINFO - TSTARTUPINFO* = STARTUPINFO PSTARTUPINFO* = ptr STARTUPINFO STICKYKEYS* {.final, pure.} = object cbSize*: DWORD dwFlags*: DWORD LPSTICKYKEYS* = ptr STICKYKEYS - TSTICKYKEYS* = STICKYKEYS PSTICKYKEYS* = ptr STICKYKEYS STRRET* {.final, pure.} = object uType*: WINUINT cStr*: array[0..(MAX_PATH) - 1, char] LPSTRRET* = ptr STRRET - TSTRRET* = STRRET PSTRRET* = ptr STRRET STYLEBUF* {.final, pure.} = object dwStyle*: DWORD szDescription*: array[0..31, char] LPSTYLEBUF* = ptr STYLEBUF - TSTYLEBUF* = STYLEBUF PSTYLEBUF* = ptr STYLEBUF STYLESTRUCT* {.final, pure.} = object styleOld*: DWORD styleNew*: DWORD LPSTYLESTRUCT* = ptr STYLESTRUCT - TSTYLESTRUCT* = STYLESTRUCT PSTYLESTRUCT* = ptr STYLESTRUCT SYSTEM_AUDIT_ACE* {.final, pure.} = object Header*: ACE_HEADER Mask*: ACCESS_MASK SidStart*: DWORD - TSYSTEMAUDITACE* = SYSTEM_AUDIT_ACE PSYSTEMAUDITACE* = ptr SYSTEM_AUDIT_ACE SYSTEM_INFO* {.final, pure.} = object dwOemId*: DWORD @@ -11624,7 +11296,6 @@ type wProcessorRevision*: int16 LPSYSTEM_INFO* = ptr SYSTEM_INFO - TSYSTEMINFO* = SYSTEM_INFO PSYSTEMINFO* = ptr SYSTEM_INFO SYSTEM_POWER_STATUS* {.final, pure.} = object ACLineStatus*: int8 @@ -11634,13 +11305,11 @@ type BatteryLifeTime*: DWORD BatteryFullLifeTime*: DWORD - TSYSTEMPOWERSTATUS* = SYSTEM_POWER_STATUS PSYSTEMPOWERSTATUS* = ptr SYSTEM_POWER_STATUS LPSYSTEM_POWER_STATUS* = ptr emptyrecord TAPE_ERASE* {.final, pure.} = object `type`*: ULONG - TTAPEERASE* = TAPE_ERASE PTAPEERASE* = ptr TAPE_ERASE TAPE_GET_DRIVE_PARAMETERS* {.final, pure.} = object ECC*: bool @@ -11655,7 +11324,6 @@ type FeaturesHigh*: ULONG EOTWarningZoneSize*: ULONG - TTAPEGETDRIVEPARAMETERS* = TAPE_GET_DRIVE_PARAMETERS PTAPEGETDRIVEPARAMETERS* = ptr TAPE_GET_DRIVE_PARAMETERS TAPE_GET_MEDIA_PARAMETERS* {.final, pure.} = object Capacity*: LARGE_INTEGER @@ -11664,7 +11332,6 @@ type PartitionCount*: DWORD WriteProtected*: bool - TTAPEGETMEDIAPARAMETERS* = TAPE_GET_MEDIA_PARAMETERS PTAPEGETMEDIAPARAMETERS* = ptr TAPE_GET_MEDIA_PARAMETERS TAPE_GET_POSITION* {.final, pure.} = object `type`*: ULONG @@ -11672,12 +11339,10 @@ type OffsetLow*: ULONG OffsetHigh*: ULONG - TTAPEGETPOSITION* = TAPE_GET_POSITION PTAPEGETPOSITION* = ptr TAPE_GET_POSITION TAPE_PREPARE* {.final, pure.} = object Operation*: ULONG - TTAPEPREPARE* = TAPE_PREPARE PTAPEPREPARE* = ptr TAPE_PREPARE TAPE_SET_DRIVE_PARAMETERS* {.final, pure.} = object ECC*: bool @@ -11686,12 +11351,10 @@ type ReportSetmarks*: bool EOTWarningZoneSize*: ULONG - TTAPESETDRIVEPARAMETERS* = TAPE_SET_DRIVE_PARAMETERS PTAPESETDRIVEPARAMETERS* = ptr TAPE_SET_DRIVE_PARAMETERS TAPE_SET_MEDIA_PARAMETERS* {.final, pure.} = object BlockSize*: ULONG - TTAPESETMEDIAPARAMETERS* = TAPE_SET_MEDIA_PARAMETERS PTAPESETMEDIAPARAMETERS* = ptr TAPE_SET_MEDIA_PARAMETERS TAPE_SET_POSITION* {.final, pure.} = object `Method`*: ULONG @@ -11699,15 +11362,13 @@ type OffsetLow*: ULONG OffsetHigh*: ULONG - TTAPESETPOSITION* = TAPE_SET_POSITION PTAPESETPOSITION* = ptr TAPE_SET_POSITION TAPE_WRITE_MARKS* {.final, pure.} = object `type`*: ULONG Count*: ULONG - TTAPEWRITEMARKS* = TAPE_WRITE_MARKS PTAPEWRITEMARKS* = ptr TAPE_WRITE_MARKS - TTBADDBITMAP* {.final, pure.} = object + TTBADDBITMAP* {.final, pure.} = object # Name conflict if we drop the `T` hInst*: HINST nID*: WINUINT @@ -11723,7 +11384,6 @@ type LPTBBUTTON* = ptr TBBUTTON LPCTBBUTTON* = ptr TBBUTTON - TTBBUTTON* = TBBUTTON PTBBUTTON* = ptr TBBUTTON TBNOTIFY* {.final, pure.} = object hdr*: NMHDR @@ -11733,20 +11393,17 @@ type pszText*: LPTSTR LPTBNOTIFY* = ptr TBNOTIFY - TTBNOTIFY* = TBNOTIFY PTBNOTIFY* = ptr TBNOTIFY TBSAVEPARAMS* {.final, pure.} = object hkr*: HKEY pszSubKey*: LPCTSTR pszValueName*: LPCTSTR - TTBSAVEPARAMS* = TBSAVEPARAMS PTBSAVEPARAMS* = ptr TBSAVEPARAMS TC_HITTESTINFO* {.final, pure.} = object pt*: POINT flags*: WINUINT - TTCHITTESTINFO* = TC_HITTESTINFO PTCHITTESTINFO* = ptr TC_HITTESTINFO TC_ITEM* {.final, pure.} = object mask*: WINUINT @@ -11757,7 +11414,6 @@ type iImage*: int32 lParam*: LPARAM - TTCITEM* = TC_ITEM PTCITEM* = ptr TC_ITEM TC_ITEMHEADER* {.final, pure.} = object mask*: WINUINT @@ -11767,20 +11423,17 @@ type cchTextMax*: int32 iImage*: int32 - TTCITEMHEADER* = TC_ITEMHEADER PTCITEMHEADER* = ptr TC_ITEMHEADER TC_KEYDOWN* {.final, pure.} = object hdr*: NMHDR wVKey*: int16 flags*: WINUINT - TTCKEYDOWN* = TC_KEYDOWN PTCKEYDOWN* = ptr TC_KEYDOWN TEXTRANGE* {.final, pure.} = object chrg*: CHARRANGE lpstrText*: LPSTR - Ttextrange* = TEXTRANGE Ptextrange* = ptr TEXTRANGE TIME_ZONE_INFORMATION* {.final, pure.} = object Bias*: LONG @@ -11792,15 +11445,13 @@ type DaylightBias*: LONG LPTIME_ZONE_INFORMATION* = ptr TIME_ZONE_INFORMATION - TTIMEZONEINFORMATION* = TIME_ZONE_INFORMATION PTIMEZONEINFORMATION* = ptr TIME_ZONE_INFORMATION TOGGLEKEYS* {.final, pure.} = object cbSize*: DWORD dwFlags*: DWORD - TTOGGLEKEYS* = TOGGLEKEYS PTOGGLEKEYS* = ptr TOGGLEKEYS - TTOKEN_SOURCE* {.final, pure.} = object + TTOKEN_SOURCE* {.final, pure.} = object # Name confict if we drop the `T` SourceName*: array[0..7, char] SourceIdentifier*: LUID @@ -11811,33 +11462,32 @@ type ModifiedId*: LUID TokenSource*: TTOKEN_SOURCE - TTOKENCONTROL* = TOKEN_CONTROL PTOKENCONTROL* = ptr TOKEN_CONTROL TTOKEN_DEFAULT_DACL* {.final, pure.} = object DefaultDacl*: PACL - PTOKENDEFAULTDACL* = ptr TTOKEN_DEFAULT_DACL - TTOKEN_GROUPS* {.final, pure.} = object + PTOKENDEFAULTDACL* = ptr TTOKEN_DEFAULT_DACL # Name conflict if we drop the `T` + TTOKEN_GROUPS* {.final, pure.} = object # Name conflict if we drop the `T` GroupCount*: DWORD Groups*: array[0..(ANYSIZE_ARRAY) - 1, SID_AND_ATTRIBUTES] LPTOKEN_GROUPS* = ptr TTOKEN_GROUPS PTOKENGROUPS* = ptr TTOKEN_GROUPS - TTOKEN_OWNER* {.final, pure.} = object + TTOKEN_OWNER* {.final, pure.} = object # Name conflict if we drop the `T` Owner*: PSID PTOKENOWNER* = ptr TTOKEN_OWNER TTOKEN_PRIMARY_GROUP* {.final, pure.} = object PrimaryGroup*: PSID - PTOKENPRIMARYGROUP* = ptr TTOKEN_PRIMARY_GROUP - TTOKEN_PRIVILEGES* {.final, pure.} = object + PTOKENPRIMARYGROUP* = ptr TTOKEN_PRIMARY_GROUP # Name conflict if we drop the `T` + TTOKEN_PRIVILEGES* {.final, pure.} = object # Name conflict if we drop the `T` PrivilegeCount*: DWORD Privileges*: array[0..(ANYSIZE_ARRAY) - 1, LUID_AND_ATTRIBUTES] PTOKEN_PRIVILEGES* = ptr TTOKEN_PRIVILEGES LPTOKEN_PRIVILEGES* = ptr TTOKEN_PRIVILEGES - TTOKEN_STATISTICS* {.final, pure.} = object + TTOKEN_STATISTICS* {.final, pure.} = object # Name conflict if we drop the `T` TokenId*: LUID AuthenticationId*: LUID ExpirationTime*: LARGE_INTEGER @@ -11850,7 +11500,7 @@ type ModifiedId*: LUID PTOKENSTATISTICS* = ptr TTOKEN_STATISTICS - TTOKEN_USER* {.final, pure.} = object + TTOKEN_USER* {.final, pure.} = object # Name conflict if we drop the `T` User*: SID_AND_ATTRIBUTES PTOKENUSER* = ptr TTOKEN_USER @@ -11864,7 +11514,6 @@ type lpszText*: LPTSTR LPTOOLINFO* = ptr TOOLINFO - TTOOLINFO* = TOOLINFO PTOOLINFO* = ptr TOOLINFO TOOLTIPTEXT* {.final, pure.} = object hdr*: NMHDR @@ -11874,14 +11523,12 @@ type uFlags*: WINUINT LPTOOLTIPTEXT* = ptr TOOLTIPTEXT - TTOOLTIPTEXT* = TOOLTIPTEXT PTOOLTIPTEXT* = ptr TOOLTIPTEXT TPMPARAMS* {.final, pure.} = object cbSize*: WINUINT rcExclude*: RECT LPTPMPARAMS* = ptr TPMPARAMS - TTPMPARAMS* = TPMPARAMS PTPMPARAMS* = ptr TPMPARAMS TRANSMIT_FILE_BUFFERS* {.final, pure.} = object Head*: PVOID @@ -11889,7 +11536,6 @@ type Tail*: PVOID TailLength*: DWORD - TTRANSMITFILEBUFFERS* = TRANSMIT_FILE_BUFFERS PTRANSMITFILEBUFFERS* = ptr TRANSMIT_FILE_BUFFERS TTHITTESTINFO* {.final, pure.} = object hwnd*: HWND @@ -11897,7 +11543,6 @@ type ti*: TOOLINFO LPHITTESTINFO* = ptr TTHITTESTINFO - TTTHITTESTINFO* = TTHITTESTINFO PTTHITTESTINFO* = ptr TTHITTESTINFO TTPOLYCURVE* {.final, pure.} = object wType*: int16 @@ -11905,7 +11550,6 @@ type apfx*: array[0..0, POINTFX] LPTTPOLYCURVE* = ptr TTPOLYCURVE - TTTPOLYCURVE* = TTPOLYCURVE PTTPOLYCURVE* = ptr TTPOLYCURVE TTPOLYGONHEADER* {.final, pure.} = object cb*: DWORD @@ -11913,13 +11557,11 @@ type pfxStart*: POINTFX LPTTPOLYGONHEADER* = ptr TTPOLYGONHEADER - TTTPOLYGONHEADER* = TTPOLYGONHEADER PTTPOLYGONHEADER* = ptr TTPOLYGONHEADER TV_DISPINFO* {.final, pure.} = object hdr*: NMHDR item*: TV_ITEM - TTVDISPINFO* = TV_DISPINFO PTVDISPINFO* = ptr TV_DISPINFO TV_HITTESTINFO* {.final, pure.} = object pt*: POINT @@ -11927,7 +11569,6 @@ type hItem*: HTREEITEM LPTV_HITTESTINFO* = ptr TV_HITTESTINFO - TTVHITTESTINFO* = TV_HITTESTINFO PTVHITTESTINFO* = ptr TV_HITTESTINFO TV_INSERTSTRUCT* {.final, pure.} = object hParent*: HTREEITEM @@ -11935,14 +11576,12 @@ type item*: TV_ITEM LPTV_INSERTSTRUCT* = ptr TV_INSERTSTRUCT - TTVINSERTSTRUCT* = TV_INSERTSTRUCT PTVINSERTSTRUCT* = ptr TV_INSERTSTRUCT TV_KEYDOWN* {.final, pure.} = object hdr*: NMHDR wVKey*: int16 flags*: WINUINT - TTVKEYDOWN* = TV_KEYDOWN PTVKEYDOWN* = ptr TV_KEYDOWN TV_SORTCB* {.final, pure.} = object hParent*: HTREEITEM @@ -11950,25 +11589,21 @@ type lParam*: LPARAM LPTV_SORTCB* = ptr TV_SORTCB - TTVSORTCB* = TV_SORTCB PTVSORTCB* = ptr TV_SORTCB UDACCEL* {.final, pure.} = object nSec*: WINUINT nInc*: WINUINT - TUDACCEL* = UDACCEL PUDACCEL* = ptr UDACCEL UNIVERSAL_NAME_INFO* {.final, pure.} = object lpUniversalName*: LPTSTR - TUNIVERSALNAMEINFO* = UNIVERSAL_NAME_INFO PUNIVERSALNAMEINFO* = ptr UNIVERSAL_NAME_INFO USEROBJECTFLAGS* {.final, pure.} = object fInherit*: WINBOOL fReserved*: WINBOOL dwFlags*: DWORD - TUSEROBJECTFLAGS* = USEROBJECTFLAGS PUSEROBJECTFLAGS* = ptr USEROBJECTFLAGS VALENT* {.final, pure.} = object ve_valuename*: LPTSTR @@ -11976,16 +11611,13 @@ type ve_valueptr*: DWORD ve_type*: DWORD - TVALENT* = VALENT PVALENT* = ptr VALENT value_ent* = VALENT - Tvalue_ent* = VALENT Pvalue_ent* = ptr VALENT VERIFY_INFORMATION* {.final, pure.} = object StartingOffset*: LARGE_INTEGER len*: DWORD - TVERIFYINFORMATION* = VERIFY_INFORMATION PVERIFYINFORMATION* = ptr VERIFY_INFORMATION VS_FIXEDFILEINFO* {.final, pure.} = object dwSignature*: DWORD @@ -12002,7 +11634,6 @@ type dwFileDateMS*: DWORD dwFileDateLS*: DWORD - TVSFIXEDFILEINFO* = VS_FIXEDFILEINFO PVSFIXEDFILEINFO* = ptr VS_FIXEDFILEINFO WIN32_FIND_DATA* {.final, pure.} = object dwFileAttributes*: DWORD @@ -12013,13 +11644,11 @@ type nFileSizeLow*: DWORD dwReserved0*: DWORD dwReserved1*: DWORD - cFileName*: array[0..(MAX_PATH) - 1, TCHAR] - cAlternateFileName*: array[0..13, TCHAR] + cFileName*: array[0..(MAX_PATH) - 1, CHAR] + cAlternateFileName*: array[0..13, CHAR] LPWIN32_FIND_DATA* = ptr WIN32_FIND_DATA PWIN32_FIND_DATA* = ptr WIN32_FIND_DATA - TWIN32FINDDATA* = WIN32_FIND_DATA - TWIN32FINDDATAA* = WIN32_FIND_DATA WIN32_FIND_DATAW* {.final, pure.} = object dwFileAttributes*: DWORD ftCreationTime*: FILETIME @@ -12034,7 +11663,6 @@ type LPWIN32_FIND_DATAW* = ptr WIN32_FIND_DATAW PWIN32_FIND_DATAW* = ptr WIN32_FIND_DATAW - TWIN32FINDDATAW* = WIN32_FIND_DATAW WIN32_STREAM_ID* {.final, pure.} = object dwStreamId*: DWORD dwStreamAttributes*: DWORD @@ -12042,7 +11670,6 @@ type dwStreamNameSize*: DWORD cStreamName*: ptr WCHAR - TWIN32STREAMID* = WIN32_STREAM_ID PWIN32STREAMID* = ptr WIN32_STREAM_ID WINDOWPLACEMENT* {.final, pure.} = object len*: WINUINT @@ -12052,7 +11679,6 @@ type ptMaxPosition*: POINT rcNormalPosition*: RECT - TWINDOWPLACEMENT* = WINDOWPLACEMENT PWINDOWPLACEMENT* = ptr WINDOWPLACEMENT WNDCLASS* {.final, pure.} = object style*: WINUINT @@ -12067,8 +11693,6 @@ type lpszClassName*: LPCTSTR LPWNDCLASS* = ptr WNDCLASS - TWNDCLASS* = WNDCLASS - TWNDCLASSA* = WNDCLASS PWNDCLASS* = ptr WNDCLASS WNDCLASSW* {.final, pure.} = object style*: WINUINT @@ -12083,7 +11707,6 @@ type lpszClassName*: LPCWSTR LPWNDCLASSW* = ptr WNDCLASSW - TWNDCLASSW* = WNDCLASSW PWNDCLASSW* = ptr WNDCLASSW WNDCLASSEX* {.final, pure.} = object cbSize*: WINUINT @@ -12100,8 +11723,6 @@ type hIconSm*: HANDLE LPWNDCLASSEX* = ptr WNDCLASSEX - TWNDCLASSEX* = WNDCLASSEX - TWNDCLASSEXA* = WNDCLASSEX PWNDCLASSEX* = ptr WNDCLASSEX WNDCLASSEXW* {.final, pure.} = object cbSize*: WINUINT @@ -12118,7 +11739,6 @@ type hIconSm*: HANDLE LPWNDCLASSEXW* = ptr WNDCLASSEXW - TWNDCLASSEXW* = WNDCLASSEXW PWNDCLASSEXW* = ptr WNDCLASSEXW CONNECTDLGSTRUCT* {.final, pure.} = object cbStructure*: DWORD @@ -12128,7 +11748,6 @@ type dwDevNum*: DWORD LPCONNECTDLGSTRUCT* = ptr CONNECTDLGSTRUCT - TCONNECTDLGSTRUCT* = CONNECTDLGSTRUCT PCONNECTDLGSTRUCT* = ptr CONNECTDLGSTRUCT DISCDLGSTRUCT* {.final, pure.} = object cbStructure*: DWORD @@ -12138,8 +11757,6 @@ type dwFlags*: DWORD LPDISCDLGSTRUCT* = ptr DISCDLGSTRUCT - TDISCDLGSTRUCT* = DISCDLGSTRUCT - TDISCDLGSTRUCTA* = DISCDLGSTRUCT PDISCDLGSTRUCT* = ptr DISCDLGSTRUCT NETINFOSTRUCT* {.final, pure.} = object cbStructure*: DWORD @@ -12152,7 +11769,6 @@ type dwDrives*: DWORD LPNETINFOSTRUCT* = ptr NETINFOSTRUCT - TNETINFOSTRUCT* = NETINFOSTRUCT PNETINFOSTRUCT* = ptr NETINFOSTRUCT NETCONNECTINFOSTRUCT* {.final, pure.} = object cbStructure*: DWORD @@ -12162,11 +11778,10 @@ type dwOptDataSize*: DWORD LPNETCONNECTINFOSTRUCT* = ptr NETCONNECTINFOSTRUCT - TNETCONNECTINFOSTRUCT* = NETCONNECTINFOSTRUCT PNETCONNECTINFOSTRUCT* = ptr NETCONNECTINFOSTRUCT ENUMMETAFILEPROC* = proc (para1: HDC, para2: HANDLETABLE, para3: METARECORD, para4: int32, para5: LPARAM): int32{.stdcall.} - ENHMETAFILEPROC* = proc (para1: HDC, para2: HANDLETABLE, para3: TENHMETARECORD, + ENHMETAFILEPROC* = proc (para1: HDC, para2: HANDLETABLE, para3: ENHMETARECORD, para4: int32, para5: LPARAM): int32{.stdcall.} ENUMFONTSPROC* = proc (para1: LPLOGFONT, para2: LPTEXTMETRIC, para3: DWORD, para4: LPARAM): int32{.stdcall.} @@ -12181,7 +11796,6 @@ type x*: float32 y*: float32 - TPOINTFLOAT* = POINTFLOAT PPOINTFLOAT* = ptr POINTFLOAT GLYPHMETRICSFLOAT* {.final, pure.} = object gmfBlackBoxX*: float32 @@ -12191,7 +11805,6 @@ type gmfCellIncY*: float32 LPGLYPHMETRICSFLOAT* = ptr GLYPHMETRICSFLOAT - TGLYPHMETRICSFLOAT* = GLYPHMETRICSFLOAT PGLYPHMETRICSFLOAT* = ptr GLYPHMETRICSFLOAT LAYERPLANEDESCRIPTOR* {.final, pure.} = object nSize*: int16 @@ -12220,7 +11833,6 @@ type crTransparent*: COLORREF LPLAYERPLANEDESCRIPTOR* = ptr LAYERPLANEDESCRIPTOR - TLAYERPLANEDESCRIPTOR* = LAYERPLANEDESCRIPTOR PLAYERPLANEDESCRIPTOR* = ptr LAYERPLANEDESCRIPTOR PIXELFORMATDESCRIPTOR* {.final, pure.} = object nSize*: int16 @@ -12251,7 +11863,6 @@ type dwDamageMask*: DWORD LPPIXELFORMATDESCRIPTOR* = ptr PIXELFORMATDESCRIPTOR - TPIXELFORMATDESCRIPTOR* = PIXELFORMATDESCRIPTOR PPIXELFORMATDESCRIPTOR* = ptr PIXELFORMATDESCRIPTOR USER_INFO_2* {.final, pure.} = object usri2_name*: LPWSTR @@ -12281,13 +11892,11 @@ type PUSER_INFO_2* = ptr USER_INFO_2 LPUSER_INFO_2* = ptr USER_INFO_2 - TUSERINFO2* = USER_INFO_2 USER_INFO_0* {.final, pure.} = object usri0_name*: LPWSTR PUSER_INFO_0* = ptr USER_INFO_0 LPUSER_INFO_0* = ptr USER_INFO_0 - TUSERINFO0* = USER_INFO_0 USER_INFO_3* {.final, pure.} = object usri3_name*: LPWSTR usri3_password*: LPWSTR @@ -12321,7 +11930,6 @@ type PUSER_INFO_3* = ptr USER_INFO_3 LPUSER_INFO_3* = ptr USER_INFO_3 - TUSERINFO3* = USER_INFO_3 GROUP_INFO_2* {.final, pure.} = object grpi2_name*: LPWSTR grpi2_comment*: LPWSTR @@ -12329,13 +11937,11 @@ type grpi2_attributes*: DWORD PGROUP_INFO_2* = ptr GROUP_INFO_2 - TGROUPINFO2* = GROUP_INFO_2 LOCALGROUP_INFO_0* {.final, pure.} = object lgrpi0_name*: LPWSTR PLOCALGROUP_INFO_0* = ptr LOCALGROUP_INFO_0 LPLOCALGROUP_INFO_0* = ptr LOCALGROUP_INFO_0 - TLOCALGROUPINFO0* = LOCALGROUP_INFO_0 IMAGE_DOS_HEADER* {.final, pure.} = object e_magic*: int16 e_cblp*: int16 @@ -12358,7 +11964,6 @@ type e_lfanew*: LONG PIMAGE_DOS_HEADER* = ptr IMAGE_DOS_HEADER - TIMAGEDOSHEADER* = IMAGE_DOS_HEADER NOTIFYICONDATAA* {.final, pure.} = object cbSize*: DWORD Wnd*: HWND @@ -12378,15 +11983,99 @@ type hIcon*: HICON szTip*: array[0..63, int16] - TNotifyIconDataA* = NOTIFYICONDATAA - TNotifyIconDataW* = NOTIFYICONDATAW - TNotifyIconData* = TNotifyIconDataA - PNotifyIconDataA* = ptr TNotifyIconDataA - PNotifyIconDataW* = ptr TNotifyIconDataW + PNotifyIconDataA* = ptr NotifyIconDataA + PNotifyIconDataW* = ptr NotifyIconDataW PNotifyIconData* = PNotifyIconDataA - TWOHandleArray* = array[0..MAXIMUM_WAIT_OBJECTS - 1, HANDLE] - PWOHandleArray* = ptr TWOHandleArray + WOHandleArray* = array[0..MAXIMUM_WAIT_OBJECTS - 1, HANDLE] + PWOHandleArray* = ptr WOHandleArray MMRESULT* = int32 +{.deprecated: [TPRINTERNOTIFYINFO: PRINTER_NOTIFY_INFO, TPRINTERNOTIFYINFODATA: PRINTER_NOTIFY_INFO_DATA, + TPRINTERINFO5: PRINTER_INFO_5, TPRINTERINFO4: PRINTER_INFO_4, TPRINTERINFO3: PRINTER_INFO_3, + TPRINTERINFO2: PRINTER_INFO_2, TPRINTERINFO1: PRINTER_INFO_1, TPRINTERDEFAULTS: PRINTER_DEFAULTS, + TPD: TPRINTDLG, TPREVENTMEDIAREMOVAL: PREVENT_MEDIA_REMOVAL, TPORTINFO2: PORT_INFO_2, + TPORTINFO1: PORT_INFO_1, TPOLYTEXT: POLYTEXT, TPERFOBJECTTYPE: PERF_OBJECT_TYPE, + TPERFINSTANCEDEFINITION: PERF_INSTANCE_DEFINITION, TPERFDATABLOCK: PERF_DATA_BLOCK, + TPERFCOUNTERDEFINITION: PERF_COUNTER_DEFINITION, TPERFCOUNTERBLOCK: PERF_COUNTER_BLOCK, + Tparaformat: PARAFORMAT, TPAINTSTRUCT: PAINTSTRUCT, TPSD: TPAGESETUPDLG, TOVERLAPPED: OVERLAPPED, + TOUTLINETEXTMETRIC: OUTLINETEXTMETRIC, TTEXTMETRICW: TEXTMETRICW, TTEXTMETRIC: TEXTMETRIC, + TOSVERSIONINFOW: OSVERSIONINFOW, TOSVERSIONINFO: OSVERSIONINFO, TOFNOTIFY: OFNOTIFY, + TOPENFILENAME_NT4: OPENFILENAME_NT4, TOFSTRUCT: OFSTRUCT, Tnumberfmt: NUMBERFMT, + TNSSERVICEINFO: NS_SERVICE_INFO, TSERVICEINFO: SERVICE_INFO, TCLSID: CLSID, + TSERVICEADDRESSES: SERVICE_ADDRESSES, TSERVICEADDRESS: SERVICE_ADDRESS, + TNONCLIENTMETRICS: NONCLIENTMETRICS, TNMUPDOWN: NM_UPDOWNW, TNMTREEVIEW: NM_TREEVIEW, + TTVITEM: TV_ITEM, TNMLISTVIEW: NM_LISTVIEW, TNEWTEXTMETRICEX: NEWTEXTMETRICEX, + TNEWTEXTMETRIC: NEWTEXTMETRIC].} + +{.deprecated: [TNEWCPLINFO: NEWCPLINFO, TNETRESOURCE: NETRESOURCE, TNETRESOURCEA: NETRESOURCE, + TNDDESHAREINFO: NDDESHAREINFO, TNCB: NCB, TNAMEBUFFER: NAME_BUFFER, TMULTIKEYHELP: MULTIKEYHELP, + Tmsgfilter: MSGFILTER, TMSGBOXPARAMS: MSGBOXPARAMS, TMSGBOXPARAMSA: MSGBOXPARAMS, TMOUSEKEYS: MOUSEKEYS, + TMOUSEHOOKSTRUCT: MOUSEHOOKSTRUCT, TMONMSGSTRUCT: MONMSGSTRUCT, TMONLINKSTRUCT: MONLINKSTRUCT, + TMONITORINFO2: MONITOR_INFO_2, TMONITORINFO1: MONITOR_INFO_1, TMONHSZSTRUCT: MONHSZSTRUCT, + TMONERRSTRUCT: MONERRSTRUCT, TMONCONVSTRUCT: MONCONVSTRUCT, TMONCBSTRUCT: MONCBSTRUCT, + TMODEMSETTINGS: MODEMSETTINGS, TMODEMDEVCAPS: MODEMDEVCAPS, TMINMAXINFO: MINMAXINFO, + TMINIMIZEDMETRICS: MINIMIZEDMETRICS, TMETARECORD: METARECORD, TMETAHEADER: METAHEADER, + TMETAFILEPICT: METAFILEPICT, TMENUTEMPLATE: MENUTEMPLATE, TMENUITEMTEMPLATEHEADER: MENUITEMTEMPLATEHEADER, + TMENUITEMTEMPLATE: MENUITEMTEMPLATE, TMENUITEMINFOA: MENUITEMINFO, TMENUITEMINFO: MENUITEMINFO, + TMENUINFO: MENUINFO, TMENUEXTEMPLATEITEM: MENUEX_TEMPLATE_ITEM, + TMENUXTEMPLATEHEADER: MENUEX_TEMPLATE_HEADER, TMEMORYSTATUS: MEMORYSTATUS, + TMEMORYBASICINFORMATION: MEMORY_BASIC_INFORMATION, TMEASUREITEMSTRUCT: MEASUREITEMSTRUCT, + TMDICREATESTRUCT: MDICREATESTRUCT, TMAT2: MAT2, TLVKEYDOWN: LV_KEYDOWN, TLVHITTESTINFO: LV_HITTESTINFO, + TLVFINDINFO: LV_FINDINFO, TLVDISPINFO: LV_DISPINFO, TLVITEM: LV_ITEM, TLVCOLUMN: LV_COLUMN, + TLUIDANDATTRIBUTESARRAY: LUID_AND_ATTRIBUTES_ARRAY, TLUIDANDATTRIBUTES: LUID_AND_ATTRIBUTES, + TLUID: LUID, TFXPT16DOT16: FXPT16DOT16, TLOCALGROUPMEMBERSINFO3: LOCALGROUP_MEMBERS_INFO_3, + TLOCALGROUPMEMBERSINFO0: LOCALGROUP_MEMBERS_INFO_0, TLOCALESIGNATURE: LOCALESIGNATURE, + TGUID: GUID, TOPENFILENAME: OPENFILENAME].} + +{.deprecated: [TTOGGLEKEYS: TOGGLEKEYS, TTIMEZONEINFORMATION: TIME_ZONE_INFORMATION, + Ttextrange: TEXTRANGE, TTCKEYDOWN: TC_KEYDOWN, TTCITEMHEADER: TC_ITEMHEADER, TTCITEM: TC_ITEM, + TTCHITTESTINFO: TC_HITTESTINFO, TTBSAVEPARAMS: TBSAVEPARAMS, TTBNOTIFY: TBNOTIFY, TTBBUTTON: TBBUTTON, + TTAPEWRITEMARKS: TAPE_WRITE_MARKS, TTAPESETPOSITION: TAPE_SET_POSITION, + TTAPESETMEDIAPARAMETERS: TAPE_SET_MEDIA_PARAMETERS, TTAPESETDRIVEPARAMETERS: TAPE_SET_DRIVE_PARAMETERS, + TTAPEPREPARE: TAPE_PREPARE, TTAPEGETPOSITION: TAPE_GET_POSITION, + TTAPEGETMEDIAPARAMETERS: TAPE_GET_MEDIA_PARAMETERS, TTAPEGETDRIVEPARAMETERS: TAPE_GET_DRIVE_PARAMETERS, + TTAPEERASE: TAPE_ERASE, TSYSTEMPOWERSTATUS: SYSTEM_POWER_STATUS, TSYSTEMINFO: SYSTEM_INFO, + TSYSTEMAUDITACE: SYSTEM_AUDIT_ACE, TSTYLESTRUCT: STYLESTRUCT, TSTYLEBUF: STYLEBUF, TSTRRET: STRRET, + TSTICKYKEYS: STICKYKEYS, TSTARTUPINFO: STARTUPINFO, TSOUNDSENTRY: SOUNDSENTRY, + TSINGLELISTENTRY: SINGLE_LIST_ENTRY, TSIDANDATTRIBUTESARRAY: SID_AND_ATTRIBUTES_ARRAY, + TSIDANDATTRIBUTES: SID_AND_ATTRIBUTES, TSHNAMEMAPPING: SHNAMEMAPPING, TSHGDN: SHGNO, + TSHFILEOPSTRUCT: SHFILEOPSTRUCT, TFILEOPFLAGS: FILEOP_FLAGS, TSHFILEINFO: SHFILEINFO, TSHCONTF: SHCONTF, + TSETPARTITIONINFORMATION: SET_PARTITION_INFORMATION, TSESSIONHEADER: SESSION_HEADER].} + +{.deprecated: [TSESSIONBUFFER: SESSION_BUFFER, TSERVICETYPEINFOABS: SERVICE_TYPE_INFO_ABS, + TSERVICETYPEVALUEABS: SERVICE_TYPE_VALUE_ABS, TSERVICETABLEENTRY: SERVICE_TABLE_ENTRY, + TSERIALKEYS: SERIALKEYS, Tselchange: SELCHANGE, TSECURITYINFORMATION: SECURITY_INFORMATION, + TSECURITYATTRIBUTES: SECURITY_ATTRIBUTES, TSCROLLINFO: SCROLLINFO, TRGNDATA: RGNDATA, + TRGNDATAHEADER: RGNDATAHEADER, Treqresize: REQRESIZE, Trepastespecial: REPASTESPECIAL, + TREMOTENAMEINFO: REMOTE_NAME_INFO, TREASSIGNBLOCKS: REASSIGN_BLOCKS, TRASTERIZERSTATUS: RASTERIZER_STATUS, + TRASPPPNBF: RASPPPNBF, TRASPPPIPX: RASPPPIPX, TRASPPPIP: RASPPPIP, TRASENTRYNAME: RASENTRYNAME, + TRASDIALPARAMS: RASDIALPARAMS, TRASDIALEXTENSIONS: RASDIALEXTENSIONS, TRASCONNSTATUS: RASCONNSTATUS, + TRASCONN: RASCONN, TRASAMB: RASAMB, Tpunctuation: PUNCTUATION, TPSHNOTIFY: PSHNOTIFY, + TPROVIDORINFO1: PROVIDOR_INFO_1, TPROTOCOLINFO: PROTOCOL_INFO, + TFNADDPROPSHEETPAGES: LPFNADDPROPSHEETPAGES, TFNADDPROPSHEETPAGE: LPFNADDPROPSHEETPAGE, + TPROPSHEETHEADER: PROPSHEETHEADER, TPROPSHEETPAGE: PROPSHEETPAGE, TFNPSPCALLBACK: LPFNPSPCALLBACK, + TPROCESSINFORMATION: PROCESS_INFORMATION, TPROCESSHEAPENTRY: PROCESS_HEAPENTRY, + TPRIVILEGESET: PRIVILEGE_SET, TPRINTPROCESSORINFO1: PRINTPROCESSOR_INFO_1, + TPRINTERNOTIFYOPTIONS: PRINTER_NOTIFY_OPTIONS, TPRINTERNOTIFYOPTIONSTYPE: PRINTER_NOTIFY_OPTIONS_TYPE].} + +{.deprecated: [TNotifyIconDataA: NOTIFYICONDATAA, TNotifyIconDataW: NOTIFYICONDATAW, + TNotifyIconData: NotifyIconDataA, TIMAGEDOSHEADER: IMAGE_DOS_HEADER, TLOCALGROUPINFO0: LOCALGROUP_INFO_0, + TGROUPINFO2: GROUP_INFO_2, TUSERINFO3: USER_INFO_3, TUSERINFO0: USER_INFO_0, TUSERINFO2: USER_INFO_2, + TPIXELFORMATDESCRIPTOR: PIXELFORMATDESCRIPTOR, TLAYERPLANEDESCRIPTOR: LAYERPLANEDESCRIPTOR, + TGLYPHMETRICSFLOAT: GLYPHMETRICSFLOAT, TPOINTFLOAT: POINTFLOAT, + TNETCONNECTINFOSTRUCT: NETCONNECTINFOSTRUCT, TNETINFOSTRUCT: NETINFOSTRUCT, + TDISCDLGSTRUCT: DISCDLGSTRUCT, TDISCDLGSTRUCTA: DISCDLGSTRUCT, TCONNECTDLGSTRUCT: CONNECTDLGSTRUCT, + TWNDCLASSEXW: WNDCLASSEXW, TWNDCLASSEX: WNDCLASSEX, TWNDCLASSEXA: WNDCLASSEX, TWNDCLASSW: WNDCLASSW, + TWNDCLASS: WNDCLASS, TWNDCLASSA: WNDCLASS, TWINDOWPLACEMENT: WINDOWPLACEMENT, + TWIN32STREAMID: WIN32_STREAM_ID, TWIN32FINDDATAW: WIN32_FIND_DATAW, TWIN32FINDDATAA: WIN32_FIND_DATA, + TWIN32FINDDATA: WIN32_FIND_DATA, TVSFIXEDFILEINFO: VS_FIXEDFILEINFO, + TVERIFYINFORMATION: VERIFY_INFORMATION, Tvalue_ent: VALENT, TVALENT: VALENT, + TUSEROBJECTFLAGS: USEROBJECTFLAGS, TUNIVERSALNAMEINFO: UNIVERSAL_NAME_INFO, TUDACCEL: UDACCEL, + TTVSORTCB: TV_SORTCB, TTVKEYDOWN: TV_KEYDOWN, TTVINSERTSTRUCT: TV_INSERTSTRUCT, + TTVHITTESTINFO: TV_HITTESTINFO, TTVDISPINFO: TV_DISPINFO, TTTPOLYGONHEADER: TTPOLYGONHEADER, + TTTPOLYCURVE: TTPOLYCURVE, TTTHITTESTINFO: TTHITTESTINFO, TTRANSMITFILEBUFFERS: TRANSMIT_FILE_BUFFERS, + TTPMPARAMS: TPMPARAMS, TTOOLTIPTEXT: TOOLTIPTEXT, TTOOLINFO: TOOLINFO, + TTOKENCONTROL: TOKEN_CONTROL, TWOHandleArray: WOHandleArray].} + type PWaveFormatEx* = ptr TWaveFormatEx @@ -13643,13 +13332,13 @@ type TWMNCHitTest* {.final, pure.} = object Msg*: WINUINT Unused*: int32 - Pos*: TSmallPoint + Pos*: SmallPoint Result*: LRESULT TWMMouse* {.final, pure.} = object Msg*: WINUINT Keys*: int32 - Pos*: TSmallPoint + Pos*: SmallPoint Result*: LRESULT TWMLButtonDblClk* = TWMMouse @@ -13662,7 +13351,7 @@ type Msg*: WINUINT Keys*: int16 WheelDelta*: int16 - Pos*: TSmallPoint + Pos*: SmallPoint Result*: LRESULT TWMNCHitMessage* {.final, pure.} = object @@ -13718,7 +13407,7 @@ type TWMContextMenu* {.final, pure.} = object Msg*: WINUINT hWnd*: HWND - Pos*: TSmallPoint + Pos*: SmallPoint Result*: LRESULT TWMNCCalcSize* {.final, pure.} = object @@ -13776,7 +13465,7 @@ type TWMMove* {.final, pure.} = object Msg*: WINUINT Unused*: int - Pos*: TSmallPoint + Pos*: SmallPoint Result*: LRESULT TWMWindowPosMsg* {.final, pure.} = object @@ -13915,7 +13604,7 @@ type TWMSizeClipboard* {.final, pure.} = object Msg*: WINUINT Viewer*: HWND - RC*: THandle + RC*: Handle Result*: LRESULT TWMSpoolerStatus* {.final, pure.} = object @@ -13950,7 +13639,7 @@ type TWMTimer* {.final, pure.} = object Msg*: WINUINT TimerID*: LPARAM - TimerProc*: TFarProc + TimerProc*: FarProc Result*: LRESULT TWMUndo* = TWMNoParams @@ -13970,7 +13659,7 @@ type TWMDropFiles* {.final, pure.} = object Msg*: WINUINT - Drop*: THANDLE + Drop*: HANDLE Unused*: LPARAM Result*: LRESULT @@ -18513,11 +18202,15 @@ proc DisableThreadLibraryCalls*(hLibModule: HMODULE): WINBOOL{.stdcall, proc GetProcAddress*(hModule: HINST, lpProcName: LPCSTR): FARPROC{.stdcall, dynlib: "kernel32", importc: "GetProcAddress".} proc GetVersion*(): DWORD{.stdcall, dynlib: "kernel32", importc: "GetVersion".} -proc GlobalAlloc*(uFlags: int32, dwBytes: DWORD): HGLOBAL{.stdcall, +proc GlobalAlloc*(uFlags: int32, dwBytes: SIZE_T): HGLOBAL{.stdcall, dynlib: "kernel32", importc: "GlobalAlloc".} -proc GlobalReAlloc*(hMem: HGLOBAL, dwBytes: DWORD, uFlags: int32): HGLOBAL{. +proc GlobalAlloc*(uFlags: int32, dwBytes: DWORD): HGLOBAL{.stdcall, + dynlib: "kernel32", importc: "GlobalAlloc", deprecated.} +proc GlobalReAlloc*(hMem: HGLOBAL, dwBytes: SIZE_T, uFlags: int32): HGLOBAL{. stdcall, dynlib: "kernel32", importc: "GlobalReAlloc".} -proc GlobalSize*(hMem: HGLOBAL): DWORD{.stdcall, dynlib: "kernel32", +proc GlobalReAlloc*(hMem: HGLOBAL, dwBytes: DWORD, uFlags: int32): HGLOBAL{. + stdcall, dynlib: "kernel32", importc: "GlobalReAlloc", deprecated.} +proc GlobalSize*(hMem: HGLOBAL): SIZE_T{.stdcall, dynlib: "kernel32", importc: "GlobalSize".} proc GlobalFlags*(hMem: HGLOBAL): WINUINT{.stdcall, dynlib: "kernel32", importc: "GlobalFlags".} @@ -18541,10 +18234,14 @@ proc GlobalUnWire*(hMem: HGLOBAL): WINBOOL{.stdcall, dynlib: "kernel32", importc: "GlobalUnWire".} proc GlobalMemoryStatus*(lpBuffer: LPMEMORYSTATUS){.stdcall, dynlib: "kernel32", importc: "GlobalMemoryStatus".} -proc LocalAlloc*(uFlags: WINUINT, uBytes: WINUINT): HLOCAL{.stdcall, +proc LocalAlloc*(uFlags: WINUINT, uBytes: SIZE_T): HLOCAL{.stdcall, dynlib: "kernel32", importc: "LocalAlloc".} -proc LocalReAlloc*(hMem: HLOCAL, uBytes: WINUINT, uFlags: WINUINT): HLOCAL{.stdcall, +proc LocalAlloc*(uFlags: WINUINT, uBytes: DWORD): HLOCAL{.stdcall, + dynlib: "kernel32", importc: "LocalAlloc", deprecated.} +proc LocalReAlloc*(hMem: HLOCAL, uBytes: SIZE_T, uFlags: WINUINT): HLOCAL{.stdcall, dynlib: "kernel32", importc: "LocalReAlloc".} +proc LocalReAlloc*(hMem: HLOCAL, uBytes: DWORD, uFlags: WINUINT): HLOCAL{.stdcall, + dynlib: "kernel32", importc: "LocalReAlloc", deprecated.} proc LocalLock*(hMem: HLOCAL): LPVOID{.stdcall, dynlib: "kernel32", importc: "LocalLock".} proc LocalHandle*(pMem: LPCVOID): HLOCAL{.stdcall, dynlib: "kernel32", @@ -18564,38 +18261,71 @@ proc LocalCompact*(uMinFree: WINUINT): WINUINT{.stdcall, dynlib: "kernel32", proc FlushInstructionCache*(hProcess: HANDLE, lpBaseAddress: LPCVOID, dwSize: DWORD): WINBOOL{.stdcall, dynlib: "kernel32", importc: "FlushInstructionCache".} -proc VirtualAlloc*(lpAddress: LPVOID, dwSize: DWORD, flAllocationType: DWORD, +proc VirtualAlloc*(lpAddress: LPVOID, dwSize: SIZE_T, flAllocationType: DWORD, flProtect: DWORD): LPVOID{.stdcall, dynlib: "kernel32", importc: "VirtualAlloc".} -proc VirtualFree*(lpAddress: LPVOID, dwSize: DWORD, dwFreeType: DWORD): WINBOOL{. +proc VirtualAlloc*(lpAddress: LPVOID, dwSize: DWORD, flAllocationType: DWORD, + flProtect: DWORD): LPVOID{.stdcall, dynlib: "kernel32", + importc: "VirtualAlloc", deprecated.} +proc VirtualAllocEx*(hProcess: HANDLE, lpAddress: LPVOID, dwSize: SIZE_T, + flAllocationType: DWORD, flProtect: DWORD): LPVOID + {.stdcall, dynlib: "kernel32", importc: "VirtualAllocEx".} +proc VirtualAllocEx*(hProcess: HANDLE, lpAddress: LPVOID, dwSize: DWORD, + flAllocationType: DWORD, flProtect: DWORD): LPVOID + {.stdcall, dynlib: "kernel32", importc: "VirtualAllocEx", + deprecated.} +proc VirtualFree*(lpAddress: LPVOID, dwSize: SIZE_T, dwFreeType: DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "VirtualFree".} -proc VirtualProtect*(lpAddress: LPVOID, dwSize: DWORD, flNewProtect: DWORD, +proc VirtualFree*(lpAddress: LPVOID, dwSize: DWORD, dwFreeType: DWORD): WINBOOL{. + stdcall, dynlib: "kernel32", importc: "VirtualFree", deprecated.} +proc VirtualFreeEx*(hProcess: HANDLE, lpAddress: LPVOID, dwSize: SIZE_T, + dwFreeType: DWORD): WINBOOL + {.stdcall, dynlib: "kernel32", importc: "VirtualFree".} +proc VirtualFreeEx*(hProcess: HANDLE, lpAddress: LPVOID, dwSize: DWORD, + dwFreeType: DWORD): WINBOOL + {.stdcall, dynlib: "kernel32", importc: "VirtualFree".} +proc VirtualProtect*(lpAddress: LPVOID, dwSize: SIZE_T, flNewProtect: DWORD, lpflOldProtect: PDWORD): WINBOOL{.stdcall, dynlib: "kernel32", importc: "VirtualProtect".} +proc VirtualProtect*(lpAddress: LPVOID, dwSize: DWORD, flNewProtect: DWORD, + lpflOldProtect: PDWORD): WINBOOL{.stdcall, + dynlib: "kernel32", importc: "VirtualProtect", deprecated.} proc VirtualQuery*(lpAddress: LPCVOID, lpBuffer: PMEMORY_BASIC_INFORMATION, dwLength: DWORD): DWORD{.stdcall, dynlib: "kernel32", importc: "VirtualQuery".} -proc VirtualProtectEx*(hProcess: HANDLE, lpAddress: LPVOID, dwSize: DWORD, +proc VirtualProtectEx*(hProcess: HANDLE, lpAddress: LPVOID, dwSize: SIZE_T, flNewProtect: DWORD, lpflOldProtect: PDWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "VirtualProtectEx".} +proc VirtualProtectEx*(hProcess: HANDLE, lpAddress: LPVOID, dwSize: DWORD, + flNewProtect: DWORD, lpflOldProtect: PDWORD): WINBOOL{. + stdcall, dynlib: "kernel32", importc: "VirtualProtectEx", deprecated.} proc VirtualQueryEx*(hProcess: HANDLE, lpAddress: LPCVOID, - lpBuffer: PMEMORY_BASIC_INFORMATION, dwLength: DWORD): DWORD{. + lpBuffer: PMEMORY_BASIC_INFORMATION, dwLength: SIZE_T): DWORD{. stdcall, dynlib: "kernel32", importc: "VirtualQueryEx".} -proc HeapCreate*(flOptions: DWORD, dwInitialSize: DWORD, dwMaximumSize: DWORD): HANDLE{. +proc VirtualQueryEx*(hProcess: HANDLE, lpAddress: LPCVOID, + lpBuffer: PMEMORY_BASIC_INFORMATION, dwLength: DWORD): DWORD{. + stdcall, dynlib: "kernel32", importc: "VirtualQueryEx", deprecated.} +proc HeapCreate*(flOptions: DWORD, dwInitialSize: SIZE_T, dwMaximumSize: SIZE_T): HANDLE{. stdcall, dynlib: "kernel32", importc: "HeapCreate".} +proc HeapCreate*(flOptions: DWORD, dwInitialSize: DWORD, dwMaximumSize: DWORD): HANDLE{. + stdcall, dynlib: "kernel32", importc: "HeapCreate", deprecated.} proc HeapDestroy*(hHeap: HANDLE): WINBOOL{.stdcall, dynlib: "kernel32", importc: "HeapDestroy".} -proc HeapAlloc*(hHeap: HANDLE, dwFlags: DWORD, dwBytes: DWORD): LPVOID{.stdcall, +proc HeapAlloc*(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T): LPVOID{.stdcall, dynlib: "kernel32", importc: "HeapAlloc".} -proc HeapReAlloc*(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID, dwBytes: DWORD): LPVOID{. +proc HeapAlloc*(hHeap: HANDLE, dwFlags: DWORD, dwBytes: DWORD): LPVOID{.stdcall, + dynlib: "kernel32", importc: "HeapAlloc", deprecated.} +proc HeapReAlloc*(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID, dwBytes: SIZE_T): LPVOID{. stdcall, dynlib: "kernel32", importc: "HeapReAlloc".} +proc HeapReAlloc*(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID, dwBytes: DWORD): LPVOID{. + stdcall, dynlib: "kernel32", importc: "HeapReAlloc", deprecated.} proc HeapFree*(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID): WINBOOL{.stdcall, dynlib: "kernel32", importc: "HeapFree".} -proc HeapSize*(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPCVOID): DWORD{.stdcall, +proc HeapSize*(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPCVOID): SIZE_T{.stdcall, dynlib: "kernel32", importc: "HeapSize".} proc HeapValidate*(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPCVOID): WINBOOL{. stdcall, dynlib: "kernel32", importc: "HeapValidate".} -proc HeapCompact*(hHeap: HANDLE, dwFlags: DWORD): WINUINT{.stdcall, +proc HeapCompact*(hHeap: HANDLE, dwFlags: DWORD): SIZE_T{.stdcall, dynlib: "kernel32", importc: "HeapCompact".} proc GetProcessHeap*(): HANDLE{.stdcall, dynlib: "kernel32", importc: "GetProcessHeap".} @@ -18632,7 +18362,7 @@ proc ExitProcess*(uExitCode: WINUINT){.stdcall, dynlib: "kernel32", importc: "ExitProcess".} proc TerminateProcess*(hProcess: HANDLE, uExitCode: WINUINT): WINBOOL{.stdcall, dynlib: "kernel32", importc: "TerminateProcess".} -proc SetProcessAffinityMask*(hProcess: THandle, dwProcessAffinityMask: DWORD): WINBOOL{. +proc SetProcessAffinityMask*(hProcess: Handle, dwProcessAffinityMask: DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "SetProcessAffinityMask".} proc GetExitCodeProcess*(hProcess: HANDLE, lpExitCode: LPDWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetExitCodeProcess".} @@ -19221,10 +18951,14 @@ proc FindNextChangeNotification*(hChangeHandle: HANDLE): WINBOOL{.stdcall, dynlib: "kernel32", importc: "FindNextChangeNotification".} proc FindCloseChangeNotification*(hChangeHandle: HANDLE): WINBOOL{.stdcall, dynlib: "kernel32", importc: "FindCloseChangeNotification".} -proc VirtualLock*(lpAddress: LPVOID, dwSize: DWORD): WINBOOL{.stdcall, +proc VirtualLock*(lpAddress: LPVOID, dwSize: SIZE_T): WINBOOL{.stdcall, dynlib: "kernel32", importc: "VirtualLock".} -proc VirtualUnlock*(lpAddress: LPVOID, dwSize: DWORD): WINBOOL{.stdcall, +proc VirtualLock*(lpAddress: LPVOID, dwSize: DWORD): WINBOOL{.stdcall, + dynlib: "kernel32", importc: "VirtualLock", deprecated.} +proc VirtualUnlock*(lpAddress: LPVOID, dwSize: SIZE_T): WINBOOL{.stdcall, dynlib: "kernel32", importc: "VirtualUnlock".} +proc VirtualUnlock*(lpAddress: LPVOID, dwSize: DWORD): WINBOOL{.stdcall, + dynlib: "kernel32", importc: "VirtualUnlock", deprecated.} proc MapViewOfFileEx*(hFileMappingObject: HANDLE, dwDesiredAccess: DWORD, dwFileOffsetHigh: DWORD, dwFileOffsetLow: DWORD, dwNumberOfBytesToMap: DWORD, lpBaseAddress: LPVOID): LPVOID{. @@ -20170,7 +19904,7 @@ proc GetWinMetaFileBits*(para1: HENHMETAFILE, para2: WINUINT, para3: LPBYTE, proc PlayEnhMetaFile*(para1: HDC, para2: HENHMETAFILE, para3: RECT): WINBOOL{. stdcall, dynlib: "gdi32", importc: "PlayEnhMetaFile".} proc PlayEnhMetaFileRecord*(para1: HDC, para2: LPHANDLETABLE, - para3: var TENHMETARECORD, para4: WINUINT): WINBOOL{. + para3: var ENHMETARECORD, para4: WINUINT): WINBOOL{. stdcall, dynlib: "gdi32", importc: "PlayEnhMetaFileRecord".} proc SetEnhMetaFileBits*(para1: WINUINT, para2: var int8): HENHMETAFILE{.stdcall, dynlib: "gdi32", importc: "SetEnhMetaFileBits".} @@ -20210,7 +19944,7 @@ proc StartPage*(para1: HDC): int32{.stdcall, dynlib: "gdi32", importc: "StartPage".} proc EndPage*(para1: HDC): int32{.stdcall, dynlib: "gdi32", importc: "EndPage".} proc AbortDoc*(para1: HDC): int32{.stdcall, dynlib: "gdi32", importc: "AbortDoc".} -proc SetAbortProc*(para1: HDC, para2: TABORTPROC): int32{.stdcall, +proc SetAbortProc*(para1: HDC, para2: ABORTPROC): int32{.stdcall, dynlib: "gdi32", importc: "SetAbortProc".} proc ArcTo*(para1: HDC, para2: int32, para3: int32, para4: int32, para5: int32, para6: int32, para7: int32, para8: int32, para9: int32): WINBOOL{. @@ -20687,7 +20421,7 @@ proc wglDescribeLayerPlane*(para1: HDC, para2: int32, para3: int32, para4: WINUI proc wglGetLayerPaletteEntries*(para1: HDC, para2: int32, para3: int32, para4: int32, para5: var COLORREF): int32{. stdcall, dynlib: "opengl32", importc: "wglGetLayerPaletteEntries".} -proc wglGetProcAddress*(para1: LPCSTR): TProc{.stdcall, dynlib: "opengl32", +proc wglGetProcAddress*(para1: LPCSTR): Proc{.stdcall, dynlib: "opengl32", importc: "wglGetProcAddress".} proc wglRealizeLayerPalette*(para1: HDC, para2: int32, para3: WINBOOL): WINBOOL{. stdcall, dynlib: "opengl32", importc: "wglRealizeLayerPalette".} @@ -20878,7 +20612,7 @@ proc SetLayeredWindowAttributes*(hwnd: HWND, crKey: COLORREF, bAlpha: int8, dynlib: "user32", importc: "SetLayeredWindowAttributes".} type PIID* = PGUID - TIID* = TGUID + TIID* = GUID TFNDlgProc* = FARPROC TFNThreadStartRoutine* = FARPROC TFNTimerAPCRoutine* = FARPROC @@ -20911,7 +20645,7 @@ type TMaxLogPalette* {.final, pure.} = object palVersion*: int16 palNumEntries*: int16 - palPalEntry*: array[int8, TPaletteEntry] + palPalEntry*: array[int8, PaletteEntry] PMaxLogPalette* = ptr TMaxLogPalette POSVersionInfoA* = POSVERSIONINFO @@ -21037,60 +20771,60 @@ proc SetCriticalSectionSpinCount*(CriticalSection: var TRTLCriticalSection, proc TryEnterCriticalSection*(CriticalSection: var TRTLCriticalSection): WINBOOL{. stdcall, dynlib: "kernel32", importc: "TryEnterCriticalSection".} proc ControlService*(hService: SC_HANDLE, dwControl: DWORD, - ServiceStatus: var TSERVICESTATUS): WINBOOL{.stdcall, + ServiceStatus: var SERVICESTATUS): WINBOOL{.stdcall, dynlib: "advapi32", importc: "ControlService".} proc QueryServiceStatus*(hService: SC_HANDLE, - lpServiceStatus: var TSERVICESTATUS): WINBOOL{.stdcall, + lpServiceStatus: var SERVICESTATUS): WINBOOL{.stdcall, dynlib: "advapi32", importc: "QueryServiceStatus".} proc SetServiceStatus*(hServiceStatus: SERVICE_STATUS_HANDLE, - ServiceStatus: TSERVICESTATUS): WINBOOL{.stdcall, + ServiceStatus: SERVICESTATUS): WINBOOL{.stdcall, dynlib: "advapi32", importc: "SetServiceStatus".} -proc AdjustTokenPrivileges*(TokenHandle: THandle, DisableAllPrivileges: WINBOOL, +proc AdjustTokenPrivileges*(TokenHandle: Handle, DisableAllPrivileges: WINBOOL, NewState: TTokenPrivileges, BufferLength: DWORD, PreviousState: var TTokenPrivileges, ReturnLength: var DWORD): WINBOOL{.stdcall, dynlib: "advapi32", importc: "AdjustTokenPrivileges".} -proc AdjustWindowRect*(lpRect: var TRect, dwStyle: DWORD, bMenu: WINBOOL): WINBOOL{. +proc AdjustWindowRect*(lpRect: var Rect, dwStyle: DWORD, bMenu: WINBOOL): WINBOOL{. stdcall, dynlib: "user32", importc: "AdjustWindowRect".} -proc AdjustWindowRectEx*(lpRect: var TRect, dwStyle: DWORD, bMenu: WINBOOL, +proc AdjustWindowRectEx*(lpRect: var Rect, dwStyle: DWORD, bMenu: WINBOOL, dwExStyle: DWORD): WINBOOL{.stdcall, dynlib: "user32", importc: "AdjustWindowRectEx".} -proc AllocateAndInitializeSid*(pIdentifierAuthority: TSIDIdentifierAuthority, +proc AllocateAndInitializeSid*(pIdentifierAuthority: SIDIdentifierAuthority, nSubAuthorityCount: int8, nSubAuthority0, nSubAuthority1: DWORD, nSubAuthority2, nSubAuthority3, nSubAuthority4: DWORD, nSubAuthority5, nSubAuthority6, nSubAuthority7: DWORD, pSid: var pointer): WINBOOL{.stdcall, dynlib: "advapi32", importc: "AllocateAndInitializeSid".} -proc AllocateLocallyUniqueId*(Luid: var TLargeInteger): WINBOOL{.stdcall, +proc AllocateLocallyUniqueId*(Luid: var LargeInteger): WINBOOL{.stdcall, dynlib: "advapi32", importc: "AllocateLocallyUniqueId".} -proc BackupRead*(hFile: THandle, lpBuffer: PByte, nNumberOfBytesToRead: DWORD, +proc BackupRead*(hFile: Handle, lpBuffer: PByte, nNumberOfBytesToRead: DWORD, lpNumberOfBytesRead: var DWORD, bAbort: WINBOOL, bProcessSecurity: WINBOOL, lpContext: var pointer): WINBOOL{. stdcall, dynlib: "kernel32", importc: "BackupRead".} -proc BackupSeek*(hFile: THandle, dwLowBytesToSeek, dwHighBytesToSeek: DWORD, +proc BackupSeek*(hFile: Handle, dwLowBytesToSeek, dwHighBytesToSeek: DWORD, lpdwLowByteSeeked, lpdwHighByteSeeked: var DWORD, lpContext: pointer): WINBOOL{.stdcall, dynlib: "kernel32", importc: "BackupSeek".} -proc BackupWrite*(hFile: THandle, lpBuffer: PByte, nNumberOfBytesToWrite: DWORD, +proc BackupWrite*(hFile: Handle, lpBuffer: PByte, nNumberOfBytesToWrite: DWORD, lpNumberOfBytesWritten: var DWORD, bAbort, bProcessSecurity: WINBOOL, lpContext: var pointer): WINBOOL{. stdcall, dynlib: "kernel32", importc: "BackupWrite".} -proc BeginPaint*(wnd: HWND, lpPaint: var TPaintStruct): HDC{.stdcall, +proc BeginPaint*(wnd: HWND, lpPaint: var PaintStruct): HDC{.stdcall, dynlib: "user32", importc: "BeginPaint".} -proc BuildCommDCB*(lpDef: cstring, lpDCB: var TDCB): WINBOOL{.stdcall, +proc BuildCommDCB*(lpDef: cstring, lpDCB: var DCB): WINBOOL{.stdcall, dynlib: "kernel32", importc: "BuildCommDCBA".} -proc BuildCommDCBA*(lpDef: LPCSTR, lpDCB: var TDCB): WINBOOL{.stdcall, +proc BuildCommDCBA*(lpDef: LPCSTR, lpDCB: var DCB): WINBOOL{.stdcall, dynlib: "kernel32", importc: "BuildCommDCBA".} -proc BuildCommDCBAndTimeouts*(lpDef: cstring, lpDCB: var TDCB, - lpCommTimeouts: var TCommTimeouts): WINBOOL{. +proc BuildCommDCBAndTimeouts*(lpDef: cstring, lpDCB: var DCB, + lpCommTimeouts: var CommTimeouts): WINBOOL{. stdcall, dynlib: "kernel32", importc: "BuildCommDCBAndTimeoutsA".} -proc BuildCommDCBAndTimeoutsA*(lpDef: LPCSTR, lpDCB: var TDCB, - lpCommTimeouts: var TCommTimeouts): WINBOOL{. +proc BuildCommDCBAndTimeoutsA*(lpDef: LPCSTR, lpDCB: var DCB, + lpCommTimeouts: var CommTimeouts): WINBOOL{. stdcall, dynlib: "kernel32", importc: "BuildCommDCBAndTimeoutsA".} -proc BuildCommDCBAndTimeoutsW*(lpDef: LPWSTR, lpDCB: var TDCB, - lpCommTimeouts: var TCommTimeouts): WINBOOL{. +proc BuildCommDCBAndTimeoutsW*(lpDef: LPWSTR, lpDCB: var DCB, + lpCommTimeouts: var CommTimeouts): WINBOOL{. stdcall, dynlib: "kernel32", importc: "BuildCommDCBAndTimeoutsW".} -proc BuildCommDCBW*(lpDef: LPWSTR, lpDCB: var TDCB): WINBOOL{.stdcall, +proc BuildCommDCBW*(lpDef: LPWSTR, lpDCB: var DCB): WINBOOL{.stdcall, dynlib: "kernel32", importc: "BuildCommDCBW".} proc CallMsgFilter*(lpMsg: var TMsg, nCode: int): WINBOOL{.stdcall, dynlib: "user32", importc: "CallMsgFilterA".} @@ -21113,45 +20847,45 @@ proc CallNamedPipeW*(lpNamedPipeName: LPWSTR, lpInBuffer: pointer, nOutBufferSize: DWORD, lpBytesRead: var DWORD, nTimeOut: DWORD): WINBOOL{.stdcall, dynlib: "kernel32", importc: "CallNamedPipeW".} -proc CoRegisterClassObject*(para1: TCLSID, para2: pointer, para3: DWORD, +proc CoRegisterClassObject*(para1: CLSID, para2: pointer, para3: DWORD, para4: DWORD, out_para5: DWORD): HRESULT{.stdcall, dynlib: "ole32.dll", importc: "CoRegisterClassObject".} -proc ChangeDisplaySettings*(lpDevMode: var TDeviceMode, dwFlags: DWORD): int32{. +proc ChangeDisplaySettings*(lpDevMode: var DevMode, dwFlags: DWORD): int32{. stdcall, dynlib: "user32", importc: "ChangeDisplaySettingsA".} -proc ChangeDisplaySettingsA*(lpDevMode: var TDeviceModeA, dwFlags: DWORD): int32{. +proc ChangeDisplaySettingsA*(lpDevMode: var DevMode, dwFlags: DWORD): int32{. stdcall, dynlib: "user32", importc: "ChangeDisplaySettingsA".} proc ChangeDisplaySettingsEx*(lpszDeviceName: cstring, - lpDevMode: var TDeviceMode, wnd: HWND, + lpDevMode: var DevMode, wnd: HWND, dwFlags: DWORD, lParam: pointer): int32{.stdcall, dynlib: "user32", importc: "ChangeDisplaySettingsExA".} proc ChangeDisplaySettingsExA*(lpszDeviceName: LPCSTR, - lpDevMode: var TDeviceModeA, wnd: HWND, + lpDevMode: var DevMode, wnd: HWND, dwFlags: DWORD, lParam: pointer): int32{.stdcall, dynlib: "user32", importc: "ChangeDisplaySettingsExA".} proc ChangeDisplaySettingsExW*(lpszDeviceName: LPWSTR, - lpDevMode: var TDeviceModeW, wnd: HWND, + lpDevMode: var DevModeW, wnd: HWND, dwFlags: DWORD, lParam: pointer): int32{.stdcall, dynlib: "user32", importc: "ChangeDisplaySettingsExW".} -proc ChangeDisplaySettingsW*(lpDevMode: var TDeviceModeW, dwFlags: DWORD): int32{. +proc ChangeDisplaySettingsW*(lpDevMode: var DevModeW, dwFlags: DWORD): int32{. stdcall, dynlib: "user32", importc: "ChangeDisplaySettingsW".} #function CheckColorsInGamut(DC: HDC; var RGBQuads, Results; Count: DWORD): WINBOOL; stdcall; external 'gdi32' name 'CheckColorsInGamut'; proc ChoosePixelFormat*(para1: HDC, para2: var PIXELFORMATDESCRIPTOR): int32{. stdcall, dynlib: "gdi32", importc: "ChoosePixelFormat".} -proc ClearCommError*(hFile: THandle, lpErrors: var DWORD, lpStat: PComStat): WINBOOL{. +proc ClearCommError*(hFile: Handle, lpErrors: var DWORD, lpStat: PComStat): WINBOOL{. stdcall, dynlib: "kernel32", importc: "ClearCommError".} -proc ClientToScreen*(wnd: HWND, lpPoint: var TPoint): WINBOOL{.stdcall, +proc ClientToScreen*(wnd: HWND, lpPoint: var Point): WINBOOL{.stdcall, dynlib: "user32", importc: "ClientToScreen".} proc ClipCursor*(lpRect: var RECT): WINBOOL{.stdcall, dynlib: "user32", importc: "ClipCursor".} - #function CombineTransform(var p1: TXForm; const p2, p3: TXForm): WINBOOL; stdcall; external 'gdi32' name 'CombineTransform'; -proc CommConfigDialog*(lpszName: cstring, wnd: HWND, lpCC: var TCommConfig): WINBOOL{. + #function CombineTransform(var p1: XForm; const p2, p3: XForm): WINBOOL; stdcall; external 'gdi32' name 'CombineTransform'; +proc CommConfigDialog*(lpszName: cstring, wnd: HWND, lpCC: var CommConfig): WINBOOL{. stdcall, dynlib: "kernel32", importc: "CommConfigDialogA".} -proc CommConfigDialogA*(lpszName: LPCSTR, wnd: HWND, lpCC: var TCommConfig): WINBOOL{. +proc CommConfigDialogA*(lpszName: LPCSTR, wnd: HWND, lpCC: var CommConfig): WINBOOL{. stdcall, dynlib: "kernel32", importc: "CommConfigDialogA".} -proc CommConfigDialogW*(lpszName: LPWSTR, wnd: HWND, lpCC: var TCommConfig): WINBOOL{. +proc CommConfigDialogW*(lpszName: LPWSTR, wnd: HWND, lpCC: var CommConfig): WINBOOL{. stdcall, dynlib: "kernel32", importc: "CommConfigDialogW".} - #function CompareFileTime(const lpFileTime1, lpFileTime2: TFileTime): Longint; stdcall; external 'kernel32' name 'CompareFileTime'; - #function ConvertToAutoInheritPrivateObjectSecurity(ParentDescriptor, CurrentSecurityDescriptor: PSecurityDescriptor; var NewDescriptor: PSecurityDescriptor; ObjectType: PGUID; IsDirectoryObject: WINBOOL; const GenericMapping: TGenericMapping): WINBOOL; + #function CompareFileTime(const lpFileTime1, lpFileTime2: FileTime): Longint; stdcall; external 'kernel32' name 'CompareFileTime'; + #function ConvertToAutoInheritPrivateObjectSecurity(ParentDescriptor, CurrentSecurityDescriptor: PSecurityDescriptor; var NewDescriptor: PSecurityDescriptor; ObjectType: PGUID; IsDirectoryObject: WINBOOL; const GenericMapping: GenericMapping): WINBOOL; # stdcall; external 'advapi32' name 'ConvertToAutoInheritPrivateObjectSecurity'; proc CopyAcceleratorTable*(hAccelSrc: HACCEL, lpAccelDst: pointer, cAccelEntries: int): int{.stdcall, dynlib: "user32", @@ -21162,7 +20896,7 @@ proc CopyAcceleratorTableA*(hAccelSrc: HACCEL, lpAccelDst: pointer, proc CopyAcceleratorTableW*(hAccelSrc: HACCEL, lpAccelDst: pointer, cAccelEntries: int): int{.stdcall, dynlib: "user32", importc: "CopyAcceleratorTableW".} -proc CopyRect*(lprcDst: var TRect, lprcSrc: TRect): WINBOOL{.stdcall, +proc CopyRect*(lprcDst: var Rect, lprcSrc: Rect): WINBOOL{.stdcall, dynlib: "user32", importc: "CopyRect".} proc CreateAcceleratorTable*(Accel: pointer, Count: int): HACCEL{.stdcall, dynlib: "user32", importc: "CreateAcceleratorTableA".} @@ -21170,105 +20904,105 @@ proc CreateAcceleratorTableA*(Accel: pointer, Count: int): HACCEL{.stdcall, dynlib: "user32", importc: "CreateAcceleratorTableA".} proc CreateAcceleratorTableW*(Accel: pointer, Count: int): HACCEL{.stdcall, dynlib: "user32", importc: "CreateAcceleratorTableW".} - #function CreateBitmapIndirect(const p1: TBitmap): HBITMAP; stdcall; external 'gdi32' name 'CreateBitmapIndirect'; - #function CreateBrushIndirect(const p1: TLogBrush): HBRUSH; stdcall; external 'gdi32' name 'CreateBrushIndirect'; -proc CreateColorSpace*(ColorSpace: var TLogColorSpace): HCOLORSPACE{.stdcall, + #function CreateBitmapIndirect(const p1: Bitmap): HBITMAP; stdcall; external 'gdi32' name 'CreateBitmapIndirect'; + #function CreateBrushIndirect(const p1: LogBrush): HBRUSH; stdcall; external 'gdi32' name 'CreateBrushIndirect'; +proc CreateColorSpace*(ColorSpace: var LogColorSpace): HCOLORSPACE{.stdcall, dynlib: "gdi32", importc: "CreateColorSpaceA".} -proc CreateColorSpaceA*(ColorSpace: var TLogColorSpaceA): HCOLORSPACE{.stdcall, +proc CreateColorSpaceA*(ColorSpace: var LogColorSpace): HCOLORSPACE{.stdcall, dynlib: "gdi32", importc: "CreateColorSpaceA".} - #function CreateColorSpaceW(var ColorSpace: TLogColorSpaceW): HCOLORSPACE; stdcall; external 'gdi32' name 'CreateColorSpaceW'; -proc CreateDialogIndirectParam*(hInstance: HINST, lpTemplate: TDlgTemplate, + #function CreateColorSpaceW(var ColorSpace: LogColorSpaceW): HCOLORSPACE; stdcall; external 'gdi32' name 'CreateColorSpaceW'; +proc CreateDialogIndirectParam*(hInstance: HINST, lpTemplate: DlgTemplate, hWndParent: HWND, lpDialogFunc: TFNDlgProc, dwInitParam: LPARAM): HWND{.stdcall, dynlib: "user32", importc: "CreateDialogIndirectParamA".} - #function CreateDialogIndirectParamA(hInstance: HINST; const lpTemplate: TDlgTemplate; hWndParent: HWND; lpDialogFunc: TFNDlgProc; dwInitParam: LPARAM): HWND; stdcall; external 'user32' name 'CreateDialogIndirectParamA'; - #function CreateDialogIndirectParamW(hInstance: HINST; const lpTemplate: TDlgTemplate; hWndParent: HWND; lpDialogFunc: TFNDlgProc; dwInitParam: LPARAM): HWND; stdcall; external 'user32' name 'CreateDialogIndirectParamW'; - #function CreateDIBitmap(DC: HDC; var InfoHeader: TBitmapInfoHeader; dwUsage: DWORD; InitBits: PChar; var InitInfo: TBitmapInfo; wUsage: WINUINT): HBITMAP; stdcall; external 'gdi32' name 'CreateDIBitmap'; + #function CreateDialogIndirectParamA(hInstance: HINST; const lpTemplate: DlgTemplate; hWndParent: HWND; lpDialogFunc: TFNDlgProc; dwInitParam: LPARAM): HWND; stdcall; external 'user32' name 'CreateDialogIndirectParamA'; + #function CreateDialogIndirectParamW(hInstance: HINST; const lpTemplate: DlgTemplate; hWndParent: HWND; lpDialogFunc: TFNDlgProc; dwInitParam: LPARAM): HWND; stdcall; external 'user32' name 'CreateDialogIndirectParamW'; + #function CreateDIBitmap(DC: HDC; var InfoHeader: BitmapInfoHeader; dwUsage: DWORD; InitBits: PChar; var InitInfo: BitmapInfo; wUsage: WINUINT): HBITMAP; stdcall; external 'gdi32' name 'CreateDIBitmap'; #function CreateDIBPatternBrushPt(const p1: pointer; p2: WINUINT): HBRUSH; stdcall; external 'gdi32' name 'CreateDIBPatternBrushPt'; - #function CreateDIBSection(DC: HDC; const p2: TBitmapInfo; p3: WINUINT; var p4: pointer; p5: THandle; p6: DWORD): HBITMAP; stdcall; external 'gdi32' name 'CreateDIBSection'; - #function CreateEllipticRgnIndirect(const p1: TRect): HRGN; stdcall; external 'gdi32' name 'CreateEllipticRgnIndirect'; - #function CreateFontIndirect(const p1: TLogFont): HFONT;stdcall; external 'gdi32' name 'CreateFontIndirectA'; - #function CreateFontIndirectA(const p1: TLogFontA): HFONT; stdcall; external 'gdi32' name 'CreateFontIndirectA'; + #function CreateDIBSection(DC: HDC; const p2: BitmapInfo; p3: WINUINT; var p4: pointer; p5: Handle; p6: DWORD): HBITMAP; stdcall; external 'gdi32' name 'CreateDIBSection'; + #function CreateEllipticRgnIndirect(const p1: Rect): HRGN; stdcall; external 'gdi32' name 'CreateEllipticRgnIndirect'; + #function CreateFontIndirect(const p1: LogFont): HFONT;stdcall; external 'gdi32' name 'CreateFontIndirectA'; + #function CreateFontIndirectA(const p1: LogFont): HFONT; stdcall; external 'gdi32' name 'CreateFontIndirectA'; #function CreateFontIndirectEx(const p1: PEnumLogFontExDV): HFONT;stdcall; external 'gdi32' name 'CreateFontIndirectExA'; #function CreateFontIndirectExA(const p1: PEnumLogFontExDVA): HFONT;stdcall; external 'gdi32' name 'CreateFontIndirectExA'; #function CreateFontIndirectExW(const p1: PEnumLogFontExDVW): HFONT;stdcall; external 'gdi32' name 'CreateFontIndirectExW'; - #function CreateFontIndirectW(const p1: TLogFontW): HFONT; stdcall; external 'gdi32' name 'CreateFontIndirectW'; -proc CreateIconIndirect*(piconinfo: var TIconInfo): HICON{.stdcall, + #function CreateFontIndirectW(const p1: LogFontW): HFONT; stdcall; external 'gdi32' name 'CreateFontIndirectW'; +proc CreateIconIndirect*(piconinfo: var IconInfo): HICON{.stdcall, dynlib: "user32", importc: "CreateIconIndirect".} - #function CreatePalette(const LogPalette: TLogPalette): HPalette; stdcall; external 'gdi32' name 'CreatePalette'; - #function CreatePenIndirect(const LogPen: TLogPen): HPEN; stdcall; external 'gdi32' name 'CreatePenIndirect'; -proc CreatePipe*(hReadPipe, hWritePipe: var THandle, + #function CreatePalette(const LogPalette: LogPalette): HPalette; stdcall; external 'gdi32' name 'CreatePalette'; + #function CreatePenIndirect(const LogPen: LogPen): HPEN; stdcall; external 'gdi32' name 'CreatePenIndirect'; +proc CreatePipe*(hReadPipe, hWritePipe: var Handle, lpPipeAttributes: PSecurityAttributes, nSize: DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "CreatePipe".} proc CreatePolygonRgn*(Points: pointer, Count, FillMode: int): HRGN{.stdcall, dynlib: "gdi32", importc: "CreatePolygonRgn".} proc CreatePolyPolygonRgn*(pPtStructs: pointer, pIntArray: pointer, p3, p4: int): HRGN{. stdcall, dynlib: "gdi32", importc: "CreatePolyPolygonRgn".} - #function CreatePrivateObjectSecurity(ParentDescriptor, CreatorDescriptor: PSecurityDescriptor; var NewDescriptor: PSecurityDescriptor; IsDirectoryObject: WINBOOL; Token: THandle; const GenericMapping: TGenericMapping): WINBOOL; + #function CreatePrivateObjectSecurity(ParentDescriptor, CreatorDescriptor: PSecurityDescriptor; var NewDescriptor: PSecurityDescriptor; IsDirectoryObject: WINBOOL; Token: Handle; const GenericMapping: GenericMapping): WINBOOL; # stdcall; external 'advapi32' name 'CreatePrivateObjectSecurity'; - #function CreatePrivateObjectSecurityEx(ParentDescriptor, CreatorDescriptor: PSecurityDescriptor; var NewDescriptor: PSecurityDescriptor; ObjectType: PGUID; IsContainerObject: WINBOOL; AutoInheritFlags: ULONG; Token: THandle; - # const GenericMapping: TGenericMapping): WINBOOL;stdcall; external 'advapi32' name 'CreatePrivateObjectSecurityEx'; + #function CreatePrivateObjectSecurityEx(ParentDescriptor, CreatorDescriptor: PSecurityDescriptor; var NewDescriptor: PSecurityDescriptor; ObjectType: PGUID; IsContainerObject: WINBOOL; AutoInheritFlags: ULONG; Token: Handle; + # const GenericMapping: GenericMapping): WINBOOL;stdcall; external 'advapi32' name 'CreatePrivateObjectSecurityEx'; proc CreateProcess*(lpApplicationName: cstring, lpCommandLine: cstring, lpProcessAttributes, lpThreadAttributes: PSecurityAttributes, bInheritHandles: WINBOOL, dwCreationFlags: DWORD, lpEnvironment: pointer, lpCurrentDirectory: cstring, - lpStartupInfo: TStartupInfo, - lpProcessInformation: var TProcessInformation): WINBOOL{. + lpStartupInfo: StartupInfo, + lpProcessInformation: var ProcessInformation): WINBOOL{. stdcall, dynlib: "kernel32", importc: "CreateProcessA".} proc CreateProcessA*(lpApplicationName: LPCSTR, lpCommandLine: LPCSTR, lpProcessAttributes, lpThreadAttributes: PSecurityAttributes, bInheritHandles: WINBOOL, dwCreationFlags: DWORD, lpEnvironment: pointer, lpCurrentDirectory: LPCSTR, - lpStartupInfo: TStartupInfo, - lpProcessInformation: var TProcessInformation): WINBOOL{. + lpStartupInfo: StartupInfo, + lpProcessInformation: var ProcessInformation): WINBOOL{. stdcall, dynlib: "kernel32", importc: "CreateProcessA".} - #function CreateProcessAsUser(hToken: THandle; lpApplicationName: PChar; lpCommandLine: PChar; lpProcessAttributes: PSecurityAttributes; lpThreadAttributes: PSecurityAttributes; bInheritHandles: WINBOOL; dwCreationFlags: DWORD; - # lpEnvironment: pointer; lpCurrentDirectory: PChar; const lpStartupInfo: TStartupInfo; var lpProcessInformation: TProcessInformation): WINBOOL;stdcall; external 'advapi32' name 'CreateProcessAsUserA'; - #function CreateProcessAsUserA(hToken: THandle; lpApplicationName: LPCSTR; lpCommandLine: LPCSTR; lpProcessAttributes: PSecurityAttributes; lpThreadAttributes: PSecurityAttributes; bInheritHandles: WINBOOL; dwCreationFlags: DWORD; - # lpEnvironment: pointer; lpCurrentDirectory: LPCSTR; const lpStartupInfo: TStartupInfo; var lpProcessInformation: TProcessInformation): WINBOOL; stdcall; external 'advapi32' name 'CreateProcessAsUserA'; - #function CreateProcessAsUserW(hToken: THandle; lpApplicationName: LPWSTR; lpCommandLine: LPWSTR; lpProcessAttributes: PSecurityAttributes; lpThreadAttributes: PSecurityAttributes; bInheritHandles: WINBOOL; dwCreationFlags: DWORD; - # lpEnvironment: pointer; lpCurrentDirectory: LPWSTR; const lpStartupInfo: TStartupInfo; var lpProcessInformation: TProcessInformation): WINBOOL; stdcall; external 'advapi32' name 'CreateProcessAsUserW'; + #function CreateProcessAsUser(hToken: Handle; lpApplicationName: PChar; lpCommandLine: PChar; lpProcessAttributes: PSecurityAttributes; lpThreadAttributes: PSecurityAttributes; bInheritHandles: WINBOOL; dwCreationFlags: DWORD; + # lpEnvironment: pointer; lpCurrentDirectory: PChar; const lpStartupInfo: StartupInfo; var lpProcessInformation: ProcessInformation): WINBOOL;stdcall; external 'advapi32' name 'CreateProcessAsUserA'; + #function CreateProcessAsUserA(hToken: Handle; lpApplicationName: LPCSTR; lpCommandLine: LPCSTR; lpProcessAttributes: PSecurityAttributes; lpThreadAttributes: PSecurityAttributes; bInheritHandles: WINBOOL; dwCreationFlags: DWORD; + # lpEnvironment: pointer; lpCurrentDirectory: LPCSTR; const lpStartupInfo: StartupInfo; var lpProcessInformation: ProcessInformation): WINBOOL; stdcall; external 'advapi32' name 'CreateProcessAsUserA'; + #function CreateProcessAsUserW(hToken: Handle; lpApplicationName: LPWSTR; lpCommandLine: LPWSTR; lpProcessAttributes: PSecurityAttributes; lpThreadAttributes: PSecurityAttributes; bInheritHandles: WINBOOL; dwCreationFlags: DWORD; + # lpEnvironment: pointer; lpCurrentDirectory: LPWSTR; const lpStartupInfo: StartupInfo; var lpProcessInformation: ProcessInformation): WINBOOL; stdcall; external 'advapi32' name 'CreateProcessAsUserW'; proc CreateProcessW*(lpApplicationName: LPWSTR, lpCommandLine: LPWSTR, lpProcessAttributes, lpThreadAttributes: PSecurityAttributes, bInheritHandles: WINBOOL, dwCreationFlags: DWORD, lpEnvironment: pointer, lpCurrentDirectory: LPWSTR, - lpStartupInfo: TStartupInfo, - lpProcessInformation: var TProcessInformation): WINBOOL{. + lpStartupInfo: StartupInfo, + lpProcessInformation: var ProcessInformation): WINBOOL{. stdcall, dynlib: "kernel32", importc: "CreateProcessW".} - #function CreateRectRgnIndirect(const p1: TRect): HRGN; stdcall; external 'gdi32' name 'CreateRectRgnIndirect'; -proc CreateRemoteThread*(hProcess: THandle, lpThreadAttributes: pointer, + #function CreateRectRgnIndirect(const p1: Rect): HRGN; stdcall; external 'gdi32' name 'CreateRectRgnIndirect'; +proc CreateRemoteThread*(hProcess: Handle, lpThreadAttributes: pointer, dwStackSize: DWORD, lpStartAddress: TFNThreadStartRoutine, lpParameter: pointer, dwCreationFlags: DWORD, - lpThreadId: var DWORD): THandle{.stdcall, + lpThreadId: var DWORD): Handle{.stdcall, dynlib: "kernel32", importc: "CreateRemoteThread".} proc CreateThread*(lpThreadAttributes: pointer, dwStackSize: DWORD, lpStartAddress: TFNThreadStartRoutine, lpParameter: pointer, - dwCreationFlags: DWORD, lpThreadId: var DWORD): THandle{. + dwCreationFlags: DWORD, lpThreadId: var DWORD): Handle{. stdcall, dynlib: "kernel32", importc: "CreateThread".} proc DdeSetQualityOfService*(hWndClient: HWnd, - pqosNew: TSecurityQualityOfService, + pqosNew: SecurityQualityOfService, pqosPrev: PSecurityQualityOfService): WINBOOL{. stdcall, dynlib: "user32", importc: "DdeSetQualityOfService".} - #function DeleteAce(var pAcl: TACL; dwAceIndex: DWORD): WINBOOL; stdcall; external 'advapi32' name 'DeleteAce'; + #function DeleteAce(var pAcl: ACL; dwAceIndex: DWORD): WINBOOL; stdcall; external 'advapi32' name 'DeleteAce'; proc DescribePixelFormat*(DC: HDC, p2: int, p3: WINUINT, - p4: var TPixelFormatDescriptor): WINBOOL{.stdcall, + p4: var PixelFormatDescriptor): WINBOOL{.stdcall, dynlib: "gdi32", importc: "DescribePixelFormat".} #function DestroyPrivateObjectSecurity(var ObjectDescriptor: PSecurityDescriptor): WINBOOL; stdcall; external 'advapi32' name 'DestroyPrivateObjectSecurity'; -proc DeviceIoControl*(hDevice: THandle, dwIoControlCode: DWORD, +proc DeviceIoControl*(hDevice: Handle, dwIoControlCode: DWORD, lpInBuffer: pointer, nInBufferSize: DWORD, lpOutBuffer: pointer, nOutBufferSize: DWORD, lpBytesReturned: var DWORD, lpOverlapped: POverlapped): WINBOOL{. stdcall, dynlib: "kernel32", importc: "DeviceIoControl".} -proc DialogBoxIndirectParam*(hInstance: HINST, lpDialogTemplate: TDlgTemplate, +proc DialogBoxIndirectParam*(hInstance: HINST, lpDialogTemplate: DlgTemplate, hWndParent: HWND, lpDialogFunc: TFNDlgProc, dwInitParam: LPARAM): int{.stdcall, dynlib: "user32", importc: "DialogBoxIndirectParamA".} -proc DialogBoxIndirectParamA*(hInstance: HINST, lpDialogTemplate: TDlgTemplate, +proc DialogBoxIndirectParamA*(hInstance: HINST, lpDialogTemplate: DlgTemplate, hWndParent: HWND, lpDialogFunc: TFNDlgProc, dwInitParam: LPARAM): int{.stdcall, dynlib: "user32", importc: "DialogBoxIndirectParamA".} -proc DialogBoxIndirectParamW*(hInstance: HINST, lpDialogTemplate: TDlgTemplate, +proc DialogBoxIndirectParamW*(hInstance: HINST, lpDialogTemplate: DlgTemplate, hWndParent: HWND, lpDialogFunc: TFNDlgProc, dwInitParam: LPARAM): int{.stdcall, dynlib: "user32", importc: "DialogBoxIndirectParamW".} @@ -21278,109 +21012,109 @@ proc DispatchMessageA*(lpMsg: TMsg): int32{.stdcall, dynlib: "user32", importc: "DispatchMessageA".} proc DispatchMessageW*(lpMsg: TMsg): int32{.stdcall, dynlib: "user32", importc: "DispatchMessageW".} -proc DosDateTimeToFileTime*(wFatDate, wFatTime: int16, lpFileTime: var TFileTime): WINBOOL{. +proc DosDateTimeToFileTime*(wFatDate, wFatTime: int16, lpFileTime: var FileTime): WINBOOL{. stdcall, dynlib: "kernel32", importc: "DosDateTimeToFileTime".} proc DPtoLP*(DC: HDC, Points: pointer, Count: int): WINBOOL{.stdcall, dynlib: "gdi32", importc: "DPtoLP".} - # function DrawAnimatedRects(wnd: HWND; idAni: Integer; const lprcFrom, lprcTo: TRect): WINBOOL; stdcall; external 'user32' name 'DrawAnimatedRects'; - #function DrawCaption(p1: HWND; p2: HDC; const p3: TRect; p4: WINUINT): WINBOOL; stdcall; external 'user32' name 'DrawCaption'; -proc DrawEdge*(hdc: HDC, qrc: var TRect, edge: WINUINT, grfFlags: WINUINT): WINBOOL{. + # function DrawAnimatedRects(wnd: HWND; idAni: Integer; const lprcFrom, lprcTo: Rect): WINBOOL; stdcall; external 'user32' name 'DrawAnimatedRects'; + #function DrawCaption(p1: HWND; p2: HDC; const p3: Rect; p4: WINUINT): WINBOOL; stdcall; external 'user32' name 'DrawCaption'; +proc DrawEdge*(hdc: HDC, qrc: var Rect, edge: WINUINT, grfFlags: WINUINT): WINBOOL{. stdcall, dynlib: "user32", importc: "DrawEdge".} - #function DrawFocusRect(hDC: HDC; const lprc: TRect): WINBOOL; stdcall; external 'user32' name 'DrawFocusRect'; -proc DrawFrameControl*(DC: HDC, Rect: TRect, uType, uState: WINUINT): WINBOOL{. + #function DrawFocusRect(hDC: HDC; const lprc: Rect): WINBOOL; stdcall; external 'user32' name 'DrawFocusRect'; +proc DrawFrameControl*(DC: HDC, Rect: Rect, uType, uState: WINUINT): WINBOOL{. stdcall, dynlib: "user32", importc: "DrawFrameControl".} -proc DrawText*(hDC: HDC, lpString: cstring, nCount: int, lpRect: var TRect, +proc DrawText*(hDC: HDC, lpString: cstring, nCount: int, lpRect: var Rect, uFormat: WINUINT): int{.stdcall, dynlib: "user32", importc: "DrawTextA".} -proc DrawTextA*(hDC: HDC, lpString: LPCSTR, nCount: int, lpRect: var TRect, +proc DrawTextA*(hDC: HDC, lpString: LPCSTR, nCount: int, lpRect: var Rect, uFormat: WINUINT): int{.stdcall, dynlib: "user32", importc: "DrawTextA".} -proc DrawTextEx*(DC: HDC, lpchText: cstring, cchText: int, p4: var TRect, +proc DrawTextEx*(DC: HDC, lpchText: cstring, cchText: int, p4: var Rect, dwDTFormat: WINUINT, DTParams: PDrawTextParams): int{.stdcall, dynlib: "user32", importc: "DrawTextExA".} -proc DrawTextExA*(DC: HDC, lpchText: LPCSTR, cchText: int, p4: var TRect, +proc DrawTextExA*(DC: HDC, lpchText: LPCSTR, cchText: int, p4: var Rect, dwDTFormat: WINUINT, DTParams: PDrawTextParams): int{.stdcall, dynlib: "user32", importc: "DrawTextExA".} -proc DrawTextExW*(DC: HDC, lpchText: LPWSTR, cchText: int, p4: var TRect, +proc DrawTextExW*(DC: HDC, lpchText: LPWSTR, cchText: int, p4: var Rect, dwDTFormat: WINUINT, DTParams: PDrawTextParams): int{.stdcall, dynlib: "user32", importc: "DrawTextExW".} -proc DrawTextW*(hDC: HDC, lpString: LPWSTR, nCount: int, lpRect: var TRect, +proc DrawTextW*(hDC: HDC, lpString: LPWSTR, nCount: int, lpRect: var Rect, uFormat: WINUINT): int{.stdcall, dynlib: "user32", importc: "DrawTextW".} - #function DuplicateTokenEx(hExistingToken: THandle; dwDesiredAccess: DWORD; lpTokenAttributes: PSecurityAttributes; ImpersonationLevel: TSecurityImpersonationLevel; TokenType: TTokenType; var phNewToken: THandle): WINBOOL; + #function DuplicateTokenEx(hExistingToken: Handle; dwDesiredAccess: DWORD; lpTokenAttributes: PSecurityAttributes; ImpersonationLevel: TSecurityImpersonationLevel; TokenType: TTokenType; var phNewToken: Handle): WINBOOL; # stdcall; external 'advapi32' name 'DuplicateTokenEx'; -proc EndPaint*(wnd: HWND, lpPaint: TPaintStruct): WINBOOL{.stdcall, +proc EndPaint*(wnd: HWND, lpPaint: PaintStruct): WINBOOL{.stdcall, dynlib: "user32", importc: "EndPaint".} #function EnumDisplayDevices(Unused: pointer; iDevNum: DWORD; var lpDisplayDevice: TDisplayDevice; dwFlags: DWORD): WINBOOL;stdcall; external 'user32' name 'EnumDisplayDevicesA'; #function EnumDisplayDevicesA(Unused: pointer; iDevNum: DWORD; var lpDisplayDevice: TDisplayDeviceA; dwFlags: DWORD): WINBOOL;stdcall; external 'user32' name 'EnumDisplayDevicesA'; #function EnumDisplayDevicesW(Unused: pointer; iDevNum: DWORD; var lpDisplayDevice: TDisplayDeviceW; dwFlags: DWORD): WINBOOL;stdcall; external 'user32' name 'EnumDisplayDevicesW'; proc EnumDisplaySettings*(lpszDeviceName: cstring, iModeNum: DWORD, - lpDevMode: var TDeviceMode): WINBOOL{.stdcall, + lpDevMode: var DevMode): WINBOOL{.stdcall, dynlib: "user32", importc: "EnumDisplaySettingsA".} proc EnumDisplaySettingsA*(lpszDeviceName: LPCSTR, iModeNum: DWORD, - lpDevMode: var TDeviceModeA): WINBOOL{.stdcall, + lpDevMode: var DevMode): WINBOOL{.stdcall, dynlib: "user32", importc: "EnumDisplaySettingsA".} proc EnumDisplaySettingsW*(lpszDeviceName: LPWSTR, iModeNum: DWORD, - lpDevMode: var TDeviceModeW): WINBOOL{.stdcall, + lpDevMode: var DevModeW): WINBOOL{.stdcall, dynlib: "user32", importc: "EnumDisplaySettingsW".} - #function EnumEnhMetaFile(DC: HDC; p2: HENHMETAFILE; p3: TFNEnhMFEnumProc; p4: pointer; const p5: TRect): WINBOOL; stdcall; external 'gdi32' name 'EnumEnhMetaFile'; - #function EnumFontFamiliesEx(DC: HDC; var p2: TLogFont; p3: TFNFontEnumProc; p4: LPARAM; p5: DWORD): WINBOOL;stdcall; external 'gdi32' name 'EnumFontFamiliesExA'; - #function EnumFontFamiliesExA(DC: HDC; var p2: TLogFontA; p3: TFNFontEnumProcA; p4: LPARAM; p5: DWORD): WINBOOL; stdcall; external 'gdi32' name 'EnumFontFamiliesExA'; - #function EnumFontFamiliesExW(DC: HDC; var p2: TLogFontW; p3: TFNFontEnumProcW; p4: LPARAM; p5: DWORD): WINBOOL; stdcall; external 'gdi32' name 'EnumFontFamiliesExW'; - #function EqualRect(const lprc1, lprc2: TRect): WINBOOL; stdcall; external 'user32' name 'EqualRect'; -proc ExtCreatePen*(PenStyle, Width: DWORD, Brush: TLogBrush, StyleCount: DWORD, + #function EnumEnhMetaFile(DC: HDC; p2: HENHMETAFILE; p3: TFNEnhMFEnumProc; p4: pointer; const p5: Rect): WINBOOL; stdcall; external 'gdi32' name 'EnumEnhMetaFile'; + #function EnumFontFamiliesEx(DC: HDC; var p2: LogFont; p3: TFNFontEnumProc; p4: LPARAM; p5: DWORD): WINBOOL;stdcall; external 'gdi32' name 'EnumFontFamiliesExA'; + #function EnumFontFamiliesExA(DC: HDC; var p2: LogFont; p3: TFNFontEnumProcA; p4: LPARAM; p5: DWORD): WINBOOL; stdcall; external 'gdi32' name 'EnumFontFamiliesExA'; + #function EnumFontFamiliesExW(DC: HDC; var p2: LogFontW; p3: TFNFontEnumProcW; p4: LPARAM; p5: DWORD): WINBOOL; stdcall; external 'gdi32' name 'EnumFontFamiliesExW'; + #function EqualRect(const lprc1, lprc2: Rect): WINBOOL; stdcall; external 'user32' name 'EqualRect'; +proc ExtCreatePen*(PenStyle, Width: DWORD, Brush: LogBrush, StyleCount: DWORD, Style: pointer): HPEN{.stdcall, dynlib: "gdi32", importc: "ExtCreatePen".} -proc ExtCreateRegion*(p1: PXForm, p2: DWORD, p3: TRgnData): HRGN{.stdcall, +proc ExtCreateRegion*(p1: PXForm, p2: DWORD, p3: RgnData): HRGN{.stdcall, dynlib: "gdi32", importc: "ExtCreateRegion".} # function ExtEscape(DC: HDC; p2, p3: Integer; const p4: LPCSTR; p5: Integer; p6: LPSTR): Integer; stdcall; external 'gdi32' name 'ExtEscape'; -proc FileTimeToDosDateTime*(lpFileTime: TFileTime, +proc FileTimeToDosDateTime*(lpFileTime: FileTime, lpFatDate, lpFatTime: var int16): WINBOOL{.stdcall, dynlib: "kernel32", importc: "FileTimeToDosDateTime".} -proc FileTimeToLocalFileTime*(lpFileTime: TFileTime, - lpLocalFileTime: var TFileTime): WINBOOL{.stdcall, +proc FileTimeToLocalFileTime*(lpFileTime: FileTime, + lpLocalFileTime: var FileTime): WINBOOL{.stdcall, dynlib: "kernel32", importc: "FileTimeToLocalFileTime".} -proc FileTimeToSystemTime*(lpFileTime: TFileTime, lpSystemTime: var TSystemTime): WINBOOL{. +proc FileTimeToSystemTime*(lpFileTime: FileTime, lpSystemTime: var SystemTime): WINBOOL{. stdcall, dynlib: "kernel32", importc: "FileTimeToSystemTime".} -proc FillConsoleOutputAttribute*(hConsoleOutput: THandle, wAttribute: int16, - nLength: DWORD, dwWriteCoord: TCoord, +proc FillConsoleOutputAttribute*(hConsoleOutput: Handle, wAttribute: int16, + nLength: DWORD, dwWriteCoord: Coord, lpNumberOfAttrsWritten: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "FillConsoleOutputAttribute".} -proc FillConsoleOutputCharacter*(hConsoleOutput: THandle, cCharacter: char, - nLength: DWORD, dwWriteCoord: TCoord, +proc FillConsoleOutputCharacter*(hConsoleOutput: Handle, cCharacter: char, + nLength: DWORD, dwWriteCoord: Coord, lpNumberOfCharsWritten: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "FillConsoleOutputCharacterA".} -proc FillConsoleOutputCharacterA*(hConsoleOutput: THandle, cCharacter: char, - nLength: DWORD, dwWriteCoord: TCoord, +proc FillConsoleOutputCharacterA*(hConsoleOutput: Handle, cCharacter: char, + nLength: DWORD, dwWriteCoord: Coord, lpNumberOfCharsWritten: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "FillConsoleOutputCharacterA".} -proc FillConsoleOutputCharacterW*(hConsoleOutput: THandle, cCharacter: WideChar, - nLength: DWORD, dwWriteCoord: TCoord, +proc FillConsoleOutputCharacterW*(hConsoleOutput: Handle, cCharacter: WideChar, + nLength: DWORD, dwWriteCoord: Coord, lpNumberOfCharsWritten: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "FillConsoleOutputCharacterW".} - #function FillRect(hDC: HDC; const lprc: TRect; hbr: HBRUSH): Integer; stdcall; external 'user32' name 'FillRect'; -proc FindFirstFile*(lpFileName: cstring, lpFindFileData: var TWIN32FindData): THandle{. + #function FillRect(hDC: HDC; const lprc: Rect; hbr: HBRUSH): Integer; stdcall; external 'user32' name 'FillRect'; +proc FindFirstFile*(lpFileName: cstring, lpFindFileData: var WIN32FindData): Handle{. stdcall, dynlib: "kernel32", importc: "FindFirstFileA".} -proc FindFirstFileA*(lpFileName: LPCSTR, lpFindFileData: var TWIN32FindDataA): THandle{. +proc FindFirstFileA*(lpFileName: LPCSTR, lpFindFileData: var WIN32FindData): Handle{. stdcall, dynlib: "kernel32", importc: "FindFirstFileA".} -proc FindFirstFileW*(lpFileName: LPWSTR, lpFindFileData: var TWIN32FindDataW): THandle{. +proc FindFirstFileW*(lpFileName: LPWSTR, lpFindFileData: var WIN32FindDataW): Handle{. stdcall, dynlib: "kernel32", importc: "FindFirstFileW".} - #function FindFirstFreeAce(var pAcl: TACL; var pAce: pointer): WINBOOL; stdcall; external 'advapi32' name 'FindFirstFreeAce'; -proc FindNextFile*(hFindFile: THandle, lpFindFileData: var TWIN32FindData): WINBOOL{. + #function FindFirstFreeAce(var pAcl: ACL; var pAce: pointer): WINBOOL; stdcall; external 'advapi32' name 'FindFirstFreeAce'; +proc FindNextFile*(hFindFile: Handle, lpFindFileData: var WIN32FindData): WINBOOL{. stdcall, dynlib: "kernel32", importc: "FindNextFileA".} -proc FindNextFileA*(hFindFile: THandle, lpFindFileData: var TWIN32FindDataA): WINBOOL{. +proc FindNextFileA*(hFindFile: Handle, lpFindFileData: var WIN32FindData): WINBOOL{. stdcall, dynlib: "kernel32", importc: "FindNextFileA".} -proc FindNextFileW*(hFindFile: THandle, lpFindFileData: var TWIN32FindDataW): WINBOOL{. +proc FindNextFileW*(hFindFile: Handle, lpFindFileData: var WIN32FindDataW): WINBOOL{. stdcall, dynlib: "kernel32", importc: "FindNextFileW".} - #function FlushInstructionCache(hProcess: THandle; const lpBaseAddress: pointer; dwSize: DWORD): WINBOOL; stdcall; external 'kernel32' name 'FlushInstructionCache'; + #function FlushInstructionCache(hProcess: Handle; const lpBaseAddress: pointer; dwSize: DWORD): WINBOOL; stdcall; external 'kernel32' name 'FlushInstructionCache'; #function FlushViewOfFile(const lpBaseAddress: pointer; dwNumberOfBytesToFlush: DWORD): WINBOOL; stdcall; external 'kernel32' name 'FlushViewOfFile'; - #function FrameRect(hDC: HDC; const lprc: TRect; hbr: HBRUSH): Integer; stdcall; external 'user32' name 'FrameRect'; - #function GetAce(const pAcl: TACL; dwAceIndex: DWORD; var pAce: pointer): WINBOOL; stdcall; external 'advapi32' name 'GetAce'; - #function GetAclInformation(const pAcl: TACL; pAclInformation: pointer; nAclInformationLength: DWORD; dwAclInformationClass: TAclInformationClass): WINBOOL; stdcall; external 'advapi32' name 'GetAclInformation'; + #function FrameRect(hDC: HDC; const lprc: Rect; hbr: HBRUSH): Integer; stdcall; external 'user32' name 'FrameRect'; + #function GetAce(const pAcl: ACL; dwAceIndex: DWORD; var pAce: pointer): WINBOOL; stdcall; external 'advapi32' name 'GetAce'; + #function GetAclInformation(const pAcl: ACL; pAclInformation: pointer; nAclInformationLength: DWORD; dwAclInformationClass: AclInformationClass): WINBOOL; stdcall; external 'advapi32' name 'GetAclInformation'; #function GetAltTabInfo(wnd: HWND; iItem: Integer; var pati: TAltTabInfo; pszItemText: PChar; cchItemText: WINUINT): WINBOOL;stdcall; external 'user32' name 'GetAltTabInfoA'; #function GetAltTabInfoA(wnd: HWND; iItem: Integer; var pati: TAltTabInfo; pszItemText: LPCSTR; cchItemText: WINUINT): WINBOOL;stdcall; external 'user32' name 'GetAltTabInfoA'; #function GetAltTabInfoW(wnd: HWND; iItem: Integer; var pati: TAltTabInfo; pszItemText: LPWSTR; cchItemText: WINUINT): WINBOOL;stdcall; external 'user32' name 'GetAltTabInfoW'; -proc GetAspectRatioFilterEx*(DC: HDC, p2: var TSize): WINBOOL{.stdcall, +proc GetAspectRatioFilterEx*(DC: HDC, p2: var Size): WINBOOL{.stdcall, dynlib: "gdi32", importc: "GetAspectRatioFilterEx".} proc GetBinaryType*(lpApplicationName: cstring, lpBinaryType: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetBinaryTypeA".} @@ -21388,13 +21122,13 @@ proc GetBinaryTypeA*(lpApplicationName: LPCSTR, lpBinaryType: var DWORD): WINBOO stdcall, dynlib: "kernel32", importc: "GetBinaryTypeA".} proc GetBinaryTypeW*(lpApplicationName: LPWSTR, lpBinaryType: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetBinaryTypeW".} -proc GetBitmapDimensionEx*(p1: HBITMAP, p2: var TSize): WINBOOL{.stdcall, +proc GetBitmapDimensionEx*(p1: HBITMAP, p2: var Size): WINBOOL{.stdcall, dynlib: "gdi32", importc: "GetBitmapDimensionEx".} -proc GetBoundsRect*(DC: HDC, p2: var TRect, p3: WINUINT): WINUINT{.stdcall, +proc GetBoundsRect*(DC: HDC, p2: var Rect, p3: WINUINT): WINUINT{.stdcall, dynlib: "gdi32", importc: "GetBoundsRect".} -proc GetBrushOrgEx*(DC: HDC, p2: var TPoint): WINBOOL{.stdcall, dynlib: "gdi32", +proc GetBrushOrgEx*(DC: HDC, p2: var Point): WINBOOL{.stdcall, dynlib: "gdi32", importc: "GetBrushOrgEx".} -proc GetCaretPos*(lpPoint: var TPoint): WINBOOL{.stdcall, dynlib: "user32", +proc GetCaretPos*(lpPoint: var Point): WINBOOL{.stdcall, dynlib: "user32", importc: "GetCaretPos".} proc GetCharABCWidths*(DC: HDC, p2, p3: WINUINT, ABCStructs: pointer): WINBOOL{. stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsA".} @@ -21410,13 +21144,13 @@ proc GetCharABCWidthsFloatW*(DC: HDC, p2, p3: WINUINT, ABCFloatSturcts: pointer) proc GetCharABCWidthsW*(DC: HDC, p2, p3: WINUINT, ABCStructs: pointer): WINBOOL{. stdcall, dynlib: "gdi32", importc: "GetCharABCWidthsW".} proc GetCharacterPlacement*(DC: HDC, p2: cstring, p3, p4: WINBOOL, - p5: var TGCPResults, p6: DWORD): DWORD{.stdcall, + p5: var GCPResults, p6: DWORD): DWORD{.stdcall, dynlib: "gdi32", importc: "GetCharacterPlacementA".} proc GetCharacterPlacementA*(DC: HDC, p2: LPCSTR, p3, p4: WINBOOL, - p5: var TGCPResults, p6: DWORD): DWORD{.stdcall, + p5: var GCPResults, p6: DWORD): DWORD{.stdcall, dynlib: "gdi32", importc: "GetCharacterPlacementA".} proc GetCharacterPlacementW*(DC: HDC, p2: LPWSTR, p3, p4: WINBOOL, - p5: var TGCPResults, p6: DWORD): DWORD{.stdcall, + p5: var GCPResults, p6: DWORD): DWORD{.stdcall, dynlib: "gdi32", importc: "GetCharacterPlacementW".} proc GetCharWidth*(DC: HDC, p2, p3: WINUINT, Widths: pointer): WINBOOL{.stdcall, dynlib: "gdi32", importc: "GetCharWidthA".} @@ -21438,37 +21172,37 @@ proc GetCharWidthFloatW*(DC: HDC, p2, p3: WINUINT, Widths: pointer): WINBOOL{. proc GetCharWidthW*(DC: HDC, p2, p3: WINUINT, Widths: pointer): WINBOOL{.stdcall, dynlib: "gdi32", importc: "GetCharWidthW".} proc GetClassInfo*(hInstance: HINST, lpClassName: cstring, - lpWndClass: var TWndClass): WINBOOL{.stdcall, + lpWndClass: var WndClass): WINBOOL{.stdcall, dynlib: "user32", importc: "GetClassInfoA".} proc GetClassInfoA*(hInstance: HINST, lpClassName: LPCSTR, - lpWndClass: var TWndClassA): WINBOOL{.stdcall, + lpWndClass: var WndClass): WINBOOL{.stdcall, dynlib: "user32", importc: "GetClassInfoA".} proc GetClassInfoEx*(Instance: HINST, Classname: cstring, - WndClass: var TWndClassEx): WINBOOL{.stdcall, + WndClass: var WndClassEx): WINBOOL{.stdcall, dynlib: "user32", importc: "GetClassInfoExA".} - #function GetClassInfoExA(Instance: HINST; Classname: LPCSTR; var WndClass: TWndClassExA): WINBOOL; stdcall; external 'user32' name 'GetClassInfoExA'; - #function GetClassInfoExW(Instance: HINST; Classname: LPWSTR; var WndClass: TWndClassExW): WINBOOL; stdcall; external 'user32' name 'GetClassInfoExW'; - #function GetClassInfoW(hInstance: HINST; lpClassName: LPWSTR; var lpWndClass: TWndClassW): WINBOOL; stdcall; external 'user32' name 'GetClassInfoW'; -proc GetClientRect*(wnd: HWND, lpRect: var TRect): WINBOOL{.stdcall, + #function GetClassInfoExA(Instance: HINST; Classname: LPCSTR; var WndClass: WndClassEx): WINBOOL; stdcall; external 'user32' name 'GetClassInfoExA'; + #function GetClassInfoExW(Instance: HINST; Classname: LPWSTR; var WndClass: WndClassExW): WINBOOL; stdcall; external 'user32' name 'GetClassInfoExW'; + #function GetClassInfoW(hInstance: HINST; lpClassName: LPWSTR; var lpWndClass: WndClassW): WINBOOL; stdcall; external 'user32' name 'GetClassInfoW'; +proc GetClientRect*(wnd: HWND, lpRect: var Rect): WINBOOL{.stdcall, dynlib: "user32", importc: "GetClientRect".} -proc GetClipBox*(DC: HDC, Rect: var TRect): int{.stdcall, dynlib: "gdi32", +proc GetClipBox*(DC: HDC, Rect: var Rect): int{.stdcall, dynlib: "gdi32", importc: "GetClipBox".} -proc GetClipCursor*(lpRect: var TRect): WINBOOL{.stdcall, dynlib: "user32", +proc GetClipCursor*(lpRect: var Rect): WINBOOL{.stdcall, dynlib: "user32", importc: "GetClipCursor".} -proc GetColorAdjustment*(DC: HDC, p2: var TColorAdjustment): WINBOOL{.stdcall, +proc GetColorAdjustment*(DC: HDC, p2: var ColorAdjustment): WINBOOL{.stdcall, dynlib: "gdi32", importc: "GetColorAdjustment".} -proc GetCommConfig*(hCommDev: THandle, lpCC: var TCommConfig, +proc GetCommConfig*(hCommDev: Handle, lpCC: var CommConfig, lpdwSize: var DWORD): WINBOOL{.stdcall, dynlib: "kernel32", importc: "GetCommConfig".} -proc GetCommMask*(hFile: THandle, lpEvtMask: var DWORD): WINBOOL{.stdcall, +proc GetCommMask*(hFile: Handle, lpEvtMask: var DWORD): WINBOOL{.stdcall, dynlib: "kernel32", importc: "GetCommMask".} -proc GetCommModemStatus*(hFile: THandle, lpModemStat: var DWORD): WINBOOL{. +proc GetCommModemStatus*(hFile: Handle, lpModemStat: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetCommModemStatus".} -proc GetCommProperties*(hFile: THandle, lpCommProp: var TCommProp): WINBOOL{. +proc GetCommProperties*(hFile: Handle, lpCommProp: var CommProp): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetCommProperties".} -proc GetCommState*(hFile: THandle, lpDCB: var TDCB): WINBOOL{.stdcall, +proc GetCommState*(hFile: Handle, lpDCB: var DCB): WINBOOL{.stdcall, dynlib: "kernel32", importc: "GetCommState".} -proc GetCommTimeouts*(hFile: THandle, lpCommTimeouts: var TCommTimeouts): WINBOOL{. +proc GetCommTimeouts*(hFile: Handle, lpCommTimeouts: var CommTimeouts): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetCommTimeouts".} proc GetComputerName*(lpBuffer: cstring, nSize: var DWORD): WINBOOL{.stdcall, dynlib: "kernel32", importc: "GetComputerNameA".} @@ -21476,38 +21210,38 @@ proc GetComputerNameA*(lpBuffer: LPCSTR, nSize: var DWORD): WINBOOL{.stdcall, dynlib: "kernel32", importc: "GetComputerNameA".} proc GetComputerNameW*(lpBuffer: LPWSTR, nSize: var DWORD): WINBOOL{.stdcall, dynlib: "kernel32", importc: "GetComputerNameW".} -proc GetConsoleCursorInfo*(hConsoleOutput: THandle, - lpConsoleCursorInfo: var TConsoleCursorInfo): WINBOOL{. +proc GetConsoleCursorInfo*(hConsoleOutput: Handle, + lpConsoleCursorInfo: var ConsoleCursorInfo): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetConsoleCursorInfo".} -proc GetConsoleMode*(hConsoleHandle: THandle, lpMode: var DWORD): WINBOOL{. +proc GetConsoleMode*(hConsoleHandle: Handle, lpMode: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetConsoleMode".} -proc GetConsoleScreenBufferInfo*(hConsoleOutput: THandle, - lpConsoleScreenBufferInfo: var TConsoleScreenBufferInfo): WINBOOL{.stdcall, +proc GetConsoleScreenBufferInfo*(hConsoleOutput: Handle, + lpConsoleScreenBufferInfo: var ConsoleScreenBufferInfo): WINBOOL{.stdcall, dynlib: "kernel32", importc: "GetConsoleScreenBufferInfo".} -proc GetCPInfo*(CodePage: WINUINT, lpCPInfo: var TCPInfo): WINBOOL{.stdcall, +proc GetCPInfo*(CodePage: WINUINT, lpCPInfo: var CPInfo): WINBOOL{.stdcall, dynlib: "kernel32", importc: "GetCPInfo".} #function GetCurrentHwProfile(var lpHwProfileInfo: THWProfileInfo): WINBOOL;stdcall; external 'advapi32' name 'GetCurrentHwProfileA'; #function GetCurrentHwProfileA(var lpHwProfileInfo: THWProfileInfoA): WINBOOL;stdcall; external 'advapi32' name 'GetCurrentHwProfileA'; #function GetCurrentHwProfileW(var lpHwProfileInfo: THWProfileInfoW): WINBOOL;stdcall; external 'advapi32' name 'GetCurrentHwProfileW'; -proc GetCursorInfo*(pci: var TCursorInfo): WINBOOL{.stdcall, dynlib: "user32", +proc GetCursorInfo*(pci: var ConsoleCursorInfo): WINBOOL{.stdcall, dynlib: "user32", importc: "GetCursorInfo".} -proc GetCursorPos*(lpPoint: var TPoint): WINBOOL{.stdcall, dynlib: "user32", +proc GetCursorPos*(lpPoint: var Point): WINBOOL{.stdcall, dynlib: "user32", importc: "GetCursorPos".} -proc GetDCOrgEx*(DC: HDC, Origin: var TPoint): WINBOOL{.stdcall, +proc GetDCOrgEx*(DC: HDC, Origin: var Point): WINBOOL{.stdcall, dynlib: "gdi32", importc: "GetDCOrgEx".} -proc GetDefaultCommConfig*(lpszName: cstring, lpCC: var TCommConfig, +proc GetDefaultCommConfig*(lpszName: cstring, lpCC: var CommConfig, lpdwSize: var DWORD): WINBOOL{.stdcall, dynlib: "kernel32", importc: "GetDefaultCommConfigA".} -proc GetDefaultCommConfigA*(lpszName: LPCSTR, lpCC: var TCommConfig, +proc GetDefaultCommConfigA*(lpszName: LPCSTR, lpCC: var CommConfig, lpdwSize: var DWORD): WINBOOL{.stdcall, dynlib: "kernel32", importc: "GetDefaultCommConfigA".} -proc GetDefaultCommConfigW*(lpszName: LPWSTR, lpCC: var TCommConfig, +proc GetDefaultCommConfigW*(lpszName: LPWSTR, lpCC: var CommConfig, lpdwSize: var DWORD): WINBOOL{.stdcall, dynlib: "kernel32", importc: "GetDefaultCommConfigW".} proc GetDIBColorTable*(DC: HDC, p2, p3: WINUINT, RGBQuadStructs: pointer): WINUINT{. stdcall, dynlib: "gdi32", importc: "GetDIBColorTable".} proc GetDIBits*(DC: HDC, Bitmap: HBitmap, StartScan, NumScans: WINUINT, - Bits: pointer, BitInfo: var TBitmapInfo, Usage: WINUINT): int{. + Bits: pointer, BitInfo: var BitmapInfo, Usage: WINUINT): int{. stdcall, dynlib: "gdi32", importc: "GetDIBits".} proc GetDiskFreeSpace*(lpRootPathName: cstring, lpSectorsPerCluster, lpBytesPerSector, lpNumberOfFreeClusters, lpTotalNumberOfClusters: var DWORD): WINBOOL{. @@ -21516,15 +21250,15 @@ proc GetDiskFreeSpaceA*(lpRootPathName: LPCSTR, lpSectorsPerCluster, lpBytesPerSector, lpNumberOfFreeClusters, lpTotalNumberOfClusters: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetDiskFreeSpaceA".} proc GetDiskFreeSpaceEx*(lpDirectoryName: cstring, lpFreeBytesAvailableToCaller, - lpTotalNumberOfBytes: var TLargeInteger, + lpTotalNumberOfBytes: var LargeInteger, lpTotalNumberOfFreeBytes: PLargeInteger): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetDiskFreeSpaceExA".} proc GetDiskFreeSpaceExA*(lpDirectoryName: LPCSTR, lpFreeBytesAvailableToCaller, - lpTotalNumberOfBytes: var TLargeInteger, + lpTotalNumberOfBytes: var LargeInteger, lpTotalNumberOfFreeBytes: PLargeInteger): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetDiskFreeSpaceExA".} proc GetDiskFreeSpaceExW*(lpDirectoryName: LPWSTR, lpFreeBytesAvailableToCaller, - lpTotalNumberOfBytes: var TLargeInteger, + lpTotalNumberOfBytes: var LargeInteger, lpTotalNumberOfFreeBytes: PLargeInteger): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetDiskFreeSpaceExW".} proc GetDiskFreeSpaceW*(lpRootPathName: LPWSTR, lpSectorsPerCluster, @@ -21539,12 +21273,12 @@ proc GetDiskFreeSpaceExA*(lpDirectoryName: LPCSTR, lpFreeBytesAvailableToCaller, proc GetDiskFreeSpaceExW*(lpDirectoryName: LPWSTR, lpFreeBytesAvailableToCaller, lpTotalNumberOfBytes: PLargeInteger, lpTotalNumberOfFreeBytes: PLargeInteger): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetDiskFreeSpaceExW".} - #function GetEnhMetaFilePixelFormat(p1: HENHMETAFILE; p2: Cardinal; var p3: TPixelFormatDescriptor): WINUINT;stdcall; external 'gdi32' name 'GetEnhMetaFilePixelFormat'; -proc GetExitCodeProcess*(hProcess: THandle, lpExitCode: var DWORD): WINBOOL{. + #function GetEnhMetaFilePixelFormat(p1: HENHMETAFILE; p2: Cardinal; var p3: PixelFormatDescriptor): WINUINT;stdcall; external 'gdi32' name 'GetEnhMetaFilePixelFormat'; +proc GetExitCodeProcess*(hProcess: Handle, lpExitCode: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetExitCodeProcess".} -proc GetExitCodeThread*(hThread: THandle, lpExitCode: var DWORD): WINBOOL{. +proc GetExitCodeThread*(hThread: Handle, lpExitCode: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetExitCodeThread".} -proc GetFileInformationByHandle*(hFile: THandle, lpFileInformation: var TByHandleFileInformation): WINBOOL{. +proc GetFileInformationByHandle*(hFile: Handle, lpFileInformation: var ByHandleFileInformation): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetFileInformationByHandle".} #function GetFileSecurity(lpFileName: PChar; RequestedInformation: SECURITY_INFORMATION; pSecurityDescriptor: PSecurityDescriptor; nLength: DWORD; var lpnLengthNeeded: DWORD): WINBOOL;stdcall; external 'advapi32' name 'GetFileSecurityA'; #function GetFileSecurityA(lpFileName: LPCSTR; RequestedInformation: SECURITY_INFORMATION; pSecurityDescriptor: PSecurityDescriptor; nLength: DWORD; var lpnLengthNeeded: DWORD): WINBOOL; stdcall; external 'advapi32' name 'GetFileSecurityA'; @@ -21559,24 +21293,24 @@ proc GetFileVersionInfoSizeW*(lptstrFilename: LPWSTR, lpdwHandle: var DWORD): DW # function GetFullPathName(lpFileName: PChar; nBufferLength: DWORD; lpBuffer: PChar; var lpFilePart: PChar): DWORD;stdcall; external 'kernel32' name 'GetFullPathNameA'; # function GetFullPathNameA(lpFileName: LPCSTR; nBufferLength: DWORD; lpBuffer: LPCSTR; var lpFilePart: LPCSTR): DWORD; stdcall; external 'kernel32' name 'GetFullPathNameA'; # function GetFullPathNameW(lpFileName: LPWSTR; nBufferLength: DWORD; lpBuffer: LPWSTR; var lpFilePart: LPWSTR): DWORD; stdcall; external 'kernel32' name 'GetFullPathNameW'; -proc GetGlyphOutline*(DC: HDC, p2, p3: WINUINT, p4: TGlyphMetrics, p5: DWORD, - p6: pointer, p7: TMat2): DWORD{.stdcall, dynlib: "gdi32", +proc GetGlyphOutline*(DC: HDC, p2, p3: WINUINT, p4: GlyphMetrics, p5: DWORD, + p6: pointer, p7: Mat2): DWORD{.stdcall, dynlib: "gdi32", importc: "GetGlyphOutlineA".} -proc GetGlyphOutlineA*(DC: HDC, p2, p3: WINUINT, p4: TGlyphMetrics, p5: DWORD, - p6: pointer, p7: TMat2): DWORD{.stdcall, dynlib: "gdi32", +proc GetGlyphOutlineA*(DC: HDC, p2, p3: WINUINT, p4: GlyphMetrics, p5: DWORD, + p6: pointer, p7: Mat2): DWORD{.stdcall, dynlib: "gdi32", importc: "GetGlyphOutlineA".} -proc GetGlyphOutlineW*(DC: HDC, p2, p3: WINUINT, p4: TGlyphMetrics, p5: DWORD, - p6: pointer, p7: TMat2): DWORD{.stdcall, dynlib: "gdi32", +proc GetGlyphOutlineW*(DC: HDC, p2, p3: WINUINT, p4: GlyphMetrics, p5: DWORD, + p6: pointer, p7: Mat2): DWORD{.stdcall, dynlib: "gdi32", importc: "GetGlyphOutlineW".} #function GetGUIThreadInfo(idThread: DWORD; var pgui: TGUIThreadinfo): WINBOOL;stdcall; external 'user32' name 'GetGUIThreadInfo'; -proc GetHandleInformation*(hObject: THandle, lpdwFlags: var DWORD): WINBOOL{. +proc GetHandleInformation*(hObject: Handle, lpdwFlags: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetHandleInformation".} #function GetICMProfile(DC: HDC; var Size: DWORD; Name: PChar): WINBOOL;stdcall; external 'gdi32' name 'GetICMProfileA'; #function GetICMProfileA(DC: HDC; var Size: DWORD; Name: LPCSTR): WINBOOL; stdcall; external 'gdi32' name 'GetICMProfileA'; #function GetICMProfileW(DC: HDC; var Size: DWORD; Name: LPWSTR): WINBOOL; stdcall; external 'gdi32' name 'GetICMProfileW'; -proc GetIconInfo*(icon: HICON, piconinfo: var TIconInfo): WINBOOL{.stdcall, +proc GetIconInfo*(icon: HICON, piconinfo: var IconInfo): WINBOOL{.stdcall, dynlib: "user32", importc: "GetIconInfo".} - #function GetKernelObjectSecurity(Handle: THandle; RequestedInformation: SECURITY_INFORMATION; pSecurityDescriptor: PSecurityDescriptor; nLength: DWORD; var lpnLengthNeeded: DWORD): WINBOOL; stdcall; external 'advapi32' name 'GetKernelObjectSecurity'; + #function GetKernelObjectSecurity(Handle: Handle; RequestedInformation: SECURITY_INFORMATION; pSecurityDescriptor: PSecurityDescriptor; nLength: DWORD; var lpnLengthNeeded: DWORD): WINBOOL; stdcall; external 'advapi32' name 'GetKernelObjectSecurity'; proc GetKerningPairs*(DC: HDC, Count: DWORD, KerningPairs: pointer): DWORD{. stdcall, dynlib: "gdi32", importc: "GetKerningPairs".} proc GetKeyboardLayoutList*(nBuff: int, List: pointer): WINUINT{.stdcall, @@ -21593,25 +21327,25 @@ proc SetSystemTime*(lpSystemTime: var SYSTEMTIME): WINBOOL{.stdcall, dynlib: "kernel32", importc: "SetSystemTime".} proc SetLocalTime*(lpSystemTime: var SYSTEMTIME): WINBOOL{.stdcall, dynlib: "kernel32", importc: "SetLocalTime".} -proc GetLogColorSpace*(p1: HCOLORSPACE, ColorSpace: var TLogColorSpace, +proc GetLogColorSpace*(p1: HCOLORSPACE, ColorSpace: var LogColorSpace, Size: DWORD): WINBOOL{.stdcall, dynlib: "gdi32", importc: "GetLogColorSpaceA".} -proc GetLogColorSpaceA*(p1: HCOLORSPACE, ColorSpace: var TLogColorSpaceA, +proc GetLogColorSpaceA*(p1: HCOLORSPACE, ColorSpace: var LogColorSpace, Size: DWORD): WINBOOL{.stdcall, dynlib: "gdi32", importc: "GetLogColorSpaceA".} - #function GetLogColorSpaceW(p1: HCOLORSPACE; var ColorSpace: TLogColorSpaceW; Size: DWORD): WINBOOL; stdcall; external 'gdi32' name 'GetLogColorSpaceW'; -proc GetMailslotInfo*(hMailslot: THandle, lpMaxMessageSize: pointer, + #function GetLogColorSpaceW(p1: HCOLORSPACE; var ColorSpace: LogColorSpaceW; Size: DWORD): WINBOOL; stdcall; external 'gdi32' name 'GetLogColorSpaceW'; +proc GetMailslotInfo*(hMailslot: Handle, lpMaxMessageSize: pointer, lpNextSize: var DWORD, lpMessageCount, lpReadTimeout: pointer): WINBOOL{.stdcall, dynlib: "kernel32", importc: "GetMailslotInfo".} #function GetMenuBarInfo(hend: HWND; idObject, idItem: Longint; var pmbi: TMenuBarInfo): WINBOOL;stdcall; external 'user32' name 'GetMenuBarInfo'; #function GetMenuInfo(menu: HMENU; var lpmi: TMenuInfo): WINBOOL;stdcall; external 'user32' name 'GetMenuInfo'; -proc GetMenuItemInfo*(p1: HMENU, p2: WINUINT, p3: WINBOOL, p4: var TMenuItemInfo): WINBOOL{. +proc GetMenuItemInfo*(p1: HMENU, p2: WINUINT, p3: WINBOOL, p4: var MenuItemInfo): WINBOOL{. stdcall, dynlib: "user32", importc: "GetMenuItemInfoA".} -proc GetMenuItemInfoA*(p1: HMENU, p2: WINUINT, p3: WINBOOL, p4: var TMenuItemInfoA): WINBOOL{. +proc GetMenuItemInfoA*(p1: HMENU, p2: WINUINT, p3: WINBOOL, p4: var MenuItemInfo): WINBOOL{. stdcall, dynlib: "user32", importc: "GetMenuItemInfoA".} - #function GetMenuItemInfoW(p1: HMENU; p2: WINUINT; p3: WINBOOL; var p4: TMenuItemInfoW): WINBOOL; stdcall; external 'user32' name 'GetMenuItemInfoW'; -proc GetMenuItemRect*(wnd: HWND, menu: HMENU, uItem: WINUINT, lprcItem: var TRect): WINBOOL{. + #function GetMenuItemInfoW(p1: HMENU; p2: WINUINT; p3: WINBOOL; var p4: MenuItemInfoW): WINBOOL; stdcall; external 'user32' name 'GetMenuItemInfoW'; +proc GetMenuItemRect*(wnd: HWND, menu: HMENU, uItem: WINUINT, lprcItem: var Rect): WINBOOL{. stdcall, dynlib: "user32", importc: "GetMenuItemRect".} proc GetMessage*(lpMsg: var TMsg, wnd: HWND, wMsgFilterMin, wMsgFilterMax: WINUINT): WINBOOL{. stdcall, dynlib: "user32", importc: "GetMessageA".} @@ -21624,17 +21358,17 @@ proc GetMessageW*(lpMsg: var TMsg, wnd: HWND, proc GetMiterLimit*(DC: HDC, Limit: var float32): WINBOOL{.stdcall, dynlib: "gdi32", importc: "GetMiterLimit".} #function GetMouseMovePoints(cbSize: WINUINT; var lppt, lpptBuf: TMouseMovePoint; nBufPoints: Integer; resolution: DWORD): Integer;stdcall; external 'user32' name 'GetMouseMovePoints'; -proc GetNamedPipeInfo*(hNamedPipe: THandle, lpFlags: var DWORD, +proc GetNamedPipeInfo*(hNamedPipe: Handle, lpFlags: var DWORD, lpOutBufferSize, lpInBufferSize, lpMaxInstances: pointer): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetNamedPipeInfo".} -proc GetNumberOfConsoleInputEvents*(hConsoleInput: THandle, +proc GetNumberOfConsoleInputEvents*(hConsoleInput: Handle, lpNumberOfEvents: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetNumberOfConsoleInputEvents".} proc GetNumberOfConsoleMouseButtons*(lpNumberOfMouseButtons: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetNumberOfConsoleMouseButtons".} - #function GetNumberOfEventLogRecords(hEventLog: THandle; var NumberOfRecords: DWORD): WINBOOL; stdcall; external 'advapi32' name 'GetNumberOfEventLogRecords'; - #function GetOldestEventLogRecord(hEventLog: THandle; var OldestRecord: DWORD): WINBOOL; stdcall; external 'advapi32' name 'GetOldestEventLogRecord'; -proc GetOverlappedResult*(hFile: THandle, lpOverlapped: TOverlapped, + #function GetNumberOfEventLogRecords(hEventLog: Handle; var NumberOfRecords: DWORD): WINBOOL; stdcall; external 'advapi32' name 'GetNumberOfEventLogRecords'; + #function GetOldestEventLogRecord(hEventLog: Handle; var OldestRecord: DWORD): WINBOOL; stdcall; external 'advapi32' name 'GetOldestEventLogRecord'; +proc GetOverlappedResult*(hFile: Handle, lpOverlapped: Overlapped, lpNumberOfBytesTransferred: var DWORD, bWait: WINBOOL): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetOverlappedResult".} proc GetPaletteEntries*(Palette: HPALETTE, StartIndex, NumEntries: WINUINT, @@ -21664,32 +21398,32 @@ proc GetPrivateProfileStructW*(lpszSection, lpszKey: LPCWSTR, lpStruct: LPVOID, proc GetPrivateProfileStruct*(lpszSection, lpszKey: LPCTSTR, lpStruct: LPVOID, uSizeStruct: WINUINT, szFile: LPCTSTR): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetPrivateProfileStructA".} -proc GetProcessAffinityMask*(hProcess: THandle, lpProcessAffinityMask, +proc GetProcessAffinityMask*(hProcess: Handle, lpProcessAffinityMask, lpSystemAffinityMask: var DWORD): WINBOOL{.stdcall, dynlib: "kernel32", importc: "GetProcessAffinityMask".} -proc GetProcessHeaps*(NumberOfHeaps: DWORD, ProcessHeaps: var THandle): DWORD{. +proc GetProcessHeaps*(NumberOfHeaps: DWORD, ProcessHeaps: var Handle): DWORD{. stdcall, dynlib: "kernel32", importc: "GetProcessHeaps".} -proc GetProcessPriorityBoost*(hThread: THandle, +proc GetProcessPriorityBoost*(hThread: Handle, DisablePriorityBoost: var WINBOOL): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetProcessPriorityBoost".} proc GetProcessShutdownParameters*(lpdwLevel, lpdwFlags: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetProcessShutdownParameters".} -proc GetProcessTimes*(hProcess: THandle, lpCreationTime, lpExitTime, - lpKernelTime, lpUserTime: var TFileTime): WINBOOL{.stdcall, +proc GetProcessTimes*(hProcess: Handle, lpCreationTime, lpExitTime, + lpKernelTime, lpUserTime: var FileTime): WINBOOL{.stdcall, dynlib: "kernel32", importc: "GetProcessTimes".} -proc GetProcessWorkingSetSize*(hProcess: THandle, lpMinimumWorkingSetSize, +proc GetProcessWorkingSetSize*(hProcess: Handle, lpMinimumWorkingSetSize, lpMaximumWorkingSetSize: var DWORD): WINBOOL{.stdcall, dynlib: "kernel32", importc: "GetProcessWorkingSetSize".} -proc GetQueuedCompletionStatus*(CompletionPort: THandle, +proc GetQueuedCompletionStatus*(CompletionPort: Handle, lpNumberOfBytesTransferred, lpCompletionKey: var DWORD, lpOverlapped: var POverlapped, dwMilliseconds: DWORD): WINBOOL{.stdcall, dynlib: "kernel32", importc: "GetQueuedCompletionStatus".} -proc GetRasterizerCaps*(p1: var TRasterizerStatus, p2: WINUINT): WINBOOL{.stdcall, +proc GetRasterizerCaps*(p1: var RasterizerStatus, p2: WINUINT): WINBOOL{.stdcall, dynlib: "gdi32", importc: "GetRasterizerCaps".} -proc GetRgnBox*(RGN: HRGN, p2: var TRect): int{.stdcall, dynlib: "gdi32", +proc GetRgnBox*(RGN: HRGN, p2: var Rect): int{.stdcall, dynlib: "gdi32", importc: "GetRgnBox".} -proc GetScrollInfo*(wnd: HWND, BarFlag: int, ScrollInfo: var TScrollInfo): WINBOOL{. +proc GetScrollInfo*(wnd: HWND, BarFlag: int, ScrollInfo: var ScrollInfo): WINBOOL{. stdcall, dynlib: "user32", importc: "GetScrollInfo".} proc GetScrollRange*(wnd: HWND, nBar: int, lpMinPos, lpMaxPos: var int): WINBOOL{. stdcall, dynlib: "user32", importc: "GetScrollRange".} @@ -21698,7 +21432,7 @@ proc GetScrollRange*(wnd: HWND, nBar: int, lpMinPos, lpMaxPos: var int): WINBOOL #function GetSecurityDescriptorGroup(pSecurityDescriptor: PSecurityDescriptor; var pGroup: PSID; var lpbGroupDefaulted: WINBOOL): WINBOOL; stdcall; external 'advapi32' name 'GetSecurityDescriptorGroup'; #function GetSecurityDescriptorOwner(pSecurityDescriptor: PSecurityDescriptor; var pOwner: PSID; var lpbOwnerDefaulted: WINBOOL): WINBOOL; stdcall; external 'advapi32' name 'GetSecurityDescriptorOwner'; #function GetSecurityDescriptorSacl(pSecurityDescriptor: PSecurityDescriptor; var lpbSaclPresent: WINBOOL; var pSacl: PACL; var lpbSaclDefaulted: WINBOOL): WINBOOL; stdcall; external 'advapi32' name 'GetSecurityDescriptorSacl'; -proc GetStartupInfo*(lpStartupInfo: var TSTARTUPINFO){.stdcall, +proc GetStartupInfo*(lpStartupInfo: var STARTUPINFO){.stdcall, dynlib: "kernel32", importc: "GetStartupInfoA".} proc GetStringTypeA*(Locale: LCID, dwInfoType: DWORD, lpSrcStr: LPCSTR, cchSrc: WINBOOL, lpCharType: var int16): WINBOOL{.stdcall, @@ -21718,12 +21452,12 @@ proc GetStringTypeW*(dwInfoType: DWORD, lpSrcStr: WCHAR, cchSrc: WINBOOL, proc GetSystemPaletteEntries*(DC: HDC, StartIndex, NumEntries: WINUINT, PaletteEntries: pointer): WINUINT{.stdcall, dynlib: "gdi32", importc: "GetSystemPaletteEntries".} -proc GetSystemPowerStatus*(lpSystemPowerStatus: var TSystemPowerStatus): WINBOOL{. +proc GetSystemPowerStatus*(lpSystemPowerStatus: var SystemPowerStatus): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetSystemPowerStatus".} proc GetSystemTimeAdjustment*(lpTimeAdjustment, lpTimeIncrement: var DWORD, lpTimeAdjustmentDisabled: var WINBOOL): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetSystemTimeAdjustment".} -proc GetSystemTimeAsFileTime*(lpSystemTimeAsFileTime: var TFILETIME){.stdcall, +proc GetSystemTimeAsFileTime*(lpSystemTimeAsFileTime: var FILETIME){.stdcall, dynlib: "kernel32", importc: "GetSystemTimeAsFileTime".} proc GetTabbedTextExtent*(hDC: HDC, lpString: cstring, nCount, nTabPositions: int, @@ -21737,55 +21471,55 @@ proc GetTabbedTextExtentW*(hDC: HDC, lpString: LPWSTR, nCount, nTabPositions: int, lpnTabStopPositions: pointer): DWORD{.stdcall, dynlib: "user32", importc: "GetTabbedTextExtentW".} -proc GetTapeParameters*(hDevice: THandle, dwOperation: DWORD, +proc GetTapeParameters*(hDevice: Handle, dwOperation: DWORD, lpdwSize: var DWORD, lpTapeInformation: pointer): DWORD{. stdcall, dynlib: "kernel32", importc: "GetTapeParameters".} -proc GetTapePosition*(hDevice: THandle, dwPositionType: DWORD, +proc GetTapePosition*(hDevice: Handle, dwPositionType: DWORD, lpdwPartition, lpdwOffsetLow: var DWORD, lpdwOffsetHigh: pointer): DWORD{.stdcall, dynlib: "kernel32", importc: "GetTapePosition".} proc GetTextExtentExPoint*(DC: HDC, p2: cstring, p3, p4: int, p5, p6: PInteger, - p7: var TSize): WINBOOL{.stdcall, dynlib: "gdi32", + p7: var Size): WINBOOL{.stdcall, dynlib: "gdi32", importc: "GetTextExtentExPointA".} proc GetTextExtentExPointA*(DC: HDC, p2: LPCSTR, p3, p4: int, p5, p6: PInteger, - p7: var TSize): WINBOOL{.stdcall, dynlib: "gdi32", + p7: var Size): WINBOOL{.stdcall, dynlib: "gdi32", importc: "GetTextExtentExPointA".} - #function GetTextExtentExPointI(DC: HDC; p2: PWORD; p3, p4: Integer; p5, p6: PINT; var p7: TSize): WINBOOL;stdcall; external 'gdi32' name 'GetTextExtentExPointI'; + #function GetTextExtentExPointI(DC: HDC; p2: PWORD; p3, p4: Integer; p5, p6: PINT; var p7: Size): WINBOOL;stdcall; external 'gdi32' name 'GetTextExtentExPointI'; proc GetTextExtentExPointW*(DC: HDC, p2: LPWSTR, p3, p4: int, p5, p6: PInteger, - p7: var TSize): WINBOOL{.stdcall, dynlib: "gdi32", + p7: var Size): WINBOOL{.stdcall, dynlib: "gdi32", importc: "GetTextExtentExPointW".} -proc GetTextExtentPoint*(DC: HDC, Str: cstring, Count: int, Size: var TSize): WINBOOL{. +proc GetTextExtentPoint*(DC: HDC, Str: cstring, Count: int, Size: var Size): WINBOOL{. stdcall, dynlib: "gdi32", importc: "GetTextExtentPointA".} -proc GetTextExtentPoint32*(DC: HDC, Str: cstring, Count: int, Size: var TSize): WINBOOL{. +proc GetTextExtentPoint32*(DC: HDC, Str: cstring, Count: int, Size: var Size): WINBOOL{. stdcall, dynlib: "gdi32", importc: "GetTextExtentPoint32A".} -proc GetTextExtentPoint32A*(DC: HDC, Str: LPCSTR, Count: int, Size: var TSize): WINBOOL{. +proc GetTextExtentPoint32A*(DC: HDC, Str: LPCSTR, Count: int, Size: var Size): WINBOOL{. stdcall, dynlib: "gdi32", importc: "GetTextExtentPoint32A".} -proc GetTextExtentPoint32W*(DC: HDC, Str: LPWSTR, Count: int, Size: var TSize): WINBOOL{. +proc GetTextExtentPoint32W*(DC: HDC, Str: LPWSTR, Count: int, Size: var Size): WINBOOL{. stdcall, dynlib: "gdi32", importc: "GetTextExtentPoint32W".} -proc GetTextExtentPointA*(DC: HDC, Str: LPCSTR, Count: int, Size: var TSize): WINBOOL{. +proc GetTextExtentPointA*(DC: HDC, Str: LPCSTR, Count: int, Size: var Size): WINBOOL{. stdcall, dynlib: "gdi32", importc: "GetTextExtentPointA".} - #function GetTextExtentPointI(DC: HDC; p2: PWORD; p3: Integer; var p4: TSize): WINBOOL;stdcall; external 'gdi32' name 'GetTextExtentPointI'; -proc GetTextExtentPointW*(DC: HDC, Str: LPWSTR, Count: int, Size: var TSize): WINBOOL{. + #function GetTextExtentPointI(DC: HDC; p2: PWORD; p3: Integer; var p4: Size): WINBOOL;stdcall; external 'gdi32' name 'GetTextExtentPointI'; +proc GetTextExtentPointW*(DC: HDC, Str: LPWSTR, Count: int, Size: var Size): WINBOOL{. stdcall, dynlib: "gdi32", importc: "GetTextExtentPointW".} -proc GetTextMetrics*(DC: HDC, TM: var TTextMetric): WINBOOL{.stdcall, +proc GetTextMetrics*(DC: HDC, TM: var TextMetric): WINBOOL{.stdcall, dynlib: "gdi32", importc: "GetTextMetricsA".} - #function GetTextMetricsA(DC: HDC; var TM: TTextMetricA): WINBOOL; stdcall; external 'gdi32' name 'GetTextMetricsA'; - #function GetTextMetricsW(DC: HDC; var TM: TTextMetricW): WINBOOL; stdcall; external 'gdi32' name 'GetTextMetricsW'; -proc GetThreadContext*(hThread: THandle, lpContext: var TContext): WINBOOL{. + #function GetTextMetricsA(DC: HDC; var TM: TextMetricA): WINBOOL; stdcall; external 'gdi32' name 'GetTextMetricsA'; + #function GetTextMetricsW(DC: HDC; var TM: TextMetricW): WINBOOL; stdcall; external 'gdi32' name 'GetTextMetricsW'; +proc GetThreadContext*(hThread: Handle, lpContext: var Context): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetThreadContext".} -proc GetThreadPriorityBoost*(hThread: THandle, DisablePriorityBoost: var WINBOOL): WINBOOL{. +proc GetThreadPriorityBoost*(hThread: Handle, DisablePriorityBoost: var WINBOOL): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetThreadPriorityBoost".} -proc GetThreadSelectorEntry*(hThread: THandle, dwSelector: DWORD, - lpSelectorEntry: var TLDTEntry): WINBOOL{.stdcall, +proc GetThreadSelectorEntry*(hThread: Handle, dwSelector: DWORD, + lpSelectorEntry: var LDTEntry): WINBOOL{.stdcall, dynlib: "kernel32", importc: "GetThreadSelectorEntry".} -proc GetThreadTimes*(hThread: THandle, lpCreationTime, lpExitTime, lpKernelTime, - lpUserTime: var TFileTime): WINBOOL{. +proc GetThreadTimes*(hThread: Handle, lpCreationTime, lpExitTime, lpKernelTime, + lpUserTime: var FileTime): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetThreadTimes".} -proc GetTimeZoneInformation*(lpTimeZoneInformation: var TTimeZoneInformation): DWORD{. +proc GetTimeZoneInformation*(lpTimeZoneInformation: var TimeZoneInformation): DWORD{. stdcall, dynlib: "kernel32", importc: "GetTimeZoneInformation".} #function GetTitleBarInfo(wnd: HWND; var pti: TTitleBarInfo): WINBOOL;stdcall; external 'user32' name 'GetTitleBarInfo'; - #function GetTokenInformation(TokenHandle: THandle; TokenInformationClass: TTokenInformationClass; TokenInformation: pointer; TokenInformationLength: DWORD; var ReturnLength: DWORD): WINBOOL; stdcall; external 'advapi32' name 'GetTokenInformation'; -proc GetUpdateRect*(wnd: HWND, lpRect: var TRect, bErase: WINBOOL): WINBOOL{. + #function GetTokenInformation(TokenHandle: Handle; TokenInformationClass: TokenInformationClass; TokenInformation: pointer; TokenInformationLength: DWORD; var ReturnLength: DWORD): WINBOOL; stdcall; external 'advapi32' name 'GetTokenInformation'; +proc GetUpdateRect*(wnd: HWND, lpRect: var Rect, bErase: WINBOOL): WINBOOL{. stdcall, dynlib: "user32", importc: "GetUpdateRect".} proc GetUserName*(lpBuffer: cstring, nSize: var DWORD): WINBOOL{.stdcall, dynlib: "advapi32", importc: "GetUserNameA".} @@ -21793,28 +21527,28 @@ proc GetUserNameA*(lpBuffer: LPCSTR, nSize: var DWORD): WINBOOL{.stdcall, dynlib: "advapi32", importc: "GetUserNameA".} proc GetUserNameW*(lpBuffer: LPWSTR, nSize: var DWORD): WINBOOL{.stdcall, dynlib: "advapi32", importc: "GetUserNameW".} -proc GetUserObjectInformation*(hObj: THandle, nIndex: int, pvInfo: pointer, +proc GetUserObjectInformation*(hObj: Handle, nIndex: int, pvInfo: pointer, nLength: DWORD, lpnLengthNeeded: var DWORD): WINBOOL{. stdcall, dynlib: "user32", importc: "GetUserObjectInformationA".} -proc GetUserObjectInformationA*(hObj: THandle, nIndex: int, pvInfo: pointer, +proc GetUserObjectInformationA*(hObj: Handle, nIndex: int, pvInfo: pointer, nLength: DWORD, lpnLengthNeeded: var DWORD): WINBOOL{. stdcall, dynlib: "user32", importc: "GetUserObjectInformationA".} -proc GetUserObjectInformationW*(hObj: THandle, nIndex: int, pvInfo: pointer, +proc GetUserObjectInformationW*(hObj: Handle, nIndex: int, pvInfo: pointer, nLength: DWORD, lpnLengthNeeded: var DWORD): WINBOOL{. stdcall, dynlib: "user32", importc: "GetUserObjectInformationW".} -proc GetUserObjectSecurity*(hObj: THandle, pSIRequested: var DWORD, +proc GetUserObjectSecurity*(hObj: Handle, pSIRequested: var DWORD, pSID: PSecurityDescriptor, nLength: DWORD, lpnLengthNeeded: var DWORD): WINBOOL{.stdcall, dynlib: "user32", importc: "GetUserObjectSecurity".} -proc GetVersionEx*(lpVersionInformation: var TOSVersionInfo): WINBOOL{.stdcall, +proc GetVersionEx*(lpVersionInformation: var OSVersionInfo): WINBOOL{.stdcall, dynlib: "kernel32", importc: "GetVersionExA".} -proc GetVersionExA*(lpVersionInformation: var TOSVersionInfo): WINBOOL{.stdcall, +proc GetVersionExA*(lpVersionInformation: var OSVersionInfo): WINBOOL{.stdcall, dynlib: "kernel32", importc: "GetVersionExA".} -proc GetVersionExW*(lpVersionInformation: var TOSVersionInfoW): WINBOOL{. +proc GetVersionExW*(lpVersionInformation: var OSVersionInfoW): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetVersionExW".} -proc GetViewportExtEx*(DC: HDC, Size: var TSize): WINBOOL{.stdcall, +proc GetViewportExtEx*(DC: HDC, Size: var Size): WINBOOL{.stdcall, dynlib: "gdi32", importc: "GetViewportExtEx".} -proc GetViewportOrgEx*(DC: HDC, Point: var TPoint): WINBOOL{.stdcall, +proc GetViewportOrgEx*(DC: HDC, Point: var Point): WINBOOL{.stdcall, dynlib: "gdi32", importc: "GetViewportOrgEx".} proc GetVolumeInformation*(lpRootPathName: cstring, lpVolumeNameBuffer: cstring, nVolumeNameSize: DWORD, lpVolumeSerialNumber: PDWORD, @@ -21836,59 +21570,59 @@ proc GetVolumeInformationW*(lpRootPathName: LPWSTR, lpVolumeNameBuffer: LPWSTR, lpFileSystemNameBuffer: LPWSTR, nFileSystemNameSize: DWORD): WINBOOL{.stdcall, dynlib: "kernel32", importc: "GetVolumeInformationW".} -proc GetWindowExtEx*(DC: HDC, Size: var TSize): WINBOOL{.stdcall, +proc GetWindowExtEx*(DC: HDC, Size: var Size): WINBOOL{.stdcall, dynlib: "gdi32", importc: "GetWindowExtEx".} #function GetWindowInfo(wnd: HWND; var pwi: TWindowInfo): WINBOOL;stdcall; external 'user32' name 'GetWindowInfo'; -proc GetWindowOrgEx*(DC: HDC, Point: var TPoint): WINBOOL{.stdcall, +proc GetWindowOrgEx*(DC: HDC, Point: var Point): WINBOOL{.stdcall, dynlib: "gdi32", importc: "GetWindowOrgEx".} -proc GetWindowRect*(wnd: HWND, lpRect: var TRect): WINBOOL{.stdcall, +proc GetWindowRect*(wnd: HWND, lpRect: var Rect): WINBOOL{.stdcall, dynlib: "user32", importc: "GetWindowRect".} -proc GetWorldTransform*(DC: HDC, p2: var TXForm): WINBOOL{.stdcall, +proc GetWorldTransform*(DC: HDC, p2: var XForm): WINBOOL{.stdcall, dynlib: "gdi32", importc: "GetWorldTransform".} #function GradientFill(DC: HDC; var p2: TTriVertex; p3: ULONG; p4: pointer; p5, p6: ULONG): WINBOOL;stdcall; external 'gdi32' name 'GradientFill'; proc GlobalMemoryStatus*(Buffer: var MEMORYSTATUS){.stdcall, dynlib: "kernel32", importc: "GlobalMemoryStatus".} -proc HeapWalk*(hHeap: THandle, lpEntry: var TProcessHeapEntry): WINBOOL{. +proc HeapWalk*(hHeap: Handle, lpEntry: var ProcessHeapEntry): WINBOOL{. stdcall, dynlib: "kernel32", importc: "HeapWalk".} proc ImageList_GetDragImage*(ppt: var POINT, pptHotspot: var POINT): HIMAGELIST{. stdcall, dynlib: "comctl32", importc: "ImageList_GetDragImage".} -proc InflateRect*(lprc: var TRect, dx, dy: int): WINBOOL{.stdcall, +proc InflateRect*(lprc: var Rect, dx, dy: int): WINBOOL{.stdcall, dynlib: "user32", importc: "InflateRect".} -proc InitializeAcl*(pAcl: var TACL, nAclLength, dwAclRevision: DWORD): WINBOOL{. +proc InitializeAcl*(pAcl: var ACL, nAclLength, dwAclRevision: DWORD): WINBOOL{. stdcall, dynlib: "advapi32", importc: "InitializeAcl".} -proc InitializeSid*(Sid: pointer, pIdentifierAuthority: TSIDIdentifierAuthority, +proc InitializeSid*(Sid: pointer, pIdentifierAuthority: SIDIdentifierAuthority, nSubAuthorityCount: int8): WINBOOL{.stdcall, dynlib: "advapi32", importc: "InitializeSid".} -proc InsertMenuItemA*(p1: HMENU, p2: WINUINT, p3: WINBOOL, p4: TMenuItemInfoA): WINBOOL{. +proc InsertMenuItemA*(p1: HMENU, p2: WINUINT, p3: WINBOOL, p4: MenuItemInfo): WINBOOL{. stdcall, dynlib: "user32", importc: "InsertMenuItemA".} - #function InsertMenuItemW(p1: HMENU; p2: WINUINT; p3: WINBOOL; const p4: TMenuItemInfoW): WINBOOL; stdcall; external 'user32' name 'InsertMenuItemW'; -proc IntersectRect*(lprcDst: var TRect, lprcSrc1, lprcSrc2: TRect): WINBOOL{. + #function InsertMenuItemW(p1: HMENU; p2: WINUINT; p3: WINBOOL; const p4: MenuItemInfoW): WINBOOL; stdcall; external 'user32' name 'InsertMenuItemW'; +proc IntersectRect*(lprcDst: var Rect, lprcSrc1, lprcSrc2: Rect): WINBOOL{. stdcall, dynlib: "user32", importc: "IntersectRect".} - #function InvertRect(hDC: HDC; const lprc: TRect): WINBOOL; stdcall; external 'user32' name 'InvertRect'; + #function InvertRect(hDC: HDC; const lprc: Rect): WINBOOL; stdcall; external 'user32' name 'InvertRect'; proc IsDialogMessage*(hDlg: HWND, lpMsg: var TMsg): WINBOOL{.stdcall, dynlib: "user32", importc: "IsDialogMessageA".} proc IsDialogMessageA*(hDlg: HWND, lpMsg: var TMsg): WINBOOL{.stdcall, dynlib: "user32", importc: "IsDialogMessageA".} proc IsDialogMessageW*(hDlg: HWND, lpMsg: var TMsg): WINBOOL{.stdcall, dynlib: "user32", importc: "IsDialogMessageW".} - #function IsRectEmpty(const lprc: TRect): WINBOOL; stdcall; external 'user32' name 'IsRectEmpty'; -proc IsValidAcl*(pAcl: TACL): WINBOOL{.stdcall, dynlib: "advapi32", + #function IsRectEmpty(const lprc: Rect): WINBOOL; stdcall; external 'user32' name 'IsRectEmpty'; +proc IsValidAcl*(pAcl: ACL): WINBOOL{.stdcall, dynlib: "advapi32", importc: "IsValidAcl".} -proc LocalFileTimeToFileTime*(lpLocalFileTime: TFileTime, - lpFileTime: var TFileTime): WINBOOL{.stdcall, +proc LocalFileTimeToFileTime*(lpLocalFileTime: FileTime, + lpFileTime: var FileTime): WINBOOL{.stdcall, dynlib: "kernel32", importc: "LocalFileTimeToFileTime".} -proc LockFileEx*(hFile: THandle, dwFlags, dwReserved: DWORD, +proc LockFileEx*(hFile: Handle, dwFlags, dwReserved: DWORD, nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh: DWORD, - lpOverlapped: TOverlapped): WINBOOL{.stdcall, + lpOverlapped: Overlapped): WINBOOL{.stdcall, dynlib: "kernel32", importc: "LockFileEx".} proc LogonUser*(lpszUsername, lpszDomain, lpszPassword: cstring, - dwLogonType, dwLogonProvider: DWORD, phToken: var THandle): WINBOOL{. + dwLogonType, dwLogonProvider: DWORD, phToken: var Handle): WINBOOL{. stdcall, dynlib: "advapi32", importc: "LogonUserA".} proc LogonUserA*(lpszUsername, lpszDomain, lpszPassword: LPCSTR, - dwLogonType, dwLogonProvider: DWORD, phToken: var THandle): WINBOOL{. + dwLogonType, dwLogonProvider: DWORD, phToken: var Handle): WINBOOL{. stdcall, dynlib: "advapi32", importc: "LogonUserA".} proc LogonUserW*(lpszUsername, lpszDomain, lpszPassword: LPWSTR, - dwLogonType, dwLogonProvider: DWORD, phToken: var THandle): WINBOOL{. + dwLogonType, dwLogonProvider: DWORD, phToken: var Handle): WINBOOL{. stdcall, dynlib: "advapi32", importc: "LogonUserW".} proc LookupAccountName*(lpSystemName, lpAccountName: cstring, Sid: PSID, cbSid: var DWORD, ReferencedDomainName: cstring, @@ -21932,30 +21666,30 @@ proc LookupPrivilegeDisplayNameW*(lpSystemName, lpName: LPCSTR, lpDisplayName: LPWSTR, cbDisplayName, lpLanguageId: var DWORD): WINBOOL{. stdcall, dynlib: "advapi32", importc: "LookupPrivilegeDisplayNameW".} -proc LookupPrivilegeName*(lpSystemName: cstring, lpLuid: var TLargeInteger, +proc LookupPrivilegeName*(lpSystemName: cstring, lpLuid: var LargeInteger, lpName: cstring, cbName: var DWORD): WINBOOL{.stdcall, dynlib: "advapi32", importc: "LookupPrivilegeNameA".} -proc LookupPrivilegeNameA*(lpSystemName: LPCSTR, lpLuid: var TLargeInteger, +proc LookupPrivilegeNameA*(lpSystemName: LPCSTR, lpLuid: var LargeInteger, lpName: LPCSTR, cbName: var DWORD): WINBOOL{.stdcall, dynlib: "advapi32", importc: "LookupPrivilegeNameA".} -proc LookupPrivilegeNameW*(lpSystemName: LPWSTR, lpLuid: var TLargeInteger, +proc LookupPrivilegeNameW*(lpSystemName: LPWSTR, lpLuid: var LargeInteger, lpName: LPWSTR, cbName: var DWORD): WINBOOL{.stdcall, dynlib: "advapi32", importc: "LookupPrivilegeNameW".} proc LookupPrivilegeValue*(lpSystemName, lpName: cstring, - lpLuid: var TLargeInteger): WINBOOL{.stdcall, + lpLuid: var LargeInteger): WINBOOL{.stdcall, dynlib: "advapi32", importc: "LookupPrivilegeValueA".} proc LookupPrivilegeValueA*(lpSystemName, lpName: LPCSTR, - lpLuid: var TLargeInteger): WINBOOL{.stdcall, + lpLuid: var LargeInteger): WINBOOL{.stdcall, dynlib: "advapi32", importc: "LookupPrivilegeValueA".} proc LookupPrivilegeValueW*(lpSystemName, lpName: LPWSTR, - lpLuid: var TLargeInteger): WINBOOL{.stdcall, + lpLuid: var LargeInteger): WINBOOL{.stdcall, dynlib: "advapi32", importc: "LookupPrivilegeValueW".} proc LPtoDP*(DC: HDC, Points: pointer, Count: int): WINBOOL{.stdcall, dynlib: "gdi32", importc: "LPtoDP".} proc MakeAbsoluteSD*(pSelfRelativeSecurityDescriptor: PSecurityDescriptor, pAbsoluteSecurityDescriptor: PSecurityDescriptor, lpdwAbsoluteSecurityDescriptorSi: var DWORD, - pDacl: var TACL, lpdwDaclSize: var DWORD, pSacl: var TACL, + pDacl: var ACL, lpdwDaclSize: var DWORD, pSacl: var ACL, lpdwSaclSize: var DWORD, pOwner: PSID, lpdwOwnerSize: var DWORD, pPrimaryGroup: pointer, @@ -21965,16 +21699,16 @@ proc MakeSelfRelativeSD*(pAbsoluteSecurityDescriptor: PSecurityDescriptor, pSelfRelativeSecurityDescriptor: PSecurityDescriptor, lpdwBufferLength: var DWORD): WINBOOL{.stdcall, dynlib: "advapi32", importc: "MakeSelfRelativeSD".} -proc MapDialogRect*(hDlg: HWND, lpRect: var TRect): WINBOOL{.stdcall, +proc MapDialogRect*(hDlg: HWND, lpRect: var Rect): WINBOOL{.stdcall, dynlib: "user32", importc: "MapDialogRect".} proc MapWindowPoints*(hWndFrom, hWndTo: HWND, lpPoints: pointer, cPoints: WINUINT): int{. stdcall, dynlib: "user32", importc: "MapWindowPoints".} -proc MessageBoxIndirect*(MsgBoxParams: TMsgBoxParams): WINBOOL{.stdcall, +proc MessageBoxIndirect*(MsgBoxParams: MsgBoxParams): WINBOOL{.stdcall, dynlib: "user32", importc: "MessageBoxIndirectA".} -proc MessageBoxIndirectA*(MsgBoxParams: TMsgBoxParamsA): WINBOOL{.stdcall, +proc MessageBoxIndirectA*(MsgBoxParams: MsgBoxParams): WINBOOL{.stdcall, dynlib: "user32", importc: "MessageBoxIndirectA".} - #function MessageBoxIndirectW(const MsgBoxParams: TMsgBoxParamsW): WINBOOL; stdcall; external 'user32' name 'MessageBoxIndirectW'; - #function ModifyWorldTransform(DC: HDC; const p2: TXForm; p3: DWORD): WINBOOL; stdcall; external 'gdi32' name 'ModifyWorldTransform'; + #function MessageBoxIndirectW(const MsgBoxParams: MsgBoxParamsW): WINBOOL; stdcall; external 'user32' name 'MessageBoxIndirectW'; + #function ModifyWorldTransform(DC: HDC; const p2: XForm; p3: DWORD): WINBOOL; stdcall; external 'gdi32' name 'ModifyWorldTransform'; proc MsgWaitForMultipleObjects*(nCount: DWORD, pHandles: pointer, fWaitAll: WINBOOL, dwMilliseconds, dwWakeMask: DWORD): DWORD{. @@ -21986,66 +21720,66 @@ proc MsgWaitForMultipleObjectsEx*(nCount: DWORD, pHandles: pointer, proc ObjectOpenAuditAlarm*(SubsystemName: cstring, HandleId: pointer, ObjectTypeName: cstring, ObjectName: cstring, pSecurityDescriptor: PSecurityDescriptor, - ClientToken: THandle, + ClientToken: Handle, DesiredAccess, GrantedAccess: DWORD, - Privileges: var TPrivilegeSet, + Privileges: var PrivilegeSet, ObjectCreation, AccessGranted: WINBOOL, GenerateOnClose: var WINBOOL): WINBOOL{.stdcall, dynlib: "advapi32", importc: "ObjectOpenAuditAlarmA".} proc ObjectOpenAuditAlarmA*(SubsystemName: LPCSTR, HandleId: pointer, ObjectTypeName: LPCSTR, ObjectName: LPCSTR, pSecurityDescriptor: PSecurityDescriptor, - ClientToken: THandle, + ClientToken: Handle, DesiredAccess, GrantedAccess: DWORD, - Privileges: var TPrivilegeSet, + Privileges: var PrivilegeSet, ObjectCreation, AccessGranted: WINBOOL, GenerateOnClose: var WINBOOL): WINBOOL{.stdcall, dynlib: "advapi32", importc: "ObjectOpenAuditAlarmA".} proc ObjectOpenAuditAlarmW*(SubsystemName: LPWSTR, HandleId: pointer, ObjectTypeName: LPWSTR, ObjectName: LPWSTR, pSecurityDescriptor: PSecurityDescriptor, - ClientToken: THandle, + ClientToken: Handle, DesiredAccess, GrantedAccess: DWORD, - Privileges: var TPrivilegeSet, + Privileges: var PrivilegeSet, ObjectCreation, AccessGranted: WINBOOL, GenerateOnClose: var WINBOOL): WINBOOL{.stdcall, dynlib: "advapi32", importc: "ObjectOpenAuditAlarmW".} proc ObjectPrivilegeAuditAlarm*(SubsystemName: cstring, HandleId: pointer, - ClientToken: THandle, DesiredAccess: DWORD, - Privileges: var TPrivilegeSet, + ClientToken: Handle, DesiredAccess: DWORD, + Privileges: var PrivilegeSet, AccessGranted: WINBOOL): WINBOOL{.stdcall, dynlib: "advapi32", importc: "ObjectPrivilegeAuditAlarmA".} proc ObjectPrivilegeAuditAlarmA*(SubsystemName: LPCSTR, HandleId: pointer, - ClientToken: THandle, DesiredAccess: DWORD, - Privileges: var TPrivilegeSet, + ClientToken: Handle, DesiredAccess: DWORD, + Privileges: var PrivilegeSet, AccessGranted: WINBOOL): WINBOOL{.stdcall, dynlib: "advapi32", importc: "ObjectPrivilegeAuditAlarmA".} proc ObjectPrivilegeAuditAlarmW*(SubsystemName: LPWSTR, HandleId: pointer, - ClientToken: THandle, DesiredAccess: DWORD, - Privileges: var TPrivilegeSet, + ClientToken: Handle, DesiredAccess: DWORD, + Privileges: var PrivilegeSet, AccessGranted: WINBOOL): WINBOOL{.stdcall, dynlib: "advapi32", importc: "ObjectPrivilegeAuditAlarmW".} -proc OffsetRect*(lprc: var TRect, dx, dy: int): WINBOOL{.stdcall, +proc OffsetRect*(lprc: var Rect, dx, dy: int): WINBOOL{.stdcall, dynlib: "user32", importc: "OffsetRect".} proc OffsetViewportOrgEx*(DC: HDC, X, Y: int, Points: pointer): WINBOOL{. stdcall, dynlib: "gdi32", importc: "OffsetViewportOrgEx".} proc OffsetWindowOrgEx*(DC: HDC, X, Y: int, Points: pointer): WINBOOL{.stdcall, dynlib: "gdi32", importc: "OffsetWindowOrgEx".} -proc OpenFile*(lpFileName: LPCSTR, lpReOpenBuff: var TOFStruct, uStyle: WINUINT): HFILE{. +proc OpenFile*(lpFileName: LPCSTR, lpReOpenBuff: var OFStruct, uStyle: WINUINT): HFILE{. stdcall, dynlib: "kernel32", importc: "OpenFile".} -proc OpenProcessToken*(ProcessHandle: THandle, DesiredAccess: DWORD, - TokenHandle: var THandle): WINBOOL{.stdcall, +proc OpenProcessToken*(ProcessHandle: Handle, DesiredAccess: DWORD, + TokenHandle: var Handle): WINBOOL{.stdcall, dynlib: "advapi32", importc: "OpenProcessToken".} -proc OpenThreadToken*(ThreadHandle: THandle, DesiredAccess: DWORD, - OpenAsSelf: WINBOOL, TokenHandle: var THandle): WINBOOL{. +proc OpenThreadToken*(ThreadHandle: Handle, DesiredAccess: DWORD, + OpenAsSelf: WINBOOL, TokenHandle: var Handle): WINBOOL{. stdcall, dynlib: "advapi32", importc: "OpenThreadToken".} -proc PeekConsoleInput*(hConsoleInput: THandle, lpBuffer: var TInputRecord, +proc PeekConsoleInput*(hConsoleInput: Handle, lpBuffer: var InputRecord, nLength: DWORD, lpNumberOfEventsRead: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "PeekConsoleInputA".} -proc PeekConsoleInputA*(hConsoleInput: THandle, lpBuffer: var TInputRecord, +proc PeekConsoleInputA*(hConsoleInput: Handle, lpBuffer: var InputRecord, nLength: DWORD, lpNumberOfEventsRead: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "PeekConsoleInputA".} -proc PeekConsoleInputW*(hConsoleInput: THandle, lpBuffer: var TInputRecord, +proc PeekConsoleInputW*(hConsoleInput: Handle, lpBuffer: var InputRecord, nLength: DWORD, lpNumberOfEventsRead: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "PeekConsoleInputW".} proc PeekMessage*(lpMsg: var TMsg, wnd: HWND, @@ -22057,11 +21791,11 @@ proc PeekMessageA*(lpMsg: var TMsg, wnd: HWND, proc PeekMessageW*(lpMsg: var TMsg, wnd: HWND, wMsgFilterMin, wMsgFilterMax, wRemoveMsg: WINUINT): WINBOOL{. stdcall, dynlib: "user32", importc: "PeekMessageW".} - #function PlayEnhMetaFile(DC: HDC; p2: HENHMETAFILE; const p3: TRect): WINBOOL; stdcall; external 'gdi32' name 'PlayEnhMetaFile'; -proc PlayEnhMetaFileRecord*(DC: HDC, p2: var THandleTable, p3: TEnhMetaRecord, + #function PlayEnhMetaFile(DC: HDC; p2: HENHMETAFILE; const p3: Rect): WINBOOL; stdcall; external 'gdi32' name 'PlayEnhMetaFile'; +proc PlayEnhMetaFileRecord*(DC: HDC, p2: var HandleTable, p3: EnhMetaRecord, p4: WINUINT): WINBOOL{.stdcall, dynlib: "gdi32", importc: "PlayEnhMetaFileRecord".} -proc PlayMetaFileRecord*(DC: HDC, p2: THandleTable, p3: TMetaRecord, p4: WINUINT): WINBOOL{. +proc PlayMetaFileRecord*(DC: HDC, p2: HandleTable, p3: MetaRecord, p4: WINUINT): WINBOOL{. stdcall, dynlib: "gdi32", importc: "PlayMetaFileRecord".} proc PlgBlt*(DC: HDC, PointsArray: pointer, p3: HDC, p4, p5, p6, p7: int, p8: HBITMAP, p9, p10: int): WINBOOL{.stdcall, dynlib: "gdi32", @@ -22088,28 +21822,28 @@ proc PolyTextOutA*(DC: HDC, PolyTextArray: pointer, Strings: int): WINBOOL{. stdcall, dynlib: "gdi32", importc: "PolyTextOutA".} proc PolyTextOutW*(DC: HDC, PolyTextArray: pointer, Strings: int): WINBOOL{. stdcall, dynlib: "gdi32", importc: "PolyTextOutW".} -proc PrivilegeCheck*(ClientToken: THandle, RequiredPrivileges: TPrivilegeSet, +proc PrivilegeCheck*(ClientToken: Handle, RequiredPrivileges: PrivilegeSet, pfResult: var WINBOOL): WINBOOL{.stdcall, dynlib: "advapi32", importc: "PrivilegeCheck".} proc PrivilegedServiceAuditAlarm*(SubsystemName, ServiceName: cstring, - ClientToken: THandle, - Privileges: var TPrivilegeSet, + ClientToken: Handle, + Privileges: var PrivilegeSet, AccessGranted: WINBOOL): WINBOOL{.stdcall, dynlib: "advapi32", importc: "PrivilegedServiceAuditAlarmA".} proc PrivilegedServiceAuditAlarmA*(SubsystemName, ServiceName: LPCSTR, - ClientToken: THandle, - Privileges: var TPrivilegeSet, + ClientToken: Handle, + Privileges: var PrivilegeSet, AccessGranted: WINBOOL): WINBOOL{.stdcall, dynlib: "advapi32", importc: "PrivilegedServiceAuditAlarmA".} proc PrivilegedServiceAuditAlarmW*(SubsystemName, ServiceName: LPWSTR, - ClientToken: THandle, - Privileges: var TPrivilegeSet, + ClientToken: Handle, + Privileges: var PrivilegeSet, AccessGranted: WINBOOL): WINBOOL{.stdcall, dynlib: "advapi32", importc: "PrivilegedServiceAuditAlarmW".} - #function PtInRect(const lprc: TRect; pt: TPoint): WINBOOL; stdcall; external 'user32' name 'PtInRect'; -proc QueryPerformanceCounter*(lpPerformanceCount: var TLargeInteger): WINBOOL{. + #function PtInRect(const lprc: Rect; pt: Point): WINBOOL; stdcall; external 'user32' name 'PtInRect'; +proc QueryPerformanceCounter*(lpPerformanceCount: var LargeInteger): WINBOOL{. stdcall, dynlib: "kernel32", importc: "QueryPerformanceCounter".} -proc QueryPerformanceFrequency*(lpFrequency: var TLargeInteger): WINBOOL{. +proc QueryPerformanceFrequency*(lpFrequency: var LargeInteger): WINBOOL{. stdcall, dynlib: "kernel32", importc: "QueryPerformanceFrequency".} #function QueryRecoveryAgents(p1: PChar; var p2: pointer; var p3: TRecoveryAgentInformation): DWORD;stdcall; external 'kernel32' name 'QueryRecoveryAgentsA'; #function QueryRecoveryAgentsA(p1: LPCSTR; var p2: pointer; var p3: TRecoveryAgentInformationA): DWORD;stdcall; external 'kernel32' name 'QueryRecoveryAgentsA'; @@ -22119,76 +21853,76 @@ proc RaiseException*(dwExceptionCode: DWORD, dwExceptionFlags: DWORD, stdcall, dynlib: "kernel32", importc: "RaiseException".} proc UnhandledExceptionFilter*(ExceptionInfo: var emptyrecord): LONG{.stdcall, dynlib: "kernel32", importc: "UnhandledExceptionFilter".} -proc ReadConsole*(hConsoleInput: THandle, lpBuffer: pointer, +proc ReadConsole*(hConsoleInput: Handle, lpBuffer: pointer, nNumberOfCharsToRead: DWORD, lpNumberOfCharsRead: var DWORD, lpReserved: pointer): WINBOOL{.stdcall, dynlib: "kernel32", importc: "ReadConsoleA".} -proc ReadConsoleA*(hConsoleInput: THandle, lpBuffer: pointer, +proc ReadConsoleA*(hConsoleInput: Handle, lpBuffer: pointer, nNumberOfCharsToRead: DWORD, lpNumberOfCharsRead: var DWORD, lpReserved: pointer): WINBOOL{.stdcall, dynlib: "kernel32", importc: "ReadConsoleA".} -proc ReadConsoleInput*(hConsoleInput: THandle, lpBuffer: var TInputRecord, +proc ReadConsoleInput*(hConsoleInput: Handle, lpBuffer: var InputRecord, nLength: DWORD, lpNumberOfEventsRead: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "ReadConsoleInputA".} -proc ReadConsoleInputA*(hConsoleInput: THandle, lpBuffer: var TInputRecord, +proc ReadConsoleInputA*(hConsoleInput: Handle, lpBuffer: var InputRecord, nLength: DWORD, lpNumberOfEventsRead: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "ReadConsoleInputA".} -proc ReadConsoleInputW*(hConsoleInput: THandle, lpBuffer: var TInputRecord, +proc ReadConsoleInputW*(hConsoleInput: Handle, lpBuffer: var InputRecord, nLength: DWORD, lpNumberOfEventsRead: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "ReadConsoleInputW".} -proc ReadConsoleOutput*(hConsoleOutput: THandle, lpBuffer: pointer, - dwBufferSize, dwBufferCoord: TCoord, - lpReadRegion: var TSmallRect): WINBOOL{.stdcall, +proc ReadConsoleOutput*(hConsoleOutput: Handle, lpBuffer: pointer, + dwBufferSize, dwBufferCoord: Coord, + lpReadRegion: var SmallRect): WINBOOL{.stdcall, dynlib: "kernel32", importc: "ReadConsoleOutputA".} -proc ReadConsoleOutputA*(hConsoleOutput: THandle, lpBuffer: pointer, - dwBufferSize, dwBufferCoord: TCoord, - lpReadRegion: var TSmallRect): WINBOOL{.stdcall, +proc ReadConsoleOutputA*(hConsoleOutput: Handle, lpBuffer: pointer, + dwBufferSize, dwBufferCoord: Coord, + lpReadRegion: var SmallRect): WINBOOL{.stdcall, dynlib: "kernel32", importc: "ReadConsoleOutputA".} -proc ReadConsoleOutputAttribute*(hConsoleOutput: THandle, lpAttribute: pointer, - nLength: DWORD, dwReadCoord: TCoord, +proc ReadConsoleOutputAttribute*(hConsoleOutput: Handle, lpAttribute: pointer, + nLength: DWORD, dwReadCoord: Coord, lpNumberOfAttrsRead: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "ReadConsoleOutputAttribute".} -proc ReadConsoleOutputCharacter*(hConsoleOutput: THandle, lpCharacter: LPCSTR, - nLength: DWORD, dwReadCoord: TCoord, +proc ReadConsoleOutputCharacter*(hConsoleOutput: Handle, lpCharacter: LPCSTR, + nLength: DWORD, dwReadCoord: Coord, lpNumberOfCharsRead: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "ReadConsoleOutputCharacterA".} -proc ReadConsoleOutputCharacterA*(hConsoleOutput: THandle, lpCharacter: LPCSTR, - nLength: DWORD, dwReadCoord: TCoord, +proc ReadConsoleOutputCharacterA*(hConsoleOutput: Handle, lpCharacter: LPCSTR, + nLength: DWORD, dwReadCoord: Coord, lpNumberOfCharsRead: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "ReadConsoleOutputCharacterA".} -proc ReadConsoleOutputCharacterW*(hConsoleOutput: THandle, lpCharacter: LPCSTR, - nLength: DWORD, dwReadCoord: TCoord, +proc ReadConsoleOutputCharacterW*(hConsoleOutput: Handle, lpCharacter: LPCSTR, + nLength: DWORD, dwReadCoord: Coord, lpNumberOfCharsRead: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "ReadConsoleOutputCharacterW".} -proc ReadConsoleOutputW*(hConsoleOutput: THandle, lpBuffer: pointer, - dwBufferSize, dwBufferCoord: TCoord, - lpReadRegion: var TSmallRect): WINBOOL{.stdcall, +proc ReadConsoleOutputW*(hConsoleOutput: Handle, lpBuffer: pointer, + dwBufferSize, dwBufferCoord: Coord, + lpReadRegion: var SmallRect): WINBOOL{.stdcall, dynlib: "kernel32", importc: "ReadConsoleOutputW".} -proc ReadConsoleW*(hConsoleInput: THandle, lpBuffer: pointer, +proc ReadConsoleW*(hConsoleInput: Handle, lpBuffer: pointer, nNumberOfCharsToRead: DWORD, lpNumberOfCharsRead: var DWORD, lpReserved: pointer): WINBOOL{.stdcall, dynlib: "kernel32", importc: "ReadConsoleW".} -proc ReadEventLog*(hEventLog: THandle, dwReadFlags, dwRecordOffset: DWORD, +proc ReadEventLog*(hEventLog: Handle, dwReadFlags, dwRecordOffset: DWORD, lpBuffer: pointer, nNumberOfBytesToRead: DWORD, pnBytesRead, pnMinNumberOfBytesNeeded: var DWORD): WINBOOL{. stdcall, dynlib: "advapi32", importc: "ReadEventLogA".} -proc ReadEventLogA*(hEventLog: THandle, dwReadFlags, dwRecordOffset: DWORD, +proc ReadEventLogA*(hEventLog: Handle, dwReadFlags, dwRecordOffset: DWORD, lpBuffer: pointer, nNumberOfBytesToRead: DWORD, pnBytesRead, pnMinNumberOfBytesNeeded: var DWORD): WINBOOL{. stdcall, dynlib: "advapi32", importc: "ReadEventLogA".} -proc ReadEventLogW*(hEventLog: THandle, dwReadFlags, dwRecordOffset: DWORD, +proc ReadEventLogW*(hEventLog: Handle, dwReadFlags, dwRecordOffset: DWORD, lpBuffer: pointer, nNumberOfBytesToRead: DWORD, pnBytesRead, pnMinNumberOfBytesNeeded: var DWORD): WINBOOL{. stdcall, dynlib: "advapi32", importc: "ReadEventLogW".} -proc ReadFile*(hFile: THandle, Buffer: pointer, nNumberOfBytesToRead: DWORD, +proc ReadFile*(hFile: Handle, Buffer: pointer, nNumberOfBytesToRead: DWORD, lpNumberOfBytesRead: var DWORD, lpOverlapped: POverlapped): WINBOOL{. stdcall, dynlib: "kernel32", importc: "ReadFile".} -proc ReadProcessMemory*(hProcess: THandle, lpBaseAddress: pointer, +proc ReadProcessMemory*(hProcess: Handle, lpBaseAddress: pointer, lpBuffer: pointer, nSize: DWORD, lpNumberOfBytesRead: var DWORD): WINBOOL{.stdcall, dynlib: "kernel32", importc: "ReadProcessMemory".} - #function RectInRegion(RGN: HRGN; const p2: TRect): WINBOOL; stdcall; external 'gdi32' name 'RectInRegion'; - #function RectVisible(DC: HDC; const Rect: TRect): WINBOOL; stdcall; external 'gdi32' name 'RectVisible'; + #function RectInRegion(RGN: HRGN; const p2: Rect): WINBOOL; stdcall; external 'gdi32' name 'RectInRegion'; + #function RectVisible(DC: HDC; const Rect: Rect): WINBOOL; stdcall; external 'gdi32' name 'RectVisible'; proc RegConnectRegistry*(lpMachineName: cstring, key: HKEY, phkResult: var HKEY): int32{. stdcall, dynlib: "advapi32", importc: "RegConnectRegistryA".} proc RegConnectRegistryA*(lpMachineName: LPCSTR, key: HKEY, phkResult: var HKEY): int32{. @@ -22253,17 +21987,17 @@ proc RegSetValueExA*(key: HKEY, lpValueName: LPCSTR, Reserved: DWORD, proc RegSetValueExW*(key: HKEY, lpValueName: LPCWSTR, Reserved: DWORD, dwType: DWORD, lpData: pointer, cbData: DWORD): LONG{. stdcall, dynlib: "advapi32", importc: "RegSetValueExW".} -proc RegisterClass*(lpWndClass: TWndClass): ATOM{.stdcall, dynlib: "user32", +proc RegisterClass*(lpWndClass: WndClass): ATOM{.stdcall, dynlib: "user32", importc: "RegisterClassA".} -proc RegisterClassA*(lpWndClass: TWndClassA): ATOM{.stdcall, dynlib: "user32", +proc RegisterClassA*(lpWndClass: WndClass): ATOM{.stdcall, dynlib: "user32", importc: "RegisterClassA".} -proc RegisterClassEx*(WndClass: TWndClassEx): ATOM{.stdcall, dynlib: "user32", +proc RegisterClassEx*(WndClass: WndClassEx): ATOM{.stdcall, dynlib: "user32", importc: "RegisterClassExA".} -proc RegisterClassExA*(WndClass: TWndClassExA): ATOM{.stdcall, dynlib: "user32", +proc RegisterClassExA*(WndClass: WndClassEx): ATOM{.stdcall, dynlib: "user32", importc: "RegisterClassExA".} -proc RegisterClassExW*(WndClass: TWndClassExW): ATOM{.stdcall, dynlib: "user32", +proc RegisterClassExW*(WndClass: WndClassExW): ATOM{.stdcall, dynlib: "user32", importc: "RegisterClassExW".} -proc RegisterClassW*(lpWndClass: TWndClassW): ATOM{.stdcall, dynlib: "user32", +proc RegisterClassW*(lpWndClass: WndClassW): ATOM{.stdcall, dynlib: "user32", importc: "RegisterClassW".} proc RegOpenKey*(key: HKEY, lpSubKey: cstring, phkResult: var HKEY): int32{. stdcall, dynlib: "advapi32", importc: "RegOpenKeyA".} @@ -22298,30 +22032,30 @@ proc RegQueryValueA*(key: HKEY, lpSubKey: LPCSTR, lpValue: LPCSTR, proc RegQueryValueW*(key: HKEY, lpSubKey: LPWSTR, lpValue: LPWSTR, lpcbValue: var int32): int32{.stdcall, dynlib: "advapi32", importc: "RegQueryValueW".} -proc ResetDC*(DC: HDC, p2: TDeviceMode): HDC{.stdcall, dynlib: "gdi32", +proc ResetDC*(DC: HDC, p2: DevMode): HDC{.stdcall, dynlib: "gdi32", importc: "ResetDCA".} -proc ResetDCA*(DC: HDC, p2: TDeviceModeA): HDC{.stdcall, dynlib: "gdi32", +proc ResetDCA*(DC: HDC, p2: DevMode): HDC{.stdcall, dynlib: "gdi32", importc: "ResetDCA".} - #function ResetDCW(DC: HDC; const p2: TDeviceModeW): HDC; stdcall; external 'gdi32' name 'ResetDCW'; -proc ScreenToClient*(wnd: HWND, lpPoint: var TPoint): WINBOOL{.stdcall, + #function ResetDCW(DC: HDC; const p2: DevModeW): HDC; stdcall; external 'gdi32' name 'ResetDCW'; +proc ScreenToClient*(wnd: HWND, lpPoint: var Point): WINBOOL{.stdcall, dynlib: "user32", importc: "ScreenToClient".} -proc ScrollConsoleScreenBuffer*(hConsoleOutput: THandle, - lpScrollRectangle: TSmallRect, - lpClipRectangle: TSmallRect, - dwDestinationOrigin: TCoord, - lpFill: var TCharInfo): WINBOOL{.stdcall, +proc ScrollConsoleScreenBuffer*(hConsoleOutput: Handle, + lpScrollRectangle: SmallRect, + lpClipRectangle: SmallRect, + dwDestinationOrigin: Coord, + lpFill: var CharInfo): WINBOOL{.stdcall, dynlib: "kernel32", importc: "ScrollConsoleScreenBufferA".} -proc ScrollConsoleScreenBufferA*(hConsoleOutput: THandle, - lpScrollRectangle: TSmallRect, - lpClipRectangle: TSmallRect, - dwDestinationOrigin: TCoord, - lpFill: var TCharInfo): WINBOOL{.stdcall, +proc ScrollConsoleScreenBufferA*(hConsoleOutput: Handle, + lpScrollRectangle: SmallRect, + lpClipRectangle: SmallRect, + dwDestinationOrigin: Coord, + lpFill: var CharInfo): WINBOOL{.stdcall, dynlib: "kernel32", importc: "ScrollConsoleScreenBufferA".} -proc ScrollConsoleScreenBufferW*(hConsoleOutput: THandle, - lpScrollRectangle: TSmallRect, - lpClipRectangle: TSmallRect, - dwDestinationOrigin: TCoord, - lpFill: var TCharInfo): WINBOOL{.stdcall, +proc ScrollConsoleScreenBufferW*(hConsoleOutput: Handle, + lpScrollRectangle: SmallRect, + lpClipRectangle: SmallRect, + dwDestinationOrigin: Coord, + lpFill: var CharInfo): WINBOOL{.stdcall, dynlib: "kernel32", importc: "ScrollConsoleScreenBufferW".} proc ScrollWindow*(wnd: HWND, XAmount: int32, YAmount: int32, rect: LPRECT, lpClipRect: LPRECT): WINBOOL{.stdcall, dynlib: "user32", @@ -22330,7 +22064,7 @@ proc ScrollWindowEx*(wnd: HWND, dx: int32, dy: int32, prcScroll: LPRECT, prcClip: LPRECT, hrgnUpdate: HRGN, prcUpdate: LPRECT, flags: WINUINT): int32{.stdcall, dynlib: "user32", importc: "ScrollWindowEx".} - #function ScrollDC(DC: HDC; DX, DY: Integer; var Scroll, Clip: TRect; Rgn: HRGN; Update: PRect): WINBOOL; stdcall; external 'user32' name 'ScrollDC'; + #function ScrollDC(DC: HDC; DX, DY: Integer; var Scroll, Clip: Rect; Rgn: HRGN; Update: PRect): WINBOOL; stdcall; external 'user32' name 'ScrollDC'; #function SearchPath(lpPath, lpFileName, lpExtension: PChar; nBufferLength: DWORD; lpBuffer: PChar; var lpFilePart: PChar): DWORD;stdcall; external 'kernel32' name 'SearchPathA'; #function SearchPathA(lpPath, lpFileName, lpExtension: LPCSTR; nBufferLength: DWORD; lpBuffer: LPCSTR; var lpFilePart: LPCSTR): DWORD; stdcall; external 'kernel32' name 'SearchPathA'; #function SearchPathW(lpPath, lpFileName, lpExtension: LPWSTR; nBufferLength: DWORD; lpBuffer: LPWSTR; var lpFilePart: LPWSTR): DWORD; stdcall; external 'kernel32' name 'SearchPathW'; @@ -22344,84 +22078,84 @@ proc SendMessageTimeoutA*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM, proc SendMessageTimeoutW*(wnd: HWND, Msg: WINUINT, wp: WPARAM, lp: LPARAM, fuFlags, uTimeout: WINUINT, lpdwResult: var DWORD): LRESULT{. stdcall, dynlib: "user32", importc: "SendMessageTimeoutW".} - #function SetAclInformation(var pAcl: TACL; pAclInformation: pointer; nAclInformationLength: DWORD; dwAclInformationClass: TAclInformationClass): WINBOOL; stdcall; external 'advapi32' name 'SetAclInformation'; - #function SetColorAdjustment(DC: HDC; const p2: TColorAdjustment): WINBOOL; stdcall; external 'gdi32' name 'SetColorAdjustment'; -proc SetCommConfig*(hCommDev: THandle, lpCC: TCommConfig, dwSize: DWORD): WINBOOL{. + #function SetAclInformation(var pAcl: ACL; pAclInformation: pointer; nAclInformationLength: DWORD; dwAclInformationClass: AclInformationClass): WINBOOL; stdcall; external 'advapi32' name 'SetAclInformation'; + #function SetColorAdjustment(DC: HDC; const p2: ColorAdjustment): WINBOOL; stdcall; external 'gdi32' name 'SetColorAdjustment'; +proc SetCommConfig*(hCommDev: Handle, lpCC: CommConfig, dwSize: DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "SetCommConfig".} -proc SetCommState*(hFile: THandle, lpDCB: TDCB): WINBOOL{.stdcall, +proc SetCommState*(hFile: Handle, lpDCB: DCB): WINBOOL{.stdcall, dynlib: "kernel32", importc: "SetCommState".} -proc SetCommTimeouts*(hFile: THandle, lpCommTimeouts: TCommTimeouts): WINBOOL{. +proc SetCommTimeouts*(hFile: Handle, lpCommTimeouts: CommTimeouts): WINBOOL{. stdcall, dynlib: "kernel32", importc: "SetCommTimeouts".} -proc SetConsoleCursorInfo*(hConsoleOutput: THandle, - lpConsoleCursorInfo: TConsoleCursorInfo): WINBOOL{. +proc SetConsoleCursorInfo*(hConsoleOutput: Handle, + lpConsoleCursorInfo: ConsoleCursorInfo): WINBOOL{. stdcall, dynlib: "kernel32", importc: "SetConsoleCursorInfo".} - #function SetConsoleWindowInfo(hConsoleOutput: THandle; bAbsolute: WINBOOL; const lpConsoleWindow: TSmallRect): WINBOOL; stdcall; external 'kernel32' name 'SetConsoleWindowInfo'; + #function SetConsoleWindowInfo(hConsoleOutput: Handle; bAbsolute: WINBOOL; const lpConsoleWindow: SmallRect): WINBOOL; stdcall; external 'kernel32' name 'SetConsoleWindowInfo'; proc SetDIBColorTable*(DC: HDC, p2, p3: WINUINT, RGBQuadSTructs: pointer): WINUINT{. stdcall, dynlib: "gdi32", importc: "SetDIBColorTable".} proc SetDIBits*(DC: HDC, Bitmap: HBITMAP, StartScan, NumScans: WINUINT, - Bits: pointer, BitsInfo: var TBitmapInfo, Usage: WINUINT): int{. + Bits: pointer, BitsInfo: var BitmapInfo, Usage: WINUINT): int{. stdcall, dynlib: "gdi32", importc: "SetDIBits".} - #function SetDIBitsToDevice(DC: HDC; DestX, DestY: Integer; Width, Height: DWORD; SrcX, SrcY: Integer; nStartScan, NumScans: WINUINT; Bits: pointer; var BitsInfo: TBitmapInfo; Usage: WINUINT): Integer; stdcall; external 'gdi32' name 'SetDIBitsToDevice'; + #function SetDIBitsToDevice(DC: HDC; DestX, DestY: Integer; Width, Height: DWORD; SrcX, SrcY: Integer; nStartScan, NumScans: WINUINT; Bits: pointer; var BitsInfo: BitmapInfo; Usage: WINUINT): Integer; stdcall; external 'gdi32' name 'SetDIBitsToDevice'; proc SetEnhMetaFileBits*(para1: WINUINT, para2: pointer): HENHMETAFILE{.stdcall, dynlib: "gdi32", importc: "SetEnhMetaFileBits".} proc SetFileTime*(hFile: HANDLE, lpCreationTime: var FILETIME, lpLastAccessTime: var FILETIME, lpLastWriteTime: var FILETIME): WINBOOL{. stdcall, dynlib: "kernel32", importc: "SetFileTime".} #function SetKeyboardState(var KeyState: TKeyboardState): WINBOOL; stdcall; external 'user32' name 'SetKeyboardState'; - #function SetLocalTime(const lpSystemTime: TSystemTime): WINBOOL; stdcall; external 'kernel32' name 'SetLocalTime'; + #function SetLocalTime(const lpSystemTime: SystemTime): WINBOOL; stdcall; external 'kernel32' name 'SetLocalTime'; #function SetMenuInfo(menu: HMENU; const lpcmi: TMenuInfo): WINBOOL;stdcall; external 'user32' name 'SetMenuInfo'; -proc SetMenuItemInfo*(p1: HMENU, p2: WINUINT, p3: WINBOOL, p4: TMenuItemInfo): WINBOOL{. +proc SetMenuItemInfo*(p1: HMENU, p2: WINUINT, p3: WINBOOL, p4: MenuItemInfo): WINBOOL{. stdcall, dynlib: "user32", importc: "SetMenuItemInfoA".} -proc SetMenuItemInfoA*(p1: HMENU, p2: WINUINT, p3: WINBOOL, p4: TMenuItemInfoA): WINBOOL{. +proc SetMenuItemInfoA*(p1: HMENU, p2: WINUINT, p3: WINBOOL, p4: MenuItemInfo): WINBOOL{. stdcall, dynlib: "user32", importc: "SetMenuItemInfoA".} - #function SetMenuItemInfoW(p1: HMENU; p2: WINUINT; p3: WINBOOL; const p4: TMenuItemInfoW): WINBOOL; stdcall; external 'user32' name 'SetMenuItemInfoW'; + #function SetMenuItemInfoW(p1: HMENU; p2: WINUINT; p3: WINBOOL; const p4: MenuItemInfoW): WINBOOL; stdcall; external 'user32' name 'SetMenuItemInfoW'; proc SetMetaFileBitsEx*(p1: WINUINT, p2: cstring): HMETAFILE{.stdcall, dynlib: "gdi32", importc: "SetMetaFileBitsEx".} -proc SetNamedPipeHandleState*(hNamedPipe: THandle, lpMode: var DWORD, +proc SetNamedPipeHandleState*(hNamedPipe: Handle, lpMode: var DWORD, lpMaxCollectionCount, lpCollectDataTimeout: pointer): WINBOOL{.stdcall, dynlib: "kernel32", importc: "SetNamedPipeHandleState".} proc SetPaletteEntries*(Palette: HPALETTE, StartIndex, NumEntries: WINUINT, PaletteEntries: pointer): WINUINT{.stdcall, dynlib: "gdi32", importc: "SetPaletteEntries".} - #function SetPrivateObjectSecurity(SecurityInformation: SECURITY_INFORMATION; ModificationDescriptor: PSecurityDescriptor; var ObjectsSecurityDescriptor: PSecurityDescriptor; const GenericMapping: TGenericMapping; Token: THandle): WINBOOL; + #function SetPrivateObjectSecurity(SecurityInformation: SECURITY_INFORMATION; ModificationDescriptor: PSecurityDescriptor; var ObjectsSecurityDescriptor: PSecurityDescriptor; const GenericMapping: GenericMapping; Token: Handle): WINBOOL; # stdcall; external 'advapi32' name 'SetPrivateObjectSecurity'; #function SetPrivateObjectSecurityEx(SecurityInformation: SECURITY_INFORMATION; ModificationDescriptor: PSecurityDescriptor; var ObjectsSecurityDescriptor: PSecurityDescriptor; AutoInheritFlags: ULONG; - # const GenericMapping: TGenericMapping; Token: THandle): WINBOOL;stdcall; external 'advapi32' name 'SetPrivateObjectSecurityEx'; -proc SetRect*(lprc: var TRect, xLeft, yTop, xRight, yBottom: int): WINBOOL{. + # const GenericMapping: GenericMapping; Token: Handle): WINBOOL;stdcall; external 'advapi32' name 'SetPrivateObjectSecurityEx'; +proc SetRect*(lprc: var Rect, xLeft, yTop, xRight, yBottom: int): WINBOOL{. stdcall, dynlib: "user32", importc: "SetRect".} -proc SetRectEmpty*(lprc: var TRect): WINBOOL{.stdcall, dynlib: "user32", +proc SetRectEmpty*(lprc: var Rect): WINBOOL{.stdcall, dynlib: "user32", importc: "SetRectEmpty".} -proc SetScrollInfo*(wnd: HWND, BarFlag: int, ScrollInfo: TScrollInfo, +proc SetScrollInfo*(wnd: HWND, BarFlag: int, ScrollInfo: ScrollInfo, Redraw: WINBOOL): int{.stdcall, dynlib: "user32", importc: "SetScrollInfo".} proc SetSysColors*(cElements: int, lpaElements: pointer, lpaRgbValues: pointer): WINBOOL{. stdcall, dynlib: "user32", importc: "SetSysColors".} - #function SetSystemTime(const lpSystemTime: TSystemTime): WINBOOL; stdcall; external 'kernel32' name 'SetSystemTime'; -proc SetThreadContext*(hThread: THandle, lpContext: TContext): WINBOOL{.stdcall, + #function SetSystemTime(const lpSystemTime: SystemTime): WINBOOL; stdcall; external 'kernel32' name 'SetSystemTime'; +proc SetThreadContext*(hThread: Handle, lpContext: Context): WINBOOL{.stdcall, dynlib: "kernel32", importc: "SetThreadContext".} - #function SetTimeZoneInformation(const lpTimeZoneInformation: TTimeZoneInformation): WINBOOL; stdcall; external 'kernel32' name 'SetTimeZoneInformation'; -proc SetUserObjectSecurity*(hObj: THandle, pSIRequested: var DWORD, + #function SetTimeZoneInformation(const lpTimeZoneInformation: TimeZoneInformation): WINBOOL; stdcall; external 'kernel32' name 'SetTimeZoneInformation'; +proc SetUserObjectSecurity*(hObj: Handle, pSIRequested: var DWORD, pSID: PSecurityDescriptor): WINBOOL{.stdcall, dynlib: "user32", importc: "SetUserObjectSecurity".} -proc SetWaitableTimer*(hTimer: THandle, lpDueTime: var TLargeInteger, +proc SetWaitableTimer*(hTimer: Handle, lpDueTime: var LargeInteger, lPeriod: int32, pfnCompletionRoutine: TFNTimerAPCRoutine, lpArgToCompletionRoutine: pointer, fResume: WINBOOL): WINBOOL{. stdcall, dynlib: "kernel32", importc: "SetWaitableTimer".} -proc SetWinMetaFileBits*(p1: WINUINT, p2: cstring, p3: HDC, p4: TMetaFilePict): HENHMETAFILE{. +proc SetWinMetaFileBits*(p1: WINUINT, p2: cstring, p3: HDC, p4: MetaFilePict): HENHMETAFILE{. stdcall, dynlib: "gdi32", importc: "SetWinMetaFileBits".} - #function SetWorldTransform(DC: HDC; const p2: TXForm): WINBOOL; stdcall; external 'gdi32' name 'SetWorldTransform'; -proc StartDoc*(DC: HDC, p2: TDocInfo): int{.stdcall, dynlib: "gdi32", + #function SetWorldTransform(DC: HDC; const p2: XForm): WINBOOL; stdcall; external 'gdi32' name 'SetWorldTransform'; +proc StartDoc*(DC: HDC, p2: DocInfo): int{.stdcall, dynlib: "gdi32", importc: "StartDocA".} -proc StartDocA*(DC: HDC, p2: TDocInfoA): int{.stdcall, dynlib: "gdi32", +proc StartDocA*(DC: HDC, p2: DocInfo): int{.stdcall, dynlib: "gdi32", importc: "StartDocA".} - #function StartDocW(DC: HDC; const p2: TDocInfoW): Integer; stdcall; external 'gdi32' name 'StartDocW'; - #function StretchDIBits(DC: HDC; DestX, DestY, DestWidth, DestHegiht, SrcX, SrcY, SrcWidth, SrcHeight: Integer; Bits: pointer; var BitsInfo: TBitmapInfo; Usage: WINUINT; Rop: DWORD): Integer; stdcall; external 'gdi32' name 'StretchDIBits'; -proc SubtractRect*(lprcDst: var TRect, lprcSrc1, lprcSrc2: TRect): WINBOOL{. + #function StartDocW(DC: HDC; const p2: DocInfoW): Integer; stdcall; external 'gdi32' name 'StartDocW'; + #function StretchDIBits(DC: HDC; DestX, DestY, DestWidth, DestHegiht, SrcX, SrcY, SrcWidth, SrcHeight: Integer; Bits: pointer; var BitsInfo: BitmapInfo; Usage: WINUINT; Rop: DWORD): Integer; stdcall; external 'gdi32' name 'StretchDIBits'; +proc SubtractRect*(lprcDst: var Rect, lprcSrc1, lprcSrc2: Rect): WINBOOL{. stdcall, dynlib: "user32", importc: "SubtractRect".} -proc SystemTimeToFileTime*(lpSystemTime: TSystemTime, lpFileTime: var TFileTime): WINBOOL{. +proc SystemTimeToFileTime*(lpSystemTime: SystemTime, lpFileTime: var FileTime): WINBOOL{. stdcall, dynlib: "kernel32", importc: "SystemTimeToFileTime".} proc SystemTimeToTzSpecificLocalTime*(lpTimeZoneInformation: PTimeZoneInformation, - lpUniversalTime, lpLocalTime: var TSystemTime): WINBOOL{.stdcall, + lpUniversalTime, lpLocalTime: var SystemTime): WINBOOL{.stdcall, dynlib: "kernel32", importc: "SystemTimeToTzSpecificLocalTime".} proc TabbedTextOut*(hDC: HDC, X, Y: int, lpString: cstring, nCount, nTabPositions: int, lpnTabStopPositions: pointer, @@ -22446,7 +22180,7 @@ proc TrackMouseEvent*(lpEventTrack: PTrackMouseEvent): WINBOOL{.stdcall, proc TrackPopupMenu*(menu: HMENU, uFlags: WINUINT, x: int32, y: int32, nReserved: int32, wnd: HWND, prcRect: PRect): WINBOOL{. stdcall, dynlib: "user32", importc: "TrackPopupMenu".} -proc TransactNamedPipe*(hNamedPipe: THandle, lpInBuffer: pointer, +proc TransactNamedPipe*(hNamedPipe: Handle, lpInBuffer: pointer, nInBufferSize: DWORD, lpOutBuffer: pointer, nOutBufferSize: DWORD, lpBytesRead: var DWORD, lpOverlapped: POverlapped): WINBOOL{.stdcall, @@ -22457,7 +22191,7 @@ proc TranslateAcceleratorA*(wnd: HWND, hAccTable: HACCEL, lpMsg: var TMsg): int{ stdcall, dynlib: "user32", importc: "TranslateAcceleratorA".} proc TranslateAcceleratorW*(wnd: HWND, hAccTable: HACCEL, lpMsg: var TMsg): int{. stdcall, dynlib: "user32", importc: "TranslateAcceleratorW".} -proc TranslateCharsetInfo*(lpSrc: var DWORD, lpCs: var TCharsetInfo, +proc TranslateCharsetInfo*(lpSrc: var DWORD, lpCs: var CharsetInfo, dwFlags: DWORD): WINBOOL{.stdcall, dynlib: "gdi32", importc: "TranslateCharsetInfo".} proc TranslateMDISysAccel*(hWndClient: HWND, lpMsg: TMsg): WINBOOL{.stdcall, @@ -22465,12 +22199,12 @@ proc TranslateMDISysAccel*(hWndClient: HWND, lpMsg: TMsg): WINBOOL{.stdcall, proc TranslateMessage*(lpMsg: TMsg): WINBOOL{.stdcall, dynlib: "user32", importc: "TranslateMessage".} #function TransparentDIBits(DC: HDC; p2, p3, p4, p5: Integer; const p6: pointer; const p7: PBitmapInfo; p8: WINUINT; p9, p10, p11, p12: Integer; p13: WINUINT): WINBOOL;stdcall; external 'gdi32' name 'TransparentDIBits'; -proc UnhandledExceptionFilter*(ExceptionInfo: TExceptionpointers): int32{. +proc UnhandledExceptionFilter*(ExceptionInfo: Exceptionpointers): int32{. stdcall, dynlib: "kernel32", importc: "UnhandledExceptionFilter".} -proc UnionRect*(lprcDst: var TRect, lprcSrc1, lprcSrc2: TRect): WINBOOL{. +proc UnionRect*(lprcDst: var Rect, lprcSrc1, lprcSrc2: Rect): WINBOOL{. stdcall, dynlib: "user32", importc: "UnionRect".} -proc UnlockFileEx*(hFile: THandle, dwReserved, nNumberOfBytesToUnlockLow: DWORD, - nNumberOfBytesToUnlockHigh: DWORD, lpOverlapped: TOverlapped): WINBOOL{. +proc UnlockFileEx*(hFile: Handle, dwReserved, nNumberOfBytesToUnlockLow: DWORD, + nNumberOfBytesToUnlockHigh: DWORD, lpOverlapped: Overlapped): WINBOOL{. stdcall, dynlib: "kernel32", importc: "UnlockFileEx".} proc VerFindFile*(uFlags: DWORD, szFileName, szWinDir, szAppDir, szCurDir: cstring, @@ -22508,19 +22242,19 @@ proc VerQueryValueA*(pBlock: pointer, lpSubBlock: LPCSTR, proc VerQueryValueW*(pBlock: pointer, lpSubBlock: LPWSTR, lplpBuffer: var pointer, puLen: var WINUINT): WINBOOL{. stdcall, dynlib: "version", importc: "VerQueryValueW".} -proc VirtualQuery*(lpAddress: pointer, lpBuffer: var TMemoryBasicInformation, +proc VirtualQuery*(lpAddress: pointer, lpBuffer: var MemoryBasicInformation, dwLength: DWORD): DWORD{.stdcall, dynlib: "kernel32", importc: "VirtualQuery".} -proc VirtualQueryEx*(hProcess: THandle, lpAddress: pointer, - lpBuffer: var TMemoryBasicInformation, dwLength: DWORD): DWORD{. +proc VirtualQueryEx*(hProcess: Handle, lpAddress: pointer, + lpBuffer: var MemoryBasicInformation, dwLength: DWORD): DWORD{. stdcall, dynlib: "kernel32", importc: "VirtualQueryEx".} -proc WaitCommEvent*(hFile: THandle, lpEvtMask: var DWORD, +proc WaitCommEvent*(hFile: Handle, lpEvtMask: var DWORD, lpOverlapped: POverlapped): WINBOOL{.stdcall, dynlib: "kernel32", importc: "WaitCommEvent".} -proc WaitForDebugEvent*(lpDebugEvent: var TDebugEvent, dwMilliseconds: DWORD): WINBOOL{. +proc WaitForDebugEvent*(lpDebugEvent: var DebugEvent, dwMilliseconds: DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "WaitForDebugEvent".} proc wglDescribeLayerPlane*(p1: HDC, p2, p3: int, p4: int, - p5: var TLayerPlaneDescriptor): WINBOOL{.stdcall, + p5: var LayerPlaneDescriptor): WINBOOL{.stdcall, dynlib: "opengl32", importc: "wglDescribeLayerPlane".} proc wglGetLayerPaletteEntries*(p1: HDC, p2, p3, p4: int, pcr: pointer): int{. stdcall, dynlib: "opengl32", importc: "wglGetLayerPaletteEntries".} @@ -22528,38 +22262,38 @@ proc wglSetLayerPaletteEntries*(p1: HDC, p2, p3, p4: int, pcr: pointer): int{. stdcall, dynlib: "opengl32", importc: "wglSetLayerPaletteEntries".} #function wglSwapMultipleBuffers(p1: WINUINT; const p2: PWGLSwap): DWORD;stdcall; external 'opengl32' name 'wglSwapMultipleBuffers'; #function WinSubmitCertificate(var lpCertificate: TWinCertificate): WINBOOL;stdcall; external 'imaghlp' name 'WinSubmitCertificate'; - #function WinVerifyTrust(wnd: HWND; const ActionID: TGUID; ActionData: pointer): Longint;stdcall; external 'imaghlp' name 'WinVerifyTrust'; -proc WNetAddConnection2*(lpNetResource: var TNetResource, + #function WinVerifyTrust(wnd: HWND; const ActionID: GUID; ActionData: pointer): Longint;stdcall; external 'imaghlp' name 'WinVerifyTrust'; +proc WNetAddConnection2*(lpNetResource: var NetResource, lpPassword, lpUserName: cstring, dwFlags: DWORD): DWORD{. stdcall, dynlib: "mpr", importc: "WNetAddConnection2A".} -proc WNetAddConnection2A*(lpNetResource: var TNetResourceA, +proc WNetAddConnection2A*(lpNetResource: var NetResource, lpPassword, lpUserName: LPCSTR, dwFlags: DWORD): DWORD{. stdcall, dynlib: "mpr", importc: "WNetAddConnection2A".} - #function WNetAddConnection2W(var lpNetResource: TNetResourceW; lpPassword, lpUserName: LPWSTR; dwFlags: DWORD): DWORD; stdcall; external 'mpr' name 'WNetAddConnection2W'; -proc WNetAddConnection3*(hwndOwner: HWND, lpNetResource: var TNetResource, + #function WNetAddConnection2W(var lpNetResource: NetResourceW; lpPassword, lpUserName: LPWSTR; dwFlags: DWORD): DWORD; stdcall; external 'mpr' name 'WNetAddConnection2W'; +proc WNetAddConnection3*(hwndOwner: HWND, lpNetResource: var NetResource, lpPassword, lpUserName: cstring, dwFlags: DWORD): DWORD{. stdcall, dynlib: "mpr", importc: "WNetAddConnection3A".} -proc WNetAddConnection3A*(hwndOwner: HWND, lpNetResource: var TNetResourceA, +proc WNetAddConnection3A*(hwndOwner: HWND, lpNetResource: var NetResource, lpPassword, lpUserName: LPCSTR, dwFlags: DWORD): DWORD{. stdcall, dynlib: "mpr", importc: "WNetAddConnection3A".} - #function WNetAddConnection3W(hwndOwner: HWND; var lpNetResource: TNetResourceW; lpPassword, lpUserName: LPWSTR; dwFlags: DWORD): DWORD; stdcall; external 'mpr' name 'WNetAddConnection3W'; -proc WNetConnectionDialog1*(lpConnDlgStruct: var TConnectDlgStruct): DWORD{. + #function WNetAddConnection3W(hwndOwner: HWND; var lpNetResource: NetResourceW; lpPassword, lpUserName: LPWSTR; dwFlags: DWORD): DWORD; stdcall; external 'mpr' name 'WNetAddConnection3W'; +proc WNetConnectionDialog1*(lpConnDlgStruct: var ConnectDlgStruct): DWORD{. stdcall, dynlib: "mpr", importc: "WNetConnectionDialog1A".} -proc WNetConnectionDialog1A*(lpConnDlgStruct: var TConnectDlgStruct): DWORD{. +proc WNetConnectionDialog1A*(lpConnDlgStruct: var ConnectDlgStruct): DWORD{. stdcall, dynlib: "mpr", importc: "WNetConnectionDialog1A".} - #function WNetConnectionDialog1W(var lpConnDlgStruct: TConnectDlgStruct): DWORD; stdcall; external 'mpr' name 'WNetConnectionDialog1W'; -proc WNetDisconnectDialog1*(lpConnDlgStruct: var TDiscDlgStruct): DWORD{. + #function WNetConnectionDialog1W(var lpConnDlgStruct: ConnectDlgStruct): DWORD; stdcall; external 'mpr' name 'WNetConnectionDialog1W'; +proc WNetDisconnectDialog1*(lpConnDlgStruct: var DiscDlgStruct): DWORD{. stdcall, dynlib: "mpr", importc: "WNetDisconnectDialog1A".} -proc WNetDisconnectDialog1A*(lpConnDlgStruct: var TDiscDlgStructA): DWORD{. +proc WNetDisconnectDialog1A*(lpConnDlgStruct: var DiscDlgStruct): DWORD{. stdcall, dynlib: "mpr", importc: "WNetDisconnectDialog1A".} - #function WNetDisconnectDialog1W(var lpConnDlgStruct: TDiscDlgStructW): DWORD; stdcall; external 'mpr' name 'WNetDisconnectDialog1W'; -proc WNetEnumResource*(hEnum: THandle, lpcCount: var DWORD, lpBuffer: pointer, + #function WNetDisconnectDialog1W(var lpConnDlgStruct: DiscDlgStructW): DWORD; stdcall; external 'mpr' name 'WNetDisconnectDialog1W'; +proc WNetEnumResource*(hEnum: Handle, lpcCount: var DWORD, lpBuffer: pointer, lpBufferSize: var DWORD): DWORD{.stdcall, dynlib: "mpr", importc: "WNetEnumResourceA".} -proc WNetEnumResourceA*(hEnum: THandle, lpcCount: var DWORD, lpBuffer: pointer, +proc WNetEnumResourceA*(hEnum: Handle, lpcCount: var DWORD, lpBuffer: pointer, lpBufferSize: var DWORD): DWORD{.stdcall, dynlib: "mpr", importc: "WNetEnumResourceA".} -proc WNetEnumResourceW*(hEnum: THandle, lpcCount: var DWORD, lpBuffer: pointer, +proc WNetEnumResourceW*(hEnum: Handle, lpcCount: var DWORD, lpBuffer: pointer, lpBufferSize: var DWORD): DWORD{.stdcall, dynlib: "mpr", importc: "WNetEnumResourceW".} proc WNetGetConnection*(lpLocalName: cstring, lpRemoteName: cstring, @@ -22584,13 +22318,13 @@ proc WNetGetLastErrorW*(lpError: var DWORD, lpErrorBuf: LPWSTR, nNameBufSize: DWORD): DWORD{.stdcall, dynlib: "mpr", importc: "WNetGetLastErrorW".} proc WNetGetNetworkInformation*(lpProvider: cstring, - lpNetInfoStruct: var TNetInfoStruct): DWORD{. + lpNetInfoStruct: var NetInfoStruct): DWORD{. stdcall, dynlib: "mpr", importc: "WNetGetNetworkInformationA".} proc WNetGetNetworkInformationA*(lpProvider: LPCSTR, - lpNetInfoStruct: var TNetInfoStruct): DWORD{. + lpNetInfoStruct: var NetInfoStruct): DWORD{. stdcall, dynlib: "mpr", importc: "WNetGetNetworkInformationA".} proc WNetGetNetworkInformationW*(lpProvider: LPWSTR, - lpNetInfoStruct: var TNetInfoStruct): DWORD{. + lpNetInfoStruct: var NetInfoStruct): DWORD{. stdcall, dynlib: "mpr", importc: "WNetGetNetworkInformationW".} proc WNetGetProviderName*(dwNetType: DWORD, lpProviderName: cstring, lpBufferSize: var DWORD): DWORD{.stdcall, @@ -22624,77 +22358,77 @@ proc WNetGetUserA*(lpName: LPCSTR, lpUserName: LPCSTR, lpnLength: var DWORD): DW proc WNetGetUserW*(lpName: LPWSTR, lpUserName: LPWSTR, lpnLength: var DWORD): DWORD{. stdcall, dynlib: "mpr", importc: "WNetGetUserW".} proc WNetOpenEnum*(dwScope, dwType, dwUsage: DWORD, lpNetResource: PNetResource, - lphEnum: var THandle): DWORD{.stdcall, dynlib: "mpr", + lphEnum: var Handle): DWORD{.stdcall, dynlib: "mpr", importc: "WNetOpenEnumA".} proc WNetOpenEnumA*(dwScope, dwType, dwUsage: DWORD, - lpNetResource: PNetResourceA, lphEnum: var THandle): DWORD{. + lpNetResource: PNetResourceA, lphEnum: var Handle): DWORD{. stdcall, dynlib: "mpr", importc: "WNetOpenEnumA".} - #function WNetOpenEnumW(dwScope, dwType, dwUsage: DWORD; lpNetResource: PNetResourceW; var lphEnum: THandle): DWORD; stdcall; external 'mpr' name 'WNetOpenEnumW'; -proc WNetUseConnection*(hwndOwner: HWND, lpNetResource: var TNetResource, + #function WNetOpenEnumW(dwScope, dwType, dwUsage: DWORD; lpNetResource: PNetResourceW; var lphEnum: Handle): DWORD; stdcall; external 'mpr' name 'WNetOpenEnumW'; +proc WNetUseConnection*(hwndOwner: HWND, lpNetResource: var NetResource, lpUserID: cstring, lpPassword: cstring, dwFlags: DWORD, lpAccessName: cstring, lpBufferSize: var DWORD, lpResult: var DWORD): DWORD{.stdcall, dynlib: "mpr", importc: "WNetUseConnectionA".} -proc WNetUseConnectionA*(hwndOwner: HWND, lpNetResource: var TNetResourceA, +proc WNetUseConnectionA*(hwndOwner: HWND, lpNetResource: var NetResource, lpUserID: LPCSTR, lpPassword: LPCSTR, dwFlags: DWORD, lpAccessName: LPCSTR, lpBufferSize: var DWORD, lpResult: var DWORD): DWORD{.stdcall, dynlib: "mpr", importc: "WNetUseConnectionA".} - #function WNetUseConnectionW(hwndOwner: HWND; var lpNetResource: TNetResourceW; lpUserID: LPWSTR; lpPassword: LPWSTR; dwFlags: DWORD; lpAccessName: LPWSTR; var lpBufferSize: DWORD; var lpResult: DWORD): DWORD; stdcall; external 'mpr' name 'WNetUseConnectionW'; -proc WriteConsole*(hConsoleOutput: THandle, lpBuffer: pointer, + #function WNetUseConnectionW(hwndOwner: HWND; var lpNetResource: NetResourceW; lpUserID: LPWSTR; lpPassword: LPWSTR; dwFlags: DWORD; lpAccessName: LPWSTR; var lpBufferSize: DWORD; var lpResult: DWORD): DWORD; stdcall; external 'mpr' name 'WNetUseConnectionW'; +proc WriteConsole*(hConsoleOutput: Handle, lpBuffer: pointer, nNumberOfCharsToWrite: DWORD, lpNumberOfCharsWritten: var DWORD, lpReserved: pointer): WINBOOL{. stdcall, dynlib: "kernel32", importc: "WriteConsoleA".} -proc WriteConsoleA*(hConsoleOutput: THandle, lpBuffer: pointer, +proc WriteConsoleA*(hConsoleOutput: Handle, lpBuffer: pointer, nNumberOfCharsToWrite: DWORD, lpNumberOfCharsWritten: var DWORD, lpReserved: pointer): WINBOOL{. stdcall, dynlib: "kernel32", importc: "WriteConsoleA".} -proc WriteConsoleInput*(hConsoleInput: THandle, lpBuffer: TInputRecord, +proc WriteConsoleInput*(hConsoleInput: Handle, lpBuffer: InputRecord, nLength: DWORD, lpNumberOfEventsWritten: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "WriteConsoleInputA".} -proc WriteConsoleInputA*(hConsoleInput: THandle, lpBuffer: TInputRecord, +proc WriteConsoleInputA*(hConsoleInput: Handle, lpBuffer: InputRecord, nLength: DWORD, lpNumberOfEventsWritten: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "WriteConsoleInputA".} -proc WriteConsoleInputW*(hConsoleInput: THandle, lpBuffer: TInputRecord, +proc WriteConsoleInputW*(hConsoleInput: Handle, lpBuffer: InputRecord, nLength: DWORD, lpNumberOfEventsWritten: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "WriteConsoleInputW".} -proc WriteConsoleOutput*(hConsoleOutput: THandle, lpBuffer: pointer, - dwBufferSize, dwBufferCoord: TCoord, - lpWriteRegion: var TSmallRect): WINBOOL{.stdcall, +proc WriteConsoleOutput*(hConsoleOutput: Handle, lpBuffer: pointer, + dwBufferSize, dwBufferCoord: Coord, + lpWriteRegion: var SmallRect): WINBOOL{.stdcall, dynlib: "kernel32", importc: "WriteConsoleOutputA".} -proc WriteConsoleOutputA*(hConsoleOutput: THandle, lpBuffer: pointer, - dwBufferSize, dwBufferCoord: TCoord, - lpWriteRegion: var TSmallRect): WINBOOL{.stdcall, +proc WriteConsoleOutputA*(hConsoleOutput: Handle, lpBuffer: pointer, + dwBufferSize, dwBufferCoord: Coord, + lpWriteRegion: var SmallRect): WINBOOL{.stdcall, dynlib: "kernel32", importc: "WriteConsoleOutputA".} -proc WriteConsoleOutputAttribute*(hConsoleOutput: THandle, lpAttribute: pointer, - nLength: DWORD, dwWriteCoord: TCoord, +proc WriteConsoleOutputAttribute*(hConsoleOutput: Handle, lpAttribute: pointer, + nLength: DWORD, dwWriteCoord: Coord, lpNumberOfAttrsWritten: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "WriteConsoleOutputAttribute".} -proc WriteConsoleOutputCharacter*(hConsoleOutput: THandle, lpCharacter: cstring, - nLength: DWORD, dwWriteCoord: TCoord, +proc WriteConsoleOutputCharacter*(hConsoleOutput: Handle, lpCharacter: cstring, + nLength: DWORD, dwWriteCoord: Coord, lpNumberOfCharsWritten: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "WriteConsoleOutputCharacterA".} -proc WriteConsoleOutputCharacterA*(hConsoleOutput: THandle, lpCharacter: LPCSTR, - nLength: DWORD, dwWriteCoord: TCoord, +proc WriteConsoleOutputCharacterA*(hConsoleOutput: Handle, lpCharacter: LPCSTR, + nLength: DWORD, dwWriteCoord: Coord, lpNumberOfCharsWritten: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "WriteConsoleOutputCharacterA".} -proc WriteConsoleOutputCharacterW*(hConsoleOutput: THandle, lpCharacter: LPWSTR, - nLength: DWORD, dwWriteCoord: TCoord, +proc WriteConsoleOutputCharacterW*(hConsoleOutput: Handle, lpCharacter: LPWSTR, + nLength: DWORD, dwWriteCoord: Coord, lpNumberOfCharsWritten: var DWORD): WINBOOL{. stdcall, dynlib: "kernel32", importc: "WriteConsoleOutputCharacterW".} -proc WriteConsoleOutputW*(hConsoleOutput: THandle, lpBuffer: pointer, - dwBufferSize, dwBufferCoord: TCoord, - lpWriteRegion: var TSmallRect): WINBOOL{.stdcall, +proc WriteConsoleOutputW*(hConsoleOutput: Handle, lpBuffer: pointer, + dwBufferSize, dwBufferCoord: Coord, + lpWriteRegion: var SmallRect): WINBOOL{.stdcall, dynlib: "kernel32", importc: "WriteConsoleOutputW".} -proc WriteConsoleW*(hConsoleOutput: THandle, lpBuffer: pointer, +proc WriteConsoleW*(hConsoleOutput: Handle, lpBuffer: pointer, nNumberOfCharsToWrite: DWORD, lpNumberOfCharsWritten: var DWORD, lpReserved: pointer): WINBOOL{. stdcall, dynlib: "kernel32", importc: "WriteConsoleW".} -proc WriteFile*(hFile: THandle, Buffer: pointer, nNumberOfBytesToWrite: DWORD, +proc WriteFile*(hFile: Handle, Buffer: pointer, nNumberOfBytesToWrite: DWORD, lpNumberOfBytesWritten: var DWORD, lpOverlapped: POverlapped): WINBOOL{. stdcall, dynlib: "kernel32", importc: "WriteFile".} -proc WriteFileEx*(hFile: THandle, lpBuffer: pointer, - nNumberOfBytesToWrite: DWORD, lpOverlapped: TOverlapped, +proc WriteFileEx*(hFile: Handle, lpBuffer: pointer, + nNumberOfBytesToWrite: DWORD, lpOverlapped: Overlapped, lpCompletionRoutine: FARPROC): WINBOOL{.stdcall, dynlib: "kernel32", importc: "WriteFileEx".} proc WritePrivateProfileStructA*(lpszSection, lpszKey: LPCSTR, lpStruct: LPVOID, @@ -22707,7 +22441,7 @@ proc WritePrivateProfileStructW*(lpszSection, lpszKey: LPCWSTR, proc WritePrivateProfileStruct*(lpszSection, lpszKey: LPCTSTR, lpStruct: LPVOID, uSizeStruct: WINUINT, szFile: LPCTSTR): WINBOOL{. stdcall, dynlib: "kernel32", importc: "WritePrivateProfileStructA".} -proc WriteProcessMemory*(hProcess: THandle, lpBaseAddress: pointer, +proc WriteProcessMemory*(hProcess: Handle, lpBaseAddress: pointer, lpBuffer: pointer, nSize: DWORD, lpNumberOfBytesWritten: var DWORD): WINBOOL{.stdcall, dynlib: "kernel32", importc: "WriteProcessMemory".} diff --git a/lib/windows/winlean.nim b/lib/windows/winlean.nim index 584f7cf48..9f04bab35 100644 --- a/lib/windows/winlean.nim +++ b/lib/windows/winlean.nim @@ -10,11 +10,13 @@ ## This module implements a small wrapper for some needed Win API procedures, ## so that the Nim compiler does not depend on the huge Windows module. +{.deadCodeElim:on.} + const useWinUnicode* = not defined(useWinAnsi) type - THandle* = int + Handle* = int LONG* = int32 ULONG* = int PULONG* = ptr int @@ -22,15 +24,15 @@ type DWORD* = int32 PDWORD* = ptr DWORD LPINT* = ptr int32 - HDC* = THandle - HGLRC* = THandle + HDC* = Handle + HGLRC* = Handle - TSECURITY_ATTRIBUTES* {.final, pure.} = object + SECURITY_ATTRIBUTES* {.final, pure.} = object nLength*: int32 lpSecurityDescriptor*: pointer bInheritHandle*: WINBOOL - - TSTARTUPINFO* {.final, pure.} = object + + STARTUPINFO* {.final, pure.} = object cb*: int32 lpReserved*: cstring lpDesktop*: cstring @@ -46,25 +48,25 @@ type wShowWindow*: int16 cbReserved2*: int16 lpReserved2*: pointer - hStdInput*: THandle - hStdOutput*: THandle - hStdError*: THandle + hStdInput*: Handle + hStdOutput*: Handle + hStdError*: Handle - TPROCESS_INFORMATION* {.final, pure.} = object - hProcess*: THandle - hThread*: THandle + PROCESS_INFORMATION* {.final, pure.} = object + hProcess*: Handle + hThread*: Handle dwProcessId*: int32 dwThreadId*: int32 - TFILETIME* {.final, pure.} = object ## CANNOT BE int64 BECAUSE OF ALIGNMENT + FILETIME* {.final, pure.} = object ## CANNOT BE int64 BECAUSE OF ALIGNMENT dwLowDateTime*: DWORD dwHighDateTime*: DWORD - - TBY_HANDLE_FILE_INFORMATION* {.final, pure.} = object + + BY_HANDLE_FILE_INFORMATION* {.final, pure.} = object dwFileAttributes*: DWORD - ftCreationTime*: TFILETIME - ftLastAccessTime*: TFILETIME - ftLastWriteTime*: TFILETIME + ftCreationTime*: FILETIME + ftLastAccessTime*: FILETIME + ftLastWriteTime*: FILETIME dwVolumeSerialNumber*: DWORD nFileSizeHigh*: DWORD nFileSizeLow*: DWORD @@ -72,10 +74,16 @@ type nFileIndexHigh*: DWORD nFileIndexLow*: DWORD +{.deprecated: [THandle: Handle, TSECURITY_ATTRIBUTES: SECURITY_ATTRIBUTES, + TSTARTUPINFO: STARTUPINFO, TPROCESS_INFORMATION: PROCESS_INFORMATION, + TFILETIME: FILETIME, TBY_HANDLE_FILE_INFORMATION: BY_HANDLE_FILE_INFORMATION].} + when useWinUnicode: - type TWinChar* = TUtf16Char + type WinChar* = Utf16Char + {.deprecated: [TWinChar: WinChar].} else: - type TWinChar* = char + type WinChar* = char + {.deprecated: [TWinChar: WinChar].} const STARTF_USESHOWWINDOW* = 1'i32 @@ -94,72 +102,72 @@ const STD_ERROR_HANDLE* = -12'i32 DETACHED_PROCESS* = 8'i32 - + SW_SHOWNORMAL* = 1'i32 - INVALID_HANDLE_VALUE* = THandle(-1) - + INVALID_HANDLE_VALUE* = Handle(-1) + CREATE_UNICODE_ENVIRONMENT* = 1024'i32 -proc closeHandle*(hObject: THandle): WINBOOL {.stdcall, dynlib: "kernel32", +proc closeHandle*(hObject: Handle): WINBOOL {.stdcall, dynlib: "kernel32", importc: "CloseHandle".} - -proc readFile*(hFile: THandle, Buffer: pointer, nNumberOfBytesToRead: int32, + +proc readFile*(hFile: Handle, Buffer: pointer, nNumberOfBytesToRead: int32, lpNumberOfBytesRead: ptr int32, lpOverlapped: pointer): WINBOOL{. stdcall, dynlib: "kernel32", importc: "ReadFile".} - -proc writeFile*(hFile: THandle, Buffer: pointer, nNumberOfBytesToWrite: int32, - lpNumberOfBytesWritten: ptr int32, + +proc writeFile*(hFile: Handle, Buffer: pointer, nNumberOfBytesToWrite: int32, + lpNumberOfBytesWritten: ptr int32, lpOverlapped: pointer): WINBOOL{. stdcall, dynlib: "kernel32", importc: "WriteFile".} -proc createPipe*(hReadPipe, hWritePipe: var THandle, - lpPipeAttributes: var TSECURITY_ATTRIBUTES, +proc createPipe*(hReadPipe, hWritePipe: var Handle, + lpPipeAttributes: var SECURITY_ATTRIBUTES, nSize: int32): WINBOOL{. stdcall, dynlib: "kernel32", importc: "CreatePipe".} when useWinUnicode: proc createProcessW*(lpApplicationName, lpCommandLine: WideCString, - lpProcessAttributes: ptr TSECURITY_ATTRIBUTES, - lpThreadAttributes: ptr TSECURITY_ATTRIBUTES, + lpProcessAttributes: ptr SECURITY_ATTRIBUTES, + lpThreadAttributes: ptr SECURITY_ATTRIBUTES, bInheritHandles: WINBOOL, dwCreationFlags: int32, lpEnvironment, lpCurrentDirectory: WideCString, - lpStartupInfo: var TSTARTUPINFO, - lpProcessInformation: var TPROCESS_INFORMATION): WINBOOL{. + lpStartupInfo: var STARTUPINFO, + lpProcessInformation: var PROCESS_INFORMATION): WINBOOL{. stdcall, dynlib: "kernel32", importc: "CreateProcessW".} else: proc createProcessA*(lpApplicationName, lpCommandLine: cstring, - lpProcessAttributes: ptr TSECURITY_ATTRIBUTES, - lpThreadAttributes: ptr TSECURITY_ATTRIBUTES, + lpProcessAttributes: ptr SECURITY_ATTRIBUTES, + lpThreadAttributes: ptr SECURITY_ATTRIBUTES, bInheritHandles: WINBOOL, dwCreationFlags: int32, lpEnvironment: pointer, lpCurrentDirectory: cstring, - lpStartupInfo: var TSTARTUPINFO, - lpProcessInformation: var TPROCESS_INFORMATION): WINBOOL{. + lpStartupInfo: var STARTUPINFO, + lpProcessInformation: var PROCESS_INFORMATION): WINBOOL{. stdcall, dynlib: "kernel32", importc: "CreateProcessA".} -proc suspendThread*(hThread: THandle): int32 {.stdcall, dynlib: "kernel32", +proc suspendThread*(hThread: Handle): int32 {.stdcall, dynlib: "kernel32", importc: "SuspendThread".} -proc resumeThread*(hThread: THandle): int32 {.stdcall, dynlib: "kernel32", +proc resumeThread*(hThread: Handle): int32 {.stdcall, dynlib: "kernel32", importc: "ResumeThread".} -proc waitForSingleObject*(hHandle: THandle, dwMilliseconds: int32): int32 {. +proc waitForSingleObject*(hHandle: Handle, dwMilliseconds: int32): int32 {. stdcall, dynlib: "kernel32", importc: "WaitForSingleObject".} -proc terminateProcess*(hProcess: THandle, uExitCode: int): WINBOOL {.stdcall, +proc terminateProcess*(hProcess: Handle, uExitCode: int): WINBOOL {.stdcall, dynlib: "kernel32", importc: "TerminateProcess".} -proc getExitCodeProcess*(hProcess: THandle, lpExitCode: var int32): WINBOOL {. +proc getExitCodeProcess*(hProcess: Handle, lpExitCode: var int32): WINBOOL {. stdcall, dynlib: "kernel32", importc: "GetExitCodeProcess".} -proc getStdHandle*(nStdHandle: int32): THandle {.stdcall, dynlib: "kernel32", +proc getStdHandle*(nStdHandle: int32): Handle {.stdcall, dynlib: "kernel32", importc: "GetStdHandle".} -proc setStdHandle*(nStdHandle: int32, hHandle: THandle): WINBOOL {.stdcall, +proc setStdHandle*(nStdHandle: int32, hHandle: Handle): WINBOOL {.stdcall, dynlib: "kernel32", importc: "SetStdHandle".} -proc flushFileBuffers*(hFile: THandle): WINBOOL {.stdcall, dynlib: "kernel32", +proc flushFileBuffers*(hFile: Handle): WINBOOL {.stdcall, dynlib: "kernel32", importc: "FlushFileBuffers".} -proc getLastError*(): int32 {.importc: "GetLastError", +proc getLastError*(): int32 {.importc: "GetLastError", stdcall, dynlib: "kernel32".} when useWinUnicode: @@ -179,7 +187,7 @@ proc localFree*(p: pointer) {. importc: "LocalFree", stdcall, dynlib: "kernel32".} when useWinUnicode: - proc getCurrentDirectoryW*(nBufferLength: int32, + proc getCurrentDirectoryW*(nBufferLength: int32, lpBuffer: WideCString): int32 {. importc: "GetCurrentDirectoryW", dynlib: "kernel32", stdcall.} proc setCurrentDirectoryW*(lpPathName: WideCString): int32 {. @@ -191,8 +199,8 @@ when useWinUnicode: proc setEnvironmentVariableW*(lpName, lpValue: WideCString): int32 {. stdcall, dynlib: "kernel32", importc: "SetEnvironmentVariableW".} - proc getModuleFileNameW*(handle: THandle, buf: WideCString, - size: int32): int32 {.importc: "GetModuleFileNameW", + proc getModuleFileNameW*(handle: Handle, buf: WideCString, + size: int32): int32 {.importc: "GetModuleFileNameW", dynlib: "kernel32", stdcall.} else: proc getCurrentDirectoryA*(nBufferLength: int32, lpBuffer: cstring): int32 {. @@ -206,7 +214,7 @@ else: proc setEnvironmentVariableA*(lpName, lpValue: cstring): int32 {. stdcall, dynlib: "kernel32", importc: "SetEnvironmentVariableA".} - proc getModuleFileNameA*(handle: THandle, buf: cstring, size: int32): int32 {. + proc getModuleFileNameA*(handle: Handle, buf: cstring, size: int32): int32 {. importc: "GetModuleFileNameA", dynlib: "kernel32", stdcall.} when useWinUnicode: @@ -237,46 +245,47 @@ const MAX_PATH* = 260 type - TWIN32_FIND_DATA* {.pure.} = object + WIN32_FIND_DATA* {.pure.} = object dwFileAttributes*: int32 - ftCreationTime*: TFILETIME - ftLastAccessTime*: TFILETIME - ftLastWriteTime*: TFILETIME + ftCreationTime*: FILETIME + ftLastAccessTime*: FILETIME + ftLastWriteTime*: FILETIME nFileSizeHigh*: int32 nFileSizeLow*: int32 dwReserved0: int32 dwReserved1: int32 - cFileName*: array[0..(MAX_PATH) - 1, TWinChar] - cAlternateFileName*: array[0..13, TWinChar] + cFileName*: array[0..(MAX_PATH) - 1, WinChar] + cAlternateFileName*: array[0..13, WinChar] +{.deprecated: [TWIN32_FIND_DATA: WIN32_FIND_DATA].} when useWinUnicode: proc findFirstFileW*(lpFileName: WideCString, - lpFindFileData: var TWIN32_FIND_DATA): THandle {. + lpFindFileData: var WIN32_FIND_DATA): Handle {. stdcall, dynlib: "kernel32", importc: "FindFirstFileW".} - proc findNextFileW*(hFindFile: THandle, - lpFindFileData: var TWIN32_FIND_DATA): int32 {. + proc findNextFileW*(hFindFile: Handle, + lpFindFileData: var WIN32_FIND_DATA): int32 {. stdcall, dynlib: "kernel32", importc: "FindNextFileW".} else: proc findFirstFileA*(lpFileName: cstring, - lpFindFileData: var TWIN32_FIND_DATA): THANDLE {. + lpFindFileData: var WIN32_FIND_DATA): THANDLE {. stdcall, dynlib: "kernel32", importc: "FindFirstFileA".} proc findNextFileA*(hFindFile: THANDLE, - lpFindFileData: var TWIN32_FIND_DATA): int32 {. + lpFindFileData: var WIN32_FIND_DATA): int32 {. stdcall, dynlib: "kernel32", importc: "FindNextFileA".} -proc findClose*(hFindFile: THandle) {.stdcall, dynlib: "kernel32", +proc findClose*(hFindFile: Handle) {.stdcall, dynlib: "kernel32", importc: "FindClose".} when useWinUnicode: proc getFullPathNameW*(lpFileName: WideCString, nBufferLength: int32, - lpBuffer: WideCString, + lpBuffer: WideCString, lpFilePart: var WideCString): int32 {. - stdcall, dynlib: "kernel32", + stdcall, dynlib: "kernel32", importc: "GetFullPathNameW".} proc getFileAttributesW*(lpFileName: WideCString): int32 {. - stdcall, dynlib: "kernel32", + stdcall, dynlib: "kernel32", importc: "GetFileAttributesW".} - proc setFileAttributesW*(lpFileName: WideCString, + proc setFileAttributesW*(lpFileName: WideCString, dwFileAttributes: int32): WINBOOL {. stdcall, dynlib: "kernel32", importc: "SetFileAttributesW".} @@ -299,12 +308,12 @@ when useWinUnicode: else: proc getFullPathNameA*(lpFileName: cstring, nBufferLength: int32, lpBuffer: cstring, lpFilePart: var cstring): int32 {. - stdcall, dynlib: "kernel32", + stdcall, dynlib: "kernel32", importc: "GetFullPathNameA".} proc getFileAttributesA*(lpFileName: cstring): int32 {. - stdcall, dynlib: "kernel32", + stdcall, dynlib: "kernel32", importc: "GetFileAttributesA".} - proc setFileAttributesA*(lpFileName: cstring, + proc setFileAttributesA*(lpFileName: cstring, dwFileAttributes: int32): WINBOOL {. stdcall, dynlib: "kernel32", importc: "SetFileAttributesA".} @@ -324,32 +333,32 @@ else: proc getCommandLineA*(): cstring {. importc: "GetCommandLineA", stdcall, dynlib: "kernel32".} -proc rdFileTime*(f: TFILETIME): int64 = +proc rdFileTime*(f: FILETIME): int64 = result = ze64(f.dwLowDateTime) or (ze64(f.dwHighDateTime) shl 32) -proc rdFileSize*(f: TWIN32_FIND_DATA): int64 = +proc rdFileSize*(f: WIN32_FIND_DATA): int64 = result = ze64(f.nFileSizeLow) or (ze64(f.nFileSizeHigh) shl 32) -proc getSystemTimeAsFileTime*(lpSystemTimeAsFileTime: var TFILETIME) {. +proc getSystemTimeAsFileTime*(lpSystemTimeAsFileTime: var FILETIME) {. importc: "GetSystemTimeAsFileTime", dynlib: "kernel32", stdcall.} proc sleep*(dwMilliseconds: int32){.stdcall, dynlib: "kernel32", importc: "Sleep".} when useWinUnicode: - proc shellExecuteW*(HWND: THandle, lpOperation, lpFile, + proc shellExecuteW*(HWND: Handle, lpOperation, lpFile, lpParameters, lpDirectory: WideCString, - nShowCmd: int32): THandle{. + nShowCmd: int32): Handle{. stdcall, dynlib: "shell32.dll", importc: "ShellExecuteW".} else: - proc shellExecuteA*(HWND: THandle, lpOperation, lpFile, + proc shellExecuteA*(HWND: Handle, lpOperation, lpFile, lpParameters, lpDirectory: cstring, - nShowCmd: int32): THandle{. + nShowCmd: int32): Handle{. stdcall, dynlib: "shell32.dll", importc: "ShellExecuteA".} - -proc getFileInformationByHandle*(hFile: THandle, - lpFileInformation: ptr TBY_HANDLE_FILE_INFORMATION): WINBOOL{. + +proc getFileInformationByHandle*(hFile: Handle, + lpFileInformation: ptr BY_HANDLE_FILE_INFORMATION): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetFileInformationByHandle".} const @@ -357,12 +366,12 @@ const WSASYS_STATUS_LEN* = 128 FD_SETSIZE* = 64 MSG_PEEK* = 2 - + INADDR_ANY* = 0 INADDR_LOOPBACK* = 0x7F000001 INADDR_BROADCAST* = -1 INADDR_NONE* = -1 - + ws2dll = "Ws2_32.dll" WSAEWOULDBLOCK* = 10035 @@ -372,35 +381,34 @@ proc wsaGetLastError*(): cint {.importc: "WSAGetLastError", dynlib: ws2dll.} type SocketHandle* = distinct int - {.deprecated: [TSocketHandle: SocketHandle].} type - WSAData* {.importc: "WSADATA", header: "winsock2.h".} = object + WSAData* {.importc: "WSADATA", header: "winsock2.h".} = object wVersion, wHighVersion: int16 szDescription: array[0..WSADESCRIPTION_LEN, char] szSystemStatus: array[0..WSASYS_STATUS_LEN, char] iMaxSockets, iMaxUdpDg: int16 lpVendorInfo: cstring - - SockAddr* {.importc: "SOCKADDR", header: "winsock2.h".} = object + + SockAddr* {.importc: "SOCKADDR", header: "winsock2.h".} = object sa_family*: int16 # unsigned sa_data: array[0..13, char] InAddr* {.importc: "IN_ADDR", header: "winsock2.h".} = object s_addr*: int32 # IP address - - Sockaddr_in* {.importc: "SOCKADDR_IN", + + Sockaddr_in* {.importc: "SOCKADDR_IN", header: "winsock2.h".} = object sin_family*: int16 sin_port*: int16 # unsigned sin_addr*: InAddr sin_zero*: array[0..7, char] - In6_addr* {.importc: "IN6_ADDR", header: "winsock2.h".} = object + In6_addr* {.importc: "IN6_ADDR", header: "winsock2.h".} = object bytes*: array[0..15, char] - Sockaddr_in6* {.importc: "SOCKADDR_IN6", + Sockaddr_in6* {.importc: "SOCKADDR_IN6", header: "winsock2.h".} = object sin6_family*: int16 sin6_port*: int16 # unsigned @@ -430,26 +438,25 @@ type h_addrtype*: int16 h_length*: int16 h_addr_list*: cstringArray - + TFdSet* = object fd_count*: cint # unsigned fd_array*: array[0..FD_SETSIZE-1, SocketHandle] - + Timeval* = object tv_sec*, tv_usec*: int32 - + AddrInfo* = object - ai_flags*: cint ## Input flags. - ai_family*: cint ## Address family of socket. - ai_socktype*: cint ## Socket type. - ai_protocol*: cint ## Protocol of socket. - ai_addrlen*: int ## Length of socket address. + ai_flags*: cint ## Input flags. + ai_family*: cint ## Address family of socket. + ai_socktype*: cint ## Socket type. + ai_protocol*: cint ## Protocol of socket. + ai_addrlen*: int ## Length of socket address. ai_canonname*: cstring ## Canonical name of service location. - ai_addr*: ptr SockAddr ## Socket address of socket. - ai_next*: ptr AddrInfo ## Pointer to next in list. + ai_addr*: ptr SockAddr ## Socket address of socket. + ai_next*: ptr AddrInfo ## Pointer to next in list. SockLen* = cuint - {.deprecated: [TSockaddr_in: Sockaddr_in, TAddrinfo: AddrInfo, TSockAddr: SockAddr, TSockLen: SockLen, TTimeval: Timeval, TWSADATA: WSADATA, Thostent: Hostent, TServent: Servent, @@ -501,7 +508,7 @@ proc bindSocket*(s: SocketHandle, name: ptr SockAddr, namelen: SockLen): cint {. stdcall, importc: "bind", dynlib: ws2dll.} proc connect*(s: SocketHandle, name: ptr SockAddr, namelen: SockLen): cint {. stdcall, importc: "connect", dynlib: ws2dll.} -proc getsockname*(s: SocketHandle, name: ptr SockAddr, +proc getsockname*(s: SocketHandle, name: ptr SockAddr, namelen: ptr SockLen): cint {. stdcall, importc: "getsockname", dynlib: ws2dll.} proc getsockopt*(s: SocketHandle, level, optname: cint, optval: pointer, @@ -515,7 +522,7 @@ proc listen*(s: SocketHandle, backlog: cint): cint {. stdcall, importc: "listen", dynlib: ws2dll.} proc recv*(s: SocketHandle, buf: pointer, len, flags: cint): cint {. stdcall, importc: "recv", dynlib: ws2dll.} -proc recvfrom*(s: SocketHandle, buf: cstring, len, flags: cint, +proc recvfrom*(s: SocketHandle, buf: cstring, len, flags: cint, fromm: ptr SockAddr, fromlen: ptr SockLen): cint {. stdcall, importc: "recvfrom", dynlib: ws2dll.} proc select*(nfds: cint, readfds, writefds, exceptfds: ptr TFdSet, @@ -529,22 +536,22 @@ proc sendto*(s: SocketHandle, buf: pointer, len, flags: cint, proc shutdown*(s: SocketHandle, how: cint): cint {. stdcall, importc: "shutdown", dynlib: ws2dll.} - + proc getnameinfo*(a1: ptr SockAddr, a2: SockLen, a3: cstring, a4: SockLen, a5: cstring, a6: SockLen, a7: cint): cint {. stdcall, importc: "getnameinfo", dynlib: ws2dll.} - + proc inet_addr*(cp: cstring): int32 {. - stdcall, importc: "inet_addr", dynlib: ws2dll.} + stdcall, importc: "inet_addr", dynlib: ws2dll.} proc WSAFDIsSet(s: SocketHandle, set: var TFdSet): bool {. stdcall, importc: "__WSAFDIsSet", dynlib: ws2dll, noSideEffect.} -proc FD_ISSET*(socket: SocketHandle, set: var TFdSet): cint = +proc FD_ISSET*(socket: SocketHandle, set: var TFdSet): cint = result = if WSAFDIsSet(socket, set): 1'i32 else: 0'i32 -proc FD_SET*(socket: SocketHandle, s: var TFdSet) = +proc FD_SET*(socket: SocketHandle, s: var TFdSet) = if s.fd_count < FD_SETSIZE: s.fd_array[int(s.fd_count)] = socket inc(s.fd_count) @@ -569,14 +576,15 @@ const MAXIMUM_WAIT_OBJECTS* = 0x00000040 type - TWOHandleArray* = array[0..MAXIMUM_WAIT_OBJECTS - 1, THandle] - PWOHandleArray* = ptr TWOHandleArray + WOHandleArray* = array[0..MAXIMUM_WAIT_OBJECTS - 1, Handle] + PWOHandleArray* = ptr WOHandleArray +{.deprecated: [TWOHandleArray: WOHandleArray].} proc waitForMultipleObjects*(nCount: DWORD, lpHandles: PWOHandleArray, bWaitAll: WINBOOL, dwMilliseconds: DWORD): DWORD{. stdcall, dynlib: "kernel32", importc: "WaitForMultipleObjects".} - - + + # for memfiles.nim: const @@ -586,7 +594,7 @@ const FILE_SHARE_READ* = 1'i32 FILE_SHARE_DELETE* = 4'i32 FILE_SHARE_WRITE* = 2'i32 - + CREATE_ALWAYS* = 2'i32 CREATE_NEW* = 1'i32 OPEN_EXISTING* = 3'i32 @@ -611,7 +619,7 @@ when useWinUnicode: proc createFileW*(lpFileName: WideCString, dwDesiredAccess, dwShareMode: DWORD, lpSecurityAttributes: pointer, dwCreationDisposition, dwFlagsAndAttributes: DWORD, - hTemplateFile: THandle): THandle {. + hTemplateFile: Handle): Handle {. stdcall, dynlib: "kernel32", importc: "CreateFileW".} proc deleteFileW*(pathName: WideCString): int32 {. importc: "DeleteFileW", dynlib: "kernel32", stdcall.} @@ -624,28 +632,28 @@ else: proc deleteFileA*(pathName: cstring): int32 {. importc: "DeleteFileA", dynlib: "kernel32", stdcall.} -proc setEndOfFile*(hFile: THandle): WINBOOL {.stdcall, dynlib: "kernel32", +proc setEndOfFile*(hFile: Handle): WINBOOL {.stdcall, dynlib: "kernel32", importc: "SetEndOfFile".} -proc setFilePointer*(hFile: THandle, lDistanceToMove: LONG, - lpDistanceToMoveHigh: ptr LONG, +proc setFilePointer*(hFile: Handle, lDistanceToMove: LONG, + lpDistanceToMoveHigh: ptr LONG, dwMoveMethod: DWORD): DWORD {. stdcall, dynlib: "kernel32", importc: "SetFilePointer".} -proc getFileSize*(hFile: THandle, lpFileSizeHigh: ptr DWORD): DWORD{.stdcall, +proc getFileSize*(hFile: Handle, lpFileSizeHigh: ptr DWORD): DWORD{.stdcall, dynlib: "kernel32", importc: "GetFileSize".} -proc mapViewOfFileEx*(hFileMappingObject: THandle, dwDesiredAccess: DWORD, +proc mapViewOfFileEx*(hFileMappingObject: Handle, dwDesiredAccess: DWORD, dwFileOffsetHigh, dwFileOffsetLow: DWORD, - dwNumberOfBytesToMap: DWORD, + dwNumberOfBytesToMap: DWORD, lpBaseAddress: pointer): pointer{. stdcall, dynlib: "kernel32", importc: "MapViewOfFileEx".} -proc createFileMappingW*(hFile: THandle, +proc createFileMappingW*(hFile: Handle, lpFileMappingAttributes: pointer, flProtect, dwMaximumSizeHigh: DWORD, - dwMaximumSizeLow: DWORD, - lpName: pointer): THandle {. + dwMaximumSizeLow: DWORD, + lpName: pointer): Handle {. stdcall, dynlib: "kernel32", importc: "CreateFileMappingW".} when not useWinUnicode: @@ -659,50 +667,52 @@ proc unmapViewOfFile*(lpBaseAddress: pointer): WINBOOL {.stdcall, dynlib: "kernel32", importc: "UnmapViewOfFile".} type - TOVERLAPPED* {.pure, inheritable.} = object + OVERLAPPED* {.pure, inheritable.} = object internal*: PULONG internalHigh*: PULONG offset*: DWORD offsetHigh*: DWORD - hEvent*: THandle + hEvent*: Handle - POVERLAPPED* = ptr TOVERLAPPED + POVERLAPPED* = ptr OVERLAPPED POVERLAPPED_COMPLETION_ROUTINE* = proc (para1: DWORD, para2: DWORD, para3: POVERLAPPED){.stdcall.} - TGUID* {.final, pure.} = object + GUID* {.final, pure.} = object D1*: int32 D2*: int16 D3*: int16 D4*: array [0..7, int8] +{.deprecated: [TOVERLAPPED: OVERLAPPED, TGUID: GUID].} const ERROR_IO_PENDING* = 997 # a.k.a WSA_IO_PENDING FILE_FLAG_OVERLAPPED* = 1073741824 WSAECONNABORTED* = 10053 + WSAEADDRINUSE* = 10048 WSAECONNRESET* = 10054 WSAEDISCON* = 10101 WSAENETRESET* = 10052 WSAETIMEDOUT* = 10060 ERROR_NETNAME_DELETED* = 64 -proc createIoCompletionPort*(FileHandle: THandle, ExistingCompletionPort: THandle, +proc createIoCompletionPort*(FileHandle: Handle, ExistingCompletionPort: Handle, CompletionKey: DWORD, - NumberOfConcurrentThreads: DWORD): THandle{.stdcall, + NumberOfConcurrentThreads: DWORD): Handle{.stdcall, dynlib: "kernel32", importc: "CreateIoCompletionPort".} -proc getQueuedCompletionStatus*(CompletionPort: THandle, +proc getQueuedCompletionStatus*(CompletionPort: Handle, lpNumberOfBytesTransferred: PDWORD, lpCompletionKey: PULONG, lpOverlapped: ptr POVERLAPPED, dwMilliseconds: DWORD): WINBOOL{.stdcall, dynlib: "kernel32", importc: "GetQueuedCompletionStatus".} -proc getOverlappedResult*(hFile: THandle, lpOverlapped: TOVERLAPPED, +proc getOverlappedResult*(hFile: Handle, lpOverlapped: OVERLAPPED, lpNumberOfBytesTransferred: var DWORD, bWait: WINBOOL): WINBOOL{. stdcall, dynlib: "kernel32", importc: "GetOverlappedResult".} -const +const IOC_OUT* = 0x40000000 IOC_IN* = 0x80000000 IOC_WS2* = 0x08000000 @@ -715,17 +725,17 @@ const SO_UPDATE_ACCEPT_CONTEXT* = 0x700B var - WSAID_CONNECTEX*: TGUID = TGUID(D1: 0x25a207b9, D2: 0xddf3'i16, D3: 0x4660, D4: [ + WSAID_CONNECTEX*: GUID = GUID(D1: 0x25a207b9, D2: 0xddf3'i16, D3: 0x4660, D4: [ 0x8e'i8, 0xe9'i8, 0x76'i8, 0xe5'i8, 0x8c'i8, 0x74'i8, 0x06'i8, 0x3e'i8]) - WSAID_ACCEPTEX*: TGUID = TGUID(D1: 0xb5367df1'i32, D2: 0xcbac'i16, D3: 0x11cf, D4: [ + WSAID_ACCEPTEX*: GUID = GUID(D1: 0xb5367df1'i32, D2: 0xcbac'i16, D3: 0x11cf, D4: [ 0x95'i8, 0xca'i8, 0x00'i8, 0x80'i8, 0x5f'i8, 0x48'i8, 0xa1'i8, 0x92'i8]) - WSAID_GETACCEPTEXSOCKADDRS*: TGUID = TGUID(D1: 0xb5367df2'i32, D2: 0xcbac'i16, D3: 0x11cf, D4: [ + WSAID_GETACCEPTEXSOCKADDRS*: GUID = GUID(D1: 0xb5367df2'i32, D2: 0xcbac'i16, D3: 0x11cf, D4: [ 0x95'i8, 0xca'i8, 0x00'i8, 0x80'i8, 0x5f'i8, 0x48'i8, 0xa1'i8, 0x92'i8]) proc WSAIoctl*(s: SocketHandle, dwIoControlCode: DWORD, lpvInBuffer: pointer, cbInBuffer: DWORD, lpvOutBuffer: pointer, cbOutBuffer: DWORD, lpcbBytesReturned: PDWORD, lpOverlapped: POVERLAPPED, - lpCompletionRoutine: POVERLAPPED_COMPLETION_ROUTINE): cint + lpCompletionRoutine: POVERLAPPED_COMPLETION_ROUTINE): cint {.stdcall, importc: "WSAIoctl", dynlib: "Ws2_32.dll".} type @@ -743,13 +753,13 @@ proc WSASend*(s: SocketHandle, buf: ptr TWSABuf, bufCount: DWORD, completionProc: POVERLAPPED_COMPLETION_ROUTINE): cint {. stdcall, importc: "WSASend", dynlib: "Ws2_32.dll".} -proc get_osfhandle*(fd:FileHandle): THandle {. +proc get_osfhandle*(fd:FileHandle): Handle {. importc: "_get_osfhandle", header:"<io.h>".} -proc getSystemTimes*(lpIdleTime, lpKernelTime, - lpUserTime: var TFILETIME): WINBOOL {.stdcall, +proc getSystemTimes*(lpIdleTime, lpKernelTime, + lpUserTime: var FILETIME): WINBOOL {.stdcall, dynlib: "kernel32", importc: "GetSystemTimes".} -proc getProcessTimes*(hProcess: THandle; lpCreationTime, lpExitTime, - lpKernelTime, lpUserTime: var TFILETIME): WINBOOL {.stdcall, +proc getProcessTimes*(hProcess: Handle; lpCreationTime, lpExitTime, + lpKernelTime, lpUserTime: var FILETIME): WINBOOL {.stdcall, dynlib: "kernel32", importc: "GetProcessTimes".} diff --git a/lib/wrappers/claro.nim b/lib/wrappers/claro.nim index 0fb0882bf..41956c28a 100644 --- a/lib/wrappers/claro.nim +++ b/lib/wrappers/claro.nim @@ -35,61 +35,62 @@ else: import cairo type - TNode* {.pure.} = object - next*: ptr TNode - prev*: ptr TNode # pointer to real structure + Node* {.pure.} = object + next*: ptr Node + prev*: ptr Node # pointer to real structure data*: pointer - TList* {.pure.} = object - head*: ptr TNode - tail*: ptr TNode + List* {.pure.} = object + head*: ptr Node + tail*: ptr Node count*: int32 - +{.deprecated: [TNode: Node, TList: List].} proc list_init*(){.cdecl, importc: "list_init", dynlib: clarodll.} -proc list_create*(list: ptr TList){.cdecl, importc: "list_create", +proc list_create*(list: ptr List){.cdecl, importc: "list_create", dynlib: clarodll.} -proc node_create*(): ptr TNode{.cdecl, importc: "node_create", +proc node_create*(): ptr Node{.cdecl, importc: "node_create", dynlib: clarodll.} -proc node_free*(n: ptr TNode){.cdecl, importc: "node_free", dynlib: clarodll.} -proc node_add*(data: pointer, n: ptr TNode, L: ptr TList){.cdecl, +proc node_free*(n: ptr Node){.cdecl, importc: "node_free", dynlib: clarodll.} +proc node_add*(data: pointer, n: ptr Node, L: ptr List){.cdecl, importc: "node_add", dynlib: clarodll.} -proc node_prepend*(data: pointer, n: ptr TNode, L: ptr TList){.cdecl, +proc node_prepend*(data: pointer, n: ptr Node, L: ptr List){.cdecl, importc: "node_prepend", dynlib: clarodll.} -proc node_del*(n: ptr TNode, L: ptr TList){.cdecl, importc: "node_del", +proc node_del*(n: ptr Node, L: ptr List){.cdecl, importc: "node_del", dynlib: clarodll.} -proc node_find*(data: pointer, L: ptr TList): ptr TNode{.cdecl, +proc node_find*(data: pointer, L: ptr List): ptr Node{.cdecl, importc: "node_find", dynlib: clarodll.} -proc node_move*(n: ptr TNode, oldlist: ptr TList, newlist: ptr TList){. +proc node_move*(n: ptr Node, oldlist: ptr List, newlist: ptr List){. cdecl, importc: "node_move", dynlib: clarodll.} type - TClaroObj*{.pure, inheritable.} = object + ClaroObj*{.pure, inheritable.} = object typ*: array[0..64 - 1, char] destroy_pending*: cint - event_handlers*: TList - children*: TList - parent*: ptr TClaroObj + event_handlers*: List + children*: List + parent*: ptr ClaroObj appdata*: pointer # !! this is for APPLICATION USE ONLY !! - TEvent*{.pure.} = object - obj*: ptr TClaroObj # the object which this event was sent to + Event*{.pure.} = object + obj*: ptr ClaroObj # the object which this event was sent to name*: array[0..64 - 1, char] handled*: cint arg_num*: cint # number of arguments format*: array[0..16 - 1, char] # format of the arguments sent arglist*: ptr pointer # list of args, as per format. - TEventFunc* = proc (obj: ptr TClaroObj, event: ptr TEvent){.cdecl.} - TEventIfaceFunc* = proc (obj: ptr TClaroObj, event: ptr TEvent, + EventFunc* = proc (obj: ptr ClaroObj, event: ptr Event){.cdecl.} + EventIfaceFunc* = proc (obj: ptr ClaroObj, event: ptr Event, data: pointer){.cdecl.} - TEventHandler*{.pure.} = object + EventHandler*{.pure.} = object typ*: array[0..32 - 1, char] data*: pointer - fun*: TEventFunc # the function that handles this event - + fun*: EventFunc # the function that handles this event +{.deprecated: [TEvent: Event, TEventFunc: EventFunc, TClaroObj: ClaroObj, + TEventIfaceFunc: EventIfaceFunc, TEventHandler: EventHandler].} -# #define event_handler(n) void n ( TClaroObj *object, event_t *event ) +# #define event_handler(n) void n ( ClaroObj *object, event_t *event ) #CLVEXP list_t object_list; proc object_init*(){.cdecl, importc: "object_init", dynlib: clarodll.} @@ -99,36 +100,36 @@ proc object_override_next_size*(size: cint){.cdecl, ## Overrides the size of next object to be created, providing the ## size is more than is requested by default. ## - ## `size` specifies the full size, which is greater than both TClaroObj + ## `size` specifies the full size, which is greater than both ClaroObj ## and the size that will be requested automatically. -proc event_get_arg_ptr*(e: ptr TEvent, arg: cint): pointer{.cdecl, +proc event_get_arg_ptr*(e: ptr Event, arg: cint): pointer{.cdecl, importc: "event_get_arg_ptr", dynlib: clarodll.} -proc event_get_arg_double*(e: ptr TEvent, arg: cint): cdouble{.cdecl, +proc event_get_arg_double*(e: ptr Event, arg: cint): cdouble{.cdecl, importc: "event_get_arg_double", dynlib: clarodll.} -proc event_get_arg_int*(e: ptr TEvent, arg: cint): cint{.cdecl, +proc event_get_arg_int*(e: ptr Event, arg: cint): cint{.cdecl, importc: "event_get_arg_int", dynlib: clarodll.} -proc object_create*(parent: ptr TClaroObj, size: int32, - typ: cstring): ptr TClaroObj{. +proc object_create*(parent: ptr ClaroObj, size: int32, + typ: cstring): ptr ClaroObj{. cdecl, importc: "object_create", dynlib: clarodll.} -proc object_destroy*(obj: ptr TClaroObj){.cdecl, importc: "object_destroy", +proc object_destroy*(obj: ptr ClaroObj){.cdecl, importc: "object_destroy", dynlib: clarodll.} -proc object_set_parent*(obj: ptr TClaroObj, parent: ptr TClaroObj){.cdecl, +proc object_set_parent*(obj: ptr ClaroObj, parent: ptr ClaroObj){.cdecl, importc: "object_set_parent", dynlib: clarodll.} -##define object_cmptype(o,t) (!strcmp(((TClaroObj *)o)->type,t)) +##define object_cmptype(o,t) (!strcmp(((ClaroObj *)o)->type,t)) # event functions -proc object_addhandler*(obj: ptr TClaroObj, event: cstring, - fun: TEventFunc){.cdecl, +proc object_addhandler*(obj: ptr ClaroObj, event: cstring, + fun: EventFunc){.cdecl, importc: "object_addhandler", dynlib: clarodll.} -proc object_addhandler_interface*(obj: ptr TClaroObj, event: cstring, - fun: TEventFunc, data: pointer){.cdecl, +proc object_addhandler_interface*(obj: ptr ClaroObj, event: cstring, + fun: EventFunc, data: pointer){.cdecl, importc: "object_addhandler_interface", dynlib: clarodll.} -proc event_send*(obj: ptr TClaroObj, event: cstring, fmt: cstring): cint{. +proc event_send*(obj: ptr ClaroObj, event: cstring, fmt: cstring): cint{. varargs, cdecl, importc: "event_send", dynlib: clarodll.} -proc event_get_name*(event: ptr TEvent): cstring{.cdecl, +proc event_get_name*(event: ptr Event): cstring{.cdecl, importc: "event_get_name", dynlib: clarodll.} proc claro_base_init(){.cdecl, importc: "claro_base_init", dynlib: clarodll.} proc claro_loop*(){.cdecl, importc: "claro_loop", dynlib: clarodll.} @@ -143,19 +144,19 @@ const cWidgetCustomDraw* = (1 shl 25) type - TBounds*{.pure.} = object + Bounds*{.pure.} = object x*: cint y*: cint w*: cint h*: cint - owner*: ptr TClaroObj - + owner*: ptr ClaroObj +{.deprecated: [TBounds: Bounds].} const cSizeRequestChanged* = 1 type - TFont*{.pure.} = object + Font*{.pure.} = object used*: cint face*: cstring size*: cint @@ -164,30 +165,31 @@ type decoration*: cint native*: pointer - TColor*{.pure.} = object + Color*{.pure.} = object used*: cint r*: cfloat g*: cfloat b*: cfloat a*: cfloat - TWidget* {.pure.} = object of TClaroObj - size_req*: ptr TBounds - size*: TBounds - size_ct*: TBounds + Widget* {.pure.} = object of ClaroObj + size_req*: ptr Bounds + size*: Bounds + size_ct*: Bounds supports_alpha*: cint size_flags*: cint flags*: cint visible*: cint notify_flags*: cint - font*: TFont + font*: Font native*: pointer # native widget ndata*: pointer # additional native data container*: pointer # native widget container (if not ->native) naddress*: array[0..3, pointer] # addressed for something # we override or need to remember - -proc clipboard_set_text*(w: ptr TWidget, text: cstring): cint{.cdecl, +{.deprecated: [TFont: Font, TColor: Color, TWidget: Widget].} + +proc clipboard_set_text*(w: ptr Widget, text: cstring): cint{.cdecl, importc: "clipboard_set_text", dynlib: clarodll.} ## Sets the (text) clipboard to the specified text value. ## @@ -207,7 +209,7 @@ const cFontDecorationUnderline* = 1 -proc widget_set_font*(widget: ptr TClaroObj, face: cstring, size: cint, +proc widget_set_font*(widget: ptr ClaroObj, face: cstring, size: cint, weight: cint, slant: cint, decoration: cint){.cdecl, importc: "widget_set_font", dynlib: clarodll.} ## Sets the font details of the specified widget. @@ -219,7 +221,7 @@ proc widget_set_font*(widget: ptr TClaroObj, face: cstring, size: cint, ## `slant` The sland of the font ## `decoration` The decoration of the font -proc widget_font_string_width*(widget: ptr TClaroObj, text: cstring, +proc widget_font_string_width*(widget: ptr ClaroObj, text: cstring, chars: cint): cint {. cdecl, importc: "widget_font_string_width", dynlib: clarodll.} ## Calculates the pixel width of the text in the widget's font. @@ -230,16 +232,16 @@ const CLARO_APPLICATION* = "claro.graphics" type - TImage* {.pure.} = object of TClaroObj + Image* {.pure.} = object of ClaroObj width*: cint height*: cint native*: pointer native2*: pointer native3*: pointer icon*: pointer +{.deprecated: [TImage: Image].} - -proc image_load*(parent: ptr TClaroObj, file: cstring): ptr TImage{.cdecl, +proc image_load*(parent: ptr ClaroObj, file: cstring): ptr Image{.cdecl, importc: "image_load", dynlib: clarodll.} ## Loads an image from a file and returns a new image object. ## @@ -249,8 +251,8 @@ proc image_load*(parent: ptr TClaroObj, file: cstring): ptr TImage{.cdecl, ## ## `Parent` object (usually the application's main window), can be nil. -proc image_load_inline_png*(parent: ptr TClaroObj, data: cstring, - len: cint): ptr TImage{.cdecl, +proc image_load_inline_png*(parent: ptr ClaroObj, data: cstring, + len: cint): ptr Image{.cdecl, importc: "image_load_inline_png", dynlib: clarodll.} ## Loads an image from inline data and returns a new image object. ## `Parent` object (usually the application's main window), can be nil. @@ -262,10 +264,11 @@ when true: else: # status icons are not supported on all platforms yet: type - TStatusIcon* {.pure.} = object of TClaroObj - icon*: ptr TImage + StatusIcon* {.pure.} = object of ClaroObj + icon*: ptr Image native*: pointer native2*: pointer + {.deprecated: [TStatusIcon: StatusIcon].} #* # \brief Creates a status icon @@ -277,8 +280,8 @@ else: # \return New status_icon_t object # - proc status_icon_create*(parent: ptr TClaroObj, icon: ptr TImage, - flags: cint): ptr TStatusIcon {. + proc status_icon_create*(parent: ptr ClaroObj, icon: ptr Image, + flags: cint): ptr StatusIcon {. cdecl, importc: "status_icon_create", dynlib: clarodll.} #* @@ -288,7 +291,7 @@ else: # \param image The image object for the icon # - proc status_icon_set_icon*(status: ptr TStatusIcon, icon: ptr TImage){.cdecl, + proc status_icon_set_icon*(status: ptr StatusIcon, icon: ptr Image){.cdecl, importc: "status_icon_set_icon", dynlib: clarodll.} #* @@ -298,7 +301,7 @@ else: # \param menu The menu object for the popup menu # - proc status_icon_set_menu*(status: ptr TStatusIcon, menu: ptr TClaroObj){.cdecl, + proc status_icon_set_menu*(status: ptr StatusIcon, menu: ptr ClaroObj){.cdecl, importc: "status_icon_set_menu", dynlib: clarodll.} #* # \brief sets the status icon's visibility @@ -307,7 +310,7 @@ else: # \param visible whether the status icon is visible or not # - proc status_icon_set_visible*(status: ptr TStatusIcon, visible: cint){.cdecl, + proc status_icon_set_visible*(status: ptr StatusIcon, visible: cint){.cdecl, importc: "status_icon_set_visible", dynlib: clarodll.} #* # \brief sets the status icon's tooltip @@ -316,7 +319,7 @@ else: # \param tooltip Tooltip string # - proc status_icon_set_tooltip*(status: ptr TStatusIcon, tooltip: cstring){.cdecl, + proc status_icon_set_tooltip*(status: ptr StatusIcon, tooltip: cstring){.cdecl, importc: "status_icon_set_tooltip", dynlib: clarodll.} #* @@ -325,7 +328,7 @@ else: # \param widget A widget # -proc widget_show*(widget: ptr TWidget){.cdecl, importc: "widget_show", +proc widget_show*(widget: ptr Widget){.cdecl, importc: "widget_show", dynlib: clarodll.} #* # \brief Makes the specified widget invisible. @@ -333,7 +336,7 @@ proc widget_show*(widget: ptr TWidget){.cdecl, importc: "widget_show", # \param widget A widget # -proc widget_hide*(widget: ptr TWidget){.cdecl, importc: "widget_hide", +proc widget_hide*(widget: ptr Widget){.cdecl, importc: "widget_hide", dynlib: clarodll.} #* # \brief Enables the widget, allowing focus @@ -341,7 +344,7 @@ proc widget_hide*(widget: ptr TWidget){.cdecl, importc: "widget_hide", # \param widget A widget # -proc widget_enable*(widget: ptr TWidget){.cdecl, importc: "widget_enable", +proc widget_enable*(widget: ptr Widget){.cdecl, importc: "widget_enable", dynlib: clarodll.} #* # \brief Disables the widget @@ -351,7 +354,7 @@ proc widget_enable*(widget: ptr TWidget){.cdecl, importc: "widget_enable", # \param widget A widget # -proc widget_disable*(widget: ptr TWidget){.cdecl, importc: "widget_disable", +proc widget_disable*(widget: ptr Widget){.cdecl, importc: "widget_disable", dynlib: clarodll.} #* # \brief Give focus to the specified widget @@ -359,7 +362,7 @@ proc widget_disable*(widget: ptr TWidget){.cdecl, importc: "widget_disable", # \param widget A widget # -proc widget_focus*(widget: ptr TWidget){.cdecl, importc: "widget_focus", +proc widget_focus*(widget: ptr Widget){.cdecl, importc: "widget_focus", dynlib: clarodll.} #* # \brief Closes a widget @@ -372,7 +375,7 @@ proc widget_focus*(widget: ptr TWidget){.cdecl, importc: "widget_focus", # \param widget A widget # -proc widget_close*(widget: ptr TWidget){.cdecl, importc: "widget_close", +proc widget_close*(widget: ptr Widget){.cdecl, importc: "widget_close", dynlib: clarodll.} #* # \brief Retrieve the screen offset of the specified widget. @@ -384,7 +387,7 @@ proc widget_close*(widget: ptr TWidget){.cdecl, importc: "widget_close", # \param dy Pointer to the location to place the Y position. # -proc widget_screen_offset*(widget: ptr TWidget, dx: ptr cint, dy: ptr cint){. +proc widget_screen_offset*(widget: ptr Widget, dx: ptr cint, dy: ptr cint){. cdecl, importc: "widget_screen_offset", dynlib: clarodll.} #* # \brief Sets the additional notify events that should be sent. @@ -397,16 +400,17 @@ proc widget_screen_offset*(widget: ptr TWidget, dx: ptr cint, dy: ptr cint){. # \param flags Any number of cWidgetNotify flags ORed together. # -proc widget_set_notify*(widget: ptr TWidget, flags: cint){.cdecl, +proc widget_set_notify*(widget: ptr Widget, flags: cint){.cdecl, importc: "widget_set_notify", dynlib: clarodll.} type - TCursorType* {.size: sizeof(cint).} = enum + CursorType* {.size: sizeof(cint).} = enum cCursorNormal = 0, cCursorTextEdit = 1, cCursorWait = 2, cCursorPoint = 3 +{.deprecated: [TCursorType: CursorType].} #* # \brief Sets the mouse cursor for the widget @@ -415,7 +419,7 @@ type # \param cursor A valid cCursor* value # -proc widget_set_cursor*(widget: ptr TWidget, cursor: TCursorType){.cdecl, +proc widget_set_cursor*(widget: ptr Widget, cursor: CursorType){.cdecl, importc: "widget_set_cursor", dynlib: clarodll.} #* @@ -426,7 +430,7 @@ proc widget_set_cursor*(widget: ptr TWidget, cursor: TCursorType){.cdecl, # \return The keycode of the key pressed. # -proc widget_get_notify_key*(widget: ptr TWidget, event: ptr TEvent): cint{. +proc widget_get_notify_key*(widget: ptr Widget, event: ptr Event): cint{. cdecl, importc: "widget_get_notify_key", dynlib: clarodll.} #* @@ -443,7 +447,7 @@ proc widget_get_notify_key*(widget: ptr TWidget, event: ptr TEvent): cint{. # \param h The new height # -proc bounds_set*(bounds: ptr TBounds, x: cint, y: cint, w: cint, h: cint){. +proc bounds_set*(bounds: ptr Bounds, x: cint, y: cint, w: cint, h: cint){. cdecl, importc: "bounds_set", dynlib: clarodll.} #* # \brief Create a new bounds object @@ -457,13 +461,13 @@ proc bounds_set*(bounds: ptr TBounds, x: cint, y: cint, w: cint, h: cint){. # \return A new bounds_t structure # -proc new_bounds*(x: cint, y: cint, w: cint, h: cint): ptr TBounds{.cdecl, +proc new_bounds*(x: cint, y: cint, w: cint, h: cint): ptr Bounds{.cdecl, importc: "new_bounds", dynlib: clarodll.} -proc get_req_bounds*(widget: ptr TWidget): ptr TBounds{.cdecl, +proc get_req_bounds*(widget: ptr Widget): ptr Bounds{.cdecl, importc: "get_req_bounds", dynlib: clarodll.} var - noBoundsVar: TBounds # set to all zero which is correct + noBoundsVar: Bounds # set to all zero which is correct template noBounds*: expr = (addr(bind noBoundsVar)) @@ -473,7 +477,7 @@ template noBounds*: expr = (addr(bind noBoundsVar)) # \param widget A widget # -proc widget_pre_init*(widget: ptr TWidget){.cdecl, importc: "widget_pre_init", +proc widget_pre_init*(widget: ptr Widget){.cdecl, importc: "widget_pre_init", dynlib: clarodll.} #* \internal # \brief Internal post-inititalisation hook @@ -481,7 +485,7 @@ proc widget_pre_init*(widget: ptr TWidget){.cdecl, importc: "widget_pre_init", # \param widget A widget # -proc widget_post_init*(widget: ptr TWidget){.cdecl, +proc widget_post_init*(widget: ptr Widget){.cdecl, importc: "widget_post_init", dynlib: clarodll.} #* \internal # \brief Internal resize event handler @@ -490,7 +494,7 @@ proc widget_post_init*(widget: ptr TWidget){.cdecl, # \param event An event resource # -proc widget_resized_handle*(obj: ptr TWidget, event: ptr TEvent){.cdecl, +proc widget_resized_handle*(obj: ptr Widget, event: ptr Event){.cdecl, importc: "widget_resized_handle", dynlib: clarodll.} # CLVEXP bounds_t no_bounds; #* \internal @@ -507,11 +511,12 @@ proc widget_resized_handle*(obj: ptr TWidget, event: ptr TEvent){.cdecl, # type - TcgraphicsCreateFunction* = proc (widget: ptr TWidget) {.cdecl.} + CgraphicsCreateFunction* = proc (widget: ptr Widget) {.cdecl.} +{.deprecated: [TcgraphicsCreateFunction: CgraphicsCreateFunction].} -proc newdefault*(parent: ptr TWidget, widget_size: int, - widget_name: cstring, size_req: ptr TBounds, flags: cint, - creator: TcgraphicsCreateFunction): ptr TWidget{.cdecl, +proc newdefault*(parent: ptr Widget, widget_size: int, + widget_name: cstring, size_req: ptr Bounds, flags: cint, + creator: CgraphicsCreateFunction): ptr Widget{.cdecl, importc: "default_widget_create", dynlib: clarodll.} #* \internal # \brief Retrieves the native container of the widget's children @@ -520,7 +525,7 @@ proc newdefault*(parent: ptr TWidget, widget_size: int, # \return A pointer to the native widget that will hold w's children # -proc widget_get_container*(widget: ptr TWidget): pointer{.cdecl, +proc widget_get_container*(widget: ptr Widget): pointer{.cdecl, importc: "widget_get_container", dynlib: clarodll.} #* \internal # \brief Sets the content size of the widget. @@ -531,7 +536,7 @@ proc widget_get_container*(widget: ptr TWidget): pointer{.cdecl, # \param event Whether to send a content_size event # -proc widget_set_content_size*(widget: ptr TWidget, w: cint, h: cint, +proc widget_set_content_size*(widget: ptr Widget, w: cint, h: cint, event: cint){.cdecl, importc: "widget_set_content_size", dynlib: clarodll.} #* \internal @@ -543,7 +548,7 @@ proc widget_set_content_size*(widget: ptr TWidget, w: cint, h: cint, # \param event Whether to send a resize event # -proc widget_set_size*(widget: ptr TWidget, w: cint, h: cint, event: cint){. +proc widget_set_size*(widget: ptr Widget, w: cint, h: cint, event: cint){. cdecl, importc: "widget_set_size", dynlib: clarodll.} #* \internal # \brief Sets the position of the widget's content area. @@ -554,7 +559,7 @@ proc widget_set_size*(widget: ptr TWidget, w: cint, h: cint, event: cint){. # \param event Whether to send a content_move event # -proc widget_set_content_position*(widget: ptr TWidget, x: cint, y: cint, +proc widget_set_content_position*(widget: ptr Widget, x: cint, y: cint, event: cint){.cdecl, importc: "widget_set_content_position", dynlib: clarodll.} #* \internal @@ -566,7 +571,7 @@ proc widget_set_content_position*(widget: ptr TWidget, x: cint, y: cint, # \param event Whether to send a moved event # -proc widget_set_position*(widget: ptr TWidget, x: cint, y: cint, event: cint){. +proc widget_set_position*(widget: ptr Widget, x: cint, y: cint, event: cint){. cdecl, importc: "widget_set_position", dynlib: clarodll.} #* \internal # \brief Sends a destroy event to the specified widget. @@ -576,13 +581,13 @@ proc widget_set_position*(widget: ptr TWidget, x: cint, y: cint, event: cint){. # \param widget A widget # -proc widget_destroy*(widget: ptr TWidget){.cdecl, importc: "widget_destroy", +proc widget_destroy*(widget: ptr Widget){.cdecl, importc: "widget_destroy", dynlib: clarodll.} type - TOpenglWidget* {.pure.} = object of TWidget + OpenglWidget* {.pure.} = object of Widget gldata*: pointer - +{.deprecated: [TOpenglWidget: OpenglWidget].} # functions #* @@ -594,8 +599,8 @@ type # \return A new OpenGL widget object. # -proc newopengl*(parent: ptr TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TOpenglWidget {. +proc newopengl*(parent: ptr ClaroObj, bounds: ptr Bounds, + flags: cint): ptr OpenglWidget {. cdecl, importc: "opengl_widget_create", dynlib: clarodll.} #* # \brief Flips the front and back buffers @@ -603,7 +608,7 @@ proc newopengl*(parent: ptr TClaroObj, bounds: ptr TBounds, # \param widget A valid OpenGL widget object # -proc opengl_flip*(widget: ptr TOpenglWidget) {.cdecl, importc: "opengl_flip", +proc opengl_flip*(widget: ptr OpenglWidget) {.cdecl, importc: "opengl_flip", dynlib: clarodll.} #* # \brief Activates this OpenGL widget's context @@ -611,13 +616,13 @@ proc opengl_flip*(widget: ptr TOpenglWidget) {.cdecl, importc: "opengl_flip", # \param widget A valid OpenGL widget object # -proc opengl_activate*(widget: ptr TOpenglWidget) {. +proc opengl_activate*(widget: ptr OpenglWidget) {. cdecl, importc: "opengl_activate", dynlib: clarodll.} type - TButton* {.pure.} = object of TWidget + Button* {.pure.} = object of Widget text*: array[0..256-1, char] - +{.deprecated: [TButton: Button].} # functions #* @@ -629,8 +634,8 @@ type # \return A new Button widget object. # -proc newbutton*(parent: ptr TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TButton {. +proc newbutton*(parent: ptr ClaroObj, bounds: ptr Bounds, + flags: cint): ptr Button {. cdecl, importc: "button_widget_create", dynlib: clarodll.} #* # \brief Creates a Button widget with a label @@ -642,9 +647,9 @@ proc newbutton*(parent: ptr TClaroObj, bounds: ptr TBounds, # \return A new Button widget object. # -proc newbutton*(parent: ptr TClaroObj, - bounds: ptr TBounds, flags: cint, - label: cstring): ptr TButton{.cdecl, +proc newbutton*(parent: ptr ClaroObj, + bounds: ptr Bounds, flags: cint, + label: cstring): ptr Button{.cdecl, importc: "button_widget_create_with_label", dynlib: clarodll.} #* # \brief Changes the label of the button @@ -653,7 +658,7 @@ proc newbutton*(parent: ptr TClaroObj, # \param label The new label for the button # -proc button_set_text*(obj: ptr TButton, label: cstring){.cdecl, +proc button_set_text*(obj: ptr Button, label: cstring){.cdecl, importc: "button_set_label", dynlib: clarodll.} #* @@ -666,7 +671,7 @@ proc button_set_text*(obj: ptr TButton, label: cstring){.cdecl, # \param image The new image for the button # -proc button_set_image*(obj: ptr TButton, image: ptr TImage){.cdecl, +proc button_set_image*(obj: ptr Button, image: ptr Image){.cdecl, importc: "button_set_image", dynlib: clarodll.} const @@ -680,7 +685,7 @@ const # END OLD type - TCanvas*{.pure.} = object of TWidget + Canvas*{.pure.} = object of Widget surface*: cairo.PSurface cr*: cairo.PContext surfdata*: pointer @@ -697,6 +702,7 @@ type charsize*: array[0..256 - 1, cairo.TTextExtents] csz_loaded*: cint fontsize*: cint +{.deprecated: [TCanvas: Canvas].} # functions #* @@ -708,8 +714,8 @@ type # \return A new Canvas widget object. # -proc newcanvas*(parent: ptr TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TCanvas{. +proc newcanvas*(parent: ptr ClaroObj, bounds: ptr Bounds, + flags: cint): ptr Canvas{. cdecl, importc: "canvas_widget_create", dynlib: clarodll.} #* # \brief Invalidates and redraws a canvas widget @@ -717,7 +723,7 @@ proc newcanvas*(parent: ptr TClaroObj, bounds: ptr TBounds, # \param widget A valid Canvas widget object. # -proc canvas_redraw*(widget: ptr TCanvas){.cdecl, importc: "canvas_redraw", +proc canvas_redraw*(widget: ptr Canvas){.cdecl, importc: "canvas_redraw", dynlib: clarodll.} # claro text functions #* @@ -730,7 +736,7 @@ proc canvas_redraw*(widget: ptr TCanvas){.cdecl, importc: "canvas_redraw", # \param a Alpha component (0.0 - 1.0) # -proc canvas_set_text_color*(widget: ptr TCanvas, r: cdouble, g: cdouble, +proc canvas_set_text_color*(widget: ptr Canvas, r: cdouble, g: cdouble, b: cdouble, a: cdouble){.cdecl, importc: "canvas_set_text_color", dynlib: clarodll.} #* @@ -743,7 +749,7 @@ proc canvas_set_text_color*(widget: ptr TCanvas, r: cdouble, g: cdouble, # \param a Alpha component (0.0 - 1.0) # -proc canvas_set_text_bgcolor*(widget: ptr TCanvas, r: cdouble, g: cdouble, +proc canvas_set_text_bgcolor*(widget: ptr Canvas, r: cdouble, g: cdouble, b: cdouble, a: cdouble){.cdecl, importc: "canvas_set_text_bgcolor", dynlib: clarodll.} #* @@ -757,7 +763,7 @@ proc canvas_set_text_bgcolor*(widget: ptr TCanvas, r: cdouble, g: cdouble, # \param decoration Font decorations # -proc canvas_set_text_font*(widget: ptr TCanvas, face: cstring, size: cint, +proc canvas_set_text_font*(widget: ptr Canvas, face: cstring, size: cint, weight: cint, slant: cint, decoration: cint){.cdecl, importc: "canvas_set_text_font", dynlib: clarodll.} #* @@ -769,7 +775,7 @@ proc canvas_set_text_font*(widget: ptr TCanvas, face: cstring, size: cint, # \return Width of the text in pixels # -proc canvas_text_width*(widget: ptr TCanvas, text: cstring, len: cint): cint{. +proc canvas_text_width*(widget: ptr Canvas, text: cstring, len: cint): cint{. cdecl, importc: "canvas_text_width", dynlib: clarodll.} #* # \brief Calculates the width of the specified text's bounding box @@ -780,7 +786,7 @@ proc canvas_text_width*(widget: ptr TCanvas, text: cstring, len: cint): cint{. # \return Width of the text's bounding box in pixels # -proc canvas_text_box_width*(widget: ptr TCanvas, text: cstring, +proc canvas_text_box_width*(widget: ptr Canvas, text: cstring, len: cint): cint{. cdecl, importc: "canvas_text_box_width", dynlib: clarodll.} #* @@ -793,7 +799,7 @@ proc canvas_text_box_width*(widget: ptr TCanvas, text: cstring, # \return The number of characters of text that will fit in width pixels. # -proc canvas_text_display_count*(widget: ptr TCanvas, text: cstring, +proc canvas_text_display_count*(widget: ptr Canvas, text: cstring, width: cint): cint{.cdecl, importc: "canvas_text_display_count", dynlib: clarodll.} #* @@ -806,7 +812,7 @@ proc canvas_text_display_count*(widget: ptr TCanvas, text: cstring, # \param len The number of characters of text to calulcate # -proc canvas_show_text*(widget: ptr TCanvas, x: cint, y: cint, text: cstring, +proc canvas_show_text*(widget: ptr Canvas, x: cint, y: cint, text: cstring, len: cint){.cdecl, importc: "canvas_show_text", dynlib: clarodll.} #* @@ -823,7 +829,7 @@ proc canvas_show_text*(widget: ptr TCanvas, x: cint, y: cint, text: cstring, # \param a Alpha component (0.0 - 1.0) # -proc canvas_fill_rect*(widget: ptr TCanvas, x: cint, y: cint, w: cint, +proc canvas_fill_rect*(widget: ptr Canvas, x: cint, y: cint, w: cint, h: cint, r, g, b, a: cdouble){. cdecl, importc: "canvas_fill_rect", dynlib: clarodll.} #* @@ -835,7 +841,7 @@ proc canvas_fill_rect*(widget: ptr TCanvas, x: cint, y: cint, w: cint, # \param y The Y position at which the image will be drawn # -proc canvas_draw_image*(widget: ptr TCanvas, image: ptr TImage, x: cint, +proc canvas_draw_image*(widget: ptr Canvas, image: ptr Image, x: cint, y: cint){.cdecl, importc: "canvas_draw_image", dynlib: clarodll.} # claro "extensions" of cairo @@ -843,25 +849,25 @@ proc canvas_draw_image*(widget: ptr TCanvas, image: ptr TImage, x: cint, # \brief Internal claro extension of cairo text functions # -proc canvas_cairo_buffered_text_width*(widget: ptr TCanvas, +proc canvas_cairo_buffered_text_width*(widget: ptr Canvas, text: cstring, len: cint): cint{.cdecl, importc: "canvas_cairo_buffered_text_width", dynlib: clarodll.} #* \internal # \brief Internal claro extension of cairo text functions # -proc canvas_cairo_buffered_text_display_count*(widget: ptr TCanvas, +proc canvas_cairo_buffered_text_display_count*(widget: ptr Canvas, text: cstring, width: cint): cint{.cdecl, importc: "canvas_cairo_buffered_text_display_count", dynlib: clarodll.} -proc canvas_get_cairo_context*(widget: ptr TCanvas): cairo.PContext {.cdecl, +proc canvas_get_cairo_context*(widget: ptr Canvas): cairo.PContext {.cdecl, importc: "canvas_get_cairo_context", dynlib: clarodll.} type - TCheckBox*{.pure.} = object of TWidget + CheckBox*{.pure.} = object of Widget text*: array[0..256-1, char] checked*: cint - +{.deprecated: [TCheckBox: CheckBox].} #* # \brief Creates a Checkbox widget # @@ -871,8 +877,8 @@ type # \return A new Checkbox widget object. # -proc newcheckbox*(parent: ptr TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TCheckBox{. +proc newcheckbox*(parent: ptr ClaroObj, bounds: ptr Bounds, + flags: cint): ptr CheckBox{. cdecl, importc: "checkbox_widget_create", dynlib: clarodll.} #* # \brief Creates a Checkbox widget with a label @@ -884,9 +890,9 @@ proc newcheckbox*(parent: ptr TClaroObj, bounds: ptr TBounds, # \return A new Checkbox widget object. # -proc newcheckbox*(parent: ptr TClaroObj, - bounds: ptr TBounds, flags: cint, - label: cstring): ptr TCheckBox {.cdecl, +proc newcheckbox*(parent: ptr ClaroObj, + bounds: ptr Bounds, flags: cint, + label: cstring): ptr CheckBox {.cdecl, importc: "checkbox_widget_create_with_label", dynlib: clarodll.} #* # \brief Sets a new label for the Checkbox widget @@ -895,7 +901,7 @@ proc newcheckbox*(parent: ptr TClaroObj, # \param label The new label for the checkbox # -proc checkbox_set_text*(obj: ptr TCheckBox, label: cstring){.cdecl, +proc checkbox_set_text*(obj: ptr CheckBox, label: cstring){.cdecl, importc: "checkbox_set_label", dynlib: clarodll.} #* # \brief Retrieves the checkbox's check state @@ -904,7 +910,7 @@ proc checkbox_set_text*(obj: ptr TCheckBox, label: cstring){.cdecl, # \return 1 if the checkbox is checked, otherwise 0 # -proc checkbox_checked*(obj: ptr TCheckBox): cint{.cdecl, +proc checkbox_checked*(obj: ptr CheckBox): cint{.cdecl, importc: "checkbox_get_checked", dynlib: clarodll.} #* # \brief Sets the checkbox's checked state @@ -913,7 +919,7 @@ proc checkbox_checked*(obj: ptr TCheckBox): cint{.cdecl, # \param checked 1 if the checkbox should become checked, otherwise 0 # -proc checkbox_set_checked*(obj: ptr TCheckBox, checked: cint){.cdecl, +proc checkbox_set_checked*(obj: ptr CheckBox, checked: cint){.cdecl, importc: "checkbox_set_checked", dynlib: clarodll.} @@ -922,31 +928,31 @@ proc checkbox_set_checked*(obj: ptr TCheckBox, checked: cint){.cdecl, # type - TListItem*{.pure.} = object of TClaroObj + ListItem*{.pure.} = object of ClaroObj row*: cint native*: pointer nativeid*: int - menu*: ptr TClaroObj + menu*: ptr ClaroObj enabled*: cint data*: ptr pointer - ListItemChildren*: TList - ListItemParent*: ptr TList - parent_item*: ptr TListItem # drawing related info, not always required - text_color*: TColor - sel_text_color*: TColor - back_color*: TColor - sel_back_color*: TColor - font*: TFont - - TListWidget* {.pure.} = object of TWidget ## List widget, base for + ListItemChildren*: List + ListItemParent*: ptr List + parent_item*: ptr ListItem # drawing related info, not always required + text_color*: Color + sel_text_color*: Color + back_color*: Color + sel_back_color*: Color + font*: Font + + ListWidget* {.pure.} = object of Widget ## List widget, base for ## widgets containing items columns*: cint coltypes*: ptr cint - items*: TList - - TCombo*{.pure.} = object of TListWidget - selected*: ptr TListItem + items*: List + Combo*{.pure.} = object of ListWidget + selected*: ptr ListItem +{.deprecated: [TListItem: ListItem, TListWidget: ListWidget, TCombo: Combo].} # functions #* @@ -958,8 +964,8 @@ type # \return A new Combo widget object. # -proc newcombo*(parent: ptr TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TCombo{. +proc newcombo*(parent: ptr ClaroObj, bounds: ptr Bounds, + flags: cint): ptr Combo{. cdecl, importc: "combo_widget_create", dynlib: clarodll.} #* # \brief Append a row to a Combo widget @@ -969,7 +975,7 @@ proc newcombo*(parent: ptr TClaroObj, bounds: ptr TBounds, # \return A new list item. # -proc combo_append_row*(combo: ptr TCombo, text: cstring): ptr TListItem {. +proc combo_append_row*(combo: ptr Combo, text: cstring): ptr ListItem {. cdecl, importc: "combo_append_row", dynlib: clarodll.} #* # \brief Insert a row at the specified position into a Combo widget @@ -980,8 +986,8 @@ proc combo_append_row*(combo: ptr TCombo, text: cstring): ptr TListItem {. # \return A new list item. # -proc combo_insert_row*(combo: ptr TCombo, pos: cint, - text: cstring): ptr TListItem {. +proc combo_insert_row*(combo: ptr Combo, pos: cint, + text: cstring): ptr ListItem {. cdecl, importc: "combo_insert_row", dynlib: clarodll.} #* # \brief Move a row in a Combo widget @@ -991,7 +997,7 @@ proc combo_insert_row*(combo: ptr TCombo, pos: cint, # \param row New position to place this item # -proc combo_move_row*(combo: ptr TCombo, item: ptr TListItem, row: cint){. +proc combo_move_row*(combo: ptr Combo, item: ptr ListItem, row: cint){. cdecl, importc: "combo_move_row", dynlib: clarodll.} #* # \brief Remove a row from a Combo widget @@ -1000,7 +1006,7 @@ proc combo_move_row*(combo: ptr TCombo, item: ptr TListItem, row: cint){. # \param item A valid list item # -proc combo_remove_row*(combo: ptr TCombo, item: ptr TListItem){.cdecl, +proc combo_remove_row*(combo: ptr Combo, item: ptr ListItem){.cdecl, importc: "combo_remove_row", dynlib: clarodll.} #* # \brief Returns the currently selected Combo item @@ -1009,7 +1015,7 @@ proc combo_remove_row*(combo: ptr TCombo, item: ptr TListItem){.cdecl, # \return The currently selected Combo item, or NULL if no item is selected. # -proc combo_get_selected*(obj: ptr TCombo): ptr TListItem{.cdecl, +proc combo_get_selected*(obj: ptr Combo): ptr ListItem{.cdecl, importc: "combo_get_selected", dynlib: clarodll.} #* # \brief Returns the number of rows in a Combo widget @@ -1018,7 +1024,7 @@ proc combo_get_selected*(obj: ptr TCombo): ptr TListItem{.cdecl, # \return Number of rows # -proc combo_get_rows*(obj: ptr TCombo): cint{.cdecl, +proc combo_get_rows*(obj: ptr Combo): cint{.cdecl, importc: "combo_get_rows", dynlib: clarodll.} #* # \brief Selects a row in a Combo widget @@ -1027,7 +1033,7 @@ proc combo_get_rows*(obj: ptr TCombo): cint{.cdecl, # \param item A valid list item # -proc combo_select_item*(obj: ptr TCombo, item: ptr TListItem){.cdecl, +proc combo_select_item*(obj: ptr Combo, item: ptr ListItem){.cdecl, importc: "combo_select_item", dynlib: clarodll.} #* # \brief Removes all entries from a Combo widget @@ -1035,11 +1041,12 @@ proc combo_select_item*(obj: ptr TCombo, item: ptr TListItem){.cdecl, # \param obj A valid Combo widget object. # -proc combo_clear*(obj: ptr TCombo){.cdecl, importc: "combo_clear", +proc combo_clear*(obj: ptr Combo){.cdecl, importc: "combo_clear", dynlib: clarodll.} type - TContainerWidget* {.pure.} = object of TWidget + ContainerWidget* {.pure.} = object of Widget +{.deprecated: [TContainerWidget: ContainerWidget].} # functions @@ -1052,14 +1059,14 @@ type # \return A new Container widget object. # -proc newcontainer*(parent: ptr TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TContainerWidget{. +proc newcontainer*(parent: ptr ClaroObj, bounds: ptr Bounds, + flags: cint): ptr ContainerWidget{. cdecl, importc: "container_widget_create", dynlib: clarodll.} -proc newdialog*(parent: ptr TClaroObj, bounds: ptr TBounds, format: cstring, - flags: cint): ptr TClaroObj{.cdecl, +proc newdialog*(parent: ptr ClaroObj, bounds: ptr Bounds, format: cstring, + flags: cint): ptr ClaroObj{.cdecl, importc: "dialog_widget_create", dynlib: clarodll.} -proc dialog_set_text*(obj: ptr TClaroObj, text: cstring){.cdecl, +proc dialog_set_text*(obj: ptr ClaroObj, text: cstring){.cdecl, importc: "dialog_set_text", dynlib: clarodll.} proc dialog_set_default_icon*(typ: cstring, file: cstring){.cdecl, importc: "dialog_set_default_icon", dynlib: clarodll.} @@ -1075,8 +1082,9 @@ proc dialog_other*(format: cstring, text: cstring, default_icon: cstring): cint{ cdecl, importc: "dialog_other", dynlib: clarodll.} type - TFontDialog* {.pure.} = object of TWidget - selected*: TFont + FontDialog* {.pure.} = object of Widget + selected*: Font +{.deprecated: [TFontDialog: FontDialog].} # functions #* @@ -1087,7 +1095,7 @@ type # \return A new Font Selection widget object. # -proc newFontDialog*(parent: ptr TClaroObj, flags: cint): ptr TFontDialog {. +proc newFontDialog*(parent: ptr ClaroObj, flags: cint): ptr FontDialog {. cdecl, importc: "font_dialog_widget_create", dynlib: clarodll.} #* # \brief Changes the selected font @@ -1096,7 +1104,7 @@ proc newFontDialog*(parent: ptr TClaroObj, flags: cint): ptr TFontDialog {. # \param font The name of the font # -proc font_dialog_set_font*(obj: ptr TFontDialog, face: cstring, size: cint, +proc font_dialog_set_font*(obj: ptr FontDialog, face: cstring, size: cint, weight: cint, slant: cint, decoration: cint){.cdecl, importc: "font_dialog_set_font", dynlib: clarodll.} #* @@ -1106,13 +1114,13 @@ proc font_dialog_set_font*(obj: ptr TFontDialog, face: cstring, size: cint, # \return A font_t structure containing information about the selected font. # -proc font_dialog_get_font*(obj: ptr TFontDialog): ptr TFont{.cdecl, +proc font_dialog_get_font*(obj: ptr FontDialog): ptr Font{.cdecl, importc: "font_dialog_get_font", dynlib: clarodll.} type - TFrame* {.pure.} = object of TWidget + Frame* {.pure.} = object of Widget text*: array[0..256-1, char] - +{.deprecated: [TFrame: Frame].} #* # \brief Creates a Frame widget @@ -1123,8 +1131,8 @@ type # \return A new Frame widget object. # -proc newframe*(parent: ptr TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TFrame{. +proc newframe*(parent: ptr ClaroObj, bounds: ptr Bounds, + flags: cint): ptr Frame{. cdecl, importc: "frame_widget_create", dynlib: clarodll.} #* # \brief Creates a Frame widget with a label @@ -1136,8 +1144,8 @@ proc newframe*(parent: ptr TClaroObj, bounds: ptr TBounds, # \return A new Frame widget object. # -proc newframe*(parent: ptr TClaroObj, bounds: ptr TBounds, flags: cint, - label: cstring): ptr TFrame {.cdecl, +proc newframe*(parent: ptr ClaroObj, bounds: ptr Bounds, flags: cint, + label: cstring): ptr Frame {.cdecl, importc: "frame_widget_create_with_label", dynlib: clarodll.} #* # \brief Creates a Container widget @@ -1148,13 +1156,13 @@ proc newframe*(parent: ptr TClaroObj, bounds: ptr TBounds, flags: cint, # \return A new Container widget object. # -proc frame_set_text*(frame: ptr TFrame, label: cstring){.cdecl, +proc frame_set_text*(frame: ptr Frame, label: cstring){.cdecl, importc: "frame_set_label", dynlib: clarodll.} type - TImageWidget* {.pure.} = object of TWidget - src*: ptr TImage - + ImageWidget* {.pure.} = object of Widget + src*: ptr Image +{.deprecated: [TImageWidget: ImageWidget].} #* # \brief Creates an Image widget @@ -1165,8 +1173,8 @@ type # \return A new Image widget object. # -proc newimageWidget*(parent: ptr TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TImageWidget{. +proc newimageWidget*(parent: ptr ClaroObj, bounds: ptr Bounds, + flags: cint): ptr ImageWidget{. cdecl, importc: "image_widget_create", dynlib: clarodll.} #* # \brief Creates an Image widget with an image @@ -1178,9 +1186,9 @@ proc newimageWidget*(parent: ptr TClaroObj, bounds: ptr TBounds, # \return A new Image widget object. # -proc newimageWidget*(parent: ptr TClaroObj, - bounds: ptr TBounds, flags: cint, - image: ptr TImage): ptr TImageWidget{.cdecl, +proc newimageWidget*(parent: ptr ClaroObj, + bounds: ptr Bounds, flags: cint, + image: ptr Image): ptr ImageWidget{.cdecl, importc: "image_widget_create_with_image", dynlib: clarodll.} #* # \brief Sets the image object of the image widget @@ -1189,16 +1197,17 @@ proc newimageWidget*(parent: ptr TClaroObj, # \param src The source image object # -proc image_set_image*(image: ptr TImageWidget, src: ptr TImage){.cdecl, +proc image_set_image*(image: ptr ImageWidget, src: ptr Image){.cdecl, importc: "image_set_image", dynlib: clarodll.} type - TLabel*{.pure.} = object of TWidget + Label*{.pure.} = object of Widget text*: array[0..256-1, char] - TcLabelJustify* = enum + CLabelJustify* = enum cLabelLeft = 0x00000001, cLabelRight = 0x00000002, cLabelCenter = 0x00000004, cLabelFill = 0x00000008 +{.deprecated: [TLabel: Label, TcLabelJustify: CLabelJustify].} #* # \brief Creates a Label widget @@ -1209,8 +1218,8 @@ type # \return A new Label widget object. # -proc newlabel*(parent: ptr TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TLabel{. +proc newlabel*(parent: ptr ClaroObj, bounds: ptr Bounds, + flags: cint): ptr Label{. cdecl, importc: "label_widget_create", dynlib: clarodll.} #* # \brief Creates a Label widget @@ -1221,9 +1230,9 @@ proc newlabel*(parent: ptr TClaroObj, bounds: ptr TBounds, # \return A new Label widget object. # -proc newLabel*(parent: ptr TClaroObj, - bounds: ptr TBounds, flags: cint, - text: cstring): ptr TLabel{.cdecl, +proc newLabel*(parent: ptr ClaroObj, + bounds: ptr Bounds, flags: cint, + text: cstring): ptr Label{.cdecl, importc: "label_widget_create_with_text", dynlib: clarodll.} #* # \brief Sets the text of a label widget @@ -1232,7 +1241,7 @@ proc newLabel*(parent: ptr TClaroObj, # \param text The text this label widget will show # -proc label_set_text*(obj: ptr TLabel, text: cstring){.cdecl, +proc label_set_text*(obj: ptr Label, text: cstring){.cdecl, importc: "label_set_text", dynlib: clarodll.} #* @@ -1242,7 +1251,7 @@ proc label_set_text*(obj: ptr TLabel, text: cstring){.cdecl, # \param text The justification (see cLabelJustify enum) # -proc label_set_justify*(obj: ptr TLabel, flags: cint){.cdecl, +proc label_set_justify*(obj: ptr Label, flags: cint){.cdecl, importc: "label_set_justify", dynlib: clarodll.} const @@ -1262,7 +1271,7 @@ const # types of the columns. # -proc list_widget_init_ptr*(obj: ptr TListWidget, col_num: cint, +proc list_widget_init_ptr*(obj: ptr ListWidget, col_num: cint, cols: ptr cint) {.cdecl, importc: "list_widget_init_ptr", dynlib: clarodll.} #* @@ -1273,7 +1282,7 @@ proc list_widget_init_ptr*(obj: ptr TListWidget, col_num: cint, # \param argpi A pointer to a va_list to parse # -#proc list_widget_init_vaptr*(obj: ptr TClaroObj, col_num: cunsignedint, +#proc list_widget_init_vaptr*(obj: ptr ClaroObj, col_num: cunsignedint, # argpi: va_list){.cdecl, # importc: "list_widget_init_vaptr", dynlib: clarodll.} @@ -1282,7 +1291,7 @@ proc list_widget_init_ptr*(obj: ptr TListWidget, col_num: cint, # it's own arguments, and a pointer to the first variable argument. # -proc list_widget_init*(obj: ptr TListWidget, col_num: cint){.varargs, +proc list_widget_init*(obj: ptr ListWidget, col_num: cint){.varargs, cdecl, importc: "list_widget_init", dynlib: clarodll.} #* # \brief Inserts a row to a list under parent at the position specified. @@ -1302,16 +1311,16 @@ proc list_widget_init*(obj: ptr TListWidget, col_num: cint){.varargs, # a pointer to the first variable argument. # -proc list_widget_row_append*(list: ptr TListWidget, - parent: ptr TListItem): ptr TListItem{. +proc list_widget_row_append*(list: ptr ListWidget, + parent: ptr ListItem): ptr ListItem{. varargs, cdecl, importc: "list_widget_row_append", dynlib: clarodll.} #* # Shortcut function, calls list_widget_row_insert_ptr with # it's own arguments, and a pointer to the first variable argument. # -proc list_widget_row_insert*(list: ptr TListWidget, parent: ptr TListItem, - pos: cint): ptr TListItem {.varargs, cdecl, +proc list_widget_row_insert*(list: ptr ListWidget, parent: ptr ListItem, + pos: cint): ptr ListItem {.varargs, cdecl, importc: "list_widget_row_insert", dynlib: clarodll.} #* # \brief Removes a row from a list @@ -1320,7 +1329,7 @@ proc list_widget_row_insert*(list: ptr TListWidget, parent: ptr TListItem, # \param item The item to remove # -proc list_widget_row_remove*(list: ptr TListWidget, item: ptr TListItem){. +proc list_widget_row_remove*(list: ptr ListWidget, item: ptr ListItem){. cdecl, importc: "list_widget_row_remove", dynlib: clarodll.} #* # \brief Moves a row to a new position in the list @@ -1331,7 +1340,7 @@ proc list_widget_row_remove*(list: ptr TListWidget, item: ptr TListItem){. # position will result in no change. # -proc list_widget_row_move*(list: ptr TListWidget, item: ptr TListItem, +proc list_widget_row_move*(list: ptr ListWidget, item: ptr ListItem, row: cint){.cdecl, importc: "list_widget_row_move", dynlib: clarodll.} #* @@ -1342,8 +1351,8 @@ proc list_widget_row_move*(list: ptr TListWidget, item: ptr TListItem, # \param row Row index of item to return # -proc list_widget_get_row*(list: ptr TListWidget, parent: ptr TListItem, - row: cint): ptr TListItem{.cdecl, +proc list_widget_get_row*(list: ptr ListWidget, parent: ptr ListItem, + row: cint): ptr ListItem{.cdecl, importc: "list_widget_get_row", dynlib: clarodll.} #* # \brief Edit items of a row in the list. @@ -1365,7 +1374,7 @@ proc list_widget_get_row*(list: ptr TListWidget, parent: ptr TListItem, # Don't forget the -1. # -proc list_widget_edit_row*(list: ptr TListWidget, item: ptr TListItem){. +proc list_widget_edit_row*(list: ptr ListWidget, item: ptr ListItem){. varargs, cdecl, importc: "list_widget_edit_row", dynlib: clarodll.} #* # \brief Set the text color of an item. @@ -1379,7 +1388,7 @@ proc list_widget_edit_row*(list: ptr TListWidget, item: ptr TListItem){. # should be 1.0) # -proc list_item_set_text_color*(item: ptr TListItem, r: cfloat, g: cfloat, +proc list_item_set_text_color*(item: ptr ListItem, r: cfloat, g: cfloat, b: cfloat, a: cfloat){.cdecl, importc: "list_item_set_text_color", dynlib: clarodll.} #* @@ -1394,7 +1403,7 @@ proc list_item_set_text_color*(item: ptr TListItem, r: cfloat, g: cfloat, # should be 1.0) # -proc list_item_set_text_bgcolor*(item: ptr TListItem, r: cfloat, g: cfloat, +proc list_item_set_text_bgcolor*(item: ptr ListItem, r: cfloat, g: cfloat, b: cfloat, a: cfloat){.cdecl, importc: "list_item_set_text_bgcolor", dynlib: clarodll.} #* @@ -1409,7 +1418,7 @@ proc list_item_set_text_bgcolor*(item: ptr TListItem, r: cfloat, g: cfloat, # should be 1.0) # -proc list_item_set_sel_text_color*(item: ptr TListItem, r: cfloat, g: cfloat, +proc list_item_set_sel_text_color*(item: ptr ListItem, r: cfloat, g: cfloat, b: cfloat, a: cfloat){.cdecl, importc: "list_item_set_sel_text_color", dynlib: clarodll.} #* @@ -1424,7 +1433,7 @@ proc list_item_set_sel_text_color*(item: ptr TListItem, r: cfloat, g: cfloat, # should be 1.0) # -proc list_item_set_sel_text_bgcolor*(item: ptr TListItem, r: cfloat, +proc list_item_set_sel_text_bgcolor*(item: ptr ListItem, r: cfloat, g: cfloat, b: cfloat, a: cfloat){.cdecl, importc: "list_item_set_sel_text_bgcolor", dynlib: clarodll.} #* @@ -1436,13 +1445,14 @@ proc list_item_set_sel_text_bgcolor*(item: ptr TListItem, r: cfloat, # \param decoration Font decorations # -proc list_item_set_font_extra*(item: ptr TListItem, weight: cint, +proc list_item_set_font_extra*(item: ptr ListItem, weight: cint, slant: cint, decoration: cint){.cdecl, importc: "list_item_set_font_extra", dynlib: clarodll.} type - TListbox* {.pure.} = object of TListWidget - selected*: ptr TListItem + Listbox* {.pure.} = object of ListWidget + selected*: ptr ListItem +{.deprecated: [TListbox: Listbox].} # functions #* @@ -1454,8 +1464,8 @@ type # \return A new ListBox widget object. # -proc newlistbox*(parent: ptr TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TListbox{. +proc newlistbox*(parent: ptr ClaroObj, bounds: ptr Bounds, + flags: cint): ptr Listbox{. cdecl, importc: "listbox_widget_create", dynlib: clarodll.} #* # \brief Insert a row at the specified position into a ListBox widget @@ -1466,8 +1476,8 @@ proc newlistbox*(parent: ptr TClaroObj, bounds: ptr TBounds, # \return A new list item. # -proc listbox_insert_row*(listbox: ptr TListbox, pos: cint, - text: cstring): ptr TListItem{. +proc listbox_insert_row*(listbox: ptr Listbox, pos: cint, + text: cstring): ptr ListItem{. cdecl, importc: "listbox_insert_row", dynlib: clarodll.} #* # \brief Append a row to a ListBox widget @@ -1477,7 +1487,7 @@ proc listbox_insert_row*(listbox: ptr TListbox, pos: cint, # \return A new list item. # -proc listbox_append_row*(listbox: ptr TListbox, text: cstring): ptr TListItem{. +proc listbox_append_row*(listbox: ptr Listbox, text: cstring): ptr ListItem{. cdecl, importc: "listbox_append_row", dynlib: clarodll.} #* # \brief Move a row in a ListBox widget @@ -1487,7 +1497,7 @@ proc listbox_append_row*(listbox: ptr TListbox, text: cstring): ptr TListItem{. # \param row New position to place this item # -proc listbox_move_row*(listbox: ptr TListbox, item: ptr TListItem, row: cint){. +proc listbox_move_row*(listbox: ptr Listbox, item: ptr ListItem, row: cint){. cdecl, importc: "listbox_move_row", dynlib: clarodll.} #* # \brief Remove a row from a ListBox widget @@ -1496,7 +1506,7 @@ proc listbox_move_row*(listbox: ptr TListbox, item: ptr TListItem, row: cint){. # \param item A valid list item # -proc listbox_remove_row*(listbox: ptr TListbox, item: ptr TListItem){.cdecl, +proc listbox_remove_row*(listbox: ptr Listbox, item: ptr ListItem){.cdecl, importc: "listbox_remove_row", dynlib: clarodll.} #* # \brief Returns the currently selected ListBox item @@ -1505,7 +1515,7 @@ proc listbox_remove_row*(listbox: ptr TListbox, item: ptr TListItem){.cdecl, # \return The currently selected ListBox item, or NULL if no item is selected. # -proc listbox_get_selected*(obj: ptr TListbox): ptr TListItem{.cdecl, +proc listbox_get_selected*(obj: ptr Listbox): ptr ListItem{.cdecl, importc: "listbox_get_selected", dynlib: clarodll.} #* # \brief Returns the number of rows in a ListBox widget @@ -1514,7 +1524,7 @@ proc listbox_get_selected*(obj: ptr TListbox): ptr TListItem{.cdecl, # \return Number of rows # -proc listbox_get_rows*(obj: ptr TListbox): cint{.cdecl, +proc listbox_get_rows*(obj: ptr Listbox): cint{.cdecl, importc: "listbox_get_rows", dynlib: clarodll.} #* # \brief Selects a row in a ListBox widget @@ -1523,7 +1533,7 @@ proc listbox_get_rows*(obj: ptr TListbox): cint{.cdecl, # \param item A valid list item # -proc listbox_select_item*(obj: ptr TListbox, item: ptr TListItem){.cdecl, +proc listbox_select_item*(obj: ptr Listbox, item: ptr ListItem){.cdecl, importc: "listbox_select_item", dynlib: clarodll.} const @@ -1538,11 +1548,11 @@ const cListViewRowCheckBoxes* = 1 type - TListview* {.pure.} = object of TListWidget + Listview* {.pure.} = object of ListWidget titles*: cstringArray nativep*: pointer - selected*: ptr TListItem - + selected*: ptr ListItem +{.deprecated: [TListview: Listview].} # functions #* @@ -1557,8 +1567,8 @@ type # \return A new ListView widget object. # -proc newlistview*(parent: ptr TClaroObj, bounds: ptr TBounds, columns: cint, - flags: cint): ptr TListview {.varargs, cdecl, +proc newlistview*(parent: ptr ClaroObj, bounds: ptr Bounds, columns: cint, + flags: cint): ptr Listview {.varargs, cdecl, importc: "listview_widget_create", dynlib: clarodll.} #* # \brief Append a row to a ListView widget @@ -1568,7 +1578,7 @@ proc newlistview*(parent: ptr TClaroObj, bounds: ptr TBounds, columns: cint, # \return A new list item. # -proc listview_append_row*(listview: ptr TListview): ptr TListItem{.varargs, +proc listview_append_row*(listview: ptr Listview): ptr ListItem{.varargs, cdecl, importc: "listview_append_row", dynlib: clarodll.} #* # \brief Insert a row at the specified position into a ListView widget @@ -1579,7 +1589,7 @@ proc listview_append_row*(listview: ptr TListview): ptr TListItem{.varargs, # \return A new list item. # -proc listview_insert_row*(listview: ptr TListview, pos: cint): ptr TListItem{. +proc listview_insert_row*(listview: ptr Listview, pos: cint): ptr ListItem{. varargs, cdecl, importc: "listview_insert_row", dynlib: clarodll.} #* # \brief Move a row in a ListView widget @@ -1589,7 +1599,7 @@ proc listview_insert_row*(listview: ptr TListview, pos: cint): ptr TListItem{. # \param row New position to place this item # -proc listview_move_row*(listview: ptr TListview, item: ptr TListItem, +proc listview_move_row*(listview: ptr Listview, item: ptr ListItem, row: cint){.cdecl, importc: "listview_move_row", dynlib: clarodll.} #* @@ -1599,7 +1609,7 @@ proc listview_move_row*(listview: ptr TListview, item: ptr TListItem, # \param item A valid list item # -proc listview_remove_row*(listview: ptr TListview, item: ptr TListItem){. +proc listview_remove_row*(listview: ptr Listview, item: ptr ListItem){. cdecl, importc: "listview_remove_row", dynlib: clarodll.} #* # \brief Returns the currently selected ListView item @@ -1608,7 +1618,7 @@ proc listview_remove_row*(listview: ptr TListview, item: ptr TListItem){. # \return The currently selected ListView item, or NULL if no item is selected. # -proc listview_get_selected*(obj: ptr TListview): ptr TListItem{.cdecl, +proc listview_get_selected*(obj: ptr Listview): ptr ListItem{.cdecl, importc: "listview_get_selected", dynlib: clarodll.} #* # \brief Returns the number of rows in a ListView widget @@ -1617,7 +1627,7 @@ proc listview_get_selected*(obj: ptr TListview): ptr TListItem{.cdecl, # \return Number of rows # -proc listview_get_rows*(obj: ptr TListview): cint{.cdecl, +proc listview_get_rows*(obj: ptr Listview): cint{.cdecl, importc: "listview_get_rows", dynlib: clarodll.} #* # \brief Selects a row in a ListView widget @@ -1626,15 +1636,15 @@ proc listview_get_rows*(obj: ptr TListview): cint{.cdecl, # \param item A valid list item # -proc listview_select_item*(obj: ptr TListview, item: ptr TListItem){.cdecl, +proc listview_select_item*(obj: ptr Listview, item: ptr ListItem){.cdecl, importc: "listview_select_item", dynlib: clarodll.} const cMenuPopupAtCursor* = 1 type - TMenu* {.pure.} = object of TListWidget - + Menu* {.pure.} = object of ListWidget +{.deprecated: [TMenu: Menu].} #* # \brief Creates a Menu widget @@ -1644,7 +1654,7 @@ type # \return A new Menu widget object. # -proc newmenu*(parent: ptr TClaroObj, flags: cint): ptr TMenu {.cdecl, +proc newmenu*(parent: ptr ClaroObj, flags: cint): ptr Menu {.cdecl, importc: "menu_widget_create", dynlib: clarodll.} #* # \brief Append a row to a Menu widget @@ -1656,8 +1666,8 @@ proc newmenu*(parent: ptr TClaroObj, flags: cint): ptr TMenu {.cdecl, # \return A new list item. # -proc menu_append_item*(menu: ptr TMenu, parent: ptr TListItem, - image: ptr TImage, title: cstring): ptr TListItem{. +proc menu_append_item*(menu: ptr Menu, parent: ptr ListItem, + image: ptr Image, title: cstring): ptr ListItem{. cdecl, importc: "menu_append_item", dynlib: clarodll.} #* # \brief Insert a row into a Menu widget @@ -1670,8 +1680,8 @@ proc menu_append_item*(menu: ptr TMenu, parent: ptr TListItem, # \return A new list item. # -proc menu_insert_item*(menu: ptr TMenu, parent: ptr TListItem, pos: cint, - image: ptr TImage, title: cstring): ptr TListItem{. +proc menu_insert_item*(menu: ptr Menu, parent: ptr ListItem, pos: cint, + image: ptr Image, title: cstring): ptr ListItem{. cdecl, importc: "menu_insert_item", dynlib: clarodll.} #* # \brief Append a separator to a Menu widget @@ -1681,8 +1691,8 @@ proc menu_insert_item*(menu: ptr TMenu, parent: ptr TListItem, pos: cint, # \return A new list item. # -proc menu_append_separator*(menu: ptr TMenu, - parent: ptr TListItem): ptr TListItem{. +proc menu_append_separator*(menu: ptr Menu, + parent: ptr ListItem): ptr ListItem{. cdecl, importc: "menu_append_separator", dynlib: clarodll.} #* # \brief Insert a separator into a Menu widget @@ -1693,8 +1703,8 @@ proc menu_append_separator*(menu: ptr TMenu, # \return A new list item. # -proc menu_insert_separator*(menu: ptr TMenu, parent: ptr TListItem, - pos: cint): ptr TListItem{.cdecl, +proc menu_insert_separator*(menu: ptr Menu, parent: ptr ListItem, + pos: cint): ptr ListItem{.cdecl, importc: "menu_insert_separator", dynlib: clarodll.} #* # \brief Move a row in a Menu widget @@ -1704,7 +1714,7 @@ proc menu_insert_separator*(menu: ptr TMenu, parent: ptr TListItem, # \param row New position to place this item # -proc menu_move_item*(menu: ptr TMenu, item: ptr TListItem, row: cint){. +proc menu_move_item*(menu: ptr Menu, item: ptr ListItem, row: cint){. cdecl, importc: "menu_move_item", dynlib: clarodll.} #* # \brief Remove a row from a Menu widget @@ -1713,7 +1723,7 @@ proc menu_move_item*(menu: ptr TMenu, item: ptr TListItem, row: cint){. # \param item A valid list item # -proc menu_remove_item*(menu: ptr TMenu, item: ptr TListItem){.cdecl, +proc menu_remove_item*(menu: ptr Menu, item: ptr ListItem){.cdecl, importc: "menu_remove_item", dynlib: clarodll.} #* # \brief Returns the number of rows in a Menu widget @@ -1724,7 +1734,7 @@ proc menu_remove_item*(menu: ptr TMenu, item: ptr TListItem){.cdecl, # \return Number of rows # -proc menu_item_count*(obj: ptr TMenu, parent: ptr TListItem): cint{. +proc menu_item_count*(obj: ptr Menu, parent: ptr ListItem): cint{. cdecl, importc: "menu_item_count", dynlib: clarodll.} #* # \brief Disables a menu item (no focus and greyed out) @@ -1733,7 +1743,7 @@ proc menu_item_count*(obj: ptr TMenu, parent: ptr TListItem): cint{. # \param item A valid list item # -proc menu_disable_item*(menu: ptr TMenu, item: ptr TListItem){.cdecl, +proc menu_disable_item*(menu: ptr Menu, item: ptr ListItem){.cdecl, importc: "menu_disable_item", dynlib: clarodll.} #* # \brief Enables a menu item (allows focus and not greyed out) @@ -1742,7 +1752,7 @@ proc menu_disable_item*(menu: ptr TMenu, item: ptr TListItem){.cdecl, # \param item A valid list item # -proc menu_enable_item*(menu: ptr TMenu, item: ptr TListItem){.cdecl, +proc menu_enable_item*(menu: ptr Menu, item: ptr ListItem){.cdecl, importc: "menu_enable_item", dynlib: clarodll.} #* # \brief Pops up the menu at the position specified @@ -1753,7 +1763,7 @@ proc menu_enable_item*(menu: ptr TMenu, item: ptr TListItem){.cdecl, # \param flags Flags # -proc menu_popup*(menu: ptr TMenu, x: cint, y: cint, flags: cint){.cdecl, +proc menu_popup*(menu: ptr Menu, x: cint, y: cint, flags: cint){.cdecl, importc: "menu_popup", dynlib: clarodll.} # # Menu modifiers @@ -1764,8 +1774,8 @@ const cModifierCommand* = 1 shl 1 type - TMenubar* {.pure.} = object of TListWidget - + Menubar* {.pure.} = object of ListWidget +{.deprecated: [TMenubar: Menubar].} #* # \brief Creates a MenuBar widget # @@ -1774,7 +1784,7 @@ type # \return A new MenuBar widget object. # -proc newmenubar*(parent: ptr TClaroObj, flags: cint): ptr TMenubar {.cdecl, +proc newmenubar*(parent: ptr ClaroObj, flags: cint): ptr Menubar {.cdecl, importc: "menubar_widget_create", dynlib: clarodll.} #* # \brief Add a key binding to a menu items @@ -1785,7 +1795,7 @@ proc newmenubar*(parent: ptr TClaroObj, flags: cint): ptr TMenubar {.cdecl, # \param modifier The modifier key, or 0. # -proc menubar_add_key_binding*(menubar: ptr TMenubar, item: ptr TListItem, +proc menubar_add_key_binding*(menubar: ptr Menubar, item: ptr ListItem, utf8_key: cstring, modifier: cint){.cdecl, importc: "menubar_add_key_binding", dynlib: clarodll.} #* @@ -1798,8 +1808,8 @@ proc menubar_add_key_binding*(menubar: ptr TMenubar, item: ptr TListItem, # \return A new list item. # -proc menubar_append_item*(menubar: ptr TMenubar, parent: ptr TListItem, - image: ptr TImage, title: cstring): ptr TListItem{. +proc menubar_append_item*(menubar: ptr Menubar, parent: ptr ListItem, + image: ptr Image, title: cstring): ptr ListItem{. cdecl, importc: "menubar_append_item", dynlib: clarodll.} #* # \brief Insert a row into a MenuBar widget @@ -1812,9 +1822,9 @@ proc menubar_append_item*(menubar: ptr TMenubar, parent: ptr TListItem, # \return A new list item. # -proc menubar_insert_item*(menubar: ptr TMenubar, parent: ptr TListItem, - pos: cint, image: ptr TImage, - title: cstring): ptr TListItem{. +proc menubar_insert_item*(menubar: ptr Menubar, parent: ptr ListItem, + pos: cint, image: ptr Image, + title: cstring): ptr ListItem{. cdecl, importc: "menubar_insert_item", dynlib: clarodll.} #* # \brief Append a separator to a MenuBar widget @@ -1824,8 +1834,8 @@ proc menubar_insert_item*(menubar: ptr TMenubar, parent: ptr TListItem, # \return A new list item. # -proc menubar_append_separator*(menubar: ptr TMenubar, - parent: ptr TListItem): ptr TListItem{. +proc menubar_append_separator*(menubar: ptr Menubar, + parent: ptr ListItem): ptr ListItem{. cdecl, importc: "menubar_append_separator", dynlib: clarodll.} #* # \brief Insert a separator into a MenuBar widget @@ -1836,8 +1846,8 @@ proc menubar_append_separator*(menubar: ptr TMenubar, # \return A new list item. # -proc menubar_insert_separator*(menubar: ptr TMenubar, parent: ptr TListItem, - pos: cint): ptr TListItem{.cdecl, +proc menubar_insert_separator*(menubar: ptr Menubar, parent: ptr ListItem, + pos: cint): ptr ListItem{.cdecl, importc: "menubar_insert_separator", dynlib: clarodll.} #* # \brief Move a row in a MenuBar widget @@ -1847,7 +1857,7 @@ proc menubar_insert_separator*(menubar: ptr TMenubar, parent: ptr TListItem, # \param row New position to place this item # -proc menubar_move_item*(menubar: ptr TMenubar, item: ptr TListItem, +proc menubar_move_item*(menubar: ptr Menubar, item: ptr ListItem, row: cint){.cdecl, importc: "menubar_move_item", dynlib: clarodll.} #* @@ -1857,7 +1867,7 @@ proc menubar_move_item*(menubar: ptr TMenubar, item: ptr TListItem, # \param item A valid list item # -proc menubar_remove_item*(menubar: ptr TMenubar, item: ptr TListItem) {. +proc menubar_remove_item*(menubar: ptr Menubar, item: ptr ListItem) {. cdecl, importc: "menubar_remove_item", dynlib: clarodll.} #* # \brief Returns the number of rows in a MenuBar widget @@ -1868,7 +1878,7 @@ proc menubar_remove_item*(menubar: ptr TMenubar, item: ptr TListItem) {. # \return Number of rows # -proc menubar_item_count*(obj: ptr TMenubar, parent: ptr TListItem): cint{. +proc menubar_item_count*(obj: ptr Menubar, parent: ptr ListItem): cint{. cdecl, importc: "menubar_item_count", dynlib: clarodll.} #* # \brief Disables a menu item (no focus and greyed out) @@ -1877,7 +1887,7 @@ proc menubar_item_count*(obj: ptr TMenubar, parent: ptr TListItem): cint{. # \param item A valid list item # -proc menubar_disable_item*(menubar: ptr TMenubar, item: ptr TListItem){. +proc menubar_disable_item*(menubar: ptr Menubar, item: ptr ListItem){. cdecl, importc: "menubar_disable_item", dynlib: clarodll.} #* # \brief Enables a menu item (allows focus and not greyed out) @@ -1886,15 +1896,16 @@ proc menubar_disable_item*(menubar: ptr TMenubar, item: ptr TListItem){. # \param item A valid list item # -proc menubar_enable_item*(menubar: ptr TMenubar, item: ptr TListItem){. +proc menubar_enable_item*(menubar: ptr Menubar, item: ptr ListItem){. cdecl, importc: "menubar_enable_item", dynlib: clarodll.} type - TProgress* {.pure.} = object of TWidget + Progress* {.pure.} = object of Widget - TcProgressStyle* = enum + CProgressStyle* = enum cProgressLeftRight = 0x00000000, cProgressRightLeft = 0x00000001, cProgressTopBottom = 0x00000002, cProgressBottomTop = 0x00000004 +{.deprecated: [TProgress: Progress, TcProgressStyle: CProgressStyle].} #* # \brief Creates a Progress widget @@ -1905,8 +1916,8 @@ type # \return A new Progress widget object. # -proc newprogress*(parent: ptr TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TProgress {. +proc newprogress*(parent: ptr ClaroObj, bounds: ptr Bounds, + flags: cint): ptr Progress {. cdecl, importc: "progress_widget_create", dynlib: clarodll.} #* # \brief Sets the value of a progress widget @@ -1915,7 +1926,7 @@ proc newprogress*(parent: ptr TClaroObj, bounds: ptr TBounds, # \param percentage Progress value # -proc progress_set_level*(progress: ptr TProgress, percentage: cdouble){.cdecl, +proc progress_set_level*(progress: ptr Progress, percentage: cdouble){.cdecl, importc: "progress_set_level", dynlib: clarodll.} #* # \brief Sets the orientation of a progress widget @@ -1924,19 +1935,19 @@ proc progress_set_level*(progress: ptr TProgress, percentage: cdouble){.cdecl, # \param flags One of the cProgressStyle values # -proc progress_set_orientation*(progress: ptr TProgress, flags: cint){.cdecl, +proc progress_set_orientation*(progress: ptr Progress, flags: cint){.cdecl, importc: "progress_set_orientation", dynlib: clarodll.} type - TRadioGroup* {.pure.} = object of TClaroObj - buttons*: TList - selected*: ptr TClaroObj + RadioGroup* {.pure.} = object of ClaroObj + buttons*: List + selected*: ptr ClaroObj ndata*: pointer - TRadioButton* {.pure.} = object of TWidget + RadioButton* {.pure.} = object of Widget text*: array[0..256-1, char] - group*: ptr TRadioGroup - + group*: ptr RadioGroup +{.deprecated: [TRadioGroup: RadioGroup, TRadioButton: RadioButton].} #* # \brief Creates a Radio Group widget @@ -1946,7 +1957,7 @@ type # \return A new Radio Group widget object. # -proc newRadiogroup*(parent: ptr TClaroObj, flags: cint): ptr TRadioGroup {. +proc newRadiogroup*(parent: ptr ClaroObj, flags: cint): ptr RadioGroup {. cdecl, importc: "radiogroup_create", dynlib: clarodll.} #* # \brief Creates a Radio Button widget @@ -1959,9 +1970,9 @@ proc newRadiogroup*(parent: ptr TClaroObj, flags: cint): ptr TRadioGroup {. # \return A new Radio Button widget object. # -proc newradiobutton*(parent: ptr TClaroObj, group: ptr TRadioGroup, - bounds: ptr TBounds, label: cstring, - flags: cint): ptr TRadioButton{. +proc newradiobutton*(parent: ptr ClaroObj, group: ptr RadioGroup, + bounds: ptr Bounds, label: cstring, + flags: cint): ptr RadioButton{. cdecl, importc: "radiobutton_widget_create", dynlib: clarodll.} #* # \brief Set the label of a Radio Button @@ -1970,7 +1981,7 @@ proc newradiobutton*(parent: ptr TClaroObj, group: ptr TRadioGroup, # \param label The new label for the Radio Button # -proc radiobutton_set_text*(obj: ptr TRadioButton, label: cstring){.cdecl, +proc radiobutton_set_text*(obj: ptr RadioButton, label: cstring){.cdecl, importc: "radiobutton_set_label", dynlib: clarodll.} #* # \brief Set the group of a Radio Button @@ -1979,18 +1990,18 @@ proc radiobutton_set_text*(obj: ptr TRadioButton, label: cstring){.cdecl, # \param group A valid Radio Group widget object # -proc radiobutton_set_group*(rbutton: ptr TRadioButton, group: ptr TRadioGroup){. +proc radiobutton_set_group*(rbutton: ptr RadioButton, group: ptr RadioGroup){. cdecl, importc: "radiobutton_set_group", dynlib: clarodll.} const CLARO_SCROLLBAR_MAXIMUM* = 256 type - TScrollbar* {.pure.} = object of TWidget + Scrollbar* {.pure.} = object of Widget min*: cint max*: cint pagesize*: cint - +{.deprecated: [TScrollbar: Scrollbar].} const cScrollbarHorizontal* = 0 @@ -2006,8 +2017,8 @@ const # \return A new ScrollBar widget object. # -proc newscrollbar*(parent: ptr TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TScrollbar{. +proc newscrollbar*(parent: ptr ClaroObj, bounds: ptr Bounds, + flags: cint): ptr Scrollbar{. cdecl, importc: "scrollbar_widget_create", dynlib: clarodll.} #* # \brief Returns the width that scrollbars should be on this platform @@ -2026,7 +2037,7 @@ proc scrollbar_get_sys_width*(): cint{.cdecl, # \param max The maximum value # -proc scrollbar_set_range*(w: ptr TScrollbar, min: cint, max: cint){.cdecl, +proc scrollbar_set_range*(w: ptr Scrollbar, min: cint, max: cint){.cdecl, importc: "scrollbar_set_range", dynlib: clarodll.} #* # \brief Sets the position of a ScrollBar widget @@ -2035,7 +2046,7 @@ proc scrollbar_set_range*(w: ptr TScrollbar, min: cint, max: cint){.cdecl, # \param pos The new position # -proc scrollbar_set_pos*(w: ptr TScrollbar, pos: cint){.cdecl, +proc scrollbar_set_pos*(w: ptr Scrollbar, pos: cint){.cdecl, importc: "scrollbar_set_pos", dynlib: clarodll.} #* # \brief Gets the position of a ScrollBar widget @@ -2044,7 +2055,7 @@ proc scrollbar_set_pos*(w: ptr TScrollbar, pos: cint){.cdecl, # \return The current position # -proc scrollbar_get_pos*(w: ptr TScrollbar): cint{.cdecl, +proc scrollbar_get_pos*(w: ptr Scrollbar): cint{.cdecl, importc: "scrollbar_get_pos", dynlib: clarodll.} #* # \brief Sets the page size of a ScrollBar widget @@ -2053,20 +2064,21 @@ proc scrollbar_get_pos*(w: ptr TScrollbar): cint{.cdecl, # \param pagesize The size of a page (the number of units visible at one time) # -proc scrollbar_set_pagesize*(w: ptr TScrollbar, pagesize: cint){.cdecl, +proc scrollbar_set_pagesize*(w: ptr Scrollbar, pagesize: cint){.cdecl, importc: "scrollbar_set_pagesize", dynlib: clarodll.} type - TcSplitterChildren* = enum + CSplitterChildren* = enum cSplitterFirst = 0, cSplitterSecond = 1 - TSplitterChild* {.pure.} = object + SplitterChild* {.pure.} = object flex*: cint size*: cint - w*: ptr TWidget - - TSplitter* {.pure.} = object of TWidget - pair*: array[0..1, TSplitterChild] + w*: ptr Widget + Splitter* {.pure.} = object of Widget + pair*: array[0..1, SplitterChild] +{.deprecated: [TcSplitterChildren: CSplitterChildren, TSplitter: Splitter, + TSplitterChild: SplitterChild].} const cSplitterHorizontal* = 0 @@ -2082,8 +2094,8 @@ const # \return A new Splitter widget object. # -proc newsplitter*(parent: ptr TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TSplitter{. +proc newsplitter*(parent: ptr ClaroObj, bounds: ptr Bounds, + flags: cint): ptr Splitter{. cdecl, importc: "splitter_widget_create", dynlib: clarodll.} #* # \brief Sets the sizing information of a child @@ -2095,13 +2107,14 @@ proc newsplitter*(parent: ptr TClaroObj, bounds: ptr TBounds, # \param size The size of this child # -proc splitter_set_info*(splitter: ptr TSplitter, child: cint, flex: cint, +proc splitter_set_info*(splitter: ptr Splitter, child: cint, flex: cint, size: cint){.cdecl, importc: "splitter_set_info", dynlib: clarodll.} type - TStatusbar* {.pure.} = object of TWidget + Statusbar* {.pure.} = object of Widget text*: array[0..256 - 1, char] +{.deprecated: [TStatusbar: Statusbar].} #* @@ -2112,7 +2125,7 @@ type # \return A new StatusBar widget object. # -proc newstatusbar*(parent: ptr TClaroObj, flags: cint): ptr TStatusbar {.cdecl, +proc newstatusbar*(parent: ptr ClaroObj, flags: cint): ptr Statusbar {.cdecl, importc: "statusbar_widget_create", dynlib: clarodll.} #* # \brief Sets the text of a statusbar @@ -2121,7 +2134,7 @@ proc newstatusbar*(parent: ptr TClaroObj, flags: cint): ptr TStatusbar {.cdecl, # \param text The new text # -proc statusbar_set_text*(obj: ptr TStatusbar, text: cstring){.cdecl, +proc statusbar_set_text*(obj: ptr Statusbar, text: cstring){.cdecl, importc: "statusbar_set_text", dynlib: clarodll.} #* # \brief obtains a stock image @@ -2130,7 +2143,7 @@ proc statusbar_set_text*(obj: ptr TStatusbar, text: cstring){.cdecl, # \return The Image object. # -proc stock_get_image*(stock_id: cstring): ptr TImage{.cdecl, +proc stock_get_image*(stock_id: cstring): ptr Image{.cdecl, importc: "stock_get_image", dynlib: clarodll.} #* # \brief adds a stock id image @@ -2140,15 +2153,16 @@ proc stock_get_image*(stock_id: cstring): ptr TImage{.cdecl, # \return The Image object. # -proc stock_add_image*(stock_id: cstring, img: ptr TImage){.cdecl, +proc stock_add_image*(stock_id: cstring, img: ptr Image){.cdecl, importc: "stock_add_image", dynlib: clarodll.} const CLARO_TEXTAREA_MAXIMUM = (1024 * 1024) type - TTextArea* {.pure.} = object of TWidget + TextArea* {.pure.} = object of Widget text*: array[0..CLARO_TEXTAREA_MAXIMUM - 1, char] +{.deprecated: [TTextArea: TextArea].} #* @@ -2160,8 +2174,8 @@ type # \return A new TextArea widget object. # -proc newtextarea*(parent: ptr TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TTextArea{. +proc newtextarea*(parent: ptr ClaroObj, bounds: ptr Bounds, + flags: cint): ptr TextArea{. cdecl, importc: "textarea_widget_create", dynlib: clarodll.} #* # \brief Sets the text of a textarea @@ -2170,7 +2184,7 @@ proc newtextarea*(parent: ptr TClaroObj, bounds: ptr TBounds, # \param text The new text # -proc textarea_set_text*(obj: ptr TTextArea, text: cstring){.cdecl, +proc textarea_set_text*(obj: ptr TextArea, text: cstring){.cdecl, importc: "textarea_set_text", dynlib: clarodll.} #* # \brief Retrieve the text of a textarea @@ -2179,16 +2193,16 @@ proc textarea_set_text*(obj: ptr TTextArea, text: cstring){.cdecl, # \return Pointer to an internal reference of the text. Should not be changed. # -proc textarea_get_text*(obj: ptr TTextArea): cstring{.cdecl, +proc textarea_get_text*(obj: ptr TextArea): cstring{.cdecl, importc: "textarea_get_text", dynlib: clarodll.} const CLARO_TEXTBOX_MAXIMUM = 8192 type - TTextBox* {.pure.} = object of TWidget + TextBox* {.pure.} = object of Widget text*: array[0..CLARO_TEXTBOX_MAXIMUM-1, char] - +{.deprecated: [TTextBox: TextBox].} const cTextBoxTypePassword* = 1 @@ -2203,8 +2217,8 @@ const # \return A new TextBox widget object. # -proc newtextbox*(parent: ptr TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TTextBox{. +proc newtextbox*(parent: ptr ClaroObj, bounds: ptr Bounds, + flags: cint): ptr TextBox{. cdecl, importc: "textbox_widget_create", dynlib: clarodll.} #* # \brief Sets the text of a textbox @@ -2213,7 +2227,7 @@ proc newtextbox*(parent: ptr TClaroObj, bounds: ptr TBounds, # \param text The new text # -proc textbox_set_text*(obj: ptr TTextBox, text: cstring){.cdecl, +proc textbox_set_text*(obj: ptr TextBox, text: cstring){.cdecl, importc: "textbox_set_text", dynlib: clarodll.} #* # \brief Retrieve the text of a textbox @@ -2222,7 +2236,7 @@ proc textbox_set_text*(obj: ptr TTextBox, text: cstring){.cdecl, # \return Pointer to an internal reference of the text. Should not be changed. # -proc textbox_get_text*(obj: ptr TTextBox): cstring{.cdecl, +proc textbox_get_text*(obj: ptr TextBox): cstring{.cdecl, importc: "textbox_get_text", dynlib: clarodll.} #* # \brief Retrieve the cursor position inside a textbox @@ -2231,7 +2245,7 @@ proc textbox_get_text*(obj: ptr TTextBox): cstring{.cdecl, # \return Cursor position inside TextBox # -proc textbox_get_pos*(obj: ptr TTextBox): cint{.cdecl, +proc textbox_get_pos*(obj: ptr TextBox): cint{.cdecl, importc: "textbox_get_pos", dynlib: clarodll.} #* # \brief Sets the cursor position inside a textbox @@ -2240,7 +2254,7 @@ proc textbox_get_pos*(obj: ptr TTextBox): cint{.cdecl, # \param pos New cursor position inside TextBox # -proc textbox_set_pos*(obj: ptr TTextBox, pos: cint){.cdecl, +proc textbox_set_pos*(obj: ptr TextBox, pos: cint){.cdecl, importc: "textbox_set_pos", dynlib: clarodll.} const @@ -2250,8 +2264,8 @@ const cToolbarAutoSizeButtons* = 4 type - TToolbar* {.pure.} = object of TListWidget - + Toolbar* {.pure.} = object of ListWidget +{.deprecated: [TToolbar: Toolbar].} #* # \brief Creates a ToolBar widget # @@ -2260,7 +2274,7 @@ type # \return A new ToolBar widget object. # -proc newtoolbar*(parent: ptr TClaroObj, flags: cint): ptr TToolbar{.cdecl, +proc newtoolbar*(parent: ptr ClaroObj, flags: cint): ptr Toolbar{.cdecl, importc: "toolbar_widget_create", dynlib: clarodll.} #* # \brief Append a row to a ToolBar widget @@ -2272,8 +2286,8 @@ proc newtoolbar*(parent: ptr TClaroObj, flags: cint): ptr TToolbar{.cdecl, # \return A new list item. # -proc toolbar_append_icon*(toolbar: ptr TToolbar, image: ptr TImage, - title: cstring, tooltip: cstring): ptr TListItem{. +proc toolbar_append_icon*(toolbar: ptr Toolbar, image: ptr Image, + title: cstring, tooltip: cstring): ptr ListItem{. cdecl, importc: "toolbar_append_icon", dynlib: clarodll.} #* # \brief Insert a row into a ToolBar widget @@ -2286,9 +2300,9 @@ proc toolbar_append_icon*(toolbar: ptr TToolbar, image: ptr TImage, # \return A new list item. # -proc toolbar_insert_icon*(toolbar: ptr TToolbar, pos: cint, - image: ptr TImage, title: cstring, - tooltip: cstring): ptr TListItem{. +proc toolbar_insert_icon*(toolbar: ptr Toolbar, pos: cint, + image: ptr Image, title: cstring, + tooltip: cstring): ptr ListItem{. cdecl, importc: "toolbar_insert_icon", dynlib: clarodll.} #* # \brief Append a separator to a ToolBar widget @@ -2297,7 +2311,7 @@ proc toolbar_insert_icon*(toolbar: ptr TToolbar, pos: cint, # \return A new list item. # -proc toolbar_append_separator*(toolbar: ptr TToolbar): ptr TListItem{.cdecl, +proc toolbar_append_separator*(toolbar: ptr Toolbar): ptr ListItem{.cdecl, importc: "toolbar_append_separator", dynlib: clarodll.} #* # \brief Insert a separator into a ToolBar widget @@ -2307,8 +2321,8 @@ proc toolbar_append_separator*(toolbar: ptr TToolbar): ptr TListItem{.cdecl, # \return A new list item. # -proc toolbar_insert_separator*(toolbar: ptr TToolbar, - pos: cint): ptr TListItem {. +proc toolbar_insert_separator*(toolbar: ptr Toolbar, + pos: cint): ptr ListItem {. cdecl, importc: "toolbar_insert_separator", dynlib: clarodll.} #* # \brief Assign a menu widget to an item. @@ -2321,8 +2335,8 @@ proc toolbar_insert_separator*(toolbar: ptr TToolbar, # \param menu Menu widget object, or NULL to remove a menu. # -proc toolbar_set_item_menu*(toolbar: ptr TToolbar, item: ptr TListItem, - menu: ptr TMenu){.cdecl, +proc toolbar_set_item_menu*(toolbar: ptr Toolbar, item: ptr ListItem, + menu: ptr Menu){.cdecl, importc: "toolbar_set_item_menu", dynlib: clarodll.} #* # \brief Move a row in a ToolBar widget @@ -2332,7 +2346,7 @@ proc toolbar_set_item_menu*(toolbar: ptr TToolbar, item: ptr TListItem, # \param row New position to place this item # -proc toolbar_move_icon*(toolbar: ptr TToolbar, item: ptr TListItem, +proc toolbar_move_icon*(toolbar: ptr Toolbar, item: ptr ListItem, row: cint){.cdecl, importc: "toolbar_move_icon", dynlib: clarodll.} #* @@ -2342,7 +2356,7 @@ proc toolbar_move_icon*(toolbar: ptr TToolbar, item: ptr TListItem, # \param item A valid list item # -proc toolbar_remove_icon*(toolbar: ptr TToolbar, item: ptr TListItem){. +proc toolbar_remove_icon*(toolbar: ptr Toolbar, item: ptr ListItem){. cdecl, importc: "toolbar_remove_icon", dynlib: clarodll.} #* # \brief Returns the number of rows in a ToolBar widget @@ -2351,16 +2365,16 @@ proc toolbar_remove_icon*(toolbar: ptr TToolbar, item: ptr TListItem){. # \return Number of rows # -proc toolbar_item_count*(obj: ptr TToolbar): cint{.cdecl, +proc toolbar_item_count*(obj: ptr Toolbar): cint{.cdecl, importc: "toolbar_item_count", dynlib: clarodll.} #* # \brief TreeView widget # type - TTreeview* {.pure.} = object of TListWidget - selected*: ptr TListItem - + Treeview* {.pure.} = object of ListWidget + selected*: ptr ListItem +{.deprecated: [TTreeview: Treeview].} # functions #* @@ -2372,8 +2386,8 @@ type # \return A new TreeView widget object. # -proc newtreeview*(parent: ptr TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TTreeview{. +proc newtreeview*(parent: ptr ClaroObj, bounds: ptr Bounds, + flags: cint): ptr Treeview{. cdecl, importc: "treeview_widget_create", dynlib: clarodll.} #* # \brief Append a row to a TreeView @@ -2385,8 +2399,8 @@ proc newtreeview*(parent: ptr TClaroObj, bounds: ptr TBounds, # \return A new list item. # -proc treeview_append_row*(treeview: ptr TTreeview, parent: ptr TListItem, - image: ptr TImage, title: cstring): ptr TListItem{. +proc treeview_append_row*(treeview: ptr Treeview, parent: ptr ListItem, + image: ptr Image, title: cstring): ptr ListItem{. cdecl, importc: "treeview_append_row", dynlib: clarodll.} #* # \brief Insert a row at the specified position into a TreeView @@ -2399,9 +2413,9 @@ proc treeview_append_row*(treeview: ptr TTreeview, parent: ptr TListItem, # \return A new list item. # -proc treeview_insert_row*(treeview: ptr TTreeview, parent: ptr TListItem, - pos: cint, image: ptr TImage, - title: cstring): ptr TListItem{. +proc treeview_insert_row*(treeview: ptr Treeview, parent: ptr ListItem, + pos: cint, image: ptr Image, + title: cstring): ptr ListItem{. cdecl, importc: "treeview_insert_row", dynlib: clarodll.} #* # \brief Move a row in a TreeView @@ -2411,7 +2425,7 @@ proc treeview_insert_row*(treeview: ptr TTreeview, parent: ptr TListItem, # \param row New position to place this item # -proc treeview_move_row*(treeview: ptr TTreeview, item: ptr TListItem, +proc treeview_move_row*(treeview: ptr Treeview, item: ptr ListItem, row: cint){.cdecl, importc: "treeview_move_row", dynlib: clarodll.} #* @@ -2421,7 +2435,7 @@ proc treeview_move_row*(treeview: ptr TTreeview, item: ptr TListItem, # \param item A valid list item # -proc treeview_remove_row*(treeview: ptr TTreeview, item: ptr TListItem){. +proc treeview_remove_row*(treeview: ptr Treeview, item: ptr ListItem){. cdecl, importc: "treeview_remove_row", dynlib: clarodll.} #* # \brief Expand a row in a TreeView @@ -2430,7 +2444,7 @@ proc treeview_remove_row*(treeview: ptr TTreeview, item: ptr TListItem){. # \param item A valid list item # -proc treeview_expand*(treeview: ptr TTreeview, item: ptr TListItem){.cdecl, +proc treeview_expand*(treeview: ptr Treeview, item: ptr ListItem){.cdecl, importc: "treeview_expand", dynlib: clarodll.} #* # \brief Collapse a row in a TreeView @@ -2439,7 +2453,7 @@ proc treeview_expand*(treeview: ptr TTreeview, item: ptr TListItem){.cdecl, # \param item A valid list item # -proc treeview_collapse*(treeview: ptr TTreeview, item: ptr TListItem){.cdecl, +proc treeview_collapse*(treeview: ptr Treeview, item: ptr ListItem){.cdecl, importc: "treeview_collapse", dynlib: clarodll.} #* # \brief Returns the currently selected TreeView item @@ -2448,7 +2462,7 @@ proc treeview_collapse*(treeview: ptr TTreeview, item: ptr TListItem){.cdecl, # \return The currently selected TreeView item, or NULL if no item is selected. # -proc treeview_get_selected*(obj: ptr TTreeview): ptr TListItem{.cdecl, +proc treeview_get_selected*(obj: ptr Treeview): ptr ListItem{.cdecl, importc: "treeview_get_selected", dynlib: clarodll.} #* # \brief Returns the number of rows in a TreeView @@ -2459,7 +2473,7 @@ proc treeview_get_selected*(obj: ptr TTreeview): ptr TListItem{.cdecl, # \return Number of rows # -proc treeview_get_rows*(obj: ptr TTreeview, parent: ptr TListItem): cint{. +proc treeview_get_rows*(obj: ptr Treeview, parent: ptr ListItem): cint{. cdecl, importc: "treeview_get_rows", dynlib: clarodll.} #* # \brief Selects a row in a TreeView @@ -2468,7 +2482,7 @@ proc treeview_get_rows*(obj: ptr TTreeview, parent: ptr TListItem): cint{. # \param item A valid list item # -proc treeview_select_item*(obj: ptr TTreeview, item: ptr TListItem){.cdecl, +proc treeview_select_item*(obj: ptr Treeview, item: ptr ListItem){.cdecl, importc: "treeview_select_item", dynlib: clarodll.} const @@ -2477,15 +2491,15 @@ const cWindowNoResizing* = 4 type - TWindow* {.pure.} = object of TWidget + Window* {.pure.} = object of Widget title*: array[0..512 - 1, char] - icon*: ptr TImage - menubar*: ptr TWidget - workspace*: ptr TWidget + icon*: ptr Image + menubar*: ptr Widget + workspace*: ptr Widget exsp_tools*: cint exsp_status*: cint exsp_init*: cint - +{.deprecated: [TWindow: Window].} const cWindowFixedSize* = 1 @@ -2500,8 +2514,8 @@ const # \return A new Window widget object. # -proc newwindow*(parent: ptr TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TWindow {. +proc newwindow*(parent: ptr ClaroObj, bounds: ptr Bounds, + flags: cint): ptr Window {. cdecl, importc: "window_widget_create", dynlib: clarodll.} #* # \brief Sets a Window's title @@ -2510,7 +2524,7 @@ proc newwindow*(parent: ptr TClaroObj, bounds: ptr TBounds, # \param title The new title for the window # -proc window_set_title*(w: ptr TWindow, title: cstring){.cdecl, +proc window_set_title*(w: ptr Window, title: cstring){.cdecl, importc: "window_set_title", dynlib: clarodll.} #* # \brief Makes a window visible @@ -2518,7 +2532,7 @@ proc window_set_title*(w: ptr TWindow, title: cstring){.cdecl, # \param w A valid Window widget object # -proc window_show*(w: ptr TWindow){.cdecl, importc: "window_show", +proc window_show*(w: ptr Window){.cdecl, importc: "window_show", dynlib: clarodll.} #* # \brief Makes a window invisible @@ -2526,7 +2540,7 @@ proc window_show*(w: ptr TWindow){.cdecl, importc: "window_show", # \param w A valid Window widget object # -proc window_hide*(w: ptr TWindow){.cdecl, importc: "window_hide", +proc window_hide*(w: ptr Window){.cdecl, importc: "window_hide", dynlib: clarodll.} #* # \brief Gives focus to a window @@ -2534,7 +2548,7 @@ proc window_hide*(w: ptr TWindow){.cdecl, importc: "window_hide", # \param w A valid Window widget object # -proc window_focus*(w: ptr TWindow){.cdecl, importc: "window_focus", +proc window_focus*(w: ptr Window){.cdecl, importc: "window_focus", dynlib: clarodll.} #* # \brief Maximises a window @@ -2542,7 +2556,7 @@ proc window_focus*(w: ptr TWindow){.cdecl, importc: "window_focus", # \param w A valid Window widget object # -proc window_maximize*(w: ptr TWindow){.cdecl, importc: "window_maximise", +proc window_maximize*(w: ptr Window){.cdecl, importc: "window_maximise", dynlib: clarodll.} #* # \brief Minimises a window @@ -2550,7 +2564,7 @@ proc window_maximize*(w: ptr TWindow){.cdecl, importc: "window_maximise", # \param w A valid Window widget object # -proc window_minimize*(w: ptr TWindow){.cdecl, importc: "window_minimise", +proc window_minimize*(w: ptr Window){.cdecl, importc: "window_minimise", dynlib: clarodll.} #* # \brief Restores a window @@ -2558,7 +2572,7 @@ proc window_minimize*(w: ptr TWindow){.cdecl, importc: "window_minimise", # \param w A valid Window widget object # -proc window_restore*(w: ptr TWindow){.cdecl, importc: "window_restore", +proc window_restore*(w: ptr Window){.cdecl, importc: "window_restore", dynlib: clarodll.} #* # \brief Sets a window's icon @@ -2567,7 +2581,7 @@ proc window_restore*(w: ptr TWindow){.cdecl, importc: "window_restore", # \param icon A valid Image object # -proc window_set_icon*(w: ptr TWindow, icon: ptr TImage){.cdecl, +proc window_set_icon*(w: ptr Window, icon: ptr Image){.cdecl, importc: "window_set_icon", dynlib: clarodll.} const @@ -2575,13 +2589,13 @@ const cWorkspaceTileVertically* = 1 type - TWorkspace*{.pure.} = object of TWidget + Workspace*{.pure.} = object of Widget - TWorkspaceWindow*{.pure.} = object of TWidget - icon*: ptr TImage + WorkspaceWindow*{.pure.} = object of Widget + icon*: ptr Image title*: array[0..512 - 1, char] - workspace*: ptr TWorkspace - + workspace*: ptr Workspace +{.deprecated: [TWorkspace: Workspace, TWorkspaceWindow: WorkspaceWindow].} # functions (workspace) #* @@ -2593,8 +2607,8 @@ type # \return A new Workspace widget object. # -proc newworkspace*(parent: ptr TClaroObj, bounds: ptr TBounds, - flags: cint): ptr TWorkspace{. +proc newworkspace*(parent: ptr ClaroObj, bounds: ptr Bounds, + flags: cint): ptr Workspace{. cdecl, importc: "workspace_widget_create", dynlib: clarodll.} #* # \brief Sets the active (visible) workspace child @@ -2603,7 +2617,7 @@ proc newworkspace*(parent: ptr TClaroObj, bounds: ptr TBounds, # \param child A valid workspace window widget # -proc workspace_set_active*(workspace: ptr TWorkspace, child: ptr TClaroObj){. +proc workspace_set_active*(workspace: ptr Workspace, child: ptr ClaroObj){. cdecl, importc: "workspace_set_active", dynlib: clarodll.} #* # \brief Returns the active (visible) workspace child @@ -2612,7 +2626,7 @@ proc workspace_set_active*(workspace: ptr TWorkspace, child: ptr TClaroObj){. # \return The active workspace window widget # -proc workspace_get_active*(workspace: ptr TWorkspace): ptr TWorkspace{.cdecl, +proc workspace_get_active*(workspace: ptr Workspace): ptr Workspace{.cdecl, importc: "workspace_get_active", dynlib: clarodll.} #* # \brief Cascades all workspace windows @@ -2620,7 +2634,7 @@ proc workspace_get_active*(workspace: ptr TWorkspace): ptr TWorkspace{.cdecl, # \param workspace A valid workspace widget # -proc workspace_cascade*(workspace: ptr TWorkspace){.cdecl, +proc workspace_cascade*(workspace: ptr Workspace){.cdecl, importc: "workspace_cascade", dynlib: clarodll.} #* # \brief Tiles all workspace windows @@ -2629,7 +2643,7 @@ proc workspace_cascade*(workspace: ptr TWorkspace){.cdecl, # \param dir The direction to tile child widgets # -proc workspace_tile*(workspace: ptr TWorkspace, dir: cint){.cdecl, +proc workspace_tile*(workspace: ptr Workspace, dir: cint){.cdecl, importc: "workspace_tile", dynlib: clarodll.} # functions (workspace_window) #* @@ -2641,9 +2655,9 @@ proc workspace_tile*(workspace: ptr TWorkspace, dir: cint){.cdecl, # \return A new Workspace widget object. # -proc newWorkspaceWindow*(parent: ptr TClaroObj, - bounds: ptr TBounds, - flags: cint): ptr TWorkspaceWindow{. +proc newWorkspaceWindow*(parent: ptr ClaroObj, + bounds: ptr Bounds, + flags: cint): ptr WorkspaceWindow{. cdecl, importc: "workspace_window_widget_create", dynlib: clarodll.} #* # \brief Sets the title of a Workspace Window widget @@ -2652,7 +2666,7 @@ proc newWorkspaceWindow*(parent: ptr TClaroObj, # \param title The new title for the widget # -proc workspace_window_set_title*(window: ptr TWorkspaceWindow, +proc workspace_window_set_title*(window: ptr WorkspaceWindow, title: cstring){.cdecl, importc: "workspace_window_set_title", dynlib: clarodll.} #* @@ -2661,7 +2675,7 @@ proc workspace_window_set_title*(window: ptr TWorkspaceWindow, # \param window A valid Workspace Window widget # -proc workspace_window_show*(window: ptr TWorkspaceWindow){.cdecl, +proc workspace_window_show*(window: ptr WorkspaceWindow){.cdecl, importc: "workspace_window_show", dynlib: clarodll.} #* # \brief Makes a Workspace Window widget invisible @@ -2669,7 +2683,7 @@ proc workspace_window_show*(window: ptr TWorkspaceWindow){.cdecl, # \param window A valid Workspace Window widget # -proc workspace_window_hide*(window: ptr TWorkspaceWindow){.cdecl, +proc workspace_window_hide*(window: ptr WorkspaceWindow){.cdecl, importc: "workspace_window_hide", dynlib: clarodll.} #* # \brief Restores a Workspace Window widget @@ -2677,7 +2691,7 @@ proc workspace_window_hide*(window: ptr TWorkspaceWindow){.cdecl, # \param window A valid Workspace Window widget # -proc workspace_window_restore*(window: ptr TWorkspaceWindow){.cdecl, +proc workspace_window_restore*(window: ptr WorkspaceWindow){.cdecl, importc: "workspace_window_restore", dynlib: clarodll.} # American spelling @@ -2687,7 +2701,7 @@ proc workspace_window_restore*(window: ptr TWorkspaceWindow){.cdecl, # \param window A valid Workspace Window widget # -proc workspace_window_minimize*(window: ptr TWorkspaceWindow){.cdecl, +proc workspace_window_minimize*(window: ptr WorkspaceWindow){.cdecl, importc: "workspace_window_minimise", dynlib: clarodll.} #* # \brief Maxmimises a Workspace Window widget @@ -2695,7 +2709,7 @@ proc workspace_window_minimize*(window: ptr TWorkspaceWindow){.cdecl, # \param window A valid Workspace Window widget # -proc workspace_window_maximize*(window: ptr TWorkspaceWindow){.cdecl, +proc workspace_window_maximize*(window: ptr WorkspaceWindow){.cdecl, importc: "workspace_window_maximise", dynlib: clarodll.} #* # \brief Sets the icon of a Workspace Window widget @@ -2704,7 +2718,7 @@ proc workspace_window_maximize*(window: ptr TWorkspaceWindow){.cdecl, # \param icon A valid Image object. # -proc workspace_window_set_icon*(w: ptr TWorkspaceWindow, icon: ptr TImage){. +proc workspace_window_set_icon*(w: ptr WorkspaceWindow, icon: ptr Image){. cdecl, importc: "workspace_window_set_icon", dynlib: clarodll.} claro_base_init() @@ -2720,9 +2734,9 @@ when not defined(testing) and isMainModule: var b = newButton(w, new_bounds(40, 45, 150, -1), 0, "Push my button!") - proc push_my_button(obj: ptr TClaroObj, event: ptr TEvent) {.cdecl.} = + proc push_my_button(obj: ptr ClaroObj, event: ptr Event) {.cdecl.} = textbox_set_text(t, "You pushed my button!") - var button = cast[ptr TButton](obj) + var button = cast[ptr Button](obj) button_set_text(button, "Ouch!") object_addhandler(b, "pushed", push_my_button) diff --git a/lib/wrappers/expat.nim b/lib/wrappers/expat.nim index a3d888201..e1897e2b4 100644 --- a/lib/wrappers/expat.nim +++ b/lib/wrappers/expat.nim @@ -13,9 +13,9 @@ when not defined(expatDll): const expatDll = "libexpat.so(.1|)" type - TParserStruct{.pure, final.} = object + ParserStruct{.pure, final.} = object - PParser* = ptr TParserStruct + PParser* = ptr ParserStruct # The XML_Status enum gives the possible return values for several # API functions. The preprocessor #defines are included so this @@ -30,11 +30,12 @@ type # Otherwise, the #define hackery is quite ugly and would have been # dropped. # +{.deprecated: [TParserStruct: ParserStruct].} type - TStatus*{.size: sizeof(cint).} = enum + Status*{.size: sizeof(cint).} = enum STATUS_ERROR = 0, STATUS_OK = 1, STATUS_SUSPENDED = 2 - TError*{.size: sizeof(cint).} = enum + Error*{.size: sizeof(cint).} = enum ERROR_NONE, ERROR_NO_MEMORY, ERROR_SYNTAX, ERROR_NO_ELEMENTS, ERROR_INVALID_TOKEN, ERROR_UNCLOSED_TOKEN, ERROR_PARTIAL_CHAR, ERROR_TAG_MISMATCH, ERROR_DUPLICATE_ATTRIBUTE, @@ -52,10 +53,12 @@ type ERROR_ABORTED, ERROR_FINISHED, ERROR_SUSPEND_PE, ERROR_RESERVED_PREFIX_XML, ERROR_RESERVED_PREFIX_XMLNS, ERROR_RESERVED_NAMESPACE_URI - TContent_Type*{.size: sizeof(cint).} = enum + ContentType*{.size: sizeof(cint).} = enum CTYPE_EMPTY = 1, CTYPE_ANY, CTYPE_MIXED, CTYPE_NAME, CTYPE_CHOICE, CTYPE_SEQ - TContent_Quant*{.size: sizeof(cint).} = enum + ContentQuant*{.size: sizeof(cint).} = enum CQUANT_NONE, CQUANT_OPT, CQUANT_REP, CQUANT_PLUS +{.deprecated: [TStatus: Status, TError: Error, TContent_Type: ContentType, + TContent_Quant: ContentQuant].} # If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be # XML_CQUANT_NONE, and the other fields will be zero or NULL. @@ -76,13 +79,13 @@ type # type - TContent*{.pure, final.} = object - typ*: TContentType - quant*: TContentQuant + Content*{.pure, final.} = object + typ*: ContentType + quant*: ContentQuant name*: cstring numchildren*: cint - children*: ptr TContent - + children*: ptr Content +{.deprecated: [TContent: Content].} # This is called for an element declaration. See above for # description of the model argument. It's the caller's responsibility @@ -90,10 +93,11 @@ type # type - TElementDeclHandler* = proc (userData: pointer, name: cstring, - model: ptr TContent){.cdecl.} + ElementDeclHandler* = proc (userData: pointer, name: cstring, + model: ptr Content){.cdecl.} +{.deprecated: [TElementDeclHandler: ElementDeclHandler].} -proc setElementDeclHandler*(parser: PParser, eldecl: TElementDeclHandler){. +proc setElementDeclHandler*(parser: PParser, eldecl: ElementDeclHandler){. cdecl, importc: "XML_SetElementDeclHandler", dynlib: expatDll.} # The Attlist declaration handler is called for *each* attribute. So # a single Attlist declaration with multiple attributes declared will @@ -105,11 +109,12 @@ proc setElementDeclHandler*(parser: PParser, eldecl: TElementDeclHandler){. # type - TAttlistDeclHandler* = proc (userData: pointer, elname: cstring, + AttlistDeclHandler* = proc (userData: pointer, elname: cstring, attname: cstring, attType: cstring, dflt: cstring, isrequired: cint){.cdecl.} +{.deprecated: [TAttlistDeclHandler: AttlistDeclHandler].} -proc setAttlistDeclHandler*(parser: PParser, attdecl: TAttlistDeclHandler){. +proc setAttlistDeclHandler*(parser: PParser, attdecl: AttlistDeclHandler){. cdecl, importc: "XML_SetAttlistDeclHandler", dynlib: expatDll.} # The XML declaration handler is called for *both* XML declarations # and text declarations. The way to distinguish is that the version @@ -121,17 +126,18 @@ proc setAttlistDeclHandler*(parser: PParser, attdecl: TAttlistDeclHandler){. # type - TXmlDeclHandler* = proc (userData: pointer, version: cstring, + XmlDeclHandler* = proc (userData: pointer, version: cstring, encoding: cstring, standalone: cint){.cdecl.} +{.deprecated: [TXmlDeclHandler: XmlDeclHandler].} -proc setXmlDeclHandler*(parser: PParser, xmldecl: TXmlDeclHandler){.cdecl, +proc setXmlDeclHandler*(parser: PParser, xmldecl: XmlDeclHandler){.cdecl, importc: "XML_SetXmlDeclHandler", dynlib: expatDll.} type - TMemory_Handling_Suite*{.pure, final.} = object + Memory_Handling_Suite*{.pure, final.} = object mallocFcn*: proc (size: int): pointer{.cdecl.} reallocFcn*: proc (p: pointer, size: int): pointer{.cdecl.} freeFcn*: proc (p: pointer){.cdecl.} - +{.deprecated: [TMemory_Handling_Suite: MemoryHandlingSuite].} # Constructs a new parser; encoding is the encoding specified by the # external protocol or NULL if there is none specified. @@ -183,29 +189,33 @@ proc parserReset*(parser: PParser, encoding: cstring): bool{.cdecl, # type - TStartElementHandler* = proc (userData: pointer, name: cstring, + StartElementHandler* = proc (userData: pointer, name: cstring, atts: cstringArray){.cdecl.} - TEndElementHandler* = proc (userData: pointer, name: cstring){.cdecl.} - + EndElementHandler* = proc (userData: pointer, name: cstring){.cdecl.} +{.deprecated: [TStartElementHandler: StartElementHandler, + TEndElementHandler: EndElementHandler].} # s is not 0 terminated. type - TCharacterDataHandler* = proc (userData: pointer, s: cstring, len: cint){. + CharacterDataHandler* = proc (userData: pointer, s: cstring, len: cint){. cdecl.} - +{.deprecated: [TCharacterDataHandler: CharacterDataHandler].} # target and data are 0 terminated type - TProcessingInstructionHandler* = proc (userData: pointer, target: cstring, + ProcessingInstructionHandler* = proc (userData: pointer, target: cstring, data: cstring){.cdecl.} +{.deprecated: [TProcessingInstructionHandler: ProcessingInstructionHandler].} # data is 0 terminated type - TCommentHandler* = proc (userData: pointer, data: cstring){.cdecl.} - TStartCdataSectionHandler* = proc (userData: pointer){.cdecl.} - TEndCdataSectionHandler* = proc (userData: pointer){.cdecl.} - + CommentHandler* = proc (userData: pointer, data: cstring){.cdecl.} + StartCdataSectionHandler* = proc (userData: pointer){.cdecl.} + EndCdataSectionHandler* = proc (userData: pointer){.cdecl.} +{.deprecated: [TCommentHandler: CommentHandler, + TStartCdataSectionHandler: StartCdataSectionHandler, + TEndCdataSectionHandler: EndCdataSectionHandler].} # This is called for any characters in the XML document for which # there is no applicable handler. This includes both characters that # are part of markup which is of a kind that is not reported @@ -221,16 +231,17 @@ type # type - TDefaultHandler* = proc (userData: pointer, s: cstring, len: cint){.cdecl.} - + DefaultHandler* = proc (userData: pointer, s: cstring, len: cint){.cdecl.} +{.deprecated: [TDefaultHandler: DefaultHandler].} # This is called for the start of the DOCTYPE declaration, before # any DTD or internal subset is parsed. # type - TStartDoctypeDeclHandler* = proc (userData: pointer, doctypeName: cstring, + StartDoctypeDeclHandler* = proc (userData: pointer, doctypeName: cstring, sysid: cstring, pubid: cstring, hasInternalSubset: cint){.cdecl.} +{.deprecated: [TStartDoctypeDeclHandler: StartDoctypeDeclHandler].} # This is called for the start of the DOCTYPE declaration when the # closing > is encountered, but after processing any external @@ -238,7 +249,8 @@ type # type - TEndDoctypeDeclHandler* = proc (userData: pointer){.cdecl.} + EndDoctypeDeclHandler* = proc (userData: pointer){.cdecl.} +{.deprecated: [TEndDoctypeDeclHandler: EndDoctypeDeclHandler].} # This is called for entity declarations. The is_parameter_entity # argument will be non-zero if the entity is a parameter entity, zero @@ -260,13 +272,14 @@ type # type - TEntityDeclHandler* = proc (userData: pointer, entityName: cstring, + EntityDeclHandler* = proc (userData: pointer, entityName: cstring, isParameterEntity: cint, value: cstring, valueLength: cint, base: cstring, systemId: cstring, publicId: cstring, notationName: cstring){.cdecl.} +{.deprecated: [TEntityDeclHandler: EntityDeclHandler].} -proc setEntityDeclHandler*(parser: PParser, handler: TEntityDeclHandler){.cdecl, +proc setEntityDeclHandler*(parser: PParser, handler: EntityDeclHandler){.cdecl, importc: "XML_SetEntityDeclHandler", dynlib: expatDll.} # OBSOLETE -- OBSOLETE -- OBSOLETE # This handler has been superceded by the EntityDeclHandler above. @@ -279,10 +292,11 @@ proc setEntityDeclHandler*(parser: PParser, handler: TEntityDeclHandler){.cdecl, # type - TUnparsedEntityDeclHandler* = proc (userData: pointer, entityName: cstring, + UnparsedEntityDeclHandler* = proc (userData: pointer, entityName: cstring, base: cstring, systemId: cstring, publicId, notationName: cstring){. cdecl.} +{.deprecated: [TUnparsedEntityDeclHandler: UnparsedEntityDeclHandler].} # This is called for a declaration of notation. The base argument is # whatever was set by XML_SetBase. The notationName will never be @@ -290,9 +304,10 @@ type # type - TNotationDeclHandler* = proc (userData: pointer, notationName: cstring, + NotationDeclHandler* = proc (userData: pointer, notationName: cstring, base: cstring, systemId: cstring, publicId: cstring){.cdecl.} +{.deprecated: [TNotationDeclHandler: NotationDeclHandler].} # When namespace processing is enabled, these are called once for # each namespace declaration. The call to the start and end element @@ -302,10 +317,11 @@ type # type - TStartNamespaceDeclHandler* = proc (userData: pointer, prefix: cstring, + StartNamespaceDeclHandler* = proc (userData: pointer, prefix: cstring, uri: cstring){.cdecl.} - TEndNamespaceDeclHandler* = proc (userData: pointer, prefix: cstring){.cdecl.} - + EndNamespaceDeclHandler* = proc (userData: pointer, prefix: cstring){.cdecl.} +{.deprecated: [TStartNamespaceDeclHandler: StartNamespaceDeclHandler, + TEndNamespaceDeclHandler: EndNamespaceDeclHandler].} # This is called if the document is not standalone, that is, it has an # external subset or a reference to a parameter entity, but does not # have standalone="yes". If this handler returns XML_STATUS_ERROR, @@ -317,7 +333,8 @@ type # type - TNotStandaloneHandler* = proc (userData: pointer): cint{.cdecl.} + NotStandaloneHandler* = proc (userData: pointer): cint{.cdecl.} +{.deprecated: [TNotStandaloneHandler: NotStandaloneHandler].} # This is called for a reference to an external parsed general # entity. The referenced entity is not automatically parsed. The @@ -355,10 +372,10 @@ type # type - TExternalEntityRefHandler* = proc (parser: PParser, context: cstring, + ExternalEntityRefHandler* = proc (parser: PParser, context: cstring, base: cstring, systemId: cstring, publicId: cstring): cint{.cdecl.} - +{.deprecated: [TExternalEntityRefHandler: ExternalEntityRefHandler].} # This is called in two situations: # 1) An entity reference is encountered for which no declaration # has been read *and* this is not an error. @@ -371,8 +388,9 @@ type # type - TSkippedEntityHandler* = proc (userData: pointer, entityName: cstring, + SkippedEntityHandler* = proc (userData: pointer, entityName: cstring, isParameterEntity: cint){.cdecl.} +{.deprecated: [TSkippedEntityHandler: SkippedEntityHandler].} # This structure is filled in by the XML_UnknownEncodingHandler to # provide information to the parser about encodings that are unknown @@ -428,11 +446,12 @@ type # type - TEncoding*{.pure, final.} = object + Encoding*{.pure, final.} = object map*: array[0..256 - 1, cint] data*: pointer convert*: proc (data: pointer, s: cstring): cint{.cdecl.} release*: proc (data: pointer){.cdecl.} +{.deprecated: [TEncoding: Encoding].} # This is called for an encoding that is unknown to the parser. @@ -452,74 +471,75 @@ type # type - TUnknownEncodingHandler* = proc (encodingHandlerData: pointer, name: cstring, - info: ptr TEncoding): cint{.cdecl.} + UnknownEncodingHandler* = proc (encodingHandlerData: pointer, name: cstring, + info: ptr Encoding): cint{.cdecl.} +{.deprecated: [TUnknownEncodingHandler: UnknownEncodingHandler].} -proc setElementHandler*(parser: PParser, start: TStartElementHandler, - endHandler: TEndElementHandler){.cdecl, +proc setElementHandler*(parser: PParser, start: StartElementHandler, + endHandler: EndElementHandler){.cdecl, importc: "XML_SetElementHandler", dynlib: expatDll.} -proc setStartElementHandler*(parser: PParser, handler: TStartElementHandler){. +proc setStartElementHandler*(parser: PParser, handler: StartElementHandler){. cdecl, importc: "XML_SetStartElementHandler", dynlib: expatDll.} -proc setEndElementHandler*(parser: PParser, handler: TEndElementHandler){.cdecl, +proc setEndElementHandler*(parser: PParser, handler: EndElementHandler){.cdecl, importc: "XML_SetEndElementHandler", dynlib: expatDll.} -proc setCharacterDataHandler*(parser: PParser, handler: TCharacterDataHandler){. +proc setCharacterDataHandler*(parser: PParser, handler: CharacterDataHandler){. cdecl, importc: "XML_SetCharacterDataHandler", dynlib: expatDll.} proc setProcessingInstructionHandler*(parser: PParser, - handler: TProcessingInstructionHandler){. + handler: ProcessingInstructionHandler){. cdecl, importc: "XML_SetProcessingInstructionHandler", dynlib: expatDll.} -proc setCommentHandler*(parser: PParser, handler: TCommentHandler){.cdecl, +proc setCommentHandler*(parser: PParser, handler: CommentHandler){.cdecl, importc: "XML_SetCommentHandler", dynlib: expatDll.} -proc setCdataSectionHandler*(parser: PParser, start: TStartCdataSectionHandler, - endHandler: TEndCdataSectionHandler){.cdecl, +proc setCdataSectionHandler*(parser: PParser, start: StartCdataSectionHandler, + endHandler: EndCdataSectionHandler){.cdecl, importc: "XML_SetCdataSectionHandler", dynlib: expatDll.} proc setStartCdataSectionHandler*(parser: PParser, - start: TStartCdataSectionHandler){.cdecl, + start: StartCdataSectionHandler){.cdecl, importc: "XML_SetStartCdataSectionHandler", dynlib: expatDll.} proc setEndCdataSectionHandler*(parser: PParser, - endHandler: TEndCdataSectionHandler){.cdecl, + endHandler: EndCdataSectionHandler){.cdecl, importc: "XML_SetEndCdataSectionHandler", dynlib: expatDll.} # This sets the default handler and also inhibits expansion of # internal entities. These entity references will be passed to the # default handler, or to the skipped entity handler, if one is set. # -proc setDefaultHandler*(parser: PParser, handler: TDefaultHandler){.cdecl, +proc setDefaultHandler*(parser: PParser, handler: DefaultHandler){.cdecl, importc: "XML_SetDefaultHandler", dynlib: expatDll.} # This sets the default handler but does not inhibit expansion of # internal entities. The entity reference will not be passed to the # default handler. # -proc setDefaultHandlerExpand*(parser: PParser, handler: TDefaultHandler){.cdecl, +proc setDefaultHandlerExpand*(parser: PParser, handler: DefaultHandler){.cdecl, importc: "XML_SetDefaultHandlerExpand", dynlib: expatDll.} -proc setDoctypeDeclHandler*(parser: PParser, start: TStartDoctypeDeclHandler, - endHandler: TEndDoctypeDeclHandler){.cdecl, +proc setDoctypeDeclHandler*(parser: PParser, start: StartDoctypeDeclHandler, + endHandler: EndDoctypeDeclHandler){.cdecl, importc: "XML_SetDoctypeDeclHandler", dynlib: expatDll.} proc setStartDoctypeDeclHandler*(parser: PParser, - start: TStartDoctypeDeclHandler){.cdecl, + start: StartDoctypeDeclHandler){.cdecl, importc: "XML_SetStartDoctypeDeclHandler", dynlib: expatDll.} proc setEndDoctypeDeclHandler*(parser: PParser, - endHandler: TEndDoctypeDeclHandler){.cdecl, + endHandler: EndDoctypeDeclHandler){.cdecl, importc: "XML_SetEndDoctypeDeclHandler", dynlib: expatDll.} proc setUnparsedEntityDeclHandler*(parser: PParser, - handler: TUnparsedEntityDeclHandler){.cdecl, + handler: UnparsedEntityDeclHandler){.cdecl, importc: "XML_SetUnparsedEntityDeclHandler", dynlib: expatDll.} -proc setNotationDeclHandler*(parser: PParser, handler: TNotationDeclHandler){. +proc setNotationDeclHandler*(parser: PParser, handler: NotationDeclHandler){. cdecl, importc: "XML_SetNotationDeclHandler", dynlib: expatDll.} proc setNamespaceDeclHandler*(parser: PParser, - start: TStartNamespaceDeclHandler, - endHandler: TEndNamespaceDeclHandler){.cdecl, + start: StartNamespaceDeclHandler, + endHandler: EndNamespaceDeclHandler){.cdecl, importc: "XML_SetNamespaceDeclHandler", dynlib: expatDll.} proc setStartNamespaceDeclHandler*(parser: PParser, - start: TStartNamespaceDeclHandler){.cdecl, + start: StartNamespaceDeclHandler){.cdecl, importc: "XML_SetStartNamespaceDeclHandler", dynlib: expatDll.} proc setEndNamespaceDeclHandler*(parser: PParser, - endHandler: TEndNamespaceDeclHandler){.cdecl, + endHandler: EndNamespaceDeclHandler){.cdecl, importc: "XML_SetEndNamespaceDeclHandler", dynlib: expatDll.} -proc setNotStandaloneHandler*(parser: PParser, handler: TNotStandaloneHandler){. +proc setNotStandaloneHandler*(parser: PParser, handler: NotStandaloneHandler){. cdecl, importc: "XML_SetNotStandaloneHandler", dynlib: expatDll.} proc setExternalEntityRefHandler*(parser: PParser, - handler: TExternalEntityRefHandler){.cdecl, + handler: ExternalEntityRefHandler){.cdecl, importc: "XML_SetExternalEntityRefHandler", dynlib: expatDll.} # If a non-NULL value for arg is specified here, then it will be # passed as the first argument to the external entity ref handler @@ -528,10 +548,10 @@ proc setExternalEntityRefHandler*(parser: PParser, proc setExternalEntityRefHandlerArg*(parser: PParser, arg: pointer){.cdecl, importc: "XML_SetExternalEntityRefHandlerArg", dynlib: expatDll.} -proc setSkippedEntityHandler*(parser: PParser, handler: TSkippedEntityHandler){. +proc setSkippedEntityHandler*(parser: PParser, handler: SkippedEntityHandler){. cdecl, importc: "XML_SetSkippedEntityHandler", dynlib: expatDll.} proc setUnknownEncodingHandler*(parser: PParser, - handler: TUnknownEncodingHandler, + handler: UnknownEncodingHandler, encodingHandlerData: pointer){.cdecl, importc: "XML_SetUnknownEncodingHandler", dynlib: expatDll.} # This can be called within a handler for a start element, end @@ -573,7 +593,7 @@ template getUserData*(parser: expr): expr = # has no effect and returns XML_STATUS_ERROR. # -proc setEncoding*(parser: PParser, encoding: cstring): TStatus{.cdecl, +proc setEncoding*(parser: PParser, encoding: cstring): Status{.cdecl, importc: "XML_SetEncoding", dynlib: expatDll.} # If this function is called, then the parser will be passed as the # first argument to callbacks instead of userData. The userData will @@ -601,7 +621,7 @@ proc useParserAsHandlerArg*(parser: PParser){.cdecl, # XML_ERROR_FEATURE_REQUIRES_XML_DTD. # -proc useForeignDTD*(parser: PParser, useDTD: bool): TError{.cdecl, +proc useForeignDTD*(parser: PParser, useDTD: bool): Error{.cdecl, importc: "XML_UseForeignDTD", dynlib: expatDll.} # Sets the base to be used for resolving relative URIs in system # identifiers in declarations. Resolving relative identifiers is @@ -612,7 +632,7 @@ proc useForeignDTD*(parser: PParser, useDTD: bool): TError{.cdecl, # XML_STATUS_OK otherwise. # -proc setBase*(parser: PParser, base: cstring): TStatus{.cdecl, +proc setBase*(parser: PParser, base: cstring): Status{.cdecl, importc: "XML_SetBase", dynlib: expatDll.} proc getBase*(parser: PParser): cstring{.cdecl, importc: "XML_GetBase", dynlib: expatDll.} @@ -643,11 +663,11 @@ proc getIdAttributeIndex*(parser: PParser): cint{.cdecl, # values. # -proc parse*(parser: PParser, s: cstring, len: cint, isFinal: cint): TStatus{. +proc parse*(parser: PParser, s: cstring, len: cint, isFinal: cint): Status{. cdecl, importc: "XML_Parse", dynlib: expatDll.} proc getBuffer*(parser: PParser, len: cint): pointer{.cdecl, importc: "XML_GetBuffer", dynlib: expatDll.} -proc parseBuffer*(parser: PParser, len: cint, isFinal: cint): TStatus{.cdecl, +proc parseBuffer*(parser: PParser, len: cint, isFinal: cint): Status{.cdecl, importc: "XML_ParseBuffer", dynlib: expatDll.} # Stops parsing, causing XML_Parse() or XML_ParseBuffer() to return. # Must be called from within a call-back handler, except when aborting @@ -681,7 +701,7 @@ proc parseBuffer*(parser: PParser, len: cint, isFinal: cint): TStatus{.cdecl, # When suspended, parsing can be resumed by calling XML_ResumeParser(). # -proc stopParser*(parser: PParser, resumable: bool): TStatus{.cdecl, +proc stopParser*(parser: PParser, resumable: bool): Status{.cdecl, importc: "XML_StopParser", dynlib: expatDll.} # Resumes parsing after it has been suspended with XML_StopParser(). # Must not be called from within a handler call-back. Returns same @@ -696,15 +716,16 @@ proc stopParser*(parser: PParser, resumable: bool): TStatus{.cdecl, # application to call XML_ResumeParser() on it at the appropriate moment. # -proc resumeParser*(parser: PParser): TStatus{.cdecl, +proc resumeParser*(parser: PParser): Status{.cdecl, importc: "XML_ResumeParser", dynlib: expatDll.} type TParsing* = enum INITIALIZED, PARSING, FINISHED, SUSPENDED - TParsingStatus*{.pure, final.} = object + ParsingStatus*{.pure, final.} = object parsing*: TParsing finalBuffer*: bool - +{.deprecated: [#TParsing: Parsing, # Naming conflict if we drop the `T` + TParsingStatus: ParsingStatus].} # Returns status of parser with respect to being initialized, parsing, # finished, or suspended and processing the final buffer. @@ -712,7 +733,7 @@ type # XXX with XML_FINISHED_OK or XML_FINISHED_ERROR replacing XML_FINISHED # -proc getParsingStatus*(parser: PParser, status: ptr TParsingStatus){.cdecl, +proc getParsingStatus*(parser: PParser, status: ptr ParsingStatus){.cdecl, importc: "XML_GetParsingStatus", dynlib: expatDll.} # Creates an XML_Parser object that can parse an external general # entity; context is a '\0'-terminated string specifying the parse @@ -735,9 +756,10 @@ proc externalEntityParserCreate*(parser: PParser, context: cstring, encoding: cstring): PParser{.cdecl, importc: "XML_ExternalEntityParserCreate", dynlib: expatDll.} type - TParamEntityParsing* = enum + ParamEntityParsing* = enum PARAM_ENTITY_PARSING_NEVER, PARAM_ENTITY_PARSING_UNLESS_STANDALONE, PARAM_ENTITY_PARSING_ALWAYS +{.deprecated: [TParamEntityParsing: ParamEntityParsing].} # Controls parsing of parameter entities (including the external DTD # subset). If parsing of parameter entities is enabled, then @@ -763,13 +785,13 @@ type # XML_ParseBuffer, then it has no effect and will always return 0. # -proc setParamEntityParsing*(parser: PParser, parsing: TParamEntityParsing): cint{. +proc setParamEntityParsing*(parser: PParser, parsing: ParamEntityParsing): cint{. cdecl, importc: "XML_SetParamEntityParsing", dynlib: expatDll.} # If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then # XML_GetErrorCode returns information about the error. # -proc getErrorCode*(parser: PParser): TError{.cdecl, importc: "XML_GetErrorCode", +proc getErrorCode*(parser: PParser): Error{.cdecl, importc: "XML_GetErrorCode", dynlib: expatDll.} # These functions return information about the current parse # location. They may be called from any callback called to report @@ -815,7 +837,7 @@ proc getInputContext*(parser: PParser, offset: ptr cint, size: ptr cint): cstrin cdecl, importc: "XML_GetInputContext", dynlib: expatDll.} # Frees the content model passed to the element declaration handler -proc freeContentModel*(parser: PParser, model: ptr TContent){.cdecl, +proc freeContentModel*(parser: PParser, model: ptr Content){.cdecl, importc: "XML_FreeContentModel", dynlib: expatDll.} # Exposing the memory handling functions used in Expat @@ -831,39 +853,39 @@ proc parserFree*(parser: PParser){.cdecl, importc: "XML_ParserFree", dynlib: expatDll.} # Returns a string describing the error. -proc errorString*(code: TError): cstring{.cdecl, importc: "XML_ErrorString", +proc errorString*(code: Error): cstring{.cdecl, importc: "XML_ErrorString", dynlib: expatDll.} # Return a string containing the version number of this expat proc expatVersion*(): cstring{.cdecl, importc: "XML_ExpatVersion", dynlib: expatDll.} type - TExpat_Version*{.pure, final.} = object + Expat_Version*{.pure, final.} = object major*: cint minor*: cint micro*: cint - +{.deprecated: [TExpat_Version: ExpatVersion].} # Return an XML_Expat_Version structure containing numeric version # number information for this version of expat. # -proc expatVersionInfo*(): TExpatVersion{.cdecl, +proc expatVersionInfo*(): ExpatVersion{.cdecl, importc: "XML_ExpatVersionInfo", dynlib: expatDll.} # Added in Expat 1.95.5. type - TFeatureEnum* = enum + FeatureEnum* = enum FEATURE_END = 0, FEATURE_UNICODE, FEATURE_UNICODE_WCHAR_T, FEATURE_DTD, FEATURE_CONTEXT_BYTES, FEATURE_MIN_SIZE, FEATURE_SIZEOF_XML_CHAR, FEATURE_SIZEOF_XML_LCHAR, FEATURE_NS, FEATURE_LARGE_SIZE # Additional features must be added to the end of this enum. - TFeature*{.pure, final.} = object - feature*: TFeatureEnum + Feature*{.pure, final.} = object + feature*: FeatureEnum name*: cstring value*: int +{.deprecated: [TFeatureEnum: FeatureEnum, TFeature: Feature].} - -proc getFeatureList*(): ptr TFeature{.cdecl, importc: "XML_GetFeatureList", +proc getFeatureList*(): ptr Feature{.cdecl, importc: "XML_GetFeatureList", dynlib: expatDll.} # Expat follows the GNU/Linux convention of odd number minor version for # beta/development releases and even number minor version for stable diff --git a/lib/wrappers/joyent_http_parser.nim b/lib/wrappers/joyent_http_parser.nim index a008da43e..2fed392b9 100644 --- a/lib/wrappers/joyent_http_parser.nim +++ b/lib/wrappers/joyent_http_parser.nim @@ -1,20 +1,20 @@ type csize = int - HttpDataProc* = proc (a2: ptr THttpParser, at: cstring, length: csize): cint {.cdecl.} - HttpProc* = proc (a2: ptr THttpParser): cint {.cdecl.} + HttpDataProc* = proc (a2: ptr HttpParser, at: cstring, length: csize): cint {.cdecl.} + HttpProc* = proc (a2: ptr HttpParser): cint {.cdecl.} - THttpMethod* = enum + HttpMethod* = enum HTTP_DELETE = 0, HTTP_GET, HTTP_HEAD, HTTP_POST, HTTP_PUT, HTTP_CONNECT, HTTP_OPTIONS, HTTP_TRACE, HTTP_COPY, HTTP_LOCK, HTTP_MKCOL, HTTP_MOVE, HTTP_PROPFIND, HTTP_PROPPATCH, HTTP_UNLOCK, HTTP_REPORT, HTTP_MKACTIVITY, HTTP_CHECKOUT, HTTP_MERGE, HTTP_MSEARCH, HTTP_NOTIFY, HTTP_SUBSCRIBE, HTTP_UNSUBSCRIBE, HTTP_PATCH - THttpParserType* = enum + HttpParserType* = enum HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH - TParserFlag* = enum + ParserFlag* = enum F_CHUNKED = 1 shl 0, F_CONNECTION_KEEP_ALIVE = 1 shl 1, F_CONNECTION_CLOSE = 1 shl 2, @@ -22,7 +22,7 @@ type F_UPGRADE = 1 shl 4, F_SKIPBODY = 1 shl 5 - THttpErrNo* = enum + HttpErrNo* = enum HPE_OK, HPE_CB_message_begin, HPE_CB_path, HPE_CB_query_string, HPE_CB_url, HPE_CB_fragment, HPE_CB_header_field, HPE_CB_header_value, HPE_CB_headers_complete, HPE_CB_body, HPE_CB_message_complete, @@ -34,7 +34,7 @@ type HPE_INVALID_CHUNK_SIZE, HPE_INVALID_CONSTANT, HPE_INVALID_INTERNAL_STATE, HPE_STRICT, HPE_UNKNOWN - THttpParser*{.pure, final, importc: "http_parser", header: "http_parser.h".} = object + HttpParser*{.pure, final, importc: "http_parser", header: "http_parser.h".} = object typ {.importc: "type".}: char flags {.importc: "flags".}: char state*{.importc: "state".}: char @@ -50,7 +50,7 @@ type upgrade {.importc: "upgrade".}: bool data*{.importc: "data".}: pointer - THttpParserSettings*{.pure, final, importc: "http_parser_settings", header: "http_parser.h".} = object + HttpParserSettings*{.pure, final, importc: "http_parser_settings", header: "http_parser.h".} = object on_message_begin*{.importc: "on_message_begin".}: HttpProc on_url*{.importc: "on_url".}: HttpDataProc on_header_field*{.importc: "on_header_field".}: HttpDataProc @@ -58,24 +58,27 @@ type on_headers_complete*{.importc: "on_headers_complete".}: HttpProc on_body*{.importc: "on_body".}: HttpDataProc on_message_complete*{.importc: "on_message_complete".}: HttpProc +{.deprecated: [THttpMethod: HttpMethod, THttpParserType: HttpParserType, + TParserFlag: ParserFlag, THttpErrNo: HttpErrNo, + THttpParser: HttpParser, THttpParserSettings: HttpParserSettings].} -proc http_parser_init*(parser: var THttpParser, typ: THttpParserType){. +proc http_parser_init*(parser: var HttpParser, typ: HttpParserType){. importc: "http_parser_init", header: "http_parser.h".} -proc http_parser_execute*(parser: var THttpParser, - settings: var THttpParserSettings, data: cstring, +proc http_parser_execute*(parser: var HttpParser, + settings: var HttpParserSettings, data: cstring, len: csize): csize {. importc: "http_parser_execute", header: "http_parser.h".} -proc http_should_keep_alive*(parser: var THttpParser): cint{. +proc http_should_keep_alive*(parser: var HttpParser): cint{. importc: "http_should_keep_alive", header: "http_parser.h".} -proc http_method_str*(m: THttpMethod): cstring{. +proc http_method_str*(m: HttpMethod): cstring{. importc: "http_method_str", header: "http_parser.h".} -proc http_errno_name*(err: THttpErrNo): cstring{. +proc http_errno_name*(err: HttpErrNo): cstring{. importc: "http_errno_name", header: "http_parser.h".} -proc http_errno_description*(err: THttpErrNo): cstring{. +proc http_errno_description*(err: HttpErrNo): cstring{. importc: "http_errno_description", header: "http_parser.h".} diff --git a/lib/wrappers/libcurl.nim b/lib/wrappers/libcurl.nim index 8c962f6cb..924879e75 100644 --- a/lib/wrappers/libcurl.nim +++ b/lib/wrappers/libcurl.nim @@ -31,47 +31,47 @@ elif defined(unix): const libname = "libcurl.so.4" type - Pcalloc_callback* = ptr Tcalloc_callback - Pclosepolicy* = ptr Tclosepolicy - Pforms* = ptr Tforms - Pftpauth* = ptr Tftpauth - Pftpmethod* = ptr Tftpmethod - Pftpssl* = ptr Tftpssl - PHTTP_VERSION* = ptr THTTP_VERSION - Phttppost* = ptr Thttppost + Pcalloc_callback* = ptr Calloc_callback + Pclosepolicy* = ptr Closepolicy + Pforms* = ptr Forms + Pftpauth* = ptr Ftpauth + Pftpmethod* = ptr Ftpmethod + Pftpssl* = ptr Ftpssl + PHTTP_VERSION* = ptr HTTP_VERSION + Phttppost* = ptr Httppost PPcurl_httppost* = ptr Phttppost - Pinfotype* = ptr Tinfotype - Plock_access* = ptr Tlock_access - Plock_data* = ptr Tlock_data - Pmalloc_callback* = ptr Tmalloc_callback - PNETRC_OPTION* = ptr TNETRC_OPTION - Pproxytype* = ptr Tproxytype - Prealloc_callback* = ptr Trealloc_callback - Pslist* = ptr Tslist - Psocket* = ptr Tsocket - PSSL_VERSION* = ptr TSSL_VERSION - Pstrdup_callback* = ptr Tstrdup_callback - PTIMECOND* = ptr TTIMECOND - Pversion_info_data* = ptr Tversion_info_data - Pcode* = ptr Tcode - PFORMcode* = ptr TFORMcode - Pformoption* = ptr Tformoption - PINFO* = ptr TINFO - Piocmd* = ptr Tiocmd - Pioerr* = ptr Tioerr - PM* = ptr TM - PMcode* = ptr TMcode - PMoption* = ptr TMoption - PMSG* = ptr TMSG - Poption* = ptr Toption - PSH* = ptr TSH - PSHcode* = ptr TSHcode - PSHoption* = ptr TSHoption - Pversion* = ptr Tversion + Pinfotype* = ptr Infotype + Plock_access* = ptr Lock_access + Plock_data* = ptr Lock_data + Pmalloc_callback* = ptr Malloc_callback + PNETRC_OPTION* = ptr NETRC_OPTION + Pproxytype* = ptr Proxytype + Prealloc_callback* = ptr Realloc_callback + Pslist* = ptr Slist + Psocket* = ptr Socket + PSSL_VERSION* = ptr SSL_VERSION + Pstrdup_callback* = ptr Strdup_callback + PTIMECOND* = ptr TIMECOND + Pversion_info_data* = ptr Version_info_data + Pcode* = ptr Code + PFORMcode* = ptr FORMcode + Pformoption* = ptr Formoption + PINFO* = ptr INFO + Piocmd* = ptr Iocmd + Pioerr* = ptr Ioerr + PM* = ptr M + PMcode* = ptr Mcode + PMoption* = ptr Moption + PMSG* = ptr MSG + Poption* = ptr Option + PSH* = ptr SH + PSHcode* = ptr SHcode + PSHoption* = ptr SHoption + Pversion* = ptr Version Pfd_set* = pointer - PCurl* = ptr TCurl - TCurl* = pointer - Thttppost*{.final, pure.} = object + PCurl* = ptr Curl + Curl* = pointer + Httppost*{.final, pure.} = object next*: Phttppost name*: cstring namelength*: int32 @@ -85,32 +85,32 @@ type flags*: int32 showfilename*: cstring - Tprogress_callback* = proc (clientp: pointer, dltotal: float64, + Progress_callback* = proc (clientp: pointer, dltotal: float64, dlnow: float64, ultotal: float64, ulnow: float64): int32 {.cdecl.} - Twrite_callback* = proc (buffer: cstring, size: int, nitems: int, + Write_callback* = proc (buffer: cstring, size: int, nitems: int, outstream: pointer): int{.cdecl.} - Tread_callback* = proc (buffer: cstring, size: int, nitems: int, + Read_callback* = proc (buffer: cstring, size: int, nitems: int, instream: pointer): int{.cdecl.} - Tpasswd_callback* = proc (clientp: pointer, prompt: cstring, buffer: cstring, + Passwd_callback* = proc (clientp: pointer, prompt: cstring, buffer: cstring, buflen: int32): int32{.cdecl.} - Tioerr* = enum + Ioerr* = enum IOE_OK, IOE_UNKNOWNCMD, IOE_FAILRESTART, IOE_LAST - Tiocmd* = enum + Iocmd* = enum IOCMD_NOP, IOCMD_RESTARTREAD, IOCMD_LAST - Tioctl_callback* = proc (handle: PCurl, cmd: int32, clientp: pointer): Tioerr{. + Ioctl_callback* = proc (handle: PCurl, cmd: int32, clientp: pointer): Ioerr{. cdecl.} - Tmalloc_callback* = proc (size: int): pointer{.cdecl.} - Tfree_callback* = proc (p: pointer){.cdecl.} - Trealloc_callback* = proc (p: pointer, size: int): pointer{.cdecl.} - Tstrdup_callback* = proc (str: cstring): cstring{.cdecl.} - Tcalloc_callback* = proc (nmemb: int, size: int): pointer{.noconv.} - Tinfotype* = enum + Malloc_callback* = proc (size: int): pointer{.cdecl.} + Free_callback* = proc (p: pointer){.cdecl.} + Realloc_callback* = proc (p: pointer, size: int): pointer{.cdecl.} + Strdup_callback* = proc (str: cstring): cstring{.cdecl.} + Calloc_callback* = proc (nmemb: int, size: int): pointer{.noconv.} + Infotype* = enum INFO_TEXT = 0, INFO_HEADER_IN, INFO_HEADER_OUT, INFO_DATA_IN, INFO_DATA_OUT, INFO_SSL_DATA_IN, INFO_SSL_DATA_OUT, INFO_END - Tdebug_callback* = proc (handle: PCurl, theType: Tinfotype, data: cstring, + Debug_callback* = proc (handle: PCurl, theType: Infotype, data: cstring, size: int, userptr: pointer): int32{.cdecl.} - Tcode* = enum + Code* = enum E_OK = 0, E_UNSUPPORTED_PROTOCOL, E_FAILED_INIT, E_URL_MALFORMAT, E_URL_MALFORMAT_USER, E_COULDNT_RESOLVE_PROXY, E_COULDNT_RESOLVE_HOST, E_COULDNT_CONNECT, E_FTP_WEIRD_SERVER_REPLY, E_FTP_ACCESS_DENIED, @@ -135,18 +135,18 @@ type E_LOGIN_DENIED, E_TFTP_NOTFOUND, E_TFTP_PERM, E_TFTP_DISKFULL, E_TFTP_ILLEGAL, E_TFTP_UNKNOWNID, E_TFTP_EXISTS, E_TFTP_NOSUCHUSER, E_CONV_FAILED, E_CONV_REQD, LAST - Tconv_callback* = proc (buffer: cstring, len: int): Tcode{.cdecl.} - Tssl_ctx_callback* = proc (curl: PCurl, ssl_ctx, userptr: pointer): Tcode{.cdecl.} - Tproxytype* = enum + Conv_callback* = proc (buffer: cstring, len: int): Code{.cdecl.} + Ssl_ctx_callback* = proc (curl: PCurl, ssl_ctx, userptr: pointer): Code{.cdecl.} + Proxytype* = enum PROXY_HTTP = 0, PROXY_SOCKS4 = 4, PROXY_SOCKS5 = 5 - Tftpssl* = enum + Ftpssl* = enum FTPSSL_NONE, FTPSSL_TRY, FTPSSL_CONTROL, FTPSSL_ALL, FTPSSL_LAST - Tftpauth* = enum + Ftpauth* = enum FTPAUTH_DEFAULT, FTPAUTH_SSL, FTPAUTH_TLS, FTPAUTH_LAST - Tftpmethod* = enum + Ftpmethod* = enum FTPMETHOD_DEFAULT, FTPMETHOD_MULTICWD, FTPMETHOD_NOCWD, FTPMETHOD_SINGLECWD, FTPMETHOD_LAST - Toption* = enum + Option* = enum OPT_PORT = 0 + 3, OPT_TIMEOUT = 0 + 13, OPT_INFILESIZE = 0 + 14, OPT_LOW_SPEED_LIMIT = 0 + 19, OPT_LOW_SPEED_TIME = 0 + 20, OPT_RESUME_FROM = 0 + 21, OPT_CRLF = 0 + 27, OPT_SSLVERSION = 0 + 32, @@ -211,37 +211,37 @@ type OPT_MAXFILESIZE_LARGE = 30000 + 117, OPT_POSTFIELDSIZE_LARGE = 30000 + 120, OPT_MAX_SEND_SPEED_LARGE = 30000 + 145, OPT_MAX_RECV_SPEED_LARGE = 30000 + 146 - THTTP_VERSION* = enum + HTTP_VERSION* = enum HTTP_VERSION_NONE, HTTP_VERSION_1_0, HTTP_VERSION_1_1, HTTP_VERSION_LAST - TNETRC_OPTION* = enum + NETRC_OPTION* = enum NETRC_IGNORED, NETRC_OPTIONAL, NETRC_REQUIRED, NETRC_LAST - TSSL_VERSION* = enum + SSL_VERSION* = enum SSLVERSION_DEFAULT, SSLVERSION_TLSv1, SSLVERSION_SSLv2, SSLVERSION_SSLv3, SSLVERSION_LAST - TTIMECOND* = enum + TIMECOND* = enum TIMECOND_NONE, TIMECOND_IFMODSINCE, TIMECOND_IFUNMODSINCE, TIMECOND_LASTMOD, TIMECOND_LAST - Tformoption* = enum + Formoption* = enum FORM_NOTHING, FORM_COPYNAME, FORM_PTRNAME, FORM_NAMELENGTH, FORM_COPYCONTENTS, FORM_PTRCONTENTS, FORM_CONTENTSLENGTH, FORM_FILECONTENT, FORM_ARRAY, FORM_OBSOLETE, FORM_FILE, FORM_BUFFER, FORM_BUFFERPTR, FORM_BUFFERLENGTH, FORM_CONTENTTYPE, FORM_CONTENTHEADER, FORM_FILENAME, FORM_END, FORM_OBSOLETE2, FORM_LASTENTRY - Tforms*{.pure, final.} = object - option*: Tformoption + Forms*{.pure, final.} = object + option*: Formoption value*: cstring - TFORMcode* = enum + FORMcode* = enum FORMADD_OK, FORMADD_MEMORY, FORMADD_OPTION_TWICE, FORMADD_NULL, FORMADD_UNKNOWN_OPTION, FORMADD_INCOMPLETE, FORMADD_ILLEGAL_ARRAY, FORMADD_DISABLED, FORMADD_LAST - Tformget_callback* = proc (arg: pointer, buf: cstring, length: int): int{. + Formget_callback* = proc (arg: pointer, buf: cstring, length: int): int{. cdecl.} - Tslist*{.pure, final.} = object + Slist*{.pure, final.} = object data*: cstring next*: Pslist - TINFO* = enum + INFO* = enum INFO_NONE = 0, INFO_LASTONE = 30, INFO_EFFECTIVE_URL = 0x00100000 + 1, INFO_CONTENT_TYPE = 0x00100000 + 18, INFO_PRIVATE = 0x00100000 + 21, INFO_FTP_ENTRY_PATH = 0x00100000 + 30, INFO_RESPONSE_CODE = 0x00200000 + 2, @@ -261,31 +261,31 @@ type INFO_STARTTRANSFER_TIME = 0x00300000 + 17, INFO_REDIRECT_TIME = 0x00300000 + 19, INFO_SSL_ENGINES = 0x00400000 + 27, INFO_COOKIELIST = 0x00400000 + 28 - Tclosepolicy* = enum + Closepolicy* = enum CLOSEPOLICY_NONE, CLOSEPOLICY_OLDEST, CLOSEPOLICY_LEAST_RECENTLY_USED, CLOSEPOLICY_LEAST_TRAFFIC, CLOSEPOLICY_SLOWEST, CLOSEPOLICY_CALLBACK, CLOSEPOLICY_LAST - Tlock_data* = enum + Lock_data* = enum LOCK_DATA_NONE = 0, LOCK_DATA_SHARE, LOCK_DATA_COOKIE, LOCK_DATA_DNS, LOCK_DATA_SSL_SESSION, LOCK_DATA_CONNECT, LOCK_DATA_LAST - Tlock_access* = enum + Lock_access* = enum LOCK_ACCESS_NONE = 0, LOCK_ACCESS_SHARED = 1, LOCK_ACCESS_SINGLE = 2, LOCK_ACCESS_LAST - Tlock_function* = proc (handle: PCurl, data: Tlock_data, - locktype: Tlock_access, + Lock_function* = proc (handle: PCurl, data: Lock_data, + locktype: Lock_access, userptr: pointer){.cdecl.} - Tunlock_function* = proc (handle: PCurl, data: Tlock_data, userptr: pointer){. + Unlock_function* = proc (handle: PCurl, data: Lock_data, userptr: pointer){. cdecl.} - TSH* = pointer - TSHcode* = enum + SH* = pointer + SHcode* = enum SHE_OK, SHE_BAD_OPTION, SHE_IN_USE, SHE_INVALID, SHE_NOMEM, SHE_LAST - TSHoption* = enum + SHoption* = enum SHOPT_NONE, SHOPT_SHARE, SHOPT_UNSHARE, SHOPT_LOCKFUNC, SHOPT_UNLOCKFUNC, SHOPT_USERDATA, SHOPT_LAST - Tversion* = enum + Version* = enum VERSION_FIRST, VERSION_SECOND, VERSION_THIRD, VERSION_LAST - Tversion_info_data*{.pure, final.} = object - age*: Tversion + Version_info_data*{.pure, final.} = object + age*: Version version*: cstring version_num*: int32 host*: cstring @@ -299,15 +299,15 @@ type libidn*: cstring iconv_ver_num*: int32 - TM* = pointer - Tsocket* = int32 - TMcode* = enum + M* = pointer + Socket* = int32 + Mcode* = enum M_CALL_MULTI_PERFORM = - 1, M_OK = 0, M_BAD_HANDLE, M_BAD_EASY_HANDLE, M_OUT_OF_MEMORY, M_INTERNAL_ERROR, M_BAD_SOCKET, M_UNKNOWN_OPTION, M_LAST - TMSGEnum* = enum + MSGEnum* = enum MSG_NONE, MSG_DONE, MSG_LAST - TMsg*{.pure, final.} = object - msg*: TMSGEnum + Msg*{.pure, final.} = object + msg*: MSGEnum easy_handle*: PCurl whatever*: pointer #data : record # case longint of @@ -315,11 +315,29 @@ type # 1 : ( result : CURLcode ); # end; - Tsocket_callback* = proc (easy: PCurl, s: Tsocket, what: int32, + Socket_callback* = proc (easy: PCurl, s: Socket, what: int32, userp, socketp: pointer): int32{.cdecl.} - TMoption* = enum + Moption* = enum MOPT_SOCKETDATA = 10000 + 2, MOPT_LASTENTRY = 10000 + 3, MOPT_SOCKETFUNCTION = 20000 + 1 +{.deprecated: [TMsg: Msg, TCurl: Curl, Thttppost: Httppost, + Tprogress_callback: Progress_callback, Twrite_callback: Write_callback, + Tread_callback: Read_callback, Tpasswd_callback: Passwd_callback, Tioerr: Ioerr, + Tiocmd: Iocmd, Tioctl_callback: Ioctl_callback, Tmalloc_callback: Malloc_callback, + Tfree_callback: Free_callback, Trealloc_callback: Realloc_callback, + Tstrdup_callback: Strdup_callback, Tcalloc_callback: Calloc_callback, + Tinfotype: Infotype, Tdebug_callback: Debug_callback, Tcode: Code, + Tconv_callback: Conv_callback, Tssl_ctx_callback: Ssl_ctx_callback, + Tproxytype: Proxytype, Tftpssl: Ftpssl, Tftpauth: Ftpauth, Tftpmethod: Ftpmethod, + Toption: Option, THTTP_VERSION: HTTP_VERSION, TNETRC_OPTION: NETRC_OPTION, + TSSL_VERSION: SSL_VERSION, TTIMECOND: TIMECOND, Tformoption: Formoption, + Tforms: Forms, TFORMcode: FORMcode, Tformget_callback: Formget_callback, + Tslist: Slist, TINFO: INFO, Tclosepolicy: Closepolicy, Tlock_data: Lock_data, + Tlock_access: Lock_access, Tlock_function: Lock_function, + Tunlock_function: Unlock_function, TSH: Sh, TSHcode: SHcode, TSHoption: SHoption, + Tversion: Version, Tversion_info_data: Version_info_data, TM: M, Tsocket: Socket, + TMcode: Mcode, TMSGEnum: MsGEnum, Tsocket_callback: Socket_callback, + TMoption: Moption].} const OPT_SSLKEYPASSWD* = OPT_SSLCERTPASSWD @@ -413,9 +431,9 @@ proc strequal*(s1, s2: cstring): int32{.cdecl, dynlib: libname, importc: "curl_strequal".} proc strnequal*(s1, s2: cstring, n: int): int32{.cdecl, dynlib: libname, importc: "curl_strnequal".} -proc formadd*(httppost, last_post: PPcurl_httppost): TFORMcode{.cdecl, varargs, +proc formadd*(httppost, last_post: PPcurl_httppost): FORMcode{.cdecl, varargs, dynlib: libname, importc: "curl_formadd".} -proc formget*(form: Phttppost, arg: pointer, append: Tformget_callback): int32{. +proc formget*(form: Phttppost, arg: pointer, append: Formget_callback): int32{. cdecl, dynlib: libname, importc: "curl_formget".} proc formfree*(form: Phttppost){.cdecl, dynlib: libname, importc: "curl_formfree".} @@ -431,11 +449,11 @@ proc easy_unescape*(handle: PCurl, str: cstring, len: int32, outlength: var int3 proc unescape*(str: cstring, len: int32): cstring{.cdecl, dynlib: libname, importc: "curl_unescape".} proc free*(p: pointer){.cdecl, dynlib: libname, importc: "curl_free".} -proc global_init*(flags: int32): Tcode{.cdecl, dynlib: libname, +proc global_init*(flags: int32): Code{.cdecl, dynlib: libname, importc: "curl_global_init".} -proc global_init_mem*(flags: int32, m: Tmalloc_callback, f: Tfree_callback, - r: Trealloc_callback, s: Tstrdup_callback, - c: Tcalloc_callback): Tcode{.cdecl, dynlib: libname, +proc global_init_mem*(flags: int32, m: Malloc_callback, f: Free_callback, + r: Realloc_callback, s: Strdup_callback, + c: Calloc_callback): Code{.cdecl, dynlib: libname, importc: "curl_global_init_mem".} proc global_cleanup*(){.cdecl, dynlib: libname, importc: "curl_global_cleanup".} proc slist_append*(slist: Pslist, p: cstring): Pslist{.cdecl, dynlib: libname, @@ -445,50 +463,50 @@ proc slist_free_all*(para1: Pslist){.cdecl, dynlib: libname, proc getdate*(p: cstring, unused: ptr Time): Time{.cdecl, dynlib: libname, importc: "curl_getdate".} proc share_init*(): PSH{.cdecl, dynlib: libname, importc: "curl_share_init".} -proc share_setopt*(para1: PSH, option: TSHoption): TSHcode{.cdecl, varargs, +proc share_setopt*(para1: PSH, option: SHoption): SHcode{.cdecl, varargs, dynlib: libname, importc: "curl_share_setopt".} -proc share_cleanup*(para1: PSH): TSHcode{.cdecl, dynlib: libname, +proc share_cleanup*(para1: PSH): SHcode{.cdecl, dynlib: libname, importc: "curl_share_cleanup".} -proc version_info*(para1: Tversion): Pversion_info_data{.cdecl, dynlib: libname, +proc version_info*(para1: Version): Pversion_info_data{.cdecl, dynlib: libname, importc: "curl_version_info".} -proc easy_strerror*(para1: Tcode): cstring{.cdecl, dynlib: libname, +proc easy_strerror*(para1: Code): cstring{.cdecl, dynlib: libname, importc: "curl_easy_strerror".} -proc share_strerror*(para1: TSHcode): cstring{.cdecl, dynlib: libname, +proc share_strerror*(para1: SHcode): cstring{.cdecl, dynlib: libname, importc: "curl_share_strerror".} proc easy_init*(): PCurl{.cdecl, dynlib: libname, importc: "curl_easy_init".} -proc easy_setopt*(curl: PCurl, option: Toption): Tcode{.cdecl, varargs, dynlib: libname, +proc easy_setopt*(curl: PCurl, option: Option): Code{.cdecl, varargs, dynlib: libname, importc: "curl_easy_setopt".} -proc easy_perform*(curl: PCurl): Tcode{.cdecl, dynlib: libname, +proc easy_perform*(curl: PCurl): Code{.cdecl, dynlib: libname, importc: "curl_easy_perform".} proc easy_cleanup*(curl: PCurl){.cdecl, dynlib: libname, importc: "curl_easy_cleanup".} -proc easy_getinfo*(curl: PCurl, info: TINFO): Tcode{.cdecl, varargs, dynlib: libname, +proc easy_getinfo*(curl: PCurl, info: INFO): Code{.cdecl, varargs, dynlib: libname, importc: "curl_easy_getinfo".} proc easy_duphandle*(curl: PCurl): PCurl{.cdecl, dynlib: libname, importc: "curl_easy_duphandle".} proc easy_reset*(curl: PCurl){.cdecl, dynlib: libname, importc: "curl_easy_reset".} proc multi_init*(): PM{.cdecl, dynlib: libname, importc: "curl_multi_init".} -proc multi_add_handle*(multi_handle: PM, handle: PCurl): TMcode{.cdecl, +proc multi_add_handle*(multi_handle: PM, handle: PCurl): Mcode{.cdecl, dynlib: libname, importc: "curl_multi_add_handle".} -proc multi_remove_handle*(multi_handle: PM, handle: PCurl): TMcode{.cdecl, +proc multi_remove_handle*(multi_handle: PM, handle: PCurl): Mcode{.cdecl, dynlib: libname, importc: "curl_multi_remove_handle".} proc multi_fdset*(multi_handle: PM, read_fd_set: Pfd_set, write_fd_set: Pfd_set, - exc_fd_set: Pfd_set, max_fd: var int32): TMcode{.cdecl, + exc_fd_set: Pfd_set, max_fd: var int32): Mcode{.cdecl, dynlib: libname, importc: "curl_multi_fdset".} -proc multi_perform*(multi_handle: PM, running_handles: var int32): TMcode{. +proc multi_perform*(multi_handle: PM, running_handles: var int32): Mcode{. cdecl, dynlib: libname, importc: "curl_multi_perform".} -proc multi_cleanup*(multi_handle: PM): TMcode{.cdecl, dynlib: libname, +proc multi_cleanup*(multi_handle: PM): Mcode{.cdecl, dynlib: libname, importc: "curl_multi_cleanup".} proc multi_info_read*(multi_handle: PM, msgs_in_queue: var int32): PMsg{.cdecl, dynlib: libname, importc: "curl_multi_info_read".} -proc multi_strerror*(para1: TMcode): cstring{.cdecl, dynlib: libname, +proc multi_strerror*(para1: Mcode): cstring{.cdecl, dynlib: libname, importc: "curl_multi_strerror".} -proc multi_socket*(multi_handle: PM, s: Tsocket, running_handles: var int32): TMcode{. +proc multi_socket*(multi_handle: PM, s: Socket, running_handles: var int32): Mcode{. cdecl, dynlib: libname, importc: "curl_multi_socket".} -proc multi_socket_all*(multi_handle: PM, running_handles: var int32): TMcode{. +proc multi_socket_all*(multi_handle: PM, running_handles: var int32): Mcode{. cdecl, dynlib: libname, importc: "curl_multi_socket_all".} -proc multi_timeout*(multi_handle: PM, milliseconds: var int32): TMcode{.cdecl, +proc multi_timeout*(multi_handle: PM, milliseconds: var int32): Mcode{.cdecl, dynlib: libname, importc: "curl_multi_timeout".} -proc multi_setopt*(multi_handle: PM, option: TMoption): TMcode{.cdecl, varargs, +proc multi_setopt*(multi_handle: PM, option: Moption): Mcode{.cdecl, varargs, dynlib: libname, importc: "curl_multi_setopt".} -proc multi_assign*(multi_handle: PM, sockfd: Tsocket, sockp: pointer): TMcode{. +proc multi_assign*(multi_handle: PM, sockfd: Socket, sockp: pointer): Mcode{. cdecl, dynlib: libname, importc: "curl_multi_assign".} diff --git a/lib/wrappers/libffi/libffi.nim b/lib/wrappers/libffi/libffi.nim index 1b6130103..34b91f8c7 100644 --- a/lib/wrappers/libffi/libffi.nim +++ b/lib/wrappers/libffi/libffi.nim @@ -58,8 +58,9 @@ else: {.pragma: mylib, dynlib: "libffi.so".} type - TArg* = int - TSArg* = int + Arg* = int + SArg* = int +{.deprecated: [TArg: Arg, TSArg: SArg].} when defined(windows) and defined(x86): type @@ -105,67 +106,71 @@ const tkSMALL_STRUCT_4B* = (tkLAST + 3) type - TType* = object + Type* = object size*: int alignment*: uint16 typ*: uint16 - elements*: ptr ptr TType + elements*: ptr ptr Type +{.deprecated: [TType: Type].} var - type_void* {.importc: "ffi_type_void", mylib.}: TType - type_uint8* {.importc: "ffi_type_uint8", mylib.}: TType - type_sint8* {.importc: "ffi_type_sint8", mylib.}: TType - type_uint16* {.importc: "ffi_type_uint16", mylib.}: TType - type_sint16* {.importc: "ffi_type_sint16", mylib.}: TType - type_uint32* {.importc: "ffi_type_uint32", mylib.}: TType - type_sint32* {.importc: "ffi_type_sint32", mylib.}: TType - type_uint64* {.importc: "ffi_type_uint64", mylib.}: TType - type_sint64* {.importc: "ffi_type_sint64", mylib.}: TType - type_float* {.importc: "ffi_type_float", mylib.}: TType - type_double* {.importc: "ffi_type_double", mylib.}: TType - type_pointer* {.importc: "ffi_type_pointer", mylib.}: TType - type_longdouble* {.importc: "ffi_type_longdouble", mylib.}: TType + type_void* {.importc: "ffi_type_void", mylib.}: Type + type_uint8* {.importc: "ffi_type_uint8", mylib.}: Type + type_sint8* {.importc: "ffi_type_sint8", mylib.}: Type + type_uint16* {.importc: "ffi_type_uint16", mylib.}: Type + type_sint16* {.importc: "ffi_type_sint16", mylib.}: Type + type_uint32* {.importc: "ffi_type_uint32", mylib.}: Type + type_sint32* {.importc: "ffi_type_sint32", mylib.}: Type + type_uint64* {.importc: "ffi_type_uint64", mylib.}: Type + type_sint64* {.importc: "ffi_type_sint64", mylib.}: Type + type_float* {.importc: "ffi_type_float", mylib.}: Type + type_double* {.importc: "ffi_type_double", mylib.}: Type + type_pointer* {.importc: "ffi_type_pointer", mylib.}: Type + type_longdouble* {.importc: "ffi_type_longdouble", mylib.}: Type type - Tstatus* {.size: sizeof(cint).} = enum + Status* {.size: sizeof(cint).} = enum OK, BAD_TYPEDEF, BAD_ABI - TTypeKind* = cuint + TypeKind* = cuint TCif* {.pure, final.} = object abi*: TABI nargs*: cuint - arg_types*: ptr ptr TType - rtype*: ptr TType + arg_types*: ptr ptr Type + rtype*: ptr Type bytes*: cuint flags*: cuint +{.deprecated: [Tstatus: Status].} type - TRaw* = object - sint*: TSArg + Raw* = object + sint*: SArg +{.deprecated: [TRaw: Raw].} proc raw_call*(cif: var Tcif; fn: proc () {.cdecl.}; rvalue: pointer; - avalue: ptr TRaw) {.cdecl, importc: "ffi_raw_call", mylib.} -proc ptrarray_to_raw*(cif: var Tcif; args: ptr pointer; raw: ptr TRaw) {.cdecl, + avalue: ptr Raw) {.cdecl, importc: "ffi_raw_call", mylib.} +proc ptrarray_to_raw*(cif: var Tcif; args: ptr pointer; raw: ptr Raw) {.cdecl, importc: "ffi_ptrarray_to_raw", mylib.} -proc raw_to_ptrarray*(cif: var Tcif; raw: ptr TRaw; args: ptr pointer) {.cdecl, +proc raw_to_ptrarray*(cif: var Tcif; raw: ptr Raw; args: ptr pointer) {.cdecl, importc: "ffi_raw_to_ptrarray", mylib.} proc raw_size*(cif: var Tcif): int {.cdecl, importc: "ffi_raw_size", mylib.} -proc prep_cif*(cif: var Tcif; abi: TABI; nargs: cuint; rtype: ptr TType; - atypes: ptr ptr TType): TStatus {.cdecl, importc: "ffi_prep_cif", +proc prep_cif*(cif: var Tcif; abi: TABI; nargs: cuint; rtype: ptr Type; + atypes: ptr ptr Type): Status {.cdecl, importc: "ffi_prep_cif", mylib.} proc call*(cif: var Tcif; fn: proc () {.cdecl.}; rvalue: pointer; avalue: ptr pointer) {.cdecl, importc: "ffi_call", mylib.} # the same with an easier interface: type - TParamList* = array[0..100, ptr TType] - TArgList* = array[0..100, pointer] + ParamList* = array[0..100, ptr Type] + ArgList* = array[0..100, pointer] +{.deprecated: [TParamList: ParamList, TArgList: ArgList].} -proc prep_cif*(cif: var Tcif; abi: TABI; nargs: cuint; rtype: ptr TType; - atypes: TParamList): TStatus {.cdecl, importc: "ffi_prep_cif", +proc prep_cif*(cif: var Tcif; abi: TABI; nargs: cuint; rtype: ptr Type; + atypes: ParamList): Status {.cdecl, importc: "ffi_prep_cif", mylib.} proc call*(cif: var Tcif; fn, rvalue: pointer; - avalue: TArgList) {.cdecl, importc: "ffi_call", mylib.} + avalue: ArgList) {.cdecl, importc: "ffi_call", mylib.} # Useful for eliminating compiler warnings ##define FFI_FN(f) ((void (*)(void))f) diff --git a/lib/wrappers/libsvm.nim b/lib/wrappers/libsvm.nim index 00d5ac73c..8cc314412 100644 --- a/lib/wrappers/libsvm.nim +++ b/lib/wrappers/libsvm.nim @@ -21,24 +21,24 @@ else: const svmdll* = "libsvm.so" type - Tnode*{.pure, final.} = object + Node*{.pure, final.} = object index*: cint value*: cdouble - Tproblem*{.pure, final.} = object + Problem*{.pure, final.} = object L*: cint y*: ptr cdouble - x*: ptr ptr Tnode + x*: ptr ptr Node - Ttype*{.size: sizeof(cint).} = enum + Type*{.size: sizeof(cint).} = enum C_SVC, NU_SVC, ONE_CLASS, EPSILON_SVR, NU_SVR - TKernelType*{.size: sizeof(cint).} = enum + KernelType*{.size: sizeof(cint).} = enum LINEAR, POLY, RBF, SIGMOID, PRECOMPUTED - Tparameter*{.pure, final.} = object - typ*: TType - kernelType*: TKernelType + Parameter*{.pure, final.} = object + typ*: Type + kernelType*: KernelType degree*: cint # for poly gamma*: cdouble # for poly/rbf/sigmoid coef0*: cdouble # for poly/sigmoid @@ -53,18 +53,19 @@ type p*: cdouble # for EPSILON_SVR shrinking*: cint # use the shrinking heuristics probability*: cint # do probability estimates - +{.deprecated: [Tnode: Node, Tproblem: Problem, Ttype: Type, + TKernelType: KernelType, Tparameter: Parameter].} # # svm_model # type - TModel*{.pure, final.} = object - param*: Tparameter # parameter + Model*{.pure, final.} = object + param*: Parameter # parameter nr_class*: cint # number of classes, = 2 in regression/one class svm L*: cint # total #SV - SV*: ptr ptr Tnode # SVs (SV[l]) + SV*: ptr ptr Node # SVs (SV[l]) sv_coef*: ptr ptr cdouble # coefficients for SVs in decision functions (sv_coef[k-1][l]) rho*: ptr cdouble # constants in decision functions (rho[k*(k-1)/2]) probA*: ptr cdouble # pariwise probability information @@ -74,42 +75,42 @@ type # nSV[0] + nSV[1] + ... + nSV[k-1] = l # XXX free_sv*: cint # 1 if svm_model is created by svm_load_model - # 0 if svm_model is created by svm_train - + # 0 if svm_model is created by svm_train +{.deprecated: [TModel: Model].} -proc train*(prob: ptr Tproblem, param: ptr Tparameter): ptr Tmodel{.cdecl, +proc train*(prob: ptr Problem, param: ptr Parameter): ptr Model{.cdecl, importc: "svm_train", dynlib: svmdll.} -proc cross_validation*(prob: ptr Tproblem, param: ptr Tparameter, nr_fold: cint, +proc cross_validation*(prob: ptr Problem, param: ptr Parameter, nr_fold: cint, target: ptr cdouble){.cdecl, importc: "svm_cross_validation", dynlib: svmdll.} -proc save_model*(model_file_name: cstring, model: ptr Tmodel): cint{.cdecl, +proc save_model*(model_file_name: cstring, model: ptr Model): cint{.cdecl, importc: "svm_save_model", dynlib: svmdll.} -proc load_model*(model_file_name: cstring): ptr Tmodel{.cdecl, +proc load_model*(model_file_name: cstring): ptr Model{.cdecl, importc: "svm_load_model", dynlib: svmdll.} -proc get_svm_type*(model: ptr Tmodel): cint{.cdecl, importc: "svm_get_svm_type", +proc get_svm_type*(model: ptr Model): cint{.cdecl, importc: "svm_get_svm_type", dynlib: svmdll.} -proc get_nr_class*(model: ptr Tmodel): cint{.cdecl, importc: "svm_get_nr_class", +proc get_nr_class*(model: ptr Model): cint{.cdecl, importc: "svm_get_nr_class", dynlib: svmdll.} -proc get_labels*(model: ptr Tmodel, label: ptr cint){.cdecl, +proc get_labels*(model: ptr Model, label: ptr cint){.cdecl, importc: "svm_get_labels", dynlib: svmdll.} -proc get_svr_probability*(model: ptr Tmodel): cdouble{.cdecl, +proc get_svr_probability*(model: ptr Model): cdouble{.cdecl, importc: "svm_get_svr_probability", dynlib: svmdll.} -proc predict_values*(model: ptr Tmodel, x: ptr Tnode, dec_values: ptr cdouble): cdouble{. +proc predict_values*(model: ptr Model, x: ptr Node, dec_values: ptr cdouble): cdouble{. cdecl, importc: "svm_predict_values", dynlib: svmdll.} -proc predict*(model: ptr Tmodel, x: ptr Tnode): cdouble{.cdecl, +proc predict*(model: ptr Model, x: ptr Node): cdouble{.cdecl, importc: "svm_predict", dynlib: svmdll.} -proc predict_probability*(model: ptr Tmodel, x: ptr Tnode, +proc predict_probability*(model: ptr Model, x: ptr Node, prob_estimates: ptr cdouble): cdouble{.cdecl, importc: "svm_predict_probability", dynlib: svmdll.} -proc free_model_content*(model_ptr: ptr Tmodel){.cdecl, +proc free_model_content*(model_ptr: ptr Model){.cdecl, importc: "svm_free_model_content", dynlib: svmdll.} -proc free_and_destroy_model*(model_ptr_ptr: ptr ptr Tmodel){.cdecl, +proc free_and_destroy_model*(model_ptr_ptr: ptr ptr Model){.cdecl, importc: "svm_free_and_destroy_model", dynlib: svmdll.} -proc destroy_param*(param: ptr Tparameter){.cdecl, importc: "svm_destroy_param", +proc destroy_param*(param: ptr Parameter){.cdecl, importc: "svm_destroy_param", dynlib: svmdll.} -proc check_parameter*(prob: ptr Tproblem, param: ptr Tparameter): cstring{. +proc check_parameter*(prob: ptr Problem, param: ptr Parameter): cstring{. cdecl, importc: "svm_check_parameter", dynlib: svmdll.} -proc check_probability_model*(model: ptr Tmodel): cint{.cdecl, +proc check_probability_model*(model: ptr Model): cint{.cdecl, importc: "svm_check_probability_model", dynlib: svmdll.} proc set_print_string_function*(print_func: proc (arg: cstring) {.cdecl.}){. diff --git a/lib/wrappers/libuv.nim b/lib/wrappers/libuv.nim index a52ae0f63..0cb14fb2b 100644 --- a/lib/wrappers/libuv.nim +++ b/lib/wrappers/libuv.nim @@ -10,15 +10,15 @@ else: import posix type - TPort* = distinct int16 ## port type + Port* = distinct int16 ## port type cssize = int coff = int csize = int - AllocProc* = proc (handle: PHandle, suggested_size: csize): TBuf {.cdecl.} - ReadProc* = proc (stream: PStream, nread: cssize, buf: TBuf) {.cdecl.} - ReadProc2* = proc (stream: PPipe, nread: cssize, buf: TBuf, pending: THandleType) {.cdecl.} + AllocProc* = proc (handle: PHandle, suggested_size: csize): Buf {.cdecl.} + ReadProc* = proc (stream: PStream, nread: cssize, buf: Buf) {.cdecl.} + ReadProc2* = proc (stream: PPipe, nread: cssize, buf: Buf, pending: HandleType) {.cdecl.} WriteProc* = proc (req: PWrite, status: cint) {.cdecl.} ConnectProc* = proc (req: PConnect, status: cint) {.cdecl.} ShutdownProc* = proc (req: PShutdown, status: cint) {.cdecl.} @@ -41,7 +41,7 @@ type FsEventProc* = proc (handle: PFsEvent, filename: cstring, events: cint, status: cint) - TErrorCode* {.size: sizeof(cint).} = enum + ErrorCode* {.size: sizeof(cint).} = enum UNKNOWN = - 1, OK = 0, EOF, EACCESS, EAGAIN, EADDRINUSE, EADDRNOTAVAIL, EAFNOSUPPORT, EALREADY, EBADF, EBUSY, ECONNABORTED, ECONNREFUSED, ECONNRESET, EDESTADDRREQ, EFAULT, EHOSTUNREACH, EINTR, EINVAL, EISCONN, @@ -50,11 +50,11 @@ type EPROTONOSUPPORT, EPROTOTYPE, ETIMEDOUT, ECHARSET, EAIFAMNOSUPPORT, EAINONAME, EAISERVICE, EAISOCKTYPE, ESHUTDOWN, EEXIST - THandleType* {.size: sizeof(cint).} = enum + HandleType* {.size: sizeof(cint).} = enum UNKNOWN_HANDLE = 0, TCP, UDP, NAMED_PIPE, TTY, FILE, TIMER, PREPARE, CHECK, IDLE, ASYNC, ARES_TASK, ARES_EVENT, PROCESS, FS_EVENT - TReqType* {.size: sizeof(cint).} = enum + ReqType* {.size: sizeof(cint).} = enum rUNKNOWN_REQ = 0, rCONNECT, rACCEPT, @@ -68,57 +68,57 @@ type rGETADDRINFO, rREQ_TYPE_PRIVATE - TErr* {.pure, final, importc: "uv_err_t", header: "uv.h".} = object - code* {.importc: "code".}: TErrorCode + Err* {.pure, final, importc: "uv_err_t", header: "uv.h".} = object + code* {.importc: "code".}: ErrorCode sys_errno* {.importc: "sys_errno_".}: cint - TFsEventType* = enum + FsEventType* = enum evRENAME = 1, evCHANGE = 2 TFsEvent* {.pure, final, importc: "uv_fs_event_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType close_cb* {.importc: "close_cb".}: CloseProc data* {.importc: "data".}: pointer filename {.importc: "filename".}: cstring PFsEvent* = ptr TFsEvent - TFsEvents* {.pure, final, importc: "uv_fs_event_t", header: "uv.h".} = object + FsEvents* {.pure, final, importc: "uv_fs_event_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType close_cb* {.importc: "close_cb".}: CloseProc data* {.importc: "data".}: pointer filename* {.importc: "filename".}: cstring - TBuf* {.pure, final, importc: "uv_buf_t", header: "uv.h"} = object + Buf* {.pure, final, importc: "uv_buf_t", header: "uv.h"} = object base* {.importc: "base".}: cstring len* {.importc: "len".}: csize - TAnyHandle* {.pure, final, importc: "uv_any_handle", header: "uv.h".} = object + AnyHandle* {.pure, final, importc: "uv_any_handle", header: "uv.h".} = object tcp* {.importc: "tcp".}: TTcp - pipe* {.importc: "pipe".}: TPipe + pipe* {.importc: "pipe".}: Pipe prepare* {.importc: "prepare".}: TPrepare check* {.importc: "check".}: TCheck idle* {.importc: "idle".}: TIdle async* {.importc: "async".}: TAsync timer* {.importc: "timer".}: TTimer - getaddrinfo* {.importc: "getaddrinfo".}: TGetaddrinfo - fs_event* {.importc: "fs_event".}: TFsEvents + getaddrinfo* {.importc: "getaddrinfo".}: Getaddrinfo + fs_event* {.importc: "fs_event".}: FsEvents - TAnyReq* {.pure, final, importc: "uv_any_req", header: "uv.h".} = object - req* {.importc: "req".}: TReq - write* {.importc: "write".}: TWrite - connect* {.importc: "connect".}: TConnect - shutdown* {.importc: "shutdown".}: TShutdown - fs_req* {.importc: "fs_req".}: Tfs - work_req* {.importc: "work_req".}: TWork + AnyReq* {.pure, final, importc: "uv_any_req", header: "uv.h".} = object + req* {.importc: "req".}: Req + write* {.importc: "write".}: Write + connect* {.importc: "connect".}: Connect + shutdown* {.importc: "shutdown".}: Shutdown + fs_req* {.importc: "fs_req".}: Fs + work_req* {.importc: "work_req".}: Work ## better import this uint64 = int64 - TCounters* {.pure, final, importc: "uv_counters_t", header: "uv.h".} = object + Counters* {.pure, final, importc: "uv_counters_t", header: "uv.h".} = object eio_init* {.importc: "eio_init".}: uint64 req_init* {.importc: "req_init".}: uint64 handle_init* {.importc: "handle_init".}: uint64 @@ -135,36 +135,36 @@ type process_init* {.importc: "process_init".}: uint64 fs_event_init* {.importc: "fs_event_init".}: uint64 - TLoop* {.pure, final, importc: "uv_loop_t", header: "uv.h".} = object + Loop* {.pure, final, importc: "uv_loop_t", header: "uv.h".} = object # ares_handles_* {.importc: "uv_ares_handles_".}: pointer # XXX: This seems to be a private field? eio_want_poll_notifier* {.importc: "uv_eio_want_poll_notifier".}: TAsync eio_done_poll_notifier* {.importc: "uv_eio_done_poll_notifier".}: TAsync eio_poller* {.importc: "uv_eio_poller".}: TIdle - counters* {.importc: "counters".}: TCounters - last_err* {.importc: "last_err".}: TErr + counters* {.importc: "counters".}: Counters + last_err* {.importc: "last_err".}: Err data* {.importc: "data".}: pointer - PLoop* = ptr TLoop + PLoop* = ptr Loop - TShutdown* {.pure, final, importc: "uv_shutdown_t", header: "uv.h".} = object - typ* {.importc: "type".}: TReqType + Shutdown* {.pure, final, importc: "uv_shutdown_t", header: "uv.h".} = object + typ* {.importc: "type".}: ReqType data* {.importc: "data".}: pointer handle* {.importc: "handle".}: PStream cb* {.importc: "cb".}: ShutdownProc - PShutdown* = ptr TShutdown + PShutdown* = ptr Shutdown - THandle* {.pure, final, importc: "uv_handle_t", header: "uv.h".} = object + Handle* {.pure, final, importc: "uv_handle_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType close_cb* {.importc: "close_cb".}: CloseProc data* {.importc: "data".}: pointer - PHandle* = ptr THandle + PHandle* = ptr Handle - TStream* {.pure, final, importc: "uv_stream_t", header: "uv.h".} = object + Stream* {.pure, final, importc: "uv_stream_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType alloc_cb* {.importc: "alloc_cb".}: AllocProc read_cb* {.importc: "read_cb".}: ReadProc read2_cb* {.importc: "read2_cb".}: ReadProc2 @@ -172,20 +172,20 @@ type data* {.importc: "data".}: pointer write_queue_size* {.importc: "write_queue_size".}: csize - PStream* = ptr TStream + PStream* = ptr Stream - TWrite* {.pure, final, importc: "uv_write_t", header: "uv.h".} = object - typ* {.importc: "type".}: TReqType + Write* {.pure, final, importc: "uv_write_t", header: "uv.h".} = object + typ* {.importc: "type".}: ReqType data* {.importc: "data".}: pointer cb* {.importc: "cb".}: WriteProc send_handle* {.importc: "send_handle".}: PStream handle* {.importc: "handle".}: PStream - PWrite* = ptr TWrite + PWrite* = ptr Write TTcp* {.pure, final, importc: "uv_tcp_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType alloc_cb* {.importc: "alloc_cb".}: AllocProc read_cb* {.importc: "read_cb".}: ReadProc read2_cb* {.importc: "read2_cb".}: ReadProc2 @@ -195,42 +195,42 @@ type PTcp* = ptr TTcp - TConnect* {.pure, final, importc: "uv_connect_t", header: "uv.h".} = object - typ* {.importc: "type".}: TReqType + Connect* {.pure, final, importc: "uv_connect_t", header: "uv.h".} = object + typ* {.importc: "type".}: ReqType data* {.importc: "data".}: pointer cb* {.importc: "cb".}: ConnectProc handle* {.importc: "handle".}: PStream - PConnect* = ptr TConnect + PConnect* = ptr Connect - TUdpFlags* = enum + UdpFlags* = enum UDP_IPV6ONLY = 1, UDP_PARTIAL = 2 ## XXX: better import this cunsigned = int UdpSendProc* = proc (req: PUdpSend, status: cint) - UdpRecvProc* = proc (handle: PUdp, nread: cssize, buf: TBuf, adr: ptr SockAddr, flags: cunsigned) + UdpRecvProc* = proc (handle: PUdp, nread: cssize, buf: Buf, adr: ptr SockAddr, flags: cunsigned) TUdp* {.pure, final, importc: "uv_udp_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType close_cb* {.importc: "close_cb".}: CloseProc data* {.importc: "data".}: pointer PUdp* = ptr TUdp - TUdpSend* {.pure, final, importc: "uv_udp_send_t", header: "uv.h".} = object - typ* {.importc: "type".}: TReqType + UdpSend* {.pure, final, importc: "uv_udp_send_t", header: "uv.h".} = object + typ* {.importc: "type".}: ReqType data* {.importc: "data".}: pointer handle* {.importc: "handle".}: PUdp cb* {.importc: "cb".}: UdpSendProc - PUdpSend* = ptr TUdpSend + PUdpSend* = ptr UdpSend tTTy* {.pure, final, importc: "uv_tty_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType alloc_cb* {.importc: "alloc_cb".}: AllocProc read_cb* {.importc: "read_cb".}: ReadProc read2_cb* {.importc: "read2_cb".}: ReadProc2 @@ -240,9 +240,9 @@ type pTTy* = ptr tTTy - TPipe* {.pure, final, importc: "uv_pipe_t", header: "uv.h".} = object + Pipe* {.pure, final, importc: "uv_pipe_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType alloc_cb* {.importc: "alloc_cb".}: AllocProc read_cb* {.importc: "read_cb".}: ReadProc read2_cb* {.importc: "read2_cb".}: ReadProc2 @@ -251,11 +251,11 @@ type write_queue_size* {.importc: "write_queue_size".}: csize ipc {.importc: "ipc".}: int - PPipe* = ptr TPipe + PPipe* = ptr Pipe TPrepare* {.pure, final, importc: "uv_prepare_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType close_cb* {.importc: "close_cb".}: CloseProc data* {.importc: "data".}: pointer @@ -263,7 +263,7 @@ type TCheck* {.pure, final, importc: "uv_check_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType close_cb* {.importc: "close_cb".}: CloseProc data* {.importc: "data".}: pointer @@ -271,7 +271,7 @@ type TIdle* {.pure, final, importc: "uv_idle_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType close_cb* {.importc: "close_cb".}: CloseProc data* {.importc: "data".}: pointer @@ -279,7 +279,7 @@ type TAsync* {.pure, final, importc: "uv_async_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType close_cb* {.importc: "close_cb".}: CloseProc data* {.importc: "data".}: pointer @@ -287,20 +287,20 @@ type TTimer* {.pure, final, importc: "uv_timer_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType close_cb* {.importc: "close_cb".}: CloseProc data* {.importc: "data".}: pointer PTimer* = ptr TTimer - TGetAddrInfo* {.pure, final, importc: "uv_getaddrinfo_t", header: "uv.h".} = object - typ* {.importc: "type".}: TReqType + GetAddrInfo* {.pure, final, importc: "uv_getaddrinfo_t", header: "uv.h".} = object + typ* {.importc: "type".}: ReqType data* {.importc: "data".}: pointer loop* {.importc: "loop".}: PLoop - PGetAddrInfo* = ptr TGetAddrInfo + PGetAddrInfo* = ptr GetAddrInfo - TProcessOptions* {.pure, final, importc: "uv_process_options_t", header: "uv.h".} = object + ProcessOptions* {.pure, final, importc: "uv_process_options_t", header: "uv.h".} = object exit_cb* {.importc: "exit_cb".}: ExitProc file* {.importc: "file".}: cstring args* {.importc: "args".}: cstringArray @@ -311,11 +311,11 @@ type stdout_stream* {.importc: "stdout_stream".}: PPipe stderr_stream* {.importc: "stderr_stream".}: PPipe - PProcessOptions* = ptr TProcessOptions + PProcessOptions* = ptr ProcessOptions TProcess* {.pure, final, importc: "uv_process_t", header: "uv.h".} = object loop* {.importc: "loop".}: PLoop - typ* {.importc: "type".}: THandleType + typ* {.importc: "type".}: HandleType close_cb* {.importc: "close_cb".}: CloseProc data* {.importc: "data".}: pointer exit_cb* {.importc: "exit_cb".}: ExitProc @@ -323,47 +323,47 @@ type PProcess* = ptr TProcess - TWork* {.pure, final, importc: "uv_work_t", header: "uv.h".} = object - typ* {.importc: "type".}: TReqType + Work* {.pure, final, importc: "uv_work_t", header: "uv.h".} = object + typ* {.importc: "type".}: ReqType data* {.importc: "data".}: pointer loop* {.importc: "loop".}: PLoop work_cb* {.importc: "work_cb".}: WorkProc after_work_cb* {.importc: "after_work_cb".}: AfterWorkProc - PWork* = ptr TWork + PWork* = ptr Work - TFsType* {.size: sizeof(cint).} = enum + FsType* {.size: sizeof(cint).} = enum FS_UNKNOWN = - 1, FS_CUSTOM, FS_OPEN, FS_CLOSE, FS_READ, FS_WRITE, FS_SENDFILE, FS_STAT, FS_LSTAT, FS_FSTAT, FS_FTRUNCATE, FS_UTIME, FS_FUTIME, FS_CHMOD, FS_FCHMOD, FS_FSYNC, FS_FDATASYNC, FS_UNLINK, FS_RMDIR, FS_MKDIR, FS_RENAME, FS_READDIR, FS_LINK, FS_SYMLINK, FS_READLINK, FS_CHOWN, FS_FCHOWN - TFS* {.pure, final, importc: "uv_fs_t", header: "uv.h".} = object - typ* {.importc: "type".}: TReqType + FS* {.pure, final, importc: "uv_fs_t", header: "uv.h".} = object + typ* {.importc: "type".}: ReqType data* {.importc: "data".}: pointer loop* {.importc: "loop".}: PLoop - fs_type* {.importc: "fs_type".}: TFsType + fs_type* {.importc: "fs_type".}: FsType cb* {.importc: "cb".}: FsProc result* {.importc: "result".}: cssize fsPtr* {.importc: "ptr".}: pointer path* {.importc: "path".}: cstring errorno* {.importc: "errorno".}: cint - PFS* = ptr TFS + PFS* = ptr FS - TReq* {.pure, final, importc: "uv_req_t", header: "uv.h".} = object - typ* {.importc: "type".}: TReqType + Req* {.pure, final, importc: "uv_req_t", header: "uv.h".} = object + typ* {.importc: "type".}: ReqType data* {.importc: "data".}: pointer - PReq* = ptr TReq + PReq* = ptr Req - TAresOptions* {.pure, final, importc: "ares_options", header: "uv.h".} = object + AresOptions* {.pure, final, importc: "ares_options", header: "uv.h".} = object flags* {.importc: "flags".}: int timeout* {.importc: "timeout".}: int tries* {.importc: "tries".}: int ndots* {.importc: "ndots".}: int - udp_port* {.importc: "udp_port".}: TPort - tcp_port* {.importc: "tcp_port".}: TPort + udp_port* {.importc: "udp_port".}: Port + tcp_port* {.importc: "tcp_port".}: Port socket_send_buffer_size* {.importc: "socket_send_buffer_size".}: int socket_recv_buffer_size* {.importc: "socket_receive_buffer_size".}: int servers* {.importc: "servers".}: ptr InAddr @@ -378,8 +378,30 @@ type #struct apattern *sortlist; #int nsort; - PAresOptions* = ptr TAresOptions + PAresOptions* = ptr AresOptions PAresChannel* = pointer +{.deprecated: [THandle: Handle, THandleType: HandleType, TAnyHandle: AnyHandle, + TAnyReq: AnyReq, TPort: Port, TErrorCode: ErrorCode, TReqType: ReqType, + TErr: Err, TFsEventType: FsEventType, + # TFsEvent: FsEvent, # Name conflict if we drop `T` + TFsEvents: FsEvents, TBuf: Buf, TCounters: Counters, TLoop: Loop, + TShutdown: Shutdown, TStream: Stream, TWrite: Write, + # TTcp: Tcp, # Name conflict if we drop `T` + TConnect: Connect, + TUdpFlags: UdpFlags, + # TUdp: Udp, # Name conflict if we drop `T` + TUdpSend: UdpSend, + # tTTy: TTy, # Name conflict if we drop `T` + TPipe: Pipe, + # TPrepare: Prepare, # Name conflict if we drop `T` + # TCheck: Check, # Name conflict if we drop `T` + # TIdle: Idle, # Name conflict if we drop `T` + # TAsync: Async, # Name conflict if we drop `T` + # TTimer: Timer, # Name conflict if we drop `T` + TGetAddrInfo: GetAddrInfo, TProcessOptions: ProcessOptions, + # TProcess: Process, # Name conflict if we drop `T` + TWork: Work, + TFsType: FsType, TFS: FS, TReq: Req, TAresOptions: AresOptions].} proc loop_new*(): PLoop{. importc: "uv_loop_new", header: "uv.h".} @@ -405,13 +427,13 @@ proc update_time*(a2: PLoop){. proc now*(a2: PLoop): int64{. importc: "uv_now", header: "uv.h".} -proc last_error*(a2: PLoop): TErr{. +proc last_error*(a2: PLoop): Err{. importc: "uv_last_error", header: "uv.h".} -proc strerror*(err: TErr): cstring{. +proc strerror*(err: Err): cstring{. importc: "uv_strerror", header: "uv.h".} -proc err_name*(err: TErr): cstring{. +proc err_name*(err: Err): cstring{. importc: "uv_err_name", header: "uv.h".} proc shutdown*(req: PShutdown, handle: PStream, cb: ShutdownProc): cint{. @@ -423,7 +445,7 @@ proc is_active*(handle: PHandle): cint{. proc close*(handle: PHandle, close_cb: CloseProc){. importc: "uv_close", header: "uv.h".} -proc buf_init*(base: cstring, len: csize): TBuf{. +proc buf_init*(base: cstring, len: csize): Buf{. importc: "uv_buf_init", header: "uv.h".} proc listen*(stream: PStream, backlog: cint, cb: ConnectionProc): cint{. @@ -441,10 +463,10 @@ proc read_start*(a2: PStream, alloc_cb: AllocProc, read_cb: ReadProc2): cint{. proc read_stop*(a2: PStream): cint{. importc: "uv_read_stop", header: "uv.h".} -proc write*(req: PWrite, handle: PStream, bufs: ptr TBuf, bufcnt: cint, cb: WriteProc): cint{. +proc write*(req: PWrite, handle: PStream, bufs: ptr Buf, bufcnt: cint, cb: WriteProc): cint{. importc: "uv_write", header: "uv.h".} -proc write*(req: PWrite, handle: PStream, bufs: ptr TBuf, bufcnt: cint, send_handle: PStream, cb: WriteProc): cint{. +proc write*(req: PWrite, handle: PStream, bufs: ptr Buf, bufcnt: cint, send_handle: PStream, cb: WriteProc): cint{. importc: "uv_write2", header: "uv.h".} proc tcp_init*(a2: PLoop, handle: PTcp): cint{. @@ -480,10 +502,10 @@ proc udp_bind6*(handle: PUdp, adr: TSockAddrIn6, flags: cunsigned): cint{. proc udp_getsockname*(handle: PUdp, name: ptr SockAddr, namelen: var cint): cint{. importc: "uv_udp_getsockname", header: "uv.h".} -proc udp_send*(req: PUdpSend, handle: PUdp, bufs: ptr TBuf, bufcnt: cint, adr: SockAddrIn, send_cb: UdpSendProc): cint{. +proc udp_send*(req: PUdpSend, handle: PUdp, bufs: ptr Buf, bufcnt: cint, adr: SockAddrIn, send_cb: UdpSendProc): cint{. importc: "uv_udp_send", header: "uv.h".} -proc udp_send6*(req: PUdpSend, handle: PUdp, bufs: ptr TBuf, bufcnt: cint, adr: TSockAddrIn6, send_cb: UdpSendProc): cint{. +proc udp_send6*(req: PUdpSend, handle: PUdp, bufs: ptr Buf, bufcnt: cint, adr: TSockAddrIn6, send_cb: UdpSendProc): cint{. importc: "uv_udp_send6", header: "uv.h".} proc udp_recv_start*(handle: PUdp, alloc_cb: AllocProc, recv_cb: UdpRecvProc): cint{. @@ -504,7 +526,7 @@ proc tty_get_winsize*(a2: pTTy, width: var cint, height: var cint): cint{. proc tty_reset_mode*() {. importc: "uv_tty_reset_mode", header: "uv.h".} -proc guess_handle*(file: File): THandleType{. +proc guess_handle*(file: File): HandleType{. importc: "uv_guess_handle", header: "uv.h".} proc pipe_init*(a2: PLoop, handle: PPipe, ipc: int): cint{. @@ -582,7 +604,7 @@ proc getaddrinfo*(a2: PLoop, handle: PGetAddrInfo,getaddrinfo_cb: GetAddrInfoPro proc freeaddrinfo*(ai: ptr AddrInfo){. importc: "uv_freeaddrinfo", header: "uv.h".} -proc spawn*(a2: PLoop, a3: PProcess, options: TProcessOptions): cint{. +proc spawn*(a2: PLoop, a3: PProcess, options: ProcessOptions): cint{. importc: "uv_spawn", header: "uv.h".} proc process_kill*(a2: PProcess, signum: cint): cint{. diff --git a/lib/wrappers/mysql.nim b/lib/wrappers/mysql.nim index 937a8952a..73b82b5c6 100644 --- a/lib/wrappers/mysql.nim +++ b/lib/wrappers/mysql.nim @@ -51,7 +51,7 @@ const SERVICENAME* = "MySQL" type - Tenum_server_command* = enum + Enum_server_command* = enum COM_SLEEP, COM_QUIT, COM_INIT_DB, COM_QUERY, COM_FIELD_LIST, COM_CREATE_DB, COM_DROP_DB, COM_REFRESH, COM_SHUTDOWN, COM_STATISTICS, COM_PROCESS_INFO, COM_CONNECT, COM_PROCESS_KILL, COM_DEBUG, COM_PING, COM_TIME, @@ -59,6 +59,7 @@ type COM_CONNECT_OUT, COM_REGISTER_SLAVE, COM_STMT_PREPARE, COM_STMT_EXECUTE, COM_STMT_SEND_LONG_DATA, COM_STMT_CLOSE, COM_STMT_RESET, COM_SET_OPTION, COM_STMT_FETCH, COM_END +{.deprecated: [Tenum_server_command: Enum_server_command].} const SCRAMBLE_LENGTH* = 20 # Length of random string sent by server on handshake; @@ -150,8 +151,8 @@ const MAX_BLOB_WIDTH* = 8192 # Default width for blob type - Pst_net* = ptr Tst_net - Tst_net*{.final.} = object + Pst_net* = ptr St_net + St_net*{.final.} = object vio*: PVio buff*: cstring buff_end*: cstring @@ -191,14 +192,15 @@ type report_error*: my_bool # We should report error (we have unreported error) return_errno*: my_bool - TNET* = Tst_net - PNET* = ptr TNET + NET* = St_net + PNET* = ptr NET +{.deprecated: [Tst_net: St_net, TNET: NET].} const packet_error* = - 1 type - Tenum_field_types* = enum # For backward compatibility + Enum_field_types* = enum # For backward compatibility TYPE_DECIMAL, TYPE_TINY, TYPE_SHORT, TYPE_LONG, TYPE_FLOAT, TYPE_DOUBLE, TYPE_NULL, TYPE_TIMESTAMP, TYPE_LONGLONG, TYPE_INT24, TYPE_DATE, TYPE_TIME, TYPE_DATETIME, TYPE_YEAR, TYPE_NEWDATE, TYPE_VARCHAR, TYPE_BIT, @@ -206,6 +208,7 @@ type TYPE_TINY_BLOB = 249, TYPE_MEDIUM_BLOB = 250, TYPE_LONG_BLOB = 251, TYPE_BLOB = 252, TYPE_VAR_STRING = 253, TYPE_STRING = 254, TYPE_GEOMETRY = 255 +{.deprecated: [Tenum_field_types: Enum_field_types].} const CLIENT_MULTI_QUERIES* = CLIENT_MULTI_STATEMENTS @@ -244,16 +247,19 @@ const SHUTDOWN_KILLABLE_UPDATE* = chr(1 shl 3) type - Tenum_shutdown_level* = enum + Enum_shutdown_level* = enum SHUTDOWN_DEFAULT = 0, SHUTDOWN_WAIT_CONNECTIONS = 1, SHUTDOWN_WAIT_TRANSACTIONS = 2, SHUTDOWN_WAIT_UPDATES = 8, SHUTDOWN_WAIT_ALL_BUFFERS = 16, SHUTDOWN_WAIT_CRITICAL_BUFFERS = 17, KILL_QUERY = 254, KILL_CONNECTION = 255 - Tenum_cursor_type* = enum # options for mysql_set_option + Enum_cursor_type* = enum # options for mysql_set_option CURSOR_TYPE_NO_CURSOR = 0, CURSOR_TYPE_READ_ONLY = 1, CURSOR_TYPE_FOR_UPDATE = 2, CURSOR_TYPE_SCROLLABLE = 4 - Tenum_mysql_set_option* = enum + Enum_mysql_set_option* = enum OPTION_MULTI_STATEMENTS_ON, OPTION_MULTI_STATEMENTS_OFF +{.deprecated: [Tenum_shutdown_level: Enum_shutdown_level, + Tenum_cursor_type: Enum_cursor_type, + Tenum_mysql_set_option: Enum_mysql_set_option].} proc my_net_init*(net: PNET, vio: PVio): my_bool{.cdecl, dynlib: lib, importc: "my_net_init".} @@ -275,24 +281,25 @@ proc my_net_read*(net: PNET): int{.cdecl, dynlib: lib, importc: "my_net_read".} # The following function is not meant for normal usage # Currently it's used internally by manager.c type - Psockaddr* = ptr Tsockaddr - Tsockaddr*{.final.} = object # undefined structure + Psockaddr* = ptr Sockaddr + Sockaddr*{.final.} = object # undefined structure +{.deprecated: [Tsockaddr: Sockaddr].} proc my_connect*(s: my_socket, name: Psockaddr, namelen: cuint, timeout: cuint): cint{. cdecl, dynlib: lib, importc: "my_connect".} type - Prand_struct* = ptr Trand_struct - Trand_struct*{.final.} = object # The following is for user defined functions + Prand_struct* = ptr Rand_struct + Rand_struct*{.final.} = object # The following is for user defined functions seed1*: int seed2*: int max_value*: int max_value_dbl*: cdouble - TItem_result* = enum + Item_result* = enum STRING_RESULT, REAL_RESULT, INT_RESULT, ROW_RESULT, DECIMAL_RESULT - PItem_result* = ptr TItem_result - Pst_udf_args* = ptr Tst_udf_args - Tst_udf_args*{.final.} = object + PItem_result* = ptr Item_result + Pst_udf_args* = ptr St_udf_args + St_udf_args*{.final.} = object arg_count*: cuint # Number of arguments arg_type*: PItem_result # Pointer to item_results args*: cstringArray # Pointer to item_results @@ -301,18 +308,21 @@ type attributes*: cstringArray # Pointer to attribute name attribute_lengths*: ptr int # Length of attribute arguments - TUDF_ARGS* = Tst_udf_args - PUDF_ARGS* = ptr TUDF_ARGS # This holds information about the result - Pst_udf_init* = ptr Tst_udf_init - Tst_udf_init*{.final.} = object + UDF_ARGS* = St_udf_args + PUDF_ARGS* = ptr UDF_ARGS # This holds information about the result + Pst_udf_init* = ptr St_udf_init + St_udf_init*{.final.} = object maybe_null*: my_bool # 1 if function can return NULL decimals*: cuint # for real functions max_length*: int # For string functions theptr*: cstring # free pointer for function data const_item*: my_bool # free pointer for function data - TUDF_INIT* = Tst_udf_init - PUDF_INIT* = ptr TUDF_INIT # Constants when using compression + UDF_INIT* = St_udf_init + PUDF_INIT* = ptr UDF_INIT # Constants when using compression +{.deprecated: [Trand_stuct: Rand_struct, TItem_result: Item_result, + Tst_udf_args: St_udf_args, TUDF_ARGS: UDF_ARGS, + Tst_udf_init: St_udf_init, TUDF_INIT: UDF_INIT].} const NET_HEADER_SIZE* = 4 # standard header size @@ -386,8 +396,8 @@ const CLIENT_NET_WRITE_TIMEOUT* = 365 * 24 * 3600 # Timeout on write type - Pst_mysql_field* = ptr Tst_mysql_field - Tst_mysql_field*{.final.} = object + Pst_mysql_field* = ptr St_mysql_field + St_mysql_field*{.final.} = object name*: cstring # Name of column org_name*: cstring # Original column name, if an alias table*: cstring # Table of column if column was a field @@ -407,19 +417,21 @@ type flags*: cuint # Div flags decimals*: cuint # Number of decimals in field charsetnr*: cuint # Character set - ftype*: Tenum_field_types # Type of field. See mysql_com.h for types + ftype*: Enum_field_types # Type of field. See mysql_com.h for types - TFIELD* = Tst_mysql_field - PFIELD* = ptr TFIELD - PROW* = ptr TROW # return data as array of strings - TROW* = cstringArray - PFIELD_OFFSET* = ptr TFIELD_OFFSET # offset to current field - TFIELD_OFFSET* = cuint + FIELD* = St_mysql_field + PFIELD* = ptr FIELD + PROW* = ptr ROW # return data as array of strings + ROW* = cstringArray + PFIELD_OFFSET* = ptr FIELD_OFFSET # offset to current field + FIELD_OFFSET* = cuint +{.deprecated: [Tst_mysql_field: St_mysql_field, TFIELD: FIELD, TROW: ROW, + TFIELD_OFFSET: FIELD_OFFSET].} proc IS_PRI_KEY*(n: int32): bool proc IS_NOT_NULL*(n: int32): bool proc IS_BLOB*(n: int32): bool -proc IS_NUM*(t: Tenum_field_types): bool +proc IS_NUM*(t: Enum_field_types): bool proc INTERNAL_NUM_FIELD*(f: Pst_mysql_field): bool proc IS_NUM_FIELD*(f: Pst_mysql_field): bool type @@ -430,32 +442,34 @@ const COUNT_ERROR* = not (my_ulonglong(0)) type - Pst_mysql_rows* = ptr Tst_mysql_rows - Tst_mysql_rows*{.final.} = object + Pst_mysql_rows* = ptr St_mysql_rows + St_mysql_rows*{.final.} = object next*: Pst_mysql_rows # list of rows - data*: TROW + data*: ROW len*: int - TROWS* = Tst_mysql_rows - PROWS* = ptr TROWS - PROW_OFFSET* = ptr TROW_OFFSET # offset to current row - TROW_OFFSET* = TROWS + ROWS* = St_mysql_rows + PROWS* = ptr ROWS + PROW_OFFSET* = ptr ROW_OFFSET # offset to current row + ROW_OFFSET* = ROWS +{.deprecated: [Tst_mysql_rows: St_mysql_rows, TROWS: ROWS, + TROW_OFFSET: ROW_OFFSET].} const ALLOC_MAX_BLOCK_TO_DROP* = 4096 ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP* = 10 # struct for once_alloc (block) type - Pst_used_mem* = ptr Tst_used_mem - Tst_used_mem*{.final.} = object + Pst_used_mem* = ptr St_used_mem + St_used_mem*{.final.} = object next*: Pst_used_mem # Next block in use left*: cuint # memory left in block size*: cuint # size of block - TUSED_MEM* = Tst_used_mem - PUSED_MEM* = ptr TUSED_MEM - Pst_mem_root* = ptr Tst_mem_root - Tst_mem_root*{.final.} = object + USED_MEM* = St_used_mem + PUSED_MEM* = ptr USED_MEM + Pst_mem_root* = ptr St_mem_root + St_mem_root*{.final.} = object free*: PUSED_MEM # blocks with free memory in it used*: PUSED_MEM # blocks almost without free memory pre_alloc*: PUSED_MEM # preallocated block @@ -467,27 +481,30 @@ type first_block_usage*: cuint error_handler*: proc (){.cdecl.} - TMEM_ROOT* = Tst_mem_root - PMEM_ROOT* = ptr TMEM_ROOT # ------------ Stop of declaration in "my_alloc.h" ---------------------- + MEM_ROOT* = St_mem_root + PMEM_ROOT* = ptr MEM_ROOT # ------------ Stop of declaration in "my_alloc.h" ---------------------- +{.deprecated: [Tst_used_mem: St_used_mem, TUSED_MEM: USED_MEM, + Tst_mem_root: St_mem_root, TMEM_ROOT: MEM_ROOT].} type - Pst_mysql_data* = ptr Tst_mysql_data - Tst_mysql_data*{.final.} = object + Pst_mysql_data* = ptr St_mysql_data + St_mysql_data*{.final.} = object rows*: my_ulonglong fields*: cuint data*: PROWS - alloc*: TMEM_ROOT + alloc*: MEM_ROOT prev_ptr*: ptr PROWS - TDATA* = Tst_mysql_data - PDATA* = ptr TDATA - Toption* = enum + DATA* = St_mysql_data + PDATA* = ptr DATA + Option* = enum OPT_CONNECT_TIMEOUT, OPT_COMPRESS, OPT_NAMED_PIPE, INIT_COMMAND, READ_DEFAULT_FILE, READ_DEFAULT_GROUP, SET_CHARSET_DIR, SET_CHARSET_NAME, OPT_LOCAL_INFILE, OPT_PROTOCOL, SHARED_MEMORY_BASE_NAME, OPT_READ_TIMEOUT, OPT_WRITE_TIMEOUT, OPT_USE_RESULT, OPT_USE_REMOTE_CONNECTION, OPT_USE_EMBEDDED_CONNECTION, OPT_GUESS_CONNECTION, SET_CLIENT_IP, SECURE_AUTH, REPORT_DATA_TRUNCATION, OPT_RECONNECT +{.deprecated: [Tst_mysql_data: St_mysql_data, TDATA: DATA, Toption: Option].} const MAX_MYSQL_MANAGER_ERR* = 256 @@ -499,17 +516,17 @@ const MANAGER_INTERNAL_ERR* = 500 type - Tst_dynamic_array*{.final.} = object + St_dynamic_array*{.final.} = object buffer*: cstring elements*: cuint max_element*: cuint alloc_increment*: cuint size_of_element*: cuint - TDYNAMIC_ARRAY* = Tst_dynamic_array - Pst_dynamic_array* = ptr Tst_dynamic_array - Pst_mysql_options* = ptr Tst_mysql_options - Tst_mysql_options*{.final.} = object + DYNAMIC_ARRAY* = St_dynamic_array + Pst_dynamic_array* = ptr St_dynamic_array + Pst_mysql_options* = ptr St_mysql_options + St_mysql_options*{.final.} = object connect_timeout*: cuint read_timeout*: cuint write_timeout*: cuint @@ -543,7 +560,7 @@ type # a read that is replication-aware no_master_reads*: my_bool separate_thread*: my_bool - methods_to_use*: Toption + methods_to_use*: Option client_ip*: cstring secure_auth*: my_bool # Refuse client connecting to server if it uses old (pre-4.1.1) protocol report_data_truncation*: my_bool # 0 - never report, 1 - always report (default) @@ -555,16 +572,16 @@ type local_infile_error*: proc (para1: pointer, para2: cstring, para3: cuint): cint local_infile_userdata*: pointer - Tstatus* = enum + Status* = enum STATUS_READY, STATUS_GET_RESULT, STATUS_USE_RESULT - Tprotocol_type* = enum # There are three types of queries - the ones that have to go to + Protocol_type* = enum # There are three types of queries - the ones that have to go to # the master, the ones that go to a slave, and the administrative # type which must happen on the pivot connectioin PROTOCOL_DEFAULT, PROTOCOL_TCP, PROTOCOL_SOCKET, PROTOCOL_PIPE, PROTOCOL_MEMORY - Trpl_type* = enum + Rpl_type* = enum RPL_MASTER, RPL_SLAVE, RPL_ADMIN - Tcharset_info_st*{.final.} = object + Charset_info_st*{.final.} = object number*: cuint primary_number*: cuint binary_number*: cuint @@ -592,10 +609,10 @@ type cset*: pointer # was ^MY_CHARSET_HANDLER coll*: pointer # was ^MY_COLLATION_HANDLER; - TCHARSET_INFO* = Tcharset_info_st - Pcharset_info_st* = ptr Tcharset_info_st - Pcharacter_set* = ptr Tcharacter_set - Tcharacter_set*{.final.} = object + CHARSET_INFO* = Charset_info_st + Pcharset_info_st* = ptr Charset_info_st + Pcharacter_set* = ptr Character_set + Character_set*{.final.} = object number*: cuint state*: cuint csname*: cstring @@ -605,12 +622,12 @@ type mbminlen*: cuint mbmaxlen*: cuint - TMY_CHARSET_INFO* = Tcharacter_set - PMY_CHARSET_INFO* = ptr TMY_CHARSET_INFO - Pst_mysql_methods* = ptr Tst_mysql_methods - Pst_mysql* = ptr Tst_mysql - Tst_mysql*{.final.} = object - net*: TNET # Communication parameters + MY_CHARSET_INFO* = Character_set + PMY_CHARSET_INFO* = ptr MY_CHARSET_INFO + Pst_mysql_methods* = ptr St_mysql_methods + Pst_mysql* = ptr St_mysql + St_mysql*{.final.} = object + net*: NET # Communication parameters connector_fd*: gptr # ConnectorFd for SSL host*: cstring user*: cstring @@ -622,7 +639,7 @@ type db*: cstring charset*: Pcharset_info_st fields*: PFIELD - field_alloc*: TMEM_ROOT + field_alloc*: MEM_ROOT affected_rows*: my_ulonglong insert_id*: my_ulonglong # id if insert on table with NEXTNR extra_info*: my_ulonglong # Used by mysqlshow, not used by mysql 5.0 and up @@ -636,8 +653,8 @@ type server_status*: cuint server_language*: cuint warning_count*: cuint - options*: Tst_mysql_options - status*: Tstatus + options*: St_mysql_options + status*: Status free_me*: my_bool # If free in mysql_close reconnect*: my_bool # set to 1 if automatic reconnect scramble*: array[0..(SCRAMBLE_LENGTH + 1) - 1, char] # session-wide random string @@ -655,37 +672,37 @@ type # from mysql_stmt_close if close had to cancel result set of this object. unbuffered_fetch_owner*: Pmy_bool - TMySQL* = Tst_mysql - PMySQL* = ptr TMySQL - Pst_mysql_res* = ptr Tst_mysql_res - Tst_mysql_res*{.final.} = object + MySQL* = St_mysql + PMySQL* = ptr MySQL + Pst_mysql_res* = ptr St_mysql_res + St_mysql_res*{.final.} = object row_count*: my_ulonglong fields*: PFIELD data*: PDATA data_cursor*: PROWS lengths*: ptr int # column lengths of current row handle*: PMySQL # for unbuffered reads - field_alloc*: TMEM_ROOT + field_alloc*: MEM_ROOT field_count*: cuint current_field*: cuint - row*: TROW # If unbuffered read - current_row*: TROW # buffer to current row + row*: ROW # If unbuffered read + current_row*: ROW # buffer to current row eof*: my_bool # Used by mysql_fetch_row unbuffered_fetch_cancelled*: my_bool # mysql_stmt_close() had to cancel this result methods*: Pst_mysql_methods - TRES* = Tst_mysql_res - PRES* = ptr TRES - Pst_mysql_stmt* = ptr Tst_mysql_stmt - PSTMT* = ptr TSTMT - Tst_mysql_methods*{.final.} = object + RES* = St_mysql_res + PRES* = ptr RES + Pst_mysql_stmt* = ptr St_mysql_stmt + PSTMT* = ptr STMT + St_mysql_methods*{.final.} = object read_query_result*: proc (MySQL: PMySQL): my_bool{.cdecl.} - advanced_command*: proc (MySQL: PMySQL, command: Tenum_server_command, header: cstring, + advanced_command*: proc (MySQL: PMySQL, command: Enum_server_command, header: cstring, header_length: int, arg: cstring, arg_length: int, skip_check: my_bool): my_bool read_rows*: proc (MySQL: PMySQL, fields: PFIELD, fields_count: cuint): PDATA use_result*: proc (MySQL: PMySQL): PRES - fetch_lengths*: proc (fto: ptr int, column: TROW, field_count: cuint) + fetch_lengths*: proc (fto: ptr int, column: ROW, field_count: cuint) flush_use_result*: proc (MySQL: PMySQL) list_fields*: proc (MySQL: PMySQL): PFIELD read_prepare_result*: proc (MySQL: PMySQL, stmt: PSTMT): my_bool @@ -698,11 +715,11 @@ type read_change_user_result*: proc (MySQL: PMySQL, buff: cstring, passwd: cstring): cint read_rowsfrom_cursor*: proc (stmt: PSTMT): cint - TMETHODS* = Tst_mysql_methods - PMETHODS* = ptr TMETHODS - Pst_mysql_manager* = ptr Tst_mysql_manager - Tst_mysql_manager*{.final.} = object - net*: TNET + METHODS* = St_mysql_methods + PMETHODS* = ptr METHODS + Pst_mysql_manager* = ptr St_mysql_manager + St_mysql_manager*{.final.} = object + net*: NET host*: cstring user*: cstring passwd*: cstring @@ -717,24 +734,24 @@ type net_buf_size*: cint last_error*: array[0..(MAX_MYSQL_MANAGER_ERR) - 1, char] - TMANAGER* = Tst_mysql_manager - PMANAGER* = ptr TMANAGER - Pst_mysql_parameters* = ptr Tst_mysql_parameters - Tst_mysql_parameters*{.final.} = object + MANAGER* = St_mysql_manager + PMANAGER* = ptr MANAGER + Pst_mysql_parameters* = ptr St_mysql_parameters + St_mysql_parameters*{.final.} = object p_max_allowed_packet*: ptr int p_net_buffer_length*: ptr int - TPARAMETERS* = Tst_mysql_parameters - PPARAMETERS* = ptr TPARAMETERS - Tenum_mysql_stmt_state* = enum + PARAMETERS* = St_mysql_parameters + PPARAMETERS* = ptr PARAMETERS + Enum_mysql_stmt_state* = enum STMT_INIT_DONE = 1, STMT_PREPARE_DONE, STMT_EXECUTE_DONE, STMT_FETCH_DONE - Pst_mysql_bind* = ptr Tst_mysql_bind - Tst_mysql_bind*{.final.} = object + Pst_mysql_bind* = ptr St_mysql_bind + St_mysql_bind*{.final.} = object len*: int # output length pointer is_null*: Pmy_bool # Pointer to null indicator buffer*: pointer # buffer to get/put data error*: PMy_bool # set this if you want to track data truncations happened during fetch - buffer_type*: Tenum_field_types # buffer type + buffer_type*: Enum_field_types # buffer type buffer_length*: int # buffer length, must be set for str/binary # Following are for internal use. Set by mysql_stmt_bind_param row_ptr*: ptr byte # for the current data position @@ -750,15 +767,15 @@ type fetch_result*: proc (para1: Pst_mysql_bind, para2: PFIELD, row: PPbyte) skip_result*: proc (para1: Pst_mysql_bind, para2: PFIELD, row: PPbyte) - TBIND* = Tst_mysql_bind - PBIND* = ptr TBIND # statement handler - Tst_mysql_stmt*{.final.} = object - mem_root*: TMEM_ROOT # root allocations + BIND* = St_mysql_bind + PBIND* = ptr BIND # statement handler + St_mysql_stmt*{.final.} = object + mem_root*: MEM_ROOT # root allocations mysql*: PMySQL # connection handle params*: PBIND # input parameters `bind`*: PBIND # input parameters fields*: PFIELD # result set metadata - result*: TDATA # cached result set + result*: DATA # cached result set data_cursor*: PROWS # current row in cached result affected_rows*: my_ulonglong # copy of mysql->affected_rows after statement execution insert_id*: my_ulonglong @@ -771,7 +788,7 @@ type last_errno*: cuint # error code param_count*: cuint # input parameter count field_count*: cuint # number of columns in result set - state*: Tenum_mysql_stmt_state # statement state + state*: Enum_mysql_stmt_state # statement state last_error*: array[0..(ERRMSG_SIZE) - 1, char] # error message sqlstate*: array[0..(SQLSTATE_LENGTH + 1) - 1, char] send_types_to_server*: my_bool # Types of input parameters should be sent to server @@ -780,10 +797,23 @@ type unbuffered_fetch_cancelled*: my_bool update_max_length*: my_bool - TSTMT* = Tst_mysql_stmt + STMT* = St_mysql_stmt - Tenum_stmt_attr_type* = enum + Enum_stmt_attr_type* = enum STMT_ATTR_UPDATE_MAX_LENGTH, STMT_ATTR_CURSOR_TYPE, STMT_ATTR_PREFETCH_ROWS +{.deprecated: [Tst_dynamic_array: St_dynamic_array, Tst_mysql_options: St_mysql_options, + TDYNAMIC_ARRAY: DYNAMIC_ARRAY, Tprotocol_type: Protocol_type, + Trpl_type: Rpl_type, Tcharset_info_st: Charset_info_st, + TCHARSET_INFO: CHARSET_INFO, Tcharacter_set: Character_set, + TMY_CHARSET_INFO: MY_CHARSET_INFO, Tst_mysql: St_mysql, + Tst_mysql_methods: St_mysql_methods, TMySql: MySql, + Tst_mysql_res: St_mysql_res, TMETHODS: METHODS, TRES: RES, + Tst_mysql_manager: St_mysql_manager, TMANAGER: MANAGER, + Tst_mysql_parameters: St_mysql_parameters, TPARAMETERS: PARAMETERS, + Tenum_mysql_stmt_state: Enum_mysql_stmt_state, + Tst_mysql_bind: St_mysql_bind, TBIND: BIND, Tst_mysql_stmt: St_mysql_stmt, + TSTMT: STMT, Tenum_stmt_attr_type: Enum_stmt_attr_type, + Tstatus: Status].} proc server_init*(argc: cint, argv: cstringArray, groups: cstringArray): cint{. cdecl, dynlib: lib, importc: "mysql_server_init".} @@ -817,9 +847,9 @@ proc fetch_field_direct*(res: PRES, fieldnr: cuint): PFIELD{.stdcall, dynlib: lib, importc: "mysql_fetch_field_direct".} proc fetch_fields*(res: PRES): PFIELD{.stdcall, dynlib: lib, importc: "mysql_fetch_fields".} -proc row_tell*(res: PRES): TROW_OFFSET{.stdcall, dynlib: lib, +proc row_tell*(res: PRES): ROW_OFFSET{.stdcall, dynlib: lib, importc: "mysql_row_tell".} -proc field_tell*(res: PRES): TFIELD_OFFSET{.stdcall, dynlib: lib, +proc field_tell*(res: PRES): FIELD_OFFSET{.stdcall, dynlib: lib, importc: "mysql_field_tell".} proc field_count*(MySQL: PMySQL): cuint{.stdcall, dynlib: lib, importc: "mysql_field_count".} @@ -895,7 +925,7 @@ proc disable_reads_from_master*(MySQL: PMySQL){.stdcall, dynlib: lib, importc: " # get the value of the master read flag proc reads_from_master_enabled*(MySQL: PMySQL): my_bool{.stdcall, dynlib: lib, importc: "mysql_reads_from_master_enabled".} -proc rpl_query_type*(q: cstring, length: cint): Trpl_type{.stdcall, dynlib: lib, +proc rpl_query_type*(q: cstring, length: cint): Rpl_type{.stdcall, dynlib: lib, importc: "mysql_rpl_query_type".} # discover the master and its slaves proc rpl_probe*(MySQL: PMySQL): my_bool{.stdcall, dynlib: lib, importc: "mysql_rpl_probe".} @@ -904,14 +934,14 @@ proc set_master*(MySQL: PMySQL, host: cstring, port: cuint, user: cstring, passw stdcall, dynlib: lib, importc: "mysql_set_master".} proc add_slave*(MySQL: PMySQL, host: cstring, port: cuint, user: cstring, passwd: cstring): cint{. stdcall, dynlib: lib, importc: "mysql_add_slave".} -proc shutdown*(MySQL: PMySQL, shutdown_level: Tenum_shutdown_level): cint{.stdcall, +proc shutdown*(MySQL: PMySQL, shutdown_level: Enum_shutdown_level): cint{.stdcall, dynlib: lib, importc: "mysql_shutdown".} proc dump_debug_info*(MySQL: PMySQL): cint{.stdcall, dynlib: lib, importc: "mysql_dump_debug_info".} proc refresh*(sql: PMySQL, refresh_options: cuint): cint{.stdcall, dynlib: lib, importc: "mysql_refresh".} proc kill*(MySQL: PMySQL, pid: int): cint{.stdcall, dynlib: lib, importc: "mysql_kill".} -proc set_server_option*(MySQL: PMySQL, option: Tenum_mysql_set_option): cint{.stdcall, +proc set_server_option*(MySQL: PMySQL, option: Enum_mysql_set_option): cint{.stdcall, dynlib: lib, importc: "mysql_set_server_option".} proc ping*(MySQL: PMySQL): cint{.stdcall, dynlib: lib, importc: "mysql_ping".} proc stat*(MySQL: PMySQL): cstring{.stdcall, dynlib: lib, importc: "mysql_stat".} @@ -933,17 +963,17 @@ proc list_tables*(MySQL: PMySQL, wild: cstring): PRES{.stdcall, dynlib: lib, importc: "mysql_list_tables".} proc list_processes*(MySQL: PMySQL): PRES{.stdcall, dynlib: lib, importc: "mysql_list_processes".} -proc options*(MySQL: PMySQL, option: Toption, arg: cstring): cint{.stdcall, dynlib: lib, +proc options*(MySQL: PMySQL, option: Option, arg: cstring): cint{.stdcall, dynlib: lib, importc: "mysql_options".} proc free_result*(result: PRES){.stdcall, dynlib: lib, importc: "mysql_free_result".} proc data_seek*(result: PRES, offset: my_ulonglong){.stdcall, dynlib: lib, importc: "mysql_data_seek".} -proc row_seek*(result: PRES, offset: TROW_OFFSET): TROW_OFFSET{.stdcall, +proc row_seek*(result: PRES, offset: ROW_OFFSET): ROW_OFFSET{.stdcall, dynlib: lib, importc: "mysql_row_seek".} -proc field_seek*(result: PRES, offset: TFIELD_OFFSET): TFIELD_OFFSET{.stdcall, +proc field_seek*(result: PRES, offset: FIELD_OFFSET): FIELD_OFFSET{.stdcall, dynlib: lib, importc: "mysql_field_seek".} -proc fetch_row*(result: PRES): TROW{.stdcall, dynlib: lib, +proc fetch_row*(result: PRES): ROW{.stdcall, dynlib: lib, importc: "mysql_fetch_row".} proc fetch_lengths*(result: PRES): ptr int{.stdcall, dynlib: lib, importc: "mysql_fetch_lengths".} @@ -990,9 +1020,9 @@ proc stmt_store_result*(stmt: PSTMT): cint{.stdcall, dynlib: lib, importc: "mysql_stmt_store_result".} proc stmt_param_count*(stmt: PSTMT): int{.stdcall, dynlib: lib, importc: "mysql_stmt_param_count".} -proc stmt_attr_set*(stmt: PSTMT, attr_type: Tenum_stmt_attr_type, attr: pointer): my_bool{. +proc stmt_attr_set*(stmt: PSTMT, attr_type: Enum_stmt_attr_type, attr: pointer): my_bool{. stdcall, dynlib: lib, importc: "mysql_stmt_attr_set".} -proc stmt_attr_get*(stmt: PSTMT, attr_type: Tenum_stmt_attr_type, attr: pointer): my_bool{. +proc stmt_attr_get*(stmt: PSTMT, attr_type: Enum_stmt_attr_type, attr: pointer): my_bool{. stdcall, dynlib: lib, importc: "mysql_stmt_attr_get".} proc stmt_bind_param*(stmt: PSTMT, bnd: PBIND): my_bool{.stdcall, dynlib: lib, importc: "mysql_stmt_bind_param".} @@ -1017,9 +1047,9 @@ proc stmt_error*(stmt: PSTMT): cstring{.stdcall, dynlib: lib, importc: "mysql_stmt_error".} proc stmt_sqlstate*(stmt: PSTMT): cstring{.stdcall, dynlib: lib, importc: "mysql_stmt_sqlstate".} -proc stmt_row_seek*(stmt: PSTMT, offset: TROW_OFFSET): TROW_OFFSET{.stdcall, +proc stmt_row_seek*(stmt: PSTMT, offset: ROW_OFFSET): ROW_OFFSET{.stdcall, dynlib: lib, importc: "mysql_stmt_row_seek".} -proc stmt_row_tell*(stmt: PSTMT): TROW_OFFSET{.stdcall, dynlib: lib, +proc stmt_row_tell*(stmt: PSTMT): ROW_OFFSET{.stdcall, dynlib: lib, importc: "mysql_stmt_row_tell".} proc stmt_data_seek*(stmt: PSTMT, offset: my_ulonglong){.stdcall, dynlib: lib, importc: "mysql_stmt_data_seek".} @@ -1066,7 +1096,7 @@ proc IS_BLOB(n: int32): bool = proc IS_NUM_FIELD(f: Pst_mysql_field): bool = result = (f.flags and NUM_FLAG) != 0 -proc IS_NUM(t: Tenum_field_types): bool = +proc IS_NUM(t: Enum_field_types): bool = result = (t <= FIELD_TYPE_INT24) or (t == FIELD_TYPE_YEAR) or (t == FIELD_TYPE_NEWDECIMAL) diff --git a/lib/wrappers/odbcsql.nim b/lib/wrappers/odbcsql.nim index 77719e85f..22297497c 100644 --- a/lib/wrappers/odbcsql.nim +++ b/lib/wrappers/odbcsql.nim @@ -30,28 +30,39 @@ else: type TSqlChar* = char TSqlSmallInt* = int16 - TSqlUSmallInt* = int16 - TSqlHandle* = pointer - TSqlHEnv* = TSqlHandle - TSqlHDBC* = TSqlHandle - TSqlHStmt* = TSqlHandle - TSqlHDesc* = TSqlHandle + SqlUSmallInt* = int16 + SqlHandle* = pointer + SqlHEnv* = SqlHandle + SqlHDBC* = SqlHandle + SqlHStmt* = SqlHandle + SqlHDesc* = SqlHandle TSqlInteger* = int - TSqlUInteger* = int - TSqlPointer* = pointer + SqlUInteger* = int + SqlPointer* = pointer TSqlReal* = cfloat TSqlDouble* = cdouble TSqlFloat* = cdouble - TSqlHWND* = pointer + SqlHWND* = pointer PSQLCHAR* = cstring PSQLINTEGER* = ptr TSqlInteger - PSQLUINTEGER* = ptr TSqlUInteger + PSQLUINTEGER* = ptr SqlUInteger PSQLSMALLINT* = ptr TSqlSmallInt - PSQLUSMALLINT* = ptr TSqlUSmallInt + PSQLUSMALLINT* = ptr SqlUSmallInt PSQLREAL* = ptr TSqlReal PSQLDOUBLE* = ptr TSqlDouble PSQLFLOAT* = ptr TSqlFloat - PSQLHANDLE* = ptr TSqlHandle + PSQLHANDLE* = ptr SqlHandle +{.deprecated: [ + # TSqlChar: TSqlChar, # Name conflict if we drop`T` + # TSqlSmallInt: TSqlSmallInt, # Name conflict if we drop`T` + TSqlUSmallInt: SqlUSmallInt, TSqlHandle: SqlHandle, TSqlHEnv: SqlHEnv, + TSqlHDBC: SqlHDBC, TSqlHStmt: SqlHStmt, TSqlHDesc: SqlHDesc, + # TSqlInteger: TSqlInteger, # Name conflict if we drop `T` + TSqlUInteger: SqlUInteger, TSqlPointer: SqlPointer, + # TSqlReal: TSqlReal, # Name conflict if we drop`T` + # TSqlDouble: TSqlDouble, # Name conflict if we drop`T` + # TSqlFloat: TSqlFloat, # Name conflict if we drop `T` + TSqlHWND: SqlHWND].} const # SQL data type codes SQL_UNKNOWN_TYPE* = 0 @@ -199,24 +210,24 @@ const type SQL_DATE_STRUCT* {.final, pure.} = object Year*: TSqlSmallInt - Month*: TSqlUSmallInt - Day*: TSqlUSmallInt + Month*: SqlUSmallInt + Day*: SqlUSmallInt PSQL_DATE_STRUCT* = ptr SQL_DATE_STRUCT SQL_TIME_STRUCT* {.final, pure.} = object - Hour*: TSqlUSmallInt - Minute*: TSqlUSmallInt - Second*: TSqlUSmallInt + Hour*: SqlUSmallInt + Minute*: SqlUSmallInt + Second*: SqlUSmallInt PSQL_TIME_STRUCT* = ptr SQL_TIME_STRUCT SQL_TIMESTAMP_STRUCT* {.final, pure.} = object - Year*: TSqlUSmallInt - Month*: TSqlUSmallInt - Day*: TSqlUSmallInt - Hour*: TSqlUSmallInt - Minute*: TSqlUSmallInt - Second*: TSqlUSmallInt - Fraction*: TSqlUInteger + Year*: SqlUSmallInt + Month*: SqlUSmallInt + Day*: SqlUSmallInt + Hour*: SqlUSmallInt + Minute*: SqlUSmallInt + Second*: SqlUSmallInt + Fraction*: SqlUInteger PSQL_TIMESTAMP_STRUCT* = ptr SQL_TIMESTAMP_STRUCT @@ -509,11 +520,11 @@ const SQL_FETCH_PRIOR* = 4 SQL_FETCH_ABSOLUTE* = 5 SQL_FETCH_RELATIVE* = 6 - SQL_NULL_HENV* = TSqlHEnv(nil) - SQL_NULL_HDBC* = TSqlHDBC(nil) - SQL_NULL_HSTMT* = TSqlHStmt(nil) - SQL_NULL_HDESC* = TSqlHDesc(nil) #* null handle used in place of parent handle when allocating HENV */ - SQL_NULL_HANDLE* = TSqlHandle(nil) #* Values that may appear in the result set of SQLSpecialColumns() */ + SQL_NULL_HENV* = SqlHEnv(nil) + SQL_NULL_HDBC* = SqlHDBC(nil) + SQL_NULL_HSTMT* = SqlHStmt(nil) + SQL_NULL_HDESC* = SqlHDesc(nil) #* null handle used in place of parent handle when allocating HENV */ + SQL_NULL_HANDLE* = SqlHandle(nil) #* Values that may appear in the result set of SQLSpecialColumns() */ SQL_SCOPE_CURROW* = 0 SQL_SCOPE_TRANSACTION* = 1 SQL_SCOPE_SESSION* = 2 #* Column types and scopes in SQLSpecialColumns. */ @@ -622,167 +633,167 @@ const ODBC_CONFIG_SYS_DSN* = 5 ODBC_REMOVE_SYS_DSN* = 6 -proc SQLAllocHandle*(HandleType: TSqlSmallInt, InputHandle: TSqlHandle, - OutputHandlePtr: var TSqlHandle): TSqlSmallInt{. +proc SQLAllocHandle*(HandleType: TSqlSmallInt, InputHandle: SqlHandle, + OutputHandlePtr: var SqlHandle): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLSetEnvAttr*(EnvironmentHandle: TSqlHEnv, Attribute: TSqlInteger, - Value: TSqlPointer, StringLength: TSqlInteger): TSqlSmallInt{. +proc SQLSetEnvAttr*(EnvironmentHandle: SqlHEnv, Attribute: TSqlInteger, + Value: SqlPointer, StringLength: TSqlInteger): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLGetEnvAttr*(EnvironmentHandle: TSqlHEnv, Attribute: TSqlInteger, - Value: TSqlPointer, BufferLength: TSqlInteger, +proc SQLGetEnvAttr*(EnvironmentHandle: SqlHEnv, Attribute: TSqlInteger, + Value: SqlPointer, BufferLength: TSqlInteger, StringLength: PSQLINTEGER): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLFreeHandle*(HandleType: TSqlSmallInt, Handle: TSqlHandle): TSqlSmallInt{. +proc SQLFreeHandle*(HandleType: TSqlSmallInt, Handle: SqlHandle): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLGetDiagRec*(HandleType: TSqlSmallInt, Handle: TSqlHandle, +proc SQLGetDiagRec*(HandleType: TSqlSmallInt, Handle: SqlHandle, RecNumber: TSqlSmallInt, Sqlstate: PSQLCHAR, NativeError: var TSqlInteger, MessageText: PSQLCHAR, BufferLength: TSqlSmallInt, TextLength: var TSqlSmallInt): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLGetDiagField*(HandleType: TSqlSmallInt, Handle: TSqlHandle, +proc SQLGetDiagField*(HandleType: TSqlSmallInt, Handle: SqlHandle, RecNumber: TSqlSmallInt, DiagIdentifier: TSqlSmallInt, - DiagInfoPtr: TSqlPointer, BufferLength: TSqlSmallInt, + DiagInfoPtr: SqlPointer, BufferLength: TSqlSmallInt, StringLengthPtr: var TSqlSmallInt): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLConnect*(ConnectionHandle: TSqlHDBC, ServerName: PSQLCHAR, +proc SQLConnect*(ConnectionHandle: SqlHDBC, ServerName: PSQLCHAR, NameLength1: TSqlSmallInt, UserName: PSQLCHAR, NameLength2: TSqlSmallInt, Authentication: PSQLCHAR, NameLength3: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLDisconnect*(ConnectionHandle: TSqlHDBC): TSqlSmallInt{.dynlib: odbclib, +proc SQLDisconnect*(ConnectionHandle: SqlHDBC): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLDriverConnect*(hdbc: TSqlHDBC, hwnd: TSqlHWND, szCsin: cstring, +proc SQLDriverConnect*(hdbc: SqlHDBC, hwnd: SqlHWND, szCsin: cstring, szCLen: TSqlSmallInt, szCsout: cstring, cbCSMax: TSqlSmallInt, cbCsOut: var TSqlSmallInt, - f: TSqlUSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLBrowseConnect*(hdbc: TSqlHDBC, szConnStrIn: PSQLCHAR, + f: SqlUSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.} +proc SQLBrowseConnect*(hdbc: SqlHDBC, szConnStrIn: PSQLCHAR, cbConnStrIn: TSqlSmallInt, szConnStrOut: PSQLCHAR, cbConnStrOutMax: TSqlSmallInt, cbConnStrOut: var TSqlSmallInt): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLExecDirect*(StatementHandle: TSqlHStmt, StatementText: PSQLCHAR, +proc SQLExecDirect*(StatementHandle: SqlHStmt, StatementText: PSQLCHAR, TextLength: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLPrepare*(StatementHandle: TSqlHStmt, StatementText: PSQLCHAR, +proc SQLPrepare*(StatementHandle: SqlHStmt, StatementText: PSQLCHAR, TextLength: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLCloseCursor*(StatementHandle: TSqlHStmt): TSqlSmallInt{.dynlib: odbclib, +proc SQLCloseCursor*(StatementHandle: SqlHStmt): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLExecute*(StatementHandle: TSqlHStmt): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLFetch*(StatementHandle: TSqlHStmt): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLNumResultCols*(StatementHandle: TSqlHStmt, ColumnCount: var TSqlSmallInt): TSqlSmallInt{. +proc SQLExecute*(StatementHandle: SqlHStmt): TSqlSmallInt{.dynlib: odbclib, importc.} +proc SQLFetch*(StatementHandle: SqlHStmt): TSqlSmallInt{.dynlib: odbclib, importc.} +proc SQLNumResultCols*(StatementHandle: SqlHStmt, ColumnCount: var TSqlSmallInt): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLDescribeCol*(StatementHandle: TSqlHStmt, ColumnNumber: TSqlUSmallInt, +proc SQLDescribeCol*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt, ColumnName: PSQLCHAR, BufferLength: TSqlSmallInt, NameLength: var TSqlSmallInt, DataType: var TSqlSmallInt, - ColumnSize: var TSqlUInteger, + ColumnSize: var SqlUInteger, DecimalDigits: var TSqlSmallInt, Nullable: var TSqlSmallInt): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLFetchScroll*(StatementHandle: TSqlHStmt, FetchOrientation: TSqlSmallInt, +proc SQLFetchScroll*(StatementHandle: SqlHStmt, FetchOrientation: TSqlSmallInt, FetchOffset: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLExtendedFetch*(hstmt: TSqlHStmt, fFetchType: TSqlUSmallInt, +proc SQLExtendedFetch*(hstmt: SqlHStmt, fFetchType: SqlUSmallInt, irow: TSqlInteger, pcrow: PSQLUINTEGER, rgfRowStatus: PSQLUSMALLINT): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLGetData*(StatementHandle: TSqlHStmt, ColumnNumber: TSqlUSmallInt, - TargetType: TSqlSmallInt, TargetValue: TSqlPointer, +proc SQLGetData*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt, + TargetType: TSqlSmallInt, TargetValue: SqlPointer, BufferLength: TSqlInteger, StrLen_or_Ind: PSQLINTEGER): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLSetStmtAttr*(StatementHandle: TSqlHStmt, Attribute: TSqlInteger, - Value: TSqlPointer, StringLength: TSqlInteger): TSqlSmallInt{. +proc SQLSetStmtAttr*(StatementHandle: SqlHStmt, Attribute: TSqlInteger, + Value: SqlPointer, StringLength: TSqlInteger): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLGetStmtAttr*(StatementHandle: TSqlHStmt, Attribute: TSqlInteger, - Value: TSqlPointer, BufferLength: TSqlInteger, +proc SQLGetStmtAttr*(StatementHandle: SqlHStmt, Attribute: TSqlInteger, + Value: SqlPointer, BufferLength: TSqlInteger, StringLength: PSQLINTEGER): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLGetInfo*(ConnectionHandle: TSqlHDBC, InfoType: TSqlUSmallInt, - InfoValue: TSqlPointer, BufferLength: TSqlSmallInt, +proc SQLGetInfo*(ConnectionHandle: SqlHDBC, InfoType: SqlUSmallInt, + InfoValue: SqlPointer, BufferLength: TSqlSmallInt, StringLength: PSQLSMALLINT): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLBulkOperations*(StatementHandle: TSqlHStmt, Operation: TSqlSmallInt): TSqlSmallInt{. +proc SQLBulkOperations*(StatementHandle: SqlHStmt, Operation: TSqlSmallInt): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLPutData*(StatementHandle: TSqlHStmt, Data: TSqlPointer, +proc SQLPutData*(StatementHandle: SqlHStmt, Data: SqlPointer, StrLen_or_Ind: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLBindCol*(StatementHandle: TSqlHStmt, ColumnNumber: TSqlUSmallInt, - TargetType: TSqlSmallInt, TargetValue: TSqlPointer, +proc SQLBindCol*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt, + TargetType: TSqlSmallInt, TargetValue: SqlPointer, BufferLength: TSqlInteger, StrLen_or_Ind: PSQLINTEGER): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLSetPos*(hstmt: TSqlHStmt, irow: TSqlUSmallInt, fOption: TSqlUSmallInt, - fLock: TSqlUSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLDataSources*(EnvironmentHandle: TSqlHEnv, Direction: TSqlUSmallInt, +proc SQLSetPos*(hstmt: SqlHStmt, irow: SqlUSmallInt, fOption: SqlUSmallInt, + fLock: SqlUSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.} +proc SQLDataSources*(EnvironmentHandle: SqlHEnv, Direction: SqlUSmallInt, ServerName: PSQLCHAR, BufferLength1: TSqlSmallInt, NameLength1: PSQLSMALLINT, Description: PSQLCHAR, BufferLength2: TSqlSmallInt, NameLength2: PSQLSMALLINT): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLDrivers*(EnvironmentHandle: TSqlHEnv, Direction: TSqlUSmallInt, +proc SQLDrivers*(EnvironmentHandle: SqlHEnv, Direction: SqlUSmallInt, DriverDescription: PSQLCHAR, BufferLength1: TSqlSmallInt, DescriptionLength1: PSQLSMALLINT, DriverAttributes: PSQLCHAR, BufferLength2: TSqlSmallInt, AttributesLength2: PSQLSMALLINT): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLSetConnectAttr*(ConnectionHandle: TSqlHDBC, Attribute: TSqlInteger, - Value: TSqlPointer, StringLength: TSqlInteger): TSqlSmallInt{. +proc SQLSetConnectAttr*(ConnectionHandle: SqlHDBC, Attribute: TSqlInteger, + Value: SqlPointer, StringLength: TSqlInteger): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLGetCursorName*(StatementHandle: TSqlHStmt, CursorName: PSQLCHAR, +proc SQLGetCursorName*(StatementHandle: SqlHStmt, CursorName: PSQLCHAR, BufferLength: TSqlSmallInt, NameLength: PSQLSMALLINT): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLSetCursorName*(StatementHandle: TSqlHStmt, CursorName: PSQLCHAR, +proc SQLSetCursorName*(StatementHandle: SqlHStmt, CursorName: PSQLCHAR, NameLength: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLRowCount*(StatementHandle: TSqlHStmt, RowCount: var TSqlInteger): TSqlSmallInt{. +proc SQLRowCount*(StatementHandle: SqlHStmt, RowCount: var TSqlInteger): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLBindParameter*(hstmt: TSqlHStmt, ipar: TSqlUSmallInt, +proc SQLBindParameter*(hstmt: SqlHStmt, ipar: SqlUSmallInt, fParamType: TSqlSmallInt, fCType: TSqlSmallInt, - fSqlType: TSqlSmallInt, cbColDef: TSqlUInteger, - ibScale: TSqlSmallInt, rgbValue: TSqlPointer, + fSqlType: TSqlSmallInt, cbColDef: SqlUInteger, + ibScale: TSqlSmallInt, rgbValue: SqlPointer, cbValueMax: TSqlInteger, pcbValue: PSQLINTEGER): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLFreeStmt*(StatementHandle: TSqlHStmt, Option: TSqlUSmallInt): TSqlSmallInt{. +proc SQLFreeStmt*(StatementHandle: SqlHStmt, Option: SqlUSmallInt): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLColAttribute*(StatementHandle: TSqlHStmt, ColumnNumber: TSqlUSmallInt, - FieldIdentifier: TSqlUSmallInt, +proc SQLColAttribute*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt, + FieldIdentifier: SqlUSmallInt, CharacterAttribute: PSQLCHAR, BufferLength: TSqlSmallInt, StringLength: PSQLSMALLINT, - NumericAttribute: TSqlPointer): TSqlSmallInt{. + NumericAttribute: SqlPointer): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLEndTran*(HandleType: TSqlSmallInt, Handle: TSqlHandle, +proc SQLEndTran*(HandleType: TSqlSmallInt, Handle: SqlHandle, CompletionType: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLTables*(hstmt: TSqlHStmt, szTableQualifier: PSQLCHAR, +proc SQLTables*(hstmt: SqlHStmt, szTableQualifier: PSQLCHAR, cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR, cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR, cbTableName: TSqlSmallInt, szTableType: PSQLCHAR, cbTableType: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLColumns*(hstmt: TSqlHStmt, szTableQualifier: PSQLCHAR, +proc SQLColumns*(hstmt: SqlHStmt, szTableQualifier: PSQLCHAR, cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR, cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR, cbTableName: TSqlSmallInt, szColumnName: PSQLCHAR, cbColumnName: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLSpecialColumns*(StatementHandle: TSqlHStmt, IdentifierType: TSqlUSmallInt, +proc SQLSpecialColumns*(StatementHandle: SqlHStmt, IdentifierType: SqlUSmallInt, CatalogName: PSQLCHAR, NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR, NameLength2: TSqlSmallInt, TableName: PSQLCHAR, NameLength3: TSqlSmallInt, - Scope: TSqlUSmallInt, - Nullable: TSqlUSmallInt): TSqlSmallInt{. + Scope: SqlUSmallInt, + Nullable: SqlUSmallInt): TSqlSmallInt{. dynlib: odbclib, importc.} -proc SQLProcedures*(hstmt: TSqlHStmt, szTableQualifier: PSQLCHAR, +proc SQLProcedures*(hstmt: SqlHStmt, szTableQualifier: PSQLCHAR, cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR, cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR, cbTableName: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLPrimaryKeys*(hstmt: TSqlHStmt, CatalogName: PSQLCHAR, +proc SQLPrimaryKeys*(hstmt: SqlHStmt, CatalogName: PSQLCHAR, NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR, NameLength2: TSqlSmallInt, TableName: PSQLCHAR, NameLength3: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLProcedureColumns*(hstmt: TSqlHStmt, CatalogName: PSQLCHAR, +proc SQLProcedureColumns*(hstmt: SqlHStmt, CatalogName: PSQLCHAR, NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR, NameLength2: TSqlSmallInt, ProcName: PSQLCHAR, NameLength3: TSqlSmallInt, ColumnName: PSQLCHAR, NameLength4: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.} -proc SQLStatistics*(hstmt: TSqlHStmt, CatalogName: PSQLCHAR, +proc SQLStatistics*(hstmt: SqlHStmt, CatalogName: PSQLCHAR, NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR, NameLength2: TSqlSmallInt, TableName: PSQLCHAR, - NameLength3: TSqlSmallInt, Unique: TSqlUSmallInt, - Reserved: TSqlUSmallInt): TSqlSmallInt {. + NameLength3: TSqlSmallInt, Unique: SqlUSmallInt, + Reserved: SqlUSmallInt): TSqlSmallInt {. dynlib: odbclib, importc.} {.pop.} diff --git a/lib/wrappers/pdcurses.nim b/lib/wrappers/pdcurses.nim index bed69648a..7e7a6c47f 100644 --- a/lib/wrappers/pdcurses.nim +++ b/lib/wrappers/pdcurses.nim @@ -406,15 +406,15 @@ type button*: array[0..3 - 1, cshort] # state of each button changes*: cint # flags indicating what has changed with the mouse - TMEVENT*{.pure, final.} = object + MEVENT*{.pure, final.} = object id*: cshort # unused, always 0 x*: cint y*: cint - z*: cint # x, y same as MOUSE_STATUS; z unused + z*: cint # x, y same as TMOUSE_STATUS; z unused bstate*: cunsignedlong # equivalent to changes + button[], but - # in the same format as used for mousemask() + # in the same format as used for mousemask() - TWINDOW*{.pure, final.} = object + WINDOW*{.pure, final.} = object cury*: cint # current pseudo-cursor curx*: cint maxy*: cint # max window coordinates @@ -439,26 +439,30 @@ type delayms*: cint # milliseconds of delay for getch() parx*: cint pary*: cint # coords relative to parent (0,0) - parent*: ptr TWINDOW # subwin's pointer to parent win + parent*: ptr WINDOW # subwin's pointer to parent win - TPANELOBS*{.pure, final.} = object - above*: ptr TPANELOBS - pan*: ptr TPANEL + PANELOBS*{.pure, final.} = object + above*: ptr PANELOBS + pan*: ptr PANEL - TPANEL*{.pure, final.} = object - win*: ptr TWINDOW + PANEL*{.pure, final.} = object + win*: ptr WINDOW wstarty*: cint wendy*: cint wstartx*: cint wendx*: cint - below*: ptr TPANEL - above*: ptr TPANEL + below*: ptr PANEL + above*: ptr PANEL user*: pointer - obscure*: ptr TPANELOBS + obscure*: ptr PANELOBS +{.deprecated: [ + #TMOUSE_STATUS: MOUSE_STATUS, # Name conflict when we drop the `T` + TMEVENT: MEVENT, TWINDOW: WINDOW, + TPANELOBS: PANELOBS, TPANEL:PANEL].} when unixOS: type - TSCREEN*{.pure, final.} = object + SCREEN*{.pure, final.} = object alive*: cunsignedchar # if initscr() called, and not endwin() autocr*: cunsignedchar # if cr -> lf cbreak*: cunsignedchar # if terminal unbuffered @@ -481,7 +485,7 @@ when unixOS: map_mbe_to_key*: cunsignedlong # map mouse buttons to slk mouse_wait*: cint # time to wait (in ms) for a button release after a press slklines*: cint # lines in use by slk_init() - slk_winptr*: ptr TWINDOW # window for slk + slk_winptr*: ptr WINDOW # window for slk linesrippedoff*: cint # lines ripped off via ripoffline() linesrippedoffontop*: cint # lines ripped off on top via ripoffline() delaytenths*: cint # 1/10ths second to wait block getch() for @@ -499,9 +503,10 @@ when unixOS: sb_cur_y*: cint sb_cur_x*: cint line_color*: cshort # color of line attributes - default -1 + {.deprecated: [TSCREEN: SCREEN].} else: type - TSCREEN*{.pure, final.} = object + SCREEN*{.pure, final.} = object alive*: cunsignedchar # if initscr() called, and not endwin() autocr*: cunsignedchar # if cr -> lf cbreak*: cunsignedchar # if terminal unbuffered @@ -524,7 +529,7 @@ else: map_mbe_to_key*: cunsignedlong # map mouse buttons to slk mouse_wait*: cint # time to wait (in ms) for a button release after a press slklines*: cint # lines in use by slk_init() - slk_winptr*: ptr TWINDOW # window for slk + slk_winptr*: ptr WINDOW # window for slk linesrippedoff*: cint # lines ripped off via ripoffline() linesrippedoffontop*: cint # lines ripped off on top via ripoffline() delaytenths*: cint # 1/10ths second to wait block getch() for @@ -534,14 +539,15 @@ else: return_key_modifiers*: cunsignedchar # TRUE if modifier keys are returned as "real" keys key_code*: cunsignedchar # TRUE if last key is a special key; line_color*: cshort # color of line attributes - default -1 + {.deprecated: [TSCREEN: SCREEN].} var LINES*{.importc: "LINES", dynlib: pdcursesdll.}: cint COLS*{.importc: "COLS", dynlib: pdcursesdll.}: cint - stdscr*{.importc: "stdscr", dynlib: pdcursesdll.}: ptr TWINDOW - curscr*{.importc: "curscr", dynlib: pdcursesdll.}: ptr TWINDOW - SP*{.importc: "SP", dynlib: pdcursesdll.}: ptr TSCREEN - Mouse_status*{.importc: "Mouse_status", dynlib: pdcursesdll.}: TMOUSE_STATUS + stdscr*{.importc: "stdscr", dynlib: pdcursesdll.}: ptr WINDOW + curscr*{.importc: "curscr", dynlib: pdcursesdll.}: ptr WINDOW + SP*{.importc: "SP", dynlib: pdcursesdll.}: ptr SCREEN + Mouse_status*{.importc: "Mouse_status", dynlib: pdcursesdll.}: MOUSE_STATUS COLORS*{.importc: "COLORS", dynlib: pdcursesdll.}: cint COLOR_PAIRS*{.importc: "COLOR_PAIRS", dynlib: pdcursesdll.}: cint TABSIZE*{.importc: "TABSIZE", dynlib: pdcursesdll.}: cint @@ -690,14 +696,14 @@ proc border*(a2: cunsignedlong; a3: cunsignedlong; a4: cunsignedlong; a5: cunsignedlong; a6: cunsignedlong; a7: cunsignedlong; a8: cunsignedlong; a9: cunsignedlong): cint{.extdecl, importc: "border", dynlib: pdcursesdll.} -proc box*(a2: ptr TWINDOW; a3: cunsignedlong; a4: cunsignedlong): cint{.extdecl, +proc box*(a2: ptr WINDOW; a3: cunsignedlong; a4: cunsignedlong): cint{.extdecl, importc: "box", dynlib: pdcursesdll.} proc can_change_color*(): cunsignedchar{.extdecl, importc: "can_change_color", dynlib: pdcursesdll.} proc cbreak*(): cint{.extdecl, importc: "cbreak", dynlib: pdcursesdll.} proc chgat*(a2: cint; a3: cunsignedlong; a4: cshort; a5: pointer): cint{.extdecl, importc: "chgat", dynlib: pdcursesdll.} -proc clearok*(a2: ptr TWINDOW; a3: cunsignedchar): cint{.extdecl, +proc clearok*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, importc: "clearok", dynlib: pdcursesdll.} proc clear*(): cint{.extdecl, importc: "clear", dynlib: pdcursesdll.} proc clrtobot*(): cint{.extdecl, importc: "clrtobot", dynlib: pdcursesdll.} @@ -706,7 +712,7 @@ proc color_content*(a2: cshort; a3: ptr cshort; a4: ptr cshort; a5: ptr cshort): extdecl, importc: "color_content", dynlib: pdcursesdll.} proc color_set*(a2: cshort; a3: pointer): cint{.extdecl, importc: "color_set", dynlib: pdcursesdll.} -proc copywin*(a2: ptr TWINDOW; a3: ptr TWINDOW; a4: cint; a5: cint; a6: cint; +proc copywin*(a2: ptr WINDOW; a3: ptr WINDOW; a4: cint; a5: cint; a6: cint; a7: cint; a8: cint; a9: cint; a10: cint): cint{.extdecl, importc: "copywin", dynlib: pdcursesdll.} proc curs_set*(a2: cint): cint{.extdecl, importc: "curs_set", dynlib: pdcursesdll.} @@ -718,14 +724,14 @@ proc delay_output*(a2: cint): cint{.extdecl, importc: "delay_output", dynlib: pdcursesdll.} proc delch*(): cint{.extdecl, importc: "delch", dynlib: pdcursesdll.} proc deleteln*(): cint{.extdecl, importc: "deleteln", dynlib: pdcursesdll.} -proc delscreen*(a2: ptr TSCREEN){.extdecl, importc: "delscreen", +proc delscreen*(a2: ptr SCREEN){.extdecl, importc: "delscreen", dynlib: pdcursesdll.} -proc delwin*(a2: ptr TWINDOW): cint{.extdecl, importc: "delwin", +proc delwin*(a2: ptr WINDOW): cint{.extdecl, importc: "delwin", dynlib: pdcursesdll.} -proc derwin*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cint; a6: cint): ptr TWINDOW{. +proc derwin*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint; a6: cint): ptr WINDOW{. extdecl, importc: "derwin", dynlib: pdcursesdll.} proc doupdate*(): cint{.extdecl, importc: "doupdate", dynlib: pdcursesdll.} -proc dupwin*(a2: ptr TWINDOW): ptr TWINDOW{.extdecl, importc: "dupwin", +proc dupwin*(a2: ptr WINDOW): ptr WINDOW{.extdecl, importc: "dupwin", dynlib: pdcursesdll.} proc echochar*(a2: cunsignedlong): cint{.extdecl, importc: "echochar", dynlib: pdcursesdll.} @@ -736,12 +742,12 @@ proc erase*(): cint{.extdecl, importc: "erase", dynlib: pdcursesdll.} proc filter*(){.extdecl, importc: "filter", dynlib: pdcursesdll.} proc flash*(): cint{.extdecl, importc: "flash", dynlib: pdcursesdll.} proc flushinp*(): cint{.extdecl, importc: "flushinp", dynlib: pdcursesdll.} -proc getbkgd*(a2: ptr TWINDOW): cunsignedlong{.extdecl, importc: "getbkgd", +proc getbkgd*(a2: ptr WINDOW): cunsignedlong{.extdecl, importc: "getbkgd", dynlib: pdcursesdll.} proc getnstr*(a2: cstring; a3: cint): cint{.extdecl, importc: "getnstr", dynlib: pdcursesdll.} proc getstr*(a2: cstring): cint{.extdecl, importc: "getstr", dynlib: pdcursesdll.} -proc getwin*(a2: File): ptr TWINDOW{.extdecl, importc: "getwin", +proc getwin*(a2: File): ptr WINDOW{.extdecl, importc: "getwin", dynlib: pdcursesdll.} proc halfdelay*(a2: cint): cint{.extdecl, importc: "halfdelay", dynlib: pdcursesdll.} @@ -751,11 +757,11 @@ proc has_ic*(): cunsignedchar{.extdecl, importc: "has_ic", dynlib: pdcursesdll.} proc has_il*(): cunsignedchar{.extdecl, importc: "has_il", dynlib: pdcursesdll.} proc hline*(a2: cunsignedlong; a3: cint): cint{.extdecl, importc: "hline", dynlib: pdcursesdll.} -proc idcok*(a2: ptr TWINDOW; a3: cunsignedchar){.extdecl, importc: "idcok", +proc idcok*(a2: ptr WINDOW; a3: cunsignedchar){.extdecl, importc: "idcok", dynlib: pdcursesdll.} -proc idlok*(a2: ptr TWINDOW; a3: cunsignedchar): cint{.extdecl, importc: "idlok", +proc idlok*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, importc: "idlok", dynlib: pdcursesdll.} -proc immedok*(a2: ptr TWINDOW; a3: cunsignedchar){.extdecl, importc: "immedok", +proc immedok*(a2: ptr WINDOW; a3: cunsignedchar){.extdecl, importc: "immedok", dynlib: pdcursesdll.} proc inchnstr*(a2: ptr cunsignedlong; a3: cint): cint{.extdecl, importc: "inchnstr", dynlib: pdcursesdll.} @@ -766,7 +772,7 @@ proc init_color*(a2: cshort; a3: cshort; a4: cshort; a5: cshort): cint{.extdecl, importc: "init_color", dynlib: pdcursesdll.} proc init_pair*(a2: cshort; a3: cshort; a4: cshort): cint{.extdecl, importc: "init_pair", dynlib: pdcursesdll.} -proc initscr*(): ptr TWINDOW{.extdecl, importc: "initscr", dynlib: pdcursesdll.} +proc initscr*(): ptr WINDOW{.extdecl, importc: "initscr", dynlib: pdcursesdll.} proc innstr*(a2: cstring; a3: cint): cint{.extdecl, importc: "innstr", dynlib: pdcursesdll.} proc insch*(a2: cunsignedlong): cint{.extdecl, importc: "insch", @@ -777,21 +783,21 @@ proc insnstr*(a2: cstring; a3: cint): cint{.extdecl, importc: "insnstr", dynlib: pdcursesdll.} proc insstr*(a2: cstring): cint{.extdecl, importc: "insstr", dynlib: pdcursesdll.} proc instr*(a2: cstring): cint{.extdecl, importc: "instr", dynlib: pdcursesdll.} -proc intrflush*(a2: ptr TWINDOW; a3: cunsignedchar): cint{.extdecl, +proc intrflush*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, importc: "intrflush", dynlib: pdcursesdll.} proc isendwin*(): cunsignedchar{.extdecl, importc: "isendwin", dynlib: pdcursesdll.} -proc is_linetouched*(a2: ptr TWINDOW; a3: cint): cunsignedchar{.extdecl, +proc is_linetouched*(a2: ptr WINDOW; a3: cint): cunsignedchar{.extdecl, importc: "is_linetouched", dynlib: pdcursesdll.} -proc is_wintouched*(a2: ptr TWINDOW): cunsignedchar{.extdecl, +proc is_wintouched*(a2: ptr WINDOW): cunsignedchar{.extdecl, importc: "is_wintouched", dynlib: pdcursesdll.} proc keyname*(a2: cint): cstring{.extdecl, importc: "keyname", dynlib: pdcursesdll.} -proc keypad*(a2: ptr TWINDOW; a3: cunsignedchar): cint{.extdecl, importc: "keypad", +proc keypad*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, importc: "keypad", dynlib: pdcursesdll.} proc killchar*(): char{.extdecl, importc: "killchar", dynlib: pdcursesdll.} -proc leaveok*(a2: ptr TWINDOW; a3: cunsignedchar): cint{.extdecl, +proc leaveok*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, importc: "leaveok", dynlib: pdcursesdll.} proc longname*(): cstring{.extdecl, importc: "longname", dynlib: pdcursesdll.} -proc meta*(a2: ptr TWINDOW; a3: cunsignedchar): cint{.extdecl, importc: "meta", +proc meta*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, importc: "meta", dynlib: pdcursesdll.} proc move*(a2: cint; a3: cint): cint{.extdecl, importc: "move", dynlib: pdcursesdll.} @@ -811,7 +817,7 @@ proc mvcur*(a2: cint; a3: cint; a4: cint; a5: cint): cint{.extdecl, importc: "mvcur", dynlib: pdcursesdll.} proc mvdelch*(a2: cint; a3: cint): cint{.extdecl, importc: "mvdelch", dynlib: pdcursesdll.} -proc mvderwin*(a2: ptr TWINDOW; a3: cint; a4: cint): cint{.extdecl, +proc mvderwin*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl, importc: "mvderwin", dynlib: pdcursesdll.} proc mvgetch*(a2: cint; a3: cint): cint{.extdecl, importc: "mvgetch", dynlib: pdcursesdll.} @@ -843,92 +849,92 @@ proc mvscanw*(a2: cint; a3: cint; a4: cstring): cint{.varargs, extdecl, importc: "mvscanw", dynlib: pdcursesdll.} proc mvvline*(a2: cint; a3: cint; a4: cunsignedlong; a5: cint): cint{.extdecl, importc: "mvvline", dynlib: pdcursesdll.} -proc mvwaddchnstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong; +proc mvwaddchnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong; a6: cint): cint{.extdecl, importc: "mvwaddchnstr", dynlib: pdcursesdll.} -proc mvwaddchstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. +proc mvwaddchstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. extdecl, importc: "mvwaddchstr", dynlib: pdcursesdll.} -proc mvwaddch*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cunsignedlong): cint{. +proc mvwaddch*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cunsignedlong): cint{. extdecl, importc: "mvwaddch", dynlib: pdcursesdll.} -proc mvwaddnstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. +proc mvwaddnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. extdecl, importc: "mvwaddnstr", dynlib: pdcursesdll.} -proc mvwaddstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cstring): cint{.extdecl, +proc mvwaddstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{.extdecl, importc: "mvwaddstr", dynlib: pdcursesdll.} -proc mvwchgat*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cint; a6: cunsignedlong; +proc mvwchgat*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint; a6: cunsignedlong; a7: cshort; a8: pointer): cint{.extdecl, importc: "mvwchgat", dynlib: pdcursesdll.} -proc mvwdelch*(a2: ptr TWINDOW; a3: cint; a4: cint): cint{.extdecl, +proc mvwdelch*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl, importc: "mvwdelch", dynlib: pdcursesdll.} -proc mvwgetch*(a2: ptr TWINDOW; a3: cint; a4: cint): cint{.extdecl, +proc mvwgetch*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl, importc: "mvwgetch", dynlib: pdcursesdll.} -proc mvwgetnstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. +proc mvwgetnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. extdecl, importc: "mvwgetnstr", dynlib: pdcursesdll.} -proc mvwgetstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cstring): cint{.extdecl, +proc mvwgetstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{.extdecl, importc: "mvwgetstr", dynlib: pdcursesdll.} -proc mvwhline*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cunsignedlong; a6: cint): cint{. +proc mvwhline*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cunsignedlong; a6: cint): cint{. extdecl, importc: "mvwhline", dynlib: pdcursesdll.} -proc mvwinchnstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong; +proc mvwinchnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong; a6: cint): cint{.extdecl, importc: "mvwinchnstr", dynlib: pdcursesdll.} -proc mvwinchstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. +proc mvwinchstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. extdecl, importc: "mvwinchstr", dynlib: pdcursesdll.} -proc mvwinch*(a2: ptr TWINDOW; a3: cint; a4: cint): cunsignedlong{.extdecl, +proc mvwinch*(a2: ptr WINDOW; a3: cint; a4: cint): cunsignedlong{.extdecl, importc: "mvwinch", dynlib: pdcursesdll.} -proc mvwinnstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. +proc mvwinnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. extdecl, importc: "mvwinnstr", dynlib: pdcursesdll.} -proc mvwinsch*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cunsignedlong): cint{. +proc mvwinsch*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cunsignedlong): cint{. extdecl, importc: "mvwinsch", dynlib: pdcursesdll.} -proc mvwinsnstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. +proc mvwinsnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. extdecl, importc: "mvwinsnstr", dynlib: pdcursesdll.} -proc mvwinsstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cstring): cint{.extdecl, +proc mvwinsstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{.extdecl, importc: "mvwinsstr", dynlib: pdcursesdll.} -proc mvwinstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cstring): cint{.extdecl, +proc mvwinstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{.extdecl, importc: "mvwinstr", dynlib: pdcursesdll.} -proc mvwin*(a2: ptr TWINDOW; a3: cint; a4: cint): cint{.extdecl, importc: "mvwin", +proc mvwin*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl, importc: "mvwin", dynlib: pdcursesdll.} -proc mvwprintw*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cstring): cint{.varargs, +proc mvwprintw*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{.varargs, extdecl, importc: "mvwprintw", dynlib: pdcursesdll.} -proc mvwscanw*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cstring): cint{.varargs, +proc mvwscanw*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{.varargs, extdecl, importc: "mvwscanw", dynlib: pdcursesdll.} -proc mvwvline*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cunsignedlong; a6: cint): cint{. +proc mvwvline*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cunsignedlong; a6: cint): cint{. extdecl, importc: "mvwvline", dynlib: pdcursesdll.} proc napms*(a2: cint): cint{.extdecl, importc: "napms", dynlib: pdcursesdll.} -proc newpad*(a2: cint; a3: cint): ptr TWINDOW{.extdecl, importc: "newpad", +proc newpad*(a2: cint; a3: cint): ptr WINDOW{.extdecl, importc: "newpad", dynlib: pdcursesdll.} -proc newterm*(a2: cstring; a3: File; a4: File): ptr TSCREEN{.extdecl, +proc newterm*(a2: cstring; a3: File; a4: File): ptr SCREEN{.extdecl, importc: "newterm", dynlib: pdcursesdll.} -proc newwin*(a2: cint; a3: cint; a4: cint; a5: cint): ptr TWINDOW{.extdecl, +proc newwin*(a2: cint; a3: cint; a4: cint; a5: cint): ptr WINDOW{.extdecl, importc: "newwin", dynlib: pdcursesdll.} proc nl*(): cint{.extdecl, importc: "nl", dynlib: pdcursesdll.} proc nocbreak*(): cint{.extdecl, importc: "nocbreak", dynlib: pdcursesdll.} -proc nodelay*(a2: ptr TWINDOW; a3: cunsignedchar): cint{.extdecl, +proc nodelay*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, importc: "nodelay", dynlib: pdcursesdll.} proc noecho*(): cint{.extdecl, importc: "noecho", dynlib: pdcursesdll.} proc nonl*(): cint{.extdecl, importc: "nonl", dynlib: pdcursesdll.} proc noqiflush*(){.extdecl, importc: "noqiflush", dynlib: pdcursesdll.} proc noraw*(): cint{.extdecl, importc: "noraw", dynlib: pdcursesdll.} -proc notimeout*(a2: ptr TWINDOW; a3: cunsignedchar): cint{.extdecl, +proc notimeout*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, importc: "notimeout", dynlib: pdcursesdll.} -proc overlay*(a2: ptr TWINDOW; a3: ptr TWINDOW): cint{.extdecl, importc: "overlay", +proc overlay*(a2: ptr WINDOW; a3: ptr WINDOW): cint{.extdecl, importc: "overlay", dynlib: pdcursesdll.} -proc overwrite*(a2: ptr TWINDOW; a3: ptr TWINDOW): cint{.extdecl, +proc overwrite*(a2: ptr WINDOW; a3: ptr WINDOW): cint{.extdecl, importc: "overwrite", dynlib: pdcursesdll.} proc pair_content*(a2: cshort; a3: ptr cshort; a4: ptr cshort): cint{.extdecl, importc: "pair_content", dynlib: pdcursesdll.} -proc pechochar*(a2: ptr TWINDOW; a3: cunsignedlong): cint{.extdecl, +proc pechochar*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "pechochar", dynlib: pdcursesdll.} -proc pnoutrefresh*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cint; a6: cint; +proc pnoutrefresh*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint; a6: cint; a7: cint; a8: cint): cint{.extdecl, importc: "pnoutrefresh", dynlib: pdcursesdll.} -proc prefresh*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cint; a6: cint; a7: cint; +proc prefresh*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint; a6: cint; a7: cint; a8: cint): cint{.extdecl, importc: "prefresh", dynlib: pdcursesdll.} proc printw*(a2: cstring): cint{.varargs, extdecl, importc: "printw", dynlib: pdcursesdll.} -proc putwin*(a2: ptr TWINDOW; a3: File): cint{.extdecl, importc: "putwin", +proc putwin*(a2: ptr WINDOW; a3: File): cint{.extdecl, importc: "putwin", dynlib: pdcursesdll.} proc qiflush*(){.extdecl, importc: "qiflush", dynlib: pdcursesdll.} proc raw*(): cint{.extdecl, importc: "raw", dynlib: pdcursesdll.} -proc redrawwin*(a2: ptr TWINDOW): cint{.extdecl, importc: "redrawwin", +proc redrawwin*(a2: ptr WINDOW): cint{.extdecl, importc: "redrawwin", dynlib: pdcursesdll.} proc refresh*(): cint{.extdecl, importc: "refresh", dynlib: pdcursesdll.} proc reset_prog_mode*(): cint{.extdecl, importc: "reset_prog_mode", @@ -936,7 +942,7 @@ proc reset_prog_mode*(): cint{.extdecl, importc: "reset_prog_mode", proc reset_shell_mode*(): cint{.extdecl, importc: "reset_shell_mode", dynlib: pdcursesdll.} proc resetty*(): cint{.extdecl, importc: "resetty", dynlib: pdcursesdll.} -#int ripoffline(int, int (*)(TWINDOW *, int)); +#int ripoffline(int, int (*)(WINDOW *, int)); proc savetty*(): cint{.extdecl, importc: "savetty", dynlib: pdcursesdll.} proc scanw*(a2: cstring): cint{.varargs, extdecl, importc: "scanw", dynlib: pdcursesdll.} @@ -948,11 +954,11 @@ proc scr_restore*(a2: cstring): cint{.extdecl, importc: "scr_restore", dynlib: pdcursesdll.} proc scr_set*(a2: cstring): cint{.extdecl, importc: "scr_set", dynlib: pdcursesdll.} proc scrl*(a2: cint): cint{.extdecl, importc: "scrl", dynlib: pdcursesdll.} -proc scroll*(a2: ptr TWINDOW): cint{.extdecl, importc: "scroll", +proc scroll*(a2: ptr WINDOW): cint{.extdecl, importc: "scroll", dynlib: pdcursesdll.} -proc scrollok*(a2: ptr TWINDOW; a3: cunsignedchar): cint{.extdecl, +proc scrollok*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, importc: "scrollok", dynlib: pdcursesdll.} -proc set_term*(a2: ptr TSCREEN): ptr TSCREEN{.extdecl, importc: "set_term", +proc set_term*(a2: ptr SCREEN): ptr SCREEN{.extdecl, importc: "set_term", dynlib: pdcursesdll.} proc setscrreg*(a2: cint; a3: cint): cint{.extdecl, importc: "setscrreg", dynlib: pdcursesdll.} @@ -984,11 +990,11 @@ proc slk_touch*(): cint{.extdecl, importc: "slk_touch", dynlib: pdcursesdll.} proc standend*(): cint{.extdecl, importc: "standend", dynlib: pdcursesdll.} proc standout*(): cint{.extdecl, importc: "standout", dynlib: pdcursesdll.} proc start_color*(): cint{.extdecl, importc: "start_color", dynlib: pdcursesdll.} -proc subpad*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cint; a6: cint): ptr TWINDOW{. +proc subpad*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint; a6: cint): ptr WINDOW{. extdecl, importc: "subpad", dynlib: pdcursesdll.} -proc subwin*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cint; a6: cint): ptr TWINDOW{. +proc subwin*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint; a6: cint): ptr WINDOW{. extdecl, importc: "subwin", dynlib: pdcursesdll.} -proc syncok*(a2: ptr TWINDOW; a3: cunsignedchar): cint{.extdecl, importc: "syncok", +proc syncok*(a2: ptr WINDOW; a3: cunsignedchar): cint{.extdecl, importc: "syncok", dynlib: pdcursesdll.} proc termattrs*(): cunsignedlong{.extdecl, importc: "termattrs", dynlib: pdcursesdll.} @@ -996,13 +1002,13 @@ proc termattrs2*(): cunsignedlong{.extdecl, importc: "term_attrs", dynlib: pdcursesdll.} proc termname*(): cstring{.extdecl, importc: "termname", dynlib: pdcursesdll.} proc timeout*(a2: cint){.extdecl, importc: "timeout", dynlib: pdcursesdll.} -proc touchline*(a2: ptr TWINDOW; a3: cint; a4: cint): cint{.extdecl, +proc touchline*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl, importc: "touchline", dynlib: pdcursesdll.} -proc touchwin*(a2: ptr TWINDOW): cint{.extdecl, importc: "touchwin", +proc touchwin*(a2: ptr WINDOW): cint{.extdecl, importc: "touchwin", dynlib: pdcursesdll.} proc typeahead*(a2: cint): cint{.extdecl, importc: "typeahead", dynlib: pdcursesdll.} -proc untouchwin*(a2: ptr TWINDOW): cint{.extdecl, importc: "untouchwin", +proc untouchwin*(a2: ptr WINDOW): cint{.extdecl, importc: "untouchwin", dynlib: pdcursesdll.} proc use_env*(a2: cunsignedchar){.extdecl, importc: "use_env", dynlib: pdcursesdll.} proc vidattr*(a2: cunsignedlong): cint{.extdecl, importc: "vidattr", @@ -1013,123 +1019,123 @@ proc vid_attr*(a2: cunsignedlong; a3: cshort; a4: pointer): cint{.extdecl, #int vid_puts(attr_t, short, void *, int (*)(int)); proc vline*(a2: cunsignedlong; a3: cint): cint{.extdecl, importc: "vline", dynlib: pdcursesdll.} -proc vwprintw*(a2: ptr TWINDOW; a3: cstring): cint{.extdecl, varargs, +proc vwprintw*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, varargs, importc: "vw_printw", dynlib: pdcursesdll.} -proc vwprintw2*(a2: ptr TWINDOW; a3: cstring): cint{.extdecl, varargs, +proc vwprintw2*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, varargs, importc: "vwprintw", dynlib: pdcursesdll.} -proc vwscanw*(a2: ptr TWINDOW; a3: cstring): cint{.extdecl, varargs, +proc vwscanw*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, varargs, importc: "vw_scanw", dynlib: pdcursesdll.} -proc vwscanw2*(a2: ptr TWINDOW; a3: cstring): cint{.extdecl, varargs, +proc vwscanw2*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, varargs, importc: "vwscanw", dynlib: pdcursesdll.} -proc waddchnstr*(a2: ptr TWINDOW; a3: ptr cunsignedlong; a4: cint): cint{.extdecl, +proc waddchnstr*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: cint): cint{.extdecl, importc: "waddchnstr", dynlib: pdcursesdll.} -proc waddchstr*(a2: ptr TWINDOW; a3: ptr cunsignedlong): cint{.extdecl, +proc waddchstr*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, importc: "waddchstr", dynlib: pdcursesdll.} -proc waddch*(a2: ptr TWINDOW; a3: cunsignedlong): cint{.extdecl, importc: "waddch", +proc waddch*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "waddch", dynlib: pdcursesdll.} -proc waddnstr*(a2: ptr TWINDOW; a3: cstring; a4: cint): cint{.extdecl, +proc waddnstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint{.extdecl, importc: "waddnstr", dynlib: pdcursesdll.} -proc waddstr*(a2: ptr TWINDOW; a3: cstring): cint{.extdecl, importc: "waddstr", +proc waddstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, importc: "waddstr", dynlib: pdcursesdll.} -proc wattroff*(a2: ptr TWINDOW; a3: cunsignedlong): cint{.extdecl, +proc wattroff*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "wattroff", dynlib: pdcursesdll.} -proc wattron*(a2: ptr TWINDOW; a3: cunsignedlong): cint{.extdecl, +proc wattron*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "wattron", dynlib: pdcursesdll.} -proc wattrset*(a2: ptr TWINDOW; a3: cunsignedlong): cint{.extdecl, +proc wattrset*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "wattrset", dynlib: pdcursesdll.} -proc wattr_get*(a2: ptr TWINDOW; a3: ptr cunsignedlong; a4: ptr cshort; +proc wattr_get*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: ptr cshort; a5: pointer): cint{.extdecl, importc: "wattr_get", dynlib: pdcursesdll.} -proc wattr_off*(a2: ptr TWINDOW; a3: cunsignedlong; a4: pointer): cint{.extdecl, +proc wattr_off*(a2: ptr WINDOW; a3: cunsignedlong; a4: pointer): cint{.extdecl, importc: "wattr_off", dynlib: pdcursesdll.} -proc wattr_on*(a2: ptr TWINDOW; a3: cunsignedlong; a4: pointer): cint{.extdecl, +proc wattr_on*(a2: ptr WINDOW; a3: cunsignedlong; a4: pointer): cint{.extdecl, importc: "wattr_on", dynlib: pdcursesdll.} -proc wattr_set*(a2: ptr TWINDOW; a3: cunsignedlong; a4: cshort; a5: pointer): cint{. +proc wattr_set*(a2: ptr WINDOW; a3: cunsignedlong; a4: cshort; a5: pointer): cint{. extdecl, importc: "wattr_set", dynlib: pdcursesdll.} -proc wbkgdset*(a2: ptr TWINDOW; a3: cunsignedlong){.extdecl, importc: "wbkgdset", +proc wbkgdset*(a2: ptr WINDOW; a3: cunsignedlong){.extdecl, importc: "wbkgdset", dynlib: pdcursesdll.} -proc wbkgd*(a2: ptr TWINDOW; a3: cunsignedlong): cint{.extdecl, importc: "wbkgd", +proc wbkgd*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "wbkgd", dynlib: pdcursesdll.} -proc wborder*(a2: ptr TWINDOW; a3: cunsignedlong; a4: cunsignedlong; +proc wborder*(a2: ptr WINDOW; a3: cunsignedlong; a4: cunsignedlong; a5: cunsignedlong; a6: cunsignedlong; a7: cunsignedlong; a8: cunsignedlong; a9: cunsignedlong; a10: cunsignedlong): cint{. extdecl, importc: "wborder", dynlib: pdcursesdll.} -proc wchgat*(a2: ptr TWINDOW; a3: cint; a4: cunsignedlong; a5: cshort; +proc wchgat*(a2: ptr WINDOW; a3: cint; a4: cunsignedlong; a5: cshort; a6: pointer): cint{.extdecl, importc: "wchgat", dynlib: pdcursesdll.} -proc wclear*(a2: ptr TWINDOW): cint{.extdecl, importc: "wclear", +proc wclear*(a2: ptr WINDOW): cint{.extdecl, importc: "wclear", dynlib: pdcursesdll.} -proc wclrtobot*(a2: ptr TWINDOW): cint{.extdecl, importc: "wclrtobot", +proc wclrtobot*(a2: ptr WINDOW): cint{.extdecl, importc: "wclrtobot", dynlib: pdcursesdll.} -proc wclrtoeol*(a2: ptr TWINDOW): cint{.extdecl, importc: "wclrtoeol", +proc wclrtoeol*(a2: ptr WINDOW): cint{.extdecl, importc: "wclrtoeol", dynlib: pdcursesdll.} -proc wcolor_set*(a2: ptr TWINDOW; a3: cshort; a4: pointer): cint{.extdecl, +proc wcolor_set*(a2: ptr WINDOW; a3: cshort; a4: pointer): cint{.extdecl, importc: "wcolor_set", dynlib: pdcursesdll.} -proc wcursyncup*(a2: ptr TWINDOW){.extdecl, importc: "wcursyncup", +proc wcursyncup*(a2: ptr WINDOW){.extdecl, importc: "wcursyncup", dynlib: pdcursesdll.} -proc wdelch*(a2: ptr TWINDOW): cint{.extdecl, importc: "wdelch", +proc wdelch*(a2: ptr WINDOW): cint{.extdecl, importc: "wdelch", dynlib: pdcursesdll.} -proc wdeleteln*(a2: ptr TWINDOW): cint{.extdecl, importc: "wdeleteln", +proc wdeleteln*(a2: ptr WINDOW): cint{.extdecl, importc: "wdeleteln", dynlib: pdcursesdll.} -proc wechochar*(a2: ptr TWINDOW; a3: cunsignedlong): cint{.extdecl, +proc wechochar*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "wechochar", dynlib: pdcursesdll.} -proc werase*(a2: ptr TWINDOW): cint{.extdecl, importc: "werase", +proc werase*(a2: ptr WINDOW): cint{.extdecl, importc: "werase", dynlib: pdcursesdll.} -proc wgetch*(a2: ptr TWINDOW): cint{.extdecl, importc: "wgetch", +proc wgetch*(a2: ptr WINDOW): cint{.extdecl, importc: "wgetch", dynlib: pdcursesdll.} -proc wgetnstr*(a2: ptr TWINDOW; a3: cstring; a4: cint): cint{.extdecl, +proc wgetnstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint{.extdecl, importc: "wgetnstr", dynlib: pdcursesdll.} -proc wgetstr*(a2: ptr TWINDOW; a3: cstring): cint{.extdecl, importc: "wgetstr", +proc wgetstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, importc: "wgetstr", dynlib: pdcursesdll.} -proc whline*(a2: ptr TWINDOW; a3: cunsignedlong; a4: cint): cint{.extdecl, +proc whline*(a2: ptr WINDOW; a3: cunsignedlong; a4: cint): cint{.extdecl, importc: "whline", dynlib: pdcursesdll.} -proc winchnstr*(a2: ptr TWINDOW; a3: ptr cunsignedlong; a4: cint): cint{.extdecl, +proc winchnstr*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: cint): cint{.extdecl, importc: "winchnstr", dynlib: pdcursesdll.} -proc winchstr*(a2: ptr TWINDOW; a3: ptr cunsignedlong): cint{.extdecl, +proc winchstr*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, importc: "winchstr", dynlib: pdcursesdll.} -proc winch*(a2: ptr TWINDOW): cunsignedlong{.extdecl, importc: "winch", +proc winch*(a2: ptr WINDOW): cunsignedlong{.extdecl, importc: "winch", dynlib: pdcursesdll.} -proc winnstr*(a2: ptr TWINDOW; a3: cstring; a4: cint): cint{.extdecl, +proc winnstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint{.extdecl, importc: "winnstr", dynlib: pdcursesdll.} -proc winsch*(a2: ptr TWINDOW; a3: cunsignedlong): cint{.extdecl, importc: "winsch", +proc winsch*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "winsch", dynlib: pdcursesdll.} -proc winsdelln*(a2: ptr TWINDOW; a3: cint): cint{.extdecl, importc: "winsdelln", +proc winsdelln*(a2: ptr WINDOW; a3: cint): cint{.extdecl, importc: "winsdelln", dynlib: pdcursesdll.} -proc winsertln*(a2: ptr TWINDOW): cint{.extdecl, importc: "winsertln", +proc winsertln*(a2: ptr WINDOW): cint{.extdecl, importc: "winsertln", dynlib: pdcursesdll.} -proc winsnstr*(a2: ptr TWINDOW; a3: cstring; a4: cint): cint{.extdecl, +proc winsnstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint{.extdecl, importc: "winsnstr", dynlib: pdcursesdll.} -proc winsstr*(a2: ptr TWINDOW; a3: cstring): cint{.extdecl, importc: "winsstr", +proc winsstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, importc: "winsstr", dynlib: pdcursesdll.} -proc winstr*(a2: ptr TWINDOW; a3: cstring): cint{.extdecl, importc: "winstr", +proc winstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, importc: "winstr", dynlib: pdcursesdll.} -proc wmove*(a2: ptr TWINDOW; a3: cint; a4: cint): cint{.extdecl, importc: "wmove", +proc wmove*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl, importc: "wmove", dynlib: pdcursesdll.} -proc wnoutrefresh*(a2: ptr TWINDOW): cint{.extdecl, importc: "wnoutrefresh", +proc wnoutrefresh*(a2: ptr WINDOW): cint{.extdecl, importc: "wnoutrefresh", dynlib: pdcursesdll.} -proc wprintw*(a2: ptr TWINDOW; a3: cstring): cint{.varargs, extdecl, +proc wprintw*(a2: ptr WINDOW; a3: cstring): cint{.varargs, extdecl, importc: "wprintw", dynlib: pdcursesdll.} -proc wredrawln*(a2: ptr TWINDOW; a3: cint; a4: cint): cint{.extdecl, +proc wredrawln*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl, importc: "wredrawln", dynlib: pdcursesdll.} -proc wrefresh*(a2: ptr TWINDOW): cint{.extdecl, importc: "wrefresh", +proc wrefresh*(a2: ptr WINDOW): cint{.extdecl, importc: "wrefresh", dynlib: pdcursesdll.} -proc wscanw*(a2: ptr TWINDOW; a3: cstring): cint{.varargs, extdecl, +proc wscanw*(a2: ptr WINDOW; a3: cstring): cint{.varargs, extdecl, importc: "wscanw", dynlib: pdcursesdll.} -proc wscrl*(a2: ptr TWINDOW; a3: cint): cint{.extdecl, importc: "wscrl", +proc wscrl*(a2: ptr WINDOW; a3: cint): cint{.extdecl, importc: "wscrl", dynlib: pdcursesdll.} -proc wsetscrreg*(a2: ptr TWINDOW; a3: cint; a4: cint): cint{.extdecl, +proc wsetscrreg*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl, importc: "wsetscrreg", dynlib: pdcursesdll.} -proc wstandend*(a2: ptr TWINDOW): cint{.extdecl, importc: "wstandend", +proc wstandend*(a2: ptr WINDOW): cint{.extdecl, importc: "wstandend", dynlib: pdcursesdll.} -proc wstandout*(a2: ptr TWINDOW): cint{.extdecl, importc: "wstandout", +proc wstandout*(a2: ptr WINDOW): cint{.extdecl, importc: "wstandout", dynlib: pdcursesdll.} -proc wsyncdown*(a2: ptr TWINDOW){.extdecl, importc: "wsyncdown", +proc wsyncdown*(a2: ptr WINDOW){.extdecl, importc: "wsyncdown", dynlib: pdcursesdll.} -proc wsyncup*(a2: ptr TWINDOW){.extdecl, importc: "wsyncup", dynlib: pdcursesdll.} -proc wtimeout*(a2: ptr TWINDOW; a3: cint){.extdecl, importc: "wtimeout", +proc wsyncup*(a2: ptr WINDOW){.extdecl, importc: "wsyncup", dynlib: pdcursesdll.} +proc wtimeout*(a2: ptr WINDOW; a3: cint){.extdecl, importc: "wtimeout", dynlib: pdcursesdll.} -proc wtouchln*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cint): cint{.extdecl, +proc wtouchln*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint): cint{.extdecl, importc: "wtouchln", dynlib: pdcursesdll.} -proc wvline*(a2: ptr TWINDOW; a3: cunsignedlong; a4: cint): cint{.extdecl, +proc wvline*(a2: ptr WINDOW; a3: cunsignedlong; a4: cint): cint{.extdecl, importc: "wvline", dynlib: pdcursesdll.} proc addnwstr*(a2: cstring; a3: cint): cint{.extdecl, importc: "addnwstr", dynlib: pdcursesdll.} @@ -1146,7 +1152,7 @@ proc border_set*(a2: ptr cunsignedlong; a3: ptr cunsignedlong; a6: ptr cunsignedlong; a7: ptr cunsignedlong; a8: ptr cunsignedlong; a9: ptr cunsignedlong): cint{.extdecl, importc: "border_set", dynlib: pdcursesdll.} -proc box_set*(a2: ptr TWINDOW; a3: ptr cunsignedlong; a4: ptr cunsignedlong): cint{. +proc box_set*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: ptr cunsignedlong): cint{. extdecl, importc: "box_set", dynlib: pdcursesdll.} proc echo_wchar*(a2: ptr cunsignedlong): cint{.extdecl, importc: "echo_wchar", dynlib: pdcursesdll.} @@ -1221,47 +1227,47 @@ proc mvin_wchstr*(a2: cint; a3: cint; a4: ptr cunsignedlong): cint{.extdecl, importc: "mvin_wchstr", dynlib: pdcursesdll.} proc mvvline_set*(a2: cint; a3: cint; a4: ptr cunsignedlong; a5: cint): cint{. extdecl, importc: "mvvline_set", dynlib: pdcursesdll.} -proc mvwaddnwstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. +proc mvwaddnwstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. extdecl, importc: "mvwaddnwstr", dynlib: pdcursesdll.} -proc mvwaddwstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cstring): cint{. +proc mvwaddwstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{. extdecl, importc: "mvwaddwstr", dynlib: pdcursesdll.} -proc mvwadd_wch*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. +proc mvwadd_wch*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. extdecl, importc: "mvwadd_wch", dynlib: pdcursesdll.} -proc mvwadd_wchnstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong; +proc mvwadd_wchnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong; a6: cint): cint{.extdecl, importc: "mvwadd_wchnstr", dynlib: pdcursesdll.} -proc mvwadd_wchstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. +proc mvwadd_wchstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. extdecl, importc: "mvwadd_wchstr", dynlib: pdcursesdll.} -proc mvwgetn_wstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: ptr cint; a6: cint): cint{. +proc mvwgetn_wstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cint; a6: cint): cint{. extdecl, importc: "mvwgetn_wstr", dynlib: pdcursesdll.} -proc mvwget_wch*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: ptr cint): cint{. +proc mvwget_wch*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cint): cint{. extdecl, importc: "mvwget_wch", dynlib: pdcursesdll.} -proc mvwget_wstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: ptr cint): cint{. +proc mvwget_wstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cint): cint{. extdecl, importc: "mvwget_wstr", dynlib: pdcursesdll.} -proc mvwhline_set*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong; +proc mvwhline_set*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong; a6: cint): cint{.extdecl, importc: "mvwhline_set", dynlib: pdcursesdll.} -proc mvwinnwstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. +proc mvwinnwstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. extdecl, importc: "mvwinnwstr", dynlib: pdcursesdll.} -proc mvwins_nwstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. +proc mvwins_nwstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint{. extdecl, importc: "mvwins_nwstr", dynlib: pdcursesdll.} -proc mvwins_wch*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. +proc mvwins_wch*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. extdecl, importc: "mvwins_wch", dynlib: pdcursesdll.} -proc mvwins_wstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cstring): cint{. +proc mvwins_wstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{. extdecl, importc: "mvwins_wstr", dynlib: pdcursesdll.} -proc mvwin_wch*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. +proc mvwin_wch*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. extdecl, importc: "mvwin_wch", dynlib: pdcursesdll.} -proc mvwin_wchnstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong; +proc mvwin_wchnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong; a6: cint): cint{.extdecl, importc: "mvwin_wchnstr", dynlib: pdcursesdll.} -proc mvwin_wchstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. +proc mvwin_wchstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong): cint{. extdecl, importc: "mvwin_wchstr", dynlib: pdcursesdll.} -proc mvwinwstr*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cstring): cint{. +proc mvwinwstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint{. extdecl, importc: "mvwinwstr", dynlib: pdcursesdll.} -proc mvwvline_set*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong; +proc mvwvline_set*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr cunsignedlong; a6: cint): cint{.extdecl, importc: "mvwvline_set", dynlib: pdcursesdll.} -proc pecho_wchar*(a2: ptr TWINDOW; a3: ptr cunsignedlong): cint{.extdecl, +proc pecho_wchar*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, importc: "pecho_wchar", dynlib: pdcursesdll.} proc setcchar*(a2: ptr cunsignedlong; a3: cstring; a4: cunsignedlong; a5: cshort; a6: pointer): cint{.extdecl, importc: "setcchar", @@ -1272,74 +1278,74 @@ proc unget_wch*(a2: char): cint{.extdecl, importc: "unget_wch", dynlib: pdcursesdll.} proc vline_set*(a2: ptr cunsignedlong; a3: cint): cint{.extdecl, importc: "vline_set", dynlib: pdcursesdll.} -proc waddnwstr*(a2: ptr TWINDOW; a3: cstring; a4: cint): cint{.extdecl, +proc waddnwstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint{.extdecl, importc: "waddnwstr", dynlib: pdcursesdll.} -proc waddwstr*(a2: ptr TWINDOW; a3: cstring): cint{.extdecl, +proc waddwstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, importc: "waddwstr", dynlib: pdcursesdll.} -proc wadd_wch*(a2: ptr TWINDOW; a3: ptr cunsignedlong): cint{.extdecl, +proc wadd_wch*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, importc: "wadd_wch", dynlib: pdcursesdll.} -proc wadd_wchnstr*(a2: ptr TWINDOW; a3: ptr cunsignedlong; a4: cint): cint{. +proc wadd_wchnstr*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: cint): cint{. extdecl, importc: "wadd_wchnstr", dynlib: pdcursesdll.} -proc wadd_wchstr*(a2: ptr TWINDOW; a3: ptr cunsignedlong): cint{.extdecl, +proc wadd_wchstr*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, importc: "wadd_wchstr", dynlib: pdcursesdll.} -proc wbkgrnd*(a2: ptr TWINDOW; a3: ptr cunsignedlong): cint{.extdecl, +proc wbkgrnd*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, importc: "wbkgrnd", dynlib: pdcursesdll.} -proc wbkgrndset*(a2: ptr TWINDOW; a3: ptr cunsignedlong){.extdecl, +proc wbkgrndset*(a2: ptr WINDOW; a3: ptr cunsignedlong){.extdecl, importc: "wbkgrndset", dynlib: pdcursesdll.} -proc wborder_set*(a2: ptr TWINDOW; a3: ptr cunsignedlong; a4: ptr cunsignedlong; +proc wborder_set*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: ptr cunsignedlong; a5: ptr cunsignedlong; a6: ptr cunsignedlong; a7: ptr cunsignedlong; a8: ptr cunsignedlong; a9: ptr cunsignedlong; a10: ptr cunsignedlong): cint{.extdecl, importc: "wborder_set", dynlib: pdcursesdll.} -proc wecho_wchar*(a2: ptr TWINDOW; a3: ptr cunsignedlong): cint{.extdecl, +proc wecho_wchar*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, importc: "wecho_wchar", dynlib: pdcursesdll.} -proc wgetbkgrnd*(a2: ptr TWINDOW; a3: ptr cunsignedlong): cint{.extdecl, +proc wgetbkgrnd*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, importc: "wgetbkgrnd", dynlib: pdcursesdll.} -proc wgetn_wstr*(a2: ptr TWINDOW; a3: ptr cint; a4: cint): cint{.extdecl, +proc wgetn_wstr*(a2: ptr WINDOW; a3: ptr cint; a4: cint): cint{.extdecl, importc: "wgetn_wstr", dynlib: pdcursesdll.} -proc wget_wch*(a2: ptr TWINDOW; a3: ptr cint): cint{.extdecl, +proc wget_wch*(a2: ptr WINDOW; a3: ptr cint): cint{.extdecl, importc: "wget_wch", dynlib: pdcursesdll.} -proc wget_wstr*(a2: ptr TWINDOW; a3: ptr cint): cint{.extdecl, +proc wget_wstr*(a2: ptr WINDOW; a3: ptr cint): cint{.extdecl, importc: "wget_wstr", dynlib: pdcursesdll.} -proc whline_set*(a2: ptr TWINDOW; a3: ptr cunsignedlong; a4: cint): cint{.extdecl, +proc whline_set*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: cint): cint{.extdecl, importc: "whline_set", dynlib: pdcursesdll.} -proc winnwstr*(a2: ptr TWINDOW; a3: cstring; a4: cint): cint{.extdecl, +proc winnwstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint{.extdecl, importc: "winnwstr", dynlib: pdcursesdll.} -proc wins_nwstr*(a2: ptr TWINDOW; a3: cstring; a4: cint): cint{.extdecl, +proc wins_nwstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint{.extdecl, importc: "wins_nwstr", dynlib: pdcursesdll.} -proc wins_wch*(a2: ptr TWINDOW; a3: ptr cunsignedlong): cint{.extdecl, +proc wins_wch*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, importc: "wins_wch", dynlib: pdcursesdll.} -proc wins_wstr*(a2: ptr TWINDOW; a3: cstring): cint{.extdecl, +proc wins_wstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, importc: "wins_wstr", dynlib: pdcursesdll.} -proc winwstr*(a2: ptr TWINDOW; a3: cstring): cint{.extdecl, importc: "winwstr", +proc winwstr*(a2: ptr WINDOW; a3: cstring): cint{.extdecl, importc: "winwstr", dynlib: pdcursesdll.} -proc win_wch*(a2: ptr TWINDOW; a3: ptr cunsignedlong): cint{.extdecl, +proc win_wch*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, importc: "win_wch", dynlib: pdcursesdll.} -proc win_wchnstr*(a2: ptr TWINDOW; a3: ptr cunsignedlong; a4: cint): cint{.extdecl, +proc win_wchnstr*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: cint): cint{.extdecl, importc: "win_wchnstr", dynlib: pdcursesdll.} -proc win_wchstr*(a2: ptr TWINDOW; a3: ptr cunsignedlong): cint{.extdecl, +proc win_wchstr*(a2: ptr WINDOW; a3: ptr cunsignedlong): cint{.extdecl, importc: "win_wchstr", dynlib: pdcursesdll.} proc wunctrl*(a2: ptr cunsignedlong): cstring{.extdecl, importc: "wunctrl", dynlib: pdcursesdll.} -proc wvline_set*(a2: ptr TWINDOW; a3: ptr cunsignedlong; a4: cint): cint{.extdecl, +proc wvline_set*(a2: ptr WINDOW; a3: ptr cunsignedlong; a4: cint): cint{.extdecl, importc: "wvline_set", dynlib: pdcursesdll.} -proc getattrs*(a2: ptr TWINDOW): cunsignedlong{.extdecl, importc: "getattrs", +proc getattrs*(a2: ptr WINDOW): cunsignedlong{.extdecl, importc: "getattrs", dynlib: pdcursesdll.} -proc getbegx*(a2: ptr TWINDOW): cint{.extdecl, importc: "getbegx", +proc getbegx*(a2: ptr WINDOW): cint{.extdecl, importc: "getbegx", dynlib: pdcursesdll.} -proc getbegy*(a2: ptr TWINDOW): cint{.extdecl, importc: "getbegy", +proc getbegy*(a2: ptr WINDOW): cint{.extdecl, importc: "getbegy", dynlib: pdcursesdll.} -proc getmaxx*(a2: ptr TWINDOW): cint{.extdecl, importc: "getmaxx", +proc getmaxx*(a2: ptr WINDOW): cint{.extdecl, importc: "getmaxx", dynlib: pdcursesdll.} -proc getmaxy*(a2: ptr TWINDOW): cint{.extdecl, importc: "getmaxy", +proc getmaxy*(a2: ptr WINDOW): cint{.extdecl, importc: "getmaxy", dynlib: pdcursesdll.} -proc getparx*(a2: ptr TWINDOW): cint{.extdecl, importc: "getparx", +proc getparx*(a2: ptr WINDOW): cint{.extdecl, importc: "getparx", dynlib: pdcursesdll.} -proc getpary*(a2: ptr TWINDOW): cint{.extdecl, importc: "getpary", +proc getpary*(a2: ptr WINDOW): cint{.extdecl, importc: "getpary", dynlib: pdcursesdll.} -proc getcurx*(a2: ptr TWINDOW): cint{.extdecl, importc: "getcurx", +proc getcurx*(a2: ptr WINDOW): cint{.extdecl, importc: "getcurx", dynlib: pdcursesdll.} -proc getcury*(a2: ptr TWINDOW): cint{.extdecl, importc: "getcury", +proc getcury*(a2: ptr WINDOW): cint{.extdecl, importc: "getcury", dynlib: pdcursesdll.} proc traceoff*(){.extdecl, importc: "traceoff", dynlib: pdcursesdll.} proc traceon*(){.extdecl, importc: "traceon", dynlib: pdcursesdll.} @@ -1363,7 +1369,7 @@ proc request_mouse_pos*(): cint{.extdecl, importc: "request_mouse_pos", dynlib: pdcursesdll.} proc map_button*(a2: cunsignedlong): cint{.extdecl, importc: "map_button", dynlib: pdcursesdll.} -proc wmouse_position*(a2: ptr TWINDOW; a3: ptr cint; a4: ptr cint){.extdecl, +proc wmouse_position*(a2: ptr WINDOW; a3: ptr cint; a4: ptr cint){.extdecl, importc: "wmouse_position", dynlib: pdcursesdll.} proc getmouse*(): cunsignedlong{.extdecl, importc: "getmouse", dynlib: pdcursesdll.} proc getbmap*(): cunsignedlong{.extdecl, importc: "getbmap", dynlib: pdcursesdll.} @@ -1375,7 +1381,7 @@ proc has_key*(a2: cint): cunsignedchar{.extdecl, importc: "has_key", dynlib: pdcursesdll.} proc use_default_colors*(): cint{.extdecl, importc: "use_default_colors", dynlib: pdcursesdll.} -proc wresize*(a2: ptr TWINDOW; a3: cint; a4: cint): cint{.extdecl, +proc wresize*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl, importc: "wresize", dynlib: pdcursesdll.} proc mouseinterval*(a2: cint): cint{.extdecl, importc: "mouseinterval", dynlib: pdcursesdll.} @@ -1383,13 +1389,13 @@ proc mousemask*(a2: cunsignedlong; a3: ptr cunsignedlong): cunsignedlong{.extdec importc: "mousemask", dynlib: pdcursesdll.} proc mouse_trafo*(a2: ptr cint; a3: ptr cint; a4: cunsignedchar): cunsignedchar{. extdecl, importc: "mouse_trafo", dynlib: pdcursesdll.} -proc nc_getmouse*(a2: ptr TMEVENT): cint{.extdecl, importc: "nc_getmouse", +proc nc_getmouse*(a2: ptr MEVENT): cint{.extdecl, importc: "nc_getmouse", dynlib: pdcursesdll.} -proc ungetmouse*(a2: ptr TMEVENT): cint{.extdecl, importc: "ungetmouse", +proc ungetmouse*(a2: ptr MEVENT): cint{.extdecl, importc: "ungetmouse", dynlib: pdcursesdll.} -proc wenclose*(a2: ptr TWINDOW; a3: cint; a4: cint): cunsignedchar{.extdecl, +proc wenclose*(a2: ptr WINDOW; a3: cint; a4: cint): cunsignedchar{.extdecl, importc: "wenclose", dynlib: pdcursesdll.} -proc wmouse_trafo*(a2: ptr TWINDOW; a3: ptr cint; a4: ptr cint; a5: cunsignedchar): cunsignedchar{. +proc wmouse_trafo*(a2: ptr WINDOW; a3: ptr cint; a4: ptr cint; a5: cunsignedchar): cunsignedchar{. extdecl, importc: "wmouse_trafo", dynlib: pdcursesdll.} proc addrawch*(a2: cunsignedlong): cint{.extdecl, importc: "addrawch", dynlib: pdcursesdll.} @@ -1405,23 +1411,23 @@ proc mvinsertln*(a2: cint; a3: cint): cint{.extdecl, importc: "mvinsertln", dynlib: pdcursesdll.} proc mvinsrawch*(a2: cint; a3: cint; a4: cunsignedlong): cint{.extdecl, importc: "mvinsrawch", dynlib: pdcursesdll.} -proc mvwaddrawch*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cunsignedlong): cint{. +proc mvwaddrawch*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cunsignedlong): cint{. extdecl, importc: "mvwaddrawch", dynlib: pdcursesdll.} -proc mvwdeleteln*(a2: ptr TWINDOW; a3: cint; a4: cint): cint{.extdecl, +proc mvwdeleteln*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl, importc: "mvwdeleteln", dynlib: pdcursesdll.} -proc mvwinsertln*(a2: ptr TWINDOW; a3: cint; a4: cint): cint{.extdecl, +proc mvwinsertln*(a2: ptr WINDOW; a3: cint; a4: cint): cint{.extdecl, importc: "mvwinsertln", dynlib: pdcursesdll.} -proc mvwinsrawch*(a2: ptr TWINDOW; a3: cint; a4: cint; a5: cunsignedlong): cint{. +proc mvwinsrawch*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cunsignedlong): cint{. extdecl, importc: "mvwinsrawch", dynlib: pdcursesdll.} proc raw_output*(a2: cunsignedchar): cint{.extdecl, importc: "raw_output", dynlib: pdcursesdll.} proc resize_term*(a2: cint; a3: cint): cint{.extdecl, importc: "resize_term", dynlib: pdcursesdll.} -proc resize_window*(a2: ptr TWINDOW; a3: cint; a4: cint): ptr TWINDOW{.extdecl, +proc resize_window*(a2: ptr WINDOW; a3: cint; a4: cint): ptr WINDOW{.extdecl, importc: "resize_window", dynlib: pdcursesdll.} -proc waddrawch*(a2: ptr TWINDOW; a3: cunsignedlong): cint{.extdecl, +proc waddrawch*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "waddrawch", dynlib: pdcursesdll.} -proc winsrawch*(a2: ptr TWINDOW; a3: cunsignedlong): cint{.extdecl, +proc winsrawch*(a2: ptr WINDOW; a3: cunsignedlong): cint{.extdecl, importc: "winsrawch", dynlib: pdcursesdll.} proc wordchar*(): char{.extdecl, importc: "wordchar", dynlib: pdcursesdll.} proc slk_wlabel*(a2: cint): cstring{.extdecl, importc: "slk_wlabel", @@ -1452,38 +1458,38 @@ proc return_key_modifiers*(a2: cunsignedchar): cint{.extdecl, importc: "PDC_return_key_modifiers", dynlib: pdcursesdll.} proc save_key_modifiers*(a2: cunsignedchar): cint{.extdecl, importc: "PDC_save_key_modifiers", dynlib: pdcursesdll.} -proc bottom_panel*(pan: ptr TPANEL): cint{.extdecl, importc: "bottom_panel", +proc bottom_panel*(pan: ptr PANEL): cint{.extdecl, importc: "bottom_panel", dynlib: pdcursesdll.} -proc del_panel*(pan: ptr TPANEL): cint{.extdecl, importc: "del_panel", +proc del_panel*(pan: ptr PANEL): cint{.extdecl, importc: "del_panel", dynlib: pdcursesdll.} -proc hide_panel*(pan: ptr TPANEL): cint{.extdecl, importc: "hide_panel", +proc hide_panel*(pan: ptr PANEL): cint{.extdecl, importc: "hide_panel", dynlib: pdcursesdll.} -proc move_panel*(pan: ptr TPANEL; starty: cint; startx: cint): cint{.extdecl, +proc move_panel*(pan: ptr PANEL; starty: cint; startx: cint): cint{.extdecl, importc: "move_panel", dynlib: pdcursesdll.} -proc new_panel*(win: ptr TWINDOW): ptr TPANEL{.extdecl, importc: "new_panel", +proc new_panel*(win: ptr WINDOW): ptr PANEL{.extdecl, importc: "new_panel", dynlib: pdcursesdll.} -proc panel_above*(pan: ptr TPANEL): ptr TPANEL{.extdecl, importc: "panel_above", +proc panel_above*(pan: ptr PANEL): ptr PANEL{.extdecl, importc: "panel_above", dynlib: pdcursesdll.} -proc panel_below*(pan: ptr TPANEL): ptr TPANEL{.extdecl, importc: "panel_below", +proc panel_below*(pan: ptr PANEL): ptr PANEL{.extdecl, importc: "panel_below", dynlib: pdcursesdll.} -proc panel_hidden*(pan: ptr TPANEL): cint{.extdecl, importc: "panel_hidden", +proc panel_hidden*(pan: ptr PANEL): cint{.extdecl, importc: "panel_hidden", dynlib: pdcursesdll.} -proc panel_userptr*(pan: ptr TPANEL): pointer{.extdecl, importc: "panel_userptr", +proc panel_userptr*(pan: ptr PANEL): pointer{.extdecl, importc: "panel_userptr", dynlib: pdcursesdll.} -proc panel_window*(pan: ptr TPANEL): ptr TWINDOW{.extdecl, importc: "panel_window", +proc panel_window*(pan: ptr PANEL): ptr WINDOW{.extdecl, importc: "panel_window", dynlib: pdcursesdll.} -proc replace_panel*(pan: ptr TPANEL; win: ptr TWINDOW): cint{.extdecl, +proc replace_panel*(pan: ptr PANEL; win: ptr WINDOW): cint{.extdecl, importc: "replace_panel", dynlib: pdcursesdll.} -proc set_panel_userptr*(pan: ptr TPANEL; uptr: pointer): cint{.extdecl, +proc set_panel_userptr*(pan: ptr PANEL; uptr: pointer): cint{.extdecl, importc: "set_panel_userptr", dynlib: pdcursesdll.} -proc show_panel*(pan: ptr TPANEL): cint{.extdecl, importc: "show_panel", +proc show_panel*(pan: ptr PANEL): cint{.extdecl, importc: "show_panel", dynlib: pdcursesdll.} -proc top_panel*(pan: ptr TPANEL): cint{.extdecl, importc: "top_panel", +proc top_panel*(pan: ptr PANEL): cint{.extdecl, importc: "top_panel", dynlib: pdcursesdll.} proc update_panels*(){.extdecl, importc: "update_panels", dynlib: pdcursesdll.} when unixOS: - proc Xinitscr*(a2: cint; a3: cstringArray): ptr TWINDOW{.extdecl, + proc Xinitscr*(a2: cint; a3: cstringArray): ptr WINDOW{.extdecl, importc: "Xinitscr", dynlib: pdcursesdll.} proc XCursesExit*(){.extdecl, importc: "XCursesExit", dynlib: pdcursesdll.} proc sb_init*(): cint{.extdecl, importc: "sb_init", dynlib: pdcursesdll.} @@ -1536,4 +1542,4 @@ when defined(windows): quick_edit*{.importc: "pdc_quick_edit", dynlib: pdcursesdll.}: DWORD proc get_buffer_rows*(): cint{.extdecl, importc: "PDC_get_buffer_rows", - dynlib: pdcursesdll.} \ No newline at end of file + dynlib: pdcursesdll.} diff --git a/lib/wrappers/postgres.nim b/lib/wrappers/postgres.nim index cb39c41bb..3c35bc590 100644 --- a/lib/wrappers/postgres.nim +++ b/lib/wrappers/postgres.nim @@ -26,25 +26,25 @@ const CMDSTATUS_LEN* = 40 type - TSockAddr* = array[1..112, int8] - TPGresAttDesc*{.pure, final.} = object + SockAddr* = array[1..112, int8] + PGresAttDesc*{.pure, final.} = object name*: cstring adtid*: Oid adtsize*: int - PPGresAttDesc* = ptr TPGresAttDesc + PPGresAttDesc* = ptr PGresAttDesc PPPGresAttDesc* = ptr PPGresAttDesc - TPGresAttValue*{.pure, final.} = object + PGresAttValue*{.pure, final.} = object length*: int32 value*: cstring - PPGresAttValue* = ptr TPGresAttValue + PPGresAttValue* = ptr PGresAttValue PPPGresAttValue* = ptr PPGresAttValue - PExecStatusType* = ptr TExecStatusType - TExecStatusType* = enum + PExecStatusType* = ptr ExecStatusType + ExecStatusType* = enum PGRES_EMPTY_QUERY = 0, PGRES_COMMAND_OK, PGRES_TUPLES_OK, PGRES_COPY_OUT, PGRES_COPY_IN, PGRES_BAD_RESPONSE, PGRES_NONFATAL_ERROR, PGRES_FATAL_ERROR - TPGlobjfuncs*{.pure, final.} = object + PGlobjfuncs*{.pure, final.} = object fn_lo_open*: Oid fn_lo_close*: Oid fn_lo_creat*: Oid @@ -54,26 +54,26 @@ type fn_lo_read*: Oid fn_lo_write*: Oid - PPGlobjfuncs* = ptr TPGlobjfuncs - PConnStatusType* = ptr TConnStatusType - TConnStatusType* = enum + PPGlobjfuncs* = ptr PGlobjfuncs + PConnStatusType* = ptr ConnStatusType + ConnStatusType* = enum CONNECTION_OK, CONNECTION_BAD, CONNECTION_STARTED, CONNECTION_MADE, CONNECTION_AWAITING_RESPONSE, CONNECTION_AUTH_OK, CONNECTION_SETENV, CONNECTION_SSL_STARTUP, CONNECTION_NEEDED - TPGconn*{.pure, final.} = object + PGconn*{.pure, final.} = object pghost*: cstring pgtty*: cstring pgport*: cstring pgoptions*: cstring dbName*: cstring - status*: TConnStatusType + status*: ConnStatusType errorMessage*: array[0..(ERROR_MSG_LENGTH) - 1, char] Pfin*: File Pfout*: File Pfdebug*: File sock*: int32 - laddr*: TSockAddr - raddr*: TSockAddr + laddr*: SockAddr + raddr*: SockAddr salt*: array[0..(2) - 1, char] asyncNotifyWaiting*: int32 notifyList*: pointer @@ -81,19 +81,19 @@ type pgpass*: cstring lobjfuncs*: PPGlobjfuncs - PPGconn* = ptr TPGconn - TPGresult*{.pure, final.} = object + PPGconn* = ptr PGconn + PGresult*{.pure, final.} = object ntups*: int32 numAttributes*: int32 attDescs*: PPGresAttDesc tuples*: PPPGresAttValue tupArrSize*: int32 - resultStatus*: TExecStatusType + resultStatus*: ExecStatusType cmdStatus*: array[0..(CMDSTATUS_LEN) - 1, char] binary*: int32 conn*: PPGconn - PPGresult* = ptr TPGresult + PPGresult* = ptr PGresult PPostgresPollingStatusType* = ptr PostgresPollingStatusType PostgresPollingStatusType* = enum PGRES_POLLING_FAILED = 0, PGRES_POLLING_READING, PGRES_POLLING_WRITING, @@ -143,7 +143,10 @@ type length*: int32 isint*: int32 p*: pointer - +{.deprecated: [TSockAddr: SockAddr, TPGresAttDesc: PgresAttDesc, + TPGresAttValue: PgresAttValue, TExecStatusType: ExecStatusType, + TPGlobjfuncs: Pglobjfuncs, TConnStatusType: ConnStatusType, TPGconn: Pgconn, + TPGresult: PGresult].} proc pqconnectStart*(conninfo: cstring): PPGconn{.cdecl, dynlib: dllName, importc: "PQconnectStart".} @@ -175,7 +178,7 @@ proc pqport*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQport". proc pqtty*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQtty".} proc pqoptions*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQoptions".} -proc pqstatus*(conn: PPGconn): TConnStatusType{.cdecl, dynlib: dllName, +proc pqstatus*(conn: PPGconn): ConnStatusType{.cdecl, dynlib: dllName, importc: "PQstatus".} proc pqtransactionStatus*(conn: PPGconn): PGTransactionStatusType{.cdecl, dynlib: dllName, importc: "PQtransactionStatus".} @@ -263,9 +266,9 @@ proc pqflush*(conn: PPGconn): int32{.cdecl, dynlib: dllName, importc: "PQflush". proc pqfn*(conn: PPGconn, fnid: int32, result_buf, result_len: ptr int32, result_is_int: int32, args: PPQArgBlock, nargs: int32): PPGresult{. cdecl, dynlib: dllName, importc: "PQfn".} -proc pqresultStatus*(res: PPGresult): TExecStatusType{.cdecl, dynlib: dllName, +proc pqresultStatus*(res: PPGresult): ExecStatusType{.cdecl, dynlib: dllName, importc: "PQresultStatus".} -proc pqresStatus*(status: TExecStatusType): cstring{.cdecl, dynlib: dllName, +proc pqresStatus*(status: ExecStatusType): cstring{.cdecl, dynlib: dllName, importc: "PQresStatus".} proc pqresultErrorMessage*(res: PPGresult): cstring{.cdecl, dynlib: dllName, importc: "PQresultErrorMessage".} @@ -309,7 +312,7 @@ proc pqgetisnull*(res: PPGresult, tup_num: int32, field_num: int32): int32{. cdecl, dynlib: dllName, importc: "PQgetisnull".} proc pqclear*(res: PPGresult){.cdecl, dynlib: dllName, importc: "PQclear".} proc pqfreemem*(p: pointer){.cdecl, dynlib: dllName, importc: "PQfreemem".} -proc pqmakeEmptyPGresult*(conn: PPGconn, status: TExecStatusType): PPGresult{. +proc pqmakeEmptyPGresult*(conn: PPGconn, status: ExecStatusType): PPGresult{. cdecl, dynlib: dllName, importc: "PQmakeEmptyPGresult".} proc pqescapeString*(till, `from`: cstring, len: int): int{.cdecl, dynlib: dllName, importc: "PQescapeString".} diff --git a/lib/wrappers/readline/history.nim b/lib/wrappers/readline/history.nim index 495bc15e4..610c76a62 100644 --- a/lib/wrappers/readline/history.nim +++ b/lib/wrappers/readline/history.nim @@ -28,16 +28,17 @@ const import times, rltypedefs type - Thistdata* = pointer + Histdata* = pointer +{.deprecated: [Thistdata: Histdata].} # The structure used to store a history entry. type - THIST_ENTRY*{.pure, final.} = object + HIST_ENTRY*{.pure, final.} = object line*: cstring timestamp*: cstring # char * rather than time_t for read/write - data*: Thistdata - + data*: Histdata +{.deprecated: [THIST_ENTRY: HIST_ENTRY].} # Size of the history-library-managed space in history entry HS. @@ -47,12 +48,13 @@ template HISTENT_BYTES*(hs: expr): expr = # A structure used to pass the current state of the history stuff around. type - THISTORY_STATE*{.pure, final.} = object - entries*: ptr ptr THIST_ENTRY # Pointer to the entries themselves. + HISTORY_STATE*{.pure, final.} = object + entries*: ptr ptr HIST_ENTRY # Pointer to the entries themselves. offset*: cint # The location pointer within this array. length*: cint # Number of elements within this array. size*: cint # Number of slots allocated to this array. flags*: cint +{.deprecated: [THISTORY_STATE: HISTORY_STATE].} # Flag values for the `flags' member of HISTORY_STATE. @@ -67,11 +69,11 @@ const proc using_history*(){.cdecl, importc: "using_history", dynlib: historyDll.} # Return the current HISTORY_STATE of the history. -proc history_get_history_state*(): ptr THISTORY_STATE{.cdecl, +proc history_get_history_state*(): ptr HISTORY_STATE{.cdecl, importc: "history_get_history_state", dynlib: historyDll.} # Set the state of the current history array to STATE. -proc history_set_history_state*(a2: ptr THISTORY_STATE){.cdecl, +proc history_set_history_state*(a2: ptr HISTORY_STATE){.cdecl, importc: "history_set_history_state", dynlib: historyDll.} # Manage the history list. # Place STRING at the end of the history list. @@ -88,18 +90,18 @@ proc add_history_time*(a2: cstring){.cdecl, importc: "add_history_time", # is the magic number that tells us which element to delete. The # elements are numbered from 0. -proc remove_history*(a2: cint): ptr THIST_ENTRY{.cdecl, +proc remove_history*(a2: cint): ptr HIST_ENTRY{.cdecl, importc: "remove_history", dynlib: historyDll.} # Free the history entry H and return any application-specific data # associated with it. -proc free_history_entry*(a2: ptr THIST_ENTRY): Thistdata{.cdecl, +proc free_history_entry*(a2: ptr HIST_ENTRY): Histdata{.cdecl, importc: "free_history_entry", dynlib: historyDll.} # Make the history entry at WHICH have LINE and DATA. This returns # the old entry so you can dispose of the data. In the case of an # invalid WHICH, a NULL pointer is returned. -proc replace_history_entry*(a2: cint, a3: cstring, a4: Thistdata): ptr THIST_ENTRY{. +proc replace_history_entry*(a2: cint, a3: cstring, a4: Histdata): ptr HIST_ENTRY{. cdecl, importc: "replace_history_entry", dynlib: historyDll.} # Clear the history list and start over. @@ -123,7 +125,7 @@ proc history_is_stifled*(): cint{.cdecl, importc: "history_is_stifled", # history. Element 0 of this list is the beginning of time. If there # is no history, return NULL. -proc history_list*(): ptr ptr THIST_ENTRY{.cdecl, importc: "history_list", +proc history_list*(): ptr ptr HIST_ENTRY{.cdecl, importc: "history_list", dynlib: historyDll.} # Returns the number which says what history element we are now # looking at. @@ -132,17 +134,17 @@ proc where_history*(): cint{.cdecl, importc: "where_history", dynlib: historyDll # Return the history entry at the current position, as determined by # history_offset. If there is no entry there, return a NULL pointer. -proc current_history*(): ptr THIST_ENTRY{.cdecl, importc: "current_history", +proc current_history*(): ptr HIST_ENTRY{.cdecl, importc: "current_history", dynlib: historyDll.} # Return the history entry which is logically at OFFSET in the history # array. OFFSET is relative to history_base. -proc history_get*(a2: cint): ptr THIST_ENTRY{.cdecl, importc: "history_get", +proc history_get*(a2: cint): ptr HIST_ENTRY{.cdecl, importc: "history_get", dynlib: historyDll.} # Return the timestamp associated with the HIST_ENTRY * passed as an # argument -proc history_get_time*(a2: ptr THIST_ENTRY): Time{.cdecl, +proc history_get_time*(a2: ptr HIST_ENTRY): Time{.cdecl, importc: "history_get_time", dynlib: historyDll.} # Return the number of bytes that the primary history entries are using. # This just adds up the lengths of the_history->lines. @@ -158,13 +160,13 @@ proc history_set_pos*(a2: cint): cint{.cdecl, importc: "history_set_pos", # a pointer to that entry. If there is no previous entry, return # a NULL pointer. -proc previous_history*(): ptr THIST_ENTRY{.cdecl, importc: "previous_history", +proc previous_history*(): ptr HIST_ENTRY{.cdecl, importc: "previous_history", dynlib: historyDll.} # Move history_offset forward to the next item in the input_history, # and return the a pointer to that entry. If there is no next entry, # return a NULL pointer. -proc next_history*(): ptr THIST_ENTRY{.cdecl, importc: "next_history", +proc next_history*(): ptr HIST_ENTRY{.cdecl, importc: "next_history", dynlib: historyDll.} # Searching the history list. # Search the history for STRING, starting at history_offset. diff --git a/lib/wrappers/readline/readline.nim b/lib/wrappers/readline/readline.nim index 5a319243e..652808576 100644 --- a/lib/wrappers/readline/readline.nim +++ b/lib/wrappers/readline/readline.nim @@ -29,7 +29,7 @@ elif defined(macosx): else: const readlineDll* = "libreadline.so.6(|.0)" -# mangle "'TCommandFunc'" TCommandFunc +# mangle "'CommandFunc'" CommandFunc # mangle TvcpFunc TvcpFunc import rltypedefs @@ -78,9 +78,10 @@ const # TYPE says which kind of thing FUNCTION is. type - TKEYMAP_ENTRY*{.pure, final.} = object + KEYMAP_ENTRY*{.pure, final.} = object typ*: char - function*: TCommandFunc + function*: CommandFunc +{.deprecated: [TKEYMAP_ENTRY: KEYMAP_ENTRY].} # This must be large enough to hold bindings for all of the characters @@ -97,8 +98,9 @@ const # Maybe I need C lessons. type - TKEYMAP_ENTRY_ARRAY* = array[0..KEYMAP_SIZE - 1, TKEYMAP_ENTRY] - PKeymap* = ptr TKEYMAP_ENTRY + KEYMAP_ENTRY_ARRAY* = array[0..KEYMAP_SIZE - 1, KEYMAP_ENTRY] + PKeymap* = ptr KEYMAP_ENTRY +{.deprecated: [TKEYMAP_ENTRY_ARRAY: KEYMAP_ENTRY_ARRAY].} # The values that TYPE can have in a keymap entry. @@ -110,12 +112,12 @@ const when false: var emacs_standard_keymap*{.importc: "emacs_standard_keymap", - dynlib: readlineDll.}: TKEYMAP_ENTRY_ARRAY - emacs_meta_keymap*{.importc: "emacs_meta_keymap", dynlib: readlineDll.}: TKEYMAP_ENTRY_ARRAY - emacs_ctlx_keymap*{.importc: "emacs_ctlx_keymap", dynlib: readlineDll.}: TKEYMAP_ENTRY_ARRAY + dynlib: readlineDll.}: KEYMAP_ENTRY_ARRAY + emacs_meta_keymap*{.importc: "emacs_meta_keymap", dynlib: readlineDll.}: KEYMAP_ENTRY_ARRAY + emacs_ctlx_keymap*{.importc: "emacs_ctlx_keymap", dynlib: readlineDll.}: KEYMAP_ENTRY_ARRAY var - vi_insertion_keymap*{.importc: "vi_insertion_keymap", dynlib: readlineDll.}: TKEYMAP_ENTRY_ARRAY - vi_movement_keymap*{.importc: "vi_movement_keymap", dynlib: readlineDll.}: TKEYMAP_ENTRY_ARRAY + vi_insertion_keymap*{.importc: "vi_insertion_keymap", dynlib: readlineDll.}: KEYMAP_ENTRY_ARRAY + vi_movement_keymap*{.importc: "vi_movement_keymap", dynlib: readlineDll.}: KEYMAP_ENTRY_ARRAY # Return a new, empty keymap. # Free it with free() when you are done. @@ -154,7 +156,8 @@ const tildeDll = readlineDll type - Thook_func* = proc (a2: cstring): cstring{.cdecl.} + Hook_func* = proc (a2: cstring): cstring{.cdecl.} +{.deprecated: [Thook_func: Hook_func].} when not defined(macosx): # If non-null, this contains the address of a function that the application @@ -163,7 +166,7 @@ when not defined(macosx): # which is the expansion, or a NULL pointer if the expansion fails. var expansion_preexpansion_hook*{.importc: "tilde_expansion_preexpansion_hook", - dynlib: tildeDll.}: Thook_func + dynlib: tildeDll.}: Hook_func # If non-null, this contains the address of a function to call if the # standard meaning for expanding a tilde fails. The function is called @@ -171,7 +174,7 @@ when not defined(macosx): # which is the expansion, or a NULL pointer if there is no expansion. var expansion_failure_hook*{.importc: "tilde_expansion_failure_hook", - dynlib: tildeDll.}: Thook_func + dynlib: tildeDll.}: Hook_func # When non-null, this is a NULL terminated array of strings which # are duplicates for a tilde prefix. Bash uses this to expand @@ -214,35 +217,38 @@ const # the code tells undo what to undo, not how to undo it. type - Tundo_code* = enum + Undo_code* = enum UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END +{.deprecated: [Tundo_code: Undo_code].} # What an element of THE_UNDO_LIST looks like. type - TUNDO_LIST*{.pure, final.} = object - next*: ptr Tundo_list + UNDO_LIST*{.pure, final.} = object + next*: ptr UNDO_LIST start*: cint theEnd*: cint # Where the change took place. text*: cstring # The text to insert, if undoing a delete. - what*: Tundo_code # Delete, Insert, Begin, End. + what*: Undo_code # Delete, Insert, Begin, End. +{.deprecated: [TUNDO_LIST: UNDO_LIST].} # The current undo list for RL_LINE_BUFFER. when not defined(macosx): - var undo_list*{.importc: "rl_undo_list", dynlib: readlineDll.}: ptr TUNDO_LIST + var undo_list*{.importc: "rl_undo_list", dynlib: readlineDll.}: ptr UNDO_LIST # The data structure for mapping textual names to code addresses. type - TFUNMAP*{.pure, final.} = object + FUNMAP*{.pure, final.} = object name*: cstring - function*: TCommandFunc + function*: CommandFunc +{.deprecated: [TFUNMAP: FUNMAP].} when not defined(macosx): - var funmap*{.importc: "funmap", dynlib: readlineDll.}: ptr ptr TFUNMAP + var funmap*{.importc: "funmap", dynlib: readlineDll.}: ptr ptr FUNMAP # **************************************************************** # @@ -604,31 +610,31 @@ proc discard_argument*(): cint{.cdecl, importc: "rl_discard_argument", dynlib: readlineDll.} # Utility functions to bind keys to readline commands. -proc add_defun*(a2: cstring, a3: TCommandFunc, a4: cint): cint{.cdecl, +proc add_defun*(a2: cstring, a3: CommandFunc, a4: cint): cint{.cdecl, importc: "rl_add_defun", dynlib: readlineDll.} -proc bind_key*(a2: cint, a3: TCommandFunc): cint{.cdecl, +proc bind_key*(a2: cint, a3: CommandFunc): cint{.cdecl, importc: "rl_bind_key", dynlib: readlineDll.} -proc bind_key_in_map*(a2: cint, a3: TCommandFunc, a4: PKeymap): cint{.cdecl, +proc bind_key_in_map*(a2: cint, a3: CommandFunc, a4: PKeymap): cint{.cdecl, importc: "rl_bind_key_in_map", dynlib: readlineDll.} proc unbind_key*(a2: cint): cint{.cdecl, importc: "rl_unbind_key", dynlib: readlineDll.} proc unbind_key_in_map*(a2: cint, a3: PKeymap): cint{.cdecl, importc: "rl_unbind_key_in_map", dynlib: readlineDll.} -proc bind_key_if_unbound*(a2: cint, a3: TCommandFunc): cint{.cdecl, +proc bind_key_if_unbound*(a2: cint, a3: CommandFunc): cint{.cdecl, importc: "rl_bind_key_if_unbound", dynlib: readlineDll.} -proc bind_key_if_unbound_in_map*(a2: cint, a3: TCommandFunc, a4: PKeymap): cint{. +proc bind_key_if_unbound_in_map*(a2: cint, a3: CommandFunc, a4: PKeymap): cint{. cdecl, importc: "rl_bind_key_if_unbound_in_map", dynlib: readlineDll.} -proc unbind_function_in_map*(a2: TCommandFunc, a3: PKeymap): cint{.cdecl, +proc unbind_function_in_map*(a2: CommandFunc, a3: PKeymap): cint{.cdecl, importc: "rl_unbind_function_in_map", dynlib: readlineDll.} proc unbind_command_in_map*(a2: cstring, a3: PKeymap): cint{.cdecl, importc: "rl_unbind_command_in_map", dynlib: readlineDll.} -proc bind_keyseq*(a2: cstring, a3: TCommandFunc): cint{.cdecl, +proc bind_keyseq*(a2: cstring, a3: CommandFunc): cint{.cdecl, importc: "rl_bind_keyseq", dynlib: readlineDll.} -proc bind_keyseq_in_map*(a2: cstring, a3: TCommandFunc, a4: PKeymap): cint{. +proc bind_keyseq_in_map*(a2: cstring, a3: CommandFunc, a4: PKeymap): cint{. cdecl, importc: "rl_bind_keyseq_in_map", dynlib: readlineDll.} -proc bind_keyseq_if_unbound*(a2: cstring, a3: TCommandFunc): cint{.cdecl, +proc bind_keyseq_if_unbound*(a2: cstring, a3: CommandFunc): cint{.cdecl, importc: "rl_bind_keyseq_if_unbound", dynlib: readlineDll.} -proc bind_keyseq_if_unbound_in_map*(a2: cstring, a3: TCommandFunc, +proc bind_keyseq_if_unbound_in_map*(a2: cstring, a3: CommandFunc, a4: PKeymap): cint{.cdecl, importc: "rl_bind_keyseq_if_unbound_in_map", dynlib: readlineDll.} proc generic_bind*(a2: cint, a3: cstring, a4: cstring, a5: PKeymap): cint{. @@ -639,7 +645,7 @@ proc variable_bind*(a2: cstring, a3: cstring): cint{.cdecl, importc: "rl_variable_bind", dynlib: readlineDll.} # Backwards compatibility, use rl_bind_keyseq_in_map instead. -proc set_key*(a2: cstring, a3: TCommandFunc, a4: PKeymap): cint{.cdecl, +proc set_key*(a2: cstring, a3: CommandFunc, a4: PKeymap): cint{.cdecl, importc: "rl_set_key", dynlib: readlineDll.} # Backwards compatibility, use rl_generic_bind instead. @@ -651,15 +657,15 @@ proc translate_keyseq*(a2: cstring, a3: cstring, a4: ptr cint): cint{.cdecl, importc: "rl_translate_keyseq", dynlib: readlineDll.} proc untranslate_keyseq*(a2: cint): cstring{.cdecl, importc: "rl_untranslate_keyseq", dynlib: readlineDll.} -proc named_function*(a2: cstring): TCommandFunc{.cdecl, +proc named_function*(a2: cstring): CommandFunc{.cdecl, importc: "rl_named_function", dynlib: readlineDll.} -proc function_of_keyseq*(a2: cstring, a3: PKeymap, a4: ptr cint): TCommandFunc{. +proc function_of_keyseq*(a2: cstring, a3: PKeymap, a4: ptr cint): CommandFunc{. cdecl, importc: "rl_function_of_keyseq", dynlib: readlineDll.} proc list_funmap_names*(){.cdecl, importc: "rl_list_funmap_names", dynlib: readlineDll.} -proc invoking_keyseqs_in_map*(a2: TCommandFunc, a3: PKeymap): cstringArray{. +proc invoking_keyseqs_in_map*(a2: CommandFunc, a3: PKeymap): cstringArray{. cdecl, importc: "rl_invoking_keyseqs_in_map", dynlib: readlineDll.} -proc invoking_keyseqs*(a2: TCommandFunc): cstringArray{.cdecl, +proc invoking_keyseqs*(a2: CommandFunc): cstringArray{.cdecl, importc: "rl_invoking_keyseqs", dynlib: readlineDll.} proc function_dumper*(a2: cint){.cdecl, importc: "rl_function_dumper", dynlib: readlineDll.} @@ -682,7 +688,7 @@ proc get_keymap_name_from_edit_mode*(): cstring{.cdecl, importc: "rl_get_keymap_name_from_edit_mode", dynlib: readlineDll.} # Functions for manipulating the funmap, which maps command names to functions. -proc add_funmap_entry*(a2: cstring, a3: TCommandFunc): cint{.cdecl, +proc add_funmap_entry*(a2: cstring, a3: CommandFunc): cint{.cdecl, importc: "rl_add_funmap_entry", dynlib: readlineDll.} proc funmap_names*(): cstringArray{.cdecl, importc: "rl_funmap_names", dynlib: readlineDll.} @@ -697,7 +703,7 @@ proc push_macro_input*(a2: cstring){.cdecl, importc: "rl_push_macro_input", dynlib: readlineDll.} # Functions for undoing, from undo.c -proc add_undo*(a2: Tundo_code, a3: cint, a4: cint, a5: cstring){.cdecl, +proc add_undo*(a2: Undo_code, a3: cint, a4: cint, a5: cstring){.cdecl, importc: "rl_add_undo", dynlib: readlineDll.} proc free_undo_list*(){.cdecl, importc: "rl_free_undo_list", dynlib: readlineDll.} proc do_undo*(): cint{.cdecl, importc: "rl_do_undo", dynlib: readlineDll.} @@ -816,13 +822,13 @@ proc complete_internal*(a2: cint): cint{.cdecl, importc: "rl_complete_internal", dynlib: readlineDll.} proc display_match_list*(a2: cstringArray, a3: cint, a4: cint){.cdecl, importc: "rl_display_match_list", dynlib: readlineDll.} -proc completion_matches*(a2: cstring, a3: Tcompentry_func): cstringArray{. +proc completion_matches*(a2: cstring, a3: Compentry_func): cstringArray{. cdecl, importc: "rl_completion_matches", dynlib: readlineDll.} proc username_completion_function*(a2: cstring, a3: cint): cstring{.cdecl, importc: "rl_username_completion_function", dynlib: readlineDll.} proc filename_completion_function*(a2: cstring, a3: cint): cstring{.cdecl, importc: "rl_filename_completion_function", dynlib: readlineDll.} -proc completion_mode*(a2: TCommandFunc): cint{.cdecl, +proc completion_mode*(a2: CommandFunc): cint{.cdecl, importc: "rl_completion_mode", dynlib: readlineDll.} # **************************************************************** # @@ -877,7 +883,7 @@ when false: # The current value of the numeric argument specified by the user. var numeric_arg*{.importc: "rl_numeric_arg", dynlib: readlineDll.}: cint # The address of the last command function Readline executed. - var last_func*{.importc: "rl_last_func", dynlib: readlineDll.}: TCommandFunc + var last_func*{.importc: "rl_last_func", dynlib: readlineDll.}: CommandFunc # The name of the terminal to use. var terminal_name*{.importc: "rl_terminal_name", dynlib: readlineDll.}: cstring # The input and output streams. @@ -1169,18 +1175,18 @@ template ISSTATE*(x: expr): expr = (readline_state and x) != 0 type - Treadline_state*{.pure, final.} = object + Readline_state*{.pure, final.} = object point*: cint # line state theEnd*: cint mark*: cint buffer*: cstring buflen*: cint - ul*: ptr TUNDO_LIST + ul*: ptr UNDO_LIST prompt*: cstring # global state rlstate*: cint done*: cint kmap*: PKeymap # input state - lastfunc*: TCommandFunc + lastfunc*: CommandFunc insmode*: cint edmode*: cint kseqlen*: cint @@ -1194,9 +1200,10 @@ type # options state # reserved for future expansion, so the struct size doesn't change reserved*: array[0..64 - 1, char] +{.deprecated: [Treadline_state: Readline_state].} -proc save_state*(a2: ptr Treadline_state): cint{.cdecl, +proc save_state*(a2: ptr Readline_state): cint{.cdecl, importc: "rl_save_state", dynlib: readlineDll.} -proc restore_state*(a2: ptr Treadline_state): cint{.cdecl, +proc restore_state*(a2: ptr Readline_state): cint{.cdecl, importc: "rl_restore_state", dynlib: readlineDll.} diff --git a/lib/wrappers/readline/rltypedefs.nim b/lib/wrappers/readline/rltypedefs.nim index 847834e80..759b81297 100644 --- a/lib/wrappers/readline/rltypedefs.nim +++ b/lib/wrappers/readline/rltypedefs.nim @@ -19,27 +19,32 @@ # type - TFunction* = proc (): cint{.cdecl.} - TVFunction* = proc (){.cdecl.} - TCPFunction* = proc (): cstring{.cdecl.} - TCPPFunction* = proc (): cstringArray{.cdecl.} + Function* = proc (): cint{.cdecl.} + VFunction* = proc (){.cdecl.} + CPFunction* = proc (): cstring{.cdecl.} + CPPFunction* = proc (): cstringArray{.cdecl.} +{.deprecated: [TFunction: Function, TVFunction: VFunction, + TCPFunction: CPFunction, TCPPFunction: CPPFunction].} # Bindable functions type - Tcommand_func* = proc (a2: cint, a3: cint): cint{.cdecl.} + Command_func* = proc (a2: cint, a3: cint): cint{.cdecl.} +{.deprecated: [Tcommand_func: Command_func].} # Typedefs for the completion system type - Tcompentry_func* = proc (a2: cstring, a3: cint): cstring{.cdecl.} - Tcompletion_func* = proc (a2: cstring, a3: cint, a4: cint): cstringArray{. + Compentry_func* = proc (a2: cstring, a3: cint): cstring{.cdecl.} + Completion_func* = proc (a2: cstring, a3: cint, a4: cint): cstringArray{. cdecl.} - Tquote_func* = proc (a2: cstring, a3: cint, a4: cstring): cstring{.cdecl.} - Tdequote_func* = proc (a2: cstring, a3: cint): cstring{.cdecl.} - Tcompignore_func* = proc (a2: cstringArray): cint{.cdecl.} - Tcompdisp_func* = proc (a2: cstringArray, a3: cint, a4: cint){.cdecl.} - + Quote_func* = proc (a2: cstring, a3: cint, a4: cstring): cstring{.cdecl.} + Dequote_func* = proc (a2: cstring, a3: cint): cstring{.cdecl.} + Compignore_func* = proc (a2: cstringArray): cint{.cdecl.} + Compdisp_func* = proc (a2: cstringArray, a3: cint, a4: cint){.cdecl.} +{.deprecated: [Tcompentry_func: Compentry_func,Tcompletion_func: Completion_func, + Tquote_func: Quote_func, Tdequote_func: Dequote_func, + Tcompignore_func: Compignore_func, Tcompdisp_func: Compdisp_func].} # Type for input and pre-read hook functions like rl_event_hook type diff --git a/lib/wrappers/sdl/sdl.nim b/lib/wrappers/sdl/sdl.nim index 5bb5b7ec2..376de8e08 100644 --- a/lib/wrappers/sdl/sdl.nim +++ b/lib/wrappers/sdl/sdl.nim @@ -346,7 +346,7 @@ const HAT_LEFTDOWN* = HAT_LEFT or HAT_DOWN # SDL_events.h constants type - TEventKind* = enum # kind of an SDL event + EventKind* = enum # kind of an SDL event NOEVENT = 0, # Unused (do not remove) ACTIVEEVENT = 1, # Application loses/gains visibility KEYDOWN = 2, # Keys pressed @@ -374,6 +374,7 @@ type # Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use USEREVENT = 24 # This last event is only for bounding internal arrays # It is the number of bits in the event mask datatype -- int32 +{.deprecated: [TEventKind: EventKind].} const NUMEVENTS* = 32 @@ -750,12 +751,12 @@ const # Enumeration of valid key mods (possibly OR'd tog GRAB_ON* = 1 #SDL_GRAB_FULLSCREEN // Used internally type - THandle* = int #SDL_types.h types + Handle* = int #SDL_types.h types # Basic data types - TBool* = enum + Bool* = enum sdlFALSE, sdlTRUE - PUInt8Array* = ptr TUInt8Array - TUInt8Array* = array[0..high(int) shr 1, byte] + PUInt8Array* = ptr UInt8Array + UInt8Array* = array[0..high(int) shr 1, byte] PUInt16* = ptr uint16 PUInt32* = ptr uint32 PUInt64* = ptr UInt64 @@ -768,15 +769,14 @@ type hi*: int32 lo*: int32 - TGrabMode* = int32 # SDL_error.h types - Terrorcode* = enum + GrabMode* = int32 # SDL_error.h types + ErrorCode* = enum ENOMEM, EFREAD, EFWRITE, EFSEEK, LASTERROR - Errorcode* = Terrorcode - TArg*{.final.} = object + Arg*{.final.} = object buf*: array[0..ERR_MAX_STRLEN - 1, int8] - Perror* = ptr Terror - TError*{.final.} = object # This is a numeric value corresponding to the current error + Perror* = ptr Error + Error*{.final.} = object # This is a numeric value corresponding to the current error # SDL_rwops.h types # This is the read/write operation structure -- very basic # some helper types to handle the unions @@ -787,51 +787,51 @@ type # used directly as an error message format string. key*: array[0..ERR_MAX_STRLEN - 1, int8] # These are the arguments for the error functions argc*: int - args*: array[0..ERR_MAX_ARGS - 1, TArg] + args*: array[0..ERR_MAX_ARGS - 1, Arg] - TStdio*{.final.} = object + Stdio*{.final.} = object autoclose*: int # FILE * is only defined in Kylix so we use a simple pointer fp*: pointer - TMem*{.final.} = object + Mem*{.final.} = object base*: ptr byte here*: ptr byte stop*: ptr byte - PRWops* = ptr TRWops # now the pointer to function types - TSeek* = proc (context: PRWops, offset: int, whence: int): int{.cdecl.} - TRead* = proc (context: PRWops, thePtr: pointer, size: int, maxnum: int): int{. + PRWops* = ptr RWops # now the pointer to function types + Seek* = proc (context: PRWops, offset: int, whence: int): int{.cdecl.} + Read* = proc (context: PRWops, thePtr: pointer, size: int, maxnum: int): int{. cdecl.} - TWrite* = proc (context: PRWops, thePtr: pointer, size: int, num: int): int{. + Write* = proc (context: PRWops, thePtr: pointer, size: int, num: int): int{. cdecl.} - TClose* = proc (context: PRWops): int{.cdecl.} # the variant record itself - TRWops*{.final.} = object - seek*: TSeek - read*: TRead - write*: TWrite - closeFile*: TClose # a keyword as name is not allowed + Close* = proc (context: PRWops): int{.cdecl.} # the variant record itself + RWops*{.final.} = object + seek*: Seek + read*: Read + write*: Write + closeFile*: Close # a keyword as name is not allowed # be warned! structure alignment may arise at this point theType*: cint - mem*: TMem + mem*: Mem - RWops* = TRWops # SDL_timer.h types + # SDL_timer.h types # Function prototype for the timer callback function - TTimerCallback* = proc (interval: int32): int32{.cdecl.} - TNewTimerCallback* = proc (interval: int32, param: pointer): int32{.cdecl.} + TimerCallback* = proc (interval: int32): int32{.cdecl.} + NewTimerCallback* = proc (interval: int32, param: pointer): int32{.cdecl.} - PTimerID* = ptr TTimerID - TTimerID*{.final.} = object + PTimerID* = ptr TimerID + TimerID*{.final.} = object interval*: int32 - callback*: TNewTimerCallback + callback*: NewTimerCallback param*: pointer lastAlarm*: int32 next*: PTimerID - TAudioSpecCallback* = proc (userdata: pointer, stream: ptr byte, length: int){. + AudioSpecCallback* = proc (userdata: pointer, stream: ptr byte, length: int){. cdecl.} # SDL_audio.h types # The calculated values in this structure are calculated by SDL_OpenAudio() - PAudioSpec* = ptr TAudioSpec - TAudioSpec*{.final.} = object # A structure to hold a set of audio conversion filters and buffers + PAudioSpec* = ptr AudioSpec + AudioSpec*{.final.} = object # A structure to hold a set of audio conversion filters and buffers freq*: int # DSP frequency -- samples per second format*: uint16 # Audio data format channels*: byte # Number of channels: 1 mono, 2 stereo @@ -844,18 +844,18 @@ type # 'len' is the length of that buffer in bytes. # Once the callback returns, the buffer will no longer be valid. # Stereo samples are stored in a LRLRLR ordering. - callback*: TAudioSpecCallback + callback*: AudioSpecCallback userdata*: pointer - PAudioCVT* = ptr TAudioCVT - PAudioCVTFilter* = ptr TAudioCVTFilter - TAudioCVTFilter*{.final.} = object + PAudioCVT* = ptr AudioCVT + PAudioCVTFilter* = ptr AudioCVTFilter + AudioCVTFilter*{.final.} = object cvt*: PAudioCVT format*: uint16 - PAudioCVTFilterArray* = ptr TAudioCVTFilterArray - TAudioCVTFilterArray* = array[0..9, PAudioCVTFilter] - TAudioCVT*{.final.} = object + PAudioCVTFilterArray* = ptr AudioCVTFilterArray + AudioCVTFilterArray* = array[0..9, PAudioCVTFilter] + AudioCVT*{.final.} = object needed*: int # Set to 1 if conversion possible srcFormat*: uint16 # Source audio format dstFormat*: uint16 # Target audio format @@ -865,49 +865,49 @@ type lenCvt*: int # Length of converted audio buffer lenMult*: int # buffer must be len*len_mult big lenRatio*: float64 # Given len, final size is len*len_ratio - filters*: TAudioCVTFilterArray + filters*: AudioCVTFilterArray filterIndex*: int # Current audio conversion function - TAudiostatus* = enum # SDL_cdrom.h types + AudioStatus* = enum # SDL_cdrom.h types AUDIO_STOPPED, AUDIO_PLAYING, AUDIO_PAUSED - TCDStatus* = enum + CDStatus* = enum CD_ERROR, CD_TRAYEMPTY, CD_STOPPED, CD_PLAYING, CD_PAUSED - PCDTrack* = ptr TCDTrack - TCDTrack*{.final.} = object # This structure is only current as of the last call to SDL_CDStatus() + PCDTrack* = ptr CDTrack + CDTrack*{.final.} = object # This structure is only current as of the last call to SDL_CDStatus() id*: byte # Track number theType*: byte # Data or audio track unused*: uint16 len*: int32 # Length, in frames, of this track offset*: int32 # Offset, in frames, from start of disk - PCD* = ptr TCD - TCD*{.final.} = object #SDL_joystick.h types + PCD* = ptr CD + CD*{.final.} = object #SDL_joystick.h types id*: int # Private drive identifier - status*: TCDStatus # Current drive status + status*: CDStatus # Current drive status # The rest of this structure is only valid if there's a CD in drive numtracks*: int # Number of tracks on disk - curTrack*: int # Current track position + curTrack*: int # Current track position curFrame*: int # Current frame offset within current track - track*: array[0..MAX_TRACKS, TCDTrack] + track*: array[0..MAX_TRACKS, CDTrack] - PTransAxis* = ptr TTransAxis - TTransAxis*{.final.} = object # The private structure used to keep track of a joystick + PTransAxis* = ptr TransAxis + TransAxis*{.final.} = object # The private structure used to keep track of a joystick offset*: int scale*: float32 - PJoystickHwdata* = ptr TJoystickHwdata - TJoystick_hwdata*{.final.} = object # joystick ID + PJoystickHwdata* = ptr JoystickHwdata + Joystick_hwdata*{.final.} = object # joystick ID id*: int # values used to translate device-specific coordinates into SDL-standard ranges - transaxis*: array[0..5, TTransAxis] + transaxis*: array[0..5, TransAxis] - PBallDelta* = ptr TBallDelta - TBallDelta*{.final.} = object # Current ball motion deltas + PBallDelta* = ptr BallDelta + BallDelta*{.final.} = object # Current ball motion deltas # The SDL joystick structure dx*: int dy*: int - PJoystick* = ptr TJoystick - TJoystick*{.final.} = object # SDL_verion.h types + PJoystick* = ptr Joystick + Joystick*{.final.} = object # SDL_verion.h types index*: byte # Device index name*: cstring # Joystick name - system dependent naxes*: int # Number of axis controls on the joystick @@ -921,16 +921,16 @@ type hwdata*: PJoystickHwdata # Driver dependent information refCount*: int # Reference count for multiple opens - Pversion* = ptr Tversion - Tversion*{.final.} = object # SDL_keyboard.h types + Pversion* = ptr Version + Version*{.final.} = object # SDL_keyboard.h types major*: byte minor*: byte patch*: byte - TKey* = int32 - TMod* = int32 - PKeySym* = ptr TKeySym - TKeySym*{.final.} = object # SDL_events.h types + Key* = int32 + Mod* = int32 + PKeySym* = ptr KeySym + KeySym*{.final.} = object # SDL_events.h types #Checks the event queue for messages and optionally returns them. # If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to # the back of the event queue. @@ -943,69 +943,69 @@ type # This function returns the number of events actually stored, or -1 # if there was an error. This function is thread-safe. scancode*: byte # hardware specific scancode - sym*: TKey # SDL virtual keysym - modifier*: TMod # current key modifiers + sym*: Key # SDL virtual keysym + modifier*: Mod # current key modifiers unicode*: uint16 # translated character - TEventAction* = enum # Application visibility event structure + EventAction* = enum # Application visibility event structure ADDEVENT, PEEKEVENT, GETEVENT PActiveEvent* = ptr TActiveEvent TActiveEvent*{.final.} = object # SDL_ACTIVEEVENT # Keyboard event structure - kind*: TEventKind + kind*: EventKind gain*: byte # Whether given states were gained or lost (1/0) state*: byte # A mask of the focus states - PKeyboardEvent* = ptr TKeyboardEvent - TKeyboardEvent*{.final.} = object # SDL_KEYDOWN or SDL_KEYUP + PKeyboardEvent* = ptr KeyboardEvent + KeyboardEvent*{.final.} = object # SDL_KEYDOWN or SDL_KEYUP # Mouse motion event structure - kind*: TEventKind + kind*: EventKind which*: byte # The keyboard device index state*: byte # SDL_PRESSED or SDL_RELEASED - keysym*: TKeySym + keysym*: KeySym - PMouseMotionEvent* = ptr TMouseMotionEvent - TMouseMotionEvent*{.final.} = object # SDL_MOUSEMOTION + PMouseMotionEvent* = ptr MouseMotionEvent + MouseMotionEvent*{.final.} = object # SDL_MOUSEMOTION # Mouse button event structure - kind*: TEventKind + kind*: EventKind which*: byte # The mouse device index state*: byte # The current button state x*, y*: uint16 # The X/Y coordinates of the mouse xrel*: int16 # The relative motion in the X direction yrel*: int16 # The relative motion in the Y direction - PMouseButtonEvent* = ptr TMouseButtonEvent - TMouseButtonEvent*{.final.} = object # SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP + PMouseButtonEvent* = ptr MouseButtonEvent + MouseButtonEvent*{.final.} = object # SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP # Joystick axis motion event structure - kind*: TEventKind + kind*: EventKind which*: byte # The mouse device index button*: byte # The mouse button index state*: byte # SDL_PRESSED or SDL_RELEASED x*: uint16 # The X coordinates of the mouse at press time y*: uint16 # The Y coordinates of the mouse at press time - PJoyAxisEvent* = ptr TJoyAxisEvent - TJoyAxisEvent*{.final.} = object # SDL_JOYAXISMOTION + PJoyAxisEvent* = ptr JoyAxisEvent + JoyAxisEvent*{.final.} = object # SDL_JOYAXISMOTION # Joystick trackball motion event structure - kind*: TEventKind + kind*: EventKind which*: byte # The joystick device index axis*: byte # The joystick axis index value*: int16 # The axis value (range: -32768 to 32767) - PJoyBallEvent* = ptr TJoyBallEvent - TJoyBallEvent*{.final.} = object # SDL_JOYAVBALLMOTION + PJoyBallEvent* = ptr JoyBallEvent + JoyBallEvent*{.final.} = object # SDL_JOYAVBALLMOTION # Joystick hat position change event structure - kind*: TEventKind + kind*: EventKind which*: byte # The joystick device index ball*: byte # The joystick trackball index xrel*: int16 # The relative motion in the X direction yrel*: int16 # The relative motion in the Y direction - PJoyHatEvent* = ptr TJoyHatEvent - TJoyHatEvent*{.final.} = object # SDL_JOYHATMOTION */ + PJoyHatEvent* = ptr JoyHatEvent + JoyHatEvent*{.final.} = object # SDL_JOYHATMOTION */ # Joystick button event structure - kind*: TEventKind + kind*: EventKind which*: byte # The joystick device index */ hat*: byte # The joystick hat index */ value*: byte # The hat position value: @@ -1014,146 +1014,174 @@ type # 6 5 4 # Note that zero means the POV is centered. - PJoyButtonEvent* = ptr TJoyButtonEvent - TJoyButtonEvent*{.final.} = object # SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP + PJoyButtonEvent* = ptr JoyButtonEvent + JoyButtonEvent*{.final.} = object # SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP # The "window resized" event # When you get this event, you are # responsible for setting a new video # mode with the new width and height. - kind*: TEventKind + kind*: EventKind which*: byte # The joystick device index button*: byte # The joystick button index state*: byte # SDL_PRESSED or SDL_RELEASED - PResizeEvent* = ptr TResizeEvent - TResizeEvent*{.final.} = object # SDL_VIDEORESIZE + PResizeEvent* = ptr ResizeEvent + ResizeEvent*{.final.} = object # SDL_VIDEORESIZE # A user-defined event type - kind*: TEventKind + kind*: EventKind w*: cint # New width h*: cint # New height PUserEvent* = ptr TUserEvent TUserEvent*{.final.} = object # SDL_USEREVENT through SDL_NUMEVENTS-1 - kind*: TEventKind - code*: cint # User defined event code + kind*: EventKind + code*: cint # User defined event code data1*: pointer # User defined data pointer data2*: pointer # User defined data pointer - -when defined(Unix): +{.deprecated: [THandle: Handle, TEventAction: EventAction, TKey: Key, TArg: Arg, + TKeySym: KeySym, TKeyboardEvent: KeyboardEvent, TError: Error, + TWrite: Write, TBool: Bool, TUInt8Array: UInt8Array, + TGrabMode: GrabMode, Terrorcode: Errorcode, TStdio: Stdio, + TMem: Mem, TSeek: Seek, TRead: Read, TClose: Close, + TTimerCallback: TimerCallback, TNewTimerCallback: NewTimerCallback, + TTimerID: TimerID, TAudioSpecCallback: AudioSpecCallback, + TAudioSpec: AudioSpec, TAudioCVTFilter: AudioCVTFilter, + TAudioCVTFilterArray: AudioCVTFilterArray, TAudioCVT: AudioCVT, + TAudioStatus: AudioStatus, TCDStatus: CDStatus, TCDTrack: CDTrack, + TCD: CD, TTransAxis: TransAxis, TJoystick_hwdata: Joystick_hwdata, + TJoystick: Joystick, TJoyAxisEvent: JoyAxisEvent, TRWops: RWops, + TJoyBallEvent: JoyBallEvent, TJoyHatEvent: JoyHatEvent, + TJoyButtonEvent: JoyButtonEvent, TBallDelta: BallDelta, + Tversion: Version, TMod: Mod, + # TActiveEvent: ActiveEvent, # Naming conflict when we drop the `T` + TMouseMotionEvent: MouseMotionEvent, TMouseButtonEvent: MouseButtonEvent, + TResizeEvent: ResizeEvent, + # TUserEvent: UserEvent # Naming conflict when we drop the `T` + ].} + +when defined(Unix): type #These are the various supported subsystems under UNIX - TSysWm* = enum + SysWm* = enum SYSWM_X11 -when defined(WINDOWS): + {.deprecated: [TSysWm: SysWm].} +when defined(WINDOWS): type - PSysWMmsg* = ptr TSysWMmsg - TSysWMmsg*{.final.} = object - version*: Tversion - hwnd*: THandle # The window for the message + PSysWMmsg* = ptr SysWMmsg + SysWMmsg*{.final.} = object + version*: Version + hwnd*: Handle # The window for the message msg*: int # The type of message wParam*: int32 # WORD message parameter lParam*: int32 # LONG message parameter + {.deprecated: [TSysWMmsg: SysWMmsg].} elif defined(Unix): type # The Linux custom event structure - PSysWMmsg* = ptr TSysWMmsg - TSysWMmsg*{.final.} = object - version*: Tversion - subsystem*: TSysWm + PSysWMmsg* = ptr SysWMmsg + SysWMmsg*{.final.} = object + version*: Version + subsystem*: SysWm when false: event*: TXEvent + {.deprecated: [TSysWMmsg: SysWMmsg].} else: type # The generic custom event structure - PSysWMmsg* = ptr TSysWMmsg - TSysWMmsg*{.final.} = object - version*: Tversion + PSysWMmsg* = ptr SysWMmsg + SysWMmsg*{.final.} = object + version*: Version data*: int + {.deprecated: [TSysWMmsg: SysWMmsg].} # The Windows custom window manager information structure when defined(WINDOWS): type - PSysWMinfo* = ptr TSysWMinfo - TSysWMinfo*{.final.} = object - version*: Tversion - window*: THandle # The display window + PSysWMinfo* = ptr SysWMinfo + SysWMinfo*{.final.} = object + version*: Version + window*: Handle # The display window + {.deprecated: [TSysWMinfo: SysWMinfo].} elif defined(Unix): type - TX11*{.final.} = object + X11*{.final.} = object when false: display*: PDisplay # The X11 display - window*: TWindow # The X11 display window + window*: Window # The X11 display window # These locking functions should be called around # any X11 functions using the display variable. # They lock the event thread, so should not be # called around event functions or from event filters. lock_func*: pointer unlock_func*: pointer # Introduced in SDL 1.0.2 - fswindow*: TWindow # The X11 fullscreen window - wmwindow*: TWindow # The X11 managed input window + fswindow*: Window # The X11 fullscreen window + wmwindow*: Window # The X11 managed input window + {.deprecated: [TX11: X11].} type - PSysWMinfo* = ptr TSysWMinfo - TSysWMinfo*{.final.} = object - version*: Tversion - subsystem*: TSysWm - X11*: TX11 + PSysWMinfo* = ptr SysWMinfo + SysWMinfo*{.final.} = object + version*: Version + subsystem*: SysWm + X11*: X11 + {.deprecated: [TSysWMinfo: SysWMinfo].} else: type # The generic custom window manager information structure - PSysWMinfo* = ptr TSysWMinfo - TSysWMinfo*{.final.} = object - version*: Tversion + PSysWMinfo* = ptr SysWMinfo + SysWMinfo*{.final.} = object + version*: Version data*: int + {.deprecated: [TSysWMinfo: SysWMinfo].} type PSysWMEvent* = ptr TSysWMEvent TSysWMEvent*{.final.} = object - kind*: TEventKind + kind*: EventKind msg*: PSysWMmsg - PExposeEvent* = ptr TExposeEvent - TExposeEvent*{.final.} = object - kind*: TEventKind + PExposeEvent* = ptr ExposeEvent + ExposeEvent*{.final.} = object + kind*: EventKind - PQuitEvent* = ptr TQuitEvent - TQuitEvent*{.final.} = object - kind*: TEventKind + PQuitEvent* = ptr QuitEvent + QuitEvent*{.final.} = object + kind*: EventKind - PEvent* = ptr TEvent - TEvent*{.final.} = object - kind*: TEventKind + PEvent* = ptr Event + Event*{.final.} = object + kind*: EventKind pad: array[0..19, byte] - TEventFilter* = proc (event: PEvent): int{.cdecl.} # SDL_video.h types + EventFilter* = proc (event: PEvent): int{.cdecl.} # SDL_video.h types # Useful data types PPSDL_Rect* = ptr PRect - PRect* = ptr TRect - TRect*{.final.} = object + PRect* = ptr Rect + Rect*{.final.} = object x*, y*: int16 w*, h*: uint16 - Rect* = TRect - PColor* = ptr TColor - TColor*{.final.} = object +# Rect* = TRect + PColor* = ptr Color + Color*{.final.} = object r*: byte g*: byte b*: byte unused*: byte - PColorArray* = ptr TColorArray - TColorArray* = array[0..65000, TColor] - PPalette* = ptr TPalette - TPalette*{.final.} = object # Everything in the pixel format structure is read-only + PColorArray* = ptr ColorArray + ColorArray* = array[0..65000, Color] + PPalette* = ptr Palette + Palette*{.final.} = object # Everything in the pixel format structure is read-only ncolors*: int colors*: PColorArray - PPixelFormat* = ptr TPixelFormat - TPixelFormat*{.final.} = object # The structure passed to the low level blit functions + PPixelFormat* = ptr PixelFormat + PixelFormat*{.final.} = object # The structure passed to the low level blit functions palette*: PPalette bitsPerPixel*: byte bytesPerPixel*: byte @@ -1172,8 +1200,8 @@ type colorkey*: int32 # RGB color key information alpha*: byte # Alpha value information (per-surface alpha) - PBlitInfo* = ptr TBlitInfo - TBlitInfo*{.final.} = object # typedef for private surface blitting functions + PBlitInfo* = ptr BlitInfo + BlitInfo*{.final.} = object # typedef for private surface blitting functions sPixels*: ptr byte sWidth*: int sHeight*: int @@ -1187,10 +1215,10 @@ type table*: ptr byte dst*: PPixelFormat - PSurface* = ptr TSurface - TBlit* = proc (src: PSurface, srcrect: PRect, + PSurface* = ptr Surface + Blit* = proc (src: PSurface, srcrect: PRect, dst: PSurface, dstrect: PRect): int{.cdecl.} - TSurface*{.final.} = object # Useful for determining the video hardware capabilities + Surface*{.final.} = object # Useful for determining the video hardware capabilities flags*: int32 # Read-only format*: PPixelFormat # Read-only w*, h*: cint # Read-only @@ -1199,7 +1227,7 @@ type offset*: cint # Private hwdata*: pointer #TPrivate_hwdata; Hardware-specific surface info # clipping information: - clipRect*: TRect # Read-only + clipRect*: Rect # Read-only unused1*: int32 # for binary compatibility # Allow recursive locks locked*: int32 # Private @@ -1209,8 +1237,8 @@ type formatVersion*: cint # Private refcount*: cint - PVideoInfo* = ptr TVideoInfo - TVideoInfo*{.final.} = object # The YUV hardware video overlay + PVideoInfo* = ptr VideoInfo + VideoInfo*{.final.} = object # The YUV hardware video overlay hwAvailable*: byte blitHw*: byte unusedBits3*: byte # Unused at this point @@ -1219,8 +1247,8 @@ type currentW*: int32 # Value: The current video mode width currentH*: int32 # Value: The current video mode height - POverlay* = ptr TOverlay - TOverlay*{.final.} = object # Public enumeration for setting the OpenGL window attributes. + POverlay* = ptr Overlay + Overlay*{.final.} = object # Public enumeration for setting the OpenGL window attributes. format*: int32 # Overlay format w*, h*: int # Width and height of overlay planes*: int # Number of planes in the overlay. Usually either 1 or 3 @@ -1228,61 +1256,74 @@ type pixels*: ptr ptr byte # An array of pointers to the data of each plane. The overlay should be locked before these pointers are used. hwOverlay*: int32 # This will be set to 1 if the overlay is hardware accelerated. - TGLAttr* = enum - GL_RED_SIZE, GL_GREEN_SIZE, GL_BLUE_SIZE, GL_ALPHA_SIZE, GL_BUFFER_SIZE, - GL_DOUBLEBUFFER, GL_DEPTH_SIZE, GL_STENCIL_SIZE, GL_ACCUM_RED_SIZE, - GL_ACCUM_GREEN_SIZE, GL_ACCUM_BLUE_SIZE, GL_ACCUM_ALPHA_SIZE, GL_STEREO, - GL_MULTISAMPLEBUFFERS, GL_MULTISAMPLESAMPLES, GL_ACCELERATED_VISUAL, + GLAttr* = enum + GL_RED_SIZE, GL_GREEN_SIZE, GL_BLUE_SIZE, GL_ALPHA_SIZE, GL_BUFFER_SIZE, + GL_DOUBLEBUFFER, GL_DEPTH_SIZE, GL_STENCIL_SIZE, GL_ACCUM_RED_SIZE, + GL_ACCUM_GREEN_SIZE, GL_ACCUM_BLUE_SIZE, GL_ACCUM_ALPHA_SIZE, GL_STEREO, + GL_MULTISAMPLEBUFFERS, GL_MULTISAMPLESAMPLES, GL_ACCELERATED_VISUAL, GL_SWAP_CONTROL - PCursor* = ptr TCursor - TCursor*{.final.} = object # SDL_mutex.h types - area*: TRect # The area of the mouse cursor + PCursor* = ptr Cursor + Cursor*{.final.} = object # SDL_mutex.h types + area*: Rect # The area of the mouse cursor hotX*, hot_y*: int16 # The "tip" of the cursor data*: ptr byte # B/W cursor data mask*: ptr byte # B/W cursor mask save*: array[1..2, ptr byte] # Place to save cursor area wmCursor*: pointer # Window-manager cursor - +{.deprecated: [TRect: Rect, TSurface: Surface, TEvent: Event, TColor: Color, + TEventFilter: EventFilter, TColorArray: ColorArray, + # TSysWMEvent: SysWMEvent, # Naming conflict when we drop the `T` + TExposeEvent: ExposeEvent, + TQuitEvent: QuitEvent, TPalette: Palette, TPixelFormat: PixelFormat, + TBlitInfo: BlitInfo, TBlit: Blit, TVideoInfo: VideoInfo, + TOverlay: Overlay, TGLAttr: GLAttr, TCursor: Cursor].} type - PMutex* = ptr TMutex - TMutex*{.final.} = object - Psemaphore* = ptr Tsemaphore - Tsemaphore*{.final.} = object - PSem* = ptr TSem - TSem* = Tsemaphore - PCond* = ptr TCond - TCond*{.final.} = object # SDL_thread.h types - -when defined(WINDOWS): + PMutex* = ptr Mutex + Mutex*{.final.} = object + Psemaphore* = ptr Semaphore + Semaphore*{.final.} = object + PSem* = ptr Sem + Sem* = Semaphore + PCond* = ptr Cond + Cond*{.final.} = object # SDL_thread.h types +{.deprecated: [TCond: Cond, TSem: Sem, TMutex: Mutex, Tsemaphore: Semaphore].} + +when defined(WINDOWS): type - TSYS_ThreadHandle* = THandle -when defined(Unix): + SYS_ThreadHandle* = Handle + {.deprecated: [TSYS_ThreadHandle: SYS_ThreadHandle].} +when defined(Unix): type - TSYS_ThreadHandle* = pointer + SYS_ThreadHandle* = pointer + {.deprecated: [TSYS_ThreadHandle: SYS_ThreadHandle].} type # This is the system-independent thread info structure - PThread* = ptr TThread - TThread*{.final.} = object # Helper Types + PThread* = ptr Thread + Thread*{.final.} = object # Helper Types # Keyboard State Array ( See demos for how to use ) threadid*: int32 - handle*: TSYS_ThreadHandle + handle*: SYS_ThreadHandle status*: int - errbuf*: Terror + errbuf*: Error data*: pointer - PKeyStateArr* = ptr TKeyStateArr - TKeyStateArr* = array[0..65000, byte] # Types required so we don't need to use Windows.pas + PKeyStateArr* = ptr KeyStateArr + KeyStateArr* = array[0..65000, byte] # Types required so we don't need to use Windows.pas PInteger* = ptr int PByte* = ptr int8 PWord* = ptr int16 PLongWord* = ptr int32 # General arrays - PByteArray* = ptr TByteArray - TByteArray* = array[0..32767, int8] - PWordArray* = ptr TWordArray - TWordArray* = array[0..16383, int16] # Generic procedure pointer + PByteArray* = ptr ByteArray + ByteArray* = array[0..32767, int8] + PWordArray* = ptr WordArray + WordArray* = array[0..16383, int16] # Generic procedure pointer +{.deprecated: [TKeyStateArr: KeyStateArr, TByteArray: ByteArray, TThread: Thread, + TWordArray: WordArray].} + +type EventSeq = set[EventKind] +{.deprecated: [TEventSeq: EventSeq].} -type TEventSeq = set[TEventKind] -template evconv(procName: expr, ptrName: typedesc, assertions: TEventSeq): stmt {.immediate.} = +template evconv(procName: expr, ptrName: typedesc, assertions: EventSeq): stmt {.immediate.} = proc `procName`*(event: PEvent): ptrName = assert(contains(assertions, event.kind)) result = cast[ptrName](event) @@ -1337,7 +1378,7 @@ proc getError*(): cstring{.cdecl, importc: "SDL_GetError", dynlib: LibName.} proc setError*(fmt: cstring){.cdecl, importc: "SDL_SetError", dynlib: LibName.} proc clearError*(){.cdecl, importc: "SDL_ClearError", dynlib: LibName.} when not (defined(WINDOWS)): - proc error*(Code: Terrorcode){.cdecl, importc: "SDL_Error", dynlib: LibName.} + proc error*(Code: ErrorCode){.cdecl, importc: "SDL_Error", dynlib: LibName.} #------------------------------------------------------------------------------ # io handling #------------------------------------------------------------------------------ @@ -1368,13 +1409,13 @@ proc getTicks*(): int32{.cdecl, importc: "SDL_GetTicks", dynlib: LibName.} proc delay*(msec: int32){.cdecl, importc: "SDL_Delay", dynlib: LibName.} # Add a new timer to the pool of timers already running. # Returns a timer ID, or NULL when an error occurs. -proc addTimer*(interval: int32, callback: TNewTimerCallback, param: pointer): PTimerID{. +proc addTimer*(interval: int32, callback: NewTimerCallback, param: pointer): PTimerID{. cdecl, importc: "SDL_AddTimer", dynlib: LibName.} # Remove one of the multiple timers knowing its ID. # Returns a boolean value indicating success. -proc removeTimer*(t: PTimerID): TBool{.cdecl, importc: "SDL_RemoveTimer", +proc removeTimer*(t: PTimerID): Bool{.cdecl, importc: "SDL_RemoveTimer", dynlib: LibName.} -proc setTimer*(interval: int32, callback: TTimerCallback): int{.cdecl, +proc setTimer*(interval: int32, callback: TimerCallback): int{.cdecl, importc: "SDL_SetTimer", dynlib: LibName.} #------------------------------------------------------------------------------ # audio-routines @@ -1432,7 +1473,7 @@ proc audioDriverName*(namebuf: cstring, maxlen: int): cstring{.cdecl, proc openAudio*(desired, obtained: PAudioSpec): int{.cdecl, importc: "SDL_OpenAudio", dynlib: LibName.} # Get the current audio state: -proc getAudioStatus*(): TAudiostatus{.cdecl, importc: "SDL_GetAudioStatus", +proc getAudioStatus*(): Audiostatus{.cdecl, importc: "SDL_GetAudioStatus", dynlib: LibName.} # This function pauses and unpauses the audio callback processing. # It should be called with a parameter of 0 after opening the audio @@ -1518,7 +1559,7 @@ proc cdOpen*(drive: int): PCD{.cdecl, importc: "SDL_CDOpen", dynlib: LibName.} # This function returns the current status of the given drive. # If the drive has a CD in it, the table of contents of the CD and current # play position of the CD will be stored in the SDL_CD structure. -proc cdStatus*(cdrom: PCD): TCDStatus{.cdecl, importc: "SDL_CDStatus", +proc cdStatus*(cdrom: PCD): CDStatus{.cdecl, importc: "SDL_CDStatus", dynlib: LibName.} # Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks' # tracks and 'nframes' frames. If both 'ntrack' and 'nframe' are 0, play @@ -1559,7 +1600,7 @@ proc cdEject*(cdrom: PCD): int{.cdecl, importc: "SDL_CDEject", dynlib: LibName.} # Closes the handle for the CD-ROM drive proc cdClose*(cdrom: PCD){.cdecl, importc: "SDL_CDClose", dynlib: LibName.} # Given a status, returns true if there's a disk in the drive -proc cdInDrive*(status: TCDStatus): bool +proc cdInDrive*(status: CDStatus): bool proc numJoysticks*(): int{.cdecl, importc: "SDL_NumJoysticks", dynlib: LibName.} # Get the implementation dependent name of a joystick. @@ -1643,7 +1684,7 @@ proc pumpEvents*(){.cdecl, importc: "SDL_PumpEvents", dynlib: LibName.} # removed from the queue. # This function returns the number of events actually stored, or -1 # if there was an error. This function is thread-safe. -proc peepEvents*(events: PEvent, numevents: int, action: TEventAction, +proc peepEvents*(events: PEvent, numevents: int, action: EventAction, mask: int32): int{.cdecl, importc: "SDL_PeepEvents", dynlib: LibName.} # Polls for currently pending events, and returns 1 if there are any pending @@ -1672,11 +1713,11 @@ proc pushEvent*(event: PEvent): int{.cdecl, importc: "SDL_PushEvent", # be closed, otherwise the window will remain open if possible. # If the quit event is generated by an interrupt signal, it will bypass the # internal queue and be delivered to the application at the next event poll. -proc setEventFilter*(filter: TEventFilter){.cdecl, +proc setEventFilter*(filter: EventFilter){.cdecl, importc: "SDL_SetEventFilter", dynlib: LibName.} # Return the current event filter - can be used to "chain" filters. # If there is no event filter set, this function returns NULL. -proc getEventFilter*(): TEventFilter{.cdecl, importc: "SDL_GetEventFilter", +proc getEventFilter*(): EventFilter{.cdecl, importc: "SDL_GetEventFilter", dynlib: LibName.} # This function allows you to set the state of processing certain events. # If 'state' is set to SDL_IGNORE, that event will be automatically dropped @@ -1691,7 +1732,7 @@ proc eventState*(theType: byte, state: int): byte{.cdecl, #------------------------------------------------------------------------------ # This macro can be used to fill a version structure with the compile-time # version of the SDL library. -proc version*(x: var Tversion) +proc version*(x: var Version) # This macro turns the version numbers into a numeric value: # (1,2,3) -> (1203) # This assumes that there will never be more than 100 patchlevels @@ -2174,7 +2215,7 @@ proc glLoadLibrary*(filename: cstring): int{.cdecl, proc glGetProcAddress*(procname: cstring): pointer{.cdecl, importc: "SDL_GL_GetProcAddress", dynlib: LibName.} # Set an attribute of the OpenGL subsystem before intialization. -proc glSetAttribute*(attr: TGLAttr, value: int): int{.cdecl, +proc glSetAttribute*(attr: GLAttr, value: int): int{.cdecl, importc: "SDL_GL_SetAttribute", dynlib: LibName.} # Get an attribute of the OpenGL subsystem from the windowing # interface, such as glX. This is of course different from getting @@ -2183,7 +2224,7 @@ proc glSetAttribute*(attr: TGLAttr, value: int): int{.cdecl, # # Developers should track the values they pass into SDL_GL_SetAttribute # themselves if they want to retrieve these values. -proc glGetAttribute*(attr: TGLAttr, value: var int): int{.cdecl, +proc glGetAttribute*(attr: GLAttr, value: var int): int{.cdecl, importc: "SDL_GL_GetAttribute", dynlib: LibName.} # Swap the OpenGL buffers, if double-buffering is supported. proc glSwapBuffers*(){.cdecl, importc: "SDL_GL_SwapBuffers", dynlib: LibName.} @@ -2230,7 +2271,7 @@ proc wmToggleFullScreen*(surface: PSurface): int{.cdecl, # Grabbing means that the mouse is confined to the application window, # and nearly all keyboard input is passed directly to the application, # and not interpreted by a window manager, if any. -proc wmGrabInput*(mode: TGrabMode): TGrabMode{.cdecl, +proc wmGrabInput*(mode: GrabMode): GrabMode{.cdecl, importc: "SDL_WM_GrabInput", dynlib: LibName.} #------------------------------------------------------------------------------ # mouse-routines @@ -2305,13 +2346,13 @@ proc getKeyRepeat*(delay: PInteger, interval: PInteger){.cdecl, proc getKeyState*(numkeys: pointer): ptr byte{.cdecl, importc: "SDL_GetKeyState", dynlib: LibName.} # Get the current key modifier state -proc getModState*(): TMod{.cdecl, importc: "SDL_GetModState", dynlib: LibName.} +proc getModState*(): Mod{.cdecl, importc: "SDL_GetModState", dynlib: LibName.} # Set the current key modifier state # This does not change the keyboard state, only the key modifier flags. -proc setModState*(modstate: TMod){.cdecl, importc: "SDL_SetModState", +proc setModState*(modstate: Mod){.cdecl, importc: "SDL_SetModState", dynlib: LibName.} # Get the name of an SDL virtual keysym -proc getKeyName*(key: TKey): cstring{.cdecl, importc: "SDL_GetKeyName", +proc getKeyName*(key: Key): cstring{.cdecl, importc: "SDL_GetKeyName", dynlib: LibName.} #------------------------------------------------------------------------------ # Active Routines @@ -2469,7 +2510,7 @@ proc loadWAV(filename: cstring, spec: PAudioSpec, audioBuf: ptr byte, audiolen: PUInt32): PAudioSpec = result = loadWAV_RW(rWFromFile(filename, "rb"), 1, spec, audioBuf, audiolen) -proc cdInDrive(status: TCDStatus): bool = +proc cdInDrive(status: CDStatus): bool = result = ord(status) > ord(CD_ERROR) proc framesToMsf*(frames: int; m, s, f: var int) = @@ -2483,7 +2524,7 @@ proc framesToMsf*(frames: int; m, s, f: var int) = proc msfToFrames*(m, s, f: int): int = result = m * 60 * CD_FPS + s * CD_FPS + f -proc version(x: var Tversion) = +proc version(x: var Version) = x.major = MAJOR_VERSION x.minor = MINOR_VERSION x.patch = PATCHLEVEL diff --git a/lib/wrappers/sdl/sdl_gfx.nim b/lib/wrappers/sdl/sdl_gfx.nim index 5523ad0a2..0f5afaa9b 100644 --- a/lib/wrappers/sdl/sdl_gfx.nim +++ b/lib/wrappers/sdl/sdl_gfx.nim @@ -37,22 +37,22 @@ const # Some rates in Hz SMOOTHING_ON* = 1 type - PFPSmanager* = ptr TFPSmanager - TFPSmanager*{.final.} = object # ---- Structures + PFPSmanager* = ptr FPSmanager + FPSmanager*{.final.} = object # ---- Structures framecount*: uint32 rateticks*: float32 lastticks*: uint32 rate*: uint32 - PColorRGBA* = ptr TColorRGBA - TColorRGBA*{.final.} = object + PColorRGBA* = ptr ColorRGBA + ColorRGBA*{.final.} = object r*: byte g*: byte b*: byte a*: byte - PColorY* = ptr TColorY - TColorY*{.final.} = object # + PColorY* = ptr ColorY + ColorY*{.final.} = object # # # SDL_framerate: framerate manager # @@ -60,7 +60,7 @@ type # # y*: byte - +{.deprecated: [TFPSmanager: FPSmanager, TColorRGBA: ColorRGBA, TColorY: ColorY].} proc initFramerate*(manager: PFPSmanager){.cdecl, importc: "SDL_initFramerate", dynlib: gfxLibName.} diff --git a/lib/wrappers/sdl/sdl_image.nim b/lib/wrappers/sdl/sdl_image.nim index 9c56e6a46..7f99c8069 100644 --- a/lib/wrappers/sdl/sdl_image.nim +++ b/lib/wrappers/sdl/sdl_image.nim @@ -148,7 +148,7 @@ const # This macro can be used to fill a version structure with the compile-time # version of the SDL_image library. -proc imageVersion*(x: var Tversion) +proc imageVersion*(x: var Version) # This function gets the version of the dynamically linked SDL_image library. # it should NOT be used to fill a version structure, instead you should # use the SDL_IMAGE_VERSION() macro. @@ -236,7 +236,7 @@ proc imgLoadXV_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadXV_RW", proc imgReadXPMFromArray*(xpm: cstringArray): PSurface{.cdecl, importc: "IMG_ReadXPMFromArray", dynlib: ImageLibName.} -proc imageVersion(x: var Tversion) = +proc imageVersion(x: var Version) = x.major = IMAGE_MAJOR_VERSION x.minor = IMAGE_MINOR_VERSION x.patch = IMAGE_PATCHLEVEL diff --git a/lib/wrappers/sdl/sdl_mixer.nim b/lib/wrappers/sdl/sdl_mixer.nim index 2f8664635..b8f013a4a 100644 --- a/lib/wrappers/sdl/sdl_mixer.nim +++ b/lib/wrappers/sdl/sdl_mixer.nim @@ -188,34 +188,34 @@ const (LIBMIKMOD_VERSION_MINOR shl 8) or (LIBMIKMOD_REVISION)) type #music_cmd.h types - PMusicCMD* = ptr TMusicCMD - TMusicCMD*{.final.} = object #wavestream.h types + PMusicCMD* = ptr MusicCMD + MusicCMD*{.final.} = object #wavestream.h types filename*: array[0..PATH_MAX - 1, char] cmd*: array[0..PATH_MAX - 1, char] pid*: TSYS_ThreadHandle - PWAVStream* = ptr TWAVStream - TWAVStream*{.final.} = object #playmidi.h types + PWAVStream* = ptr WAVStream + WAVStream*{.final.} = object #playmidi.h types wavefp*: pointer start*: int32 stop*: int32 cvt*: TAudioCVT - PMidiEvent* = ptr TMidiEvent - TMidiEvent*{.final.} = object + PMidiEvent* = ptr MidiEvent + MidiEvent*{.final.} = object time*: int32 channel*: byte typ*: byte a*: byte b*: byte - PMidiSong* = ptr TMidiSong - TMidiSong*{.final.} = object #music_ogg.h types + PMidiSong* = ptr MidiSong + MidiSong*{.final.} = object #music_ogg.h types samples*: int32 events*: PMidiEvent - POGG_Music* = ptr TOGG_Music - TOGG_Music*{.final.} = object # mikmod.h types + POGG_Music* = ptr OGG_Music + OGG_Music*{.final.} = object # mikmod.h types #* # * Error codes # * @@ -226,7 +226,7 @@ type #music_cmd.h types lenAvailable*: int32 sndAvailable*: pointer - TErrorEnum* = enum + ErrorEnum* = enum MMERR_OPENING_FILE, MMERR_OUT_OF_MEMORY, MMERR_DYNAMIC_LINKING, MMERR_SAMPLE_TOO_BIG, MMERR_OUT_OF_HANDLES, MMERR_UNKNOWN_WAVE_TYPE, MMERR_LOADING_PATTERN, MMERR_LOADING_TRACK, MMERR_LOADING_HEADER, @@ -246,37 +246,41 @@ type #music_cmd.h types MMERR_DS_EVENT, MMERR_DS_THREAD, MMERR_DS_UPDATE, MMERR_WINMM_HANDLE, MMERR_WINMM_ALLOCATED, MMERR_WINMM_DEVICEID, MMERR_WINMM_FORMAT, MMERR_WINMM_UNKNOWN, MMERR_MAC_SPEED, MMERR_MAC_START, MMERR_MAX - PMODULE* = ptr TMODULE - TMODULE*{.final.} = object - PUNIMOD* = ptr TUNIMOD - TUNIMOD* = TMODULE #SDL_mixer.h types + PMODULE* = ptr MODULE + MODULE*{.final.} = object + PUNIMOD* = ptr UNIMOD + UNIMOD* = MODULE #SDL_mixer.h types # The internal format for an audio chunk - PChunk* = ptr TChunk - TChunk*{.final.} = object + PChunk* = ptr Chunk + Chunk*{.final.} = object allocated*: cint abuf*: pointer alen*: uint32 volume*: byte # Per-sample volume, 0-128 - TFading* = enum + Fading* = enum MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN - TMusicType* = enum + MusicType* = enum MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3 - PMusic* = ptr TMusic - TMusic*{.final.} = object # The internal format for a music chunk interpreted via mikmod - mixtype*: TMusicType # other fields are not aviable - # data : TMusicUnion; + PMusic* = ptr Music + Music*{.final.} = object # The internal format for a music chunk interpreted via mikmod + mixtype*: MusicType # other fields are not aviable + # data : MusicUnion; # fading : TMix_Fading; # fade_volume : integer; # fade_step : integer; # fade_steps : integer; # error : integer; - TMixFunction* = proc (udata, stream: pointer, length: cint): pointer{. + MixFunction* = proc (udata, stream: pointer, length: cint): pointer{. cdecl.} # This macro can be used to fill a version structure with the compile-time # version of the SDL_mixer library. +{.deprecated: [TMusicCMD: MusicCMD, TWAVStream: WAVStream, TMidiEvent: MidiEvent, + TMidiSong: MidiSong, TOGG_Music: OGG_Music, TErrorEnum: ErrorEnum, + TMODULE: MODULE, TUNIMOD: UNIMOD, TChunk: Chunk, TFading: Fading, + TMusicType: MusicType, TMusic: Music, TMixFunction: MixFunction].} -proc version*(x: var sdl.Tversion) +proc version*(x: var sdl.Version) # This function gets the version of the dynamically linked SDL_mixer library. # It should NOT be used to fill a version structure, instead you should use the # SDL_MIXER_VERSION() macro. @@ -314,18 +318,18 @@ proc freeMusic*(music: PMusic){.cdecl, importc: "Mix_FreeMusic", dynlib: MixerLibName.} # Find out the music format of a mixer music, or the currently playing # music, if 'music' is NULL. -proc getMusicType*(music: PMusic): TMusicType{.cdecl, +proc getMusicType*(music: PMusic): MusicType{.cdecl, importc: "Mix_GetMusicType", dynlib: MixerLibName.} # Set a function that is called after all mixing is performed. # This can be used to provide real-time visual display of the audio stream # or add a custom mixer filter for the stream data. # -proc setPostMix*(mixFunc: TMixFunction, arg: pointer){.cdecl, +proc setPostMix*(mixFunc: MixFunction, arg: pointer){.cdecl, importc: "Mix_SetPostMix", dynlib: MixerLibName.} # Add your own music player or additional mixer function. # If 'mix_func' is NULL, the default music player is re-enabled. # -proc hookMusic*(mixFunc: TMixFunction, arg: pointer){.cdecl, +proc hookMusic*(mixFunc: MixFunction, arg: pointer){.cdecl, importc: "Mix_HookMusic", dynlib: MixerLibName.} # Add your own callback when the music has finished playing. # @@ -337,9 +341,10 @@ proc getMusicHookData*(): pointer{.cdecl, importc: "Mix_GetMusicHookData", #* Add your own callback when a channel has finished playing. NULL # * to disable callback.* type - TChannelFinished* = proc (channel: cint){.cdecl.} + ChannelFinished* = proc (channel: cint){.cdecl.} +{.deprecated: [TChannelFinished: ChannelFinished].} -proc channelFinished*(channelFinished: TChannelFinished){.cdecl, +proc channelFinished*(channelFinished: ChannelFinished){.cdecl, importc: "Mix_ChannelFinished", dynlib: MixerLibName.} const CHANNEL_POST* = - 2 @@ -430,9 +435,9 @@ proc fadeOutGroup*(tag: cint, ms: cint): cint{.cdecl, proc fadeOutMusic*(ms: cint): cint{.cdecl, importc: "Mix_FadeOutMusic", dynlib: MixerLibName.} # Query the fading status of a channel -proc fadingMusic*(): TFading{.cdecl, importc: "Mix_FadingMusic", +proc fadingMusic*(): Fading{.cdecl, importc: "Mix_FadingMusic", dynlib: MixerLibName.} -proc fadingChannel*(which: cint): TFading{.cdecl, +proc fadingChannel*(which: cint): Fading{.cdecl, importc: "Mix_FadingChannel", dynlib: MixerLibName.} proc pause*(channel: cint){.cdecl, importc: "Mix_Pause", dynlib: MixerLibName.} @@ -468,7 +473,7 @@ proc getChunk*(channel: cint): PChunk{.cdecl, importc: "Mix_GetChunk", proc closeAudio*(){.cdecl, importc: "Mix_CloseAudio", dynlib: MixerLibName.} -proc version(x: var sdl.Tversion) = +proc version(x: var sdl.Version) = x.major = MAJOR_VERSION x.minor = MINOR_VERSION x.patch = PATCHLEVEL diff --git a/lib/wrappers/sdl/sdl_mixer_nosmpeg.nim b/lib/wrappers/sdl/sdl_mixer_nosmpeg.nim index 7a8c41af1..670cf1643 100644 --- a/lib/wrappers/sdl/sdl_mixer_nosmpeg.nim +++ b/lib/wrappers/sdl/sdl_mixer_nosmpeg.nim @@ -40,34 +40,34 @@ const (LIBMIKMOD_VERSION_MINOR shl 8) or (LIBMIKMOD_REVISION)) type #music_cmd.h types - PMusicCMD* = ptr TMusicCMD - TMusicCMD*{.final.} = object #wavestream.h types + PMusicCMD* = ptr MusicCMD + MusicCMD*{.final.} = object #wavestream.h types filename*: array[0..PATH_MAX - 1, char] cmd*: array[0..PATH_MAX - 1, char] pid*: TSYS_ThreadHandle - PWAVStream* = ptr TWAVStream - TWAVStream*{.final.} = object #playmidi.h types + PWAVStream* = ptr WAVStream + WAVStream*{.final.} = object #playmidi.h types wavefp*: pointer start*: int32 stop*: int32 cvt*: TAudioCVT - PMidiEvent* = ptr TMidiEvent - TMidiEvent*{.final.} = object + PMidiEvent* = ptr MidiEvent + MidiEvent*{.final.} = object time*: int32 channel*: byte typ*: byte a*: byte b*: byte - PMidiSong* = ptr TMidiSong - TMidiSong*{.final.} = object #music_ogg.h types + PMidiSong* = ptr MidiSong + MidiSong*{.final.} = object #music_ogg.h types samples*: int32 events*: PMidiEvent - POGG_Music* = ptr TOGG_Music - TOGG_Music*{.final.} = object # mikmod.h types + POGG_Music* = ptr OGG_Music + OGG_Music*{.final.} = object # mikmod.h types #* # * Error codes # * @@ -78,7 +78,7 @@ type #music_cmd.h types lenAvailable*: cint sndAvailable*: pointer - TErrorEnum* = enum + ErrorEnum* = enum MMERR_OPENING_FILE, MMERR_OUT_OF_MEMORY, MMERR_DYNAMIC_LINKING, MMERR_SAMPLE_TOO_BIG, MMERR_OUT_OF_HANDLES, MMERR_UNKNOWN_WAVE_TYPE, MMERR_LOADING_PATTERN, MMERR_LOADING_TRACK, MMERR_LOADING_HEADER, @@ -98,31 +98,36 @@ type #music_cmd.h types MMERR_DS_EVENT, MMERR_DS_THREAD, MMERR_DS_UPDATE, MMERR_WINMM_HANDLE, MMERR_WINMM_ALLOCATED, MMERR_WINMM_DEVICEID, MMERR_WINMM_FORMAT, MMERR_WINMM_UNKNOWN, MMERR_MAC_SPEED, MMERR_MAC_START, MMERR_MAX - PMODULE* = ptr TMODULE - TMODULE*{.final.} = object - PUNIMOD* = ptr TUNIMOD - TUNIMOD* = TMODULE #SDL_mixer.h types + PMODULE* = ptr MODULE + MODULE*{.final.} = object + PUNIMOD* = ptr UNIMOD + UNIMOD* = MODULE #SDL_mixer.h types # The internal format for an audio chunk - PChunk* = ptr TChunk - TChunk*{.final.} = object + PChunk* = ptr Chunk + Chunk*{.final.} = object allocated*: cint abuf*: pointer alen*: uint32 volume*: byte # Per-sample volume, 0-128 - TFading* = enum + Fading* = enum MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN - TMusicType* = enum + MusicType* = enum MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG - PMusic* = ptr TMusic - TMusic*{.final.} = object - typ*: TMusicType + PMusic* = ptr Music + Music*{.final.} = object + typ*: MusicType - TMixFunction* = proc (udata, stream: pointer, length: cint): pointer{. + MixFunction* = proc (udata, stream: pointer, length: cint): pointer{. cdecl.} # This macro can be used to fill a version structure with the compile-time # version of the SDL_mixer library. +{.deprecated: [TMusicCMD: MusicCMD, TWAVStream: WAVStream, TMidiEvent: MidiEvent, + TMidiSong: MidiSong, TOGG_Music: OGG_Music, TErrorEnum: ErrorEnum, + TMODULE: MODULE, TUNIMOD: UNIMOD, TChunk: Chunk, TFading: Fading, + TMusicType: MusicType, TMusic: Music, TMixFunction: MixFunction].} -proc version*(x: var sdl.Tversion) + +proc version*(x: var sdl.Version) # This function gets the version of the dynamically linked SDL_mixer library. # It should NOT be used to fill a version structure, instead you should use the # SDL_MIXER_VERSION() macro. @@ -160,18 +165,18 @@ proc freeMusic*(music: PMusic){.cdecl, importc: "Mix_FreeMusic", dynlib: MixerLibName.} # Find out the music format of a mixer music, or the currently playing # music, if 'music' is NULL. -proc getMusicType*(music: PMusic): TMusicType{.cdecl, +proc getMusicType*(music: PMusic): MusicType{.cdecl, importc: "Mix_GetMusicType", dynlib: MixerLibName.} # Set a function that is called after all mixing is performed. # This can be used to provide real-time visual display of the audio stream # or add a custom mixer filter for the stream data. # -proc setPostMix*(mixfunc: TMixFunction, arg: pointer){.cdecl, +proc setPostMix*(mixfunc: MixFunction, arg: pointer){.cdecl, importc: "Mix_SetPostMix", dynlib: MixerLibName.} # Add your own music player or additional mixer function. # If 'mix_func' is NULL, the default music player is re-enabled. # -proc hookMusic*(mixFunc: TMixFunction, arg: pointer){.cdecl, +proc hookMusic*(mixFunc: MixFunction, arg: pointer){.cdecl, importc: "Mix_HookMusic", dynlib: MixerLibName.} # Add your own callback when the music has finished playing. # @@ -183,9 +188,10 @@ proc getMusicHookData*(): pointer{.cdecl, importc: "Mix_GetMusicHookData", #* Add your own callback when a channel has finished playing. NULL # * to disable callback.* type - TChannelFinished* = proc (channel: cint){.cdecl.} + ChannelFinished* = proc (channel: cint){.cdecl.} +{.deprecated: [TChannelFinished: ChannelFinished].} -proc channelFinished*(channelFinished: TChannelFinished){.cdecl, +proc channelFinished*(channelFinished: ChannelFinished){.cdecl, importc: "Mix_ChannelFinished", dynlib: MixerLibName.} const CHANNEL_POST* = - 2 @@ -286,9 +292,9 @@ proc fadeOutGroup*(tag: cint, ms: cint): cint{.cdecl, proc fadeOutMusic*(ms: cint): cint{.cdecl, importc: "Mix_FadeOutMusic", dynlib: MixerLibName.} # Query the fading status of a channel -proc fadingMusic*(): TFading{.cdecl, importc: "Mix_FadingMusic", +proc fadingMusic*(): Fading{.cdecl, importc: "Mix_FadingMusic", dynlib: MixerLibName.} -proc fadingChannel*(which: cint): TFading{.cdecl, +proc fadingChannel*(which: cint): Fading{.cdecl, importc: "Mix_FadingChannel", dynlib: MixerLibName.} # Pause/Resume a particular channel proc pause*(channel: cint){.cdecl, importc: "Mix_Pause", dynlib: MixerLibName.} @@ -335,7 +341,7 @@ proc getChunk*(channel: cint): PChunk{.cdecl, importc: "Mix_GetChunk", proc closeAudio*(){.cdecl, importc: "Mix_CloseAudio", dynlib: MixerLibName.} # We'll use SDL for reporting errors -proc version(x: var Tversion) = +proc version(x: var Version) = x.major = MAJOR_VERSION x.minor = MINOR_VERSION x.patch = PATCHLEVEL diff --git a/lib/wrappers/sdl/sdl_net.nim b/lib/wrappers/sdl/sdl_net.nim index 1ffdb5cca..5bde607f7 100644 --- a/lib/wrappers/sdl/sdl_net.nim +++ b/lib/wrappers/sdl/sdl_net.nim @@ -143,34 +143,34 @@ type # SDL_net.h types #*********************************************************************** #* IPv4 hostname resolution API * #*********************************************************************** - PIPAddress* = ptr TIPAddress - TIPAddress*{.final.} = object #* TCP network API + PIPAddress* = ptr IPAddress + IPAddress*{.final.} = object #* TCP network API host*: uint32 # 32-bit IPv4 host address */ port*: uint16 # 16-bit protocol port */ - PTCPSocket* = ptr TTCPSocket - TTCPSocket*{.final.} = object # UDP network API + PTCPSocket* = ptr TCPSocket + TCPSocket*{.final.} = object # UDP network API ready*: int channel*: int - remoteAddress*: TIPAddress - localAddress*: TIPAddress + remoteAddress*: IPAddress + localAddress*: IPAddress sflag*: int - PUDP_Channel* = ptr TUDP_Channel - TUDP_Channel*{.final.} = object + PUDP_Channel* = ptr UDP_Channel + UDP_Channel*{.final.} = object numbound*: int - address*: array[0..MAX_UDPADDRESSES - 1, TIPAddress] + address*: array[0..MAX_UDPADDRESSES - 1, IPAddress] - PUDPSocket* = ptr TUDPSocket - TUDPSocket*{.final.} = object + PUDPSocket* = ptr UDPSocket + UDPSocket*{.final.} = object ready*: int channel*: int - address*: TIPAddress - binding*: array[0..MAX_UDPCHANNELS - 1, TUDP_Channel] + address*: IPAddress + binding*: array[0..MAX_UDPCHANNELS - 1, UDP_Channel] - PUDPpacket* = ptr TUDPpacket + PUDPpacket* = ptr UDPpacket PPUDPpacket* = ptr PUDPpacket - TUDPpacket*{.final.} = object #*********************************************************************** + UDPpacket*{.final.} = object #*********************************************************************** #* Hooks for checking sockets for available data * #*********************************************************************** channel*: int #* The src/dst channel of the packet * @@ -178,25 +178,27 @@ type # SDL_net.h types length*: int #* The length of the packet data * maxlen*: int #* The size of the data buffer * status*: int #* packet status after sending * - address*: TIPAddress #* The source/dest address of an incoming/outgoing packet * + address*: IPAddress #* The source/dest address of an incoming/outgoing packet * - PSocket* = ptr TSocket - TSocket*{.final.} = object + PSocket* = ptr Socket + Socket*{.final.} = object ready*: int channel*: int - PSocketSet* = ptr TSocketSet - TSocketSet*{.final.} = object # Any network socket can be safely cast to this socket type * + PSocketSet* = ptr SocketSet + SocketSet*{.final.} = object # Any network socket can be safely cast to this socket type * numsockets*: int maxsockets*: int sockets*: PSocket - PGenericSocket* = ptr TGenericSocket - TGenericSocket*{.final.} = object + PGenericSocket* = ptr GenericSocket + GenericSocket*{.final.} = object ready*: int +{.deprecated: [TSocket: Socket, TSocketSet: SocketSet, TIPAddress: IpAddress, + TTCPSocket: TCPSocket, TUDP_Channel: UDP_Channel, TUDPSocket: UDPSocket, + TUDPpacket: UDPpacket, TGenericSocket: GenericSocket].} - -proc version*(x: var Tversion) +proc version*(x: var Version) #* Initialize/Cleanup the network API # SDL must be initialized before calls to functions in this library, # because this library uses utility functions from the SDL library. @@ -209,14 +211,14 @@ proc quit*(){.cdecl, importc: "SDLNet_Quit", dynlib: NetLibName.} # address will be INADDR_NONE, and the function will return -1. # If 'host' is NULL, the resolved host will be set to INADDR_ANY. # * -proc resolveHost*(address: var TIPAddress, host: cstring, port: uint16): int{. +proc resolveHost*(address: var IPAddress, host: cstring, port: uint16): int{. cdecl, importc: "SDLNet_ResolveHost", dynlib: NetLibName.} #* Resolve an ip address to a host name in canonical form. # If the ip couldn't be resolved, this function returns NULL, # otherwise a pointer to a static buffer containing the hostname # is returned. Note that this function is not thread-safe. #* -proc resolveIP*(ip: var TIPAddress): cstring{.cdecl, +proc resolveIP*(ip: var IPAddress): cstring{.cdecl, importc: "SDLNet_ResolveIP", dynlib: NetLibName.} #*********************************************************************** #* TCP network API * @@ -229,7 +231,7 @@ proc resolveIP*(ip: var TIPAddress): cstring{.cdecl, # in the correct form). # The newly created socket is returned, or NULL if there was an error. #* -proc tcpOpen*(ip: var TIPAddress): PTCPSocket{.cdecl, +proc tcpOpen*(ip: var IPAddress): PTCPSocket{.cdecl, importc: "SDLNet_TCP_Open", dynlib: NetLibName.} #* Accept an incoming connection on the given server socket. # The newly created socket is returned, or NULL if there was an error. @@ -295,7 +297,7 @@ proc udpOpen*(port: uint16): PUDPSocket{.cdecl, importc: "SDLNet_UDP_Open", # address, to which all outbound packets on the channel are sent. # This function returns the channel which was bound, or -1 on error. #* -proc udpBind*(sock: PUDPSocket, channel: int, address: var TIPAddress): int{. +proc udpBind*(sock: PUDPSocket, channel: int, address: var IPAddress): int{. cdecl, importc: "SDLNet_UDP_Bind", dynlib: NetLibName.} #* Unbind all addresses from the given channel * proc udpUnbind*(sock: PUDPSocket, channel: int){.cdecl, @@ -405,7 +407,7 @@ proc read16*(area: pointer): uint16{.cdecl, importc: "SDLNet_Read16", proc read32*(area: pointer): uint32{.cdecl, importc: "SDLNet_Read32", dynlib: NetLibName.} -proc version(x: var Tversion) = +proc version(x: var Version) = x.major = MAJOR_VERSION x.minor = MINOR_VERSION x.patch = PATCHLEVEL diff --git a/lib/wrappers/sdl/sdl_ttf.nim b/lib/wrappers/sdl/sdl_ttf.nim index 9ebe70b9d..06604f96e 100644 --- a/lib/wrappers/sdl/sdl_ttf.nim +++ b/lib/wrappers/sdl/sdl_ttf.nim @@ -177,8 +177,9 @@ const UNICODE_BOM_SWAPPED* = 0x0000FFFE type - PFont* = ptr TFont - TFont = object + PFont* = ptr Font + Font = object +{.deprecated: [TFont: Font].} # This macro can be used to fill a version structure with the compile-time @@ -256,9 +257,9 @@ proc sizeUNICODE*(font: PFont, text: PUInt16, w: var cint, y: var cint): cint{. # to the text color. # This function returns the new surface, or NULL if there was an error. # -proc renderUTF8Solid*(font: PFont, text: cstring, fg: TColor): PSurface{. +proc renderUTF8Solid*(font: PFont, text: cstring, fg: Color): PSurface{. cdecl, importc: "TTF_RenderUTF8_Solid", dynlib: ttfLibName.} -proc renderUNICODE_Solid*(font: PFont, text: PUInt16, fg: TColor): PSurface{. +proc renderUNICODE_Solid*(font: PFont, text: PUInt16, fg: Color): PSurface{. cdecl, importc: "TTF_RenderUNICODE_Solid", dynlib: ttfLibName.} # #Create an 8-bit palettized surface and render the given glyph at @@ -268,21 +269,21 @@ proc renderUNICODE_Solid*(font: PFont, text: PUInt16, fg: TColor): PSurface{. # centering in the X direction, and aligned normally in the Y direction. # This function returns the new surface, or NULL if there was an error. # -proc renderGlyphSolid*(font: PFont, ch: uint16, fg: TColor): PSurface{. +proc renderGlyphSolid*(font: PFont, ch: uint16, fg: Color): PSurface{. cdecl, importc: "TTF_RenderGlyph_Solid", dynlib: ttfLibName.} # Create an 8-bit palettized surface and render the given text at # high quality with the given font and colors. The 0 pixel is background, # while other pixels have varying degrees of the foreground color. # This function returns the new surface, or NULL if there was an error. # -proc renderTextShaded*(font: PFont, text: cstring, fg: TColor, - bg: TColor): PSurface{.cdecl, +proc renderTextShaded*(font: PFont, text: cstring, fg: Color, + bg: Color): PSurface{.cdecl, importc: "TTF_RenderText_Shaded", dynlib: ttfLibName.} -proc renderUTF8Shaded*(font: PFont, text: cstring, fg: TColor, - bg: TColor): PSurface{.cdecl, +proc renderUTF8Shaded*(font: PFont, text: cstring, fg: Color, + bg: Color): PSurface{.cdecl, importc: "TTF_RenderUTF8_Shaded", dynlib: ttfLibName.} -proc renderUNICODE_Shaded*(font: PFont, text: PUInt16, fg: TColor, - bg: TColor): PSurface{.cdecl, +proc renderUNICODE_Shaded*(font: PFont, text: PUInt16, fg: Color, + bg: Color): PSurface{.cdecl, importc: "TTF_RenderUNICODE_Shaded", dynlib: ttfLibName.} # Create an 8-bit palettized surface and render the given glyph at # high quality with the given font and colors. The 0 pixel is background, @@ -291,17 +292,17 @@ proc renderUNICODE_Shaded*(font: PFont, text: PUInt16, fg: TColor, # direction, and aligned normally in the Y direction. # This function returns the new surface, or NULL if there was an error. # -proc renderGlyphShaded*(font: PFont, ch: uint16, fg: TColor, bg: TColor): PSurface{. +proc renderGlyphShaded*(font: PFont, ch: uint16, fg: Color, bg: Color): PSurface{. cdecl, importc: "TTF_RenderGlyph_Shaded", dynlib: ttfLibName.} # Create a 32-bit ARGB surface and render the given text at high quality, # using alpha blending to dither the font with the given color. # This function returns the new surface, or NULL if there was an error. # -proc renderTextBlended*(font: PFont, text: cstring, fg: TColor): PSurface{. +proc renderTextBlended*(font: PFont, text: cstring, fg: Color): PSurface{. cdecl, importc: "TTF_RenderText_Blended", dynlib: ttfLibName.} -proc renderUTF8Blended*(font: PFont, text: cstring, fg: TColor): PSurface{. +proc renderUTF8Blended*(font: PFont, text: cstring, fg: Color): PSurface{. cdecl, importc: "TTF_RenderUTF8_Blended", dynlib: ttfLibName.} -proc RenderUNICODE_Blended*(font: PFont, text: PUInt16, fg: TColor): PSurface{. +proc RenderUNICODE_Blended*(font: PFont, text: PUInt16, fg: Color): PSurface{. cdecl, importc: "TTF_RenderUNICODE_Blended", dynlib: ttfLibName.} # Create a 32-bit ARGB surface and render the given glyph at high quality, # using alpha blending to dither the font with the given color. @@ -309,7 +310,7 @@ proc RenderUNICODE_Blended*(font: PFont, text: PUInt16, fg: TColor): PSurface{. # direction, and aligned normally in the Y direction. # This function returns the new surface, or NULL if there was an error. # -proc renderGlyphBlended*(font: PFont, ch: uint16, fg: TColor): PSurface{. +proc renderGlyphBlended*(font: PFont, ch: uint16, fg: Color): PSurface{. cdecl, importc: "TTF_RenderGlyph_Blended", dynlib: ttfLibName.} # For compatibility with previous versions, here are the old functions # #define TTF_RenderText(font, text, fg, bg) @@ -327,11 +328,11 @@ proc quit*(){.cdecl, importc: "TTF_Quit", dynlib: ttfLibName.} proc wasInit*(): cint{.cdecl, importc: "TTF_WasInit", dynlib: ttfLibName.} -proc version*(x: var sdl.Tversion) = +proc version*(x: var sdl.Version) = x.major = MAJOR_VERSION x.minor = MINOR_VERSION x.patch = PATCHLEVEL -proc renderTextSolid*(font: PFont, text: cstring, fg: TColor): PSurface{. +proc renderTextSolid*(font: PFont, text: cstring, fg: Color): PSurface{. cdecl, importc: "TTF_RenderText_Solid", dynlib: ttfLibName.} diff --git a/lib/wrappers/sdl/smpeg.nim b/lib/wrappers/sdl/smpeg.nim index 318c0b3df..57c16fa47 100644 --- a/lib/wrappers/sdl/smpeg.nim +++ b/lib/wrappers/sdl/smpeg.nim @@ -142,22 +142,23 @@ const FILTER_INFO_PIXEL_ERROR* = 2 # Filter info from SMPEG type - TFilterInfo*{.final.} = object + FilterInfo*{.final.} = object yuvMbSquareError*: PUInt16 yuvPixelSquareError*: PUInt16 - PFilterInfo* = ptr TFilterInfo # MPEG filter definition - PFilter* = ptr TFilter # Callback functions for the filter - TFilterCallback* = proc (dest, source: POverlay, region: PRect, + PFilterInfo* = ptr FilterInfo # MPEG filter definition + PFilter* = ptr Filter # Callback functions for the filter + FilterCallback* = proc (dest, source: POverlay, region: PRect, filterInfo: PFilterInfo, data: pointer): pointer{. cdecl.} - TFilterDestroy* = proc (filter: PFilter): pointer{.cdecl.} # The filter definition itself - TFilter*{.final.} = object # The null filter (default). It simply copies the source rectangle to the video overlay. + FilterDestroy* = proc (filter: PFilter): pointer{.cdecl.} # The filter definition itself + Filter*{.final.} = object # The null filter (default). It simply copies the source rectangle to the video overlay. flags*: uint32 data*: pointer - callback*: TFilterCallback - destroy*: TFilterDestroy - + callback*: FilterCallback + destroy*: FilterDestroy +{.deprecated: [TFilterInfo: FilterInfo, TFilterCallback: FilterCallback, + TFilterDestroy: FilterDestroy, TFilter: Filter].} proc filterNull*(): PFilter{.cdecl, importc: "SMPEGfilter_null", dynlib: SmpegLibName.} @@ -184,7 +185,7 @@ type Pversion* = ptr TVersion # This is the actual SMPEG object TSMPEG* = object PSMPEG* = ptr TSMPEG # Used to get information about the SMPEG object - TInfo* = object + Info* = object hasAudio*: int32 hasVideo*: int32 width*: int32 @@ -198,7 +199,8 @@ type currentTime*: float64 totalTime*: float64 - PInfo* = ptr TInfo # Possible MPEG status codes + PInfo* = ptr Info # Possible MPEG status codes +{.deprecated: [TInfo: Info].} const STATUS_ERROR* = - 1 @@ -206,7 +208,7 @@ const STATUS_PLAYING* = 1 type - Tstatus* = int32 + Status* = int32 Pstatus* = ptr int32 # Matches the declaration of SDL_UpdateRect() TDisplayCallback* = proc (dst: PSurface, x, y: int, w, h: int): pointer{. cdecl.} # Create a new SMPEG object from an MPEG file. @@ -217,6 +219,7 @@ type # The sdl_audio parameter indicates if SMPEG should initialize the SDL audio # subsystem. If not, you will have to use the playaudio() function below # to extract the decoded data. +{.deprecated: [Tstatus: Status].} proc new*(theFile: cstring, info: PInfo, audio: int): PSMPEG{.cdecl, importc: "SMPEG_new", dynlib: SmpegLibName.} @@ -243,7 +246,7 @@ proc enablevideo*(mpeg: PSMPEG, enable: int){.cdecl, proc delete*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_delete", dynlib: SmpegLibName.} # Get the current status of an SMPEG object -proc status*(mpeg: PSMPEG): Tstatus{.cdecl, importc: "SMPEG_status", +proc status*(mpeg: PSMPEG): Status{.cdecl, importc: "SMPEG_status", dynlib: SmpegLibName.} # status # Set the audio volume of an MPEG stream, in the range 0-100 diff --git a/lib/wrappers/sphinx.nim b/lib/wrappers/sphinx.nim index e4a282968..d9e98faa8 100644 --- a/lib/wrappers/sphinx.nim +++ b/lib/wrappers/sphinx.nim @@ -96,18 +96,18 @@ const SPH_GROUPBY_ATTRPAIR* = 5 type - TSphinxBool* {.size: sizeof(cint).} = enum + SphinxBool* {.size: sizeof(cint).} = enum SPH_FALSE = 0, SPH_TRUE = 1 - Tclient {.pure, final.} = object - PClient* = ptr TClient - Twordinfo*{.pure, final.} = object + Client {.pure, final.} = object + PClient* = ptr Client + Wordinfo*{.pure, final.} = object word*: cstring docs*: cint hits*: cint - Tresult*{.pure, final.} = object + Result*{.pure, final.} = object error*: cstring warning*: cstring status*: cint @@ -122,9 +122,9 @@ type total_found*: cint time_msec*: cint num_words*: cint - words*: ptr array [0..100_000, TWordinfo] + words*: ptr array [0..100_000, Wordinfo] - Texcerpt_options*{.pure, final.} = object + Excerpt_options*{.pure, final.} = object before_match*: cstring after_match*: cstring chunk_separator*: cstring @@ -135,24 +135,26 @@ type limit_words*: cint around*: cint start_passage_id*: cint - exact_phrase*: TSphinxBool - single_passage*: TSphinxBool - use_boundaries*: TSphinxBool - weight_order*: TSphinxBool - query_mode*: TSphinxBool - force_all_words*: TSphinxBool - load_files*: TSphinxBool - allow_empty*: TSphinxBool - emit_zones*: TSphinxBool + exact_phrase*: SphinxBool + single_passage*: SphinxBool + use_boundaries*: SphinxBool + weight_order*: SphinxBool + query_mode*: SphinxBool + force_all_words*: SphinxBool + load_files*: SphinxBool + allow_empty*: SphinxBool + emit_zones*: SphinxBool - Tkeyword_info*{.pure, final.} = object + Keyword_info*{.pure, final.} = object tokenized*: cstring normalized*: cstring num_docs*: cint num_hits*: cint +{.deprecated: [TSphinxBool: SphinxBool, + Tclient: Client, Twordinfo: Wordinfo, Tresult: Result, + Texcerpt_options: Excerpt_options, Tkeyword_info: Keyword_info].} - -proc create*(copy_args: TSphinxBool): PClient{.cdecl, importc: "sphinx_create", +proc create*(copy_args: SphinxBool): PClient{.cdecl, importc: "sphinx_create", dynlib: sphinxDll.} proc cleanup*(client: PClient){.cdecl, importc: "sphinx_cleanup", dynlib: sphinxDll.} @@ -162,87 +164,87 @@ proc error*(client: PClient): cstring{.cdecl, importc: "sphinx_error", dynlib: sphinxDll.} proc warning*(client: PClient): cstring{.cdecl, importc: "sphinx_warning", dynlib: sphinxDll.} -proc set_server*(client: PClient, host: cstring, port: cint): TSphinxBool{.cdecl, +proc set_server*(client: PClient, host: cstring, port: cint): SphinxBool{.cdecl, importc: "sphinx_set_server", dynlib: sphinxDll.} -proc set_connect_timeout*(client: PClient, seconds: float32): TSphinxBool{.cdecl, +proc set_connect_timeout*(client: PClient, seconds: float32): SphinxBool{.cdecl, importc: "sphinx_set_connect_timeout", dynlib: sphinxDll.} -proc open*(client: PClient): TSphinxBool{.cdecl, importc: "sphinx_open", +proc open*(client: PClient): SphinxBool{.cdecl, importc: "sphinx_open", dynlib: sphinxDll.} -proc close*(client: PClient): TSphinxBool{.cdecl, importc: "sphinx_close", +proc close*(client: PClient): SphinxBool{.cdecl, importc: "sphinx_close", dynlib: sphinxDll.} proc set_limits*(client: PClient, offset: cint, limit: cint, - max_matches: cint, cutoff: cint): TSphinxBool{.cdecl, + max_matches: cint, cutoff: cint): SphinxBool{.cdecl, importc: "sphinx_set_limits", dynlib: sphinxDll.} -proc set_max_query_time*(client: PClient, max_query_time: cint): TSphinxBool{. +proc set_max_query_time*(client: PClient, max_query_time: cint): SphinxBool{. cdecl, importc: "sphinx_set_max_query_time", dynlib: sphinxDll.} -proc set_match_mode*(client: PClient, mode: cint): TSphinxBool{.cdecl, +proc set_match_mode*(client: PClient, mode: cint): SphinxBool{.cdecl, importc: "sphinx_set_match_mode", dynlib: sphinxDll.} -proc set_ranking_mode*(client: PClient, ranker: cint): TSphinxBool{.cdecl, +proc set_ranking_mode*(client: PClient, ranker: cint): SphinxBool{.cdecl, importc: "sphinx_set_ranking_mode", dynlib: sphinxDll.} -proc set_sort_mode*(client: PClient, mode: cint, sortby: cstring): TSphinxBool{. +proc set_sort_mode*(client: PClient, mode: cint, sortby: cstring): SphinxBool{. cdecl, importc: "sphinx_set_sort_mode", dynlib: sphinxDll.} proc set_field_weights*(client: PClient, num_weights: cint, - field_names: cstringArray, field_weights: ptr cint): TSphinxBool{. + field_names: cstringArray, field_weights: ptr cint): SphinxBool{. cdecl, importc: "sphinx_set_field_weights", dynlib: sphinxDll.} proc set_index_weights*(client: PClient, num_weights: cint, - index_names: cstringArray, index_weights: ptr cint): TSphinxBool{. + index_names: cstringArray, index_weights: ptr cint): SphinxBool{. cdecl, importc: "sphinx_set_index_weights", dynlib: sphinxDll.} -proc set_id_range*(client: PClient, minid: int64, maxid: int64): TSphinxBool{. +proc set_id_range*(client: PClient, minid: int64, maxid: int64): SphinxBool{. cdecl, importc: "sphinx_set_id_range", dynlib: sphinxDll.} proc add_filter*(client: PClient, attr: cstring, num_values: cint, - values: ptr int64, exclude: TSphinxBool): TSphinxBool{.cdecl, + values: ptr int64, exclude: SphinxBool): SphinxBool{.cdecl, importc: "sphinx_add_filter", dynlib: sphinxDll.} proc add_filter_range*(client: PClient, attr: cstring, umin: int64, - umax: int64, exclude: TSphinxBool): TSphinxBool{.cdecl, + umax: int64, exclude: SphinxBool): SphinxBool{.cdecl, importc: "sphinx_add_filter_range", dynlib: sphinxDll.} proc add_filter_float_range*(client: PClient, attr: cstring, fmin: float32, - fmax: float32, exclude: TSphinxBool): TSphinxBool{.cdecl, + fmax: float32, exclude: SphinxBool): SphinxBool{.cdecl, importc: "sphinx_add_filter_float_range", dynlib: sphinxDll.} proc set_geoanchor*(client: PClient, attr_latitude: cstring, - attr_longitude: cstring, latitude: float32, longitude: float32): TSphinxBool{. + attr_longitude: cstring, latitude: float32, longitude: float32): SphinxBool{. cdecl, importc: "sphinx_set_geoanchor", dynlib: sphinxDll.} proc set_groupby*(client: PClient, attr: cstring, groupby_func: cint, - group_sort: cstring): TSphinxBool{.cdecl, + group_sort: cstring): SphinxBool{.cdecl, importc: "sphinx_set_groupby", dynlib: sphinxDll.} -proc set_groupby_distinct*(client: PClient, attr: cstring): TSphinxBool{.cdecl, +proc set_groupby_distinct*(client: PClient, attr: cstring): SphinxBool{.cdecl, importc: "sphinx_set_groupby_distinct", dynlib: sphinxDll.} -proc set_retries*(client: PClient, count: cint, delay: cint): TSphinxBool{.cdecl, +proc set_retries*(client: PClient, count: cint, delay: cint): SphinxBool{.cdecl, importc: "sphinx_set_retries", dynlib: sphinxDll.} proc add_override*(client: PClient, attr: cstring, docids: ptr int64, - num_values: cint, values: ptr cint): TSphinxBool{.cdecl, + num_values: cint, values: ptr cint): SphinxBool{.cdecl, importc: "sphinx_add_override", dynlib: sphinxDll.} -proc set_select*(client: PClient, select_list: cstring): TSphinxBool{.cdecl, +proc set_select*(client: PClient, select_list: cstring): SphinxBool{.cdecl, importc: "sphinx_set_select", dynlib: sphinxDll.} proc reset_filters*(client: PClient){.cdecl, importc: "sphinx_reset_filters", dynlib: sphinxDll.} proc reset_groupby*(client: PClient){.cdecl, importc: "sphinx_reset_groupby", dynlib: sphinxDll.} proc query*(client: PClient, query: cstring, index_list: cstring, - comment: cstring): ptr Tresult{.cdecl, importc: "sphinx_query", + comment: cstring): ptr Result{.cdecl, importc: "sphinx_query", dynlib: sphinxDll.} proc add_query*(client: PClient, query: cstring, index_list: cstring, comment: cstring): cint{.cdecl, importc: "sphinx_add_query", dynlib: sphinxDll.} -proc run_queries*(client: PClient): ptr Tresult{.cdecl, +proc run_queries*(client: PClient): ptr Result{.cdecl, importc: "sphinx_run_queries", dynlib: sphinxDll.} proc get_num_results*(client: PClient): cint{.cdecl, importc: "sphinx_get_num_results", dynlib: sphinxDll.} -proc get_id*(result: ptr Tresult, match: cint): int64{.cdecl, +proc get_id*(result: ptr Result, match: cint): int64{.cdecl, importc: "sphinx_get_id", dynlib: sphinxDll.} -proc get_weight*(result: ptr Tresult, match: cint): cint{.cdecl, +proc get_weight*(result: ptr Result, match: cint): cint{.cdecl, importc: "sphinx_get_weight", dynlib: sphinxDll.} -proc get_int*(result: ptr Tresult, match: cint, attr: cint): int64{.cdecl, +proc get_int*(result: ptr Result, match: cint, attr: cint): int64{.cdecl, importc: "sphinx_get_int", dynlib: sphinxDll.} -proc get_float*(result: ptr Tresult, match: cint, attr: cint): float32{.cdecl, +proc get_float*(result: ptr Result, match: cint, attr: cint): float32{.cdecl, importc: "sphinx_get_float", dynlib: sphinxDll.} -proc get_mva*(result: ptr Tresult, match: cint, attr: cint): ptr cint{. +proc get_mva*(result: ptr Result, match: cint, attr: cint): ptr cint{. cdecl, importc: "sphinx_get_mva", dynlib: sphinxDll.} -proc get_string*(result: ptr Tresult, match: cint, attr: cint): cstring{.cdecl, +proc get_string*(result: ptr Result, match: cint, attr: cint): cstring{.cdecl, importc: "sphinx_get_string", dynlib: sphinxDll.} -proc init_excerpt_options*(opts: ptr Texcerpt_options){.cdecl, +proc init_excerpt_options*(opts: ptr Excerpt_options){.cdecl, importc: "sphinx_init_excerpt_options", dynlib: sphinxDll.} proc build_excerpts*(client: PClient, num_docs: cint, docs: cstringArray, - index: cstring, words: cstring, opts: ptr Texcerpt_options): cstringArray{. + index: cstring, words: cstring, opts: ptr Excerpt_options): cstringArray{. cdecl, importc: "sphinx_build_excerpts", dynlib: sphinxDll.} proc update_attributes*(client: PClient, index: cstring, num_attrs: cint, attrs: cstringArray, num_docs: cint, @@ -253,7 +255,7 @@ proc update_attributes_mva*(client: PClient, index: cstring, attr: cstring, values: ptr cint): cint{.cdecl, importc: "sphinx_update_attributes_mva", dynlib: sphinxDll.} proc build_keywords*(client: PClient, query: cstring, index: cstring, - hits: TSphinxBool, out_num_keywords: ptr cint): ptr Tkeyword_info{. + hits: SphinxBool, out_num_keywords: ptr cint): ptr Keyword_info{. cdecl, importc: "sphinx_build_keywords", dynlib: sphinxDll.} proc status*(client: PClient, num_rows: ptr cint, num_cols: ptr cint): cstringArray{. cdecl, importc: "sphinx_status", dynlib: sphinxDll.} diff --git a/lib/wrappers/sqlite3.nim b/lib/wrappers/sqlite3.nim index e3a3fa0b8..8dacb15e7 100644 --- a/lib/wrappers/sqlite3.nim +++ b/lib/wrappers/sqlite3.nim @@ -97,33 +97,39 @@ const SQLITE_TRANSIENT* = cast[pointer](- 1) type - TSqlite3 {.pure, final.} = object - PSqlite3* = ptr TSqlite3 + Sqlite3 {.pure, final.} = object + PSqlite3* = ptr Sqlite3 PPSqlite3* = ptr PSqlite3 - TContext{.pure, final.} = object - Pcontext* = ptr TContext + Context{.pure, final.} = object + Pcontext* = ptr Context Tstmt{.pure, final.} = object Pstmt* = ptr Tstmt - Tvalue{.pure, final.} = object - Pvalue* = ptr Tvalue + Value{.pure, final.} = object + Pvalue* = ptr Value PValueArg* = array[0..127, Pvalue] - Tcallback* = proc (para1: pointer, para2: int32, para3, + Callback* = proc (para1: pointer, para2: int32, para3, para4: cstringArray): int32{.cdecl.} Tbind_destructor_func* = proc (para1: pointer){.cdecl.} - Tcreate_function_step_func* = proc (para1: Pcontext, para2: int32, + Create_function_step_func* = proc (para1: Pcontext, para2: int32, para3: PValueArg){.cdecl.} - Tcreate_function_func_func* = proc (para1: Pcontext, para2: int32, + Create_function_func_func* = proc (para1: Pcontext, para2: int32, para3: PValueArg){.cdecl.} - Tcreate_function_final_func* = proc (para1: Pcontext){.cdecl.} - Tresult_func* = proc (para1: pointer){.cdecl.} - Tcreate_collation_func* = proc (para1: pointer, para2: int32, para3: pointer, + Create_function_final_func* = proc (para1: Pcontext){.cdecl.} + Result_func* = proc (para1: pointer){.cdecl.} + Create_collation_func* = proc (para1: pointer, para2: int32, para3: pointer, para4: int32, para5: pointer): int32{.cdecl.} - Tcollation_needed_func* = proc (para1: pointer, para2: PSqlite3, eTextRep: int32, + Collation_needed_func* = proc (para1: pointer, para2: PSqlite3, eTextRep: int32, para4: cstring){.cdecl.} +{.deprecated: [TSqlite3: Sqlite3, TContext: Context, Tvalue: Value, + Tcallback: Callback, Tcreate_function_step_func: Create_function_step_func, + Tcreate_function_func_func: Create_function_func_func, + Tcreate_function_final_func: Create_function_final_func, + Tresult_func: Result_func, Tcreate_collation_func: Create_collation_func, + Tcollation_needed_func: Collation_needed_func].} proc close*(para1: PSqlite3): int32{.cdecl, dynlib: Lib, importc: "sqlite3_close".} -proc exec*(para1: PSqlite3, sql: cstring, para3: Tcallback, para4: pointer, +proc exec*(para1: PSqlite3, sql: cstring, para3: Callback, para4: pointer, errmsg: var cstring): int32{.cdecl, dynlib: Lib, importc: "sqlite3_exec".} proc last_insert_rowid*(para1: PSqlite3): int64{.cdecl, dynlib: Lib, @@ -261,15 +267,15 @@ proc finalize*(pStmt: Pstmt): int32{.cdecl, dynlib: Lib, proc reset*(pStmt: Pstmt): int32{.cdecl, dynlib: Lib, importc: "sqlite3_reset".} proc create_function*(para1: PSqlite3, zFunctionName: cstring, nArg: int32, eTextRep: int32, para5: pointer, - xFunc: Tcreate_function_func_func, - xStep: Tcreate_function_step_func, - xFinal: Tcreate_function_final_func): int32{.cdecl, + xFunc: Create_function_func_func, + xStep: Create_function_step_func, + xFinal: Create_function_final_func): int32{.cdecl, dynlib: Lib, importc: "sqlite3_create_function".} proc create_function16*(para1: PSqlite3, zFunctionName: pointer, nArg: int32, eTextRep: int32, para5: pointer, - xFunc: Tcreate_function_func_func, - xStep: Tcreate_function_step_func, - xFinal: Tcreate_function_final_func): int32{.cdecl, + xFunc: Create_function_func_func, + xStep: Create_function_step_func, + xFinal: Create_function_final_func): int32{.cdecl, dynlib: Lib, importc: "sqlite3_create_function16".} proc aggregate_count*(para1: Pcontext): int32{.cdecl, dynlib: Lib, importc: "sqlite3_aggregate_count".} @@ -305,7 +311,7 @@ proc set_auxdata*(para1: Pcontext, para2: int32, para3: pointer, para4: proc (para1: pointer){.cdecl.}){.cdecl, dynlib: Lib, importc: "sqlite3_set_auxdata".} proc result_blob*(para1: Pcontext, para2: pointer, para3: int32, - para4: Tresult_func){.cdecl, dynlib: Lib, + para4: Result_func){.cdecl, dynlib: Lib, importc: "sqlite3_result_blob".} proc result_double*(para1: Pcontext, para2: float64){.cdecl, dynlib: Lib, importc: "sqlite3_result_double".} @@ -320,28 +326,28 @@ proc result_int64*(para1: Pcontext, para2: int64){.cdecl, dynlib: Lib, proc result_null*(para1: Pcontext){.cdecl, dynlib: Lib, importc: "sqlite3_result_null".} proc result_text*(para1: Pcontext, para2: cstring, para3: int32, - para4: Tresult_func){.cdecl, dynlib: Lib, + para4: Result_func){.cdecl, dynlib: Lib, importc: "sqlite3_result_text".} proc result_text16*(para1: Pcontext, para2: pointer, para3: int32, - para4: Tresult_func){.cdecl, dynlib: Lib, + para4: Result_func){.cdecl, dynlib: Lib, importc: "sqlite3_result_text16".} proc result_text16le*(para1: Pcontext, para2: pointer, para3: int32, - para4: Tresult_func){.cdecl, dynlib: Lib, + para4: Result_func){.cdecl, dynlib: Lib, importc: "sqlite3_result_text16le".} proc result_text16be*(para1: Pcontext, para2: pointer, para3: int32, - para4: Tresult_func){.cdecl, dynlib: Lib, + para4: Result_func){.cdecl, dynlib: Lib, importc: "sqlite3_result_text16be".} proc result_value*(para1: Pcontext, para2: Pvalue){.cdecl, dynlib: Lib, importc: "sqlite3_result_value".} proc create_collation*(para1: PSqlite3, zName: cstring, eTextRep: int32, - para4: pointer, xCompare: Tcreate_collation_func): int32{. + para4: pointer, xCompare: Create_collation_func): int32{. cdecl, dynlib: Lib, importc: "sqlite3_create_collation".} proc create_collation16*(para1: PSqlite3, zName: cstring, eTextRep: int32, - para4: pointer, xCompare: Tcreate_collation_func): int32{. + para4: pointer, xCompare: Create_collation_func): int32{. cdecl, dynlib: Lib, importc: "sqlite3_create_collation16".} -proc collation_needed*(para1: PSqlite3, para2: pointer, para3: Tcollation_needed_func): int32{. +proc collation_needed*(para1: PSqlite3, para2: pointer, para3: Collation_needed_func): int32{. cdecl, dynlib: Lib, importc: "sqlite3_collation_needed".} -proc collation_needed16*(para1: PSqlite3, para2: pointer, para3: Tcollation_needed_func): int32{. +proc collation_needed16*(para1: PSqlite3, para2: pointer, para3: Collation_needed_func): int32{. cdecl, dynlib: Lib, importc: "sqlite3_collation_needed16".} proc libversion*(): cstring{.cdecl, dynlib: Lib, importc: "sqlite3_libversion".} #Alias for allowing better code portability (win32 is not working with external variables) diff --git a/lib/wrappers/tinyc.nim b/lib/wrappers/tinyc.nim index ac6cb70f1..05c65b12f 100644 --- a/lib/wrappers/tinyc.nim +++ b/lib/wrappers/tinyc.nim @@ -8,10 +8,11 @@ # type - TccState {.pure, final.} = object - PccState* = ptr TccState + CcState {.pure, final.} = object + PccState* = ptr CcState - TErrorFunc* = proc (opaque: pointer, msg: cstring) {.cdecl.} + ErrorFunc* = proc (opaque: pointer, msg: cstring) {.cdecl.} +{.deprecated: [TccState: CcState, TErrorFunc: ErrorFunc].} proc openCCState*(): PccState {.importc: "tcc_new", cdecl.} ## create a new TCC compilation context @@ -22,7 +23,7 @@ proc closeCCState*(s: PccState) {.importc: "tcc_delete", cdecl.} proc enableDebug*(s: PccState) {.importc: "tcc_enable_debug", cdecl.} ## add debug information in the generated code -proc setErrorFunc*(s: PccState, errorOpaque: pointer, errorFun: TErrorFunc) {. +proc setErrorFunc*(s: PccState, errorOpaque: pointer, errorFun: ErrorFunc) {. cdecl, importc: "tcc_set_error_func".} ## set error/warning display callback diff --git a/lib/wrappers/tre.nim b/lib/wrappers/tre.nim index 92cd16333..36bf3cb69 100644 --- a/lib/wrappers/tre.nim +++ b/lib/wrappers/tre.nim @@ -27,16 +27,16 @@ const # structs and enums ourselves. type - TRegoff* = cint - TRegex*{.pure, final.} = object + Regoff* = cint + Regex*{.pure, final.} = object re_nsub*: int ## Number of parenthesized subexpressions. value*: pointer ## For internal use only. - TRegmatch*{.pure, final.} = object - rm_so*: TRegoff - rm_eo*: TRegoff + Regmatch*{.pure, final.} = object + rm_so*: Regoff + rm_eo*: Regoff - TReg_errcode*{.size: 4.} = enum ## POSIX tre_regcomp() return error codes. + Reg_errcode*{.size: 4.} = enum ## POSIX tre_regcomp() return error codes. ## (In the order listed in the standard.) REG_OK = 0, ## No error. REG_NOMATCH, ## No match. @@ -52,6 +52,8 @@ type REG_ERANGE, ## Invalid use of range operator REG_ESPACE, ## Out of memory. REG_BADRPT ## Invalid use of repetition operators. +{.deprecated: [TRegoff: Regoff, TRegex: Regex, TRegmatch: Regmatch, + TReg_errcode: Reg_errcode].} # POSIX tre_regcomp() flags. @@ -88,22 +90,22 @@ const # The POSIX.2 regexp functions -proc regcomp*(preg: var TRegex, regex: cstring, cflags: cint): cint{.cdecl, +proc regcomp*(preg: var Regex, regex: cstring, cflags: cint): cint{.cdecl, importc: "tre_regcomp", dynlib: treDll.} -proc regexec*(preg: var TRegex, string: cstring, nmatch: int, - pmatch: ptr TRegmatch, eflags: cint): cint{.cdecl, +proc regexec*(preg: var Regex, string: cstring, nmatch: int, + pmatch: ptr Regmatch, eflags: cint): cint{.cdecl, importc: "tre_regexec", dynlib: treDll.} -proc regerror*(errcode: cint, preg: var TRegex, errbuf: cstring, +proc regerror*(errcode: cint, preg: var Regex, errbuf: cstring, errbuf_size: int): int{.cdecl, importc: "tre_regerror", dynlib: treDll.} -proc regfree*(preg: var TRegex){.cdecl, importc: "tre_regfree", dynlib: treDll.} +proc regfree*(preg: var Regex){.cdecl, importc: "tre_regfree", dynlib: treDll.} # Versions with a maximum length argument and therefore the capability to # handle null characters in the middle of the strings (not in POSIX.2). -proc regncomp*(preg: var TRegex, regex: cstring, len: int, cflags: cint): cint{. +proc regncomp*(preg: var Regex, regex: cstring, len: int, cflags: cint): cint{. cdecl, importc: "tre_regncomp", dynlib: treDll.} -proc regnexec*(preg: var TRegex, string: cstring, len: int, nmatch: int, - pmatch: ptr TRegmatch, eflags: cint): cint{.cdecl, +proc regnexec*(preg: var Regex, string: cstring, len: int, nmatch: int, + pmatch: ptr Regmatch, eflags: cint): cint{.cdecl, importc: "tre_regnexec", dynlib: treDll.} # Approximate matching parameter struct. @@ -124,7 +126,7 @@ type type TRegamatch*{.pure, final.} = object nmatch*: int ## Length of pmatch[] array. - pmatch*: ptr TRegmatch ## Submatch data. + pmatch*: ptr Regmatch ## Submatch data. cost*: cint ## Cost of the match. num_ins*: cint ## Number of inserts in the match. num_del*: cint ## Number of deletes in the match. @@ -133,10 +135,10 @@ type # Approximate matching functions. -proc regaexec*(preg: var TRegex, string: cstring, match: ptr TRegamatch, +proc regaexec*(preg: var Regex, string: cstring, match: ptr TRegamatch, params: TRegaparams, eflags: cint): cint{.cdecl, importc: "tre_regaexec", dynlib: treDll.} -proc reganexec*(preg: var TRegex, string: cstring, len: int, +proc reganexec*(preg: var Regex, string: cstring, len: int, match: ptr TRegamatch, params: TRegaparams, eflags: cint): cint{. cdecl, importc: "tre_reganexec", dynlib: treDll.} @@ -155,8 +157,8 @@ type context*: pointer -proc reguexec*(preg: var TRegex, string: ptr TStrSource, nmatch: int, - pmatch: ptr TRegmatch, eflags: cint): cint{.cdecl, +proc reguexec*(preg: var Regex, string: ptr TStrSource, nmatch: int, + pmatch: ptr Regmatch, eflags: cint): cint{.cdecl, importc: "tre_reguexec", dynlib: treDll.} proc runtimeVersion*(): cstring{.cdecl, importc: "tre_version", dynlib: treDll.} @@ -177,10 +179,10 @@ const # Returns 1 if the compiled pattern has back references, 0 if not. -proc have_backrefs*(preg: var TRegex): cint{.cdecl, +proc have_backrefs*(preg: var Regex): cint{.cdecl, importc: "tre_have_backrefs", dynlib: treDll.} # Returns 1 if the compiled pattern uses approximate matching features, # 0 if not. -proc have_approx*(preg: var TRegex): cint{.cdecl, importc: "tre_have_approx", +proc have_approx*(preg: var Regex): cint{.cdecl, importc: "tre_have_approx", dynlib: treDll.} diff --git a/lib/wrappers/zip/libzip.nim b/lib/wrappers/zip/libzip.nim index 86670b450..076965d46 100644 --- a/lib/wrappers/zip/libzip.nim +++ b/lib/wrappers/zip/libzip.nim @@ -59,12 +59,12 @@ else: {.pragma: mydll.} type - TZipSourceCmd* = int32 + ZipSourceCmd* = int32 - TZipSourceCallback* = proc (state: pointer, data: pointer, length: int, - cmd: TZipSourceCmd): int {.cdecl.} - PZipStat* = ptr TZipStat - TZipStat* = object ## the 'zip_stat' struct + ZipSourceCallback* = proc (state: pointer, data: pointer, length: int, + cmd: ZipSourceCmd): int {.cdecl.} + PZipStat* = ptr ZipStat + ZipStat* = object ## the 'zip_stat' struct name*: cstring ## name of the file index*: int32 ## index within archive crc*: int32 ## crc of file data @@ -74,14 +74,16 @@ type compMethod*: int16 ## compression method used encryptionMethod*: int16 ## encryption method used - TZip = object - TZipSource = object - TZipFile = object - - PZip* = ptr TZip ## represents a zip archive - PZipFile* = ptr TZipFile ## represents a file within an archive - PZipSource* = ptr TZipSource ## represents a source for an archive + Zip = object + ZipSource = object + ZipFile = object + PZip* = ptr Zip ## represents a zip archive + PZipFile* = ptr ZipFile ## represents a file within an archive + PZipSource* = ptr ZipSource ## represents a source for an archive +{.deprecated: [TZipSourceCmd: ZipSourceCmd, TZipStat: ZipStat, TZip: Zip, + TZipSourceCallback: ZipSourceCallback, TZipSource: ZipSource, + TZipFile: ZipFile].} # flags for zip_name_locate, zip_fopen, zip_stat, ... const @@ -229,7 +231,7 @@ proc zip_source_filep*(para1: PZip, para2: File, para3: int, para4: int): PZipSo cdecl, mydll, importc: "zip_source_filep".} proc zip_source_free*(para1: PZipSource) {.cdecl, mydll, importc: "zip_source_free".} -proc zip_source_function*(para1: PZip, para2: TZipSourceCallback, +proc zip_source_function*(para1: PZip, para2: ZipSourceCallback, para3: pointer): PZipSource {.cdecl, mydll, importc: "zip_source_function".} proc zip_source_zip*(para1: PZip, para2: PZip, para3: int32, para4: int32, diff --git a/lib/wrappers/zip/zlib.nim b/lib/wrappers/zip/zlib.nim index 8bdb47106..6bb582b79 100644 --- a/lib/wrappers/zip/zlib.nim +++ b/lib/wrappers/zip/zlib.nim @@ -17,11 +17,11 @@ type ZOffT* = int32 Pbyte* = cstring Pbytef* = cstring - TAllocfunc* = proc (p: pointer, items: Uint, size: Uint): pointer{.cdecl.} - TFreeFunc* = proc (p: pointer, address: pointer){.cdecl.} - TInternalState*{.final, pure.} = object - PInternalState* = ptr TInternalState - TZStream*{.final, pure.} = object + Allocfunc* = proc (p: pointer, items: Uint, size: Uint): pointer{.cdecl.} + FreeFunc* = proc (p: pointer, address: pointer){.cdecl.} + InternalState*{.final, pure.} = object + PInternalState* = ptr InternalState + ZStream*{.final, pure.} = object nextIn*: Pbytef availIn*: Uint totalIn*: Ulong @@ -30,16 +30,18 @@ type totalOut*: Ulong msg*: Pbytef state*: PInternalState - zalloc*: TAllocfunc - zfree*: TFreeFunc + zalloc*: Allocfunc + zfree*: FreeFunc opaque*: pointer dataType*: int32 adler*: Ulong reserved*: Ulong - TZStreamRec* = TZStream - PZstream* = ptr TZStream + ZStreamRec* = ZStream + PZstream* = ptr ZStream GzFile* = pointer +{.deprecated: [TInternalState: InternalState, TAllocfunc: Allocfunc, + TFreeFunc: FreeFunc, TZStream: ZStream, TZStreamRec: ZStreamRec].} const Z_NO_FLUSH* = 0 @@ -70,29 +72,29 @@ const Z_NULL* = 0 proc zlibVersion*(): cstring{.cdecl, dynlib: libz, importc: "zlibVersion".} -proc deflate*(strm: var TZStream, flush: int32): int32{.cdecl, dynlib: libz, +proc deflate*(strm: var ZStream, flush: int32): int32{.cdecl, dynlib: libz, importc: "deflate".} -proc deflateEnd*(strm: var TZStream): int32{.cdecl, dynlib: libz, +proc deflateEnd*(strm: var ZStream): int32{.cdecl, dynlib: libz, importc: "deflateEnd".} -proc inflate*(strm: var TZStream, flush: int32): int32{.cdecl, dynlib: libz, +proc inflate*(strm: var ZStream, flush: int32): int32{.cdecl, dynlib: libz, importc: "inflate".} -proc inflateEnd*(strm: var TZStream): int32{.cdecl, dynlib: libz, +proc inflateEnd*(strm: var ZStream): int32{.cdecl, dynlib: libz, importc: "inflateEnd".} -proc deflateSetDictionary*(strm: var TZStream, dictionary: Pbytef, +proc deflateSetDictionary*(strm: var ZStream, dictionary: Pbytef, dictLength: Uint): int32{.cdecl, dynlib: libz, importc: "deflateSetDictionary".} -proc deflateCopy*(dest, source: var TZStream): int32{.cdecl, dynlib: libz, +proc deflateCopy*(dest, source: var ZStream): int32{.cdecl, dynlib: libz, importc: "deflateCopy".} -proc deflateReset*(strm: var TZStream): int32{.cdecl, dynlib: libz, +proc deflateReset*(strm: var ZStream): int32{.cdecl, dynlib: libz, importc: "deflateReset".} -proc deflateParams*(strm: var TZStream, level: int32, strategy: int32): int32{. +proc deflateParams*(strm: var ZStream, level: int32, strategy: int32): int32{. cdecl, dynlib: libz, importc: "deflateParams".} -proc inflateSetDictionary*(strm: var TZStream, dictionary: Pbytef, +proc inflateSetDictionary*(strm: var ZStream, dictionary: Pbytef, dictLength: Uint): int32{.cdecl, dynlib: libz, importc: "inflateSetDictionary".} -proc inflateSync*(strm: var TZStream): int32{.cdecl, dynlib: libz, +proc inflateSync*(strm: var ZStream): int32{.cdecl, dynlib: libz, importc: "inflateSync".} -proc inflateReset*(strm: var TZStream): int32{.cdecl, dynlib: libz, +proc inflateReset*(strm: var ZStream): int32{.cdecl, dynlib: libz, importc: "inflateReset".} proc compress*(dest: Pbytef, destLen: Pulongf, source: Pbytef, sourceLen: Ulong): cint{. cdecl, dynlib: libz, importc: "compress".} @@ -137,45 +139,45 @@ proc adler32*(adler: Ulong, buf: Pbytef, length: Uint): Ulong{.cdecl, ## **Warning**: Adler-32 requires at least a few hundred bytes to get rolling. proc crc32*(crc: Ulong, buf: Pbytef, length: Uint): Ulong{.cdecl, dynlib: libz, importc: "crc32".} -proc deflateInitu*(strm: var TZStream, level: int32, version: cstring, +proc deflateInitu*(strm: var ZStream, level: int32, version: cstring, streamSize: int32): int32{.cdecl, dynlib: libz, importc: "deflateInit_".} -proc inflateInitu*(strm: var TZStream, version: cstring, +proc inflateInitu*(strm: var ZStream, version: cstring, streamSize: int32): int32 {. cdecl, dynlib: libz, importc: "inflateInit_".} -proc deflateInit*(strm: var TZStream, level: int32): int32 -proc inflateInit*(strm: var TZStream): int32 -proc deflateInit2u*(strm: var TZStream, level: int32, `method`: int32, +proc deflateInit*(strm: var ZStream, level: int32): int32 +proc inflateInit*(strm: var ZStream): int32 +proc deflateInit2u*(strm: var ZStream, level: int32, `method`: int32, windowBits: int32, memLevel: int32, strategy: int32, version: cstring, streamSize: int32): int32 {.cdecl, dynlib: libz, importc: "deflateInit2_".} -proc inflateInit2u*(strm: var TZStream, windowBits: int32, version: cstring, +proc inflateInit2u*(strm: var ZStream, windowBits: int32, version: cstring, streamSize: int32): int32{.cdecl, dynlib: libz, importc: "inflateInit2_".} -proc deflateInit2*(strm: var TZStream, +proc deflateInit2*(strm: var ZStream, level, `method`, windowBits, memLevel, strategy: int32): int32 -proc inflateInit2*(strm: var TZStream, windowBits: int32): int32 +proc inflateInit2*(strm: var ZStream, windowBits: int32): int32 proc zError*(err: int32): cstring{.cdecl, dynlib: libz, importc: "zError".} proc inflateSyncPoint*(z: PZstream): int32{.cdecl, dynlib: libz, importc: "inflateSyncPoint".} proc getCrcTable*(): pointer{.cdecl, dynlib: libz, importc: "get_crc_table".} -proc deflateInit(strm: var TZStream, level: int32): int32 = - result = deflateInitu(strm, level, zlibVersion(), sizeof(TZStream).cint) +proc deflateInit(strm: var ZStream, level: int32): int32 = + result = deflateInitu(strm, level, zlibVersion(), sizeof(ZStream).cint) -proc inflateInit(strm: var TZStream): int32 = - result = inflateInitu(strm, zlibVersion(), sizeof(TZStream).cint) +proc inflateInit(strm: var ZStream): int32 = + result = inflateInitu(strm, zlibVersion(), sizeof(ZStream).cint) -proc deflateInit2(strm: var TZStream, +proc deflateInit2(strm: var ZStream, level, `method`, windowBits, memLevel, strategy: int32): int32 = result = deflateInit2u(strm, level, `method`, windowBits, memLevel, - strategy, zlibVersion(), sizeof(TZStream).cint) + strategy, zlibVersion(), sizeof(ZStream).cint) -proc inflateInit2(strm: var TZStream, windowBits: int32): int32 = +proc inflateInit2(strm: var ZStream, windowBits: int32): int32 = result = inflateInit2u(strm, windowBits, zlibVersion(), - sizeof(TZStream).cint) + sizeof(ZStream).cint) proc zlibAllocMem*(appData: pointer, items, size: int): pointer {.cdecl.} = result = alloc(items * size) @@ -200,7 +202,7 @@ proc uncompress*(sourceBuf: cstring, sourceLen: int): string = ## concatenated deflated values properly. assert (not sourceBuf.isNil) - var z: TZStream + var z: ZStream # Initialize input. z.nextIn = sourceBuf diff --git a/lib/wrappers/zip/zzip.nim b/lib/wrappers/zip/zzip.nim index 73fd53c34..fab7d55b3 100644 --- a/lib/wrappers/zip/zzip.nim +++ b/lib/wrappers/zip/zzip.nim @@ -27,7 +27,8 @@ else: dllname = "libzzip.so" type - TZZipError* = int32 + TZZipError* = int32 # Name conflict if we drop the `T` + const ZZIP_ERROR* = -4096'i32 ZZIP_NO_ERROR* = 0'i32 # no error, may be used if user sets it. @@ -54,119 +55,122 @@ const ZZIP_THREADED* = 1'i32 shl 19'i32 type - TZZipDir* {.final, pure.} = object - TZZipFile* {.final, pure.} = object - TZZipPluginIO* {.final, pure.} = object + ZZipDir* {.final, pure.} = object + ZZipFile* {.final, pure.} = object + ZZipPluginIO* {.final, pure.} = object - TZZipDirent* {.final, pure.} = object + ZZipDirent* {.final, pure.} = object d_compr*: int32 ## compression method d_csize*: int32 ## compressed size st_size*: int32 ## file size / decompressed size d_name*: cstring ## file name / strdupped name - TZZipStat* = TZZipDirent + ZZipStat* = ZZipDirent +{.deprecated: [TZZipDir: ZzipDir, TZZipFile: ZzipFile, + TZZipPluginIO: ZzipPluginIO, TZZipDirent: ZzipDirent, + TZZipStat: ZZipStat].} proc zzip_strerror*(errcode: int32): cstring {.cdecl, dynlib: dllname, importc: "zzip_strerror".} -proc zzip_strerror_of*(dir: ptr TZZipDir): cstring {.cdecl, dynlib: dllname, +proc zzip_strerror_of*(dir: ptr ZZipDir): cstring {.cdecl, dynlib: dllname, importc: "zzip_strerror_of".} proc zzip_errno*(errcode: int32): int32 {.cdecl, dynlib: dllname, importc: "zzip_errno".} -proc zzip_geterror*(dir: ptr TZZipDir): int32 {.cdecl, dynlib: dllname, +proc zzip_geterror*(dir: ptr ZZipDir): int32 {.cdecl, dynlib: dllname, importc: "zzip_error".} -proc zzip_seterror*(dir: ptr TZZipDir, errcode: int32) {.cdecl, dynlib: dllname, +proc zzip_seterror*(dir: ptr ZZipDir, errcode: int32) {.cdecl, dynlib: dllname, importc: "zzip_seterror".} proc zzip_compr_str*(compr: int32): cstring {.cdecl, dynlib: dllname, importc: "zzip_compr_str".} -proc zzip_dirhandle*(fp: ptr TZZipFile): ptr TZZipDir {.cdecl, dynlib: dllname, +proc zzip_dirhandle*(fp: ptr ZZipFile): ptr ZZipDir {.cdecl, dynlib: dllname, importc: "zzip_dirhandle".} -proc zzip_dirfd*(dir: ptr TZZipDir): int32 {.cdecl, dynlib: dllname, +proc zzip_dirfd*(dir: ptr ZZipDir): int32 {.cdecl, dynlib: dllname, importc: "zzip_dirfd".} -proc zzip_dir_real*(dir: ptr TZZipDir): int32 {.cdecl, dynlib: dllname, +proc zzip_dir_real*(dir: ptr ZZipDir): int32 {.cdecl, dynlib: dllname, importc: "zzip_dir_real".} -proc zzip_file_real*(fp: ptr TZZipFile): int32 {.cdecl, dynlib: dllname, +proc zzip_file_real*(fp: ptr ZZipFile): int32 {.cdecl, dynlib: dllname, importc: "zzip_file_real".} -proc zzip_realdir*(dir: ptr TZZipDir): pointer {.cdecl, dynlib: dllname, +proc zzip_realdir*(dir: ptr ZZipDir): pointer {.cdecl, dynlib: dllname, importc: "zzip_realdir".} -proc zzip_realfd*(fp: ptr TZZipFile): int32 {.cdecl, dynlib: dllname, +proc zzip_realfd*(fp: ptr ZZipFile): int32 {.cdecl, dynlib: dllname, importc: "zzip_realfd".} -proc zzip_dir_alloc*(fileext: cstringArray): ptr TZZipDir {.cdecl, +proc zzip_dir_alloc*(fileext: cstringArray): ptr ZZipDir {.cdecl, dynlib: dllname, importc: "zzip_dir_alloc".} -proc zzip_dir_free*(para1: ptr TZZipDir): int32 {.cdecl, dynlib: dllname, +proc zzip_dir_free*(para1: ptr ZZipDir): int32 {.cdecl, dynlib: dllname, importc: "zzip_dir_free".} -proc zzip_dir_fdopen*(fd: int32, errcode_p: ptr TZZipError): ptr TZZipDir {.cdecl, +proc zzip_dir_fdopen*(fd: int32, errcode_p: ptr TZZipError): ptr ZZipDir {.cdecl, dynlib: dllname, importc: "zzip_dir_fdopen".} -proc zzip_dir_open*(filename: cstring, errcode_p: ptr TZZipError): ptr TZZipDir {. +proc zzip_dir_open*(filename: cstring, errcode_p: ptr TZZipError): ptr ZZipDir {. cdecl, dynlib: dllname, importc: "zzip_dir_open".} -proc zzip_dir_close*(dir: ptr TZZipDir) {.cdecl, dynlib: dllname, +proc zzip_dir_close*(dir: ptr ZZipDir) {.cdecl, dynlib: dllname, importc: "zzip_dir_close".} -proc zzip_dir_read*(dir: ptr TZZipDir, dirent: ptr TZZipDirent): int32 {.cdecl, +proc zzip_dir_read*(dir: ptr ZZipDir, dirent: ptr ZZipDirent): int32 {.cdecl, dynlib: dllname, importc: "zzip_dir_read".} -proc zzip_opendir*(filename: cstring): ptr TZZipDir {.cdecl, dynlib: dllname, +proc zzip_opendir*(filename: cstring): ptr ZZipDir {.cdecl, dynlib: dllname, importc: "zzip_opendir".} -proc zzip_closedir*(dir: ptr TZZipDir) {.cdecl, dynlib: dllname, +proc zzip_closedir*(dir: ptr ZZipDir) {.cdecl, dynlib: dllname, importc: "zzip_closedir".} -proc zzip_readdir*(dir: ptr TZZipDir): ptr TZZipDirent {.cdecl, dynlib: dllname, +proc zzip_readdir*(dir: ptr ZZipDir): ptr ZZipDirent {.cdecl, dynlib: dllname, importc: "zzip_readdir".} -proc zzip_rewinddir*(dir: ptr TZZipDir) {.cdecl, dynlib: dllname, +proc zzip_rewinddir*(dir: ptr ZZipDir) {.cdecl, dynlib: dllname, importc: "zzip_rewinddir".} -proc zzip_telldir*(dir: ptr TZZipDir): int {.cdecl, dynlib: dllname, +proc zzip_telldir*(dir: ptr ZZipDir): int {.cdecl, dynlib: dllname, importc: "zzip_telldir".} -proc zzip_seekdir*(dir: ptr TZZipDir, offset: int) {.cdecl, dynlib: dllname, +proc zzip_seekdir*(dir: ptr ZZipDir, offset: int) {.cdecl, dynlib: dllname, importc: "zzip_seekdir".} -proc zzip_file_open*(dir: ptr TZZipDir, name: cstring, flags: int32): ptr TZZipFile {. +proc zzip_file_open*(dir: ptr ZZipDir, name: cstring, flags: int32): ptr ZZipFile {. cdecl, dynlib: dllname, importc: "zzip_file_open".} -proc zzip_file_close*(fp: ptr TZZipFile) {.cdecl, dynlib: dllname, +proc zzip_file_close*(fp: ptr ZZipFile) {.cdecl, dynlib: dllname, importc: "zzip_file_close".} -proc zzip_file_read*(fp: ptr TZZipFile, buf: pointer, length: int): int {. +proc zzip_file_read*(fp: ptr ZZipFile, buf: pointer, length: int): int {. cdecl, dynlib: dllname, importc: "zzip_file_read".} -proc zzip_open*(name: cstring, flags: int32): ptr TZZipFile {.cdecl, +proc zzip_open*(name: cstring, flags: int32): ptr ZZipFile {.cdecl, dynlib: dllname, importc: "zzip_open".} -proc zzip_close*(fp: ptr TZZipFile) {.cdecl, dynlib: dllname, +proc zzip_close*(fp: ptr ZZipFile) {.cdecl, dynlib: dllname, importc: "zzip_close".} -proc zzip_read*(fp: ptr TZZipFile, buf: pointer, length: int): int {. +proc zzip_read*(fp: ptr ZZipFile, buf: pointer, length: int): int {. cdecl, dynlib: dllname, importc: "zzip_read".} -proc zzip_freopen*(name: cstring, mode: cstring, para3: ptr TZZipFile): ptr TZZipFile {. +proc zzip_freopen*(name: cstring, mode: cstring, para3: ptr ZZipFile): ptr ZZipFile {. cdecl, dynlib: dllname, importc: "zzip_freopen".} -proc zzip_fopen*(name: cstring, mode: cstring): ptr TZZipFile {.cdecl, +proc zzip_fopen*(name: cstring, mode: cstring): ptr ZZipFile {.cdecl, dynlib: dllname, importc: "zzip_fopen".} proc zzip_fread*(p: pointer, size: int, nmemb: int, - file: ptr TZZipFile): int {.cdecl, dynlib: dllname, + file: ptr ZZipFile): int {.cdecl, dynlib: dllname, importc: "zzip_fread".} -proc zzip_fclose*(fp: ptr TZZipFile) {.cdecl, dynlib: dllname, +proc zzip_fclose*(fp: ptr ZZipFile) {.cdecl, dynlib: dllname, importc: "zzip_fclose".} -proc zzip_rewind*(fp: ptr TZZipFile): int32 {.cdecl, dynlib: dllname, +proc zzip_rewind*(fp: ptr ZZipFile): int32 {.cdecl, dynlib: dllname, importc: "zzip_rewind".} -proc zzip_seek*(fp: ptr TZZipFile, offset: int, whence: int32): int {. +proc zzip_seek*(fp: ptr ZZipFile, offset: int, whence: int32): int {. cdecl, dynlib: dllname, importc: "zzip_seek".} -proc zzip_tell*(fp: ptr TZZipFile): int {.cdecl, dynlib: dllname, +proc zzip_tell*(fp: ptr ZZipFile): int {.cdecl, dynlib: dllname, importc: "zzip_tell".} -proc zzip_dir_stat*(dir: ptr TZZipDir, name: cstring, zs: ptr TZZipStat, +proc zzip_dir_stat*(dir: ptr ZZipDir, name: cstring, zs: ptr ZZipStat, flags: int32): int32 {.cdecl, dynlib: dllname, importc: "zzip_dir_stat".} -proc zzip_file_stat*(fp: ptr TZZipFile, zs: ptr TZZipStat): int32 {.cdecl, +proc zzip_file_stat*(fp: ptr ZZipFile, zs: ptr ZZipStat): int32 {.cdecl, dynlib: dllname, importc: "zzip_file_stat".} -proc zzip_fstat*(fp: ptr TZZipFile, zs: ptr TZZipStat): int32 {.cdecl, dynlib: dllname, +proc zzip_fstat*(fp: ptr ZZipFile, zs: ptr ZZipStat): int32 {.cdecl, dynlib: dllname, importc: "zzip_fstat".} -proc zzip_open_shared_io*(stream: ptr TZZipFile, name: cstring, +proc zzip_open_shared_io*(stream: ptr ZZipFile, name: cstring, o_flags: int32, o_modes: int32, ext: cstringArray, - io: ptr TZZipPluginIO): ptr TZZipFile {.cdecl, + io: ptr ZZipPluginIO): ptr ZZipFile {.cdecl, dynlib: dllname, importc: "zzip_open_shared_io".} proc zzip_open_ext_io*(name: cstring, o_flags: int32, o_modes: int32, - ext: cstringArray, io: ptr TZZipPluginIO): ptr TZZipFile {. + ext: cstringArray, io: ptr ZZipPluginIO): ptr ZZipFile {. cdecl, dynlib: dllname, importc: "zzip_open_ext_io".} proc zzip_opendir_ext_io*(name: cstring, o_modes: int32, - ext: cstringArray, io: ptr TZZipPluginIO): ptr TZZipDir {. + ext: cstringArray, io: ptr ZZipPluginIO): ptr ZZipDir {. cdecl, dynlib: dllname, importc: "zzip_opendir_ext_io".} proc zzip_dir_open_ext_io*(filename: cstring, errcode_p: ptr TZZipError, - ext: cstringArray, io: ptr TZZipPluginIO): ptr TZZipDir {. + ext: cstringArray, io: ptr ZZipPluginIO): ptr ZZipDir {. cdecl, dynlib: dllname, importc: "zzip_dir_open_ext_io".} diff --git a/tests/collections/tcounttable.nim b/tests/collections/tcounttable.nim new file mode 100644 index 000000000..ebbb1c8e5 --- /dev/null +++ b/tests/collections/tcounttable.nim @@ -0,0 +1,19 @@ +discard """ + output: "And we get here" +""" + +# bug #2625 + +const s_len = 32 + +import tables +var substr_counts: CountTable[string] = initCountTable[string]() +var my_string = "Hello, this is sadly broken for strings over 64 characters. Note that it *does* appear to work for short strings." +for i in 0..(my_string.len - s_len): + let s = my_string[i..i+s_len-1] + substr_counts[s] = 1 + # substr_counts[s] = substr_counts[s] + 1 # Also breaks, + 2 as well, etc. + # substr_counts.inc(s) # This works + #echo "Iteration ", i + +echo "And we get here" diff --git a/tests/collections/tsets.nim b/tests/collections/tsets.nim index 656c5b3f2..a5bbe8dbd 100644 --- a/tests/collections/tsets.nim +++ b/tests/collections/tsets.nim @@ -1,17 +1,37 @@ -discard """ - output: '''true -true''' -""" - import sets -var - a = initSet[int]() - b = initSet[int]() - c = initSet[string]() -for i in 0..5: a.incl(i) -for i in 1..6: b.incl(i) -for i in 0..5: c.incl($i) +block setEquality: + var + a = initSet[int]() + b = initSet[int]() + c = initSet[string]() + + for i in 0..5: a.incl(i) + for i in 1..6: b.incl(i) + for i in 0..5: c.incl($i) + + doAssert map(a, proc(x: int): int = x + 1) == b + doAssert map(a, proc(x: int): string = $x) == c + + +block setsContainingTuples: + var set = initSet[tuple[i: int, i64: int64, f: float]]() + set.incl( (i: 123, i64: 123'i64, f: 3.14) ) + doAssert set.contains( (i: 123, i64: 123'i64, f: 3.14) ) + doAssert( not set.contains( (i: 456, i64: 789'i64, f: 2.78) ) ) + + +block setWithTuplesWithSeqs: + var s = initSet[tuple[s: seq[int]]]() + s.incl( (s: @[1, 2, 3]) ) + doAssert s.contains( (s: @[1, 2, 3]) ) + doAssert( not s.contains((s: @[4, 5, 6])) ) + + +block setWithSequences: + var s = initSet[seq[int]]() + s.incl( @[1, 2, 3] ) + doAssert s.contains(@[1, 2, 3]) + doAssert( not s.contains(@[4, 5, 6]) ) + -echo map(a, proc(x: int): int = x + 1) == b -echo map(a, proc(x: int): string = $x) == c diff --git a/tests/collections/ttables.nim b/tests/collections/ttables.nim index 3a923610e..a10606843 100644 --- a/tests/collections/ttables.nim +++ b/tests/collections/ttables.nim @@ -22,15 +22,15 @@ const "---00": 346677844, "0": 34404, "1": 344004, - "10": 34484, + "10": 34484, "11": 34474, "12": 789, "19": 34464, - "2": 344774, "20": 34454, + "2": 344774, "20": 34454, "3": 342244, "30": 34141244, "34": 123456, "4": 3412344, "40": 344114, - "5": 341232144, "50": 344490, + "5": 341232144, "50": 344490, "6": 34214544, "60": 344491, "7": 3434544, "70": 344492, "8": 344544, "80": 344497, @@ -46,7 +46,7 @@ block tableTest1: for x in 0..1: for y in 0..1: assert t[(x,y)] == $x & $y - assert($t == + assert($t == "{(x: 0, y: 1): 01, (x: 0, y: 0): 00, (x: 1, y: 0): 10, (x: 1, y: 1): 11}") block tableTest2: @@ -55,14 +55,16 @@ block tableTest2: t["111"] = 1.000043 t["123"] = 1.23 t.del("111") - + t["012"] = 67.9 t["123"] = 1.5 # test overwriting - + assert t["123"] == 1.5 assert t["111"] == 0.0 # deleted assert(not hasKey(t, "111")) - + assert "123" in t + assert("111" notin t) + for key, val in items(data): t[key] = val.toFloat for key, val in items(data): assert t[key] == val.toFloat diff --git a/tests/collections/ttablesref.nim b/tests/collections/ttablesref.nim index 16b0d831e..0b641ebc7 100644 --- a/tests/collections/ttablesref.nim +++ b/tests/collections/ttablesref.nim @@ -22,15 +22,15 @@ const "---00": 346677844, "0": 34404, "1": 344004, - "10": 34484, + "10": 34484, "11": 34474, "12": 789, "19": 34464, - "2": 344774, "20": 34454, + "2": 344774, "20": 34454, "3": 342244, "30": 34141244, "34": 123456, "4": 3412344, "40": 344114, - "5": 341232144, "50": 344490, + "5": 341232144, "50": 344490, "6": 34214544, "60": 344491, "7": 3434544, "70": 344492, "8": 344544, "80": 344497, @@ -46,7 +46,7 @@ block tableTest1: for x in 0..1: for y in 0..1: assert t[(x,y)] == $x & $y - assert($t == + assert($t == "{(x: 0, y: 1): 01, (x: 0, y: 0): 00, (x: 1, y: 0): 10, (x: 1, y: 1): 11}") block tableTest2: @@ -55,17 +55,19 @@ block tableTest2: t["111"] = 1.000043 t["123"] = 1.23 t.del("111") - + t["012"] = 67.9 t["123"] = 1.5 # test overwriting - + assert t["123"] == 1.5 assert t["111"] == 0.0 # deleted + assert "123" in t assert(not hasKey(t, "111")) - + assert "111" notin t + for key, val in items(data): t[key] = val.toFloat for key, val in items(data): assert t[key] == val.toFloat - + block orderedTableTest1: var t = newOrderedTable[string, int](2) diff --git a/tests/distinct/tdistinct_consts.nim b/tests/distinct/tdistinct_consts.nim new file mode 100644 index 000000000..4f6ced2d2 --- /dev/null +++ b/tests/distinct/tdistinct_consts.nim @@ -0,0 +1,20 @@ + +# bug #2641 + +type MyChar = distinct char +const c:MyChar = MyChar('a') + +type MyBool = distinct bool +const b:MyBool = MyBool(true) + +type MyBoolSet = distinct set[bool] +const bs:MyBoolSet = MyBoolSet({true}) + +type MyCharSet= distinct set[char] +const cs:MyCharSet = MyCharSet({'a'}) + +type MyBoolSeq = distinct seq[bool] +const bseq:MyBoolSeq = MyBoolSeq(@[true, false]) + +type MyBoolArr = distinct array[3, bool] +const barr:MyBoolArr = MyBoolArr([true, false, true]) diff --git a/tests/enum/tenumitems.nim b/tests/enum/tenumitems.nim index 04737fa9e..38233aad7 100644 --- a/tests/enum/tenumitems.nim +++ b/tests/enum/tenumitems.nim @@ -1,6 +1,6 @@ discard """ line: 7 - errormsg: "undeclared identifier: 'items'" + errormsg: "attempting to call undeclared routine: 'items'" """ type a = enum b,c,d diff --git a/tests/js/taddr.nim b/tests/js/taddr.nim index 6a60aa902..f9c89fbc3 100644 --- a/tests/js/taddr.nim +++ b/tests/js/taddr.nim @@ -1,3 +1,7 @@ +discard """ + action: run +""" + type T = object x: int s: string @@ -29,8 +33,10 @@ doAssert objDeref.x == 42 obj.s = "lorem ipsum dolor sit amet" var indexAddr = addr(obj.s[2]) -doAssert indexAddr[] == '4' +doAssert indexAddr[] == 'r' indexAddr[] = 'd' doAssert indexAddr[] == 'd' + +doAssert obj.s == "lodem ipsum dolor sit amet" diff --git a/tests/js/testmagic.nim b/tests/js/testmagic.nim index 5f793ae05..8e06f1a9b 100644 --- a/tests/js/testmagic.nim +++ b/tests/js/testmagic.nim @@ -1,5 +1,7 @@ discard """ - output: '''true''' + output: '''true +123 +''' """ # This file tests some magic @@ -7,3 +9,4 @@ discard """ var foo = cstring("foo") var bar = cstring("foo") echo(foo == bar) +echo "01234"[1 .. ^2] diff --git a/tests/js/testobjs.nim b/tests/js/testobjs.nim index 4fb9a83dc..0166c0f38 100644 --- a/tests/js/testobjs.nim +++ b/tests/js/testobjs.nim @@ -1,3 +1,7 @@ +discard """ + action: run +""" + ## Tests javascript object generation type @@ -28,7 +32,7 @@ var recurse1 = Recurse[int](data: 1, next: recurse2) -assert(test.name == "Jorden") -assert(knight.age == 19) -assert(knight.item.price == 50) -assert(recurse1.next.next.data == 3) +doAssert test.name == "Jorden" +doAssert knight.age == 19 +doAssert knight.item.price == 50 +doAssert recurse1.next.next.data == 3 diff --git a/tests/js/tobjfieldbyvar.nim b/tests/js/tobjfieldbyvar.nim new file mode 100644 index 000000000..91a3c1315 --- /dev/null +++ b/tests/js/tobjfieldbyvar.nim @@ -0,0 +1,20 @@ +discard """ + output: '''5 +''' +""" + +# bug #2798 + +type Inner = object + value: int + +type Outer = object + i: Inner + +proc test(i: var Inner) = + i.value += 5 + +var o: Outer +test(o.i) + +echo o.i.value diff --git a/tests/js/trefbyvar.nim b/tests/js/trefbyvar.nim new file mode 100644 index 000000000..68dd36543 --- /dev/null +++ b/tests/js/trefbyvar.nim @@ -0,0 +1,35 @@ +discard """ + output: '''0 +5 +0 +5''' +""" + +# bug #2476 + +type A = ref object + m: int + +proc f(a: var A) = + var b: A + b.new() + b.m = 5 + a = b + +var t: A +t.new() + +echo t.m +t.f() +echo t.m + +proc main = + # now test the same for locals + var t: A + t.new() + + echo t.m + t.f() + echo t.m + +main() diff --git a/tests/js/tunittests.nim b/tests/js/tunittests.nim index 8a264a5e0..4b09c99a9 100644 --- a/tests/js/tunittests.nim +++ b/tests/js/tunittests.nim @@ -1,10 +1,7 @@ discard """ - disabled: "true" + output: '''[OK] >:)''' """ -# Unittest uses lambdalifting at compile-time which we disable for the JS -# codegen! So this cannot and will not work for quite some time. - import unittest suite "Bacon": diff --git a/tests/macros/tgettype.nim b/tests/macros/tgettype.nim new file mode 100644 index 000000000..0eab6c0a0 --- /dev/null +++ b/tests/macros/tgettype.nim @@ -0,0 +1,20 @@ +discard """ +msg: '''ObjectTy(Sym(Model), RecList(Sym(name), Sym(password))) +BracketExpr(Sym(typeDesc), Sym(User))''' +""" +import strutils, macros + +type + Model = object of RootObj + User = object of Model + name : string + password : string + +macro testUser: expr = + return newLit(User.getType.lispRepr) + +macro testGeneric(T: typedesc[Model]): expr = + return newLit(T.getType.lispRepr) + +echo testUser +echo User.testGeneric diff --git a/tests/manyloc/standalone/panicoverride.nim b/tests/manyloc/standalone/panicoverride.nim index efd2b21f9..d9b3f4388 100644 --- a/tests/manyloc/standalone/panicoverride.nim +++ b/tests/manyloc/standalone/panicoverride.nim @@ -7,13 +7,13 @@ proc exit(code: int) {.importc, header: "<stdlib.h>", cdecl.} proc rawoutput(s: string) = printf("%s\n", s) -proc panic(s: string) = +proc panic(s: string) {.noreturn.} = rawoutput(s) exit(1) # Alternatively we also could implement these 2 here: # -# template sysFatal(exceptn: typeDesc, message: string) -# template sysFatal(exceptn: typeDesc, message, arg: string) +# proc sysFatal(exceptn: typeDesc, message: string) {.noReturn.} +# proc sysFatal(exceptn: typeDesc, message, arg: string) {.noReturn.} {.pop.} diff --git a/tests/metatype/ttypedesc3.nim b/tests/metatype/ttypedesc3.nim new file mode 100644 index 000000000..3d40b25b2 --- /dev/null +++ b/tests/metatype/ttypedesc3.nim @@ -0,0 +1,19 @@ +import typetraits + +type + Base = object of RootObj + Child = object of Base + +proc pr(T: typedesc[Base]) = echo "proc " & T.name +method me(T: typedesc[Base]) = echo "method " & T.name +iterator it(T: typedesc[Base]) = yield "yield " & T.name + +Base.pr +Child.pr + +Base.me +when false: + Child.me #<- bug #2710 + +for s in Base.it: echo s +for s in Child.it: echo s #<- bug #2662 diff --git a/tests/misc/tissue710.nim b/tests/misc/tissue710.nim index ecfdf653e..3b6d3e5f3 100644 --- a/tests/misc/tissue710.nim +++ b/tests/misc/tissue710.nim @@ -1,7 +1,7 @@ discard """ file: "tissue710.nim" line: 8 - errorMsg: "undeclared identifier: '||'" + errorMsg: "attempting to call undeclared routine: '||'" """ var sum = 0 for x in 3..1000: diff --git a/tests/misc/tnoop.nim b/tests/misc/tnoop.nim index 10c2eb2ec..1e3fbe6cf 100644 --- a/tests/misc/tnoop.nim +++ b/tests/misc/tnoop.nim @@ -1,7 +1,7 @@ discard """ file: "tnoop.nim" line: 11 - errormsg: "undeclared identifier: 'a'" + errormsg: "attempting to call undeclared routine: 'a'" """ diff --git a/tests/modules/topaque.nim b/tests/modules/topaque.nim index f0587c959..84e2388bc 100644 --- a/tests/modules/topaque.nim +++ b/tests/modules/topaque.nim @@ -1,16 +1,16 @@ discard """ file: "topaque.nim" line: 16 - errormsg: "undeclared identifier: \'buffer\'" + errormsg: "undeclared field: \'buffer\'" """ # Test the new opaque types -import +import mopaque - + var L: TLexer - + L.filename = "ha" L.line = 34 L.buffer[0] = '\0' #ERROR_MSG undeclared field: 'buffer' diff --git a/tests/parallel/tptr_to_ref.nim b/tests/parallel/tptr_to_ref.nim new file mode 100644 index 000000000..66d618481 --- /dev/null +++ b/tests/parallel/tptr_to_ref.nim @@ -0,0 +1,26 @@ +# bug #2854 + +import locks, threadpool, osproc + +const MAX_WORKERS = 10 + +type + Killer = object + lock: Lock + bailed {.guard: lock.}: bool + processes {.guard: lock.}: array[0..MAX_WORKERS-1, foreign ptr Process] + +template hold(lock: Lock, body: stmt) = + lock.acquire + defer: lock.release + {.locks: [lock].}: + body + +proc initKiller*(): Killer = + initLock(result.lock) + result.lock.hold: + result.bailed = false + for i, _ in result.processes: + result.processes[i] = nil + +var killer = initKiller() diff --git a/tests/readme.txt b/tests/readme.txt index 0d33a81c7..2cfc79f9a 100644 --- a/tests/readme.txt +++ b/tests/readme.txt @@ -3,8 +3,11 @@ Each test must have a filename of the form: ``t*.nim`` Each test can contain a spec in a ``discard """"""`` block. -The folder ``rodfiles`` contains special tests that test incremental +The folder ``rodfiles`` contains special tests that test incremental compilation via symbol files. The folder ``dll`` contains simple DLL tests. +The folder ``realtimeGC`` contains a test for validating that the realtime GC +can run properly without linking against the nimrtl.dll/so. It includes a C +client and platform specific build files for manual compilation. diff --git a/tests/realtimeGC/cmain.c b/tests/realtimeGC/cmain.c new file mode 100644 index 000000000..e9a46d7ce --- /dev/null +++ b/tests/realtimeGC/cmain.c @@ -0,0 +1,67 @@ + +#ifdef WIN +#include <windows.h> +#else +#include <dlfcn.h> +#endif +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <assert.h> +#include <time.h> + +#define RUNTIME (15*60) + + +typedef void (*pFunc)(void); + +int main(int argc, char* argv[]) +{ + int i; + void* hndl; + pFunc status; + pFunc count; + pFunc checkOccupiedMem; + +#ifdef WIN + hndl = (void*) LoadLibrary((char const*)"./tests/realtimeGC/shared.dll"); + status = (pFunc)GetProcAddress((HMODULE) hndl, (char const*)"status"); + count = (pFunc)GetProcAddress((HMODULE) hndl, (char const*)"count"); + checkOccupiedMem = (pFunc)GetProcAddress((HMODULE) hndl, (char const*)"checkOccupiedMem"); +#else /* OSX || NIX */ + hndl = (void*) dlopen((char const*)"./tests/realtimeGC/libshared.so", RTLD_LAZY); + status = (pFunc) dlsym(hndl, (char const*)"status"); + count = (pFunc) dlsym(hndl, (char const*)"count"); + checkOccupiedMem = (pFunc) dlsym(hndl, (char const*)"checkOccupiedMem"); +#endif + + assert(hndl); + assert(status); + assert(count); + assert(checkOccupiedMem); + + time_t startTime = time((time_t*)0); + time_t runTime = (time_t)(RUNTIME); + time_t accumTime = 0; + while (accumTime < runTime) { + for (i = 0; i < 10; i++) + count(); + /* printf("1. sleeping...\n"); */ + sleep(1); + for (i = 0; i < 10; i++) + status(); + /* printf("2. sleeping...\n"); */ + sleep(1); + checkOccupiedMem(); + accumTime = time((time_t*)0) - startTime; + /* printf("--- Minutes left to run: %d\n", (int)(runTime-accumTime)/60); */ + } + printf("Cleaning up the shared object pointer...\n"); +#ifdef WIN + FreeLibrary((HMODULE)hndl); +#else /* OSX || NIX */ + dlclose(hndl); +#endif + printf("Done\n"); + return 0; +} diff --git a/tests/realtimeGC/main.nim.cfg b/tests/realtimeGC/main.nim.cfg new file mode 100644 index 000000000..fed4fa471 --- /dev/null +++ b/tests/realtimeGC/main.nim.cfg @@ -0,0 +1,6 @@ + +--app:console +--threads:on + +-d:release +-d:useRealtimeGC diff --git a/tests/realtimeGC/nmain.nim b/tests/realtimeGC/nmain.nim new file mode 100644 index 000000000..c9f558dbc --- /dev/null +++ b/tests/realtimeGC/nmain.nim @@ -0,0 +1,46 @@ +discard """ + cmd: "nim $target --debuginfo $options $file" + output: "Done" +""" + +import times, os, threadpool + +const RUNTIME = 15 * 60 # 15 minutes + +when defined(windows): + const dllname = "./tests/realtimeGC/shared.dll" +elif defined(macosx): + const dllname = "./tests/realtimeGC/libshared.dylib" +else: + const dllname = "./tests/realtimeGC/libshared.so" + +proc status() {.importc: "status", dynlib: dllname.} +proc count() {.importc: "count", dynlib: dllname.} +proc checkOccupiedMem() {.importc: "checkOccupiedMem", dynlib: dllname.} + +proc process() = + let startTime = getTime() + let runTime = cast[Time](RUNTIME) # + var accumTime: Time + while accumTime < runTime: + for i in 0..10: + count() + # echo("1. sleeping... ") + sleep(500) + for i in 0..10: + status() + # echo("2. sleeping... ") + sleep(500) + checkOccupiedMem() + accumTime = cast[Time]((getTime() - startTime)) + # echo("--- Minutes left to run: ", int(int(runTime-accumTime)/60)) + +proc main() = + process() + # parallel: + # for i in 0..0: + # spawn process() + # sync() + echo("Done") + +main() diff --git a/tests/realtimeGC/readme.txt b/tests/realtimeGC/readme.txt new file mode 100644 index 000000000..035a00001 --- /dev/null +++ b/tests/realtimeGC/readme.txt @@ -0,0 +1,21 @@ +Test the realtime GC without linking nimrtl.dll/so. + +Note, this is a long running test, default is 35 minutes. To change the +the run time see RUNTIME in main.nim and main.c. + +You can build shared.nim, main.nim, and main.c by running make (nix systems) +or maike.bat (Windows systems). They both assume GCC and that it's in your +path. Output: shared.(dll/so), camin(.exe), nmain(.exe). + +To run the test: execute either nmain or cmain in a shell window. + +To build buy hand: + + - build the shared object (shared.nim): + + $ nim c shared.nim + + - build the client executables: + + $ nim c -o:nmain main.nim + $ gcc -o cmain main.c -ldl diff --git a/tests/realtimeGC/shared.nim b/tests/realtimeGC/shared.nim new file mode 100644 index 000000000..2d1dd6c3c --- /dev/null +++ b/tests/realtimeGC/shared.nim @@ -0,0 +1,63 @@ +discard """ + cmd: "nim $target --debuginfo --hints:on --app:lib $options $file" +""" + +import strutils + +# Global state, accessing with threads, no locks. Don't do this at +# home. +var gCounter: uint64 +var gTxStatus: bool +var gRxStatus: bool +var gConnectStatus: bool +var gPttStatus: bool +var gComm1Status: bool +var gComm2Status: bool + +proc getTxStatus(): string = + result = if gTxStatus: "On" else: "Off" + gTxStatus = not gTxStatus + +proc getRxStatus(): string = + result = if gRxStatus: "On" else: "Off" + gRxStatus = not gRxStatus + +proc getConnectStatus(): string = + result = if gConnectStatus: "Yes" else: "No" + gConnectStatus = not gConnectStatus + +proc getPttStatus(): string = + result = if gPttStatus: "PTT: On" else: "PTT: Off" + gPttStatus = not gPttStatus + +proc getComm1Status(): string = + result = if gComm1Status: "On" else: "Off" + gComm1Status = not gComm1Status + +proc getComm2Status(): string = + result = if gComm2Status: "On" else: "Off" + gComm2Status = not gComm2Status + +proc status() {.exportc: "status", dynlib.} = + var tx_status = getTxStatus() + var rx_status = getRxStatus() + var connected = getConnectStatus() + var ptt_status = getPttStatus() + var str1: string = "[PilotEdge] Connected: $1 TX: $2 RX: $3" % [connected, tx_status, rx_status] + var a = getComm1Status() + var b = getComm2Status() + var str2: string = "$1 COM1: $2 COM2: $3" % [ptt_status, a, b] + # echo(str1) + # echo(str2) + +proc count() {.exportc: "count", dynlib.} = + var temp: uint64 + for i in 0..100_000: + temp += 1 + gCounter += 1 + # echo("gCounter: ", gCounter) + +proc checkOccupiedMem() {.exportc: "checkOccupiedMem", dynlib.} = + if getOccupiedMem() > 10_000_000: + quit 1 + discard diff --git a/tests/realtimeGC/shared.nim.cfg b/tests/realtimeGC/shared.nim.cfg new file mode 100644 index 000000000..e153b26fa --- /dev/null +++ b/tests/realtimeGC/shared.nim.cfg @@ -0,0 +1,5 @@ +--app:lib +--threads:on + +-d:release +-d:useRealtimeGC diff --git a/tests/stdlib/tunittest.nim b/tests/stdlib/tunittest.nim new file mode 100644 index 000000000..b23b3cdab --- /dev/null +++ b/tests/stdlib/tunittest.nim @@ -0,0 +1,21 @@ +import unittest + + +proc doThings(spuds: var int): int = + spuds = 24 + return 99 +test "#964": + var spuds = 0 + check doThings(spuds) == 99 + check spuds == 24 + + +from strutils import toUpper +test "#1384": + check(@["hello", "world"].map(toUpper) == @["HELLO", "WORLD"]) + + +import options +test "unittest typedescs": + check(none(int) == none(int)) + check(none(int) != some(1)) diff --git a/tests/template/tdefault_nil.nim b/tests/template/tdefault_nil.nim new file mode 100644 index 000000000..891166306 --- /dev/null +++ b/tests/template/tdefault_nil.nim @@ -0,0 +1,14 @@ + +# bug #2629 +import sequtils, os + +template glob_rst(basedir: string = nil): expr = + if baseDir.isNil: + to_seq(walk_files("*.rst")) + else: + to_seq(walk_files(basedir/"*.rst")) + +let + rst_files = concat(glob_rst(), glob_rst("docs")) + +when isMainModule: echo rst_files diff --git a/tests/testament/categories.nim b/tests/testament/categories.nim index 07a2421a6..4de1edeee 100644 --- a/tests/testament/categories.nim +++ b/tests/testament/categories.nim @@ -138,6 +138,18 @@ proc gcTests(r: var TResults, cat: Category, options: string) = test "stackrefleak" test "cyclecollector" +proc longGCTests(r: var TResults, cat: Category, options: string) = + when defined(windows): + let cOptions = "gcc -ldl -DWIN" + else: + let cOptions = "gcc -ldl" + + var c = initResults() + # According to ioTests, this should compile the file + testNoSpec c, makeTest("tests/realtimeGC/shared", options, cat, actionCompile) + testC r, makeTest("tests/realtimeGC/cmain", cOptions, cat, actionRun) + testSpec r, makeTest("tests/realtimeGC/nmain", options & "--threads: on", cat, actionRun) + # ------------------------- threading tests ----------------------------------- proc threadTests(r: var TResults, cat: Category, options: string) = @@ -340,6 +352,8 @@ proc processCategory(r: var TResults, cat: Category, options: string) = dllTests(r, cat, options) of "gc": gcTests(r, cat, options) + of "longgc": + longGCTests(r, cat, options) of "debugger": debuggerTests(r, cat, options) of "manyloc": diff --git a/tests/testament/tester.nim b/tests/testament/tester.nim index b3e65959a..62dafee80 100644 --- a/tests/testament/tester.nim +++ b/tests/testament/tester.nim @@ -31,6 +31,7 @@ Arguments: Options: --print also print results to the console --failing only show failing/ignored tests + --pedantic return non-zero status code if there are failures """ % resultsFile type @@ -89,6 +90,25 @@ proc callCompiler(cmdTemplate, filename, options: string, elif suc =~ pegSuccess: result.err = reSuccess +proc callCCompiler(cmdTemplate, filename, options: string, + target: TTarget): TSpec = + let c = parseCmdLine(cmdTemplate % ["target", targetToCmd[target], + "options", options, "file", filename.quoteShell]) + var p = startProcess(command="gcc", args=c[5.. ^1], + options={poStdErrToStdOut, poUsePath}) + let outp = p.outputStream + var x = newStringOfCap(120) + result.nimout = "" + result.msg = "" + result.file = "" + result.outp = "" + result.line = -1 + while outp.readLine(x.TaintedString) or running(p): + result.nimout.add(x & "\n") + close(p) + if p.peekExitCode == 0: + result.err = reSuccess + proc initResults: TResults = result.total = 0 result.passed = 0 @@ -257,8 +277,22 @@ proc testNoSpec(r: var TResults, test: TTest) = r.addResult(test, "", given.msg, given.err) if given.err == reSuccess: inc(r.passed) +proc testC(r: var TResults, test: TTest) = + # runs C code. Doesn't support any specs, just goes by exit code. + let tname = test.name.addFileExt(".c") + inc(r.total) + styledEcho "Processing ", fgCyan, extractFilename(tname) + var given = callCCompiler(cmdTemplate, test.name & ".c", test.options, test.target) + if given.err != reSuccess: + r.addResult(test, "", given.msg, given.err) + elif test.action == actionRun: + let exeFile = changeFileExt(test.name, ExeExt) + var (buf, exitCode) = execCmdEx(exeFile, options = {poStdErrToStdOut, poUseShell}) + if exitCode != 0: given.err = reExitCodesDiffer + if given.err == reSuccess: inc(r.passed) + proc makeTest(test, options: string, cat: Category, action = actionCompile, - target = targetC): TTest = + target = targetC, env: string = ""): TTest = # start with 'actionCompile', will be overwritten in the spec: result = TTest(cat: cat, name: test, options: options, target: target, action: action) @@ -277,12 +311,14 @@ proc main() = backend.open() var optPrintResults = false var optFailing = false + var optPedantic = false var p = initOptParser() p.next() while p.kind == cmdLongoption: case p.key.string.normalize of "print", "verbose": optPrintResults = true of "failing": optFailing = true + of "pedantic": optPedantic = true else: quit Usage p.next() if p.kind != cmdArgument: quit Usage @@ -315,8 +351,10 @@ proc main() = if action == "html": openDefaultBrowser(resultsFile) else: echo r, r.data backend.close() + if optPedantic: + var failed = r.total - r.passed - r.skipped + if failed > 0 : quit(QuitFailure) if paramCount() == 0: quit Usage main() - diff --git a/tests/tuples/tuple_with_seq.nim b/tests/tuples/tuple_with_seq.nim new file mode 100644 index 000000000..39edb500f --- /dev/null +++ b/tests/tuples/tuple_with_seq.nim @@ -0,0 +1,46 @@ +discard """ + output: '''it's nil +@[1, 2, 3]''' +""" + +template foo(s: string = nil) = + if isNil(s): + echo "it's nil" + else: + echo s + +foo + + +# bug #2632 + +proc takeTup(x: tuple[s: string;x: seq[int]]) = + discard + +takeTup(("foo", @[])) + + +#proc foobar(): () = + +proc f(xs: seq[int]) = + discard + +proc g(t: tuple[n:int, xs:seq[int]]) = + discard + +when isMainModule: + f(@[]) # OK + g((1,@[1])) # OK + g((0,@[])) # NG + + +# bug #2630 +type T = tuple[a: seq[int], b: int] + +var t: T = (@[1,2,3], 7) + +proc test(s: seq[int]): T = + echo s + (s, 7) + +t = test(t.a) diff --git a/tests/tuples/twrongtupleaccess.nim b/tests/tuples/twrongtupleaccess.nim index 1a9ae64a2..b1684b097 100644 --- a/tests/tuples/twrongtupleaccess.nim +++ b/tests/tuples/twrongtupleaccess.nim @@ -1,7 +1,7 @@ discard """ file: "twrongtupleaccess.nim" line: 9 - errormsg: "undeclared identifier: \'setBLAH\'" + errormsg: "attempting to call undeclared routine: \'setBLAH\'" """ # Bugfix diff --git a/tests/vm/tconstobj.nim b/tests/vm/tconstobj.nim new file mode 100644 index 000000000..414708945 --- /dev/null +++ b/tests/vm/tconstobj.nim @@ -0,0 +1,14 @@ +discard """ + output: '''(name: hello)''' +""" + +# bug #2774 + +type Foo = object + name: string + +const fooArray = [ + Foo(name: "hello") +] + +echo fooArray[0] diff --git a/todo.txt b/todo.txt index 1f6932c94..4972015a7 100644 --- a/todo.txt +++ b/todo.txt @@ -1,14 +1,14 @@ -version 0.10.4 +version 0.11.2 ============== - - -version 0.10.6 (RC1?) -===================== - +- The remaining bugs of the lambda lifting pass that is responsible to enable + closures and closure iterators need to be fixed. +- ``concept`` needs to be refined, a nice name for the feature is not enough. +- Destructors need to be refined. - make '--implicitStatic:on' the default; then we can also clean up the 'static[T]' mess in the compiler! -- finish 'parallel' or mark as experimental + +- Finish the implementation of the 'parallel' statement. - Deprecate ``immediate`` for templates and macros - special case varargs[untyped] and varargs[typed] - make 'nil' work for 'add': diff --git a/tools/niminst/niminst.nim b/tools/niminst/niminst.nim index f0ae45484..253543a50 100644 --- a/tools/niminst/niminst.nim +++ b/tools/niminst/niminst.nim @@ -35,7 +35,7 @@ type actionNsis, # action: create NSIS installer actionScripts # action: create install and deinstall scripts actionZip, # action: create zip file - actionTargz, # action: create targz file + actionXz, # action: create xz file actionDeb # action: prepare deb package FileCategory = enum @@ -172,7 +172,7 @@ proc parseCmdLine(c: var ConfigData) = of "csource": incl(c.actions, actionCSource) of "scripts": incl(c.actions, actionScripts) of "zip": incl(c.actions, actionZip) - of "targz": incl(c.actions, actionTargz) + of "xz": incl(c.actions, actionXz) of "inno": incl(c.actions, actionInno) of "nsis": incl(c.actions, actionNsis) of "deb": incl(c.actions, actionDeb) @@ -538,7 +538,7 @@ when haveZipLib: var n = "$#.zip" % proj if c.outdir.len == 0: n = "build" / n else: n = c.outdir / n - var z: TZipArchive + var z: ZipArchive if open(z, n, fmWrite): addFile(z, proj / buildBatFile32, "build" / buildBatFile32) addFile(z, proj / buildBatFile64, "build" / buildBatFile64) @@ -560,9 +560,9 @@ when haveZipLib: else: quit("Cannot open for writing: " & n) -proc targzDist(c: var ConfigData) = +proc xzDist(c: var ConfigData) = let proj = toLower(c.name) & "-" & c.version - var n = "$#.tar.gz" % proj + var n = "$#.tar.xz" % proj let tmpDir = if c.outdir.len == 0: "build" else: c.outdir template processFile(z, dest, src) = @@ -571,7 +571,7 @@ proc targzDist(c: var ConfigData) = echo "Copying ", s, " to ", tmpDir / d let destdir = tmpdir / d.splitFile.dir if not dirExists(destdir): createDir(destdir) - copyFile(s, tmpDir / d) + copyFileWithPermissions(s, tmpDir / d) processFile(z, proj / buildBatFile32, "build" / buildBatFile32) processFile(z, proj / buildBatFile64, "build" / buildBatFile64) @@ -593,9 +593,7 @@ proc targzDist(c: var ConfigData) = let oldDir = getCurrentDir() setCurrentDir(tmpDir) try: - #if execShellCmd("7z a -ttar $1.tar $1" % proj) != 0 or - # execShellCmd("7z a -tgzip $1.tar.gz $1.tar" % proj) != 0 or - if execShellCmd("7z a -tzip $1.zip $1" % proj) != 0: + if execShellCmd("XZ_OPT=-9 tar Jcf $1.tar.xz $1" % proj) != 0: echo("External program failed") finally: setCurrentDir(oldDir) @@ -666,7 +664,7 @@ if actionZip in c.actions: zipDist(c) else: quit("libzip is not installed") -if actionTargz in c.actions: - targzDist(c) +if actionXz in c.actions: + xzDist(c) if actionDeb in c.actions: debDist(c) diff --git a/web/documentation.txt b/web/documentation.txt index 145a6e827..67f8b4070 100644 --- a/web/documentation.txt +++ b/web/documentation.txt @@ -8,13 +8,13 @@ Nim's Documentation .. container:: libraries - - | `Standard Library <0.11.0/lib.html>`_ + - | `Standard Library <docs/lib.html>`_ | This document describes Nim's standard library. - - | `Language Manual <0.11.0/manual.html>`_ + - | `Language Manual <docs/manual.html>`_ | The Nim manual is a draft that will evolve into a proper specification. - - | `Compiler User Guide <0.11.0/nimc.html>`_ + - | `Compiler User Guide <docs/nimc.html>`_ | The user guide lists command line arguments, special features of the compiler, etc. @@ -26,11 +26,11 @@ Nim's Documentation .. container:: tools - - | `Source Code Filters <0.11.0/filters.html>`_ + - | `Source Code Filters <docs/filters.html>`_ | The Nim compiler supports source code filters as a simple yet powerful builtin templating system. - - | `Tools Documentation <0.11.0/tools.html>`_ + - | `Tools Documentation <docs/tools.html>`_ | Description of some tools that come with the standard distribution. @@ -41,11 +41,11 @@ Nim's Documentation .. container:: internals - - | `Garbage Collector <0.11.0/gc.html>`_ + - | `Garbage Collector <docs/gc.html>`_ | Additional documentation about Nim's GC and how to operate it in a realtime setting. - - | `Internal Documentation <0.11.0/intern.html>`_ + - | `Internal Documentation <docs/intern.html>`_ | The internal documentation describes how the compiler is implemented. Read this if you want to hack the compiler. @@ -53,5 +53,5 @@ Nim's Documentation Search Options -------------- -`Documentation Index <0.11.0/theindex.html>`_ - The generated +`Documentation Index <docs/theindex.html>`_ - The generated index. **Index + (Ctrl+F) == Joy** diff --git a/web/download.txt b/web/download.txt index c9bc202cd..6acc80b53 100644 --- a/web/download.txt +++ b/web/download.txt @@ -13,8 +13,8 @@ Binaries -------- Unfortunately for now we only provide builds for Windows. -* 32 bit: `nim-0.11.0_x32.exe <download/nim-0.11.0_x32.exe>`_ -* 64 bit: `nim-0.11.0_x64.exe <download/nim-0.11.0_x64.exe>`_ +* 32 bit: `nim-0.11.2_x32.exe <download/nim-0.11.2_x32.exe>`_ +* 64 bit: `nim-0.11.2_x64.exe <download/nim-0.11.2_x64.exe>`_ Installation based on generated C code @@ -26,8 +26,8 @@ like systems. Binary packages may be provided later. Download one of these: -* `nim-0.11.0.zip (28 MB) <download/nim-0.11.0.zip>`_ -* `nim-0.11.0.tar.xz (2.6MB) <download/nim-0.11.0.tar.xz>`_ +* `nim-0.11.2.zip (28 MB) <download/nim-0.11.2.zip>`_ +* `nim-0.11.2.tar.xz (2.6MB) <download/nim-0.11.2.tar.xz>`_ Extract the file and follow these instructions: diff --git a/web/learn.txt b/web/learn.txt index a2df38cde..bf0cc43ef 100644 --- a/web/learn.txt +++ b/web/learn.txt @@ -8,10 +8,10 @@ Learning Nim .. container:: tutorials - - | `Tutorial (part I) <0.11.0/tut1.html>`_ + - | `Tutorial (part I) <docs/tut1.html>`_ | Learn the basics of Nim's types, variables, procedures, control flow, etc... - - | `Tutorial (part II) <0.11.0/tut2.html>`_ + - | `Tutorial (part II) <docs/tut2.html>`_ | Learn Nim's more advanced features such as OOP, generics, macros, etc... @@ -52,5 +52,5 @@ Learning Nim Documentation ------------- -More examples of Nim code can be found in the `Nim Language Documentation <0.11.0/manual.html>`_. +More examples of Nim code can be found in the `Nim Language Documentation <docs/manual.html>`_. diff --git a/web/news.txt b/web/news.txt index 0f3f8def6..6a82b3f26 100644 --- a/web/news.txt +++ b/web/news.txt @@ -2,6 +2,40 @@ News ==== +.. + 2015-05-05 Version 0.11.2 released + ================================== + + Changes affecting backwards compatibility + ----------------------------------------- + + - The ``miliseconds`` property of ``times.TimeInterval`` is now ``milliseconds``. + Code accessing that property is deprecated and code using ``miliseconds`` + during object initialization or as a named parameter of ``initInterval()`` + will need to be updated. + + - ``std.logging`` functions no longer do formatting and semantically treat + their arguments just like ``echo`` does. Affected functions: ``log``, + ``debug``, ``info``, ``warn``, ``error``, ``fatal``. Custom subtypes of + ``Logger`` also need to be adjusted accordingly. + + Language Additions + ------------------ + + + Bugfixes + -------- + + +2015-05-04 Version 0.11.2 released +================================== + +This is just a bugfix release that fixes the most pressing regressions we +introduced with version 0.11.0. The way types are computed was +changed significantly causing all sort of problems. Sorry for the +inconvenience; we grew overconfident our large test suite would prevent these +things. + 2015-04-30 Version 0.11.0 released ================================== @@ -198,6 +232,7 @@ Library additions space between ``.. <`` and ``.. ^`` is not necessary anymore. - Added ``system.xlen`` for strings and sequences to get back the old ``len`` operation that doesn't check for ``nil`` for efficiency. +- Added sexp.nim to parse and generate sexp. Bugfixes diff --git a/web/ticker.txt b/web/ticker.txt index 799246521..4840e4039 100644 --- a/web/ticker.txt +++ b/web/ticker.txt @@ -1,6 +1,6 @@ -<a class="news" href="news.html#Z2015-04-30-version-0-11-0-released"> - <h4>Apr 30, 2015</h4> - <p>Nim version 0.11.0 has been released!</p> +<a class="news" href="news.html#Z2015-05-04-version-0-11-2-released"> + <h4>May 4, 2015</h4> + <p>Nim version 0.11.2 has been released!</p> </a> <a class="news" href="news.html#Z2014-12-29-version-0-10-2-released"> |