Merge branch 'master' into asyncmacro
This commit is contained in:
commit
ab534804c6
37 changed files with 1737 additions and 1328 deletions
|
|
@ -795,6 +795,9 @@ const
|
|||
|
||||
skLocalVars* = {skVar, skLet, skForVar, skParam, skResult}
|
||||
|
||||
lfFullExternalName* = lfParamCopy # \
|
||||
# only used when 'gCmd == cmdPretty': Indicates that the symbol has been
|
||||
# imported via 'importc: "fullname"' and no format string.
|
||||
|
||||
# creator procs:
|
||||
proc NewSym*(symKind: TSymKind, Name: PIdent, owner: PSym,
|
||||
|
|
|
|||
|
|
@ -701,6 +701,7 @@ proc genTry(p: BProc, t: PNode, d: var TLoc) =
|
|||
#
|
||||
if not isEmptyType(t.typ) and d.k == locNone:
|
||||
getTemp(p, t.typ, d)
|
||||
discard lists.IncludeStr(p.module.headerFiles, "<setjmp.h>")
|
||||
genLineDir(p, t)
|
||||
var safePoint = getTempName()
|
||||
discard cgsym(p.module, "E_Base")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#
|
||||
#
|
||||
# The Nimrod Compiler
|
||||
# (c) Copyright 2012 Andreas Rumpf
|
||||
# (c) Copyright 2013 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
|
|
@ -10,48 +10,35 @@
|
|||
# This module handles the conditional symbols.
|
||||
|
||||
import
|
||||
ast, astalgo, hashes, platform, strutils, idents
|
||||
strtabs, platform, strutils, idents
|
||||
|
||||
var gSymbols*: TStrTable
|
||||
# We need to use a PStringTable here as defined symbols are always guaranteed
|
||||
# to be style insensitive. Otherwise hell would break lose.
|
||||
var gSymbols: PStringTable
|
||||
|
||||
proc DefineSymbol*(symbol: string) =
|
||||
var i = getIdent(symbol)
|
||||
var sym = StrTableGet(gSymbols, i)
|
||||
if sym == nil:
|
||||
new(sym) # circumvent the ID mechanism
|
||||
sym.kind = skConditional
|
||||
sym.name = i
|
||||
StrTableAdd(gSymbols, sym)
|
||||
sym.position = 1
|
||||
gSymbols[symbol] = "true"
|
||||
|
||||
proc UndefSymbol*(symbol: string) =
|
||||
var sym = StrTableGet(gSymbols, getIdent(symbol))
|
||||
if sym != nil: sym.position = 0
|
||||
|
||||
proc isDefined*(symbol: PIdent): bool =
|
||||
var sym = StrTableGet(gSymbols, symbol)
|
||||
result = sym != nil and sym.position == 1
|
||||
gSymbols[symbol] = "false"
|
||||
|
||||
proc isDefined*(symbol: string): bool =
|
||||
result = isDefined(getIdent(symbol))
|
||||
if gSymbols.hasKey(symbol):
|
||||
result = gSymbols[symbol] == "true"
|
||||
|
||||
proc isDefined*(symbol: PIdent): bool = isDefined(symbol.s)
|
||||
|
||||
iterator definedSymbolNames*: string =
|
||||
var it: TTabIter
|
||||
var s = InitTabIter(it, gSymbols)
|
||||
while s != nil:
|
||||
if s.position == 1: yield s.name.s
|
||||
s = nextIter(it, gSymbols)
|
||||
for key, val in pairs(gSymbols):
|
||||
if val == "true": yield key
|
||||
|
||||
proc countDefinedSymbols*(): int =
|
||||
var it: TTabIter
|
||||
var s = InitTabIter(it, gSymbols)
|
||||
result = 0
|
||||
while s != nil:
|
||||
if s.position == 1: inc(result)
|
||||
s = nextIter(it, gSymbols)
|
||||
for key, val in pairs(gSymbols):
|
||||
if val == "true": inc(result)
|
||||
|
||||
proc InitDefines*() =
|
||||
initStrTable(gSymbols)
|
||||
gSymbols = newStringTable(modeStyleInsensitive)
|
||||
DefineSymbol("nimrod") # 'nimrod' is always defined
|
||||
# for bootstrapping purposes and old code:
|
||||
DefineSymbol("nimhygiene")
|
||||
|
|
@ -66,7 +53,7 @@ proc InitDefines*() =
|
|||
of cpuI386: DefineSymbol("x86")
|
||||
of cpuIa64: DefineSymbol("itanium")
|
||||
of cpuAmd64: DefineSymbol("x8664")
|
||||
else: nil
|
||||
else: discard
|
||||
case targetOS
|
||||
of osDOS:
|
||||
DefineSymbol("msdos")
|
||||
|
|
@ -92,12 +79,10 @@ proc InitDefines*() =
|
|||
DefineSymbol("macintosh")
|
||||
DefineSymbol("unix")
|
||||
DefineSymbol("posix")
|
||||
else: nil
|
||||
else: discard
|
||||
DefineSymbol("cpu" & $cpu[targetCPU].bit)
|
||||
DefineSymbol(normalize(endianToStr[cpu[targetCPU].endian]))
|
||||
DefineSymbol(cpu[targetCPU].name)
|
||||
DefineSymbol(platform.os[targetOS].name)
|
||||
if platform.OS[targetOS].props.contains(ospLacksThreadVars):
|
||||
DefineSymbol("emulatedthreadvars")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -889,17 +889,10 @@ proc evalRepr(c: PEvalContext, n: PNode): PNode =
|
|||
proc isEmpty(n: PNode): bool =
|
||||
result = n != nil and n.kind == nkEmpty
|
||||
|
||||
# The lexer marks multi-line strings as residing at the line where they
|
||||
# are closed. This function returns the line where the string begins
|
||||
# Maybe the lexer should mark both the beginning and the end of expressions,
|
||||
# then this function could be removed.
|
||||
proc stringStartingLine(s: PNode): int =
|
||||
result = s.info.line.int - countLines(s.strVal)
|
||||
|
||||
proc evalParseExpr(c: PEvalContext, n: PNode): PNode =
|
||||
var code = evalAux(c, n.sons[1], {})
|
||||
var ast = parseString(code.getStrValue, code.info.toFilename,
|
||||
code.stringStartingLine)
|
||||
code.info.line.int)
|
||||
if sonsLen(ast) != 1:
|
||||
GlobalError(code.info, errExprExpected, "multiple statements")
|
||||
result = ast.sons[0]
|
||||
|
|
@ -908,7 +901,7 @@ proc evalParseExpr(c: PEvalContext, n: PNode): PNode =
|
|||
proc evalParseStmt(c: PEvalContext, n: PNode): PNode =
|
||||
var code = evalAux(c, n.sons[1], {})
|
||||
result = parseString(code.getStrValue, code.info.toFilename,
|
||||
code.stringStartingLine)
|
||||
code.info.line.int)
|
||||
#result.typ = newType(tyStmt, c.module)
|
||||
|
||||
proc evalTypeTrait*(n: PNode, context: PSym): PNode =
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ type
|
|||
# or float literals
|
||||
literal*: string # the parsed (string) literal; and
|
||||
# documentation comments are here too
|
||||
line*, col*: int
|
||||
|
||||
TLexer* = object of TBaseLexer
|
||||
fileIdx*: int32
|
||||
|
|
@ -124,8 +125,10 @@ proc isKeyword*(kind: TTokType): bool
|
|||
proc openLexer*(lex: var TLexer, fileidx: int32, inputstream: PLLStream)
|
||||
proc rawGetTok*(L: var TLexer, tok: var TToken)
|
||||
# reads in the next token into tok and skips it
|
||||
proc getColumn*(L: TLexer): int
|
||||
proc getLineInfo*(L: TLexer): TLineInfo
|
||||
|
||||
proc getLineInfo*(L: TLexer, tok: TToken): TLineInfo {.inline.} =
|
||||
newLineInfo(L.fileIdx, tok.line, tok.col)
|
||||
|
||||
proc closeLexer*(lex: var TLexer)
|
||||
proc PrintTok*(tok: TToken)
|
||||
proc tokToStr*(tok: TToken): string
|
||||
|
|
@ -702,6 +705,8 @@ proc rawGetTok(L: var TLexer, tok: var TToken) =
|
|||
tok.indent = -1
|
||||
skip(L, tok)
|
||||
var c = L.buf[L.bufpos]
|
||||
tok.line = L.linenumber
|
||||
tok.col = getColNumber(L, L.bufpos)
|
||||
if c in SymStartChars - {'r', 'R', 'l'}:
|
||||
getSymbol(L, tok)
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ import
|
|||
wordrecg, sem, semdata, idents, passes, docgen, extccomp,
|
||||
cgen, jsgen, json, nversion,
|
||||
platform, nimconf, importer, passaux, depends, evals, types, idgen,
|
||||
tables, docgen2, service, parser, modules, ccgutils, sigmatch, ropes, lists
|
||||
tables, docgen2, service, parser, modules, ccgutils, sigmatch, ropes, lists,
|
||||
pretty
|
||||
|
||||
from magicsys import SystemModule, resetSysTypes
|
||||
|
||||
|
|
@ -162,12 +163,19 @@ proc commandEval(exp: string) =
|
|||
var echoExp = "echo \"eval\\t\", " & "repr(" & exp & ")"
|
||||
evalNim(echoExp.parseString, makeStdinModule())
|
||||
|
||||
proc CommandPretty =
|
||||
proc CommandPrettyOld =
|
||||
var projectFile = addFileExt(mainCommandArg(), NimExt)
|
||||
var module = parseFile(projectFile.fileInfoIdx)
|
||||
if module != nil:
|
||||
renderModule(module, getOutFile(mainCommandArg(), "pretty." & NimExt))
|
||||
|
||||
proc CommandPretty =
|
||||
msgs.gErrorMax = high(int) # do not stop after first error
|
||||
semanticPasses()
|
||||
registerPass(prettyPass)
|
||||
compileProject()
|
||||
pretty.overwriteFiles()
|
||||
|
||||
proc CommandScan =
|
||||
var f = addFileExt(mainCommandArg(), nimExt)
|
||||
var stream = LLStreamOpen(f, fmRead)
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ proc checkSymbol(L: TLexer, tok: TToken) =
|
|||
proc parseAssignment(L: var TLexer, tok: var TToken) =
|
||||
if tok.ident.id == getIdent("-").id or tok.ident.id == getIdent("--").id:
|
||||
confTok(L, tok) # skip unnecessary prefix
|
||||
var info = getLineInfo(L) # safe for later in case of an error
|
||||
var info = getLineInfo(L, tok) # safe for later in case of an error
|
||||
checkSymbol(L, tok)
|
||||
var s = tokToStr(tok)
|
||||
confTok(L, tok) # skip symbol
|
||||
|
|
@ -176,7 +176,7 @@ proc parseAssignment(L: var TLexer, tok: var TToken) =
|
|||
add(val, tokToStr(tok))
|
||||
confTok(L, tok)
|
||||
if tok.tokType == tkBracketRi: confTok(L, tok)
|
||||
else: lexMessage(L, errTokenExpected, "\']\'")
|
||||
else: lexMessage(L, errTokenExpected, "']'")
|
||||
add(val, ']')
|
||||
if tok.tokType in {tkColon, tkEquals}:
|
||||
if len(val) > 0: add(val, ':')
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ proc Eat(p: var TParser, TokType: TTokType) =
|
|||
else: lexMessage(p.lex, errTokenExpected, TokTypeToStr[tokType])
|
||||
|
||||
proc parLineInfo(p: TParser): TLineInfo =
|
||||
result = getLineInfo(p.lex)
|
||||
result = getLineInfo(p.lex, p.tok)
|
||||
|
||||
proc indAndComment(p: var TParser, n: PNode) =
|
||||
if p.tok.indent > p.currInd:
|
||||
|
|
@ -154,7 +154,7 @@ proc indAndComment(p: var TParser, n: PNode) =
|
|||
skipComment(p, n)
|
||||
|
||||
proc newNodeP(kind: TNodeKind, p: TParser): PNode =
|
||||
result = newNodeI(kind, getLineInfo(p.lex))
|
||||
result = newNodeI(kind, parLineInfo(p))
|
||||
|
||||
proc newIntNodeP(kind: TNodeKind, intVal: BiggestInt, p: TParser): PNode =
|
||||
result = newNodeP(kind, p)
|
||||
|
|
@ -350,7 +350,7 @@ proc exprList(p: var TParser, endTok: TTokType, result: PNode) =
|
|||
|
||||
proc dotExpr(p: var TParser, a: PNode): PNode =
|
||||
#| dotExpr = expr '.' optInd ('type' | 'addr' | symbol)
|
||||
var info = p.lex.getlineInfo
|
||||
var info = p.parLineInfo
|
||||
getTok(p)
|
||||
optInd(p, a)
|
||||
case p.tok.tokType
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ proc pragmaAsm*(c: PContext, n: PNode): char =
|
|||
if n != nil:
|
||||
for i in countup(0, sonsLen(n) - 1):
|
||||
let it = n.sons[i]
|
||||
if (it.kind == nkExprColonExpr) and (it.sons[0].kind == nkIdent):
|
||||
if it.kind == nkExprColonExpr and it.sons[0].kind == nkIdent:
|
||||
case whichKeyword(it.sons[0].ident)
|
||||
of wSubsChar:
|
||||
if it.sons[1].kind == nkCharLit: result = chr(int(it.sons[1].intVal))
|
||||
|
|
@ -86,6 +86,9 @@ proc pragmaAsm*(c: PContext, n: PNode): char =
|
|||
|
||||
proc setExternName(s: PSym, extname: string) =
|
||||
s.loc.r = toRope(extname % s.name.s)
|
||||
if gCmd == cmdPretty and '$' notin extname:
|
||||
# note that '{.importc.}' is transformed into '{.importc: "$1".}'
|
||||
s.loc.flags.incl(lfFullExternalName)
|
||||
|
||||
proc MakeExternImport(s: PSym, extname: string) =
|
||||
setExternName(s, extname)
|
||||
|
|
@ -513,11 +516,11 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: int,
|
|||
if k in validPragmas:
|
||||
case k
|
||||
of wExportc:
|
||||
makeExternExport(sym, getOptionalStr(c, it, sym.name.s))
|
||||
makeExternExport(sym, getOptionalStr(c, it, "$1"))
|
||||
incl(sym.flags, sfUsed) # avoid wrong hints
|
||||
of wImportc: makeExternImport(sym, getOptionalStr(c, it, sym.name.s))
|
||||
of wImportc: makeExternImport(sym, getOptionalStr(c, it, "$1"))
|
||||
of wImportCompilerProc:
|
||||
processImportCompilerProc(sym, getOptionalStr(c, it, sym.name.s))
|
||||
processImportCompilerProc(sym, getOptionalStr(c, it, "$1"))
|
||||
of wExtern: setExternName(sym, expectStrLit(c, it))
|
||||
of wImmediate:
|
||||
if sym.kind in {skTemplate, skMacro}: incl(sym.flags, sfImmediate)
|
||||
|
|
@ -526,9 +529,9 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: int,
|
|||
if sym.kind == skTemplate: incl(sym.flags, sfDirty)
|
||||
else: invalidPragma(it)
|
||||
of wImportCpp:
|
||||
processImportCpp(sym, getOptionalStr(c, it, sym.name.s))
|
||||
processImportCpp(sym, getOptionalStr(c, it, "$1"))
|
||||
of wImportObjC:
|
||||
processImportObjC(sym, getOptionalStr(c, it, sym.name.s))
|
||||
processImportObjC(sym, getOptionalStr(c, it, "$1"))
|
||||
of wAlign:
|
||||
if sym.typ == nil: invalidPragma(it)
|
||||
var align = expectIntLit(c, it)
|
||||
|
|
@ -598,7 +601,7 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: int,
|
|||
processDynLib(c, it, sym)
|
||||
of wCompilerProc:
|
||||
noVal(it) # compilerproc may not get a string!
|
||||
makeExternExport(sym, sym.name.s)
|
||||
makeExternExport(sym, "$1")
|
||||
incl(sym.flags, sfCompilerProc)
|
||||
incl(sym.flags, sfUsed) # suppress all those stupid warnings
|
||||
registerCompilerProc(sym)
|
||||
|
|
|
|||
180
compiler/pretty.nim
Normal file
180
compiler/pretty.nim
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
#
|
||||
#
|
||||
# The Nimrod Compiler
|
||||
# (c) Copyright 2013 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## This module implements the code "prettifier". This is part of the toolchain
|
||||
## to convert Nimrod code into a consistent style.
|
||||
|
||||
import
|
||||
strutils, os, options, ast, astalgo, msgs, ropes, idents, passes,
|
||||
intsets, strtabs
|
||||
|
||||
const
|
||||
removeTP = false # when true, "nimrod pretty" converts TTyp to Typ.
|
||||
|
||||
type
|
||||
TGen = object of TPassContext
|
||||
module*: PSym
|
||||
PGen = ref TGen
|
||||
|
||||
TSourceFile = object
|
||||
lines: seq[string]
|
||||
dirty: bool
|
||||
fullpath: string
|
||||
|
||||
var
|
||||
gSourceFiles: seq[TSourceFile] = @[]
|
||||
rules: PStringTable
|
||||
|
||||
proc loadFile(info: TLineInfo) =
|
||||
let i = info.fileIndex
|
||||
if i >= gSourceFiles.len:
|
||||
gSourceFiles.setLen(i+1)
|
||||
if gSourceFiles[i].lines.isNil:
|
||||
gSourceFiles[i].lines = @[]
|
||||
let path = info.toFullPath
|
||||
gSourceFiles[i].fullpath = path
|
||||
# we want to die here for EIO:
|
||||
for line in lines(path):
|
||||
gSourceFiles[i].lines.add(line)
|
||||
|
||||
proc overwriteFiles*() =
|
||||
for i in 0 .. high(gSourceFiles):
|
||||
if not gSourceFiles[i].dirty: continue
|
||||
let newFile = gSourceFiles[i].fullpath.changeFileExt(".pretty.nim")
|
||||
try:
|
||||
var f = open(newFile, fmWrite)
|
||||
for line in gSourceFiles[i].lines:
|
||||
f.writeln(line)
|
||||
f.close
|
||||
except EIO:
|
||||
rawMessage(errCannotOpenFile, newFile)
|
||||
|
||||
proc beautifyName(s: string, k: TSymKind): string =
|
||||
result = newStringOfCap(s.len)
|
||||
var i = 0
|
||||
case k
|
||||
of skType, skGenericParam:
|
||||
# skip leading 'T'
|
||||
when removeTP:
|
||||
if s[0] == 'T' and s[1] in {'A'..'Z'}:
|
||||
i = 1
|
||||
result.add toUpper(s[i])
|
||||
of skConst, skEnumField:
|
||||
# for 'const' we keep how it's spelt; either upper case or lower case:
|
||||
result.add s[0]
|
||||
else:
|
||||
# as a special rule, don't transform 'L' to 'l'
|
||||
if s.len == 1 and s[0] == 'L': result.add 'L'
|
||||
else: result.add toLower(s[0])
|
||||
inc i
|
||||
let allUpper = allCharsInSet(s, {'A'..'Z', '0'..'9', '_'})
|
||||
while i < s.len:
|
||||
if s[i] == '_':
|
||||
inc i
|
||||
result.add toUpper(s[i])
|
||||
elif allUpper:
|
||||
result.add toLower(s[i])
|
||||
else:
|
||||
result.add s[i]
|
||||
inc i
|
||||
|
||||
proc checkStyle*(info: TLineInfo, s: string, k: TSymKind) =
|
||||
let beau = beautifyName(s, k)
|
||||
if s != beau:
|
||||
Message(info, errGenerated,
|
||||
"name does not adhere to naming convention; should be: " & beau)
|
||||
|
||||
const
|
||||
Letters = {'a'..'z', 'A'..'Z', '0'..'9', '\x80'..'\xFF', '_'}
|
||||
|
||||
proc identLen(line: string, start: int): int =
|
||||
while start+result < line.len and line[start+result] in Letters:
|
||||
inc result
|
||||
|
||||
proc differ(line: string, a, b: int, x: string): bool =
|
||||
let y = line[a..b]
|
||||
result = cmpIgnoreStyle(y, x) == 0 and y != x
|
||||
when false:
|
||||
var j = 0
|
||||
for i in a..b:
|
||||
if line[i] != x[j]: return true
|
||||
inc j
|
||||
return false
|
||||
|
||||
var cannotRename = initIntSet()
|
||||
|
||||
proc processSym(c: PPassContext, n: PNode): PNode =
|
||||
result = n
|
||||
var g = PGen(c)
|
||||
case n.kind
|
||||
of nkSym:
|
||||
if n.info.fileIndex < 0: return
|
||||
let s = n.sym
|
||||
# operators stay as they are:
|
||||
if s.kind in {skResult, skTemp} or s.name.s[0] notin Letters: return
|
||||
if s.kind in {skType, skGenericParam} and sfAnon in s.flags: return
|
||||
|
||||
if s.id in cannotRename: return
|
||||
|
||||
let newName = if rules.hasKey(s.name.s): rules[s.name.s]
|
||||
else: beautifyName(s.name.s, n.sym.kind)
|
||||
|
||||
loadFile(n.info)
|
||||
|
||||
let line = gSourceFiles[n.info.fileIndex].lines[n.info.line-1]
|
||||
var first = n.info.col.int
|
||||
if first < 0: return
|
||||
#inc first, skipIgnoreCase(line, "proc ", first)
|
||||
while first > 0 and line[first-1] in Letters: dec first
|
||||
if line[first] == '`': inc first
|
||||
|
||||
if {sfImportc, sfExportc} * s.flags != {}:
|
||||
# careful, we must ensure the resulting name still matches the external
|
||||
# name:
|
||||
if newName != s.name.s and newName != s.loc.r.ropeToStr and
|
||||
lfFullExternalName notin s.loc.flags:
|
||||
Message(n.info, errGenerated,
|
||||
"cannot rename $# to $# due to external name" % [s.name.s, newName])
|
||||
cannotRename.incl(s.id)
|
||||
return
|
||||
let last = first+identLen(line, first)-1
|
||||
if last-first+1 != newName.len or differ(line, first, last, newName):
|
||||
var x = line.subStr(0, first-1) & newName & line.substr(last+1)
|
||||
when removeTP:
|
||||
# the WinAPI module is full of 'TX = X' which after the substitution
|
||||
# becomes 'X = X'. We remove those lines:
|
||||
if x.match(peg"\s* {\ident} \s* '=' \s* y$1 ('#' .*)?"):
|
||||
x = ""
|
||||
|
||||
system.shallowCopy(gSourceFiles[n.info.fileIndex].lines[n.info.line-1], x)
|
||||
gSourceFiles[n.info.fileIndex].dirty = true
|
||||
else:
|
||||
for i in 0 .. <n.safeLen:
|
||||
discard processSym(c, n.sons[i])
|
||||
|
||||
proc myOpen(module: PSym): PPassContext =
|
||||
var g: PGen
|
||||
new(g)
|
||||
g.module = module
|
||||
result = g
|
||||
if rules.isNil:
|
||||
rules = newStringTable(modeStyleInsensitive)
|
||||
when removeTP:
|
||||
# XXX activate when the T/P stuff is deprecated
|
||||
let path = joinPath([getPrefixDir(), "config", "rename.rules.cfg"])
|
||||
for line in lines(path):
|
||||
if line.len > 0:
|
||||
let colon = line.find(':')
|
||||
if colon > 0:
|
||||
rules[line.substr(0, colon-1)] = line.substr(colon+1)
|
||||
else:
|
||||
rules[line] = line
|
||||
|
||||
const prettyPass* = makePass(open = myOpen, process = processSym)
|
||||
|
||||
|
|
@ -45,14 +45,10 @@ proc addStmt(w: PRodWriter, n: PNode)
|
|||
proc writeRod(w: PRodWriter)
|
||||
|
||||
proc getDefines(): string =
|
||||
var it: TTabIter
|
||||
var s = InitTabIter(it, gSymbols)
|
||||
result = ""
|
||||
while s != nil:
|
||||
if s.position == 1:
|
||||
if result.len != 0: add(result, " ")
|
||||
add(result, s.name.s)
|
||||
s = nextIter(it, gSymbols)
|
||||
for d in definedSymbolNames():
|
||||
if result.len != 0: add(result, " ")
|
||||
add(result, d)
|
||||
|
||||
proc fileIdx(w: PRodWriter, filename: string): int =
|
||||
for i in countup(0, high(w.files)):
|
||||
|
|
|
|||
|
|
@ -431,7 +431,7 @@ proc semConst(c: PContext, n: PNode): PNode =
|
|||
var b = newNodeI(nkConstDef, a.info)
|
||||
if importantComments(): b.comment = a.comment
|
||||
addSon(b, newSymNode(v))
|
||||
addSon(b, ast.emptyNode) # no type description
|
||||
addSon(b, a.sons[1])
|
||||
addSon(b, copyTree(def))
|
||||
addSon(result, b)
|
||||
|
||||
|
|
|
|||
|
|
@ -601,7 +601,7 @@ proc paramTypeClass(c: PContext, paramType: PType, procKind: TSymKind):
|
|||
result.typ = newTypeS(tyExpr, c)
|
||||
result.typ.sons = paramType.sons
|
||||
of tyTypeDesc:
|
||||
if tfInstantiated notin paramType.flags:
|
||||
if tfInstantiated notin paramType.flags:
|
||||
result.typ = newTypeS(tyTypeDesc, c)
|
||||
result.typ.sons = paramType.sons
|
||||
of tyDistinct:
|
||||
|
|
@ -719,8 +719,8 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode,
|
|||
if skipTypes(typ, {tyGenericInst}).kind == tyEmpty: continue
|
||||
for j in countup(0, length-3):
|
||||
var arg = newSymG(skParam, a.sons[j], c)
|
||||
var finalType = liftParamType(c, kind, genericParams, typ,
|
||||
arg.name.s, arg.info).skipIntLit
|
||||
var finalType = liftParamType(c, kind, genericParams, typ, arg.name.s,
|
||||
a.sons[length-2].info).skipIntLit
|
||||
arg.typ = finalType
|
||||
arg.position = counter
|
||||
arg.constraint = constraint
|
||||
|
|
|
|||
|
|
@ -205,13 +205,11 @@ proc findClosestCall(n: PNode): PNode =
|
|||
if result != nil: return
|
||||
|
||||
proc isTracked(current: TLineInfo, tokenLen: int): bool =
|
||||
# the column of an identifier is at its *end*, so we subtract to get the
|
||||
# start of it.
|
||||
for i in countup(0, high(checkPoints)):
|
||||
if current.fileIndex == checkPoints[i].fileIndex:
|
||||
if current.line == checkPoints[i].line:
|
||||
let col = checkPoints[i].col
|
||||
if col >= current.col-tokenLen and col <= current.col:
|
||||
if col >= current.col and col <= current.col+tokenLen-1:
|
||||
return true
|
||||
|
||||
proc findClosestSym(n: PNode): PNode =
|
||||
|
|
|
|||
153
compiler/vm.nim
153
compiler/vm.nim
|
|
@ -10,7 +10,11 @@
|
|||
## This file implements the new evaluation engine for Nimrod code.
|
||||
## An instruction is 1-2 int32s in memory, it is a register based VM.
|
||||
|
||||
import ast, astalgo, msgs, vmdef, vmgen, nimsets, types, passes, unsigned
|
||||
import
|
||||
strutils, ast, astalgo, msgs, vmdef, vmgen, nimsets, types, passes, unsigned,
|
||||
parser, vmdeps
|
||||
|
||||
from semfold import leValueConv
|
||||
|
||||
type
|
||||
PStackFrame* = ref TStackFrame
|
||||
|
|
@ -70,6 +74,10 @@ template decodeBC(k: expr) {.immediate, dirty.} =
|
|||
let rc = instr.regC
|
||||
ensureKind(k)
|
||||
|
||||
template declBC() {.immediate, dirty.} =
|
||||
let rb = instr.regB
|
||||
let rc = instr.regC
|
||||
|
||||
template decodeBImm(k: expr) {.immediate, dirty.} =
|
||||
let rb = instr.regB
|
||||
let imm = instr.regC - byteExcess
|
||||
|
|
@ -79,10 +87,6 @@ template decodeBx(k: expr) {.immediate, dirty.} =
|
|||
let rbx = instr.regBx - wordExcess
|
||||
ensureKind(k)
|
||||
|
||||
proc compile(c: PCtx, s: PSym): int =
|
||||
result = vmgen.genProc(c, s)
|
||||
c.echoCode
|
||||
|
||||
proc myreset(n: PNode) =
|
||||
when defined(system.reset):
|
||||
var oldInfo = n.info
|
||||
|
|
@ -130,18 +134,14 @@ proc pushSafePoint(f: PStackFrame; pc: int) =
|
|||
|
||||
proc popSafePoint(f: PStackFrame) = discard f.safePoints.pop()
|
||||
|
||||
proc nextSafePoint(f: PStackFrame): int =
|
||||
var f = f
|
||||
while f.safePoints.isNil or f.safePoints.len == 0:
|
||||
f = f.next
|
||||
if f.isNil: return -1
|
||||
result = f.safePoints.pop
|
||||
|
||||
proc cleanUpOnException(c: PCtx; tos: PStackFrame; regs: TNodeSeq): int =
|
||||
let raisedType = c.currentExceptionA.typ.skipTypes(abstractPtrs)
|
||||
var f = tos
|
||||
while true:
|
||||
var pc2 = tos.nextSafePoint
|
||||
if pc2 == -1: return -1
|
||||
while f.safePoints.isNil or f.safePoints.len == 0:
|
||||
f = f.next
|
||||
if f.isNil: return -1
|
||||
var pc2 = f.safePoints[f.safePoints.high]
|
||||
|
||||
var nextExceptOrFinally = -1
|
||||
if c.code[pc2].opcode == opcExcept:
|
||||
|
|
@ -163,6 +163,8 @@ proc cleanUpOnException(c: PCtx; tos: PStackFrame; regs: TNodeSeq): int =
|
|||
if c.code[pc2].opcode == opcFinally:
|
||||
# execute the corresponding handler, but don't quit walking the stack:
|
||||
return pc2
|
||||
# not the right one:
|
||||
discard f.safePoints.pop
|
||||
|
||||
proc cleanUpOnReturn(c: PCtx; f: PStackFrame): int =
|
||||
if f.safePoints.isNil: return -1
|
||||
|
|
@ -174,6 +176,10 @@ proc cleanUpOnReturn(c: PCtx; f: PStackFrame): int =
|
|||
return pc
|
||||
return -1
|
||||
|
||||
proc compile(c: PCtx, s: PSym): int =
|
||||
result = vmgen.genProc(c, s)
|
||||
#c.echoCode
|
||||
|
||||
proc execute(c: PCtx, start: int) =
|
||||
var pc = start
|
||||
var regs: TNodeSeq # alias to tos.slots for performance
|
||||
|
|
@ -183,16 +189,17 @@ proc execute(c: PCtx, start: int) =
|
|||
{.interpreterLoop.}
|
||||
let instr = c.code[pc]
|
||||
let ra = instr.regA
|
||||
echo "PC ", pc, " ", c.code[pc].opcode, " ra ", ra
|
||||
#echo "PC ", pc, " ", c.code[pc].opcode, " ra ", ra
|
||||
case instr.opcode
|
||||
of opcEof: break
|
||||
of opcRet:
|
||||
# XXX perform any cleanup actions
|
||||
pc = tos.comesFrom
|
||||
tos = tos.next
|
||||
if tos.isNil: return
|
||||
|
||||
let retVal = regs[0]
|
||||
move(regs, tos.slots)
|
||||
pc = tos.comesFrom
|
||||
assert c.code[pc].opcode in {opcIndCall, opcIndCallAsgn}
|
||||
if c.code[pc].opcode == opcIndCallAsgn:
|
||||
regs[c.code[pc].regA] = retVal
|
||||
|
|
@ -222,6 +229,10 @@ proc execute(c: PCtx, start: int) =
|
|||
let idx = regs[rc].intVal
|
||||
# XXX what if the array is not 0-based? -> codegen should insert a sub
|
||||
regs[ra] = regs[rb].sons[idx.int]
|
||||
of opcLdStrIdx:
|
||||
decodeBC(nkIntLit)
|
||||
let idx = regs[rc].intVal
|
||||
regs[ra].intVal = regs[rb].strVal[idx.int].ord
|
||||
of opcWrArr:
|
||||
# a[b] = c
|
||||
let rb = instr.regB
|
||||
|
|
@ -277,7 +288,8 @@ proc execute(c: PCtx, start: int) =
|
|||
regs[ra].intVal = regs[rb].intVal - imm
|
||||
of opcLenSeq:
|
||||
decodeBImm(nkIntLit)
|
||||
assert regs[rb].kind == nkBracket
|
||||
#assert regs[rb].kind == nkBracket
|
||||
# also used by mNLen
|
||||
regs[ra].intVal = regs[rb].len - imm
|
||||
of opcLenStr:
|
||||
decodeBImm(nkIntLit)
|
||||
|
|
@ -432,6 +444,15 @@ proc execute(c: PCtx, start: int) =
|
|||
regs[ra].strVal = getstr(regs[rb])
|
||||
for i in rb+1..rb+rc-1:
|
||||
regs[ra].strVal.add getstr(regs[i])
|
||||
of opcAddStrCh:
|
||||
decodeB(nkStrLit)
|
||||
regs[ra].strVal.add(regs[rb].intVal.chr)
|
||||
of opcAddStrStr:
|
||||
decodeB(nkStrLit)
|
||||
regs[ra].strVal.add(regs[rb].strVal)
|
||||
of opcAddSeqElem:
|
||||
decodeB(nkBracket)
|
||||
regs[ra].add(copyTree(regs[rb]))
|
||||
of opcEcho:
|
||||
echo regs[ra].strVal
|
||||
of opcContainsSet:
|
||||
|
|
@ -444,6 +465,14 @@ proc execute(c: PCtx, start: int) =
|
|||
let rd = c.code[pc].regA
|
||||
regs[ra].strVal = substr(regs[rb].strVal, regs[rc].intVal.int,
|
||||
regs[rd].intVal.int)
|
||||
of opcRangeChck:
|
||||
let rb = instr.regB
|
||||
let rc = instr.regC
|
||||
if not (leValueConv(regs[rb], regs[ra]) and
|
||||
leValueConv(regs[ra], regs[rc])):
|
||||
stackTrace(c, tos, pc, errGenerated,
|
||||
msgKindToString(errIllegalConvFromXtoY) % [
|
||||
"unknown type" , "unknown type"])
|
||||
of opcIndCall, opcIndCallAsgn:
|
||||
# dest = call regStart, n; where regStart = fn, arg1, ...
|
||||
let rb = instr.regB
|
||||
|
|
@ -462,7 +491,8 @@ proc execute(c: PCtx, start: int) =
|
|||
newFrame.slots[i] = newNode(nkEmpty)
|
||||
tos = newFrame
|
||||
move(regs, newFrame.slots)
|
||||
pc = newPc
|
||||
# -1 for the following 'inc pc'
|
||||
pc = newPc-1
|
||||
of opcTJmp:
|
||||
# jump Bx if A != 0
|
||||
let rbx = instr.regBx - wordExcess - 1 # -1 for the following 'inc pc'
|
||||
|
|
@ -544,10 +574,95 @@ proc execute(c: PCtx, start: int) =
|
|||
regs[ra] = getNullValue(typ, c.debug[pc])
|
||||
of opcLdConst:
|
||||
regs[ra] = c.constants.sons[instr.regBx - wordExcess]
|
||||
of opcAsgnConst:
|
||||
let rb = instr.regBx - wordExcess
|
||||
if regs[ra].isNil:
|
||||
regs[ra] = copyTree(c.constants.sons[rb])
|
||||
else:
|
||||
asgnComplex(regs[ra], c.constants.sons[rb])
|
||||
of opcNBindSym:
|
||||
# trivial implementation:
|
||||
let rb = instr.regB
|
||||
regs[ra] = regs[rb].sons[1]
|
||||
of opcNChild:
|
||||
let rb = instr.regB
|
||||
let rc = instr.regC
|
||||
regs[ra] = regs[rb].sons[regs[rc].intVal.int]
|
||||
of opcNSetChild:
|
||||
let rb = instr.regB
|
||||
let rc = instr.regC
|
||||
regs[ra].sons[regs[rb].intVal.int] = regs[rc]
|
||||
of opcNAdd:
|
||||
declBC()
|
||||
regs[rb].add(regs[rb])
|
||||
regs[ra] = regs[rb]
|
||||
of opcNAddMultiple:
|
||||
declBC()
|
||||
let x = regs[rc]
|
||||
# XXX can be optimized:
|
||||
for i in 0.. <x.len: regs[rb].add(x.sons[i])
|
||||
regs[ra] = regs[rb]
|
||||
of opcNKind:
|
||||
decodeB(nkIntLit)
|
||||
regs[ra].intVal = ord(regs[rb].kind)
|
||||
of opcNIntVal:
|
||||
decodeB(nkIntLit)
|
||||
let a = regs[rb]
|
||||
case a.kind
|
||||
of nkCharLit..nkInt64Lit: regs[ra].intVal = a.intVal
|
||||
else: stackTrace(c, tos, pc, errFieldXNotFound, "intVal")
|
||||
of opcNFloatVal:
|
||||
decodeB(nkFloatLit)
|
||||
let a = regs[rb]
|
||||
case a.kind
|
||||
of nkFloatLit..nkFloat64Lit: regs[ra].floatVal = a.floatVal
|
||||
else: stackTrace(c, tos, pc, errFieldXNotFound, "floatVal")
|
||||
of opcNSymbol:
|
||||
let rb = instr.regB
|
||||
if regs[rb].kind != nkSym:
|
||||
stackTrace(c, tos, pc, errFieldXNotFound, "symbol")
|
||||
regs[ra] = regs[rb]
|
||||
of opcNIdent:
|
||||
let rb = instr.regB
|
||||
if regs[rb].kind != nkIdent:
|
||||
stackTrace(c, tos, pc, errFieldXNotFound, "ident")
|
||||
regs[ra] = regs[rb]
|
||||
of opcNGetType:
|
||||
InternalError(c.debug[pc], "unknown opcode " & $instr.opcode)
|
||||
of opcNStrVal:
|
||||
decodeB(nkStrLit)
|
||||
let a = regs[rb]
|
||||
case a.kind
|
||||
of nkStrLit..nkTripleStrLit: regs[ra].strVal = a.strVal
|
||||
else: stackTrace(c, tos, pc, errFieldXNotFound, "strVal")
|
||||
of opcSlurp:
|
||||
decodeB(nkStrLit)
|
||||
regs[ra].strVal = opSlurp(regs[rb].strVal, c.debug[pc], c.module)
|
||||
of opcGorge:
|
||||
decodeBC(nkStrLit)
|
||||
regs[ra].strVal = opGorge(regs[rb].strVal, regs[rc].strVal)
|
||||
of opcNError:
|
||||
stackTrace(c, tos, pc, errUser, regs[ra].strVal)
|
||||
of opcNWarning:
|
||||
Message(c.debug[pc], warnUser, regs[ra].strVal)
|
||||
of opcNHint:
|
||||
Message(c.debug[pc], hintUser, regs[ra].strVal)
|
||||
of opcParseExprToAst:
|
||||
let rb = instr.regB
|
||||
# c.debug[pc].line.int - countLines(regs[rb].strVal) ?
|
||||
let ast = parseString(regs[rb].strVal, c.debug[pc].toFilename,
|
||||
c.debug[pc].line.int)
|
||||
if sonsLen(ast) != 1:
|
||||
GlobalError(c.debug[pc], errExprExpected, "multiple statements")
|
||||
regs[ra] = ast.sons[0]
|
||||
of opcParseStmtToAst:
|
||||
let rb = instr.regB
|
||||
let ast = parseString(regs[rb].strVal, c.debug[pc].toFilename,
|
||||
c.debug[pc].line.int)
|
||||
regs[ra] = ast
|
||||
of opcCallSite:
|
||||
if c.callsite != nil: regs[ra] = c.callsite
|
||||
else: stackTrace(c, tos, pc, errFieldXNotFound, "callsite")
|
||||
else:
|
||||
InternalError(c.debug[pc], "unknown opcode " & $instr.opcode)
|
||||
inc pc
|
||||
|
|
@ -566,7 +681,7 @@ proc myOpen(module: PSym): PPassContext =
|
|||
#var c = newEvalContext(module, emRepl)
|
||||
#c.features = {allowCast, allowFFI, allowInfiniteLoops}
|
||||
#pushStackFrame(c, newStackFrame())
|
||||
result = newCtx()
|
||||
result = newCtx(module)
|
||||
|
||||
var oldErrorCount: int
|
||||
|
||||
|
|
|
|||
|
|
@ -21,10 +21,6 @@ type
|
|||
TDest* = range[-1 .. 255]
|
||||
TInstr* = distinct uint32
|
||||
|
||||
TInstrFormat = enum
|
||||
ifABC, # three registers
|
||||
ifABx, # A + extended B
|
||||
|
||||
TOpcode* = enum
|
||||
opcEof, # end of code
|
||||
opcRet, # return
|
||||
|
|
@ -46,6 +42,7 @@ type
|
|||
opcAddr,
|
||||
opcDeref,
|
||||
opcWrStrIdx,
|
||||
opcLdStrIdx, # a = b[c]
|
||||
|
||||
opcAddInt,
|
||||
opcAddImmInt,
|
||||
|
|
@ -66,12 +63,39 @@ type
|
|||
opcSwap, opcIsNil, opcOf,
|
||||
opcSubStr, opcConv, opcCast, opcQuit, opcReset,
|
||||
|
||||
opcAddStrCh,
|
||||
opcAddStrStr,
|
||||
opcAddSeqElem,
|
||||
opcRangeChck,
|
||||
|
||||
opcNAdd,
|
||||
opcNAddMultiple,
|
||||
opcNKind,
|
||||
opcNIntVal,
|
||||
opcNFloatVal,
|
||||
opcNSymbol,
|
||||
opcNIdent,
|
||||
opcNGetType,
|
||||
opcNStrVal,
|
||||
|
||||
opcSlurp,
|
||||
opcGorge,
|
||||
opcParseExprToAst,
|
||||
opcParseStmtToAst,
|
||||
opcNError,
|
||||
opcNWarning,
|
||||
opcNHint,
|
||||
|
||||
opcEcho,
|
||||
opcIndCall, # dest = call regStart, n; where regStart = fn, arg1, ...
|
||||
opcIndCallAsgn, # dest = call regStart, n; where regStart = fn, arg1, ...
|
||||
|
||||
opcRaise,
|
||||
opcNChild,
|
||||
opcNSetChild,
|
||||
opcNBindSym, # opcodes for the AST manipulation following
|
||||
opcCallSite,
|
||||
opcNewStr,
|
||||
|
||||
opcTJmp, # jump Bx if A != 0
|
||||
opcFJmp, # jump Bx if A == 0
|
||||
|
|
@ -83,9 +107,9 @@ type
|
|||
opcFinallyEnd,
|
||||
opcNew,
|
||||
opcNewSeq,
|
||||
opcNewStr,
|
||||
opcLdNull, # dest = nullvalue(types[Bx])
|
||||
opcLdConst, # dest = constants[Bx]
|
||||
opcAsgnConst, # dest = copy(constants[Bx])
|
||||
opcLdGlobal, # dest = globals[Bx]
|
||||
opcLdImmInt, # dest = immediate value
|
||||
opcWrGlobal,
|
||||
|
|
@ -100,7 +124,8 @@ type
|
|||
# temporary slot usage. This is required for the parameter
|
||||
# passing implementation.
|
||||
slotEmpty, # slot is unused
|
||||
slotFixed, # slot is used for a fixed var/param/result
|
||||
slotFixedVar, # slot is used for a fixed var/result (requires copy then)
|
||||
slotFixedLet, # slot is used for a fixed param/let
|
||||
slotTempUnknown, # slot but type unknown (argument of proc call)
|
||||
slotTempInt, # some temporary int
|
||||
slotTempFloat, # some temporary float
|
||||
|
|
@ -117,30 +142,28 @@ type
|
|||
code*: seq[TInstr]
|
||||
debug*: seq[TLineInfo] # line info for every instruction; kept separate
|
||||
# to not slow down interpretation
|
||||
jumpTargets*: TIntSet # we need to mark instructions that are
|
||||
# jump targets;
|
||||
# we must not optimize over a jump target and we
|
||||
# need to generate a label for a jump target when
|
||||
# producing a VM listing
|
||||
globals*: PNode #
|
||||
constants*: PNode # constant data
|
||||
types*: seq[PType] # some instructions reference types (e.g. 'except')
|
||||
currentExceptionA*, currentExceptionB*: PNode
|
||||
exceptionInstr*: int # index of instruction that raised the exception
|
||||
prc*: PProc
|
||||
module*: PSym
|
||||
callsite*: PNode
|
||||
|
||||
TPosition* = distinct int
|
||||
|
||||
proc newCtx*(): PCtx =
|
||||
PCtx(code: @[], debug: @[], jumpTargets: initIntSet(),
|
||||
proc newCtx*(module: PSym): PCtx =
|
||||
PCtx(code: @[], debug: @[],
|
||||
globals: newNode(nkStmtList), constants: newNode(nkStmtList), types: @[],
|
||||
prc: PProc(blocks: @[]))
|
||||
prc: PProc(blocks: @[]), module: module)
|
||||
|
||||
const
|
||||
firstABxInstr* = opcTJmp
|
||||
largeInstrs* = { # instructions which use 2 int32s instead of 1:
|
||||
opcSubstr, opcConv, opcCast, opcNewSeq, opcOf}
|
||||
slotSomeTemp* = slotTempUnknown
|
||||
relativeJumps* = {opcTJmp, opcFJmp, opcJmp}
|
||||
|
||||
template opcode*(x: TInstr): TOpcode {.immediate.} = TOpcode(x.uint32 and 0xff'u32)
|
||||
template regA*(x: TInstr): TRegister {.immediate.} = TRegister(x.uint32 shr 8'u32 and 0xff'u32)
|
||||
|
|
|
|||
108
compiler/vmdeps.nim
Normal file
108
compiler/vmdeps.nim
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
#
|
||||
#
|
||||
# The Nimrod Compiler
|
||||
# (c) Copyright 2013 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
import ast, msgs, osproc, streams, options
|
||||
|
||||
proc readOutput(p: PProcess): string =
|
||||
result = ""
|
||||
var output = p.outputStream
|
||||
discard p.waitForExit
|
||||
while not output.atEnd:
|
||||
result.add(output.readLine)
|
||||
|
||||
proc opGorge*(cmd, input: string): string =
|
||||
var p = startCmd(cmd)
|
||||
if input.len != 0:
|
||||
p.inputStream.write(input)
|
||||
p.inputStream.close()
|
||||
result = p.readOutput
|
||||
|
||||
proc opSlurp*(file: string, info: TLineInfo, module: PSym): string =
|
||||
try:
|
||||
let filename = file.FindFile
|
||||
result = readFile(filename)
|
||||
# we produce a fake include statement for every slurped filename, so that
|
||||
# the module dependencies are accurate:
|
||||
appendToModule(module, newNode(nkIncludeStmt, info, @[
|
||||
newStrNode(nkStrLit, filename)]))
|
||||
except EIO:
|
||||
result = ""
|
||||
LocalError(info, errCannotOpenFile, file)
|
||||
|
||||
when false:
|
||||
proc opExpandToAst*(c: PEvalContext, original: PNode): PNode =
|
||||
var
|
||||
n = original.copyTree
|
||||
macroCall = n.sons[1]
|
||||
expandedSym = macroCall.sons[0].sym
|
||||
|
||||
for i in countup(1, macroCall.sonsLen - 1):
|
||||
macroCall.sons[i] = evalAux(c, macroCall.sons[i], {})
|
||||
|
||||
case expandedSym.kind
|
||||
of skTemplate:
|
||||
let genSymOwner = if c.tos != nil and c.tos.prc != nil:
|
||||
c.tos.prc
|
||||
else:
|
||||
c.module
|
||||
result = evalTemplate(macroCall, expandedSym, genSymOwner)
|
||||
of skMacro:
|
||||
# At this point macroCall.sons[0] is nkSym node.
|
||||
# To be completely compatible with normal macro invocation,
|
||||
# we want to replace it with nkIdent node featuring
|
||||
# the original unmangled macro name.
|
||||
macroCall.sons[0] = newIdentNode(expandedSym.name, expandedSym.info)
|
||||
result = evalMacroCall(c, macroCall, original, expandedSym)
|
||||
else:
|
||||
InternalError(macroCall.info,
|
||||
"ExpandToAst: expanded symbol is no macro or template")
|
||||
result = emptyNode
|
||||
|
||||
proc opTypeTrait*(n: PNode, context: PSym): PNode =
|
||||
## XXX: This should be pretty much guaranteed to be true
|
||||
# by the type traits procs' signatures, but until the
|
||||
# code is more mature it doesn't hurt to be extra safe
|
||||
internalAssert n.len >= 2 and n.sons[1].kind == nkSym
|
||||
|
||||
let typ = n.sons[1].sym.typ.skipTypes({tyTypeDesc})
|
||||
case n.sons[0].sym.name.s.normalize
|
||||
of "name":
|
||||
result = newStrNode(nkStrLit, typ.typeToString(preferExported))
|
||||
result.typ = newType(tyString, context)
|
||||
result.info = n.info
|
||||
else:
|
||||
internalAssert false
|
||||
|
||||
proc opIs*(n: PNode): PNode =
|
||||
InternalAssert n.sonsLen == 3 and
|
||||
n[1].kind == nkSym and n[1].sym.kind == skType and
|
||||
n[2].kind in {nkStrLit..nkTripleStrLit, nkType}
|
||||
|
||||
let t1 = n[1].sym.typ
|
||||
|
||||
if n[2].kind in {nkStrLit..nkTripleStrLit}:
|
||||
case n[2].strVal.normalize
|
||||
of "closure":
|
||||
let t = skipTypes(t1, abstractRange)
|
||||
result = newIntNode(nkIntLit, ord(t.kind == tyProc and
|
||||
t.callConv == ccClosure and
|
||||
tfIterator notin t.flags))
|
||||
of "iterator":
|
||||
let t = skipTypes(t1, abstractRange)
|
||||
result = newIntNode(nkIntLit, ord(t.kind == tyProc and
|
||||
t.callConv == ccClosure and
|
||||
tfIterator in t.flags))
|
||||
else:
|
||||
let t2 = n[2].typ
|
||||
var match = if t2.kind == tyTypeClass: matchTypeClass(t2, t1)
|
||||
else: sameType(t1, t2)
|
||||
result = newIntNode(nkIntLit, ord(match))
|
||||
|
||||
result.typ = n.typ
|
||||
|
||||
|
|
@ -14,18 +14,32 @@ import
|
|||
trees, intsets, rodread
|
||||
|
||||
proc codeListing(c: PCtx, result: var string) =
|
||||
# first iteration: compute all necessary labels:
|
||||
var jumpTargets = initIntSet()
|
||||
|
||||
for i in 0.. < c.code.len:
|
||||
let x = c.code[i]
|
||||
if x.opcode in relativeJumps:
|
||||
jumpTargets.incl(i+x.regBx-wordExcess)
|
||||
|
||||
# for debugging purposes
|
||||
var i = 0
|
||||
while i < c.code.len:
|
||||
if i in c.jumpTargets: result.addf("L$1:\n", i)
|
||||
if i in jumpTargets: result.addf("L$1:\n", i)
|
||||
let x = c.code[i]
|
||||
|
||||
let opc = opcode(x)
|
||||
if opc < firstABxInstr:
|
||||
result.addf("\t$#\tr$#, r$#, r$#", ($opc).substr(3), x.regA,
|
||||
x.regB, x.regC)
|
||||
elif opc in relativeJumps:
|
||||
result.addf("\t$#\tr$#, L$#", ($opc).substr(3), x.regA,
|
||||
i+x.regBx-wordExcess)
|
||||
elif opc in {opcLdConst, opcAsgnConst}:
|
||||
result.addf("\t$#\tr$#, $#", ($opc).substr(3), x.regA,
|
||||
c.constants[x.regBx-wordExcess].renderTree)
|
||||
else:
|
||||
result.addf("\t$#\tr$#, r$#", ($opc).substr(3), x.regA, x.regBx-wordExcess)
|
||||
result.addf("\t$#\tr$#, $#", ($opc).substr(3), x.regA, x.regBx-wordExcess)
|
||||
result.add("\t#")
|
||||
result.add(toFileLine(c.debug[i]))
|
||||
result.add("\n")
|
||||
|
|
@ -64,9 +78,9 @@ proc xjmp(c: PCtx; n: PNode; opc: TOpcode; a: TRegister = 0): TPosition =
|
|||
|
||||
proc genLabel(c: PCtx): TPosition =
|
||||
result = TPosition(c.code.len)
|
||||
c.jumpTargets.incl(c.code.len)
|
||||
#c.jumpTargets.incl(c.code.len)
|
||||
|
||||
proc jmp(c: PCtx, n: PNode, opc: TOpcode, p = TPosition(0)) =
|
||||
proc jmpBack(c: PCtx, n: PNode, opc: TOpcode, p = TPosition(0)) =
|
||||
let dist = p.int - c.code.len
|
||||
InternalAssert(-0x7fff < dist and dist < 0x7fff)
|
||||
gABx(c, n, opc, 0, dist)
|
||||
|
|
@ -75,12 +89,12 @@ proc patch(c: PCtx, p: TPosition) =
|
|||
# patch with current index
|
||||
let p = p.int
|
||||
let diff = c.code.len - p
|
||||
c.jumpTargets.incl(c.code.len)
|
||||
#c.jumpTargets.incl(c.code.len)
|
||||
InternalAssert(-0x7fff < diff and diff < 0x7fff)
|
||||
let oldInstr = c.code[p]
|
||||
# opcode and regA stay the same:
|
||||
c.code[p] = ((oldInstr.uint32 and 0xffff'u32) or
|
||||
uint32(diff+wordExcess) shr 16'u32).TInstr
|
||||
c.code[p] = ((oldInstr.uint32 and 0xffff'u32).uint32 or
|
||||
uint32(diff+wordExcess) shl 16'u32).TInstr
|
||||
|
||||
proc getSlotKind(t: PType): TSlotKind =
|
||||
case t.skipTypes(abstractRange).kind
|
||||
|
|
@ -185,7 +199,7 @@ proc genWhile(c: PCtx; n: PNode) =
|
|||
let L2 = c.xjmp(n, opcFJmp, tmp)
|
||||
c.freeTemp(tmp)
|
||||
c.gen(n.sons[1])
|
||||
c.jmp(n, opcJmp, L1)
|
||||
c.jmpBack(n, opcJmp, L1)
|
||||
c.patch(L2)
|
||||
|
||||
proc genBlock(c: PCtx; n: PNode; dest: var TDest) =
|
||||
|
|
@ -195,10 +209,11 @@ proc genBlock(c: PCtx; n: PNode; dest: var TDest) =
|
|||
proc genBreak(c: PCtx; n: PNode) =
|
||||
let L1 = c.xjmp(n, opcJmp)
|
||||
if n.sons[0].kind == nkSym:
|
||||
echo cast[int](n.sons[0].sym)
|
||||
for i in countdown(c.prc.blocks.len-1, 0):
|
||||
if c.prc.blocks[i].label == n.sons[0].sym:
|
||||
c.prc.blocks[i].fixups.add L1
|
||||
break
|
||||
return
|
||||
InternalError(n.info, "cannot find 'break' target")
|
||||
else:
|
||||
c.prc.blocks[c.prc.blocks.high].fixups.add L1
|
||||
|
|
@ -222,7 +237,7 @@ proc genIf(c: PCtx, n: PNode; dest: var TDest) =
|
|||
withTemp(tmp, it.sons[0].typ):
|
||||
c.gen(it.sons[0], tmp)
|
||||
let elsePos = c.xjmp(it.sons[0], opcFJmp, tmp) # if false
|
||||
c.gen(n.sons[1], dest) # then part
|
||||
c.gen(it.sons[1], dest) # then part
|
||||
if i < sonsLen(n)-1:
|
||||
endings.add(c.xjmp(it.sons[1], opcJmp, 0))
|
||||
c.patch(elsePos)
|
||||
|
|
@ -365,7 +380,10 @@ proc genCall(c: PCtx; n: PNode; dest: var TDest) =
|
|||
|
||||
proc genNew(c: PCtx; n: PNode) =
|
||||
let dest = c.genx(n.sons[1])
|
||||
c.gABx(n, opcNew, dest, c.genType(n.sons[1].typ.skipTypes(abstractVar)))
|
||||
# we use the ref's base type here as the VM conflates 'ref object'
|
||||
# and 'object' since internally we already have a pointer.
|
||||
c.gABx(n, opcNew, dest,
|
||||
c.genType(n.sons[1].typ.skipTypes(abstractVar).sons[0]))
|
||||
c.freeTemp(dest)
|
||||
|
||||
proc genNewSeq(c: PCtx; n: PNode) =
|
||||
|
|
@ -382,6 +400,12 @@ proc genUnaryABC(c: PCtx; n: PNode; dest: var TDest; opc: TOpcode) =
|
|||
c.gABC(n, opc, dest, tmp)
|
||||
c.freeTemp(tmp)
|
||||
|
||||
proc genUnaryABI(c: PCtx; n: PNode; dest: var TDest; opc: TOpcode) =
|
||||
let tmp = c.genx(n.sons[1])
|
||||
if dest < 0: dest = c.getTemp(n.typ)
|
||||
c.gABI(n, opc, dest, tmp, 0)
|
||||
c.freeTemp(tmp)
|
||||
|
||||
proc genBinaryABC(c: PCtx; n: PNode; dest: var TDest; opc: TOpcode) =
|
||||
let
|
||||
tmp = c.genx(n.sons[1])
|
||||
|
|
@ -391,6 +415,18 @@ proc genBinaryABC(c: PCtx; n: PNode; dest: var TDest; opc: TOpcode) =
|
|||
c.freeTemp(tmp)
|
||||
c.freeTemp(tmp2)
|
||||
|
||||
proc genBinaryStmt(c: PCtx; n: PNode; opc: TOpcode) =
|
||||
let
|
||||
dest = c.genx(n.sons[1])
|
||||
tmp = c.genx(n.sons[2])
|
||||
c.gABC(n, opc, dest, tmp, 0)
|
||||
c.freeTemp(tmp)
|
||||
|
||||
proc genUnaryStmt(c: PCtx; n: PNode; opc: TOpcode) =
|
||||
let tmp = c.genx(n.sons[2])
|
||||
c.gABC(n, opc, tmp, 0, 0)
|
||||
c.freeTemp(tmp)
|
||||
|
||||
proc genVarargsABC(c: PCtx; n: PNode; dest: var TDest; opc: TOpcode) =
|
||||
if dest < 0: dest = getTemp(c, n.typ)
|
||||
var x = c.getTempRange(n.len-1, slotTempStr)
|
||||
|
|
@ -465,9 +501,9 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest) =
|
|||
c.gABC(n, opcNewStr, dest, tmp)
|
||||
c.freeTemp(tmp)
|
||||
of mLengthOpenArray, mLengthArray, mLengthSeq:
|
||||
genUnaryABC(c, n, dest, opcLenSeq)
|
||||
genUnaryABI(c, n, dest, opcLenSeq)
|
||||
of mLengthStr:
|
||||
genUnaryABC(c, n, dest, opcLenStr)
|
||||
genUnaryABI(c, n, dest, opcLenStr)
|
||||
of mIncl, mExcl:
|
||||
unused(n, dest)
|
||||
var d = c.genx(n.sons[1])
|
||||
|
|
@ -596,29 +632,47 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest) =
|
|||
var d = c.genx(n.sons[i])
|
||||
c.gABC(n, opcEcho, d)
|
||||
c.freeTemp(d)
|
||||
of mAppendStrCh: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mAppendStrStr: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mAppendSeqElem: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mParseExprToAst: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mParseStmtToAst: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mAppendStrCh:
|
||||
unused(n, dest)
|
||||
genBinaryStmt(c, n, opcAddStrCh)
|
||||
of mAppendStrStr:
|
||||
unused(n, dest)
|
||||
genBinaryStmt(c, n, opcAddStrStr)
|
||||
of mAppendSeqElem:
|
||||
unused(n, dest)
|
||||
genBinaryStmt(c, n, opcAddSeqElem)
|
||||
of mParseExprToAst:
|
||||
genUnaryABC(c, n, dest, opcParseExprToAst)
|
||||
of mParseStmtToAst:
|
||||
genUnaryABC(c, n, dest, opcParseStmtToAst)
|
||||
of mExpandToAst: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mTypeTrait: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mIs: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mSlurp: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mStaticExec: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNLen: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNChild: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNSetChild: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNAdd: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNAddMultiple: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNDel: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNKind: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNIntVal: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNFloatVal: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNSymbol: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNIdent: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNGetType: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNStrVal: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mSlurp: genUnaryABC(c, n, dest, opcSlurp)
|
||||
of mStaticExec: genBinaryABC(c, n, dest, opcGorge)
|
||||
of mNLen: genUnaryABI(c, n, dest, opcLenSeq)
|
||||
of mNChild: genBinaryABC(c, n, dest, opcNChild)
|
||||
of mNSetChild:
|
||||
unused(n, dest)
|
||||
var
|
||||
tmp1 = c.genx(n.sons[1])
|
||||
tmp2 = c.genx(n.sons[2])
|
||||
tmp3 = c.genx(n.sons[3])
|
||||
c.gABC(n, opcNSetChild, tmp1, tmp2, tmp3)
|
||||
c.freeTemp(tmp1)
|
||||
c.freeTemp(tmp2)
|
||||
c.freeTemp(tmp3)
|
||||
of mNAdd: genBinaryABC(c, n, dest, opcNAdd)
|
||||
of mNAddMultiple: genBinaryABC(c, n, dest, opcNAddMultiple)
|
||||
of mNDel:
|
||||
InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNKind: genUnaryABC(c, n, dest, opcNKind)
|
||||
of mNIntVal: genUnaryABC(c, n, dest, opcNIntVal)
|
||||
of mNFloatVal: genUnaryABC(c, n, dest, opcNFloatVal)
|
||||
of mNSymbol: genUnaryABC(c, n, dest, opcNSymbol)
|
||||
of mNIdent: genUnaryABC(c, n, dest, opcNIdent)
|
||||
of mNGetType: genUnaryABC(c, n, dest, opcNGetType)
|
||||
of mNStrVal: genUnaryABC(c, n, dest, opcNStrVal)
|
||||
of mNSetIntVal: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNSetFloatVal: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNSetSymbol: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
|
|
@ -628,16 +682,24 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest) =
|
|||
of mNNewNimNode: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNCopyNimNode: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNCopyNimTree: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNBindSym: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNBindSym: genUnaryABC(c, n, dest, opcNBindSym)
|
||||
of mStrToIdent: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mIdentToStr: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mEqIdent: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mEqNimrodNode: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNLineInfo: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNHint: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNWarning: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNError: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNCallSite: InternalError(n.info, "cannot generate code for: " & $m)
|
||||
of mNHint:
|
||||
unused(n, dest)
|
||||
genUnaryStmt(c, n, opcNHint)
|
||||
of mNWarning:
|
||||
unused(n, dest)
|
||||
genUnaryStmt(c, n, opcNWarning)
|
||||
of mNError:
|
||||
unused(n, dest)
|
||||
genUnaryStmt(c, n, opcNError)
|
||||
of mNCallSite:
|
||||
if dest < 0: dest = c.getTemp(n.typ)
|
||||
c.gABC(n, opcCallSite, dest)
|
||||
else:
|
||||
# XXX get rid of these: mMinI, mMaxI, mMinI64, mMaxI64, mMinF64, mMaxF64
|
||||
# mGCref, mGCunref, mEqCString, mAbsI, mAbsI64, mAbsF64
|
||||
|
|
@ -664,18 +726,18 @@ proc requiresCopy(n: PNode): bool =
|
|||
else:
|
||||
result = true
|
||||
|
||||
proc unnecessaryIndirection(n: PNode): bool =
|
||||
proc unneededIndirection(n: PNode): bool =
|
||||
n.typ.skipTypes(abstractInst).kind == tyRef
|
||||
|
||||
proc skipDeref(n: PNode): PNode =
|
||||
if n.kind in {nkDerefExpr, nkHiddenDeref} and unnecessaryIndirection(n):
|
||||
if n.kind in {nkDerefExpr, nkHiddenDeref} and unneededIndirection(n.sons[0]):
|
||||
result = n.sons[0]
|
||||
else:
|
||||
result = n
|
||||
|
||||
proc genAddrDeref(c: PCtx; n: PNode; dest: var TDest; opc: TOpcode) =
|
||||
# a nop for certain types
|
||||
if unnecessaryIndirection(n):
|
||||
if unneededIndirection(n.sons[0]):
|
||||
gen(c, n.sons[0], dest)
|
||||
else:
|
||||
let tmp = c.genx(n.sons[0])
|
||||
|
|
@ -740,9 +802,11 @@ proc genAsgn(c: PCtx; le, ri: PNode; requiresCopy: bool) =
|
|||
genAsgn(c, dest, ri, requiresCopy)
|
||||
|
||||
proc genLit(c: PCtx; n: PNode; dest: var TDest) =
|
||||
var opc = opcLdConst
|
||||
if dest < 0: dest = c.getTemp(n.typ)
|
||||
elif c.prc.slots[dest].kind == slotFixedVar: opc = opcAsgnConst
|
||||
let lit = genLiteral(c, n)
|
||||
c.gABx(n, opcLdConst, dest, lit)
|
||||
c.gABx(n, opc, dest, lit)
|
||||
|
||||
proc genRdVar(c: PCtx; n: PNode; dest: var TDest) =
|
||||
let s = n.sym
|
||||
|
|
@ -775,7 +839,10 @@ proc genObjAccess(c: PCtx; n: PNode; dest: var TDest) =
|
|||
genAccess(c, n, dest, opcLdObj)
|
||||
|
||||
proc genArrAccess(c: PCtx; n: PNode; dest: var TDest) =
|
||||
genAccess(c, n, dest, opcLdArr)
|
||||
if n.sons[0].typ.skipTypes(abstractVarRange).kind in {tyString, tyCString}:
|
||||
genAccess(c, n, dest, opcLdStrIdx)
|
||||
else:
|
||||
genAccess(c, n, dest, opcLdArr)
|
||||
|
||||
proc getNullValue*(typ: PType, info: TLineInfo): PNode
|
||||
proc getNullValueAux(obj: PNode, result: PNode) =
|
||||
|
|
@ -827,7 +894,8 @@ proc setSlot(c: PCtx; v: PSym) =
|
|||
# XXX generate type initialization here?
|
||||
if v.position == 0:
|
||||
v.position = c.prc.maxSlots
|
||||
c.prc.slots[v.position] = (inUse: true, kind: slotFixed)
|
||||
c.prc.slots[v.position] = (inUse: true,
|
||||
kind: if v.kind == skLet: slotFixedLet else: slotFixedVar)
|
||||
inc c.prc.maxSlots
|
||||
|
||||
proc genVarSection(c: PCtx; n: PNode) =
|
||||
|
|
@ -959,36 +1027,56 @@ proc gen(c: PCtx; n: PNode; dest: var TDest) =
|
|||
let s = n.sons[namePos].sym
|
||||
discard genProc(c, s)
|
||||
genLit(c, n.sons[namePos], dest)
|
||||
of nkChckRangeF, nkChckRange64, nkChckRange:
|
||||
let
|
||||
tmp0 = c.genx(n.sons[0])
|
||||
tmp1 = c.genx(n.sons[1])
|
||||
tmp2 = c.genx(n.sons[2])
|
||||
c.gABC(n, opcRangeChck, tmp0, tmp1, tmp2)
|
||||
c.freeTemp(tmp1)
|
||||
c.freeTemp(tmp2)
|
||||
if dest >= 0:
|
||||
gABC(c, n, whichAsgnOpc(n), dest, tmp0)
|
||||
c.freeTemp(tmp0)
|
||||
else:
|
||||
dest = tmp0
|
||||
of nkEmpty, nkCommentStmt, nkTypeSection, nkConstSection, nkPragma,
|
||||
nkTemplateDef, nkIncludeStmt, nkImportStmt:
|
||||
unused(n, dest)
|
||||
of nkStringToCString, nkCStringToString:
|
||||
gen(c, n.sons[0], dest)
|
||||
else:
|
||||
#of nkCurly, nkBracket, nkPar:
|
||||
InternalError n.info, "too implement " & $n.kind
|
||||
|
||||
proc genStmt*(c: PCtx; n: PNode): int =
|
||||
result = c.code.len
|
||||
var d: TDest = -1
|
||||
gen(c, n, d)
|
||||
proc removeLastEof(c: PCtx) =
|
||||
let last = c.code.len-1
|
||||
if last >= 0 and c.code[last].opcode == opcEof:
|
||||
# since we can re-use the EOF nothing happened:
|
||||
result = last
|
||||
else:
|
||||
gABC(c, n, opcEof)
|
||||
# overwrite last EOF:
|
||||
assert c.code.len == c.debug.len
|
||||
c.code.setLen(last)
|
||||
c.debug.setLen(last)
|
||||
|
||||
proc genStmt*(c: PCtx; n: PNode): int =
|
||||
c.removeLastEof
|
||||
result = c.code.len
|
||||
var d: TDest = -1
|
||||
c.gen(n, d)
|
||||
c.gABC(n, opcEof)
|
||||
InternalAssert d < 0
|
||||
|
||||
proc genParams(c: PCtx; params: PNode) =
|
||||
# res.sym.position is already 0
|
||||
c.prc.slots[0] = (inUse: true, kind: slotFixed)
|
||||
c.prc.slots[0] = (inUse: true, kind: slotFixedVar)
|
||||
for i in 1.. <params.len:
|
||||
let param = params.sons[i].sym
|
||||
c.prc.slots[i] = (inUse: true, kind: slotFixed)
|
||||
c.prc.slots[i] = (inUse: true, kind: slotFixedLet)
|
||||
c.prc.maxSlots = max(params.len, 1)
|
||||
|
||||
proc genProc(c: PCtx; s: PSym): int =
|
||||
let x = s.ast.sons[optimizedCodePos]
|
||||
if x.kind == nkEmpty:
|
||||
c.removeLastEof
|
||||
result = c.code.len+1 # skip the jump instruction
|
||||
s.ast.sons[optimizedCodePos] = newIntNode(nkIntLit, result)
|
||||
# thanks to the jmp we can add top level statements easily and also nest
|
||||
|
|
@ -1004,6 +1092,7 @@ proc genProc(c: PCtx; s: PSym): int =
|
|||
# generate final 'return' statement:
|
||||
c.gABC(body, opcRet)
|
||||
c.patch(procStart)
|
||||
c.gABC(body, opcEof)
|
||||
s.position = c.prc.maxSlots
|
||||
c.prc = oldPrc
|
||||
else:
|
||||
|
|
|
|||
9
config/rename.rules.cfg
Normal file
9
config/rename.rules.cfg
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
TSignedInt
|
||||
TUnsignedInt
|
||||
TOrdinal
|
||||
TReal
|
||||
TNumber
|
||||
TEnum
|
||||
TObject
|
||||
TResult
|
||||
TOpenArray
|
||||
|
|
@ -480,6 +480,9 @@ proc ExpectKind*(n: PNimrodNode; k: set[TNimrodNodeKind]) {.compileTime.} =
|
|||
proc newProc*(name = newEmptyNode(); params: openarray[PNimrodNode] = [];
|
||||
body: PNimrodNode = newStmtList(), procType = nnkProcDef): PNimrodNode {.compileTime.} =
|
||||
## shortcut for creating a new proc
|
||||
##
|
||||
## The ``params`` array should start with the return type of the proc,
|
||||
## followed by a list of IdentDefs which specify the params.
|
||||
assert procType in RoutineNodes
|
||||
result = newNimNode(procType).add(
|
||||
name,
|
||||
|
|
|
|||
|
|
@ -360,7 +360,7 @@ proc drawEllipse*(sur: PSurface, CX, CY, XRadius, YRadius: Natural,
|
|||
## of the ellipse.
|
||||
var
|
||||
X, Y: Natural
|
||||
XChange, YChange: Natural
|
||||
XChange, YChange: Int
|
||||
EllipseError: Natural
|
||||
TwoASquare, TwoBSquare: Natural
|
||||
StoppingX, StoppingY: Natural
|
||||
|
|
@ -501,6 +501,7 @@ if sdl_ttf.Init() < 0: raiseEGraphics()
|
|||
|
||||
when isMainModule:
|
||||
var surf = newScreenSurface(800, 600)
|
||||
|
||||
surf.fillSurface(colWhite)
|
||||
|
||||
# Draw the shapes
|
||||
|
|
@ -545,6 +546,8 @@ when isMainModule:
|
|||
if evk.keysym.sym == SDL.K_LEFT:
|
||||
surf.drawHorLine(395, 300, 50, colBlack)
|
||||
echo("Drawing")
|
||||
elif evk.keysym.sym == SDL.K_ESCAPE:
|
||||
break
|
||||
else:
|
||||
echo(evk.keysym.sym)
|
||||
of SDL.MOUSEBUTTONDOWN:
|
||||
|
|
|
|||
|
|
@ -836,9 +836,11 @@ proc copyFile*(source, dest: string) {.rtl, extern: "nos$1",
|
|||
##
|
||||
## If this fails, `EOS` is raised. On the Windows platform this proc will
|
||||
## copy the source file's attributes into dest. On other platforms you need
|
||||
## to use getFilePermissions and setFilePermissions to copy them by hand,
|
||||
## otherwise `dest` will inherit the default permissions of a newly created
|
||||
## file for the user.
|
||||
## to use getFilePermissions and setFilePermissions to copy them by hand (or
|
||||
## use the convenience copyFileWithPermissions() proc), otherwise `dest` will
|
||||
## inherit the default permissions of a newly created file for the user. If
|
||||
## `dest` already exists, the file attributes will be preserved and the
|
||||
## content overwritten.
|
||||
when defined(Windows):
|
||||
when useWinUnicode:
|
||||
let s = newWideCString(source)
|
||||
|
|
@ -1383,6 +1385,26 @@ proc setFilePermissions*(filename: string, permissions: set[TFilePermission]) {.
|
|||
var res2 = SetFileAttributesA(filename, res)
|
||||
if res2 == - 1'i32: OSError(OSLastError())
|
||||
|
||||
proc copyFileWithPermissions*(source, dest: string,
|
||||
ignorePermissionErrors = true) =
|
||||
## Copies a file from `source` to `dest` preserving file permissions.
|
||||
##
|
||||
## This is a wrapper proc around copyFile, getFilePermissions and
|
||||
## setFilePermissions on non Windows platform. On windows this proc is just a
|
||||
## wrapper for copyFile since that proc already copies attributes.
|
||||
##
|
||||
## On non windows systems permissions are copied after the file itself has
|
||||
## been copied, which won't happen atomically and could lead to a race
|
||||
## condition. If ignorePermissionErrors is true, errors while reading/setting
|
||||
## file attributes will be ignored, otherwise will raise `OSError`.
|
||||
copyFile(source, dest)
|
||||
when not defined(Windows):
|
||||
try:
|
||||
setFilePermissions(dest, getFilePermissions(source))
|
||||
except:
|
||||
if not ignorePermissionErrors:
|
||||
raise
|
||||
|
||||
proc inclFilePermissions*(filename: string,
|
||||
permissions: set[TFilePermission]) {.
|
||||
rtl, extern: "nos$1", tags: [FReadDir, FWriteDir].} =
|
||||
|
|
@ -1403,6 +1425,9 @@ proc exclFilePermissions*(filename: string,
|
|||
|
||||
proc getHomeDir*(): string {.rtl, extern: "nos$1", tags: [FReadEnv].} =
|
||||
## Returns the home directory of the current user.
|
||||
##
|
||||
## This proc is wrapped by the expandTilde proc for the convenience of
|
||||
## processing paths coming from user configuration files.
|
||||
when defined(windows): return string(getEnv("USERPROFILE")) & "\\"
|
||||
else: return string(getEnv("HOME")) & "/"
|
||||
|
||||
|
|
@ -1580,5 +1605,26 @@ proc findExe*(exe: string): string {.tags: [FReadDir, FReadEnv].} =
|
|||
if ExistsFile(x): return x
|
||||
result = ""
|
||||
|
||||
proc expandTilde*(path: string): string =
|
||||
## Expands a path starting with ``~/`` to a full path.
|
||||
##
|
||||
## If `path` starts with the tilde character and is followed by `/` or `\\`
|
||||
## this proc will return the reminder of the path appended to the result of
|
||||
## the getHomeDir() proc, otherwise the input path will be returned without
|
||||
## modification.
|
||||
##
|
||||
## The behaviour of this proc is the same on the Windows platform despite not
|
||||
## having this convention. Example:
|
||||
##
|
||||
## .. code-block:: nimrod
|
||||
## let configFile = expandTilde("~" / "appname.cfg")
|
||||
## echo configFile
|
||||
## # --> C:\Users\amber\appname.cfg
|
||||
|
||||
if len(path) > 1 and path[0] == '~' and (path[1] == '/' or path[1] == '\\'):
|
||||
result = getHomeDir() / path[2..len(path)-1]
|
||||
else:
|
||||
result = path
|
||||
|
||||
{.pop.}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ type
|
|||
PXmlAttributes* = PStringTable ## an alias for a string to string mapping
|
||||
|
||||
TXmlNode {.pure, final, acyclic.} = object
|
||||
case k: TXmlNodeKind
|
||||
case k: TXmlNodeKind # private, use the kind() proc to read this field.
|
||||
of xnText, xnComment, xnCData, xnEntity:
|
||||
fText: string
|
||||
of xnElement:
|
||||
|
|
@ -297,3 +297,40 @@ proc attr*(n: PXmlNode, name: string): string =
|
|||
assert n.kind == xnElement
|
||||
if n.attrs == nil: return ""
|
||||
return n.attrs[name]
|
||||
|
||||
proc findAll*(n: PXmlNode, tag: string, result: var seq[PXmlNode]) =
|
||||
## Iterates over all the children of `n` returning those matching `tag`.
|
||||
##
|
||||
## Found nodes satisfying the condition will be appended to the `result`
|
||||
## sequence, which can't be nil or the proc will crash. Usage example:
|
||||
##
|
||||
## .. code-block:: nimrod
|
||||
## var
|
||||
## html: PXmlNode
|
||||
## tags: seq[PXmlNode] = @[]
|
||||
##
|
||||
## html = buildHtml()
|
||||
## findAll(html, "img", tags)
|
||||
## for imgTag in tags:
|
||||
## process(imgTag)
|
||||
assert isNil(result) == false
|
||||
assert n.k == xnElement
|
||||
for child in n.items():
|
||||
if child.k != xnElement:
|
||||
continue
|
||||
if child.tag == tag:
|
||||
result.add(child)
|
||||
elif child.k == xnElement:
|
||||
child.findAll(tag, result)
|
||||
|
||||
proc findAll*(n: PXmlNode, tag: string): seq[PXmlNode] =
|
||||
## Shortcut version to assign in let blocks. Example:
|
||||
##
|
||||
## .. code-block:: nimrod
|
||||
## var html: PXmlNode
|
||||
##
|
||||
## html = buildHtml(html)
|
||||
## for imgTag in html.findAll("img"):
|
||||
## process(imgTag)
|
||||
newSeq(result, 0)
|
||||
findAll(n, tag, result)
|
||||
|
|
|
|||
|
|
@ -1454,9 +1454,9 @@ proc `&` *[T](x: seq[T], y: T): seq[T] {.noSideEffect.} =
|
|||
|
||||
proc `&` *[T](x: T, y: seq[T]): seq[T] {.noSideEffect.} =
|
||||
newSeq(result, y.len + 1)
|
||||
result[0] = x
|
||||
for i in 0..y.len-1:
|
||||
result[i] = y[i]
|
||||
result[y.len] = x
|
||||
result[i+1] = y[i]
|
||||
|
||||
when not defined(NimrodVM):
|
||||
when not defined(JS):
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ type
|
|||
C_TextFileStar = ptr CTextFile
|
||||
C_BinaryFileStar = ptr CBinaryFile
|
||||
|
||||
C_JmpBuf {.importc: "jmp_buf", header: "<setjmp.h>".} = array[0..31, int]
|
||||
C_JmpBuf {.importc: "jmp_buf", header: "<setjmp.h>".} = object
|
||||
|
||||
var
|
||||
c_stdin {.importc: "stdin", nodecl.}: C_TextFileStar
|
||||
|
|
|
|||
|
|
@ -48,12 +48,7 @@
|
|||
# October 2007
|
||||
#
|
||||
|
||||
when defined(windows):
|
||||
const LIB_CAIRO* = "libcairo-2.dll"
|
||||
elif defined(macosx):
|
||||
const LIB_CAIRO* = "libcairo.dylib"
|
||||
else:
|
||||
const LIB_CAIRO* = "libcairo.so(|.2)"
|
||||
include "cairo_pragma.nim"
|
||||
|
||||
type
|
||||
PByte = cstring
|
||||
|
|
@ -220,499 +215,499 @@ type
|
|||
num_rectangles: int32
|
||||
|
||||
|
||||
proc version*(): int32{.cdecl, importc: "cairo_version", dynlib: LIB_CAIRO.}
|
||||
proc version*(): int32{.cdecl, importc: "cairo_version", libcairo.}
|
||||
proc version_string*(): cstring{.cdecl, importc: "cairo_version_string",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
#Helper function to retrieve decoded version
|
||||
proc version*(major, minor, micro: var int32)
|
||||
#* Functions for manipulating state objects
|
||||
proc create*(target: PSurface): PContext{.cdecl, importc: "cairo_create",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc reference*(cr: PContext): PContext{.cdecl, importc: "cairo_reference", dynlib: LIB_CAIRO.}
|
||||
proc destroy*(cr: PContext){.cdecl, importc: "cairo_destroy", dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc reference*(cr: PContext): PContext{.cdecl, importc: "cairo_reference", libcairo.}
|
||||
proc destroy*(cr: PContext){.cdecl, importc: "cairo_destroy", libcairo.}
|
||||
proc get_reference_count*(cr: PContext): int32{.cdecl,
|
||||
importc: "cairo_get_reference_count", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_get_reference_count", libcairo.}
|
||||
proc get_user_data*(cr: PContext, key: PUserDataKey): pointer{.cdecl,
|
||||
importc: "cairo_get_user_data", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_get_user_data", libcairo.}
|
||||
proc set_user_data*(cr: PContext, key: PUserDataKey, user_data: Pointer,
|
||||
destroy: TDestroyFunc): TStatus{.cdecl,
|
||||
importc: "cairo_set_user_data", dynlib: LIB_CAIRO.}
|
||||
proc save*(cr: PContext){.cdecl, importc: "cairo_save", dynlib: LIB_CAIRO.}
|
||||
proc restore*(cr: PContext){.cdecl, importc: "cairo_restore", dynlib: LIB_CAIRO.}
|
||||
proc push_group*(cr: PContext){.cdecl, importc: "cairo_push_group", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_set_user_data", libcairo.}
|
||||
proc save*(cr: PContext){.cdecl, importc: "cairo_save", libcairo.}
|
||||
proc restore*(cr: PContext){.cdecl, importc: "cairo_restore", libcairo.}
|
||||
proc push_group*(cr: PContext){.cdecl, importc: "cairo_push_group", libcairo.}
|
||||
proc push_group_with_content*(cr: PContext, content: TContent){.cdecl,
|
||||
importc: "cairo_push_group_with_content", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_push_group_with_content", libcairo.}
|
||||
proc pop_group*(cr: PContext): PPattern{.cdecl, importc: "cairo_pop_group",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc pop_group_to_source*(cr: PContext){.cdecl, importc: "cairo_pop_group_to_source",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
#* Modify state
|
||||
proc set_operator*(cr: PContext, op: TOperator){.cdecl, importc: "cairo_set_operator",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc set_source*(cr: PContext, source: PPattern){.cdecl, importc: "cairo_set_source",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc set_source_rgb*(cr: PContext, red, green, blue: float64){.cdecl,
|
||||
importc: "cairo_set_source_rgb", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_set_source_rgb", libcairo.}
|
||||
proc set_source_rgba*(cr: PContext, red, green, blue, alpha: float64){.cdecl,
|
||||
importc: "cairo_set_source_rgba", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_set_source_rgba", libcairo.}
|
||||
proc set_source*(cr: PContext, surface: PSurface, x, y: float64){.cdecl,
|
||||
importc: "cairo_set_source_surface", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_set_source_surface", libcairo.}
|
||||
proc set_tolerance*(cr: PContext, tolerance: float64){.cdecl,
|
||||
importc: "cairo_set_tolerance", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_set_tolerance", libcairo.}
|
||||
proc set_antialias*(cr: PContext, antialias: TAntialias){.cdecl,
|
||||
importc: "cairo_set_antialias", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_set_antialias", libcairo.}
|
||||
proc set_fill_rule*(cr: PContext, fill_rule: TFillRule){.cdecl,
|
||||
importc: "cairo_set_fill_rule", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_set_fill_rule", libcairo.}
|
||||
proc set_line_width*(cr: PContext, width: float64){.cdecl,
|
||||
importc: "cairo_set_line_width", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_set_line_width", libcairo.}
|
||||
proc set_line_cap*(cr: PContext, line_cap: TLineCap){.cdecl,
|
||||
importc: "cairo_set_line_cap", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_set_line_cap", libcairo.}
|
||||
proc set_line_join*(cr: PContext, line_join: TLineJoin){.cdecl,
|
||||
importc: "cairo_set_line_join", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_set_line_join", libcairo.}
|
||||
proc set_dash*(cr: PContext, dashes: openarray[float64], offset: float64){.cdecl,
|
||||
importc: "cairo_set_dash", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_set_dash", libcairo.}
|
||||
proc set_miter_limit*(cr: PContext, limit: float64){.cdecl,
|
||||
importc: "cairo_set_miter_limit", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_set_miter_limit", libcairo.}
|
||||
proc translate*(cr: PContext, tx, ty: float64){.cdecl, importc: "cairo_translate",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc scale*(cr: PContext, sx, sy: float64){.cdecl, importc: "cairo_scale",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc rotate*(cr: PContext, angle: float64){.cdecl, importc: "cairo_rotate",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc transform*(cr: PContext, matrix: PMatrix){.cdecl, importc: "cairo_transform",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc set_matrix*(cr: PContext, matrix: PMatrix){.cdecl, importc: "cairo_set_matrix",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc identity_matrix*(cr: PContext){.cdecl, importc: "cairo_identity_matrix",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc user_to_device*(cr: PContext, x, y: var float64){.cdecl,
|
||||
importc: "cairo_user_to_device", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_user_to_device", libcairo.}
|
||||
proc user_to_device_distance*(cr: PContext, dx, dy: var float64){.cdecl,
|
||||
importc: "cairo_user_to_device_distance", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_user_to_device_distance", libcairo.}
|
||||
proc device_to_user*(cr: PContext, x, y: var float64){.cdecl,
|
||||
importc: "cairo_device_to_user", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_device_to_user", libcairo.}
|
||||
proc device_to_user_distance*(cr: PContext, dx, dy: var float64){.cdecl,
|
||||
importc: "cairo_device_to_user_distance", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_device_to_user_distance", libcairo.}
|
||||
#* Path creation functions
|
||||
proc new_path*(cr: PContext){.cdecl, importc: "cairo_new_path", dynlib: LIB_CAIRO.}
|
||||
proc new_path*(cr: PContext){.cdecl, importc: "cairo_new_path", libcairo.}
|
||||
proc move_to*(cr: PContext, x, y: float64){.cdecl, importc: "cairo_move_to",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc new_sub_path*(cr: PContext){.cdecl, importc: "cairo_new_sub_path",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc line_to*(cr: PContext, x, y: float64){.cdecl, importc: "cairo_line_to",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc curve_to*(cr: PContext, x1, y1, x2, y2, x3, y3: float64){.cdecl,
|
||||
importc: "cairo_curve_to", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_curve_to", libcairo.}
|
||||
proc arc*(cr: PContext, xc, yc, radius, angle1, angle2: float64){.cdecl,
|
||||
importc: "cairo_arc", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_arc", libcairo.}
|
||||
proc arc_negative*(cr: PContext, xc, yc, radius, angle1, angle2: float64){.cdecl,
|
||||
importc: "cairo_arc_negative", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_arc_negative", libcairo.}
|
||||
proc rel_move_to*(cr: PContext, dx, dy: float64){.cdecl, importc: "cairo_rel_move_to",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc rel_line_to*(cr: PContext, dx, dy: float64){.cdecl, importc: "cairo_rel_line_to",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc rel_curve_to*(cr: PContext, dx1, dy1, dx2, dy2, dx3, dy3: float64){.cdecl,
|
||||
importc: "cairo_rel_curve_to", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_rel_curve_to", libcairo.}
|
||||
proc rectangle*(cr: PContext, x, y, width, height: float64){.cdecl,
|
||||
importc: "cairo_rectangle", dynlib: LIB_CAIRO.}
|
||||
proc close_path*(cr: PContext){.cdecl, importc: "cairo_close_path", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_rectangle", libcairo.}
|
||||
proc close_path*(cr: PContext){.cdecl, importc: "cairo_close_path", libcairo.}
|
||||
#* Painting functions
|
||||
proc paint*(cr: PContext){.cdecl, importc: "cairo_paint", dynlib: LIB_CAIRO.}
|
||||
proc paint*(cr: PContext){.cdecl, importc: "cairo_paint", libcairo.}
|
||||
proc paint_with_alpha*(cr: PContext, alpha: float64){.cdecl,
|
||||
importc: "cairo_paint_with_alpha", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_paint_with_alpha", libcairo.}
|
||||
proc mask*(cr: PContext, pattern: PPattern){.cdecl, importc: "cairo_mask",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc mask*(cr: PContext, surface: PSurface, surface_x, surface_y: float64){.
|
||||
cdecl, importc: "cairo_mask_surface", dynlib: LIB_CAIRO.}
|
||||
proc stroke*(cr: PContext){.cdecl, importc: "cairo_stroke", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_mask_surface", libcairo.}
|
||||
proc stroke*(cr: PContext){.cdecl, importc: "cairo_stroke", libcairo.}
|
||||
proc stroke_preserve*(cr: PContext){.cdecl, importc: "cairo_stroke_preserve",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc fill*(cr: PContext){.cdecl, importc: "cairo_fill", dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc fill*(cr: PContext){.cdecl, importc: "cairo_fill", libcairo.}
|
||||
proc fill_preserve*(cr: PContext){.cdecl, importc: "cairo_fill_preserve",
|
||||
dynlib: LIB_CAIRO.}
|
||||
proc copy_page*(cr: PContext){.cdecl, importc: "cairo_copy_page", dynlib: LIB_CAIRO.}
|
||||
proc show_page*(cr: PContext){.cdecl, importc: "cairo_show_page", dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc copy_page*(cr: PContext){.cdecl, importc: "cairo_copy_page", libcairo.}
|
||||
proc show_page*(cr: PContext){.cdecl, importc: "cairo_show_page", libcairo.}
|
||||
#* Insideness testing
|
||||
proc in_stroke*(cr: PContext, x, y: float64): TBool{.cdecl, importc: "cairo_in_stroke",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc in_fill*(cr: PContext, x, y: float64): TBool{.cdecl, importc: "cairo_in_fill",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
#* Rectangular extents
|
||||
proc stroke_extents*(cr: PContext, x1, y1, x2, y2: var float64){.cdecl,
|
||||
importc: "cairo_stroke_extents", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_stroke_extents", libcairo.}
|
||||
proc fill_extents*(cr: PContext, x1, y1, x2, y2: var float64){.cdecl,
|
||||
importc: "cairo_fill_extents", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_fill_extents", libcairo.}
|
||||
#* Clipping
|
||||
proc reset_clip*(cr: PContext){.cdecl, importc: "cairo_reset_clip", dynlib: LIB_CAIRO.}
|
||||
proc clip*(cr: PContext){.cdecl, importc: "cairo_clip", dynlib: LIB_CAIRO.}
|
||||
proc reset_clip*(cr: PContext){.cdecl, importc: "cairo_reset_clip", libcairo.}
|
||||
proc clip*(cr: PContext){.cdecl, importc: "cairo_clip", libcairo.}
|
||||
proc clip_preserve*(cr: PContext){.cdecl, importc: "cairo_clip_preserve",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc clip_extents*(cr: PContext, x1, y1, x2, y2: var float64){.cdecl,
|
||||
importc: "cairo_clip_extents", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_clip_extents", libcairo.}
|
||||
proc copy_clip_rectangle_list*(cr: PContext): PRectangleList{.cdecl,
|
||||
importc: "cairo_copy_clip_rectangle_list", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_copy_clip_rectangle_list", libcairo.}
|
||||
proc rectangle_list_destroy*(rectangle_list: PRectangleList){.cdecl,
|
||||
importc: "cairo_rectangle_list_destroy", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_rectangle_list_destroy", libcairo.}
|
||||
#* Font/Text functions
|
||||
proc font_options_create*(): PFontOptions{.cdecl,
|
||||
importc: "cairo_font_options_create", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_font_options_create", libcairo.}
|
||||
proc copy*(original: PFontOptions): PFontOptions{.cdecl,
|
||||
importc: "cairo_font_options_copy", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_font_options_copy", libcairo.}
|
||||
proc destroy*(options: PFontOptions){.cdecl,
|
||||
importc: "cairo_font_options_destroy", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_font_options_destroy", libcairo.}
|
||||
proc status*(options: PFontOptions): TStatus{.cdecl,
|
||||
importc: "cairo_font_options_status", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_font_options_status", libcairo.}
|
||||
proc merge*(options, other: PFontOptions){.cdecl,
|
||||
importc: "cairo_font_options_merge", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_font_options_merge", libcairo.}
|
||||
proc equal*(options, other: PFontOptions): TBool{.cdecl,
|
||||
importc: "cairo_font_options_equal", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_font_options_equal", libcairo.}
|
||||
proc hash*(options: PFontOptions): int32{.cdecl,
|
||||
importc: "cairo_font_options_hash", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_font_options_hash", libcairo.}
|
||||
proc set_antialias*(options: PFontOptions, antialias: TAntialias){.
|
||||
cdecl, importc: "cairo_font_options_set_antialias", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_font_options_set_antialias", libcairo.}
|
||||
proc get_antialias*(options: PFontOptions): TAntialias{.cdecl,
|
||||
importc: "cairo_font_options_get_antialias", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_font_options_get_antialias", libcairo.}
|
||||
proc set_subpixel_order*(options: PFontOptions,
|
||||
subpixel_order: TSubpixelOrder){.cdecl,
|
||||
importc: "cairo_font_options_set_subpixel_order", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_font_options_set_subpixel_order", libcairo.}
|
||||
proc get_subpixel_order*(options: PFontOptions): TSubpixelOrder{.
|
||||
cdecl, importc: "cairo_font_options_get_subpixel_order", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_font_options_get_subpixel_order", libcairo.}
|
||||
proc set_hint_style*(options: PFontOptions, hint_style: THintStyle){.
|
||||
cdecl, importc: "cairo_font_options_set_hint_style", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_font_options_set_hint_style", libcairo.}
|
||||
proc get_hint_style*(options: PFontOptions): THintStyle{.cdecl,
|
||||
importc: "cairo_font_options_get_hint_style", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_font_options_get_hint_style", libcairo.}
|
||||
proc set_hint_metrics*(options: PFontOptions,
|
||||
hint_metrics: THintMetrics){.cdecl,
|
||||
importc: "cairo_font_options_set_hint_metrics", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_font_options_set_hint_metrics", libcairo.}
|
||||
proc get_hint_metrics*(options: PFontOptions): THintMetrics{.cdecl,
|
||||
importc: "cairo_font_options_get_hint_metrics", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_font_options_get_hint_metrics", libcairo.}
|
||||
#* This interface is for dealing with text as text, not caring about the
|
||||
# font object inside the the TCairo.
|
||||
proc select_font_face*(cr: PContext, family: cstring, slant: TFontSlant,
|
||||
weight: TFontWeight){.cdecl,
|
||||
importc: "cairo_select_font_face", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_select_font_face", libcairo.}
|
||||
proc set_font_size*(cr: PContext, size: float64){.cdecl,
|
||||
importc: "cairo_set_font_size", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_set_font_size", libcairo.}
|
||||
proc set_font_matrix*(cr: PContext, matrix: PMatrix){.cdecl,
|
||||
importc: "cairo_set_font_matrix", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_set_font_matrix", libcairo.}
|
||||
proc get_font_matrix*(cr: PContext, matrix: PMatrix){.cdecl,
|
||||
importc: "cairo_get_font_matrix", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_get_font_matrix", libcairo.}
|
||||
proc set_font_options*(cr: PContext, options: PFontOptions){.cdecl,
|
||||
importc: "cairo_set_font_options", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_set_font_options", libcairo.}
|
||||
proc get_font_options*(cr: PContext, options: PFontOptions){.cdecl,
|
||||
importc: "cairo_get_font_options", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_get_font_options", libcairo.}
|
||||
proc set_font_face*(cr: PContext, font_face: PFontFace){.cdecl,
|
||||
importc: "cairo_set_font_face", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_set_font_face", libcairo.}
|
||||
proc get_font_face*(cr: PContext): PFontFace{.cdecl, importc: "cairo_get_font_face",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc set_scaled_font*(cr: PContext, scaled_font: PScaledFont){.cdecl,
|
||||
importc: "cairo_set_scaled_font", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_set_scaled_font", libcairo.}
|
||||
proc get_scaled_font*(cr: PContext): PScaledFont{.cdecl,
|
||||
importc: "cairo_get_scaled_font", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_get_scaled_font", libcairo.}
|
||||
proc show_text*(cr: PContext, utf8: cstring){.cdecl, importc: "cairo_show_text",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc show_glyphs*(cr: PContext, glyphs: PGlyph, num_glyphs: int32){.cdecl,
|
||||
importc: "cairo_show_glyphs", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_show_glyphs", libcairo.}
|
||||
proc text_path*(cr: PContext, utf8: cstring){.cdecl, importc: "cairo_text_path",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc glyph_path*(cr: PContext, glyphs: PGlyph, num_glyphs: int32){.cdecl,
|
||||
importc: "cairo_glyph_path", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_glyph_path", libcairo.}
|
||||
proc text_extents*(cr: PContext, utf8: cstring, extents: PTextExtents){.cdecl,
|
||||
importc: "cairo_text_extents", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_text_extents", libcairo.}
|
||||
proc glyph_extents*(cr: PContext, glyphs: PGlyph, num_glyphs: int32,
|
||||
extents: PTextExtents){.cdecl,
|
||||
importc: "cairo_glyph_extents", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_glyph_extents", libcairo.}
|
||||
proc font_extents*(cr: PContext, extents: PFontExtents){.cdecl,
|
||||
importc: "cairo_font_extents", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_font_extents", libcairo.}
|
||||
#* Generic identifier for a font style
|
||||
proc reference*(font_face: PFontFace): PFontFace{.cdecl,
|
||||
importc: "cairo_font_face_reference", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_font_face_reference", libcairo.}
|
||||
proc destroy*(font_face: PFontFace){.cdecl,
|
||||
importc: "cairo_font_face_destroy", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_font_face_destroy", libcairo.}
|
||||
proc get_reference_count*(font_face: PFontFace): int32{.cdecl,
|
||||
importc: "cairo_font_face_get_reference_count", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_font_face_get_reference_count", libcairo.}
|
||||
proc status*(font_face: PFontFace): TStatus{.cdecl,
|
||||
importc: "cairo_font_face_status", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_font_face_status", libcairo.}
|
||||
proc get_type*(font_face: PFontFace): TFontType{.cdecl,
|
||||
importc: "cairo_font_face_get_type", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_font_face_get_type", libcairo.}
|
||||
proc get_user_data*(font_face: PFontFace, key: PUserDataKey): pointer{.
|
||||
cdecl, importc: "cairo_font_face_get_user_data", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_font_face_get_user_data", libcairo.}
|
||||
proc set_user_data*(font_face: PFontFace, key: PUserDataKey,
|
||||
user_data: pointer, destroy: TDestroyFunc): TStatus{.
|
||||
cdecl, importc: "cairo_font_face_set_user_data", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_font_face_set_user_data", libcairo.}
|
||||
#* Portable interface to general font features
|
||||
proc scaled_font_create*(font_face: PFontFace, font_matrix: PMatrix,
|
||||
ctm: PMatrix, options: PFontOptions): PScaledFont{.
|
||||
cdecl, importc: "cairo_scaled_font_create", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_scaled_font_create", libcairo.}
|
||||
proc reference*(scaled_font: PScaledFont): PScaledFont{.cdecl,
|
||||
importc: "cairo_scaled_font_reference", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_scaled_font_reference", libcairo.}
|
||||
proc destroy*(scaled_font: PScaledFont){.cdecl,
|
||||
importc: "cairo_scaled_font_destroy", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_scaled_font_destroy", libcairo.}
|
||||
proc get_reference_count*(scaled_font: PScaledFont): int32{.cdecl,
|
||||
importc: "cairo_scaled_font_get_reference_count", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_scaled_font_get_reference_count", libcairo.}
|
||||
proc status*(scaled_font: PScaledFont): TStatus{.cdecl,
|
||||
importc: "cairo_scaled_font_status", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_scaled_font_status", libcairo.}
|
||||
proc get_type*(scaled_font: PScaledFont): TFontType{.cdecl,
|
||||
importc: "cairo_scaled_font_get_type", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_scaled_font_get_type", libcairo.}
|
||||
proc get_user_data*(scaled_font: PScaledFont, key: PUserDataKey): Pointer{.
|
||||
cdecl, importc: "cairo_scaled_font_get_user_data", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_scaled_font_get_user_data", libcairo.}
|
||||
proc set_user_data*(scaled_font: PScaledFont, key: PUserDataKey,
|
||||
user_data: Pointer, destroy: TDestroyFunc): TStatus{.
|
||||
cdecl, importc: "cairo_scaled_font_set_user_data", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_scaled_font_set_user_data", libcairo.}
|
||||
proc extents*(scaled_font: PScaledFont, extents: PFontExtents){.
|
||||
cdecl, importc: "cairo_scaled_font_extents", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_scaled_font_extents", libcairo.}
|
||||
proc text_extents*(scaled_font: PScaledFont, utf8: cstring,
|
||||
extents: PTextExtents){.cdecl,
|
||||
importc: "cairo_scaled_font_text_extents", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_scaled_font_text_extents", libcairo.}
|
||||
proc glyph_extents*(scaled_font: PScaledFont, glyphs: PGlyph,
|
||||
num_glyphs: int32, extents: PTextExtents){.
|
||||
cdecl, importc: "cairo_scaled_font_glyph_extents", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_scaled_font_glyph_extents", libcairo.}
|
||||
proc get_font_face*(scaled_font: PScaledFont): PFontFace{.cdecl,
|
||||
importc: "cairo_scaled_font_get_font_face", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_scaled_font_get_font_face", libcairo.}
|
||||
proc get_font_matrix*(scaled_font: PScaledFont, font_matrix: PMatrix){.
|
||||
cdecl, importc: "cairo_scaled_font_get_font_matrix", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_scaled_font_get_font_matrix", libcairo.}
|
||||
proc get_ctm*(scaled_font: PScaledFont, ctm: PMatrix){.cdecl,
|
||||
importc: "cairo_scaled_font_get_ctm", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_scaled_font_get_ctm", libcairo.}
|
||||
proc get_font_options*(scaled_font: PScaledFont,
|
||||
options: PFontOptions){.cdecl,
|
||||
importc: "cairo_scaled_font_get_font_options", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_scaled_font_get_font_options", libcairo.}
|
||||
#* Query functions
|
||||
proc get_operator*(cr: PContext): TOperator{.cdecl, importc: "cairo_get_operator",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc get_source*(cr: PContext): PPattern{.cdecl, importc: "cairo_get_source",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc get_tolerance*(cr: PContext): float64{.cdecl, importc: "cairo_get_tolerance",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc get_antialias*(cr: PContext): TAntialias{.cdecl, importc: "cairo_get_antialias",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc get_current_point*(cr: PContext, x, y: var float64){.cdecl,
|
||||
importc: "cairo_get_current_point", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_get_current_point", libcairo.}
|
||||
proc get_fill_rule*(cr: PContext): TFillRule{.cdecl, importc: "cairo_get_fill_rule",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc get_line_width*(cr: PContext): float64{.cdecl, importc: "cairo_get_line_width",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc get_line_cap*(cr: PContext): TLineCap{.cdecl, importc: "cairo_get_line_cap",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc get_line_join*(cr: PContext): TLineJoin{.cdecl, importc: "cairo_get_line_join",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc get_miter_limit*(cr: PContext): float64{.cdecl, importc: "cairo_get_miter_limit",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc get_dash_count*(cr: PContext): int32{.cdecl, importc: "cairo_get_dash_count",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc get_dash*(cr: PContext, dashes, offset: var float64){.cdecl,
|
||||
importc: "cairo_get_dash", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_get_dash", libcairo.}
|
||||
proc get_matrix*(cr: PContext, matrix: PMatrix){.cdecl, importc: "cairo_get_matrix",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc get_target*(cr: PContext): PSurface{.cdecl, importc: "cairo_get_target",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc get_group_target*(cr: PContext): PSurface{.cdecl,
|
||||
importc: "cairo_get_group_target", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_get_group_target", libcairo.}
|
||||
proc copy_path*(cr: PContext): PPath{.cdecl, importc: "cairo_copy_path",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc copy_path_flat*(cr: PContext): PPath{.cdecl, importc: "cairo_copy_path_flat",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc append_path*(cr: PContext, path: PPath){.cdecl, importc: "cairo_append_path",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc destroy*(path: PPath){.cdecl, importc: "cairo_path_destroy",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
#* Error status queries
|
||||
proc status*(cr: PContext): TStatus{.cdecl, importc: "cairo_status", dynlib: LIB_CAIRO.}
|
||||
proc status*(cr: PContext): TStatus{.cdecl, importc: "cairo_status", libcairo.}
|
||||
proc status_to_string*(status: TStatus): cstring{.cdecl,
|
||||
importc: "cairo_status_to_string", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_status_to_string", libcairo.}
|
||||
#* Surface manipulation
|
||||
proc surface_create_similar*(other: PSurface, content: TContent,
|
||||
width, height: int32): PSurface{.cdecl,
|
||||
importc: "cairo_surface_create_similar", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_surface_create_similar", libcairo.}
|
||||
proc reference*(surface: PSurface): PSurface{.cdecl,
|
||||
importc: "cairo_surface_reference", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_surface_reference", libcairo.}
|
||||
proc finish*(surface: PSurface){.cdecl, importc: "cairo_surface_finish",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc destroy*(surface: PSurface){.cdecl,
|
||||
importc: "cairo_surface_destroy", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_surface_destroy", libcairo.}
|
||||
proc get_reference_count*(surface: PSurface): int32{.cdecl,
|
||||
importc: "cairo_surface_get_reference_count", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_surface_get_reference_count", libcairo.}
|
||||
proc status*(surface: PSurface): TStatus{.cdecl,
|
||||
importc: "cairo_surface_status", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_surface_status", libcairo.}
|
||||
proc get_type*(surface: PSurface): TSurfaceType{.cdecl,
|
||||
importc: "cairo_surface_get_type", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_surface_get_type", libcairo.}
|
||||
proc get_content*(surface: PSurface): TContent{.cdecl,
|
||||
importc: "cairo_surface_get_content", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_surface_get_content", libcairo.}
|
||||
proc write_to_png*(surface: PSurface, filename: cstring): TStatus{.
|
||||
cdecl, importc: "cairo_surface_write_to_png", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_surface_write_to_png", libcairo.}
|
||||
proc write_to_png*(surface: PSurface, write_func: TWriteFunc,
|
||||
closure: pointer): TStatus{.cdecl,
|
||||
importc: "cairo_surface_write_to_png_stream", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_surface_write_to_png_stream", libcairo.}
|
||||
proc get_user_data*(surface: PSurface, key: PUserDataKey): pointer{.
|
||||
cdecl, importc: "cairo_surface_get_user_data", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_surface_get_user_data", libcairo.}
|
||||
proc set_user_data*(surface: PSurface, key: PUserDataKey,
|
||||
user_data: pointer, destroy: TDestroyFunc): TStatus{.
|
||||
cdecl, importc: "cairo_surface_set_user_data", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_surface_set_user_data", libcairo.}
|
||||
proc get_font_options*(surface: PSurface, options: PFontOptions){.cdecl,
|
||||
importc: "cairo_surface_get_font_options", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_surface_get_font_options", libcairo.}
|
||||
proc flush*(surface: PSurface){.cdecl, importc: "cairo_surface_flush",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc mark_dirty*(surface: PSurface){.cdecl,
|
||||
importc: "cairo_surface_mark_dirty", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_surface_mark_dirty", libcairo.}
|
||||
proc mark_dirty_rectangle*(surface: PSurface, x, y, width, height: int32){.
|
||||
cdecl, importc: "cairo_surface_mark_dirty_rectangle", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_surface_mark_dirty_rectangle", libcairo.}
|
||||
proc set_device_offset*(surface: PSurface, x_offset, y_offset: float64){.
|
||||
cdecl, importc: "cairo_surface_set_device_offset", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_surface_set_device_offset", libcairo.}
|
||||
proc get_device_offset*(surface: PSurface,
|
||||
x_offset, y_offset: var float64){.cdecl,
|
||||
importc: "cairo_surface_get_device_offset", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_surface_get_device_offset", libcairo.}
|
||||
proc set_fallback_resolution*(surface: PSurface, x_pixels_per_inch,
|
||||
y_pixels_per_inch: float64){.cdecl, importc: "cairo_surface_set_fallback_resolution",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
#* Image-surface functions
|
||||
proc image_surface_create*(format: TFormat, width, height: int32): PSurface{.
|
||||
cdecl, importc: "cairo_image_surface_create", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_image_surface_create", libcairo.}
|
||||
proc image_surface_create*(data: Pbyte, format: TFormat,
|
||||
width, height, stride: int32): PSurface{.
|
||||
cdecl, importc: "cairo_image_surface_create_for_data", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_image_surface_create_for_data", libcairo.}
|
||||
proc get_data*(surface: PSurface): cstring{.cdecl,
|
||||
importc: "cairo_image_surface_get_data", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_image_surface_get_data", libcairo.}
|
||||
proc get_format*(surface: PSurface): TFormat{.cdecl,
|
||||
importc: "cairo_image_surface_get_format", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_image_surface_get_format", libcairo.}
|
||||
proc get_width*(surface: PSurface): int32{.cdecl,
|
||||
importc: "cairo_image_surface_get_width", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_image_surface_get_width", libcairo.}
|
||||
proc get_height*(surface: PSurface): int32{.cdecl,
|
||||
importc: "cairo_image_surface_get_height", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_image_surface_get_height", libcairo.}
|
||||
proc get_stride*(surface: PSurface): int32{.cdecl,
|
||||
importc: "cairo_image_surface_get_stride", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_image_surface_get_stride", libcairo.}
|
||||
proc image_surface_create_from_png*(filename: cstring): PSurface{.cdecl,
|
||||
importc: "cairo_image_surface_create_from_png", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_image_surface_create_from_png", libcairo.}
|
||||
proc image_surface_create_from_png*(read_func: TReadFunc,
|
||||
closure: pointer): PSurface{.cdecl, importc: "cairo_image_surface_create_from_png_stream",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
#* Pattern creation functions
|
||||
proc pattern_create_rgb*(red, green, blue: float64): PPattern{.cdecl,
|
||||
importc: "cairo_pattern_create_rgb", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_pattern_create_rgb", libcairo.}
|
||||
proc pattern_create_rgba*(red, green, blue, alpha: float64): PPattern{.cdecl,
|
||||
importc: "cairo_pattern_create_rgba", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_pattern_create_rgba", libcairo.}
|
||||
proc pattern_create_for_surface*(surface: PSurface): PPattern{.cdecl,
|
||||
importc: "cairo_pattern_create_for_surface", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_pattern_create_for_surface", libcairo.}
|
||||
proc pattern_create_linear*(x0, y0, x1, y1: float64): PPattern{.cdecl,
|
||||
importc: "cairo_pattern_create_linear", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_pattern_create_linear", libcairo.}
|
||||
proc pattern_create_radial*(cx0, cy0, radius0, cx1, cy1, radius1: float64): PPattern{.
|
||||
cdecl, importc: "cairo_pattern_create_radial", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_pattern_create_radial", libcairo.}
|
||||
proc reference*(pattern: PPattern): PPattern{.cdecl,
|
||||
importc: "cairo_pattern_reference", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_pattern_reference", libcairo.}
|
||||
proc destroy*(pattern: PPattern){.cdecl,
|
||||
importc: "cairo_pattern_destroy", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_pattern_destroy", libcairo.}
|
||||
proc get_reference_count*(pattern: PPattern): int32{.cdecl,
|
||||
importc: "cairo_pattern_get_reference_count", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_pattern_get_reference_count", libcairo.}
|
||||
proc status*(pattern: PPattern): TStatus{.cdecl,
|
||||
importc: "cairo_pattern_status", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_pattern_status", libcairo.}
|
||||
proc get_user_data*(pattern: PPattern, key: PUserDataKey): Pointer{.
|
||||
cdecl, importc: "cairo_pattern_get_user_data", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_pattern_get_user_data", libcairo.}
|
||||
proc set_user_data*(pattern: PPattern, key: PUserDataKey,
|
||||
user_data: Pointer, destroy: TDestroyFunc): TStatus{.
|
||||
cdecl, importc: "cairo_pattern_set_user_data", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_pattern_set_user_data", libcairo.}
|
||||
proc get_type*(pattern: PPattern): TPatternType{.cdecl,
|
||||
importc: "cairo_pattern_get_type", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_pattern_get_type", libcairo.}
|
||||
proc add_color_stop_rgb*(pattern: PPattern,
|
||||
offset, red, green, blue: float64){.cdecl,
|
||||
importc: "cairo_pattern_add_color_stop_rgb", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_pattern_add_color_stop_rgb", libcairo.}
|
||||
proc add_color_stop_rgba*(pattern: PPattern,
|
||||
offset, red, green, blue, alpha: float64){.
|
||||
cdecl, importc: "cairo_pattern_add_color_stop_rgba", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_pattern_add_color_stop_rgba", libcairo.}
|
||||
proc set_matrix*(pattern: PPattern, matrix: PMatrix){.cdecl,
|
||||
importc: "cairo_pattern_set_matrix", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_pattern_set_matrix", libcairo.}
|
||||
proc get_matrix*(pattern: PPattern, matrix: PMatrix){.cdecl,
|
||||
importc: "cairo_pattern_get_matrix", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_pattern_get_matrix", libcairo.}
|
||||
proc set_extend*(pattern: PPattern, extend: TExtend){.cdecl,
|
||||
importc: "cairo_pattern_set_extend", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_pattern_set_extend", libcairo.}
|
||||
proc get_extend*(pattern: PPattern): TExtend{.cdecl,
|
||||
importc: "cairo_pattern_get_extend", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_pattern_get_extend", libcairo.}
|
||||
proc set_filter*(pattern: PPattern, filter: TFilter){.cdecl,
|
||||
importc: "cairo_pattern_set_filter", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_pattern_set_filter", libcairo.}
|
||||
proc get_filter*(pattern: PPattern): TFilter{.cdecl,
|
||||
importc: "cairo_pattern_get_filter", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_pattern_get_filter", libcairo.}
|
||||
proc get_rgba*(pattern: PPattern,
|
||||
red, green, blue, alpha: var float64): TStatus{.
|
||||
cdecl, importc: "cairo_pattern_get_rgba", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_pattern_get_rgba", libcairo.}
|
||||
proc get_surface*(pattern: PPattern, surface: PPSurface): TStatus{.
|
||||
cdecl, importc: "cairo_pattern_get_surface", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_pattern_get_surface", libcairo.}
|
||||
proc get_color_stop_rgba*(pattern: PPattern, index: int32,
|
||||
offset, red, green, blue, alpha: var float64): TStatus{.
|
||||
cdecl, importc: "cairo_pattern_get_color_stop_rgba", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_pattern_get_color_stop_rgba", libcairo.}
|
||||
proc get_color_stop_count*(pattern: PPattern, count: var int32): TStatus{.
|
||||
cdecl, importc: "cairo_pattern_get_color_stop_count", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_pattern_get_color_stop_count", libcairo.}
|
||||
proc get_linear_points*(pattern: PPattern,
|
||||
x0, y0, x1, y1: var float64): TStatus{.
|
||||
cdecl, importc: "cairo_pattern_get_linear_points", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_pattern_get_linear_points", libcairo.}
|
||||
proc get_radial_circles*(pattern: PPattern,
|
||||
x0, y0, r0, x1, y1, r1: var float64): TStatus{.
|
||||
cdecl, importc: "cairo_pattern_get_radial_circles", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_pattern_get_radial_circles", libcairo.}
|
||||
#* Matrix functions
|
||||
proc init*(matrix: PMatrix, xx, yx, xy, yy, x0, y0: float64){.cdecl,
|
||||
importc: "cairo_matrix_init", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_matrix_init", libcairo.}
|
||||
proc init_identity*(matrix: PMatrix){.cdecl,
|
||||
importc: "cairo_matrix_init_identity", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_matrix_init_identity", libcairo.}
|
||||
proc init_translate*(matrix: PMatrix, tx, ty: float64){.cdecl,
|
||||
importc: "cairo_matrix_init_translate", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_matrix_init_translate", libcairo.}
|
||||
proc init_scale*(matrix: PMatrix, sx, sy: float64){.cdecl,
|
||||
importc: "cairo_matrix_init_scale", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_matrix_init_scale", libcairo.}
|
||||
proc init_rotate*(matrix: PMatrix, radians: float64){.cdecl,
|
||||
importc: "cairo_matrix_init_rotate", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_matrix_init_rotate", libcairo.}
|
||||
proc translate*(matrix: PMatrix, tx, ty: float64){.cdecl,
|
||||
importc: "cairo_matrix_translate", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_matrix_translate", libcairo.}
|
||||
proc scale*(matrix: PMatrix, sx, sy: float64){.cdecl,
|
||||
importc: "cairo_matrix_scale", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_matrix_scale", libcairo.}
|
||||
proc rotate*(matrix: PMatrix, radians: float64){.cdecl,
|
||||
importc: "cairo_matrix_rotate", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_matrix_rotate", libcairo.}
|
||||
proc invert*(matrix: PMatrix): TStatus{.cdecl,
|
||||
importc: "cairo_matrix_invert", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_matrix_invert", libcairo.}
|
||||
proc multiply*(result, a, b: PMatrix){.cdecl,
|
||||
importc: "cairo_matrix_multiply", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_matrix_multiply", libcairo.}
|
||||
proc transform_distance*(matrix: PMatrix, dx, dy: var float64){.cdecl,
|
||||
importc: "cairo_matrix_transform_distance", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_matrix_transform_distance", libcairo.}
|
||||
proc transform_point*(matrix: PMatrix, x, y: var float64){.cdecl,
|
||||
importc: "cairo_matrix_transform_point", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_matrix_transform_point", libcairo.}
|
||||
#* PDF functions
|
||||
proc pdf_surface_create*(filename: cstring,
|
||||
width_in_points, height_in_points: float64): PSurface{.
|
||||
cdecl, importc: "cairo_pdf_surface_create", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_pdf_surface_create", libcairo.}
|
||||
proc pdf_surface_create_for_stream*(write_func: TWriteFunc, closure: Pointer,
|
||||
width_in_points, height_in_points: float64): PSurface{.
|
||||
cdecl, importc: "cairo_pdf_surface_create_for_stream", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_pdf_surface_create_for_stream", libcairo.}
|
||||
proc pdf_surface_set_size*(surface: PSurface,
|
||||
width_in_points, height_in_points: float64){.cdecl,
|
||||
importc: "cairo_pdf_surface_set_size", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_pdf_surface_set_size", libcairo.}
|
||||
#* PS functions
|
||||
proc ps_surface_create*(filename: cstring,
|
||||
width_in_points, height_in_points: float64): PSurface{.
|
||||
cdecl, importc: "cairo_ps_surface_create", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_ps_surface_create", libcairo.}
|
||||
proc ps_surface_create_for_stream*(write_func: TWriteFunc, closure: Pointer,
|
||||
width_in_points, height_in_points: float64): PSurface{.
|
||||
cdecl, importc: "cairo_ps_surface_create_for_stream", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_ps_surface_create_for_stream", libcairo.}
|
||||
proc ps_surface_set_size*(surface: PSurface,
|
||||
width_in_points, height_in_points: float64){.cdecl,
|
||||
importc: "cairo_ps_surface_set_size", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_ps_surface_set_size", libcairo.}
|
||||
proc ps_surface_dsc_comment*(surface: PSurface, comment: cstring){.cdecl,
|
||||
importc: "cairo_ps_surface_dsc_comment", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_ps_surface_dsc_comment", libcairo.}
|
||||
proc ps_surface_dsc_begin_setup*(surface: PSurface){.cdecl,
|
||||
importc: "cairo_ps_surface_dsc_begin_setup", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_ps_surface_dsc_begin_setup", libcairo.}
|
||||
proc ps_surface_dsc_begin_page_setup*(surface: PSurface){.cdecl,
|
||||
importc: "cairo_ps_surface_dsc_begin_page_setup", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_ps_surface_dsc_begin_page_setup", libcairo.}
|
||||
#* SVG functions
|
||||
proc svg_surface_create*(filename: cstring,
|
||||
width_in_points, height_in_points: float64): PSurface{.
|
||||
cdecl, importc: "cairo_svg_surface_create", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_svg_surface_create", libcairo.}
|
||||
proc svg_surface_create_for_stream*(write_func: TWriteFunc, closure: Pointer,
|
||||
width_in_points, height_in_points: float64): PSurface{.
|
||||
cdecl, importc: "cairo_svg_surface_create_for_stream", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_svg_surface_create_for_stream", libcairo.}
|
||||
proc svg_surface_restrict_to_version*(surface: PSurface, version: TSvgVersion){.
|
||||
cdecl, importc: "cairo_svg_surface_restrict_to_version", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_svg_surface_restrict_to_version", libcairo.}
|
||||
#todo: see how translate this
|
||||
#procedure cairo_svg_get_versions(TCairoSvgVersion const **versions,
|
||||
# int *num_versions);
|
||||
proc svg_version_to_string*(version: TSvgVersion): cstring{.cdecl,
|
||||
importc: "cairo_svg_version_to_string", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_svg_version_to_string", libcairo.}
|
||||
#* Functions to be used while debugging (not intended for use in production code)
|
||||
proc debug_reset_static_data*(){.cdecl,
|
||||
importc: "cairo_debug_reset_static_data",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
# implementation
|
||||
|
||||
proc version(major, minor, micro: var int32) =
|
||||
|
|
|
|||
16
lib/wrappers/cairo/cairo_pragma.nim
Normal file
16
lib/wrappers/cairo/cairo_pragma.nim
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# included by cairo bindings
|
||||
|
||||
when defined(use_pkg_config) or defined(use_pkg_config_static):
|
||||
{.pragma: libcairo, cdecl.}
|
||||
when defined(use_pkg_config_static):
|
||||
{.passl: gorge("pkg-config cairo --libs --static").}
|
||||
else:
|
||||
{.passl: gorge("pkg-config cairo --libs").}
|
||||
else:
|
||||
when defined(windows):
|
||||
const LIB_CAIRO* = "libcairo-2.dll"
|
||||
elif defined(macosx):
|
||||
const LIB_CAIRO* = "libcairo.dylib"
|
||||
else:
|
||||
const LIB_CAIRO* = "libcairo.so(|.2)"
|
||||
{.pragma: libcairo, cdecl, dynlib: LIB_CAIRO.}
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
import
|
||||
cairo, freetypeh
|
||||
|
||||
include "cairo_pragma.nim"
|
||||
#todo: properly define FcPattern:
|
||||
#It will require translate FontConfig header
|
||||
|
||||
|
|
@ -23,13 +24,13 @@ type
|
|||
FcPattern* = Pointer
|
||||
PFcPattern* = ptr FcPattern
|
||||
|
||||
proc ft_font_face_create_for_pattern*(pattern: PFcPattern): PFontFace{.cdecl,
|
||||
importc: "cairo_ft_font_face_create_for_pattern", dynlib: LIB_CAIRO.}
|
||||
proc ft_font_face_create_for_pattern*(pattern: PFcPattern): PFontFace{.libcairo,
|
||||
importc: "cairo_ft_font_face_create_for_pattern".}
|
||||
proc ft_font_options_substitute*(options: PFontOptions, pattern: PFcPattern){.
|
||||
cdecl, importc: "cairo_ft_font_options_substitute", dynlib: LIB_CAIRO.}
|
||||
proc ft_font_face_create_for_ft_face*(face: TFT_Face, load_flags: int32): PFontFace{.
|
||||
cdecl, importc: "cairo_ft_font_face_create_for_ft_face", dynlib: LIB_CAIRO.}
|
||||
proc ft_scaled_font_lock_face*(scaled_font: PScaledFont): TFT_Face{.cdecl,
|
||||
importc: "cairo_ft_scaled_font_lock_face", dynlib: LIB_CAIRO.}
|
||||
proc ft_scaled_font_unlock_face*(scaled_font: PScaledFont){.cdecl,
|
||||
importc: "cairo_ft_scaled_font_unlock_face", dynlib: LIB_CAIRO.}
|
||||
libcairo, importc: "cairo_ft_font_options_substitute".}
|
||||
proc ft_font_face_create_for_ft_face*(face: TFT_Face, load_flags: int32): PFontFace{.libcairo,
|
||||
importc: "cairo_ft_font_face_create_for_ft_face".}
|
||||
proc ft_scaled_font_lock_face*(scaled_font: PScaledFont): TFT_Face{.libcairo,
|
||||
importc: "cairo_ft_scaled_font_lock_face".}
|
||||
proc ft_scaled_font_unlock_face*(scaled_font: PScaledFont){.libcairo,
|
||||
importc: "cairo_ft_scaled_font_unlock_face".}
|
||||
|
|
|
|||
|
|
@ -7,33 +7,35 @@
|
|||
import
|
||||
cairo, x, xlib, xrender
|
||||
|
||||
include "cairo_pragma.nim"
|
||||
|
||||
proc xlib_surface_create*(dpy: PDisplay, drawable: TDrawable, visual: PVisual,
|
||||
width, height: int32): PSurface{.cdecl,
|
||||
importc: "cairo_xlib_surface_create", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_xlib_surface_create", libcairo.}
|
||||
proc xlib_surface_create_for_bitmap*(dpy: PDisplay, bitmap: TPixmap,
|
||||
screen: PScreen, width, height: int32): PSurface{.
|
||||
cdecl, importc: "cairo_xlib_surface_create_for_bitmap", dynlib: LIB_CAIRO.}
|
||||
cdecl, importc: "cairo_xlib_surface_create_for_bitmap", libcairo.}
|
||||
proc xlib_surface_create_with_xrender_format*(dpy: PDisplay,
|
||||
drawable: TDrawable, screen: PScreen, format: PXRenderPictFormat,
|
||||
width, height: int32): PSurface{.cdecl, importc: "cairo_xlib_surface_create_with_xrender_format",
|
||||
dynlib: LIB_CAIRO.}
|
||||
libcairo.}
|
||||
proc xlib_surface_get_depth*(surface: PSurface): int32{.cdecl,
|
||||
importc: "cairo_xlib_surface_get_depth", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_xlib_surface_get_depth", libcairo.}
|
||||
proc xlib_surface_get_display*(surface: PSurface): PDisplay{.cdecl,
|
||||
importc: "cairo_xlib_surface_get_display", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_xlib_surface_get_display", libcairo.}
|
||||
proc xlib_surface_get_drawable*(surface: PSurface): TDrawable{.cdecl,
|
||||
importc: "cairo_xlib_surface_get_drawable", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_xlib_surface_get_drawable", libcairo.}
|
||||
proc xlib_surface_get_height*(surface: PSurface): int32{.cdecl,
|
||||
importc: "cairo_xlib_surface_get_height", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_xlib_surface_get_height", libcairo.}
|
||||
proc xlib_surface_get_screen*(surface: PSurface): PScreen{.cdecl,
|
||||
importc: "cairo_xlib_surface_get_screen", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_xlib_surface_get_screen", libcairo.}
|
||||
proc xlib_surface_get_visual*(surface: PSurface): PVisual{.cdecl,
|
||||
importc: "cairo_xlib_surface_get_visual", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_xlib_surface_get_visual", libcairo.}
|
||||
proc xlib_surface_get_width*(surface: PSurface): int32{.cdecl,
|
||||
importc: "cairo_xlib_surface_get_width", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_xlib_surface_get_width", libcairo.}
|
||||
proc xlib_surface_set_size*(surface: PSurface, width, height: int32){.cdecl,
|
||||
importc: "cairo_xlib_surface_set_size", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_xlib_surface_set_size", libcairo.}
|
||||
proc xlib_surface_set_drawable*(surface: PSurface, drawable: TDrawable,
|
||||
width, height: int32){.cdecl,
|
||||
importc: "cairo_xlib_surface_set_drawable", dynlib: LIB_CAIRO.}
|
||||
importc: "cairo_xlib_surface_set_drawable", libcairo.}
|
||||
# implementation
|
||||
|
|
|
|||
|
|
@ -270,6 +270,7 @@
|
|||
#
|
||||
|
||||
{.deadCodeElim: on.}
|
||||
import unsigned
|
||||
when defined(windows):
|
||||
const
|
||||
LibName = "SDL.dll"
|
||||
|
|
@ -1807,7 +1808,7 @@ proc ListModes*(format: PPixelFormat, flags: int32): PPSDL_Rect{.cdecl,
|
|||
# applications that redraw the entire screen on every update.
|
||||
#
|
||||
# This function returns the video framebuffer surface, or NULL if it fails.
|
||||
proc SetVideoMode*(width, height, bpp: int, flags: int32): PSurface{.cdecl,
|
||||
proc SetVideoMode*(width, height, bpp: int, flags: uint32): PSurface{.cdecl,
|
||||
importc: "SDL_SetVideoMode", dynlib: LibName.}
|
||||
# Makes sure the given list of rectangles is updated on the given screen.
|
||||
# If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire
|
||||
|
|
|
|||
|
|
@ -163,6 +163,17 @@ proc IMG_Linked_Version*(): Pversion{.importc: "IMG_Linked_Version",
|
|||
# surface afterwards by calling:
|
||||
# SDL_SetColorKey(image, SDL_RLEACCEL, image.format.colorkey);
|
||||
#
|
||||
|
||||
const
|
||||
IMG_INIT_JPG* = 0x00000001
|
||||
IMG_INIT_PNG* = 0x00000002
|
||||
IMG_INIT_TIF* = 0x00000004
|
||||
IMG_INIT_WEBP* = 0x00000008
|
||||
|
||||
proc IMG_Init*(flags: cint): int {.cdecl, importc: "IMG_Init",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_Quit*() {.cdecl, importc: "IMG_Quit",
|
||||
dynlib: ImageLibName.}
|
||||
proc IMG_LoadTyped_RW*(src: PRWops, freesrc: cint, theType: cstring): PSurface{.
|
||||
cdecl, importc: "IMG_LoadTyped_RW", dynlib: ImageLibName.}
|
||||
# Convenience functions
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
# x.h
|
||||
#
|
||||
# Pointers to basic pascal types, inserted by h2pas conversion program.
|
||||
import unsigned
|
||||
|
||||
const
|
||||
X_PROTOCOL* = 11
|
||||
|
|
@ -47,6 +48,9 @@ type
|
|||
PKeyCode* = ptr TKeyCode
|
||||
TKeyCode* = cuchar
|
||||
|
||||
proc `==`*(a, b: TAtom): bool =
|
||||
return unsigned.`==`(a,b)
|
||||
|
||||
const
|
||||
None* = 0
|
||||
ParentRelative* = 1
|
||||
|
|
|
|||
20
lib/wrappers/x11/x11pragma.nim
Normal file
20
lib/wrappers/x11/x11pragma.nim
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# included from xlib bindings
|
||||
|
||||
|
||||
when defined(use_pkg_config) or defined(use_pkg_config_static):
|
||||
{.pragma: libx11, cdecl, importc.}
|
||||
{.pragma: libx11c, cdecl.}
|
||||
when defined(use_pkg_config_static):
|
||||
{.passl: gorge("pkg-config x11 --static --libs").}
|
||||
else:
|
||||
{.passl: gorge("pkg-config x11 --libs").}
|
||||
else:
|
||||
when defined(macosx):
|
||||
const
|
||||
libX11* = "libX11.dylib"
|
||||
else:
|
||||
const
|
||||
libX11* = "libX11.so"
|
||||
|
||||
{.pragma: libx11, cdecl, dynlib: libX11, importc.}
|
||||
{.pragma: libx11c, cdecl, dynlib: libX11.}
|
||||
|
|
@ -71,6 +71,8 @@
|
|||
import
|
||||
X, Xlib
|
||||
|
||||
include "x11pragma.nim"
|
||||
|
||||
proc XkbCharToInt*(v: int8): int16
|
||||
proc XkbIntTo2Chars*(i: int16, h, L: var int8)
|
||||
proc Xkb2CharsToInt*(h, L: int8): int16
|
||||
|
|
@ -1700,224 +1702,200 @@ proc XkbSetKeyShape*(g: PXkbGeometryPtr, k: PXkbKeyPtr, s: PXkbShapeDoodadPtr)
|
|||
proc XkbSetKeyColor*(g: PXkbGeometryPtr, k: PXkbKeyPtr, c: PXkbColorPtr)
|
||||
proc XkbGeomColorIndex*(g: PXkbGeometryPtr, c: PXkbColorPtr): int32
|
||||
proc XkbAddGeomProperty*(geom: PXkbGeometryPtr, name: cstring, value: cstring): PXkbPropertyPtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAddGeomProperty".}
|
||||
libx11c, importc: "XkbAddGeomProperty".}
|
||||
proc XkbAddGeomKeyAlias*(geom: PXkbGeometryPtr, alias: cstring, float: cstring): PXkbKeyAliasPtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAddGeomKeyAlias".}
|
||||
libx11c, importc: "XkbAddGeomKeyAlias".}
|
||||
proc XkbAddGeomColor*(geom: PXkbGeometryPtr, spec: cstring, pixel: int16): PXkbColorPtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAddGeomColor".}
|
||||
libx11c, importc: "XkbAddGeomColor".}
|
||||
proc XkbAddGeomOutline*(shape: PXkbShapePtr, sz_points: int16): PXkbOutlinePtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAddGeomOutline".}
|
||||
libx11c, importc: "XkbAddGeomOutline".}
|
||||
proc XkbAddGeomShape*(geom: PXkbGeometryPtr, name: TAtom, sz_outlines: int16): PXkbShapePtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAddGeomShape".}
|
||||
proc XkbAddGeomKey*(row: PXkbRowPtr): PXkbKeyPtr{.cdecl, dynlib: libX11,
|
||||
libx11c, importc: "XkbAddGeomShape".}
|
||||
proc XkbAddGeomKey*(row: PXkbRowPtr): PXkbKeyPtr{.libx11c,
|
||||
importc: "XkbAddGeomKey".}
|
||||
proc XkbAddGeomRow*(section: PXkbSectionPtr, sz_keys: int16): PXkbRowPtr{.cdecl,
|
||||
dynlib: libX11, importc: "XkbAddGeomRow".}
|
||||
proc XkbAddGeomRow*(section: PXkbSectionPtr, sz_keys: int16): PXkbRowPtr{.libx11c, importc: "XkbAddGeomRow".}
|
||||
proc XkbAddGeomSection*(geom: PXkbGeometryPtr, name: TAtom, sz_rows: int16,
|
||||
sz_doodads: int16, sz_overlays: int16): PXkbSectionPtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAddGeomSection".}
|
||||
libx11c, importc: "XkbAddGeomSection".}
|
||||
proc XkbAddGeomOverlay*(section: PXkbSectionPtr, name: TAtom, sz_rows: int16): PXkbOverlayPtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAddGeomOverlay".}
|
||||
libx11c, importc: "XkbAddGeomOverlay".}
|
||||
proc XkbAddGeomOverlayRow*(overlay: PXkbOverlayPtr, row_under: int16,
|
||||
sz_keys: int16): PXkbOverlayRowPtr{.cdecl,
|
||||
dynlib: libX11, importc: "XkbAddGeomOverlayRow".}
|
||||
sz_keys: int16): PXkbOverlayRowPtr{.libx11c, importc: "XkbAddGeomOverlayRow".}
|
||||
proc XkbAddGeomOverlayKey*(overlay: PXkbOverlayPtr, row: PXkbOverlayRowPtr,
|
||||
over: cstring, under: cstring): PXkbOverlayKeyPtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAddGeomOverlayKey".}
|
||||
libx11c, importc: "XkbAddGeomOverlayKey".}
|
||||
proc XkbAddGeomDoodad*(geom: PXkbGeometryPtr, section: PXkbSectionPtr,
|
||||
name: TAtom): PXkbDoodadPtr{.cdecl, dynlib: libX11,
|
||||
name: TAtom): PXkbDoodadPtr{.libx11c,
|
||||
importc: "XkbAddGeomDoodad".}
|
||||
proc XkbFreeGeomKeyAliases*(geom: PXkbGeometryPtr, first: int16, count: int16,
|
||||
freeAll: bool){.cdecl, dynlib: libX11,
|
||||
freeAll: bool){.libx11c,
|
||||
importc: "XkbFreeGeomKeyAliases".}
|
||||
proc XkbFreeGeomColors*(geom: PXkbGeometryPtr, first: int16, count: int16,
|
||||
freeAll: bool){.cdecl, dynlib: libX11,
|
||||
freeAll: bool){.libx11c,
|
||||
importc: "XkbFreeGeomColors".}
|
||||
proc XkbFreeGeomDoodads*(doodads: PXkbDoodadPtr, nDoodads: int16, freeAll: bool){.
|
||||
cdecl, dynlib: libX11, importc: "XkbFreeGeomDoodads".}
|
||||
libx11c, importc: "XkbFreeGeomDoodads".}
|
||||
proc XkbFreeGeomProperties*(geom: PXkbGeometryPtr, first: int16, count: int16,
|
||||
freeAll: bool){.cdecl, dynlib: libX11,
|
||||
freeAll: bool){.libx11c,
|
||||
importc: "XkbFreeGeomProperties".}
|
||||
proc XkbFreeGeomOverlayKeys*(row: PXkbOverlayRowPtr, first: int16, count: int16,
|
||||
freeAll: bool){.cdecl, dynlib: libX11,
|
||||
freeAll: bool){.libx11c,
|
||||
importc: "XkbFreeGeomOverlayKeys".}
|
||||
proc XkbFreeGeomOverlayRows*(overlay: PXkbOverlayPtr, first: int16,
|
||||
count: int16, freeAll: bool){.cdecl,
|
||||
dynlib: libX11, importc: "XkbFreeGeomOverlayRows".}
|
||||
count: int16, freeAll: bool){.libx11c, importc: "XkbFreeGeomOverlayRows".}
|
||||
proc XkbFreeGeomOverlays*(section: PXkbSectionPtr, first: int16, count: int16,
|
||||
freeAll: bool){.cdecl, dynlib: libX11,
|
||||
freeAll: bool){.libx11c,
|
||||
importc: "XkbFreeGeomOverlays".}
|
||||
proc XkbFreeGeomKeys*(row: PXkbRowPtr, first: int16, count: int16, freeAll: bool){.
|
||||
cdecl, dynlib: libX11, importc: "XkbFreeGeomKeys".}
|
||||
libx11c, importc: "XkbFreeGeomKeys".}
|
||||
proc XkbFreeGeomRows*(section: PXkbSectionPtr, first: int16, count: int16,
|
||||
freeAll: bool){.cdecl, dynlib: libX11,
|
||||
freeAll: bool){.libx11c,
|
||||
importc: "XkbFreeGeomRows".}
|
||||
proc XkbFreeGeomSections*(geom: PXkbGeometryPtr, first: int16, count: int16,
|
||||
freeAll: bool){.cdecl, dynlib: libX11,
|
||||
freeAll: bool){.libx11c,
|
||||
importc: "XkbFreeGeomSections".}
|
||||
proc XkbFreeGeomPoints*(outline: PXkbOutlinePtr, first: int16, count: int16,
|
||||
freeAll: bool){.cdecl, dynlib: libX11,
|
||||
freeAll: bool){.libx11c,
|
||||
importc: "XkbFreeGeomPoints".}
|
||||
proc XkbFreeGeomOutlines*(shape: PXkbShapePtr, first: int16, count: int16,
|
||||
freeAll: bool){.cdecl, dynlib: libX11,
|
||||
freeAll: bool){.libx11c,
|
||||
importc: "XkbFreeGeomOutlines".}
|
||||
proc XkbFreeGeomShapes*(geom: PXkbGeometryPtr, first: int16, count: int16,
|
||||
freeAll: bool){.cdecl, dynlib: libX11,
|
||||
freeAll: bool){.libx11c,
|
||||
importc: "XkbFreeGeomShapes".}
|
||||
proc XkbFreeGeometry*(geom: PXkbGeometryPtr, which: int16, freeMap: bool){.
|
||||
cdecl, dynlib: libX11, importc: "XkbFreeGeometry".}
|
||||
proc XkbAllocGeomProps*(geom: PXkbGeometryPtr, nProps: int16): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbAllocGeomProps".}
|
||||
libx11c, importc: "XkbFreeGeometry".}
|
||||
proc XkbAllocGeomProps*(geom: PXkbGeometryPtr, nProps: int16): TStatus{.libx11c, importc: "XkbAllocGeomProps".}
|
||||
proc XkbAllocGeomKeyAliases*(geom: PXkbGeometryPtr, nAliases: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocGeomKeyAliases".}
|
||||
proc XkbAllocGeomColors*(geom: PXkbGeometryPtr, nColors: int16): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbAllocGeomColors".}
|
||||
proc XkbAllocGeomShapes*(geom: PXkbGeometryPtr, nShapes: int16): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbAllocGeomShapes".}
|
||||
libx11c, importc: "XkbAllocGeomKeyAliases".}
|
||||
proc XkbAllocGeomColors*(geom: PXkbGeometryPtr, nColors: int16): TStatus{.libx11c, importc: "XkbAllocGeomColors".}
|
||||
proc XkbAllocGeomShapes*(geom: PXkbGeometryPtr, nShapes: int16): TStatus{.libx11c, importc: "XkbAllocGeomShapes".}
|
||||
proc XkbAllocGeomSections*(geom: PXkbGeometryPtr, nSections: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocGeomSections".}
|
||||
libx11c, importc: "XkbAllocGeomSections".}
|
||||
proc XkbAllocGeomOverlays*(section: PXkbSectionPtr, num_needed: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocGeomOverlays".}
|
||||
libx11c, importc: "XkbAllocGeomOverlays".}
|
||||
proc XkbAllocGeomOverlayRows*(overlay: PXkbOverlayPtr, num_needed: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocGeomOverlayRows".}
|
||||
libx11c, importc: "XkbAllocGeomOverlayRows".}
|
||||
proc XkbAllocGeomOverlayKeys*(row: PXkbOverlayRowPtr, num_needed: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocGeomOverlayKeys".}
|
||||
libx11c, importc: "XkbAllocGeomOverlayKeys".}
|
||||
proc XkbAllocGeomDoodads*(geom: PXkbGeometryPtr, nDoodads: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocGeomDoodads".}
|
||||
libx11c, importc: "XkbAllocGeomDoodads".}
|
||||
proc XkbAllocGeomSectionDoodads*(section: PXkbSectionPtr, nDoodads: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocGeomSectionDoodads".}
|
||||
proc XkbAllocGeomOutlines*(shape: PXkbShapePtr, nOL: int16): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbAllocGeomOutlines".}
|
||||
proc XkbAllocGeomRows*(section: PXkbSectionPtr, nRows: int16): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbAllocGeomRows".}
|
||||
proc XkbAllocGeomPoints*(ol: PXkbOutlinePtr, nPts: int16): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbAllocGeomPoints".}
|
||||
proc XkbAllocGeomKeys*(row: PXkbRowPtr, nKeys: int16): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbAllocGeomKeys".}
|
||||
libx11c, importc: "XkbAllocGeomSectionDoodads".}
|
||||
proc XkbAllocGeomOutlines*(shape: PXkbShapePtr, nOL: int16): TStatus{.libx11c, importc: "XkbAllocGeomOutlines".}
|
||||
proc XkbAllocGeomRows*(section: PXkbSectionPtr, nRows: int16): TStatus{.libx11c, importc: "XkbAllocGeomRows".}
|
||||
proc XkbAllocGeomPoints*(ol: PXkbOutlinePtr, nPts: int16): TStatus{.libx11c, importc: "XkbAllocGeomPoints".}
|
||||
proc XkbAllocGeomKeys*(row: PXkbRowPtr, nKeys: int16): TStatus{.libx11c, importc: "XkbAllocGeomKeys".}
|
||||
proc XkbAllocGeometry*(xkb: PXkbDescPtr, sizes: PXkbGeometrySizesPtr): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocGeometry".}
|
||||
libx11c, importc: "XkbAllocGeometry".}
|
||||
proc XkbSetGeometryProc*(dpy: PDisplay, deviceSpec: int16, geom: PXkbGeometryPtr): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbSetGeometry".}
|
||||
libx11c, importc: "XkbSetGeometry".}
|
||||
proc XkbComputeShapeTop*(shape: PXkbShapePtr, bounds: PXkbBoundsPtr): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbComputeShapeTop".}
|
||||
proc XkbComputeShapeBounds*(shape: PXkbShapePtr): bool{.cdecl, dynlib: libX11,
|
||||
libx11c, importc: "XkbComputeShapeTop".}
|
||||
proc XkbComputeShapeBounds*(shape: PXkbShapePtr): bool{.libx11c,
|
||||
importc: "XkbComputeShapeBounds".}
|
||||
proc XkbComputeRowBounds*(geom: PXkbGeometryPtr, section: PXkbSectionPtr,
|
||||
row: PXkbRowPtr): bool{.cdecl, dynlib: libX11,
|
||||
row: PXkbRowPtr): bool{.libx11c,
|
||||
importc: "XkbComputeRowBounds".}
|
||||
proc XkbComputeSectionBounds*(geom: PXkbGeometryPtr, section: PXkbSectionPtr): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbComputeSectionBounds".}
|
||||
libx11c, importc: "XkbComputeSectionBounds".}
|
||||
proc XkbFindOverlayForKey*(geom: PXkbGeometryPtr, wanted: PXkbSectionPtr,
|
||||
under: cstring): cstring{.cdecl, dynlib: libX11,
|
||||
under: cstring): cstring{.libx11c,
|
||||
importc: "XkbFindOverlayForKey".}
|
||||
proc XkbGetGeometryProc*(dpy: PDisplay, xkb: PXkbDescPtr): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbGetGeometry".}
|
||||
proc XkbGetGeometryProc*(dpy: PDisplay, xkb: PXkbDescPtr): TStatus{.libx11c, importc: "XkbGetGeometry".}
|
||||
proc XkbGetNamedGeometry*(dpy: PDisplay, xkb: PXkbDescPtr, name: TAtom): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetNamedGeometry".}
|
||||
libx11c, importc: "XkbGetNamedGeometry".}
|
||||
when defined(XKB_IN_SERVER):
|
||||
proc SrvXkbAddGeomKeyAlias*(geom: PXkbGeometryPtr, alias: cstring,
|
||||
float: cstring): PXkbKeyAliasPtr{.cdecl,
|
||||
dynlib: libX11, importc: "XkbAddGeomKeyAlias".}
|
||||
float: cstring): PXkbKeyAliasPtr{.libx11c, importc: "XkbAddGeomKeyAlias".}
|
||||
proc SrvXkbAddGeomColor*(geom: PXkbGeometryPtr, spec: cstring, pixel: int16): PXkbColorPtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAddGeomColor".}
|
||||
libx11c, importc: "XkbAddGeomColor".}
|
||||
proc SrvXkbAddGeomDoodad*(geom: PXkbGeometryPtr, section: PXkbSectionPtr,
|
||||
name: TAtom): PXkbDoodadPtr{.cdecl, dynlib: libX11,
|
||||
name: TAtom): PXkbDoodadPtr{.libx11c,
|
||||
importc: "XkbAddGeomDoodad".}
|
||||
proc SrvXkbAddGeomKey*(geom: PXkbGeometryPtr, alias: cstring, float: cstring): PXkbKeyAliasPtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAddGeomKeyAlias".}
|
||||
libx11c, importc: "XkbAddGeomKeyAlias".}
|
||||
proc SrvXkbAddGeomOutline*(shape: PXkbShapePtr, sz_points: int16): PXkbOutlinePtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAddGeomOutline".}
|
||||
libx11c, importc: "XkbAddGeomOutline".}
|
||||
proc SrvXkbAddGeomOverlay*(overlay: PXkbOverlayPtr, row: PXkbOverlayRowPtr,
|
||||
over: cstring, under: cstring): PXkbOverlayKeyPtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAddGeomOverlayKey".}
|
||||
libx11c, importc: "XkbAddGeomOverlayKey".}
|
||||
proc SrvXkbAddGeomOverlayRow*(overlay: PXkbOverlayPtr, row_under: int16,
|
||||
sz_keys: int16): PXkbOverlayRowPtr{.cdecl,
|
||||
dynlib: libX11, importc: "XkbAddGeomOverlayRow".}
|
||||
sz_keys: int16): PXkbOverlayRowPtr{.libx11c, importc: "XkbAddGeomOverlayRow".}
|
||||
proc SrvXkbAddGeomOverlayKey*(overlay: PXkbOverlayPtr, row: PXkbOverlayRowPtr,
|
||||
over: cstring, under: cstring): PXkbOverlayKeyPtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAddGeomOverlayKey".}
|
||||
libx11c, importc: "XkbAddGeomOverlayKey".}
|
||||
proc SrvXkbAddGeomProperty*(geom: PXkbGeometryPtr, name: cstring,
|
||||
value: cstring): PXkbPropertyPtr{.cdecl,
|
||||
dynlib: libX11, importc: "XkbAddGeomProperty".}
|
||||
value: cstring): PXkbPropertyPtr{.libx11c, importc: "XkbAddGeomProperty".}
|
||||
proc SrvXkbAddGeomRow*(section: PXkbSectionPtr, sz_keys: int16): PXkbRowPtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAddGeomRow".}
|
||||
libx11c, importc: "XkbAddGeomRow".}
|
||||
proc SrvXkbAddGeomSection*(geom: PXkbGeometryPtr, name: TAtom, sz_rows: int16,
|
||||
sz_doodads: int16, sz_overlays: int16): PXkbSectionPtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAddGeomSection".}
|
||||
libx11c, importc: "XkbAddGeomSection".}
|
||||
proc SrvXkbAddGeomShape*(geom: PXkbGeometryPtr, name: TAtom,
|
||||
sz_outlines: int16): PXkbShapePtr{.cdecl,
|
||||
dynlib: libX11, importc: "XkbAddGeomShape".}
|
||||
sz_outlines: int16): PXkbShapePtr{.libx11c, importc: "XkbAddGeomShape".}
|
||||
proc SrvXkbAllocGeomKeyAliases*(geom: PXkbGeometryPtr, nAliases: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocGeomKeyAliases".}
|
||||
libx11c, importc: "XkbAllocGeomKeyAliases".}
|
||||
proc SrvXkbAllocGeomColors*(geom: PXkbGeometryPtr, nColors: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocGeomColors".}
|
||||
libx11c, importc: "XkbAllocGeomColors".}
|
||||
proc SrvXkbAllocGeomDoodads*(geom: PXkbGeometryPtr, nDoodads: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocGeomDoodads".}
|
||||
proc SrvXkbAllocGeomKeys*(row: PXkbRowPtr, nKeys: int16): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbAllocGeomKeys".}
|
||||
libx11c, importc: "XkbAllocGeomDoodads".}
|
||||
proc SrvXkbAllocGeomKeys*(row: PXkbRowPtr, nKeys: int16): TStatus{.libx11c, importc: "XkbAllocGeomKeys".}
|
||||
proc SrvXkbAllocGeomOutlines*(shape: PXkbShapePtr, nOL: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocGeomOutlines".}
|
||||
proc SrvXkbAllocGeomPoints*(ol: PXkbOutlinePtr, nPts: int16): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbAllocGeomPoints".}
|
||||
libx11c, importc: "XkbAllocGeomOutlines".}
|
||||
proc SrvXkbAllocGeomPoints*(ol: PXkbOutlinePtr, nPts: int16): TStatus{.libx11c, importc: "XkbAllocGeomPoints".}
|
||||
proc SrvXkbAllocGeomProps*(geom: PXkbGeometryPtr, nProps: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocGeomProps".}
|
||||
libx11c, importc: "XkbAllocGeomProps".}
|
||||
proc SrvXkbAllocGeomRows*(section: PXkbSectionPtr, nRows: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocGeomRows".}
|
||||
libx11c, importc: "XkbAllocGeomRows".}
|
||||
proc SrvXkbAllocGeomSectionDoodads*(section: PXkbSectionPtr, nDoodads: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocGeomSectionDoodads".}
|
||||
libx11c, importc: "XkbAllocGeomSectionDoodads".}
|
||||
proc SrvXkbAllocGeomSections*(geom: PXkbGeometryPtr, nSections: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocGeomSections".}
|
||||
libx11c, importc: "XkbAllocGeomSections".}
|
||||
proc SrvXkbAllocGeomOverlays*(section: PXkbSectionPtr, num_needed: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocGeomOverlays".}
|
||||
libx11c, importc: "XkbAllocGeomOverlays".}
|
||||
proc SrvXkbAllocGeomOverlayRows*(overlay: PXkbOverlayPtr, num_needed: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocGeomOverlayRows".}
|
||||
libx11c, importc: "XkbAllocGeomOverlayRows".}
|
||||
proc SrvXkbAllocGeomOverlayKeys*(row: PXkbOverlayRowPtr, num_needed: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocGeomOverlayKeys".}
|
||||
libx11c, importc: "XkbAllocGeomOverlayKeys".}
|
||||
proc SrvXkbAllocGeomShapes*(geom: PXkbGeometryPtr, nShapes: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocGeomShapes".}
|
||||
libx11c, importc: "XkbAllocGeomShapes".}
|
||||
proc SrvXkbAllocGeometry*(xkb: PXkbDescPtr, sizes: PXkbGeometrySizesPtr): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocGeometry".}
|
||||
libx11c, importc: "XkbAllocGeometry".}
|
||||
proc SrvXkbFreeGeomKeyAliases*(geom: PXkbGeometryPtr, first: int16,
|
||||
count: int16, freeAll: bool){.cdecl,
|
||||
dynlib: libX11, importc: "XkbFreeGeomKeyAliases".}
|
||||
count: int16, freeAll: bool){.libx11c, importc: "XkbFreeGeomKeyAliases".}
|
||||
proc SrvXkbFreeGeomColors*(geom: PXkbGeometryPtr, first: int16, count: int16,
|
||||
freeAll: bool){.cdecl, dynlib: libX11,
|
||||
freeAll: bool){.libx11c,
|
||||
importc: "XkbFreeGeomColors".}
|
||||
proc SrvXkbFreeGeomDoodads*(doodads: PXkbDoodadPtr, nDoodads: int16,
|
||||
freeAll: bool){.cdecl, dynlib: libX11,
|
||||
freeAll: bool){.libx11c,
|
||||
importc: "XkbFreeGeomDoodads".}
|
||||
proc SrvXkbFreeGeomProperties*(geom: PXkbGeometryPtr, first: int16,
|
||||
count: int16, freeAll: bool){.cdecl,
|
||||
dynlib: libX11, importc: "XkbFreeGeomProperties".}
|
||||
count: int16, freeAll: bool){.libx11c, importc: "XkbFreeGeomProperties".}
|
||||
proc SrvXkbFreeGeomOverlayKeys*(row: PXkbOverlayRowPtr, first: int16,
|
||||
count: int16, freeAll: bool){.cdecl,
|
||||
dynlib: libX11, importc: "XkbFreeGeomOverlayKeys".}
|
||||
count: int16, freeAll: bool){.libx11c, importc: "XkbFreeGeomOverlayKeys".}
|
||||
proc SrvXkbFreeGeomOverlayRows*(overlay: PXkbOverlayPtr, first: int16,
|
||||
count: int16, freeAll: bool){.cdecl,
|
||||
dynlib: libX11, importc: "XkbFreeGeomOverlayRows".}
|
||||
count: int16, freeAll: bool){.libx11c, importc: "XkbFreeGeomOverlayRows".}
|
||||
proc SrvXkbFreeGeomOverlays*(section: PXkbSectionPtr, first: int16,
|
||||
count: int16, freeAll: bool){.cdecl,
|
||||
dynlib: libX11, importc: "XkbFreeGeomOverlays".}
|
||||
count: int16, freeAll: bool){.libx11c, importc: "XkbFreeGeomOverlays".}
|
||||
proc SrvXkbFreeGeomKeys*(row: PXkbRowPtr, first: int16, count: int16,
|
||||
freeAll: bool){.cdecl, dynlib: libX11,
|
||||
freeAll: bool){.libx11c,
|
||||
importc: "XkbFreeGeomKeys".}
|
||||
proc SrvXkbFreeGeomRows*(section: PXkbSectionPtr, first: int16, count: int16,
|
||||
freeAll: bool){.cdecl, dynlib: libX11,
|
||||
freeAll: bool){.libx11c,
|
||||
importc: "XkbFreeGeomRows".}
|
||||
proc SrvXkbFreeGeomSections*(geom: PXkbGeometryPtr, first: int16,
|
||||
count: int16, freeAll: bool){.cdecl,
|
||||
dynlib: libX11, importc: "XkbFreeGeomSections".}
|
||||
count: int16, freeAll: bool){.libx11c, importc: "XkbFreeGeomSections".}
|
||||
proc SrvXkbFreeGeomPoints*(outline: PXkbOutlinePtr, first: int16,
|
||||
count: int16, freeAll: bool){.cdecl,
|
||||
dynlib: libX11, importc: "XkbFreeGeomPoints".}
|
||||
count: int16, freeAll: bool){.libx11c, importc: "XkbFreeGeomPoints".}
|
||||
proc SrvXkbFreeGeomOutlines*(shape: PXkbShapePtr, first: int16, count: int16,
|
||||
freeAll: bool){.cdecl, dynlib: libX11,
|
||||
freeAll: bool){.libx11c,
|
||||
importc: "XkbFreeGeomOutlines".}
|
||||
proc SrvXkbFreeGeomShapes*(geom: PXkbGeometryPtr, first: int16, count: int16,
|
||||
freeAll: bool){.cdecl, dynlib: libX11,
|
||||
freeAll: bool){.libx11c,
|
||||
importc: "XkbFreeGeomShapes".}
|
||||
proc SrvXkbFreeGeometry*(geom: PXkbGeometryPtr, which: int16, freeMap: bool){.
|
||||
cdecl, dynlib: libX11, importc: "XkbFreeGeometry".}
|
||||
libx11c, importc: "XkbFreeGeometry".}
|
||||
# implementation
|
||||
|
||||
import #************************************ xkb ************************************
|
||||
|
|
|
|||
|
|
@ -52,6 +52,10 @@
|
|||
import
|
||||
X, Xlib, XKB
|
||||
|
||||
|
||||
include "x11pragma.nim"
|
||||
|
||||
|
||||
type
|
||||
PXkbAnyEvent* = ptr TXkbAnyEvent
|
||||
TXkbAnyEvent*{.final.} = object
|
||||
|
|
@ -338,21 +342,18 @@ const
|
|||
XkbLC_AllComposeControls* = 0xC0000000
|
||||
XkbLC_AllControls* = 0xC000001F
|
||||
|
||||
proc XkbIgnoreExtension*(ignore: bool): bool{.cdecl, dynlib: libX11,
|
||||
proc XkbIgnoreExtension*(ignore: bool): bool{.libx11c,
|
||||
importc: "XkbIgnoreExtension".}
|
||||
proc XkbOpenDisplay*(name: cstring, ev_rtrn, err_rtrn, major_rtrn, minor_rtrn,
|
||||
reason: ptr int16): PDisplay{.cdecl,
|
||||
dynlib: libX11, importc: "XkbOpenDisplay".}
|
||||
reason: ptr int16): PDisplay{.libx11c, importc: "XkbOpenDisplay".}
|
||||
proc XkbQueryExtension*(dpy: PDisplay, opcodeReturn, eventBaseReturn,
|
||||
errorBaseReturn, majorRtrn, minorRtrn: ptr int16): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbQueryExtension".}
|
||||
libx11c, importc: "XkbQueryExtension".}
|
||||
proc XkbUseExtension*(dpy: PDisplay, major_rtrn, minor_rtrn: ptr int16): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbUseExtension".}
|
||||
proc XkbLibraryVersion*(libMajorRtrn, libMinorRtrn: ptr int16): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbLibraryVersion".}
|
||||
proc XkbSetXlibControls*(dpy: PDisplay, affect, values: int16): int16{.cdecl,
|
||||
dynlib: libX11, importc: "XkbSetXlibControls".}
|
||||
proc XkbGetXlibControls*(dpy: PDisplay): int16{.cdecl, dynlib: libX11,
|
||||
libx11c, importc: "XkbUseExtension".}
|
||||
proc XkbLibraryVersion*(libMajorRtrn, libMinorRtrn: ptr int16): bool{.libx11c, importc: "XkbLibraryVersion".}
|
||||
proc XkbSetXlibControls*(dpy: PDisplay, affect, values: int16): int16{.libx11c, importc: "XkbSetXlibControls".}
|
||||
proc XkbGetXlibControls*(dpy: PDisplay): int16{.libx11c,
|
||||
importc: "XkbGetXlibControls".}
|
||||
type
|
||||
TXkbInternAtomFunc* = proc (dpy: PDisplay, name: cstring, only_if_exists: bool): TAtom{.
|
||||
|
|
@ -362,68 +363,64 @@ type
|
|||
TXkbGetAtomNameFunc* = proc (dpy: PDisplay, atom: TAtom): cstring{.cdecl.}
|
||||
|
||||
proc XkbSetAtomFuncs*(getAtom: TXkbInternAtomFunc, getName: TXkbGetAtomNameFunc){.
|
||||
cdecl, dynlib: libX11, importc: "XkbSetAtomFuncs".}
|
||||
libx11c, importc: "XkbSetAtomFuncs".}
|
||||
proc XkbKeycodeToKeysym*(dpy: PDisplay, kc: TKeyCode, group, level: int16): TKeySym{.
|
||||
cdecl, dynlib: libX11, importc: "XkbKeycodeToKeysym".}
|
||||
proc XkbKeysymToModifiers*(dpy: PDisplay, ks: TKeySym): int16{.cdecl,
|
||||
dynlib: libX11, importc: "XkbKeysymToModifiers".}
|
||||
libx11c, importc: "XkbKeycodeToKeysym".}
|
||||
proc XkbKeysymToModifiers*(dpy: PDisplay, ks: TKeySym): int16{.libx11c, importc: "XkbKeysymToModifiers".}
|
||||
proc XkbLookupKeySym*(dpy: PDisplay, keycode: TKeyCode,
|
||||
modifiers, modifiers_return: int16, keysym_return: PKeySym): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbLookupKeySym".}
|
||||
libx11c, importc: "XkbLookupKeySym".}
|
||||
proc XkbLookupKeyBinding*(dpy: PDisplay, sym_rtrn: TKeySym, mods: int16,
|
||||
buffer: cstring, nbytes: int16, extra_rtrn: ptr int16): int16{.
|
||||
cdecl, dynlib: libX11, importc: "XkbLookupKeyBinding".}
|
||||
libx11c, importc: "XkbLookupKeyBinding".}
|
||||
proc XkbTranslateKeyCode*(xkb: PXkbDescPtr, keycode: TKeyCode,
|
||||
modifiers, modifiers_return: int16,
|
||||
keysym_return: PKeySym): bool{.cdecl, dynlib: libX11,
|
||||
keysym_return: PKeySym): bool{.libx11c,
|
||||
importc: "XkbTranslateKeyCode".}
|
||||
proc XkbTranslateKeySym*(dpy: PDisplay, sym_return: TKeySym, modifiers: int16,
|
||||
buffer: cstring, nbytes: int16, extra_rtrn: ptr int16): int16{.
|
||||
cdecl, dynlib: libX11, importc: "XkbTranslateKeySym".}
|
||||
libx11c, importc: "XkbTranslateKeySym".}
|
||||
proc XkbSetAutoRepeatRate*(dpy: PDisplay, deviceSpec, delay, interval: int16): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbSetAutoRepeatRate".}
|
||||
libx11c, importc: "XkbSetAutoRepeatRate".}
|
||||
proc XkbGetAutoRepeatRate*(dpy: PDisplay, deviceSpec: int16,
|
||||
delayRtrn, intervalRtrn: PWord): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbGetAutoRepeatRate".}
|
||||
delayRtrn, intervalRtrn: PWord): bool{.libx11c, importc: "XkbGetAutoRepeatRate".}
|
||||
proc XkbChangeEnabledControls*(dpy: PDisplay, deviceSpec, affect, values: int16): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbChangeEnabledControls".}
|
||||
libx11c, importc: "XkbChangeEnabledControls".}
|
||||
proc XkbDeviceBell*(dpy: PDisplay, win: TWindow,
|
||||
deviceSpec, bellClass, bellID, percent: int16, name: TAtom): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbDeviceBell".}
|
||||
libx11c, importc: "XkbDeviceBell".}
|
||||
proc XkbForceDeviceBell*(dpy: PDisplay,
|
||||
deviceSpec, bellClass, bellID, percent: int16): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbForceDeviceBell".}
|
||||
libx11c, importc: "XkbForceDeviceBell".}
|
||||
proc XkbDeviceBellEvent*(dpy: PDisplay, win: TWindow,
|
||||
deviceSpec, bellClass, bellID, percent: int16,
|
||||
name: TAtom): bool{.cdecl, dynlib: libX11,
|
||||
name: TAtom): bool{.libx11c,
|
||||
importc: "XkbDeviceBellEvent".}
|
||||
proc XkbBell*(dpy: PDisplay, win: TWindow, percent: int16, name: TAtom): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbBell".}
|
||||
proc XkbForceBell*(dpy: PDisplay, percent: int16): bool{.cdecl, dynlib: libX11,
|
||||
libx11c, importc: "XkbBell".}
|
||||
proc XkbForceBell*(dpy: PDisplay, percent: int16): bool{.libx11c,
|
||||
importc: "XkbForceBell".}
|
||||
proc XkbBellEvent*(dpy: PDisplay, win: TWindow, percent: int16, name: TAtom): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbBellEvent".}
|
||||
libx11c, importc: "XkbBellEvent".}
|
||||
proc XkbSelectEvents*(dpy: PDisplay, deviceID, affect, values: int16): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbSelectEvents".}
|
||||
libx11c, importc: "XkbSelectEvents".}
|
||||
proc XkbSelectEventDetails*(dpy: PDisplay, deviceID, eventType: int16,
|
||||
affect, details: int32): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbSelectEventDetails".}
|
||||
affect, details: int32): bool{.libx11c, importc: "XkbSelectEventDetails".}
|
||||
proc XkbNoteMapChanges*(old: PXkbMapChangesPtr, new: PXkbMapNotifyEvent,
|
||||
wanted: int16){.cdecl, dynlib: libX11,
|
||||
wanted: int16){.libx11c,
|
||||
importc: "XkbNoteMapChanges".}
|
||||
proc XkbNoteNameChanges*(old: PXkbNameChangesPtr, new: PXkbNamesNotifyEvent,
|
||||
wanted: int16){.cdecl, dynlib: libX11,
|
||||
wanted: int16){.libx11c,
|
||||
importc: "XkbNoteNameChanges".}
|
||||
proc XkbGetIndicatorState*(dpy: PDisplay, deviceSpec: int16, pStateRtrn: PWord): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetIndicatorState".}
|
||||
libx11c, importc: "XkbGetIndicatorState".}
|
||||
proc XkbGetDeviceIndicatorState*(dpy: PDisplay,
|
||||
deviceSpec, ledClass, ledID: int16,
|
||||
pStateRtrn: PWord): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbGetDeviceIndicatorState".}
|
||||
pStateRtrn: PWord): TStatus{.libx11c, importc: "XkbGetDeviceIndicatorState".}
|
||||
proc XkbGetIndicatorMap*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetIndicatorMap".}
|
||||
libx11c, importc: "XkbGetIndicatorMap".}
|
||||
proc XkbSetIndicatorMap*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbSetIndicatorMap".}
|
||||
libx11c, importc: "XkbSetIndicatorMap".}
|
||||
proc XkbNoteIndicatorMapChanges*(o, n: PXkbIndicatorChangesPtr, w: int16)
|
||||
proc XkbNoteIndicatorStateChanges*(o, n: PXkbIndicatorChangesPtr, w: int16)
|
||||
proc XkbGetIndicatorMapChanges*(d: PDisplay, x: PXkbDescPtr,
|
||||
|
|
@ -432,176 +429,151 @@ proc XkbChangeIndicatorMaps*(d: PDisplay, x: PXkbDescPtr,
|
|||
c: PXkbIndicatorChangesPtr): bool
|
||||
proc XkbGetNamedIndicator*(dpy: PDisplay, name: TAtom, pNdxRtrn: ptr int16,
|
||||
pStateRtrn: ptr bool, pMapRtrn: PXkbIndicatorMapPtr,
|
||||
pRealRtrn: ptr bool): bool{.cdecl, dynlib: libX11,
|
||||
pRealRtrn: ptr bool): bool{.libx11c,
|
||||
importc: "XkbGetNamedIndicator".}
|
||||
proc XkbGetNamedDeviceIndicator*(dpy: PDisplay,
|
||||
deviceSpec, ledClass, ledID: int16,
|
||||
name: TAtom, pNdxRtrn: ptr int16,
|
||||
pStateRtrn: ptr bool,
|
||||
pMapRtrn: PXkbIndicatorMapPtr,
|
||||
pRealRtrn: ptr bool): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbGetNamedDeviceIndicator".}
|
||||
pRealRtrn: ptr bool): bool{.libx11c, importc: "XkbGetNamedDeviceIndicator".}
|
||||
proc XkbSetNamedIndicator*(dpy: PDisplay, name: TAtom,
|
||||
changeState, state, createNewMap: bool,
|
||||
pMap: PXkbIndicatorMapPtr): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbSetNamedIndicator".}
|
||||
pMap: PXkbIndicatorMapPtr): bool{.libx11c, importc: "XkbSetNamedIndicator".}
|
||||
proc XkbSetNamedDeviceIndicator*(dpy: PDisplay,
|
||||
deviceSpec, ledClass, ledID: int16,
|
||||
name: TAtom,
|
||||
changeState, state, createNewMap: bool,
|
||||
pMap: PXkbIndicatorMapPtr): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbSetNamedDeviceIndicator".}
|
||||
pMap: PXkbIndicatorMapPtr): bool{.libx11c, importc: "XkbSetNamedDeviceIndicator".}
|
||||
proc XkbLockModifiers*(dpy: PDisplay, deviceSpec, affect, values: int16): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbLockModifiers".}
|
||||
libx11c, importc: "XkbLockModifiers".}
|
||||
proc XkbLatchModifiers*(dpy: PDisplay, deviceSpec, affect, values: int16): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbLatchModifiers".}
|
||||
proc XkbLockGroup*(dpy: PDisplay, deviceSpec, group: int16): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbLockGroup".}
|
||||
proc XkbLatchGroup*(dpy: PDisplay, deviceSpec, group: int16): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbLatchGroup".}
|
||||
libx11c, importc: "XkbLatchModifiers".}
|
||||
proc XkbLockGroup*(dpy: PDisplay, deviceSpec, group: int16): bool{.libx11c, importc: "XkbLockGroup".}
|
||||
proc XkbLatchGroup*(dpy: PDisplay, deviceSpec, group: int16): bool{.libx11c, importc: "XkbLatchGroup".}
|
||||
proc XkbSetServerInternalMods*(dpy: PDisplay, deviceSpec, affectReal,
|
||||
realValues, affectVirtual, virtualValues: int16): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbSetServerInternalMods".}
|
||||
realValues, affectVirtual, virtualValues: int16): bool{.libx11c, importc: "XkbSetServerInternalMods".}
|
||||
proc XkbSetIgnoreLockMods*(dpy: PDisplay, deviceSpec, affectReal, realValues,
|
||||
affectVirtual, virtualValues: int16): bool{.cdecl, dynlib: libX11,
|
||||
affectVirtual, virtualValues: int16): bool{.libx11c,
|
||||
importc: "XkbSetIgnoreLockMods".}
|
||||
proc XkbVirtualModsToReal*(dpy: PDisplay, virtual_mask: int16, mask_rtrn: PWord): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbVirtualModsToReal".}
|
||||
libx11c, importc: "XkbVirtualModsToReal".}
|
||||
proc XkbComputeEffectiveMap*(xkb: PXkbDescPtr, theType: PXkbKeyTypePtr,
|
||||
map_rtrn: PByte): bool{.cdecl, dynlib: libX11,
|
||||
map_rtrn: PByte): bool{.libx11c,
|
||||
importc: "XkbComputeEffectiveMap".}
|
||||
proc XkbInitCanonicalKeyTypes*(xkb: PXkbDescPtr, which: int16, keypadVMod: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbInitCanonicalKeyTypes".}
|
||||
proc XkbAllocKeyboard*(): PXkbDescPtr{.cdecl, dynlib: libX11,
|
||||
libx11c, importc: "XkbInitCanonicalKeyTypes".}
|
||||
proc XkbAllocKeyboard*(): PXkbDescPtr{.libx11c,
|
||||
importc: "XkbAllocKeyboard".}
|
||||
proc XkbFreeKeyboard*(xkb: PXkbDescPtr, which: int16, freeDesc: bool){.cdecl,
|
||||
dynlib: libX11, importc: "XkbFreeKeyboard".}
|
||||
proc XkbAllocClientMap*(xkb: PXkbDescPtr, which, nTypes: int16): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbAllocClientMap".}
|
||||
proc XkbFreeKeyboard*(xkb: PXkbDescPtr, which: int16, freeDesc: bool){.libx11c, importc: "XkbFreeKeyboard".}
|
||||
proc XkbAllocClientMap*(xkb: PXkbDescPtr, which, nTypes: int16): TStatus{.libx11c, importc: "XkbAllocClientMap".}
|
||||
proc XkbAllocServerMap*(xkb: PXkbDescPtr, which, nActions: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocServerMap".}
|
||||
proc XkbFreeClientMap*(xkb: PXkbDescPtr, what: int16, freeMap: bool){.cdecl,
|
||||
dynlib: libX11, importc: "XkbFreeClientMap".}
|
||||
proc XkbFreeServerMap*(xkb: PXkbDescPtr, what: int16, freeMap: bool){.cdecl,
|
||||
dynlib: libX11, importc: "XkbFreeServerMap".}
|
||||
libx11c, importc: "XkbAllocServerMap".}
|
||||
proc XkbFreeClientMap*(xkb: PXkbDescPtr, what: int16, freeMap: bool){.libx11c, importc: "XkbFreeClientMap".}
|
||||
proc XkbFreeServerMap*(xkb: PXkbDescPtr, what: int16, freeMap: bool){.libx11c, importc: "XkbFreeServerMap".}
|
||||
proc XkbAddKeyType*(xkb: PXkbDescPtr, name: TAtom, map_count: int16,
|
||||
want_preserve: bool, num_lvls: int16): PXkbKeyTypePtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAddKeyType".}
|
||||
proc XkbAllocIndicatorMaps*(xkb: PXkbDescPtr): TStatus{.cdecl, dynlib: libX11,
|
||||
libx11c, importc: "XkbAddKeyType".}
|
||||
proc XkbAllocIndicatorMaps*(xkb: PXkbDescPtr): TStatus{.libx11c,
|
||||
importc: "XkbAllocIndicatorMaps".}
|
||||
proc XkbFreeIndicatorMaps*(xkb: PXkbDescPtr){.cdecl, dynlib: libX11,
|
||||
proc XkbFreeIndicatorMaps*(xkb: PXkbDescPtr){.libx11c,
|
||||
importc: "XkbFreeIndicatorMaps".}
|
||||
proc XkbGetMap*(dpy: PDisplay, which, deviceSpec: int16): PXkbDescPtr{.cdecl,
|
||||
dynlib: libX11, importc: "XkbGetMap".}
|
||||
proc XkbGetMap*(dpy: PDisplay, which, deviceSpec: int16): PXkbDescPtr{.libx11c, importc: "XkbGetMap".}
|
||||
proc XkbGetUpdatedMap*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetUpdatedMap".}
|
||||
libx11c, importc: "XkbGetUpdatedMap".}
|
||||
proc XkbGetMapChanges*(dpy: PDisplay, xkb: PXkbDescPtr,
|
||||
changes: PXkbMapChangesPtr): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbGetMapChanges".}
|
||||
proc XkbRefreshKeyboardMapping*(event: PXkbMapNotifyEvent): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbRefreshKeyboardMapping".}
|
||||
changes: PXkbMapChangesPtr): TStatus{.libx11c, importc: "XkbGetMapChanges".}
|
||||
proc XkbRefreshKeyboardMapping*(event: PXkbMapNotifyEvent): TStatus{.libx11c, importc: "XkbRefreshKeyboardMapping".}
|
||||
proc XkbGetKeyTypes*(dpy: PDisplay, first, num: int16, xkb: PXkbDescPtr): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetKeyTypes".}
|
||||
libx11c, importc: "XkbGetKeyTypes".}
|
||||
proc XkbGetKeySyms*(dpy: PDisplay, first, num: int16, xkb: PXkbDescPtr): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetKeySyms".}
|
||||
libx11c, importc: "XkbGetKeySyms".}
|
||||
proc XkbGetKeyActions*(dpy: PDisplay, first, num: int16, xkb: PXkbDescPtr): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetKeyActions".}
|
||||
libx11c, importc: "XkbGetKeyActions".}
|
||||
proc XkbGetKeyBehaviors*(dpy: PDisplay, firstKey, nKeys: int16,
|
||||
desc: PXkbDescPtr): TStatus{.cdecl, dynlib: libX11,
|
||||
desc: PXkbDescPtr): TStatus{.libx11c,
|
||||
importc: "XkbGetKeyBehaviors".}
|
||||
proc XkbGetVirtualMods*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetVirtualMods".}
|
||||
libx11c, importc: "XkbGetVirtualMods".}
|
||||
proc XkbGetKeyExplicitComponents*(dpy: PDisplay, firstKey, nKeys: int16,
|
||||
desc: PXkbDescPtr): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbGetKeyExplicitComponents".}
|
||||
desc: PXkbDescPtr): TStatus{.libx11c, importc: "XkbGetKeyExplicitComponents".}
|
||||
proc XkbGetKeyModifierMap*(dpy: PDisplay, firstKey, nKeys: int16,
|
||||
desc: PXkbDescPtr): TStatus{.cdecl, dynlib: libX11,
|
||||
desc: PXkbDescPtr): TStatus{.libx11c,
|
||||
importc: "XkbGetKeyModifierMap".}
|
||||
proc XkbAllocControls*(xkb: PXkbDescPtr, which: int16): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbAllocControls".}
|
||||
proc XkbFreeControls*(xkb: PXkbDescPtr, which: int16, freeMap: bool){.cdecl,
|
||||
dynlib: libX11, importc: "XkbFreeControls".}
|
||||
proc XkbAllocControls*(xkb: PXkbDescPtr, which: int16): TStatus{.libx11c, importc: "XkbAllocControls".}
|
||||
proc XkbFreeControls*(xkb: PXkbDescPtr, which: int16, freeMap: bool){.libx11c, importc: "XkbFreeControls".}
|
||||
proc XkbGetControls*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetControls".}
|
||||
libx11c, importc: "XkbGetControls".}
|
||||
proc XkbSetControls*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbSetControls".}
|
||||
libx11c, importc: "XkbSetControls".}
|
||||
proc XkbNoteControlsChanges*(old: PXkbControlsChangesPtr,
|
||||
new: PXkbControlsNotifyEvent, wanted: int16){.
|
||||
cdecl, dynlib: libX11, importc: "XkbNoteControlsChanges".}
|
||||
libx11c, importc: "XkbNoteControlsChanges".}
|
||||
proc XkbGetControlsChanges*(d: PDisplay, x: PXkbDescPtr,
|
||||
c: PXkbControlsChangesPtr): TStatus
|
||||
proc XkbChangeControls*(d: PDisplay, x: PXkbDescPtr, c: PXkbControlsChangesPtr): bool
|
||||
proc XkbAllocCompatMap*(xkb: PXkbDescPtr, which, nInterpret: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocCompatMap".}
|
||||
proc XkbFreeCompatMap*(xkib: PXkbDescPtr, which: int16, freeMap: bool){.cdecl,
|
||||
dynlib: libX11, importc: "XkbFreeCompatMap".}
|
||||
libx11c, importc: "XkbAllocCompatMap".}
|
||||
proc XkbFreeCompatMap*(xkib: PXkbDescPtr, which: int16, freeMap: bool){.libx11c, importc: "XkbFreeCompatMap".}
|
||||
proc XkbGetCompatMap*(dpy: PDisplay, which: int16, xkb: PXkbDescPtr): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetCompatMap".}
|
||||
libx11c, importc: "XkbGetCompatMap".}
|
||||
proc XkbSetCompatMap*(dpy: PDisplay, which: int16, xkb: PXkbDescPtr,
|
||||
updateActions: bool): bool{.cdecl, dynlib: libX11,
|
||||
updateActions: bool): bool{.libx11c,
|
||||
importc: "XkbSetCompatMap".}
|
||||
proc XkbAddSymInterpret*(xkb: PXkbDescPtr, si: PXkbSymInterpretPtr,
|
||||
updateMap: bool, changes: PXkbChangesPtr): PXkbSymInterpretPtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAddSymInterpret".}
|
||||
libx11c, importc: "XkbAddSymInterpret".}
|
||||
proc XkbAllocNames*(xkb: PXkbDescPtr, which: int16,
|
||||
nTotalRG, nTotalAliases: int16): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbAllocNames".}
|
||||
nTotalRG, nTotalAliases: int16): TStatus{.libx11c, importc: "XkbAllocNames".}
|
||||
proc XkbGetNames*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetNames".}
|
||||
libx11c, importc: "XkbGetNames".}
|
||||
proc XkbSetNames*(dpy: PDisplay, which, firstType, nTypes: int16,
|
||||
desc: PXkbDescPtr): bool{.cdecl, dynlib: libX11,
|
||||
desc: PXkbDescPtr): bool{.libx11c,
|
||||
importc: "XkbSetNames".}
|
||||
proc XkbChangeNames*(dpy: PDisplay, xkb: PXkbDescPtr,
|
||||
changes: PXkbNameChangesPtr): bool{.cdecl, dynlib: libX11,
|
||||
changes: PXkbNameChangesPtr): bool{.libx11c,
|
||||
importc: "XkbChangeNames".}
|
||||
proc XkbFreeNames*(xkb: PXkbDescPtr, which: int16, freeMap: bool){.cdecl,
|
||||
dynlib: libX11, importc: "XkbFreeNames".}
|
||||
proc XkbFreeNames*(xkb: PXkbDescPtr, which: int16, freeMap: bool){.libx11c, importc: "XkbFreeNames".}
|
||||
proc XkbGetState*(dpy: PDisplay, deviceSpec: int16, rtrnState: PXkbStatePtr): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetState".}
|
||||
proc XkbSetMap*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbSetMap".}
|
||||
libx11c, importc: "XkbGetState".}
|
||||
proc XkbSetMap*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): bool{.libx11c, importc: "XkbSetMap".}
|
||||
proc XkbChangeMap*(dpy: PDisplay, desc: PXkbDescPtr, changes: PXkbMapChangesPtr): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbChangeMap".}
|
||||
libx11c, importc: "XkbChangeMap".}
|
||||
proc XkbSetDetectableAutoRepeat*(dpy: PDisplay, detectable: bool,
|
||||
supported: ptr bool): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbSetDetectableAutoRepeat".}
|
||||
supported: ptr bool): bool{.libx11c, importc: "XkbSetDetectableAutoRepeat".}
|
||||
proc XkbGetDetectableAutoRepeat*(dpy: PDisplay, supported: ptr bool): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetDetectableAutoRepeat".}
|
||||
libx11c, importc: "XkbGetDetectableAutoRepeat".}
|
||||
proc XkbSetAutoResetControls*(dpy: PDisplay, changes: int16,
|
||||
auto_ctrls, auto_values: PWord): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbSetAutoResetControls".}
|
||||
auto_ctrls, auto_values: PWord): bool{.libx11c, importc: "XkbSetAutoResetControls".}
|
||||
proc XkbGetAutoResetControls*(dpy: PDisplay, auto_ctrls, auto_ctrl_values: PWord): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetAutoResetControls".}
|
||||
libx11c, importc: "XkbGetAutoResetControls".}
|
||||
proc XkbSetPerClientControls*(dpy: PDisplay, change: int16, values: PWord): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbSetPerClientControls".}
|
||||
proc XkbGetPerClientControls*(dpy: PDisplay, ctrls: PWord): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbGetPerClientControls".}
|
||||
proc XkbCopyKeyType*(`from`, into: PXkbKeyTypePtr): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbCopyKeyType".}
|
||||
libx11c, importc: "XkbSetPerClientControls".}
|
||||
proc XkbGetPerClientControls*(dpy: PDisplay, ctrls: PWord): bool{.libx11c, importc: "XkbGetPerClientControls".}
|
||||
proc XkbCopyKeyType*(`from`, into: PXkbKeyTypePtr): TStatus{.libx11c, importc: "XkbCopyKeyType".}
|
||||
proc XkbCopyKeyTypes*(`from`, into: PXkbKeyTypePtr, num_types: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbCopyKeyTypes".}
|
||||
libx11c, importc: "XkbCopyKeyTypes".}
|
||||
proc XkbResizeKeyType*(xkb: PXkbDescPtr, type_ndx, map_count: int16,
|
||||
want_preserve: bool, new_num_lvls: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbResizeKeyType".}
|
||||
libx11c, importc: "XkbResizeKeyType".}
|
||||
proc XkbResizeKeySyms*(desc: PXkbDescPtr, forKey, symsNeeded: int16): PKeySym{.
|
||||
cdecl, dynlib: libX11, importc: "XkbResizeKeySyms".}
|
||||
libx11c, importc: "XkbResizeKeySyms".}
|
||||
proc XkbResizeKeyActions*(desc: PXkbDescPtr, forKey, actsNeeded: int16): PXkbAction{.
|
||||
cdecl, dynlib: libX11, importc: "XkbResizeKeyActions".}
|
||||
libx11c, importc: "XkbResizeKeyActions".}
|
||||
proc XkbChangeTypesOfKey*(xkb: PXkbDescPtr, key, num_groups: int16,
|
||||
groups: int16, newTypes: ptr int16,
|
||||
pChanges: PXkbMapChangesPtr): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbChangeTypesOfKey".}
|
||||
pChanges: PXkbMapChangesPtr): TStatus{.libx11c, importc: "XkbChangeTypesOfKey".}
|
||||
|
||||
proc XkbListComponents*(dpy: PDisplay, deviceSpec: int16,
|
||||
ptrns: PXkbComponentNamesPtr, max_inout: ptr int16): PXkbComponentListPtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbListComponents".}
|
||||
proc XkbFreeComponentList*(list: PXkbComponentListPtr){.cdecl, dynlib: libX11,
|
||||
libx11c, importc: "XkbListComponents".}
|
||||
proc XkbFreeComponentList*(list: PXkbComponentListPtr){.libx11c,
|
||||
importc: "XkbFreeComponentList".}
|
||||
proc XkbGetKeyboard*(dpy: PDisplay, which, deviceSpec: int16): PXkbDescPtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetKeyboard".}
|
||||
libx11c, importc: "XkbGetKeyboard".}
|
||||
proc XkbGetKeyboardByName*(dpy: PDisplay, deviceSpec: int16,
|
||||
names: PXkbComponentNamesPtr, want, need: int16,
|
||||
load: bool): PXkbDescPtr{.cdecl, dynlib: libX11,
|
||||
load: bool): PXkbDescPtr{.libx11c,
|
||||
importc: "XkbGetKeyboardByName".}
|
||||
|
||||
proc XkbKeyTypesForCoreSymbols*(xkb: PXkbDescPtr,
|
||||
|
|
@ -609,65 +581,55 @@ proc XkbKeyTypesForCoreSymbols*(xkb: PXkbDescPtr,
|
|||
core_syms: PKeySym, # always mapWidth symbols
|
||||
protected: int16, # explicit key types
|
||||
types_inout: ptr int16, # always four type indices
|
||||
xkb_syms_rtrn: PKeySym): int16{.cdecl,
|
||||
dynlib: libX11, importc: "XkbKeyTypesForCoreSymbols".}
|
||||
xkb_syms_rtrn: PKeySym): int16{.libx11c, importc: "XkbKeyTypesForCoreSymbols".}
|
||||
# must have enough space
|
||||
proc XkbApplyCompatMapToKey*(xkb: PXkbDescPtr,
|
||||
key: TKeyCode, # key to be updated
|
||||
changes: PXkbChangesPtr): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbApplyCompatMapToKey".}
|
||||
changes: PXkbChangesPtr): bool{.libx11c, importc: "XkbApplyCompatMapToKey".}
|
||||
# resulting changes to map
|
||||
proc XkbUpdateMapFromCore*(xkb: PXkbDescPtr,
|
||||
first_key: TKeyCode, # first changed key
|
||||
num_keys,
|
||||
map_width: int16,
|
||||
core_keysyms: PKeySym, # symbols `from` core keymap
|
||||
changes: PXkbChangesPtr): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbUpdateMapFromCore".}
|
||||
changes: PXkbChangesPtr): bool{.libx11c, importc: "XkbUpdateMapFromCore".}
|
||||
|
||||
proc XkbAddDeviceLedInfo*(devi: PXkbDeviceInfoPtr, ledClass, ledId: int16): PXkbDeviceLedInfoPtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAddDeviceLedInfo".}
|
||||
libx11c, importc: "XkbAddDeviceLedInfo".}
|
||||
proc XkbResizeDeviceButtonActions*(devi: PXkbDeviceInfoPtr, newTotal: int16): TStatus{.
|
||||
cdecl, dynlib: libX11, importc: "XkbResizeDeviceButtonActions".}
|
||||
libx11c, importc: "XkbResizeDeviceButtonActions".}
|
||||
proc XkbAllocDeviceInfo*(deviceSpec, nButtons, szLeds: int16): PXkbDeviceInfoPtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbAllocDeviceInfo".}
|
||||
libx11c, importc: "XkbAllocDeviceInfo".}
|
||||
proc XkbFreeDeviceInfo*(devi: PXkbDeviceInfoPtr, which: int16, freeDevI: bool){.
|
||||
cdecl, dynlib: libX11, importc: "XkbFreeDeviceInfo".}
|
||||
libx11c, importc: "XkbFreeDeviceInfo".}
|
||||
proc XkbNoteDeviceChanges*(old: PXkbDeviceChangesPtr,
|
||||
new: PXkbExtensionDeviceNotifyEvent, wanted: int16){.
|
||||
cdecl, dynlib: libX11, importc: "XkbNoteDeviceChanges".}
|
||||
libx11c, importc: "XkbNoteDeviceChanges".}
|
||||
proc XkbGetDeviceInfo*(dpy: PDisplay, which, deviceSpec, ledClass, ledID: int16): PXkbDeviceInfoPtr{.
|
||||
cdecl, dynlib: libX11, importc: "XkbGetDeviceInfo".}
|
||||
libx11c, importc: "XkbGetDeviceInfo".}
|
||||
proc XkbGetDeviceInfoChanges*(dpy: PDisplay, devi: PXkbDeviceInfoPtr,
|
||||
changes: PXkbDeviceChangesPtr): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbGetDeviceInfoChanges".}
|
||||
changes: PXkbDeviceChangesPtr): TStatus{.libx11c, importc: "XkbGetDeviceInfoChanges".}
|
||||
proc XkbGetDeviceButtonActions*(dpy: PDisplay, devi: PXkbDeviceInfoPtr,
|
||||
all: bool, first, nBtns: int16): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbGetDeviceButtonActions".}
|
||||
all: bool, first, nBtns: int16): TStatus{.libx11c, importc: "XkbGetDeviceButtonActions".}
|
||||
proc XkbGetDeviceLedInfo*(dpy: PDisplay, devi: PXkbDeviceInfoPtr,
|
||||
ledClass, ledId, which: int16): TStatus{.cdecl,
|
||||
dynlib: libX11, importc: "XkbGetDeviceLedInfo".}
|
||||
ledClass, ledId, which: int16): TStatus{.libx11c, importc: "XkbGetDeviceLedInfo".}
|
||||
proc XkbSetDeviceInfo*(dpy: PDisplay, which: int16, devi: PXkbDeviceInfoPtr): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbSetDeviceInfo".}
|
||||
libx11c, importc: "XkbSetDeviceInfo".}
|
||||
proc XkbChangeDeviceInfo*(dpy: PDisplay, desc: PXkbDeviceInfoPtr,
|
||||
changes: PXkbDeviceChangesPtr): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbChangeDeviceInfo".}
|
||||
changes: PXkbDeviceChangesPtr): bool{.libx11c, importc: "XkbChangeDeviceInfo".}
|
||||
proc XkbSetDeviceLedInfo*(dpy: PDisplay, devi: PXkbDeviceInfoPtr,
|
||||
ledClass, ledID, which: int16): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbSetDeviceLedInfo".}
|
||||
ledClass, ledID, which: int16): bool{.libx11c, importc: "XkbSetDeviceLedInfo".}
|
||||
proc XkbSetDeviceButtonActions*(dpy: PDisplay, devi: PXkbDeviceInfoPtr,
|
||||
first, nBtns: int16): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbSetDeviceButtonActions".}
|
||||
first, nBtns: int16): bool{.libx11c, importc: "XkbSetDeviceButtonActions".}
|
||||
|
||||
proc XkbToControl*(c: int8): int8{.cdecl, dynlib: libX11,
|
||||
proc XkbToControl*(c: int8): int8{.libx11c,
|
||||
importc: "XkbToControl".}
|
||||
|
||||
proc XkbSetDebuggingFlags*(dpy: PDisplay, mask, flags: int16, msg: cstring,
|
||||
ctrls_mask, ctrls, rtrn_flags, rtrn_ctrls: int16): bool{.
|
||||
cdecl, dynlib: libX11, importc: "XkbSetDebuggingFlags".}
|
||||
libx11c, importc: "XkbSetDebuggingFlags".}
|
||||
proc XkbApplyVirtualModChanges*(xkb: PXkbDescPtr, changed: int16,
|
||||
changes: PXkbChangesPtr): bool{.cdecl,
|
||||
dynlib: libX11, importc: "XkbApplyVirtualModChanges".}
|
||||
changes: PXkbChangesPtr): bool{.libx11c, importc: "XkbApplyVirtualModChanges".}
|
||||
|
||||
# implementation
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -2,8 +2,24 @@
|
|||
import
|
||||
x, xlib
|
||||
|
||||
when defined(use_pkg_config) or defined(use_pkg_config_static):
|
||||
{.pragma: libxrender, cdecl, importc.}
|
||||
when defined(use_pkg_config):
|
||||
{.passl: gorge("pkg-config xrender --libs").}
|
||||
else:
|
||||
{.passl: gorge("pkg-config xrender --static --libs").}
|
||||
else:
|
||||
when defined(macosx):
|
||||
const
|
||||
libXrender* = "libXrender.dylib"
|
||||
else:
|
||||
const
|
||||
libXrender* = "libXrender.so"
|
||||
|
||||
|
||||
{.pragma: libxrender, dynlib: libXrender, cdecl, importc.}
|
||||
#const
|
||||
# libX11* = "libX11.so"
|
||||
# libXrender* = "libXrender.so"
|
||||
|
||||
#
|
||||
# Automatically converted by H2Pas 0.99.15 from xrender.h
|
||||
|
|
@ -187,45 +203,39 @@ type
|
|||
|
||||
|
||||
proc XRenderQueryExtension*(dpy: PDisplay, event_basep: ptr int32,
|
||||
error_basep: ptr int32): TBool{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
error_basep: ptr int32): TBool{.libxrender.}
|
||||
proc XRenderQueryVersion*(dpy: PDisplay, major_versionp: ptr int32,
|
||||
minor_versionp: ptr int32): TStatus{.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XRenderQueryFormats*(dpy: PDisplay): TStatus{.cdecl, dynlib: libX11,
|
||||
importc.}
|
||||
minor_versionp: ptr int32): TStatus{.libxrender.}
|
||||
proc XRenderQueryFormats*(dpy: PDisplay): TStatus{.libxrender.}
|
||||
proc XRenderFindVisualFormat*(dpy: PDisplay, visual: PVisual): PXRenderPictFormat{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
libxrender.}
|
||||
proc XRenderFindFormat*(dpy: PDisplay, mask: int32,
|
||||
`template`: PXRenderPictFormat, count: int32): PXRenderPictFormat{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
libxrender.}
|
||||
proc XRenderCreatePicture*(dpy: PDisplay, drawable: TDrawable,
|
||||
format: PXRenderPictFormat, valuemask: int32,
|
||||
attributes: PXRenderPictureAttributes): TPicture{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
libxrender.}
|
||||
proc XRenderChangePicture*(dpy: PDisplay, picture: TPicture, valuemask: int32,
|
||||
attributes: PXRenderPictureAttributes){.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
proc XRenderFreePicture*(dpy: PDisplay, picture: TPicture){.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
attributes: PXRenderPictureAttributes){.libxrender.}
|
||||
proc XRenderFreePicture*(dpy: PDisplay, picture: TPicture){.libxrender.}
|
||||
proc XRenderComposite*(dpy: PDisplay, op: int32, src: TPicture, mask: TPicture,
|
||||
dst: TPicture, src_x: int32, src_y: int32, mask_x: int32,
|
||||
mask_y: int32, dst_x: int32, dst_y: int32, width: int32,
|
||||
height: int32){.cdecl, dynlib: libX11, importc.}
|
||||
height: int32){.libxrender.}
|
||||
proc XRenderCreateGlyphSet*(dpy: PDisplay, format: PXRenderPictFormat): TGlyphSet{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
libxrender.}
|
||||
proc XRenderReferenceGlyphSet*(dpy: PDisplay, existing: TGlyphSet): TGlyphSet{.
|
||||
cdecl, dynlib: libX11, importc.}
|
||||
proc XRenderFreeGlyphSet*(dpy: PDisplay, glyphset: TGlyphSet){.cdecl,
|
||||
dynlib: libX11, importc.}
|
||||
libxrender.}
|
||||
proc XRenderFreeGlyphSet*(dpy: PDisplay, glyphset: TGlyphSet){.libxrender.}
|
||||
proc XRenderAddGlyphs*(dpy: PDisplay, glyphset: TGlyphSet, gids: PGlyph,
|
||||
glyphs: PXGlyphInfo, nglyphs: int32, images: cstring,
|
||||
nbyte_images: int32){.cdecl, dynlib: libX11, importc.}
|
||||
nbyte_images: int32){.libxrender.}
|
||||
proc XRenderFreeGlyphs*(dpy: PDisplay, glyphset: TGlyphSet, gids: PGlyph,
|
||||
nglyphs: int32){.cdecl, dynlib: libX11, importc.}
|
||||
nglyphs: int32){.libxrender.}
|
||||
proc XRenderCompositeString8*(dpy: PDisplay, op: int32, src: TPicture,
|
||||
dst: TPicture, maskFormat: PXRenderPictFormat,
|
||||
glyphset: TGlyphSet, xSrc: int32, ySrc: int32,
|
||||
xDst: int32, yDst: int32, str: cstring,
|
||||
nchar: int32){.cdecl, dynlib: libX11, importc.}
|
||||
nchar: int32){.libxrender.}
|
||||
# implementation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue