Merge remote-tracking branch 'upstream/devel' into test-7010
This commit is contained in:
commit
9340885251
120 changed files with 33327 additions and 771 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -45,7 +45,7 @@ xcuserdata/
|
||||||
|
|
||||||
# Generated files.
|
# Generated files.
|
||||||
/compile.json
|
/compile.json
|
||||||
/compiler/nimrod.dot
|
/compiler/nim.dot
|
||||||
/reject.json
|
/reject.json
|
||||||
/run.json
|
/run.json
|
||||||
# for `nim doc foo.nim`
|
# for `nim doc foo.nim`
|
||||||
|
|
|
||||||
13
.travis.yml
13
.travis.yml
|
|
@ -38,16 +38,17 @@ script:
|
||||||
- ./koch boot -d:release
|
- ./koch boot -d:release
|
||||||
- ./koch nimble
|
- ./koch nimble
|
||||||
- nim e tests/test_nimscript.nims
|
- nim e tests/test_nimscript.nims
|
||||||
- nimble install zip -y
|
#- nimble install zip -y
|
||||||
- nimble install opengl
|
#- nimble install opengl
|
||||||
- nimble install sdl1
|
#- nimble install sdl1
|
||||||
- nimble install jester@#head -y
|
#- nimble install jester@#head -y
|
||||||
- nimble install niminst
|
#- nimble install niminst
|
||||||
- nim c --taintMode:on -d:nimCoroutines tests/testament/tester
|
- nim c --taintMode:on -d:nimCoroutines tests/testament/tester
|
||||||
- tests/testament/tester --pedantic all -d:nimCoroutines
|
- tests/testament/tester --pedantic all -d:nimCoroutines
|
||||||
- nim c -o:bin/nimpretty nimpretty/nimpretty.nim
|
- nim c -o:bin/nimpretty nimpretty/nimpretty.nim
|
||||||
- nim c -r nimpretty/tester.nim
|
- nim c -r nimpretty/tester.nim
|
||||||
- ./koch web
|
- ./koch docs
|
||||||
- ./koch csource
|
- ./koch csource
|
||||||
- ./koch nimsuggest
|
- ./koch nimsuggest
|
||||||
- nim c -r nimsuggest/tester
|
- nim c -r nimsuggest/tester
|
||||||
|
- nim c -r nimdoc/tester
|
||||||
|
|
|
||||||
12
appveyor.yml
12
appveyor.yml
|
|
@ -49,16 +49,16 @@ build_script:
|
||||||
- nim e tests/test_nimscript.nims
|
- nim e tests/test_nimscript.nims
|
||||||
- nim c -o:bin/nimpretty.exe nimpretty/nimpretty.nim
|
- nim c -o:bin/nimpretty.exe nimpretty/nimpretty.nim
|
||||||
- nim c -r nimpretty/tester.nim
|
- nim c -r nimpretty/tester.nim
|
||||||
- nimble install zip -y
|
# - nimble install zip -y
|
||||||
- nimble install opengl
|
# - nimble install opengl -y
|
||||||
- nimble install sdl1
|
# - nimble install sdl1 -y
|
||||||
- nimble install jester@#head -y
|
# - nimble install jester@#head -y
|
||||||
- nimble install niminst
|
|
||||||
- nim c --taintMode:on -d:nimCoroutines tests/testament/tester
|
|
||||||
- nim c --taintMode:on -d:nimCoroutines --os:genode -d:posix --compileOnly tests/testament/tester
|
- nim c --taintMode:on -d:nimCoroutines --os:genode -d:posix --compileOnly tests/testament/tester
|
||||||
|
- nim c --taintMode:on -d:nimCoroutines tests/testament/tester
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
- tests\testament\tester --pedantic all -d:nimCoroutines
|
- tests\testament\tester --pedantic all -d:nimCoroutines
|
||||||
|
- nim c -r nimdoc\tester
|
||||||
# - koch csource
|
# - koch csource
|
||||||
# - koch zip
|
# - koch zip
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
import
|
import
|
||||||
ast, astalgo, ropes, options, strutils, nimlexbase, msgs, cgendata, rodutils,
|
ast, astalgo, ropes, options, strutils, nimlexbase, msgs, cgendata, rodutils,
|
||||||
intsets, platform, llstream, tables, sighashes
|
intsets, platform, llstream, tables, sighashes, pathutils
|
||||||
|
|
||||||
# Careful! Section marks need to contain a tabulator so that they cannot
|
# Careful! Section marks need to contain a tabulator so that they cannot
|
||||||
# be part of C string literals.
|
# be part of C string literals.
|
||||||
|
|
@ -226,7 +226,7 @@ proc processMergeInfo(L: var TBaseLexer, m: BModule) =
|
||||||
when not defined(nimhygiene):
|
when not defined(nimhygiene):
|
||||||
{.pragma: inject.}
|
{.pragma: inject.}
|
||||||
|
|
||||||
template withCFile(cfilename: string, body: untyped) =
|
template withCFile(cfilename: AbsoluteFile, body: untyped) =
|
||||||
var s = llStreamOpen(cfilename, fmRead)
|
var s = llStreamOpen(cfilename, fmRead)
|
||||||
if s == nil: return
|
if s == nil: return
|
||||||
var L {.inject.}: TBaseLexer
|
var L {.inject.}: TBaseLexer
|
||||||
|
|
@ -238,7 +238,7 @@ template withCFile(cfilename: string, body: untyped) =
|
||||||
body
|
body
|
||||||
closeBaseLexer(L)
|
closeBaseLexer(L)
|
||||||
|
|
||||||
proc readMergeInfo*(cfilename: string, m: BModule) =
|
proc readMergeInfo*(cfilename: AbsoluteFile, m: BModule) =
|
||||||
## reads the merge meta information into `m`.
|
## reads the merge meta information into `m`.
|
||||||
withCFile(cfilename):
|
withCFile(cfilename):
|
||||||
readKey(L, k)
|
readKey(L, k)
|
||||||
|
|
@ -251,7 +251,7 @@ type
|
||||||
f: TCFileSections
|
f: TCFileSections
|
||||||
p: TCProcSections
|
p: TCProcSections
|
||||||
|
|
||||||
proc readMergeSections(cfilename: string, m: var TMergeSections) =
|
proc readMergeSections(cfilename: AbsoluteFile, m: var TMergeSections) =
|
||||||
## reads the merge sections into `m`.
|
## reads the merge sections into `m`.
|
||||||
withCFile(cfilename):
|
withCFile(cfilename):
|
||||||
readKey(L, k)
|
readKey(L, k)
|
||||||
|
|
@ -285,7 +285,7 @@ proc mergeRequired*(m: BModule): bool =
|
||||||
#echo "not empty: ", i, " ", m.initProc.s[i]
|
#echo "not empty: ", i, " ", m.initProc.s[i]
|
||||||
return true
|
return true
|
||||||
|
|
||||||
proc mergeFiles*(cfilename: string, m: BModule) =
|
proc mergeFiles*(cfilename: AbsoluteFile, m: BModule) =
|
||||||
## merges the C file with the old version on hard disc.
|
## merges the C file with the old version on hard disc.
|
||||||
var old: TMergeSections
|
var old: TMergeSections
|
||||||
readMergeSections(cfilename, old)
|
readMergeSections(cfilename, old)
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import
|
||||||
nversion, nimsets, msgs, std / sha1, bitsets, idents, types,
|
nversion, nimsets, msgs, std / sha1, bitsets, idents, types,
|
||||||
ccgutils, os, ropes, math, passes, wordrecg, treetab, cgmeth,
|
ccgutils, os, ropes, math, passes, wordrecg, treetab, cgmeth,
|
||||||
condsyms, rodutils, renderer, idgen, cgendata, ccgmerge, semfold, aliases,
|
condsyms, rodutils, renderer, idgen, cgendata, ccgmerge, semfold, aliases,
|
||||||
lowerings, semparallel, tables, sets, ndi, lineinfos
|
lowerings, semparallel, tables, sets, ndi, lineinfos, pathutils
|
||||||
|
|
||||||
import strutils except `%` # collides with ropes.`%`
|
import strutils except `%` # collides with ropes.`%`
|
||||||
|
|
||||||
|
|
@ -1064,7 +1064,8 @@ proc genFilenames(m: BModule): Rope =
|
||||||
discard cgsym(m, "dbgRegisterFilename")
|
discard cgsym(m, "dbgRegisterFilename")
|
||||||
result = nil
|
result = nil
|
||||||
for i in 0..<m.config.m.fileInfos.len:
|
for i in 0..<m.config.m.fileInfos.len:
|
||||||
result.addf("dbgRegisterFilename($1);$N", [m.config.m.fileInfos[i].projPath.makeCString])
|
result.addf("dbgRegisterFilename($1);$N",
|
||||||
|
[m.config.m.fileInfos[i].projPath.string.makeCString])
|
||||||
|
|
||||||
proc genMainProc(m: BModule) =
|
proc genMainProc(m: BModule) =
|
||||||
const
|
const
|
||||||
|
|
@ -1348,7 +1349,7 @@ proc initProcOptions(m: BModule): TOptions =
|
||||||
let opts = m.config.options
|
let opts = m.config.options
|
||||||
if sfSystemModule in m.module.flags: opts-{optStackTrace} else: opts
|
if sfSystemModule in m.module.flags: opts-{optStackTrace} else: opts
|
||||||
|
|
||||||
proc rawNewModule(g: BModuleList; module: PSym, filename: string): BModule =
|
proc rawNewModule(g: BModuleList; module: PSym, filename: AbsoluteFile): BModule =
|
||||||
new(result)
|
new(result)
|
||||||
result.g = g
|
result.g = g
|
||||||
result.tmpBase = rope("TM" & $hashOwner(module) & "_")
|
result.tmpBase = rope("TM" & $hashOwner(module) & "_")
|
||||||
|
|
@ -1376,7 +1377,7 @@ proc rawNewModule(g: BModuleList; module: PSym, filename: string): BModule =
|
||||||
incl result.flags, preventStackTrace
|
incl result.flags, preventStackTrace
|
||||||
excl(result.preInitProc.options, optStackTrace)
|
excl(result.preInitProc.options, optStackTrace)
|
||||||
let ndiName = if optCDebug in g.config.globalOptions: changeFileExt(completeCFilePath(g.config, filename), "ndi")
|
let ndiName = if optCDebug in g.config.globalOptions: changeFileExt(completeCFilePath(g.config, filename), "ndi")
|
||||||
else: ""
|
else: AbsoluteFile""
|
||||||
open(result.ndi, ndiName, g.config)
|
open(result.ndi, ndiName, g.config)
|
||||||
|
|
||||||
proc nullify[T](arr: var T) =
|
proc nullify[T](arr: var T) =
|
||||||
|
|
@ -1427,7 +1428,7 @@ proc resetCgenModules*(g: BModuleList) =
|
||||||
for m in cgenModules(g): resetModule(m)
|
for m in cgenModules(g): resetModule(m)
|
||||||
|
|
||||||
proc rawNewModule(g: BModuleList; module: PSym; conf: ConfigRef): BModule =
|
proc rawNewModule(g: BModuleList; module: PSym; conf: ConfigRef): BModule =
|
||||||
result = rawNewModule(g, module, toFullPath(conf, module.position.FileIndex))
|
result = rawNewModule(g, module, AbsoluteFile toFullPath(conf, module.position.FileIndex))
|
||||||
|
|
||||||
proc newModule(g: BModuleList; module: PSym; conf: ConfigRef): BModule =
|
proc newModule(g: BModuleList; module: PSym; conf: ConfigRef): BModule =
|
||||||
# we should create only one cgen module for each module sym
|
# we should create only one cgen module for each module sym
|
||||||
|
|
@ -1446,7 +1447,7 @@ proc myOpen(graph: ModuleGraph; module: PSym): PPassContext =
|
||||||
injectG()
|
injectG()
|
||||||
result = newModule(g, module, graph.config)
|
result = newModule(g, module, graph.config)
|
||||||
if optGenIndex in graph.config.globalOptions and g.generatedHeader == nil:
|
if optGenIndex in graph.config.globalOptions and g.generatedHeader == nil:
|
||||||
let f = if graph.config.headerFile.len > 0: graph.config.headerFile
|
let f = if graph.config.headerFile.len > 0: AbsoluteFile graph.config.headerFile
|
||||||
else: graph.config.projectFull
|
else: graph.config.projectFull
|
||||||
g.generatedHeader = rawNewModule(g, module,
|
g.generatedHeader = rawNewModule(g, module,
|
||||||
changeFileExt(completeCFilePath(graph.config, f), hExt))
|
changeFileExt(completeCFilePath(graph.config, f), hExt))
|
||||||
|
|
@ -1477,9 +1478,9 @@ proc writeHeader(m: BModule) =
|
||||||
if optUseNimNamespace in m.config.globalOptions: result.add closeNamespaceNim()
|
if optUseNimNamespace in m.config.globalOptions: result.add closeNamespaceNim()
|
||||||
result.addf("#endif /* $1 */$n", [guard])
|
result.addf("#endif /* $1 */$n", [guard])
|
||||||
if not writeRope(result, m.filename):
|
if not writeRope(result, m.filename):
|
||||||
rawMessage(m.config, errCannotOpenFile, m.filename)
|
rawMessage(m.config, errCannotOpenFile, m.filename.string)
|
||||||
|
|
||||||
proc getCFile(m: BModule): string =
|
proc getCFile(m: BModule): AbsoluteFile =
|
||||||
let ext =
|
let ext =
|
||||||
if m.compileToCpp: ".cpp"
|
if m.compileToCpp: ".cpp"
|
||||||
elif m.config.cmd == cmdCompileToOC or sfCompileToObjC in m.module.flags: ".m"
|
elif m.config.cmd == cmdCompileToOC or sfCompileToObjC in m.module.flags: ".m"
|
||||||
|
|
@ -1523,18 +1524,18 @@ proc shouldRecompile(m: BModule; code: Rope, cfile: Cfile): bool =
|
||||||
if not equalsFile(code, cfile.cname):
|
if not equalsFile(code, cfile.cname):
|
||||||
if isDefined(m.config, "nimdiff"):
|
if isDefined(m.config, "nimdiff"):
|
||||||
if fileExists(cfile.cname):
|
if fileExists(cfile.cname):
|
||||||
copyFile(cfile.cname, cfile.cname & ".backup")
|
copyFile(cfile.cname.string, cfile.cname.string & ".backup")
|
||||||
echo "diff ", cfile.cname, ".backup ", cfile.cname
|
echo "diff ", cfile.cname.string, ".backup ", cfile.cname.string
|
||||||
else:
|
else:
|
||||||
echo "new file ", cfile.cname
|
echo "new file ", cfile.cname.string
|
||||||
if not writeRope(code, cfile.cname):
|
if not writeRope(code, cfile.cname):
|
||||||
rawMessage(m.config, errCannotOpenFile, cfile.cname)
|
rawMessage(m.config, errCannotOpenFile, cfile.cname.string)
|
||||||
return
|
return
|
||||||
if existsFile(cfile.obj) and os.fileNewer(cfile.obj, cfile.cname):
|
if fileExists(cfile.obj) and os.fileNewer(cfile.obj.string, cfile.cname.string):
|
||||||
result = false
|
result = false
|
||||||
else:
|
else:
|
||||||
if not writeRope(code, cfile.cname):
|
if not writeRope(code, cfile.cname):
|
||||||
rawMessage(m.config, errCannotOpenFile, cfile.cname)
|
rawMessage(m.config, errCannotOpenFile, cfile.cname.string)
|
||||||
|
|
||||||
# We need 2 different logics here: pending modules (including
|
# We need 2 different logics here: pending modules (including
|
||||||
# 'nim__dat') may require file merging for the combination of dead code
|
# 'nim__dat') may require file merging for the combination of dead code
|
||||||
|
|
@ -1570,14 +1571,14 @@ proc writeModule(m: BModule, pending: bool) =
|
||||||
finishTypeDescriptions(m)
|
finishTypeDescriptions(m)
|
||||||
var code = genModule(m, cf)
|
var code = genModule(m, cf)
|
||||||
if not writeRope(code, cfile):
|
if not writeRope(code, cfile):
|
||||||
rawMessage(m.config, errCannotOpenFile, cfile)
|
rawMessage(m.config, errCannotOpenFile, cfile.string)
|
||||||
addFileToCompile(m.config, cf)
|
addFileToCompile(m.config, cf)
|
||||||
else:
|
else:
|
||||||
# Consider: first compilation compiles ``system.nim`` and produces
|
# Consider: first compilation compiles ``system.nim`` and produces
|
||||||
# ``system.c`` but then compilation fails due to an error. This means
|
# ``system.c`` but then compilation fails due to an error. This means
|
||||||
# that ``system.o`` is missing, so we need to call the C compiler for it:
|
# that ``system.o`` is missing, so we need to call the C compiler for it:
|
||||||
var cf = Cfile(cname: cfile, obj: completeCFilePath(m.config, toObjFile(m.config, cfile)), flags: {})
|
var cf = Cfile(cname: cfile, obj: completeCFilePath(m.config, toObjFile(m.config, cfile)), flags: {})
|
||||||
if not existsFile(cf.obj): cf.flags = {CfileFlag.Cached}
|
if not fileExists(cf.obj): cf.flags = {CfileFlag.Cached}
|
||||||
addFileToCompile(m.config, cf)
|
addFileToCompile(m.config, cf)
|
||||||
close(m.ndi)
|
close(m.ndi)
|
||||||
|
|
||||||
|
|
@ -1592,7 +1593,7 @@ proc updateCachedModule(m: BModule) =
|
||||||
|
|
||||||
var code = genModule(m, cf)
|
var code = genModule(m, cf)
|
||||||
if not writeRope(code, cfile):
|
if not writeRope(code, cfile):
|
||||||
rawMessage(m.config, errCannotOpenFile, cfile)
|
rawMessage(m.config, errCannotOpenFile, cfile.string)
|
||||||
else:
|
else:
|
||||||
cf.flags = {CfileFlag.Cached}
|
cf.flags = {CfileFlag.Cached}
|
||||||
addFileToCompile(m.config, cf)
|
addFileToCompile(m.config, cf)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
import
|
import
|
||||||
ast, astalgo, ropes, passes, options, intsets, platform, sighashes,
|
ast, astalgo, ropes, passes, options, intsets, platform, sighashes,
|
||||||
tables, ndi, lineinfos
|
tables, ndi, lineinfos, pathutils
|
||||||
|
|
||||||
from modulegraphs import ModuleGraph
|
from modulegraphs import ModuleGraph
|
||||||
|
|
||||||
|
|
@ -136,8 +136,8 @@ type
|
||||||
s*: TCFileSections # sections of the C file
|
s*: TCFileSections # sections of the C file
|
||||||
flags*: set[Codegenflag]
|
flags*: set[Codegenflag]
|
||||||
module*: PSym
|
module*: PSym
|
||||||
filename*: string
|
filename*: AbsoluteFile
|
||||||
cfilename*: string # filename of the module (including path,
|
cfilename*: AbsoluteFile # filename of the module (including path,
|
||||||
# without extension)
|
# without extension)
|
||||||
tmpBase*: Rope # base for temp identifier generation
|
tmpBase*: Rope # base for temp identifier generation
|
||||||
typeCache*: TypeCache # cache the generated types
|
typeCache*: TypeCache # cache the generated types
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,17 @@
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# The Nim Compiler
|
||||||
|
# (c) Copyright 2018 Nim contributors
|
||||||
|
#
|
||||||
|
# See the file "copying.txt", included in this
|
||||||
|
# distribution, for details about the copyright.
|
||||||
|
#
|
||||||
|
|
||||||
## Helpers for binaries that use compiler passes, eg: nim, nimsuggest, nimfix
|
## Helpers for binaries that use compiler passes, eg: nim, nimsuggest, nimfix
|
||||||
|
|
||||||
# TODO: nimfix should use this; currently out of sync
|
|
||||||
|
|
||||||
import
|
import
|
||||||
compiler/[options, idents, nimconf, scriptconfig, extccomp, commands, msgs, lineinfos, modulegraphs, condsyms],
|
options, idents, nimconf, scriptconfig, extccomp, commands, msgs,
|
||||||
std/os
|
lineinfos, modulegraphs, condsyms, os, pathutils
|
||||||
|
|
||||||
type
|
type
|
||||||
NimProg* = ref object
|
NimProg* = ref object
|
||||||
|
|
@ -21,27 +28,27 @@ proc processCmdLineAndProjectPath*(self: NimProg, conf: ConfigRef) =
|
||||||
self.processCmdLine(passCmd1, "", conf)
|
self.processCmdLine(passCmd1, "", conf)
|
||||||
if self.supportsStdinFile and conf.projectName == "-":
|
if self.supportsStdinFile and conf.projectName == "-":
|
||||||
conf.projectName = "stdinfile"
|
conf.projectName = "stdinfile"
|
||||||
conf.projectFull = "stdinfile"
|
conf.projectFull = AbsoluteFile "stdinfile"
|
||||||
conf.projectPath = canonicalizePath(conf, getCurrentDir())
|
conf.projectPath = AbsoluteDir getCurrentDir()
|
||||||
conf.projectIsStdin = true
|
conf.projectIsStdin = true
|
||||||
elif conf.projectName != "":
|
elif conf.projectName != "":
|
||||||
try:
|
try:
|
||||||
conf.projectFull = canonicalizePath(conf, conf.projectName)
|
conf.projectFull = canonicalizePath(conf, AbsoluteFile conf.projectName)
|
||||||
except OSError:
|
except OSError:
|
||||||
conf.projectFull = conf.projectName
|
conf.projectFull = AbsoluteFile conf.projectName
|
||||||
let p = splitFile(conf.projectFull)
|
let p = splitFile(conf.projectFull)
|
||||||
let dir = if p.dir.len > 0: p.dir else: getCurrentDir()
|
let dir = if p.dir.isEmpty: AbsoluteDir getCurrentDir() else: p.dir
|
||||||
conf.projectPath = canonicalizePath(conf, dir)
|
conf.projectPath = AbsoluteDir canonicalizePath(conf, AbsoluteFile dir)
|
||||||
conf.projectName = p.name
|
conf.projectName = p.name
|
||||||
else:
|
else:
|
||||||
conf.projectPath = canonicalizePath(conf, getCurrentDir())
|
conf.projectPath = AbsoluteDir canonicalizePath(conf, AbsoluteFile getCurrentDir())
|
||||||
|
|
||||||
proc loadConfigsAndRunMainCommand*(self: NimProg, cache: IdentCache; conf: ConfigRef): bool =
|
proc loadConfigsAndRunMainCommand*(self: NimProg, cache: IdentCache; conf: ConfigRef): bool =
|
||||||
loadConfigs(DefaultConfig, cache, conf) # load all config files
|
loadConfigs(DefaultConfig, cache, conf) # load all config files
|
||||||
if self.suggestMode:
|
if self.suggestMode:
|
||||||
conf.command = "nimsuggest"
|
conf.command = "nimsuggest"
|
||||||
|
|
||||||
proc runNimScriptIfExists(path: string)=
|
proc runNimScriptIfExists(path: AbsoluteFile)=
|
||||||
if fileExists(path):
|
if fileExists(path):
|
||||||
runNimScript(cache, path, freshDefines = false, conf)
|
runNimScript(cache, path, freshDefines = false, conf)
|
||||||
|
|
||||||
|
|
@ -53,8 +60,8 @@ proc loadConfigsAndRunMainCommand*(self: NimProg, cache: IdentCache; conf: Confi
|
||||||
runNimScriptIfExists(getUserConfigPath(DefaultConfigNims))
|
runNimScriptIfExists(getUserConfigPath(DefaultConfigNims))
|
||||||
|
|
||||||
if optSkipParentConfigFiles notin conf.globalOptions:
|
if optSkipParentConfigFiles notin conf.globalOptions:
|
||||||
for dir in parentDirs(conf.projectPath, fromRoot = true, inclusive = false):
|
for dir in parentDirs(conf.projectPath.string, fromRoot = true, inclusive = false):
|
||||||
runNimScriptIfExists(dir / DefaultConfigNims)
|
runNimScriptIfExists(AbsoluteDir(dir) / DefaultConfigNims)
|
||||||
|
|
||||||
if optSkipProjConfigFile notin conf.globalOptions:
|
if optSkipProjConfigFile notin conf.globalOptions:
|
||||||
runNimScriptIfExists(conf.projectPath / DefaultConfigNims)
|
runNimScriptIfExists(conf.projectPath / DefaultConfigNims)
|
||||||
|
|
@ -63,10 +70,10 @@ proc loadConfigsAndRunMainCommand*(self: NimProg, cache: IdentCache; conf: Confi
|
||||||
if not self.suggestMode:
|
if not self.suggestMode:
|
||||||
runNimScriptIfExists(scriptFile)
|
runNimScriptIfExists(scriptFile)
|
||||||
# 'nim foo.nims' means to just run the NimScript file and do nothing more:
|
# 'nim foo.nims' means to just run the NimScript file and do nothing more:
|
||||||
if fileExists(scriptFile) and scriptFile.cmpPaths(conf.projectFull) == 0:
|
if fileExists(scriptFile) and scriptFile == conf.projectFull:
|
||||||
return false
|
return false
|
||||||
else:
|
else:
|
||||||
if scriptFile.cmpPaths(conf.projectFull) != 0:
|
if scriptFile != conf.projectFull:
|
||||||
runNimScriptIfExists(scriptFile)
|
runNimScriptIfExists(scriptFile)
|
||||||
else:
|
else:
|
||||||
# 'nimsuggest foo.nims' means to just auto-complete the NimScript file
|
# 'nimsuggest foo.nims' means to just auto-complete the NimScript file
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,8 @@ bootSwitch(usedNoGC, defined(nogc), "--gc:none")
|
||||||
|
|
||||||
import
|
import
|
||||||
os, msgs, options, nversion, condsyms, strutils, extccomp, platform,
|
os, msgs, options, nversion, condsyms, strutils, extccomp, platform,
|
||||||
wordrecg, parseutils, nimblecmd, idents, parseopt, sequtils, lineinfos
|
wordrecg, parseutils, nimblecmd, idents, parseopt, sequtils, lineinfos,
|
||||||
|
pathutils
|
||||||
|
|
||||||
# but some have deps to imported modules. Yay.
|
# but some have deps to imported modules. Yay.
|
||||||
bootSwitch(usedTinyC, hasTinyCBackend, "-d:tinyc")
|
bootSwitch(usedTinyC, hasTinyCBackend, "-d:tinyc")
|
||||||
|
|
@ -208,7 +209,7 @@ proc processSpecificNote*(arg: string, state: TSpecialWord, pass: TCmdLinePass,
|
||||||
|
|
||||||
proc processCompile(conf: ConfigRef; filename: string) =
|
proc processCompile(conf: ConfigRef; filename: string) =
|
||||||
var found = findFile(conf, filename)
|
var found = findFile(conf, filename)
|
||||||
if found == "": found = filename
|
if found.isEmpty: found = AbsoluteFile filename
|
||||||
extccomp.addExternalFileToCompile(conf, found)
|
extccomp.addExternalFileToCompile(conf, found)
|
||||||
|
|
||||||
const
|
const
|
||||||
|
|
@ -292,31 +293,32 @@ proc testCompileOption*(conf: ConfigRef; switch: string, info: TLineInfo): bool
|
||||||
else: invalidCmdLineOption(conf, passCmd1, switch, info)
|
else: invalidCmdLineOption(conf, passCmd1, switch, info)
|
||||||
|
|
||||||
proc processPath(conf: ConfigRef; path: string, info: TLineInfo,
|
proc processPath(conf: ConfigRef; path: string, info: TLineInfo,
|
||||||
notRelativeToProj = false): string =
|
notRelativeToProj = false): AbsoluteDir =
|
||||||
let p = if os.isAbsolute(path) or '$' in path:
|
let p = if os.isAbsolute(path) or '$' in path:
|
||||||
path
|
path
|
||||||
elif notRelativeToProj:
|
elif notRelativeToProj:
|
||||||
getCurrentDir() / path
|
getCurrentDir() / path
|
||||||
else:
|
else:
|
||||||
conf.projectPath / path
|
conf.projectPath.string / path
|
||||||
try:
|
try:
|
||||||
result = pathSubs(conf, p, toFullPath(conf, info).splitFile().dir)
|
result = AbsoluteDir pathSubs(conf, p, toFullPath(conf, info).splitFile().dir)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
localError(conf, info, "invalid path: " & p)
|
localError(conf, info, "invalid path: " & p)
|
||||||
result = p
|
result = AbsoluteDir p
|
||||||
|
|
||||||
proc processCfgPath(conf: ConfigRef; path: string, info: TLineInfo): string =
|
proc processCfgPath(conf: ConfigRef; path: string, info: TLineInfo): AbsoluteDir =
|
||||||
let path = if path[0] == '"': strutils.unescape(path) else: path
|
let path = if path.len > 0 and path[0] == '"': strutils.unescape(path)
|
||||||
|
else: path
|
||||||
let basedir = toFullPath(conf, info).splitFile().dir
|
let basedir = toFullPath(conf, info).splitFile().dir
|
||||||
let p = if os.isAbsolute(path) or '$' in path:
|
let p = if os.isAbsolute(path) or '$' in path:
|
||||||
path
|
path
|
||||||
else:
|
else:
|
||||||
basedir / path
|
basedir / path
|
||||||
try:
|
try:
|
||||||
result = pathSubs(conf, p, basedir)
|
result = AbsoluteDir pathSubs(conf, p, basedir)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
localError(conf, info, "invalid path: " & p)
|
localError(conf, info, "invalid path: " & p)
|
||||||
result = p
|
result = AbsoluteDir p
|
||||||
|
|
||||||
const
|
const
|
||||||
errInvalidNumber = "$1 is not a valid number"
|
errInvalidNumber = "$1 is not a valid number"
|
||||||
|
|
@ -331,9 +333,9 @@ proc trackDirty(conf: ConfigRef; arg: string, info: TLineInfo) =
|
||||||
if parseUtils.parseInt(a[3], column) <= 0:
|
if parseUtils.parseInt(a[3], column) <= 0:
|
||||||
localError(conf, info, errInvalidNumber % a[2])
|
localError(conf, info, errInvalidNumber % a[2])
|
||||||
|
|
||||||
let dirtyOriginalIdx = fileInfoIdx(conf, a[1])
|
let dirtyOriginalIdx = fileInfoIdx(conf, AbsoluteFile a[1])
|
||||||
if dirtyOriginalIdx.int32 >= 0:
|
if dirtyOriginalIdx.int32 >= 0:
|
||||||
msgs.setDirtyFile(conf, dirtyOriginalIdx, a[0])
|
msgs.setDirtyFile(conf, dirtyOriginalIdx, AbsoluteFile a[0])
|
||||||
|
|
||||||
conf.m.trackPos = newLineInfo(dirtyOriginalIdx, line, column)
|
conf.m.trackPos = newLineInfo(dirtyOriginalIdx, line, column)
|
||||||
|
|
||||||
|
|
@ -345,7 +347,7 @@ proc track(conf: ConfigRef; arg: string, info: TLineInfo) =
|
||||||
localError(conf, info, errInvalidNumber % a[1])
|
localError(conf, info, errInvalidNumber % a[1])
|
||||||
if parseUtils.parseInt(a[2], column) <= 0:
|
if parseUtils.parseInt(a[2], column) <= 0:
|
||||||
localError(conf, info, errInvalidNumber % a[2])
|
localError(conf, info, errInvalidNumber % a[2])
|
||||||
conf.m.trackPos = newLineInfo(conf, a[0], line, column)
|
conf.m.trackPos = newLineInfo(conf, AbsoluteFile a[0], line, column)
|
||||||
|
|
||||||
proc dynlibOverride(conf: ConfigRef; switch, arg: string, pass: TCmdLinePass, info: TLineInfo) =
|
proc dynlibOverride(conf: ConfigRef; switch, arg: string, pass: TCmdLinePass, info: TLineInfo) =
|
||||||
if pass in {passCmd2, passPP}:
|
if pass in {passCmd2, passPP}:
|
||||||
|
|
@ -359,14 +361,16 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
|
||||||
case switch.normalize
|
case switch.normalize
|
||||||
of "path", "p":
|
of "path", "p":
|
||||||
expectArg(conf, switch, arg, pass, info)
|
expectArg(conf, switch, arg, pass, info)
|
||||||
addPath(conf, if pass == passPP: processCfgPath(conf, arg, info) else: processPath(conf, arg, info), info)
|
addPath(conf, if pass == passPP: processCfgPath(conf, arg, info)
|
||||||
|
else: processPath(conf, arg, info), info)
|
||||||
of "nimblepath", "babelpath":
|
of "nimblepath", "babelpath":
|
||||||
# keep the old name for compat
|
# keep the old name for compat
|
||||||
if pass in {passCmd2, passPP} and optNoNimblePath notin conf.globalOptions:
|
if pass in {passCmd2, passPP} and optNoNimblePath notin conf.globalOptions:
|
||||||
expectArg(conf, switch, arg, pass, info)
|
expectArg(conf, switch, arg, pass, info)
|
||||||
var path = processPath(conf, arg, info, notRelativeToProj=true)
|
var path = processPath(conf, arg, info, notRelativeToProj=true)
|
||||||
let nimbleDir = getEnv("NIMBLE_DIR")
|
let nimbleDir = AbsoluteDir getEnv("NIMBLE_DIR")
|
||||||
if nimbleDir.len > 0 and pass == passPP: path = nimbleDir / "pkgs"
|
if not nimbleDir.isEmpty and pass == passPP:
|
||||||
|
path = nimbleDir / RelativeDir"pkgs"
|
||||||
nimblePath(conf, path, info)
|
nimblePath(conf, path, info)
|
||||||
of "nonimblepath", "nobabelpath":
|
of "nonimblepath", "nobabelpath":
|
||||||
expectNoArg(conf, switch, arg, pass, info)
|
expectNoArg(conf, switch, arg, pass, info)
|
||||||
|
|
@ -374,20 +378,14 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
|
||||||
of "excludepath":
|
of "excludepath":
|
||||||
expectArg(conf, switch, arg, pass, info)
|
expectArg(conf, switch, arg, pass, info)
|
||||||
let path = processPath(conf, arg, info)
|
let path = processPath(conf, arg, info)
|
||||||
|
conf.searchPaths.keepItIf(it != path)
|
||||||
conf.searchPaths.keepItIf(cmpPaths(it, path) != 0)
|
conf.lazyPaths.keepItIf(it != path)
|
||||||
conf.lazyPaths.keepItIf(cmpPaths(it, path) != 0)
|
|
||||||
|
|
||||||
if (len(path) > 0) and (path[len(path) - 1] == DirSep):
|
|
||||||
let strippedPath = path[0 .. (len(path) - 2)]
|
|
||||||
conf.searchPaths.keepItIf(cmpPaths(it, strippedPath) != 0)
|
|
||||||
conf.lazyPaths.keepItIf(cmpPaths(it, strippedPath) != 0)
|
|
||||||
of "nimcache":
|
of "nimcache":
|
||||||
expectArg(conf, switch, arg, pass, info)
|
expectArg(conf, switch, arg, pass, info)
|
||||||
conf.nimcacheDir = processPath(conf, arg, info, true)
|
conf.nimcacheDir = processPath(conf, arg, info, true)
|
||||||
of "out", "o":
|
of "out", "o":
|
||||||
expectArg(conf, switch, arg, pass, info)
|
expectArg(conf, switch, arg, pass, info)
|
||||||
conf.outFile = arg
|
conf.outFile = AbsoluteFile arg
|
||||||
of "docseesrcurl":
|
of "docseesrcurl":
|
||||||
expectArg(conf, switch, arg, pass, info)
|
expectArg(conf, switch, arg, pass, info)
|
||||||
conf.docSeeSrcUrl = arg
|
conf.docSeeSrcUrl = arg
|
||||||
|
|
@ -411,7 +409,8 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
|
||||||
if pass in {passCmd2, passPP}: processCompile(conf, arg)
|
if pass in {passCmd2, passPP}: processCompile(conf, arg)
|
||||||
of "link":
|
of "link":
|
||||||
expectArg(conf, switch, arg, pass, info)
|
expectArg(conf, switch, arg, pass, info)
|
||||||
if pass in {passCmd2, passPP}: addExternalFileToLink(conf, arg)
|
if pass in {passCmd2, passPP}:
|
||||||
|
addExternalFileToLink(conf, AbsoluteFile arg)
|
||||||
of "debuginfo":
|
of "debuginfo":
|
||||||
expectNoArg(conf, switch, arg, pass, info)
|
expectNoArg(conf, switch, arg, pass, info)
|
||||||
incl(conf.globalOptions, optCDebug)
|
incl(conf.globalOptions, optCDebug)
|
||||||
|
|
@ -581,7 +580,8 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
|
||||||
if pass in {passCmd2, passPP}: conf.cLibs.add processPath(conf, arg, info)
|
if pass in {passCmd2, passPP}: conf.cLibs.add processPath(conf, arg, info)
|
||||||
of "clib":
|
of "clib":
|
||||||
expectArg(conf, switch, arg, pass, info)
|
expectArg(conf, switch, arg, pass, info)
|
||||||
if pass in {passCmd2, passPP}: conf.cLinkedLibs.add processPath(conf, arg, info)
|
if pass in {passCmd2, passPP}:
|
||||||
|
conf.cLinkedLibs.add processPath(conf, arg, info).string
|
||||||
of "header":
|
of "header":
|
||||||
if conf != nil: conf.headerFile = arg
|
if conf != nil: conf.headerFile = arg
|
||||||
incl(conf.globalOptions, optGenIndex)
|
incl(conf.globalOptions, optGenIndex)
|
||||||
|
|
@ -742,7 +742,7 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
|
||||||
if strutils.find(switch, '.') >= 0: options.setConfigVar(conf, switch, arg)
|
if strutils.find(switch, '.') >= 0: options.setConfigVar(conf, switch, arg)
|
||||||
else: invalidCmdLineOption(conf, pass, switch, info)
|
else: invalidCmdLineOption(conf, pass, switch, info)
|
||||||
|
|
||||||
template gCmdLineInfo*(): untyped = newLineInfo(config, "command line", 1, 1)
|
template gCmdLineInfo*(): untyped = newLineInfo(config, AbsoluteFile"command line", 1, 1)
|
||||||
|
|
||||||
proc processCommand*(switch: string, pass: TCmdLinePass; config: ConfigRef) =
|
proc processCommand*(switch: string, pass: TCmdLinePass; config: ConfigRef) =
|
||||||
var cmd, arg: string
|
var cmd, arg: string
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,8 @@
|
||||||
# This module implements a dependency file generator.
|
# This module implements a dependency file generator.
|
||||||
|
|
||||||
import
|
import
|
||||||
os, options, ast, astalgo, msgs, ropes, idents, passes, modulepaths
|
os, options, ast, astalgo, msgs, ropes, idents, passes, modulepaths,
|
||||||
|
pathutils
|
||||||
|
|
||||||
from modulegraphs import ModuleGraph
|
from modulegraphs import ModuleGraph
|
||||||
|
|
||||||
|
|
@ -45,10 +46,10 @@ proc addDotDependency(c: PPassContext, n: PNode): PNode =
|
||||||
else:
|
else:
|
||||||
discard
|
discard
|
||||||
|
|
||||||
proc generateDot*(graph: ModuleGraph; project: string) =
|
proc generateDot*(graph: ModuleGraph; project: AbsoluteFile) =
|
||||||
let b = Backend(graph.backend)
|
let b = Backend(graph.backend)
|
||||||
discard writeRope("digraph $1 {$n$2}$n" % [
|
discard writeRope("digraph $1 {$n$2}$n" % [
|
||||||
rope(changeFileExt(extractFilename(project), "")), b.dotGraph],
|
rope(project.splitFile.name), b.dotGraph],
|
||||||
changeFileExt(project, "dot"))
|
changeFileExt(project, "dot"))
|
||||||
|
|
||||||
proc myOpen(graph: ModuleGraph; module: PSym): PPassContext =
|
proc myOpen(graph: ModuleGraph; module: PSym): PPassContext =
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,8 @@ import
|
||||||
wordrecg, syntaxes, renderer, lexer, packages/docutils/rstast,
|
wordrecg, syntaxes, renderer, lexer, packages/docutils/rstast,
|
||||||
packages/docutils/rst, packages/docutils/rstgen,
|
packages/docutils/rst, packages/docutils/rstgen,
|
||||||
packages/docutils/highlite, sempass2, json, xmltree, cgi,
|
packages/docutils/highlite, sempass2, json, xmltree, cgi,
|
||||||
typesrenderer, astalgo, modulepaths, lineinfos, sequtils, intsets
|
typesrenderer, astalgo, modulepaths, lineinfos, sequtils, intsets,
|
||||||
|
pathutils
|
||||||
|
|
||||||
type
|
type
|
||||||
TSections = array[TSymKind, Rope]
|
TSections = array[TSymKind, Rope]
|
||||||
|
|
@ -34,6 +35,8 @@ type
|
||||||
exampleCounter: int
|
exampleCounter: int
|
||||||
emitted: IntSet # we need to track which symbols have been emitted
|
emitted: IntSet # we need to track which symbols have been emitted
|
||||||
# already. See bug #3655
|
# already. See bug #3655
|
||||||
|
destFile*: AbsoluteFile
|
||||||
|
thisDir*: AbsoluteDir
|
||||||
|
|
||||||
PDoc* = ref TDocumentor ## Alias to type less.
|
PDoc* = ref TDocumentor ## Alias to type less.
|
||||||
|
|
||||||
|
|
@ -48,12 +51,12 @@ proc whichType(d: PDoc; n: PNode): PSym =
|
||||||
|
|
||||||
proc attachToType(d: PDoc; p: PSym): PSym =
|
proc attachToType(d: PDoc; p: PSym): PSym =
|
||||||
let params = p.ast.sons[paramsPos]
|
let params = p.ast.sons[paramsPos]
|
||||||
# first check the first parameter, then the return type,
|
|
||||||
# then the other parameter:
|
|
||||||
template check(i) =
|
template check(i) =
|
||||||
result = whichType(d, params[i])
|
result = whichType(d, params[i])
|
||||||
if result != nil: return result
|
if result != nil: return result
|
||||||
|
|
||||||
|
# first check the first parameter, then the return type,
|
||||||
|
# then the other parameter:
|
||||||
if params.len > 1: check(1)
|
if params.len > 1: check(1)
|
||||||
if params.len > 0: check(0)
|
if params.len > 0: check(0)
|
||||||
for i in 2..<params.len: check(i)
|
for i in 2..<params.len: check(i)
|
||||||
|
|
@ -74,10 +77,10 @@ template declareClosures =
|
||||||
of mwUnknownSubstitution: k = warnUnknownSubstitutionX
|
of mwUnknownSubstitution: k = warnUnknownSubstitutionX
|
||||||
of mwUnsupportedLanguage: k = warnLanguageXNotSupported
|
of mwUnsupportedLanguage: k = warnLanguageXNotSupported
|
||||||
of mwUnsupportedField: k = warnFieldXNotSupported
|
of mwUnsupportedField: k = warnFieldXNotSupported
|
||||||
globalError(conf, newLineInfo(conf, filename, line, col), k, arg)
|
globalError(conf, newLineInfo(conf, AbsoluteFile filename, line, col), k, arg)
|
||||||
|
|
||||||
proc docgenFindFile(s: string): string {.procvar.} =
|
proc docgenFindFile(s: string): string {.procvar.} =
|
||||||
result = options.findFile(conf, s)
|
result = options.findFile(conf, s).string
|
||||||
if result.len == 0:
|
if result.len == 0:
|
||||||
result = getCurrentDir() / s
|
result = getCurrentDir() / s
|
||||||
if not existsFile(result): result = ""
|
if not existsFile(result): result = ""
|
||||||
|
|
@ -90,13 +93,29 @@ proc parseRst(text, filename: string,
|
||||||
result = rstParse(text, filename, line, column, hasToc, rstOptions,
|
result = rstParse(text, filename, line, column, hasToc, rstOptions,
|
||||||
docgenFindFile, compilerMsgHandler)
|
docgenFindFile, compilerMsgHandler)
|
||||||
|
|
||||||
proc newDocumentor*(filename: string; cache: IdentCache; conf: ConfigRef): PDoc =
|
proc getOutFile2(conf: ConfigRef; filename: RelativeFile,
|
||||||
|
ext: string, dir: RelativeDir; guessTarget: bool): AbsoluteFile =
|
||||||
|
if optWholeProject in conf.globalOptions:
|
||||||
|
# This is correct, for 'nim doc --project' we interpret the '--out' option as an
|
||||||
|
# absolute directory, not as a filename!
|
||||||
|
let d = if conf.outFile.isEmpty: conf.projectPath / dir else: AbsoluteDir(conf.outFile)
|
||||||
|
createDir(d)
|
||||||
|
result = d / changeFileExt(filename, ext)
|
||||||
|
elif guessTarget:
|
||||||
|
let d = if not conf.outFile.isEmpty: splitFile(conf.outFile).dir
|
||||||
|
else: conf.projectPath
|
||||||
|
createDir(d)
|
||||||
|
result = d / changeFileExt(filename, ext)
|
||||||
|
else:
|
||||||
|
result = getOutFile(conf, filename, ext)
|
||||||
|
|
||||||
|
proc newDocumentor*(filename: AbsoluteFile; cache: IdentCache; conf: ConfigRef): PDoc =
|
||||||
declareClosures()
|
declareClosures()
|
||||||
new(result)
|
new(result)
|
||||||
result.conf = conf
|
result.conf = conf
|
||||||
result.cache = cache
|
result.cache = cache
|
||||||
initRstGenerator(result[], (if conf.cmd != cmdRst2tex: outHtml else: outLatex),
|
initRstGenerator(result[], (if conf.cmd != cmdRst2tex: outHtml else: outLatex),
|
||||||
conf.configVars, filename, {roSupportRawDirective},
|
conf.configVars, filename.string, {roSupportRawDirective},
|
||||||
docgenFindFile, compilerMsgHandler)
|
docgenFindFile, compilerMsgHandler)
|
||||||
|
|
||||||
if conf.configVars.hasKey("doc.googleAnalytics"):
|
if conf.configVars.hasKey("doc.googleAnalytics"):
|
||||||
|
|
@ -120,8 +139,12 @@ proc newDocumentor*(filename: string; cache: IdentCache; conf: ConfigRef): PDoc
|
||||||
result.jArray = newJArray()
|
result.jArray = newJArray()
|
||||||
initStrTable result.types
|
initStrTable result.types
|
||||||
result.onTestSnippet = proc (d: var RstGenerator; filename, cmd: string; status: int; content: string) =
|
result.onTestSnippet = proc (d: var RstGenerator; filename, cmd: string; status: int; content: string) =
|
||||||
localError(conf, newLineInfo(conf, d.filename, -1, -1), warnUser, "only 'rst2html' supports the ':test:' attribute")
|
localError(conf, newLineInfo(conf, AbsoluteFile d.filename, -1, -1),
|
||||||
|
warnUser, "only 'rst2html' supports the ':test:' attribute")
|
||||||
result.emitted = initIntSet()
|
result.emitted = initIntSet()
|
||||||
|
result.destFile = getOutFile2(conf, relativeTo(filename, conf.projectPath),
|
||||||
|
HtmlExt, RelativeDir"htmldocs", false)
|
||||||
|
result.thisDir = result.destFile.splitFile.dir
|
||||||
|
|
||||||
proc dispA(conf: ConfigRef; dest: var Rope, xml, tex: string, args: openArray[Rope]) =
|
proc dispA(conf: ConfigRef; dest: var Rope, xml, tex: string, args: openArray[Rope]) =
|
||||||
if conf.cmd != cmdRst2tex: addf(dest, xml, args)
|
if conf.cmd != cmdRst2tex: addf(dest, xml, args)
|
||||||
|
|
@ -227,6 +250,10 @@ proc getPlainDocstring(n: PNode): string =
|
||||||
result = getPlainDocstring(n.sons[i])
|
result = getPlainDocstring(n.sons[i])
|
||||||
if result.len > 0: return
|
if result.len > 0: return
|
||||||
|
|
||||||
|
proc belongsToPackage(conf: ConfigRef; module: PSym): bool =
|
||||||
|
result = module.kind == skModule and module.owner != nil and
|
||||||
|
module.owner.id == conf.mainPackageId
|
||||||
|
|
||||||
proc nodeToHighlightedHtml(d: PDoc; n: PNode; result: var Rope; renderFlags: TRenderFlags = {}) =
|
proc nodeToHighlightedHtml(d: PDoc; n: PNode; result: var Rope; renderFlags: TRenderFlags = {}) =
|
||||||
var r: TSrcGen
|
var r: TSrcGen
|
||||||
var literal = ""
|
var literal = ""
|
||||||
|
|
@ -259,8 +286,22 @@ proc nodeToHighlightedHtml(d: PDoc; n: PNode; result: var Rope; renderFlags: TRe
|
||||||
dispA(d.conf, result, "<span class=\"FloatNumber\">$1</span>",
|
dispA(d.conf, result, "<span class=\"FloatNumber\">$1</span>",
|
||||||
"\\spanFloatNumber{$1}", [rope(esc(d.target, literal))])
|
"\\spanFloatNumber{$1}", [rope(esc(d.target, literal))])
|
||||||
of tkSymbol:
|
of tkSymbol:
|
||||||
dispA(d.conf, result, "<span class=\"Identifier\">$1</span>",
|
let s = getTokSym(r)
|
||||||
"\\spanIdentifier{$1}", [rope(esc(d.target, literal))])
|
if s != nil and s.kind == skType and sfExported in s.flags and
|
||||||
|
s.owner != nil and belongsToPackage(d.conf, s.owner) and
|
||||||
|
d.target == outHtml:
|
||||||
|
|
||||||
|
let full = AbsoluteFile toFullPath(d.conf, FileIndex s.owner.position)
|
||||||
|
let tmp = getOutFile2(d.conf, full.relativeTo(d.conf.projectPath),
|
||||||
|
HtmlExt, RelativeDir"htmldocs", sfMainModule notin s.owner.flags)
|
||||||
|
|
||||||
|
let external = tmp.relativeTo(d.thisDir, '/')
|
||||||
|
result.addf "<a href=\"$1#$2\"><span class=\"Identifier\">$3</span></a>",
|
||||||
|
[rope changeFileExt(external, "html").string, rope literal,
|
||||||
|
rope(esc(d.target, literal))]
|
||||||
|
else:
|
||||||
|
dispA(d.conf, result, "<span class=\"Identifier\">$1</span>",
|
||||||
|
"\\spanIdentifier{$1}", [rope(esc(d.target, literal))])
|
||||||
of tkSpaces, tkInvalid:
|
of tkSpaces, tkInvalid:
|
||||||
add(result, literal)
|
add(result, literal)
|
||||||
of tkCurlyDotLe:
|
of tkCurlyDotLe:
|
||||||
|
|
@ -290,23 +331,25 @@ proc nodeToHighlightedHtml(d: PDoc; n: PNode; result: var Rope; renderFlags: TRe
|
||||||
|
|
||||||
proc testExample(d: PDoc; ex: PNode) =
|
proc testExample(d: PDoc; ex: PNode) =
|
||||||
if d.conf.errorCounter > 0: return
|
if d.conf.errorCounter > 0: return
|
||||||
let outputDir = d.conf.getNimcacheDir / "runnableExamples"
|
let outputDir = d.conf.getNimcacheDir / RelativeDir"runnableExamples"
|
||||||
createDir(outputDir)
|
createDir(outputDir)
|
||||||
inc d.exampleCounter
|
inc d.exampleCounter
|
||||||
let outp = outputDir / extractFilename(d.filename.changeFileExt"" &
|
let outp = outputDir / RelativeFile(extractFilename(d.filename.changeFileExt"" &
|
||||||
"_examples" & $d.exampleCounter & ".nim")
|
"_examples" & $d.exampleCounter & ".nim"))
|
||||||
#let nimcache = outp.changeFileExt"" & "_nimcache"
|
#let nimcache = outp.changeFileExt"" & "_nimcache"
|
||||||
renderModule(ex, d.filename, outp, conf = d.conf)
|
renderModule(ex, d.filename, outp.string, conf = d.conf)
|
||||||
let backend = if isDefined(d.conf, "js"): "js"
|
let backend = if isDefined(d.conf, "js"): "js"
|
||||||
elif isDefined(d.conf, "cpp"): "cpp"
|
elif isDefined(d.conf, "cpp"): "cpp"
|
||||||
elif isDefined(d.conf, "objc"): "objc"
|
elif isDefined(d.conf, "objc"): "objc"
|
||||||
else: "c"
|
else: "c"
|
||||||
if os.execShellCmd(os.getAppFilename() & " " & backend &
|
if os.execShellCmd(os.getAppFilename() & " " & backend &
|
||||||
" --nimcache:" & outputDir & " -r " & outp) != 0:
|
" --path:" & quoteShell(d.conf.projectPath) &
|
||||||
quit "[Examples] failed: see " & outp
|
" --nimcache:" & quoteShell(outputDir) &
|
||||||
|
" -r " & quoteShell(outp)) != 0:
|
||||||
|
quit "[Examples] failed: see " & outp.string
|
||||||
else:
|
else:
|
||||||
# keep generated source file `outp` to allow inspection.
|
# keep generated source file `outp` to allow inspection.
|
||||||
rawMessage(d.conf, hintSuccess, ["runnableExamples: " & outp])
|
rawMessage(d.conf, hintSuccess, ["runnableExamples: " & outp.string])
|
||||||
removeFile(outp.changeFileExt(ExeExt))
|
removeFile(outp.changeFileExt(ExeExt))
|
||||||
|
|
||||||
proc extractImports(n: PNode; result: PNode) =
|
proc extractImports(n: PNode; result: PNode) =
|
||||||
|
|
@ -332,7 +375,8 @@ proc isRunnableExample(n: PNode): bool =
|
||||||
result = n.kind == nkSym and n.sym.magic == mRunnableExamples or
|
result = n.kind == nkSym and n.sym.magic == mRunnableExamples or
|
||||||
n.kind == nkIdent and n.ident.s == "runnableExamples"
|
n.kind == nkIdent and n.ident.s == "runnableExamples"
|
||||||
|
|
||||||
proc getAllRunnableExamples(d: PDoc; n: PNode; dest: var Rope) =
|
proc getAllRunnableExamplesRec(d: PDoc; n, orig: PNode; dest: var Rope) =
|
||||||
|
if n.info.fileIndex != orig.info.fileIndex: return
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkCallKinds:
|
of nkCallKinds:
|
||||||
if isRunnableExample(n[0]) and
|
if isRunnableExample(n[0]) and
|
||||||
|
|
@ -357,7 +401,10 @@ proc getAllRunnableExamples(d: PDoc; n: PNode; dest: var Rope) =
|
||||||
dest.add(d.config.getOrDefault"doc.listing_end" % id)
|
dest.add(d.config.getOrDefault"doc.listing_end" % id)
|
||||||
else: discard
|
else: discard
|
||||||
for i in 0 ..< n.safeLen:
|
for i in 0 ..< n.safeLen:
|
||||||
getAllRunnableExamples(d, n[i], dest)
|
getAllRunnableExamplesRec(d, n[i], orig, dest)
|
||||||
|
|
||||||
|
proc getAllRunnableExamples(d: PDoc; n: PNode; dest: var Rope) =
|
||||||
|
getAllRunnableExamplesRec(d, n, n, dest)
|
||||||
|
|
||||||
when false:
|
when false:
|
||||||
proc findDocComment(n: PNode): PNode =
|
proc findDocComment(n: PNode): PNode =
|
||||||
|
|
@ -449,10 +496,8 @@ proc newUniquePlainSymbol(d: PDoc, original: string): string =
|
||||||
result = original
|
result = original
|
||||||
d.seenSymbols[original] = ""
|
d.seenSymbols[original] = ""
|
||||||
return
|
return
|
||||||
|
|
||||||
# Iterate over possible numeric variants of the original name.
|
# Iterate over possible numeric variants of the original name.
|
||||||
var count = 2
|
var count = 2
|
||||||
|
|
||||||
while true:
|
while true:
|
||||||
result = original & "_" & $count
|
result = original & "_" & $count
|
||||||
if not d.seenSymbols.hasKey(result):
|
if not d.seenSymbols.hasKey(result):
|
||||||
|
|
@ -460,7 +505,6 @@ proc newUniquePlainSymbol(d: PDoc, original: string): string =
|
||||||
break
|
break
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
|
|
||||||
proc complexName(k: TSymKind, n: PNode, baseName: string): string =
|
proc complexName(k: TSymKind, n: PNode, baseName: string): string =
|
||||||
## Builds a complex unique href name for the node.
|
## Builds a complex unique href name for the node.
|
||||||
##
|
##
|
||||||
|
|
@ -482,11 +526,9 @@ proc complexName(k: TSymKind, n: PNode, baseName: string): string =
|
||||||
of skTemplate: result.add(".t" & defaultParamSeparator)
|
of skTemplate: result.add(".t" & defaultParamSeparator)
|
||||||
of skConverter: result.add(".c" & defaultParamSeparator)
|
of skConverter: result.add(".c" & defaultParamSeparator)
|
||||||
else: discard
|
else: discard
|
||||||
|
|
||||||
if len(n) > paramsPos and n[paramsPos].kind == nkFormalParams:
|
if len(n) > paramsPos and n[paramsPos].kind == nkFormalParams:
|
||||||
result.add(renderParamTypes(n[paramsPos]))
|
result.add(renderParamTypes(n[paramsPos]))
|
||||||
|
|
||||||
|
|
||||||
proc isCallable(n: PNode): bool =
|
proc isCallable(n: PNode): bool =
|
||||||
## Returns true if `n` contains a callable node.
|
## Returns true if `n` contains a callable node.
|
||||||
case n.kind
|
case n.kind
|
||||||
|
|
@ -495,7 +537,6 @@ proc isCallable(n: PNode): bool =
|
||||||
else:
|
else:
|
||||||
result = false
|
result = false
|
||||||
|
|
||||||
|
|
||||||
proc docstringSummary(rstText: string): string =
|
proc docstringSummary(rstText: string): string =
|
||||||
## Returns just the first line or a brief chunk of text from a rst string.
|
## Returns just the first line or a brief chunk of text from a rst string.
|
||||||
##
|
##
|
||||||
|
|
@ -523,7 +564,6 @@ proc docstringSummary(rstText: string): string =
|
||||||
result.delete(pos, last)
|
result.delete(pos, last)
|
||||||
result.add("…")
|
result.add("…")
|
||||||
|
|
||||||
|
|
||||||
proc genItem(d: PDoc, n, nameNode: PNode, k: TSymKind) =
|
proc genItem(d: PDoc, n, nameNode: PNode, k: TSymKind) =
|
||||||
if not isVisible(d, nameNode): return
|
if not isVisible(d, nameNode): return
|
||||||
let
|
let
|
||||||
|
|
@ -545,8 +585,8 @@ proc genItem(d: PDoc, n, nameNode: PNode, k: TSymKind) =
|
||||||
break
|
break
|
||||||
plainName.add(literal)
|
plainName.add(literal)
|
||||||
|
|
||||||
# Render the HTML hyperlink.
|
nodeToHighlightedHtml(d, n, result, {renderNoBody, renderNoComments,
|
||||||
nodeToHighlightedHtml(d, n, result, {renderNoBody, renderNoComments, renderDocComments})
|
renderDocComments, renderSyms})
|
||||||
|
|
||||||
inc(d.id)
|
inc(d.id)
|
||||||
let
|
let
|
||||||
|
|
@ -563,16 +603,18 @@ proc genItem(d: PDoc, n, nameNode: PNode, k: TSymKind) =
|
||||||
var seeSrcRope: Rope = nil
|
var seeSrcRope: Rope = nil
|
||||||
let docItemSeeSrc = getConfigVar(d.conf, "doc.item.seesrc")
|
let docItemSeeSrc = getConfigVar(d.conf, "doc.item.seesrc")
|
||||||
if docItemSeeSrc.len > 0:
|
if docItemSeeSrc.len > 0:
|
||||||
let cwd = canonicalizePath(d.conf, getCurrentDir())
|
let path = relativeTo(AbsoluteFile toFullPath(d.conf, n.info), d.conf.projectPath, '/')
|
||||||
var path = toFullPath(d.conf, n.info)
|
when false:
|
||||||
if path.startsWith(cwd):
|
let cwd = canonicalizePath(d.conf, getCurrentDir())
|
||||||
path = path[cwd.len+1 .. ^1].replace('\\', '/')
|
var path = toFullPath(d.conf, n.info)
|
||||||
|
if path.startsWith(cwd):
|
||||||
|
path = path[cwd.len+1 .. ^1].replace('\\', '/')
|
||||||
let gitUrl = getConfigVar(d.conf, "git.url")
|
let gitUrl = getConfigVar(d.conf, "git.url")
|
||||||
if gitUrl.len > 0:
|
if gitUrl.len > 0:
|
||||||
let commit = getConfigVar(d.conf, "git.commit", "master")
|
let commit = getConfigVar(d.conf, "git.commit", "master")
|
||||||
let develBranch = getConfigVar(d.conf, "git.devel", "devel")
|
let develBranch = getConfigVar(d.conf, "git.devel", "devel")
|
||||||
dispA(d.conf, seeSrcRope, "$1", "", [ropeFormatNamedVars(d.conf, docItemSeeSrc,
|
dispA(d.conf, seeSrcRope, "$1", "", [ropeFormatNamedVars(d.conf, docItemSeeSrc,
|
||||||
["path", "line", "url", "commit", "devel"], [rope path,
|
["path", "line", "url", "commit", "devel"], [rope path.string,
|
||||||
rope($n.info.line), rope gitUrl, rope commit, rope develBranch])])
|
rope($n.info.line), rope gitUrl, rope commit, rope develBranch])])
|
||||||
|
|
||||||
add(d.section[k], ropeFormatNamedVars(d.conf, getConfigVar(d.conf, "doc.item"),
|
add(d.section[k], ropeFormatNamedVars(d.conf, getConfigVar(d.conf, "doc.item"),
|
||||||
|
|
@ -581,11 +623,22 @@ proc genItem(d: PDoc, n, nameNode: PNode, k: TSymKind) =
|
||||||
[nameRope, result, comm, itemIDRope, plainNameRope, plainSymbolRope,
|
[nameRope, result, comm, itemIDRope, plainNameRope, plainSymbolRope,
|
||||||
symbolOrIdRope, plainSymbolEncRope, symbolOrIdEncRope, seeSrcRope]))
|
symbolOrIdRope, plainSymbolEncRope, symbolOrIdEncRope, seeSrcRope]))
|
||||||
|
|
||||||
|
let external = AbsoluteFile(d.filename).relativeTo(d.conf.projectPath, '/').changeFileExt(HtmlExt).string
|
||||||
|
|
||||||
var attype: Rope
|
var attype: Rope
|
||||||
if k in routineKinds and nameNode.kind == nkSym:
|
if k in routineKinds and nameNode.kind == nkSym:
|
||||||
let att = attachToType(d, nameNode.sym)
|
let att = attachToType(d, nameNode.sym)
|
||||||
if att != nil:
|
if att != nil:
|
||||||
attype = rope esc(d.target, att.name.s)
|
attype = rope esc(d.target, att.name.s)
|
||||||
|
elif k == skType and nameNode.kind == nkSym and nameNode.sym.typ.kind in {tyEnum, tyBool}:
|
||||||
|
let etyp = nameNode.sym.typ
|
||||||
|
for e in etyp.n:
|
||||||
|
if e.sym.kind != skEnumField: continue
|
||||||
|
let plain = renderPlainSymbolName(e)
|
||||||
|
let symbolOrId = d.newUniquePlainSymbol(plain)
|
||||||
|
setIndexTerm(d[], external, symbolOrId, plain, nameNode.sym.name.s & '.' & plain,
|
||||||
|
xmltree.escape(getPlainDocstring(e).docstringSummary))
|
||||||
|
|
||||||
add(d.toc[k], ropeFormatNamedVars(d.conf, getConfigVar(d.conf, "doc.item.toc"),
|
add(d.toc[k], ropeFormatNamedVars(d.conf, getConfigVar(d.conf, "doc.item.toc"),
|
||||||
["name", "header", "desc", "itemID", "header_plain", "itemSym",
|
["name", "header", "desc", "itemID", "header_plain", "itemSym",
|
||||||
"itemSymOrID", "itemSymEnc", "itemSymOrIDEnc", "attype"],
|
"itemSymOrID", "itemSymEnc", "itemSymOrIDEnc", "attype"],
|
||||||
|
|
@ -596,11 +649,11 @@ proc genItem(d: PDoc, n, nameNode: PNode, k: TSymKind) =
|
||||||
# Ironically for types the complexSymbol is *cleaner* than the plainName
|
# Ironically for types the complexSymbol is *cleaner* than the plainName
|
||||||
# because it doesn't include object fields or documentation comments. So we
|
# because it doesn't include object fields or documentation comments. So we
|
||||||
# use the plain one for callable elements, and the complex for the rest.
|
# use the plain one for callable elements, and the complex for the rest.
|
||||||
var linkTitle = changeFileExt(extractFilename(d.filename), "") & " : "
|
var linkTitle = changeFileExt(extractFilename(d.filename), "") & ": "
|
||||||
if n.isCallable: linkTitle.add(xmltree.escape(plainName.strip))
|
if n.isCallable: linkTitle.add(xmltree.escape(plainName.strip))
|
||||||
else: linkTitle.add(xmltree.escape(complexSymbol.strip))
|
else: linkTitle.add(xmltree.escape(complexSymbol.strip))
|
||||||
|
|
||||||
setIndexTerm(d[], symbolOrId, name, linkTitle,
|
setIndexTerm(d[], external, symbolOrId, name, linkTitle,
|
||||||
xmltree.escape(plainDocstring.docstringSummary))
|
xmltree.escape(plainDocstring.docstringSummary))
|
||||||
if k == skType and nameNode.kind == nkSym:
|
if k == skType and nameNode.kind == nkSym:
|
||||||
d.types.strTableAdd nameNode.sym
|
d.types.strTableAdd nameNode.sym
|
||||||
|
|
@ -611,9 +664,7 @@ proc genJsonItem(d: PDoc, n, nameNode: PNode, k: TSymKind): JsonNode =
|
||||||
name = getName(d, nameNode)
|
name = getName(d, nameNode)
|
||||||
comm = $genRecComment(d, n)
|
comm = $genRecComment(d, n)
|
||||||
r: TSrcGen
|
r: TSrcGen
|
||||||
|
|
||||||
initTokRender(r, n, {renderNoBody, renderNoComments, renderDocComments})
|
initTokRender(r, n, {renderNoBody, renderNoComments, renderDocComments})
|
||||||
|
|
||||||
result = %{ "name": %name, "type": %($k), "line": %n.info.line.int,
|
result = %{ "name": %name, "type": %($k), "line": %n.info.line.int,
|
||||||
"col": %n.info.col}
|
"col": %n.info.col}
|
||||||
if comm.len > 0:
|
if comm.len > 0:
|
||||||
|
|
@ -626,7 +677,6 @@ proc checkForFalse(n: PNode): bool =
|
||||||
|
|
||||||
proc traceDeps(d: PDoc, it: PNode) =
|
proc traceDeps(d: PDoc, it: PNode) =
|
||||||
const k = skModule
|
const k = skModule
|
||||||
|
|
||||||
if it.kind == nkInfix and it.len == 3 and it[2].kind == nkBracket:
|
if it.kind == nkInfix and it.len == 3 and it[2].kind == nkBracket:
|
||||||
let sep = it[0]
|
let sep = it[0]
|
||||||
let dir = it[1]
|
let dir = it[1]
|
||||||
|
|
@ -637,13 +687,19 @@ proc traceDeps(d: PDoc, it: PNode) =
|
||||||
for x in it[2]:
|
for x in it[2]:
|
||||||
a.sons[2] = x
|
a.sons[2] = x
|
||||||
traceDeps(d, a)
|
traceDeps(d, a)
|
||||||
else:
|
elif it.kind == nkSym and belongsToPackage(d.conf, it.sym):
|
||||||
|
let full = AbsoluteFile toFullPath(d.conf, FileIndex it.sym.position)
|
||||||
|
let tmp = getOutFile2(d.conf, full.relativeTo(d.conf.projectPath), HtmlExt,
|
||||||
|
RelativeDir"htmldocs", sfMainModule notin it.sym.flags)
|
||||||
|
let external = relativeTo(tmp, d.thisDir, '/').string
|
||||||
if d.section[k] != nil: add(d.section[k], ", ")
|
if d.section[k] != nil: add(d.section[k], ", ")
|
||||||
dispA(d.conf, d.section[k],
|
dispA(d.conf, d.section[k],
|
||||||
"<a class=\"reference external\" href=\"$1.html\">$1</a>",
|
"<a class=\"reference external\" href=\"$2\">$1</a>",
|
||||||
"$1", [rope(splitFile(getModuleName(d.conf, it)).name)])
|
"$1", [rope esc(d.target, changeFileExt(external, "")),
|
||||||
|
rope changeFileExt(external, "html")])
|
||||||
|
|
||||||
proc generateDoc*(d: PDoc, n: PNode) =
|
proc generateDoc*(d: PDoc, n, orig: PNode) =
|
||||||
|
if orig.info.fileIndex != n.info.fileIndex: return
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkCommentStmt: add(d.modDesc, genComment(d, n))
|
of nkCommentStmt: add(d.modDesc, genComment(d, n))
|
||||||
of nkProcDef:
|
of nkProcDef:
|
||||||
|
|
@ -670,11 +726,11 @@ proc generateDoc*(d: PDoc, n: PNode) =
|
||||||
genItem(d, n.sons[i], n.sons[i].sons[0],
|
genItem(d, n.sons[i], n.sons[i].sons[0],
|
||||||
succ(skType, ord(n.kind)-ord(nkTypeSection)))
|
succ(skType, ord(n.kind)-ord(nkTypeSection)))
|
||||||
of nkStmtList:
|
of nkStmtList:
|
||||||
for i in countup(0, sonsLen(n) - 1): generateDoc(d, n.sons[i])
|
for i in countup(0, sonsLen(n) - 1): generateDoc(d, n.sons[i], orig)
|
||||||
of nkWhenStmt:
|
of nkWhenStmt:
|
||||||
# generate documentation for the first branch only:
|
# generate documentation for the first branch only:
|
||||||
if not checkForFalse(n.sons[0].sons[0]):
|
if not checkForFalse(n.sons[0].sons[0]):
|
||||||
generateDoc(d, lastSon(n.sons[0]))
|
generateDoc(d, lastSon(n.sons[0]), orig)
|
||||||
of nkImportStmt:
|
of nkImportStmt:
|
||||||
for i in 0 .. sonsLen(n)-1: traceDeps(d, n.sons[i])
|
for i in 0 .. sonsLen(n)-1: traceDeps(d, n.sons[i])
|
||||||
of nkFromStmt, nkImportExceptStmt: traceDeps(d, n.sons[0])
|
of nkFromStmt, nkImportExceptStmt: traceDeps(d, n.sons[0])
|
||||||
|
|
@ -803,7 +859,8 @@ proc genOutFile(d: PDoc): Rope =
|
||||||
# Extract the title. Non API modules generate an entry in the index table.
|
# Extract the title. Non API modules generate an entry in the index table.
|
||||||
if d.meta[metaTitle].len != 0:
|
if d.meta[metaTitle].len != 0:
|
||||||
title = d.meta[metaTitle]
|
title = d.meta[metaTitle]
|
||||||
setIndexTerm(d[], "", title)
|
let external = AbsoluteFile(d.filename).relativeTo(d.conf.projectPath, '/').changeFileExt(HtmlExt).string
|
||||||
|
setIndexTerm(d[], external, "", title)
|
||||||
else:
|
else:
|
||||||
# Modules get an automatic title for the HTML, but no entry in the index.
|
# Modules get an automatic title for the HTML, but no entry in the index.
|
||||||
title = "Module " & extractFilename(changeFileExt(d.filename, ""))
|
title = "Module " & extractFilename(changeFileExt(d.filename, ""))
|
||||||
|
|
@ -829,29 +886,27 @@ proc genOutFile(d: PDoc): Rope =
|
||||||
|
|
||||||
proc generateIndex*(d: PDoc) =
|
proc generateIndex*(d: PDoc) =
|
||||||
if optGenIndex in d.conf.globalOptions:
|
if optGenIndex in d.conf.globalOptions:
|
||||||
writeIndexFile(d[], splitFile(d.conf.outFile).dir /
|
let dir = if d.conf.outFile.isEmpty: d.conf.projectPath / RelativeDir"htmldocs"
|
||||||
splitFile(d.filename).name & IndexExt)
|
elif optWholeProject in d.conf.globalOptions: AbsoluteDir(d.conf.outFile)
|
||||||
|
else: AbsoluteDir(d.conf.outFile.string.splitFile.dir)
|
||||||
|
createDir(dir)
|
||||||
|
let dest = dir / changeFileExt(relativeTo(AbsoluteFile d.filename,
|
||||||
|
d.conf.projectPath), IndexExt)
|
||||||
|
writeIndexFile(d[], dest.string)
|
||||||
|
|
||||||
proc getOutFile2(conf: ConfigRef; filename, ext, dir: string): string =
|
proc writeOutput*(d: PDoc, useWarning = false) =
|
||||||
if optWholeProject in conf.globalOptions:
|
|
||||||
let d = if conf.outFile != "": conf.outFile else: dir
|
|
||||||
createDir(d)
|
|
||||||
result = d / changeFileExt(filename, ext)
|
|
||||||
else:
|
|
||||||
result = getOutFile(conf, filename, ext)
|
|
||||||
|
|
||||||
proc writeOutput*(d: PDoc, filename, outExt: string, useWarning = false) =
|
|
||||||
var content = genOutFile(d)
|
var content = genOutFile(d)
|
||||||
if optStdout in d.conf.globalOptions:
|
if optStdout in d.conf.globalOptions:
|
||||||
writeRope(stdout, content)
|
writeRope(stdout, content)
|
||||||
else:
|
else:
|
||||||
let outfile = getOutFile2(d.conf, filename, outExt, "htmldocs")
|
template outfile: untyped = d.destFile
|
||||||
createDir(outfile.parentDir)
|
#let outfile = getOutFile2(d.conf, shortenDir(d.conf, filename), outExt, "htmldocs")
|
||||||
|
createDir(outfile.splitFile.dir)
|
||||||
if not writeRope(content, outfile):
|
if not writeRope(content, outfile):
|
||||||
rawMessage(d.conf, if useWarning: warnCannotOpenFile else: errCannotOpenFile, outfile)
|
rawMessage(d.conf, if useWarning: warnCannotOpenFile else: errCannotOpenFile,
|
||||||
|
outfile.string)
|
||||||
|
|
||||||
proc writeOutputJson*(d: PDoc, filename, outExt: string,
|
proc writeOutputJson*(d: PDoc, useWarning = false) =
|
||||||
useWarning = false) =
|
|
||||||
let content = %*{"orig": d.filename,
|
let content = %*{"orig": d.filename,
|
||||||
"nimble": getPackageName(d.conf, d.filename),
|
"nimble": getPackageName(d.conf, d.filename),
|
||||||
"entries": d.jArray}
|
"entries": d.jArray}
|
||||||
|
|
@ -859,8 +914,7 @@ proc writeOutputJson*(d: PDoc, filename, outExt: string,
|
||||||
write(stdout, $content)
|
write(stdout, $content)
|
||||||
else:
|
else:
|
||||||
var f: File
|
var f: File
|
||||||
if open(f, getOutFile2(d.conf, splitFile(filename).name,
|
if open(f, d.destFile.string, fmWrite):
|
||||||
outExt, "jsondocs"), fmWrite):
|
|
||||||
write(f, $content)
|
write(f, $content)
|
||||||
close(f)
|
close(f)
|
||||||
else:
|
else:
|
||||||
|
|
@ -871,27 +925,28 @@ proc commandDoc*(cache: IdentCache, conf: ConfigRef) =
|
||||||
if ast == nil: return
|
if ast == nil: return
|
||||||
var d = newDocumentor(conf.projectFull, cache, conf)
|
var d = newDocumentor(conf.projectFull, cache, conf)
|
||||||
d.hasToc = true
|
d.hasToc = true
|
||||||
generateDoc(d, ast)
|
generateDoc(d, ast, ast)
|
||||||
writeOutput(d, conf.projectFull, HtmlExt)
|
writeOutput(d)
|
||||||
generateIndex(d)
|
generateIndex(d)
|
||||||
|
|
||||||
proc commandRstAux(cache: IdentCache, conf: ConfigRef; filename, outExt: string) =
|
proc commandRstAux(cache: IdentCache, conf: ConfigRef;
|
||||||
|
filename: AbsoluteFile, outExt: string) =
|
||||||
var filen = addFileExt(filename, "txt")
|
var filen = addFileExt(filename, "txt")
|
||||||
var d = newDocumentor(filen, cache, conf)
|
var d = newDocumentor(filen, cache, conf)
|
||||||
d.onTestSnippet = proc (d: var RstGenerator; filename, cmd: string;
|
d.onTestSnippet = proc (d: var RstGenerator; filename, cmd: string;
|
||||||
status: int; content: string) =
|
status: int; content: string) =
|
||||||
var outp: string
|
var outp: AbsoluteFile
|
||||||
if filename.len == 0:
|
if filename.len == 0:
|
||||||
inc(d.id)
|
inc(d.id)
|
||||||
let nameOnly = splitFile(d.filename).name
|
let nameOnly = splitFile(d.filename).name
|
||||||
let subdir = getNimcacheDir(conf) / nameOnly
|
let subdir = getNimcacheDir(conf) / RelativeDir(nameOnly)
|
||||||
createDir(subdir)
|
createDir(subdir)
|
||||||
outp = subdir / (nameOnly & "_snippet_" & $d.id & ".nim")
|
outp = subdir / RelativeFile(nameOnly & "_snippet_" & $d.id & ".nim")
|
||||||
elif isAbsolute(filename):
|
elif isAbsolute(filename):
|
||||||
outp = filename
|
outp = AbsoluteFile filename
|
||||||
else:
|
else:
|
||||||
# Nim's convention: every path is relative to the file it was written in:
|
# Nim's convention: every path is relative to the file it was written in:
|
||||||
outp = splitFile(d.filename).dir / filename
|
outp = splitFile(d.filename).dir.AbsoluteDir / RelativeFile(filename)
|
||||||
writeFile(outp, content)
|
writeFile(outp, content)
|
||||||
let cmd = cmd % quoteShell(outp)
|
let cmd = cmd % quoteShell(outp)
|
||||||
rawMessage(conf, hintExecuting, cmd)
|
rawMessage(conf, hintExecuting, cmd)
|
||||||
|
|
@ -899,14 +954,12 @@ proc commandRstAux(cache: IdentCache, conf: ConfigRef; filename, outExt: string)
|
||||||
rawMessage(conf, errGenerated, "executing of external program failed: " & cmd)
|
rawMessage(conf, errGenerated, "executing of external program failed: " & cmd)
|
||||||
|
|
||||||
d.isPureRst = true
|
d.isPureRst = true
|
||||||
var rst = parseRst(readFile(filen), filen, 0, 1, d.hasToc,
|
var rst = parseRst(readFile(filen.string), filen.string, 0, 1, d.hasToc,
|
||||||
{roSupportRawDirective}, conf)
|
{roSupportRawDirective}, conf)
|
||||||
var modDesc = newStringOfCap(30_000)
|
var modDesc = newStringOfCap(30_000)
|
||||||
#d.modDesc = newMutableRope(30_000)
|
|
||||||
renderRstToOut(d[], rst, modDesc)
|
renderRstToOut(d[], rst, modDesc)
|
||||||
#freezeMutableRope(d.modDesc)
|
|
||||||
d.modDesc = rope(modDesc)
|
d.modDesc = rope(modDesc)
|
||||||
writeOutput(d, filename, outExt)
|
writeOutput(d)
|
||||||
generateIndex(d)
|
generateIndex(d)
|
||||||
|
|
||||||
proc commandRst2Html*(cache: IdentCache, conf: ConfigRef) =
|
proc commandRst2Html*(cache: IdentCache, conf: ConfigRef) =
|
||||||
|
|
@ -928,9 +981,9 @@ proc commandJson*(cache: IdentCache, conf: ConfigRef) =
|
||||||
writeRope(stdout, content)
|
writeRope(stdout, content)
|
||||||
else:
|
else:
|
||||||
#echo getOutFile(gProjectFull, JsonExt)
|
#echo getOutFile(gProjectFull, JsonExt)
|
||||||
let filename = getOutFile(conf, conf.projectFull, JsonExt)
|
let filename = getOutFile(conf, RelativeFile conf.projectName, JsonExt)
|
||||||
if not writeRope(content, filename):
|
if not writeRope(content, filename):
|
||||||
rawMessage(conf, errCannotOpenFile, filename)
|
rawMessage(conf, errCannotOpenFile, filename.string)
|
||||||
|
|
||||||
proc commandTags*(cache: IdentCache, conf: ConfigRef) =
|
proc commandTags*(cache: IdentCache, conf: ConfigRef) =
|
||||||
var ast = parseFile(conf.projectMainIdx, cache, conf)
|
var ast = parseFile(conf.projectMainIdx, cache, conf)
|
||||||
|
|
@ -945,12 +998,12 @@ proc commandTags*(cache: IdentCache, conf: ConfigRef) =
|
||||||
writeRope(stdout, content)
|
writeRope(stdout, content)
|
||||||
else:
|
else:
|
||||||
#echo getOutFile(gProjectFull, TagsExt)
|
#echo getOutFile(gProjectFull, TagsExt)
|
||||||
let filename = getOutFile(conf, conf.projectFull, TagsExt)
|
let filename = getOutFile(conf, RelativeFile conf.projectName, TagsExt)
|
||||||
if not writeRope(content, filename):
|
if not writeRope(content, filename):
|
||||||
rawMessage(conf, errCannotOpenFile, filename)
|
rawMessage(conf, errCannotOpenFile, filename.string)
|
||||||
|
|
||||||
proc commandBuildIndex*(cache: IdentCache, conf: ConfigRef) =
|
proc commandBuildIndex*(cache: IdentCache, conf: ConfigRef) =
|
||||||
var content = mergeIndexes(conf.projectFull).rope
|
var content = mergeIndexes(conf.projectFull.string).rope
|
||||||
|
|
||||||
let code = ropeFormatNamedVars(conf, getConfigVar(conf, "doc.file"), ["title",
|
let code = ropeFormatNamedVars(conf, getConfigVar(conf, "doc.file"), ["title",
|
||||||
"tableofcontents", "moduledesc", "date", "time",
|
"tableofcontents", "moduledesc", "date", "time",
|
||||||
|
|
@ -958,6 +1011,6 @@ proc commandBuildIndex*(cache: IdentCache, conf: ConfigRef) =
|
||||||
["Index".rope, nil, nil, rope(getDateStr()),
|
["Index".rope, nil, nil, rope(getDateStr()),
|
||||||
rope(getClockStr()), content, nil, nil, nil])
|
rope(getClockStr()), content, nil, nil, nil])
|
||||||
# no analytics because context is not available
|
# no analytics because context is not available
|
||||||
let filename = getOutFile(conf, "theindex", HtmlExt)
|
let filename = getOutFile(conf, RelativeFile"theindex", HtmlExt)
|
||||||
if not writeRope(code, filename):
|
if not writeRope(code, filename):
|
||||||
rawMessage(conf, errCannotOpenFile, filename)
|
rawMessage(conf, errCannotOpenFile, filename.string)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@
|
||||||
# semantic checking.
|
# semantic checking.
|
||||||
|
|
||||||
import
|
import
|
||||||
os, options, ast, astalgo, msgs, ropes, idents, passes, docgen, lineinfos
|
os, options, ast, astalgo, msgs, ropes, idents, passes, docgen, lineinfos,
|
||||||
|
pathutils
|
||||||
|
|
||||||
from modulegraphs import ModuleGraph
|
from modulegraphs import ModuleGraph
|
||||||
|
|
||||||
|
|
@ -38,17 +39,17 @@ template closeImpl(body: untyped) {.dirty.} =
|
||||||
|
|
||||||
proc close(graph: ModuleGraph; p: PPassContext, n: PNode): PNode =
|
proc close(graph: ModuleGraph; p: PPassContext, n: PNode): PNode =
|
||||||
closeImpl:
|
closeImpl:
|
||||||
writeOutput(g.doc, toFullPath(graph.config, FileIndex g.module.position), HtmlExt, useWarning)
|
writeOutput(g.doc, useWarning)
|
||||||
|
|
||||||
proc closeJson(graph: ModuleGraph; p: PPassContext, n: PNode): PNode =
|
proc closeJson(graph: ModuleGraph; p: PPassContext, n: PNode): PNode =
|
||||||
closeImpl:
|
closeImpl:
|
||||||
writeOutputJson(g.doc, toFullPath(graph.config, FileIndex g.module.position), ".json", useWarning)
|
writeOutputJson(g.doc, useWarning)
|
||||||
|
|
||||||
proc processNode(c: PPassContext, n: PNode): PNode =
|
proc processNode(c: PPassContext, n: PNode): PNode =
|
||||||
result = n
|
result = n
|
||||||
var g = PGen(c)
|
var g = PGen(c)
|
||||||
if shouldProcess(g):
|
if shouldProcess(g):
|
||||||
generateDoc(g.doc, n)
|
generateDoc(g.doc, n, n)
|
||||||
|
|
||||||
proc processNodeJson(c: PPassContext, n: PNode): PNode =
|
proc processNodeJson(c: PPassContext, n: PNode): PNode =
|
||||||
result = n
|
result = n
|
||||||
|
|
@ -60,7 +61,8 @@ proc myOpen(graph: ModuleGraph; module: PSym): PPassContext =
|
||||||
var g: PGen
|
var g: PGen
|
||||||
new(g)
|
new(g)
|
||||||
g.module = module
|
g.module = module
|
||||||
var d = newDocumentor(toFullPath(graph.config, FileIndex module.position), graph.cache, graph.config)
|
var d = newDocumentor(AbsoluteFile toFullPath(graph.config, FileIndex module.position),
|
||||||
|
graph.cache, graph.config)
|
||||||
d.hasToc = true
|
d.hasToc = true
|
||||||
g.doc = d
|
g.doc = d
|
||||||
result = g
|
result = g
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
import
|
import
|
||||||
ropes, os, strutils, osproc, platform, condsyms, options, msgs,
|
ropes, os, strutils, osproc, platform, condsyms, options, msgs,
|
||||||
lineinfos, std / sha1, streams
|
lineinfos, std / sha1, streams, pathutils
|
||||||
|
|
||||||
type
|
type
|
||||||
TInfoCCProp* = enum # properties of the C compiler:
|
TInfoCCProp* = enum # properties of the C compiler:
|
||||||
|
|
@ -429,12 +429,13 @@ proc initVars*(conf: ConfigRef) =
|
||||||
if len(conf.ccompilerpath) == 0:
|
if len(conf.ccompilerpath) == 0:
|
||||||
conf.ccompilerpath = getConfigVar(conf, conf.cCompiler, ".path")
|
conf.ccompilerpath = getConfigVar(conf, conf.cCompiler, ".path")
|
||||||
|
|
||||||
proc completeCFilePath*(conf: ConfigRef; cfile: string, createSubDir: bool = true): string =
|
proc completeCFilePath*(conf: ConfigRef; cfile: AbsoluteFile,
|
||||||
|
createSubDir: bool = true): AbsoluteFile =
|
||||||
result = completeGeneratedFilePath(conf, cfile, createSubDir)
|
result = completeGeneratedFilePath(conf, cfile, createSubDir)
|
||||||
|
|
||||||
proc toObjFile*(conf: ConfigRef; filename: string): string =
|
proc toObjFile*(conf: ConfigRef; filename: AbsoluteFile): AbsoluteFile =
|
||||||
# Object file for compilation
|
# Object file for compilation
|
||||||
result = filename & "." & CC[conf.cCompiler].objExt
|
result = AbsoluteFile(filename.string & "." & CC[conf.cCompiler].objExt)
|
||||||
|
|
||||||
proc addFileToCompile*(conf: ConfigRef; cf: Cfile) =
|
proc addFileToCompile*(conf: ConfigRef; cf: Cfile) =
|
||||||
conf.toCompile.add(cf)
|
conf.toCompile.add(cf)
|
||||||
|
|
@ -447,8 +448,8 @@ proc resetCompilationLists*(conf: ConfigRef) =
|
||||||
# Maybe we can do that in checkDep on the other hand?
|
# Maybe we can do that in checkDep on the other hand?
|
||||||
conf.externalToLink.setLen 0
|
conf.externalToLink.setLen 0
|
||||||
|
|
||||||
proc addExternalFileToLink*(conf: ConfigRef; filename: string) =
|
proc addExternalFileToLink*(conf: ConfigRef; filename: AbsoluteFile) =
|
||||||
conf.externalToLink.insert(filename, 0)
|
conf.externalToLink.insert(filename.string, 0)
|
||||||
|
|
||||||
proc execWithEcho(conf: ConfigRef; cmd: string, msg = hintExecuting): int =
|
proc execWithEcho(conf: ConfigRef; cmd: string, msg = hintExecuting): int =
|
||||||
rawMessage(conf, msg, cmd)
|
rawMessage(conf, msg, cmd)
|
||||||
|
|
@ -459,14 +460,15 @@ proc execExternalProgram*(conf: ConfigRef; cmd: string, msg = hintExecuting) =
|
||||||
rawMessage(conf, errGenerated, "execution of an external program failed: '$1'" %
|
rawMessage(conf, errGenerated, "execution of an external program failed: '$1'" %
|
||||||
cmd)
|
cmd)
|
||||||
|
|
||||||
proc generateScript(conf: ConfigRef; projectFile: string, script: Rope) =
|
proc generateScript(conf: ConfigRef; projectFile: AbsoluteFile, script: Rope) =
|
||||||
let (dir, name, ext) = splitFile(projectFile)
|
let (_, name, _) = splitFile(projectFile)
|
||||||
let filename = getNimcacheDir(conf) / addFileExt("compile_" & name,
|
let filename = getNimcacheDir(conf) / RelativeFile(addFileExt("compile_" & name,
|
||||||
platform.OS[conf.target.targetOS].scriptExt)
|
platform.OS[conf.target.targetOS].scriptExt))
|
||||||
if writeRope(script, filename):
|
if writeRope(script, filename):
|
||||||
copyFile(conf.libpath / "nimbase.h", getNimcacheDir(conf) / "nimbase.h")
|
copyFile(conf.libpath / RelativeFile"nimbase.h",
|
||||||
|
getNimcacheDir(conf) / RelativeFile"nimbase.h")
|
||||||
else:
|
else:
|
||||||
rawMessage(conf, errGenerated, "could not write to file: " & filename)
|
rawMessage(conf, errGenerated, "could not write to file: " & filename.string)
|
||||||
|
|
||||||
proc getOptSpeed(conf: ConfigRef; c: TSystemCC): string =
|
proc getOptSpeed(conf: ConfigRef; c: TSystemCC): string =
|
||||||
result = getConfigVar(conf, c, ".options.speed")
|
result = getConfigVar(conf, c, ".options.speed")
|
||||||
|
|
@ -490,7 +492,7 @@ proc noAbsolutePaths(conf: ConfigRef): bool {.inline.} =
|
||||||
# `optGenMapping` is included here for niminst.
|
# `optGenMapping` is included here for niminst.
|
||||||
result = conf.globalOptions * {optGenScript, optGenMapping} != {}
|
result = conf.globalOptions * {optGenScript, optGenMapping} != {}
|
||||||
|
|
||||||
proc cFileSpecificOptions(conf: ConfigRef; cfilename: string): string =
|
proc cFileSpecificOptions(conf: ConfigRef; cfilename: AbsoluteFile): string =
|
||||||
result = conf.compileOptions
|
result = conf.compileOptions
|
||||||
for option in conf.compileOptionsCmd:
|
for option in conf.compileOptionsCmd:
|
||||||
if strutils.find(result, option, 0) < 0:
|
if strutils.find(result, option, 0) < 0:
|
||||||
|
|
@ -513,7 +515,7 @@ proc cFileSpecificOptions(conf: ConfigRef; cfilename: string): string =
|
||||||
if existsConfigVar(conf, key): addOpt(result, getConfigVar(conf, key))
|
if existsConfigVar(conf, key): addOpt(result, getConfigVar(conf, key))
|
||||||
|
|
||||||
proc getCompileOptions(conf: ConfigRef): string =
|
proc getCompileOptions(conf: ConfigRef): string =
|
||||||
result = cFileSpecificOptions(conf, "__dummy__")
|
result = cFileSpecificOptions(conf, AbsoluteFile"__dummy__")
|
||||||
|
|
||||||
proc getLinkOptions(conf: ConfigRef): string =
|
proc getLinkOptions(conf: ConfigRef): string =
|
||||||
result = conf.linkOptions & " " & conf.linkOptionsCmd & " "
|
result = conf.linkOptions & " " & conf.linkOptionsCmd & " "
|
||||||
|
|
@ -526,8 +528,8 @@ proc needsExeExt(conf: ConfigRef): bool {.inline.} =
|
||||||
result = (optGenScript in conf.globalOptions and conf.target.targetOS == osWindows) or
|
result = (optGenScript in conf.globalOptions and conf.target.targetOS == osWindows) or
|
||||||
(conf.target.hostOS == osWindows)
|
(conf.target.hostOS == osWindows)
|
||||||
|
|
||||||
proc getCompilerExe(conf: ConfigRef; compiler: TSystemCC; cfile: string): string =
|
proc getCompilerExe(conf: ConfigRef; compiler: TSystemCC; cfile: AbsoluteFile): string =
|
||||||
result = if conf.cmd == cmdCompileToCpp and not cfile.endsWith(".c"):
|
result = if conf.cmd == cmdCompileToCpp and not cfile.string.endsWith(".c"):
|
||||||
CC[compiler].cppCompiler
|
CC[compiler].cppCompiler
|
||||||
else:
|
else:
|
||||||
CC[compiler].compilerExe
|
CC[compiler].compilerExe
|
||||||
|
|
@ -539,7 +541,7 @@ proc getCompilerExe(conf: ConfigRef; compiler: TSystemCC; cfile: string): string
|
||||||
proc getLinkerExe(conf: ConfigRef; compiler: TSystemCC): string =
|
proc getLinkerExe(conf: ConfigRef; compiler: TSystemCC): string =
|
||||||
result = if CC[compiler].linkerExe.len > 0: CC[compiler].linkerExe
|
result = if CC[compiler].linkerExe.len > 0: CC[compiler].linkerExe
|
||||||
elif optMixedMode in conf.globalOptions and conf.cmd != cmdCompileToCpp: CC[compiler].cppCompiler
|
elif optMixedMode in conf.globalOptions and conf.cmd != cmdCompileToCpp: CC[compiler].cppCompiler
|
||||||
else: getCompilerExe(conf, compiler, "")
|
else: getCompilerExe(conf, compiler, AbsoluteFile"")
|
||||||
|
|
||||||
proc getCompileCFileCmd*(conf: ConfigRef; cfile: Cfile): string =
|
proc getCompileCFileCmd*(conf: ConfigRef; cfile: Cfile): string =
|
||||||
var c = conf.cCompiler
|
var c = conf.cCompiler
|
||||||
|
|
@ -565,43 +567,42 @@ proc getCompileCFileCmd*(conf: ConfigRef; cfile: Cfile): string =
|
||||||
includeCmd = ""
|
includeCmd = ""
|
||||||
compilePattern = getCompilerExe(conf, c, cfile.cname)
|
compilePattern = getCompilerExe(conf, c, cfile.cname)
|
||||||
|
|
||||||
var cf = if noAbsolutePaths(conf): extractFilename(cfile.cname)
|
var cf = if noAbsolutePaths(conf): AbsoluteFile extractFilename(cfile.cname.string)
|
||||||
else: cfile.cname
|
else: cfile.cname
|
||||||
|
|
||||||
var objfile =
|
var objfile =
|
||||||
if cfile.obj.len == 0:
|
if cfile.obj.isEmpty:
|
||||||
if not cfile.flags.contains(CfileFlag.External) or noAbsolutePaths(conf):
|
if not cfile.flags.contains(CfileFlag.External) or noAbsolutePaths(conf):
|
||||||
toObjFile(conf, cf)
|
toObjFile(conf, cf).string
|
||||||
else:
|
else:
|
||||||
completeCFilePath(conf, toObjFile(conf, cf))
|
completeCFilePath(conf, toObjFile(conf, cf)).string
|
||||||
elif noAbsolutePaths(conf):
|
elif noAbsolutePaths(conf):
|
||||||
extractFilename(cfile.obj)
|
extractFilename(cfile.obj.string)
|
||||||
else:
|
else:
|
||||||
cfile.obj
|
cfile.obj.string
|
||||||
|
|
||||||
# D files are required by nintendo switch libs for
|
# D files are required by nintendo switch libs for
|
||||||
# compilation. They are basically a list of all includes.
|
# compilation. They are basically a list of all includes.
|
||||||
let dfile = objfile.changeFileExt(".d").quoteShell()
|
let dfile = objfile.changeFileExt(".d").quoteShell()
|
||||||
|
|
||||||
objfile = quoteShell(objfile)
|
objfile = quoteShell(objfile)
|
||||||
cf = quoteShell(cf)
|
let cfsh = quoteShell(cf)
|
||||||
result = quoteShell(compilePattern % [
|
result = quoteShell(compilePattern % [
|
||||||
"dfile", dfile,
|
"dfile", dfile,
|
||||||
"file", cf, "objfile", objfile, "options", options,
|
"file", cfsh, "objfile", objfile, "options", options,
|
||||||
"include", includeCmd, "nim", getPrefixDir(conf),
|
"include", includeCmd, "nim", getPrefixDir(conf).string,
|
||||||
"nim", getPrefixDir(conf), "lib", conf.libpath])
|
"lib", conf.libpath.string])
|
||||||
add(result, ' ')
|
add(result, ' ')
|
||||||
addf(result, CC[c].compileTmpl, [
|
addf(result, CC[c].compileTmpl, [
|
||||||
"dfile", dfile,
|
"dfile", dfile,
|
||||||
"file", cf, "objfile", objfile,
|
"file", cfsh, "objfile", objfile,
|
||||||
"options", options, "include", includeCmd,
|
"options", options, "include", includeCmd,
|
||||||
"nim", quoteShell(getPrefixDir(conf)),
|
"nim", quoteShell(getPrefixDir(conf)),
|
||||||
"nim", quoteShell(getPrefixDir(conf)),
|
|
||||||
"lib", quoteShell(conf.libpath)])
|
"lib", quoteShell(conf.libpath)])
|
||||||
|
|
||||||
proc footprint(conf: ConfigRef; cfile: Cfile): SecureHash =
|
proc footprint(conf: ConfigRef; cfile: Cfile): SecureHash =
|
||||||
result = secureHash(
|
result = secureHash(
|
||||||
$secureHashFile(cfile.cname) &
|
$secureHashFile(cfile.cname.string) &
|
||||||
platform.OS[conf.target.targetOS].name &
|
platform.OS[conf.target.targetOS].name &
|
||||||
platform.CPU[conf.target.targetCPU].name &
|
platform.CPU[conf.target.targetCPU].name &
|
||||||
extccomp.CC[conf.cCompiler].name &
|
extccomp.CC[conf.cCompiler].name &
|
||||||
|
|
@ -614,14 +615,14 @@ proc externalFileChanged(conf: ConfigRef; cfile: Cfile): bool =
|
||||||
var hashFile = toGeneratedFile(conf, conf.withPackageName(cfile.cname), "sha1")
|
var hashFile = toGeneratedFile(conf, conf.withPackageName(cfile.cname), "sha1")
|
||||||
var currentHash = footprint(conf, cfile)
|
var currentHash = footprint(conf, cfile)
|
||||||
var f: File
|
var f: File
|
||||||
if open(f, hashFile, fmRead):
|
if open(f, hashFile.string, fmRead):
|
||||||
let oldHash = parseSecureHash(f.readLine())
|
let oldHash = parseSecureHash(f.readLine())
|
||||||
close(f)
|
close(f)
|
||||||
result = oldHash != currentHash
|
result = oldHash != currentHash
|
||||||
else:
|
else:
|
||||||
result = true
|
result = true
|
||||||
if result:
|
if result:
|
||||||
if open(f, hashFile, fmWrite):
|
if open(f, hashFile.string, fmWrite):
|
||||||
f.writeLine($currentHash)
|
f.writeLine($currentHash)
|
||||||
close(f)
|
close(f)
|
||||||
|
|
||||||
|
|
@ -630,7 +631,7 @@ proc addExternalFileToCompile*(conf: ConfigRef; c: var Cfile) =
|
||||||
c.flags.incl CfileFlag.Cached
|
c.flags.incl CfileFlag.Cached
|
||||||
conf.toCompile.add(c)
|
conf.toCompile.add(c)
|
||||||
|
|
||||||
proc addExternalFileToCompile*(conf: ConfigRef; filename: string) =
|
proc addExternalFileToCompile*(conf: ConfigRef; filename: AbsoluteFile) =
|
||||||
var c = Cfile(cname: filename,
|
var c = Cfile(cname: filename,
|
||||||
obj: toObjFile(conf, completeCFilePath(conf, filename, false)),
|
obj: toObjFile(conf, completeCFilePath(conf, filename, false)),
|
||||||
flags: {CfileFlag.External})
|
flags: {CfileFlag.External})
|
||||||
|
|
@ -650,11 +651,11 @@ proc compileCFile(conf: ConfigRef; list: CFileList, script: var Rope, cmds: var
|
||||||
add(script, compileCmd)
|
add(script, compileCmd)
|
||||||
add(script, "\n")
|
add(script, "\n")
|
||||||
|
|
||||||
proc getLinkCmd(conf: ConfigRef; projectfile, objfiles: string): string =
|
proc getLinkCmd(conf: ConfigRef; projectfile: AbsoluteFile, objfiles: string): string =
|
||||||
if optGenStaticLib in conf.globalOptions:
|
if optGenStaticLib in conf.globalOptions:
|
||||||
var libname: string
|
var libname: string
|
||||||
if conf.outFile.len > 0:
|
if not conf.outFile.isEmpty:
|
||||||
libname = conf.outFile.expandTilde
|
libname = conf.outFile.string.expandTilde
|
||||||
if not libname.isAbsolute():
|
if not libname.isAbsolute():
|
||||||
libname = getCurrentDir() / libname
|
libname = getCurrentDir() / libname
|
||||||
else:
|
else:
|
||||||
|
|
@ -679,13 +680,13 @@ proc getLinkCmd(conf: ConfigRef; projectfile, objfiles: string): string =
|
||||||
else:
|
else:
|
||||||
exefile = splitFile(projectfile).name & platform.OS[conf.target.targetOS].exeExt
|
exefile = splitFile(projectfile).name & platform.OS[conf.target.targetOS].exeExt
|
||||||
builddll = ""
|
builddll = ""
|
||||||
if conf.outFile.len > 0:
|
if not conf.outFile.isEmpty:
|
||||||
exefile = conf.outFile.expandTilde
|
exefile = conf.outFile.string.expandTilde
|
||||||
if not exefile.isAbsolute():
|
if not exefile.isAbsolute():
|
||||||
exefile = getCurrentDir() / exefile
|
exefile = getCurrentDir() / exefile
|
||||||
if not noAbsolutePaths(conf):
|
if not noAbsolutePaths(conf):
|
||||||
if not exefile.isAbsolute():
|
if not exefile.isAbsolute():
|
||||||
exefile = joinPath(splitFile(projectfile).dir, exefile)
|
exefile = string(splitFile(projectfile).dir / RelativeFile(exefile))
|
||||||
when false:
|
when false:
|
||||||
if optCDebug in conf.globalOptions:
|
if optCDebug in conf.globalOptions:
|
||||||
writeDebugInfo(exefile.changeFileExt("ndb"))
|
writeDebugInfo(exefile.changeFileExt("ndb"))
|
||||||
|
|
@ -693,7 +694,7 @@ proc getLinkCmd(conf: ConfigRef; projectfile, objfiles: string): string =
|
||||||
|
|
||||||
# Map files are required by Nintendo Switch compilation. They are a list
|
# Map files are required by Nintendo Switch compilation. They are a list
|
||||||
# of all function calls in the library and where they come from.
|
# of all function calls in the library and where they come from.
|
||||||
let mapfile = quoteShell(getNimcacheDir(conf) / splitFile(projectFile).name & ".map")
|
let mapfile = quoteShell(getNimcacheDir(conf) / RelativeFile(splitFile(projectFile).name & ".map"))
|
||||||
|
|
||||||
let linkOptions = getLinkOptions(conf) & " " &
|
let linkOptions = getLinkOptions(conf) & " " &
|
||||||
getConfigVar(conf, conf.cCompiler, ".options.linker")
|
getConfigVar(conf, conf.cCompiler, ".options.linker")
|
||||||
|
|
@ -703,7 +704,7 @@ proc getLinkCmd(conf: ConfigRef; projectfile, objfiles: string): string =
|
||||||
result = quoteShell(result % ["builddll", builddll,
|
result = quoteShell(result % ["builddll", builddll,
|
||||||
"mapfile", mapfile,
|
"mapfile", mapfile,
|
||||||
"buildgui", buildgui, "options", linkOptions, "objfiles", objfiles,
|
"buildgui", buildgui, "options", linkOptions, "objfiles", objfiles,
|
||||||
"exefile", exefile, "nim", getPrefixDir(conf), "lib", conf.libpath])
|
"exefile", exefile, "nim", getPrefixDir(conf).string, "lib", conf.libpath.string])
|
||||||
result.add ' '
|
result.add ' '
|
||||||
addf(result, linkTmpl, ["builddll", builddll,
|
addf(result, linkTmpl, ["builddll", builddll,
|
||||||
"mapfile", mapfile,
|
"mapfile", mapfile,
|
||||||
|
|
@ -761,7 +762,7 @@ proc execCmdsInParallel(conf: ConfigRef; cmds: seq[string]; prettyCb: proc (idx:
|
||||||
rawMessage(conf, errGenerated, "execution of an external program failed: '$1'" %
|
rawMessage(conf, errGenerated, "execution of an external program failed: '$1'" %
|
||||||
cmds.join())
|
cmds.join())
|
||||||
|
|
||||||
proc callCCompiler*(conf: ConfigRef; projectfile: string) =
|
proc callCCompiler*(conf: ConfigRef; projectfile: AbsoluteFile) =
|
||||||
var
|
var
|
||||||
linkCmd: string
|
linkCmd: string
|
||||||
if conf.globalOptions * {optCompileOnly, optGenScript} == {optCompileOnly}:
|
if conf.globalOptions * {optCompileOnly, optGenScript} == {optCompileOnly}:
|
||||||
|
|
@ -787,7 +788,7 @@ proc callCCompiler*(conf: ConfigRef; projectfile: string) =
|
||||||
add(objfiles, quoteShell(
|
add(objfiles, quoteShell(
|
||||||
addFileExt(objFile, CC[conf.cCompiler].objExt)))
|
addFileExt(objFile, CC[conf.cCompiler].objExt)))
|
||||||
for x in conf.toCompile:
|
for x in conf.toCompile:
|
||||||
let objFile = if noAbsolutePaths(conf): x.obj.extractFilename else: x.obj
|
let objFile = if noAbsolutePaths(conf): x.obj.extractFilename else: x.obj.string
|
||||||
add(objfiles, ' ')
|
add(objfiles, ' ')
|
||||||
add(objfiles, quoteShell(objFile))
|
add(objfiles, quoteShell(objFile))
|
||||||
|
|
||||||
|
|
@ -804,7 +805,7 @@ proc callCCompiler*(conf: ConfigRef; projectfile: string) =
|
||||||
#from json import escapeJson
|
#from json import escapeJson
|
||||||
import json
|
import json
|
||||||
|
|
||||||
proc writeJsonBuildInstructions*(conf: ConfigRef; projectfile: string) =
|
proc writeJsonBuildInstructions*(conf: ConfigRef; projectfile: AbsoluteFile) =
|
||||||
template lit(x: untyped) = f.write x
|
template lit(x: untyped) = f.write x
|
||||||
template str(x: untyped) =
|
template str(x: untyped) =
|
||||||
when compiles(escapeJson(x, buf)):
|
when compiles(escapeJson(x, buf)):
|
||||||
|
|
@ -821,7 +822,7 @@ proc writeJsonBuildInstructions*(conf: ConfigRef; projectfile: string) =
|
||||||
let compileCmd = getCompileCFileCmd(conf, it)
|
let compileCmd = getCompileCFileCmd(conf, it)
|
||||||
if pastStart: lit "],\L"
|
if pastStart: lit "],\L"
|
||||||
lit "["
|
lit "["
|
||||||
str it.cname
|
str it.cname.string
|
||||||
lit ", "
|
lit ", "
|
||||||
str compileCmd
|
str compileCmd
|
||||||
pastStart = true
|
pastStart = true
|
||||||
|
|
@ -851,11 +852,10 @@ proc writeJsonBuildInstructions*(conf: ConfigRef; projectfile: string) =
|
||||||
|
|
||||||
var buf = newStringOfCap(50)
|
var buf = newStringOfCap(50)
|
||||||
|
|
||||||
let file = projectfile.splitFile.name
|
let jsonFile = toGeneratedFile(conf, projectfile, "json")
|
||||||
let jsonFile = toGeneratedFile(conf, file, "json")
|
|
||||||
|
|
||||||
var f: File
|
var f: File
|
||||||
if open(f, jsonFile, fmWrite):
|
if open(f, jsonFile.string, fmWrite):
|
||||||
lit "{\"compile\":[\L"
|
lit "{\"compile\":[\L"
|
||||||
cfiles(conf, f, buf, conf.toCompile, false)
|
cfiles(conf, f, buf, conf.toCompile, false)
|
||||||
lit "],\L\"link\":[\L"
|
lit "],\L\"link\":[\L"
|
||||||
|
|
@ -868,11 +868,10 @@ proc writeJsonBuildInstructions*(conf: ConfigRef; projectfile: string) =
|
||||||
lit "\L}\L"
|
lit "\L}\L"
|
||||||
close(f)
|
close(f)
|
||||||
|
|
||||||
proc runJsonBuildInstructions*(conf: ConfigRef; projectfile: string) =
|
proc runJsonBuildInstructions*(conf: ConfigRef; projectfile: AbsoluteFile) =
|
||||||
let file = projectfile.splitFile.name
|
let jsonFile = toGeneratedFile(conf, projectfile, "json")
|
||||||
let jsonFile = toGeneratedFile(conf, file, "json")
|
|
||||||
try:
|
try:
|
||||||
let data = json.parseFile(jsonFile)
|
let data = json.parseFile(jsonFile.string)
|
||||||
let toCompile = data["compile"]
|
let toCompile = data["compile"]
|
||||||
doAssert toCompile.kind == JArray
|
doAssert toCompile.kind == JArray
|
||||||
var cmds: TStringSeq = @[]
|
var cmds: TStringSeq = @[]
|
||||||
|
|
@ -896,11 +895,11 @@ proc runJsonBuildInstructions*(conf: ConfigRef; projectfile: string) =
|
||||||
except:
|
except:
|
||||||
when declared(echo):
|
when declared(echo):
|
||||||
echo getCurrentException().getStackTrace()
|
echo getCurrentException().getStackTrace()
|
||||||
quit "error evaluating JSON file: " & jsonFile
|
quit "error evaluating JSON file: " & jsonFile.string
|
||||||
|
|
||||||
proc genMappingFiles(conf: ConfigRef; list: CFileList): Rope =
|
proc genMappingFiles(conf: ConfigRef; list: CFileList): Rope =
|
||||||
for it in list:
|
for it in list:
|
||||||
addf(result, "--file:r\"$1\"$N", [rope(it.cname)])
|
addf(result, "--file:r\"$1\"$N", [rope(it.cname.string)])
|
||||||
|
|
||||||
proc writeMapping*(conf: ConfigRef; symbolMapping: Rope) =
|
proc writeMapping*(conf: ConfigRef; symbolMapping: Rope) =
|
||||||
if optGenMapping notin conf.globalOptions: return
|
if optGenMapping notin conf.globalOptions: return
|
||||||
|
|
@ -914,9 +913,9 @@ proc writeMapping*(conf: ConfigRef; symbolMapping: Rope) =
|
||||||
getConfigVar(conf, conf.cCompiler, ".options.linker")))
|
getConfigVar(conf, conf.cCompiler, ".options.linker")))
|
||||||
|
|
||||||
add(code, "\n[Environment]\nlibpath=")
|
add(code, "\n[Environment]\nlibpath=")
|
||||||
add(code, strutils.escape(conf.libpath))
|
add(code, strutils.escape(conf.libpath.string))
|
||||||
|
|
||||||
addf(code, "\n[Symbols]$n$1", [symbolMapping])
|
addf(code, "\n[Symbols]$n$1", [symbolMapping])
|
||||||
let filename = joinPath(conf.projectPath, "mapping.txt")
|
let filename = conf.projectPath / RelativeFile"mapping.txt"
|
||||||
if not writeRope(code, filename):
|
if not writeRope(code, filename):
|
||||||
rawMessage(conf, errGenerated, "could not write to file: " & filename)
|
rawMessage(conf, errGenerated, "could not write to file: " & filename.string)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
import
|
import
|
||||||
llstream, os, wordrecg, idents, strutils, ast, astalgo, msgs, options,
|
llstream, os, wordrecg, idents, strutils, ast, astalgo, msgs, options,
|
||||||
renderer, filters, lineinfos
|
renderer, filters, lineinfos, pathutils
|
||||||
|
|
||||||
type
|
type
|
||||||
TParseState = enum
|
TParseState = enum
|
||||||
|
|
@ -199,7 +199,8 @@ proc parseLine(p: var TTmplParser) =
|
||||||
inc(j)
|
inc(j)
|
||||||
llStreamWrite(p.outp, "\\n\"")
|
llStreamWrite(p.outp, "\\n\"")
|
||||||
|
|
||||||
proc filterTmpl*(stdin: PLLStream, filename: string, call: PNode; conf: ConfigRef): PLLStream =
|
proc filterTmpl*(stdin: PLLStream, filename: AbsoluteFile,
|
||||||
|
call: PNode; conf: ConfigRef): PLLStream =
|
||||||
var p: TTmplParser
|
var p: TTmplParser
|
||||||
p.config = conf
|
p.config = conf
|
||||||
p.info = newLineInfo(conf, filename, 0, 0)
|
p.info = newLineInfo(conf, filename, 0, 0)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
import
|
import
|
||||||
llstream, os, wordrecg, idents, strutils, ast, astalgo, msgs, options,
|
llstream, os, wordrecg, idents, strutils, ast, astalgo, msgs, options,
|
||||||
renderer
|
renderer, pathutils
|
||||||
|
|
||||||
proc invalidPragma(conf: ConfigRef; n: PNode) =
|
proc invalidPragma(conf: ConfigRef; n: PNode) =
|
||||||
localError(conf, n.info,
|
localError(conf, n.info,
|
||||||
|
|
@ -47,7 +47,7 @@ proc boolArg*(conf: ConfigRef; n: PNode, name: string, pos: int, default: bool):
|
||||||
elif x.kind == nkIdent and cmpIgnoreStyle(x.ident.s, "false") == 0: result = false
|
elif x.kind == nkIdent and cmpIgnoreStyle(x.ident.s, "false") == 0: result = false
|
||||||
else: invalidPragma(conf, n)
|
else: invalidPragma(conf, n)
|
||||||
|
|
||||||
proc filterStrip*(conf: ConfigRef; stdin: PLLStream, filename: string, call: PNode): PLLStream =
|
proc filterStrip*(conf: ConfigRef; stdin: PLLStream, filename: AbsoluteFile, call: PNode): PLLStream =
|
||||||
var pattern = strArg(conf, call, "startswith", 1, "")
|
var pattern = strArg(conf, call, "startswith", 1, "")
|
||||||
var leading = boolArg(conf, call, "leading", 2, true)
|
var leading = boolArg(conf, call, "leading", 2, true)
|
||||||
var trailing = boolArg(conf, call, "trailing", 3, true)
|
var trailing = boolArg(conf, call, "trailing", 3, true)
|
||||||
|
|
@ -61,7 +61,7 @@ proc filterStrip*(conf: ConfigRef; stdin: PLLStream, filename: string, call: PNo
|
||||||
llStreamWriteln(result, line)
|
llStreamWriteln(result, line)
|
||||||
llStreamClose(stdin)
|
llStreamClose(stdin)
|
||||||
|
|
||||||
proc filterReplace*(conf: ConfigRef; stdin: PLLStream, filename: string, call: PNode): PLLStream =
|
proc filterReplace*(conf: ConfigRef; stdin: PLLStream, filename: AbsoluteFile, call: PNode): PLLStream =
|
||||||
var sub = strArg(conf, call, "sub", 1, "")
|
var sub = strArg(conf, call, "sub", 1, "")
|
||||||
if len(sub) == 0: invalidPragma(conf, call)
|
if len(sub) == 0: invalidPragma(conf, call)
|
||||||
var by = strArg(conf, call, "by", 2, "")
|
var by = strArg(conf, call, "by", 2, "")
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
## Module that implements ``gorge`` for the compiler.
|
## Module that implements ``gorge`` for the compiler.
|
||||||
|
|
||||||
import msgs, std / sha1, os, osproc, streams, strutils, options,
|
import msgs, std / sha1, os, osproc, streams, strutils, options,
|
||||||
lineinfos
|
lineinfos, pathutils
|
||||||
|
|
||||||
proc readOutput(p: Process): (string, int) =
|
proc readOutput(p: Process): (string, int) =
|
||||||
result[0] = ""
|
result[0] = ""
|
||||||
|
|
@ -26,7 +26,7 @@ proc opGorge*(cmd, input, cache: string, info: TLineInfo; conf: ConfigRef): (str
|
||||||
let workingDir = parentDir(toFullPath(conf, info))
|
let workingDir = parentDir(toFullPath(conf, info))
|
||||||
if cache.len > 0:# and optForceFullMake notin gGlobalOptions:
|
if cache.len > 0:# and optForceFullMake notin gGlobalOptions:
|
||||||
let h = secureHash(cmd & "\t" & input & "\t" & cache)
|
let h = secureHash(cmd & "\t" & input & "\t" & cache)
|
||||||
let filename = options.toGeneratedFile(conf, "gorge_" & $h, "txt")
|
let filename = toGeneratedFile(conf, AbsoluteFile("gorge_" & $h), "txt").string
|
||||||
var f: File
|
var f: File
|
||||||
if open(f, filename):
|
if open(f, filename):
|
||||||
result = (f.readAll, 0)
|
result = (f.readAll, 0)
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
## This module contains a simple persistent id generator.
|
## This module contains a simple persistent id generator.
|
||||||
|
|
||||||
import idents, strutils, os, options
|
import idents, strutils, os, options, pathutils
|
||||||
|
|
||||||
var gFrontEndId*: int
|
var gFrontEndId*: int
|
||||||
|
|
||||||
|
|
@ -36,18 +36,18 @@ proc setId*(id: int) {.inline.} =
|
||||||
proc idSynchronizationPoint*(idRange: int) =
|
proc idSynchronizationPoint*(idRange: int) =
|
||||||
gFrontEndId = (gFrontEndId div idRange + 1) * idRange + 1
|
gFrontEndId = (gFrontEndId div idRange + 1) * idRange + 1
|
||||||
|
|
||||||
proc toGid(conf: ConfigRef; f: string): string =
|
proc toGid(conf: ConfigRef; f: AbsoluteFile): string =
|
||||||
# we used to use ``f.addFileExt("gid")`` (aka ``$project.gid``), but this
|
# we used to use ``f.addFileExt("gid")`` (aka ``$project.gid``), but this
|
||||||
# will cause strange bugs if multiple projects are in the same folder, so
|
# will cause strange bugs if multiple projects are in the same folder, so
|
||||||
# we simply use a project independent name:
|
# we simply use a project independent name:
|
||||||
result = options.completeGeneratedFilePath(conf, "nim.gid")
|
result = options.completeGeneratedFilePath(conf, AbsoluteFile"nim.gid").string
|
||||||
|
|
||||||
proc saveMaxIds*(conf: ConfigRef; project: string) =
|
proc saveMaxIds*(conf: ConfigRef; project: AbsoluteFile) =
|
||||||
var f = open(toGid(conf, project), fmWrite)
|
var f = open(toGid(conf, project), fmWrite)
|
||||||
f.writeLine($gFrontEndId)
|
f.writeLine($gFrontEndId)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
proc loadMaxIds*(conf: ConfigRef; project: string) =
|
proc loadMaxIds*(conf: ConfigRef; project: AbsoluteFile) =
|
||||||
var f: File
|
var f: File
|
||||||
if open(f, toGid(conf, project), fmRead):
|
if open(f, toGid(conf, project), fmRead):
|
||||||
var line = newStringOfCap(20)
|
var line = newStringOfCap(20)
|
||||||
|
|
|
||||||
|
|
@ -7,15 +7,12 @@
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
#
|
#
|
||||||
|
|
||||||
# This module implements the symbol importing mechanism.
|
## This module implements the symbol importing mechanism.
|
||||||
|
|
||||||
import
|
import
|
||||||
intsets, strutils, os, ast, astalgo, msgs, options, idents, lookups,
|
intsets, strutils, os, ast, astalgo, msgs, options, idents, lookups,
|
||||||
semdata, passes, renderer, modulepaths, sigmatch, lineinfos
|
semdata, passes, renderer, modulepaths, sigmatch, lineinfos
|
||||||
|
|
||||||
proc evalImport*(c: PContext, n: PNode): PNode
|
|
||||||
proc evalFrom*(c: PContext, n: PNode): PNode
|
|
||||||
|
|
||||||
proc readExceptSet*(c: PContext, n: PNode): IntSet =
|
proc readExceptSet*(c: PContext, n: PNode): IntSet =
|
||||||
assert n.kind in {nkImportExceptStmt, nkExportExceptStmt}
|
assert n.kind in {nkImportExceptStmt, nkExportExceptStmt}
|
||||||
result = initIntSet()
|
result = initIntSet()
|
||||||
|
|
@ -140,7 +137,7 @@ proc importModuleAs(c: PContext; n: PNode, realModule: PSym): PSym =
|
||||||
c.config.options)
|
c.config.options)
|
||||||
|
|
||||||
proc myImportModule(c: PContext, n: PNode; importStmtResult: PNode): PSym =
|
proc myImportModule(c: PContext, n: PNode; importStmtResult: PNode): PSym =
|
||||||
var f = checkModuleName(c.config, n)
|
let f = checkModuleName(c.config, n)
|
||||||
if f != InvalidFileIDX:
|
if f != InvalidFileIDX:
|
||||||
let L = c.graph.importStack.len
|
let L = c.graph.importStack.len
|
||||||
let recursion = c.graph.importStack.find(f)
|
let recursion = c.graph.importStack.find(f)
|
||||||
|
|
@ -168,7 +165,8 @@ proc myImportModule(c: PContext, n: PNode; importStmtResult: PNode): PSym =
|
||||||
else:
|
else:
|
||||||
message(c.config, n.info, warnDeprecated, result.name.s)
|
message(c.config, n.info, warnDeprecated, result.name.s)
|
||||||
suggestSym(c.config, n.info, result, c.graph.usageSym, false)
|
suggestSym(c.config, n.info, result, c.graph.usageSym, false)
|
||||||
importStmtResult.add newStrNode(toFullPath(c.config, f), n.info)
|
importStmtResult.add newSymNode(result, n.info)
|
||||||
|
#newStrNode(toFullPath(c.config, f), n.info)
|
||||||
|
|
||||||
proc transformImportAs(c: PContext; n: PNode): PNode =
|
proc transformImportAs(c: PContext; n: PNode): PNode =
|
||||||
if n.kind == nkInfix and considerQuotedIdent(c, n[0]).s == "as":
|
if n.kind == nkInfix and considerQuotedIdent(c, n[0]).s == "as":
|
||||||
|
|
@ -188,7 +186,7 @@ proc impMod(c: PContext; it: PNode; importStmtResult: PNode) =
|
||||||
importAllSymbolsExcept(c, m, emptySet)
|
importAllSymbolsExcept(c, m, emptySet)
|
||||||
#importForwarded(c, m.ast, emptySet)
|
#importForwarded(c, m.ast, emptySet)
|
||||||
|
|
||||||
proc evalImport(c: PContext, n: PNode): PNode =
|
proc evalImport*(c: PContext, n: PNode): PNode =
|
||||||
result = newNodeI(nkImportStmt, n.info)
|
result = newNodeI(nkImportStmt, n.info)
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in countup(0, sonsLen(n) - 1):
|
||||||
let it = n.sons[i]
|
let it = n.sons[i]
|
||||||
|
|
@ -212,7 +210,7 @@ proc evalImport(c: PContext, n: PNode): PNode =
|
||||||
else:
|
else:
|
||||||
impMod(c, it, result)
|
impMod(c, it, result)
|
||||||
|
|
||||||
proc evalFrom(c: PContext, n: PNode): PNode =
|
proc evalFrom*(c: PContext, n: PNode): PNode =
|
||||||
result = newNodeI(nkImportStmt, n.info)
|
result = newNodeI(nkImportStmt, n.info)
|
||||||
checkMinSonsLen(n, 2, c.config)
|
checkMinSonsLen(n, 2, c.config)
|
||||||
n.sons[0] = transformImportAs(c, n.sons[0])
|
n.sons[0] = transformImportAs(c, n.sons[0])
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ import
|
||||||
ast, astalgo, strutils, hashes, trees, platform, magicsys, extccomp, options,
|
ast, astalgo, strutils, hashes, trees, platform, magicsys, extccomp, options,
|
||||||
nversion, nimsets, msgs, std / sha1, bitsets, idents, types, os, tables,
|
nversion, nimsets, msgs, std / sha1, bitsets, idents, types, os, tables,
|
||||||
times, ropes, math, passes, ccgutils, wordrecg, renderer,
|
times, ropes, math, passes, ccgutils, wordrecg, renderer,
|
||||||
intsets, cgmeth, lowerings, sighashes, lineinfos, rodutils
|
intsets, cgmeth, lowerings, sighashes, lineinfos, rodutils, pathutils
|
||||||
|
|
||||||
from modulegraphs import ModuleGraph
|
from modulegraphs import ModuleGraph
|
||||||
|
|
||||||
|
|
@ -2263,7 +2263,7 @@ proc genClass(conf: ConfigRef; obj: PType; content: Rope; ext: string) =
|
||||||
"class $#$# {$n$#$n}$n") %
|
"class $#$# {$n$#$n}$n") %
|
||||||
[rope(VersionAsString), cls, extends, content]
|
[rope(VersionAsString), cls, extends, content]
|
||||||
|
|
||||||
let outfile = changeFileExt(completeCFilePath(conf, $cls), ext)
|
let outfile = changeFileExt(completeCFilePath(conf, AbsoluteFile($cls)), ext)
|
||||||
discard writeRopeIfNotEqual(result, outfile)
|
discard writeRopeIfNotEqual(result, outfile)
|
||||||
|
|
||||||
proc myClose(graph: ModuleGraph; b: PPassContext, n: PNode): PNode =
|
proc myClose(graph: ModuleGraph; b: PPassContext, n: PNode): PNode =
|
||||||
|
|
@ -2277,11 +2277,11 @@ proc myClose(graph: ModuleGraph; b: PPassContext, n: PNode): PNode =
|
||||||
else: "nimsystem"
|
else: "nimsystem"
|
||||||
let code = wholeCode(graph, m)
|
let code = wholeCode(graph, m)
|
||||||
let outfile =
|
let outfile =
|
||||||
if m.config.outFile.len > 0:
|
if not m.config.outFile.isEmpty:
|
||||||
if m.config.outFile.isAbsolute: m.config.outFile
|
if m.config.outFile.string.isAbsolute: m.config.outFile
|
||||||
else: getCurrentDir() / m.config.outFile
|
else: AbsoluteFile(getCurrentDir() / m.config.outFile.string)
|
||||||
else:
|
else:
|
||||||
changeFileExt(completeCFilePath(m.config, f), ext)
|
changeFileExt(completeCFilePath(m.config, AbsoluteFile f), ext)
|
||||||
discard writeRopeIfNotEqual(genHeader() & code, outfile)
|
discard writeRopeIfNotEqual(genHeader() & code, outfile)
|
||||||
for obj, content in items(globals.classes):
|
for obj, content in items(globals.classes):
|
||||||
genClass(m.config, obj, content, ext)
|
genClass(m.config, obj, content, ext)
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@
|
||||||
|
|
||||||
## Layouter for nimpretty.
|
## Layouter for nimpretty.
|
||||||
|
|
||||||
import idents, lexer, lineinfos, llstream, options, msgs, strutils
|
import idents, lexer, lineinfos, llstream, options, msgs, strutils,
|
||||||
|
pathutils
|
||||||
from os import changeFileExt
|
from os import changeFileExt
|
||||||
|
|
||||||
const
|
const
|
||||||
|
|
@ -39,7 +40,7 @@ type
|
||||||
|
|
||||||
proc openEmitter*(em: var Emitter, cache: IdentCache;
|
proc openEmitter*(em: var Emitter, cache: IdentCache;
|
||||||
config: ConfigRef, fileIdx: FileIndex) =
|
config: ConfigRef, fileIdx: FileIndex) =
|
||||||
let fullPath = config.toFullPath(fileIdx)
|
let fullPath = Absolutefile config.toFullPath(fileIdx)
|
||||||
em.indWidth = getIndentWidth(fileIdx, llStreamOpen(fullPath, fmRead),
|
em.indWidth = getIndentWidth(fileIdx, llStreamOpen(fullPath, fmRead),
|
||||||
cache, config)
|
cache, config)
|
||||||
if em.indWidth == 0: em.indWidth = 2
|
if em.indWidth == 0: em.indWidth = 2
|
||||||
|
|
@ -55,7 +56,7 @@ proc openEmitter*(em: var Emitter, cache: IdentCache;
|
||||||
proc closeEmitter*(em: var Emitter) =
|
proc closeEmitter*(em: var Emitter) =
|
||||||
var f = llStreamOpen(em.config.outFile, fmWrite)
|
var f = llStreamOpen(em.config.outFile, fmWrite)
|
||||||
if f == nil:
|
if f == nil:
|
||||||
rawMessage(em.config, errGenerated, "cannot open file: " & em.config.outFile)
|
rawMessage(em.config, errGenerated, "cannot open file: " & em.config.outFile.string)
|
||||||
f.llStreamWrite em.content
|
f.llStreamWrite em.content
|
||||||
llStreamClose(f)
|
llStreamClose(f)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
import
|
import
|
||||||
hashes, options, msgs, strutils, platform, idents, nimlexbase, llstream,
|
hashes, options, msgs, strutils, platform, idents, nimlexbase, llstream,
|
||||||
wordrecg, lineinfos
|
wordrecg, lineinfos, pathutils
|
||||||
|
|
||||||
const
|
const
|
||||||
MaxLineLength* = 80 # lines longer than this lead to a warning
|
MaxLineLength* = 80 # lines longer than this lead to a warning
|
||||||
|
|
@ -232,7 +232,7 @@ proc openLexer*(lex: var TLexer, fileIdx: FileIndex, inputstream: PLLStream;
|
||||||
lex.previousToken.fileIndex = fileIdx
|
lex.previousToken.fileIndex = fileIdx
|
||||||
lex.config = config
|
lex.config = config
|
||||||
|
|
||||||
proc openLexer*(lex: var TLexer, filename: string, inputstream: PLLStream;
|
proc openLexer*(lex: var TLexer, filename: AbsoluteFile, inputstream: PLLStream;
|
||||||
cache: IdentCache; config: ConfigRef) =
|
cache: IdentCache; config: ConfigRef) =
|
||||||
openLexer(lex, fileInfoIdx(config, filename), inputstream, cache, config)
|
openLexer(lex, fileInfoIdx(config, filename), inputstream, cache, config)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
## This module contains the ``TMsgKind`` enum as well as the
|
## This module contains the ``TMsgKind`` enum as well as the
|
||||||
## ``TLineInfo`` object.
|
## ``TLineInfo`` object.
|
||||||
|
|
||||||
import ropes, tables
|
import ropes, tables, pathutils
|
||||||
|
|
||||||
const
|
const
|
||||||
explanationsBaseUrl* = "https://nim-lang.org/docs/manual"
|
explanationsBaseUrl* = "https://nim-lang.org/docs/manual"
|
||||||
|
|
@ -179,8 +179,8 @@ const
|
||||||
|
|
||||||
type
|
type
|
||||||
TFileInfo* = object
|
TFileInfo* = object
|
||||||
fullPath*: string # This is a canonical full filesystem path
|
fullPath*: AbsoluteFile # This is a canonical full filesystem path
|
||||||
projPath*: string # This is relative to the project's root
|
projPath*: RelativeFile # This is relative to the project's root
|
||||||
shortName*: string # short name of the module
|
shortName*: string # short name of the module
|
||||||
quotedName*: Rope # cached quoted short name for codegen
|
quotedName*: Rope # cached quoted short name for codegen
|
||||||
# purposes
|
# purposes
|
||||||
|
|
@ -191,7 +191,7 @@ type
|
||||||
# used for better error messages and
|
# used for better error messages and
|
||||||
# embedding the original source in the
|
# embedding the original source in the
|
||||||
# generated code
|
# generated code
|
||||||
dirtyfile*: string # the file that is actually read into memory
|
dirtyfile*: AbsoluteFile # the file that is actually read into memory
|
||||||
# and parsed; usually "" but is used
|
# and parsed; usually "" but is used
|
||||||
# for 'nimsuggest'
|
# for 'nimsuggest'
|
||||||
hash*: string # the checksum of the file
|
hash*: string # the checksum of the file
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import
|
||||||
strutils, os, intsets, strtabs
|
strutils, os, intsets, strtabs
|
||||||
|
|
||||||
import options, ast, astalgo, msgs, semdata, ropes, idents,
|
import options, ast, astalgo, msgs, semdata, ropes, idents,
|
||||||
lineinfos
|
lineinfos, pathutils
|
||||||
|
|
||||||
const
|
const
|
||||||
Letters* = {'a'..'z', 'A'..'Z', '0'..'9', '\x80'..'\xFF', '_'}
|
Letters* = {'a'..'z', 'A'..'Z', '0'..'9', '\x80'..'\xFF', '_'}
|
||||||
|
|
@ -42,7 +42,7 @@ proc overwriteFiles*(conf: ConfigRef) =
|
||||||
let newFile = if gOverWrite: conf.m.fileInfos[i].fullpath
|
let newFile = if gOverWrite: conf.m.fileInfos[i].fullpath
|
||||||
else: conf.m.fileInfos[i].fullpath.changeFileExt(".pretty.nim")
|
else: conf.m.fileInfos[i].fullpath.changeFileExt(".pretty.nim")
|
||||||
try:
|
try:
|
||||||
var f = open(newFile, fmWrite)
|
var f = open(newFile.string, fmWrite)
|
||||||
for line in conf.m.fileInfos[i].lines:
|
for line in conf.m.fileInfos[i].lines:
|
||||||
if doStrip:
|
if doStrip:
|
||||||
f.write line.strip(leading = false, trailing = true)
|
f.write line.strip(leading = false, trailing = true)
|
||||||
|
|
@ -51,7 +51,7 @@ proc overwriteFiles*(conf: ConfigRef) =
|
||||||
f.write(conf.m.fileInfos[i], "\L")
|
f.write(conf.m.fileInfos[i], "\L")
|
||||||
f.close
|
f.close
|
||||||
except IOError:
|
except IOError:
|
||||||
rawMessage(conf, errGenerated, "cannot open file: " & newFile)
|
rawMessage(conf, errGenerated, "cannot open file: " & newFile.string)
|
||||||
|
|
||||||
proc `=~`(s: string, a: openArray[string]): bool =
|
proc `=~`(s: string, a: openArray[string]): bool =
|
||||||
for x in a:
|
for x in a:
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
## Low-level streams for high performance.
|
## Low-level streams for high performance.
|
||||||
|
|
||||||
import
|
import
|
||||||
strutils
|
strutils, pathutils
|
||||||
|
|
||||||
# support '-d:useGnuReadline' for backwards compatibility:
|
# support '-d:useGnuReadline' for backwards compatibility:
|
||||||
when not defined(windows) and (defined(useGnuReadline) or defined(useLinenoise)):
|
when not defined(windows) and (defined(useGnuReadline) or defined(useLinenoise)):
|
||||||
|
|
@ -41,10 +41,10 @@ proc llStreamOpen*(f: File): PLLStream =
|
||||||
result.f = f
|
result.f = f
|
||||||
result.kind = llsFile
|
result.kind = llsFile
|
||||||
|
|
||||||
proc llStreamOpen*(filename: string, mode: FileMode): PLLStream =
|
proc llStreamOpen*(filename: AbsoluteFile, mode: FileMode): PLLStream =
|
||||||
new(result)
|
new(result)
|
||||||
result.kind = llsFile
|
result.kind = llsFile
|
||||||
if not open(result.f, filename, mode): result = nil
|
if not open(result.f, filename.string, mode): result = nil
|
||||||
|
|
||||||
proc llStreamOpen*(): PLLStream =
|
proc llStreamOpen*(): PLLStream =
|
||||||
new(result)
|
new(result)
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import
|
||||||
cgen, jsgen, json, nversion,
|
cgen, jsgen, json, nversion,
|
||||||
platform, nimconf, importer, passaux, depends, vm, vmdef, types, idgen,
|
platform, nimconf, importer, passaux, depends, vm, vmdef, types, idgen,
|
||||||
docgen2, parser, modules, ccgutils, sigmatch, ropes,
|
docgen2, parser, modules, ccgutils, sigmatch, ropes,
|
||||||
modulegraphs, tables, rod, lineinfos
|
modulegraphs, tables, rod, lineinfos, pathutils
|
||||||
|
|
||||||
from magicsys import resetSysTypes
|
from magicsys import resetSysTypes
|
||||||
|
|
||||||
|
|
@ -30,8 +30,8 @@ proc semanticPasses(g: ModuleGraph) =
|
||||||
registerPass g, verbosePass
|
registerPass g, verbosePass
|
||||||
registerPass g, semPass
|
registerPass g, semPass
|
||||||
|
|
||||||
proc writeDepsFile(g: ModuleGraph; project: string) =
|
proc writeDepsFile(g: ModuleGraph; project: AbsoluteFile) =
|
||||||
let f = open(changeFileExt(project, "deps"), fmWrite)
|
let f = open(changeFileExt(project, "deps").string, fmWrite)
|
||||||
for m in g.modules:
|
for m in g.modules:
|
||||||
if m != nil:
|
if m != nil:
|
||||||
f.writeLine(toFullPath(g.config, m.position.FileIndex))
|
f.writeLine(toFullPath(g.config, m.position.FileIndex))
|
||||||
|
|
@ -47,8 +47,9 @@ proc commandGenDepend(graph: ModuleGraph) =
|
||||||
let project = graph.config.projectFull
|
let project = graph.config.projectFull
|
||||||
writeDepsFile(graph, project)
|
writeDepsFile(graph, project)
|
||||||
generateDot(graph, project)
|
generateDot(graph, project)
|
||||||
execExternalProgram(graph.config, "dot -Tpng -o" & changeFileExt(project, "png") &
|
execExternalProgram(graph.config, "dot -Tpng -o" &
|
||||||
' ' & changeFileExt(project, "dot"))
|
changeFileExt(project, "png").string &
|
||||||
|
' ' & changeFileExt(project, "dot").string)
|
||||||
|
|
||||||
proc commandCheck(graph: ModuleGraph) =
|
proc commandCheck(graph: ModuleGraph) =
|
||||||
graph.config.errorMax = high(int) # do not stop after first error
|
graph.config.errorMax = high(int) # do not stop after first error
|
||||||
|
|
@ -126,7 +127,7 @@ proc commandEval(graph: ModuleGraph; exp: string) =
|
||||||
makeStdinModule(graph))
|
makeStdinModule(graph))
|
||||||
|
|
||||||
proc commandScan(cache: IdentCache, config: ConfigRef) =
|
proc commandScan(cache: IdentCache, config: ConfigRef) =
|
||||||
var f = addFileExt(mainCommandArg(config), NimExt)
|
var f = addFileExt(AbsoluteFile mainCommandArg(config), NimExt)
|
||||||
var stream = llStreamOpen(f, fmRead)
|
var stream = llStreamOpen(f, fmRead)
|
||||||
if stream != nil:
|
if stream != nil:
|
||||||
var
|
var
|
||||||
|
|
@ -140,7 +141,7 @@ proc commandScan(cache: IdentCache, config: ConfigRef) =
|
||||||
if tok.tokType == tkEof: break
|
if tok.tokType == tkEof: break
|
||||||
closeLexer(L)
|
closeLexer(L)
|
||||||
else:
|
else:
|
||||||
rawMessage(config, errGenerated, "cannot open file: " & f)
|
rawMessage(config, errGenerated, "cannot open file: " & f.string)
|
||||||
|
|
||||||
const
|
const
|
||||||
PrintRopeCacheStats = false
|
PrintRopeCacheStats = false
|
||||||
|
|
@ -231,11 +232,11 @@ proc mainCommand*(graph: ModuleGraph) =
|
||||||
for s in definedSymbolNames(conf.symbols): definedSymbols.elems.add(%s)
|
for s in definedSymbolNames(conf.symbols): definedSymbols.elems.add(%s)
|
||||||
|
|
||||||
var libpaths = newJArray()
|
var libpaths = newJArray()
|
||||||
for dir in conf.searchPaths: libpaths.elems.add(%dir)
|
for dir in conf.searchPaths: libpaths.elems.add(%dir.string)
|
||||||
|
|
||||||
var dumpdata = % [
|
var dumpdata = % [
|
||||||
(key: "version", val: %VersionAsString),
|
(key: "version", val: %VersionAsString),
|
||||||
(key: "project_path", val: %conf.projectFull),
|
(key: "project_path", val: %conf.projectFull.string),
|
||||||
(key: "defined_symbols", val: definedSymbols),
|
(key: "defined_symbols", val: definedSymbols),
|
||||||
(key: "lib_paths", val: libpaths)
|
(key: "lib_paths", val: libpaths)
|
||||||
]
|
]
|
||||||
|
|
@ -247,7 +248,7 @@ proc mainCommand*(graph: ModuleGraph) =
|
||||||
for s in definedSymbolNames(conf.symbols): msgWriteln(conf, s, {msgStdout, msgSkipHook})
|
for s in definedSymbolNames(conf.symbols): msgWriteln(conf, s, {msgStdout, msgSkipHook})
|
||||||
msgWriteln(conf, "-- end of list --", {msgStdout, msgSkipHook})
|
msgWriteln(conf, "-- end of list --", {msgStdout, msgSkipHook})
|
||||||
|
|
||||||
for it in conf.searchPaths: msgWriteln(conf, it)
|
for it in conf.searchPaths: msgWriteln(conf, it.string)
|
||||||
of "check":
|
of "check":
|
||||||
conf.cmd = cmdCheck
|
conf.cmd = cmdCheck
|
||||||
commandCheck(graph)
|
commandCheck(graph)
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,8 @@
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
#
|
#
|
||||||
|
|
||||||
import ast, renderer, strutils, msgs, options, idents, os, lineinfos
|
import ast, renderer, strutils, msgs, options, idents, os, lineinfos,
|
||||||
|
pathutils, nimblecmd
|
||||||
import nimblecmd
|
|
||||||
|
|
||||||
when false:
|
when false:
|
||||||
const
|
const
|
||||||
|
|
@ -160,7 +159,7 @@ proc checkModuleName*(conf: ConfigRef; n: PNode; doLocalError=true): FileIndex =
|
||||||
# This returns the full canonical path for a given module import
|
# This returns the full canonical path for a given module import
|
||||||
let modulename = getModuleName(conf, n)
|
let modulename = getModuleName(conf, n)
|
||||||
let fullPath = findModule(conf, modulename, toFullPath(conf, n.info))
|
let fullPath = findModule(conf, modulename, toFullPath(conf, n.info))
|
||||||
if fullPath.len == 0:
|
if fullPath.isEmpty:
|
||||||
if doLocalError:
|
if doLocalError:
|
||||||
let m = if modulename.len > 0: modulename else: $n
|
let m = if modulename.len > 0: modulename else: $n
|
||||||
localError(conf, n.info, "cannot open file: " & m)
|
localError(conf, n.info, "cannot open file: " & m)
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
import
|
import
|
||||||
ast, astalgo, magicsys, std / sha1, msgs, cgendata, sigmatch, options,
|
ast, astalgo, magicsys, std / sha1, msgs, cgendata, sigmatch, options,
|
||||||
idents, os, lexer, idgen, passes, syntaxes, llstream, modulegraphs, rod,
|
idents, os, lexer, idgen, passes, syntaxes, llstream, modulegraphs, rod,
|
||||||
lineinfos
|
lineinfos, pathutils
|
||||||
|
|
||||||
proc resetSystemArtifacts*(g: ModuleGraph) =
|
proc resetSystemArtifacts*(g: ModuleGraph) =
|
||||||
magicsys.resetSysTypes(g)
|
magicsys.resetSysTypes(g)
|
||||||
|
|
@ -102,19 +102,21 @@ proc connectCallbacks*(graph: ModuleGraph) =
|
||||||
proc compileSystemModule*(graph: ModuleGraph) =
|
proc compileSystemModule*(graph: ModuleGraph) =
|
||||||
if graph.systemModule == nil:
|
if graph.systemModule == nil:
|
||||||
connectCallbacks(graph)
|
connectCallbacks(graph)
|
||||||
graph.config.m.systemFileIdx = fileInfoIdx(graph.config, graph.config.libpath / "system.nim")
|
graph.config.m.systemFileIdx = fileInfoIdx(graph.config,
|
||||||
|
graph.config.libpath / RelativeFile"system.nim")
|
||||||
discard graph.compileModule(graph.config.m.systemFileIdx, {sfSystemModule})
|
discard graph.compileModule(graph.config.m.systemFileIdx, {sfSystemModule})
|
||||||
|
|
||||||
proc wantMainModule*(conf: ConfigRef) =
|
proc wantMainModule*(conf: ConfigRef) =
|
||||||
if conf.projectFull.len == 0:
|
if conf.projectFull.isEmpty:
|
||||||
fatal(conf, newLineInfo(conf, "command line", 1, 1), errGenerated, "command expects a filename")
|
fatal(conf, newLineInfo(conf, AbsoluteFile"command line", 1, 1), errGenerated,
|
||||||
|
"command expects a filename")
|
||||||
conf.projectMainIdx = fileInfoIdx(conf, addFileExt(conf.projectFull, NimExt))
|
conf.projectMainIdx = fileInfoIdx(conf, addFileExt(conf.projectFull, NimExt))
|
||||||
|
|
||||||
proc compileProject*(graph: ModuleGraph; projectFileIdx = InvalidFileIDX) =
|
proc compileProject*(graph: ModuleGraph; projectFileIdx = InvalidFileIDX) =
|
||||||
connectCallbacks(graph)
|
connectCallbacks(graph)
|
||||||
let conf = graph.config
|
let conf = graph.config
|
||||||
wantMainModule(conf)
|
wantMainModule(conf)
|
||||||
let systemFileIdx = fileInfoIdx(conf, conf.libpath / "system.nim")
|
let systemFileIdx = fileInfoIdx(conf, conf.libpath / RelativeFile"system.nim")
|
||||||
let projectFile = if projectFileIdx == InvalidFileIDX: conf.projectMainIdx else: projectFileIdx
|
let projectFile = if projectFileIdx == InvalidFileIDX: conf.projectMainIdx else: projectFileIdx
|
||||||
graph.importStack.add projectFile
|
graph.importStack.add projectFile
|
||||||
if projectFile == systemFileIdx:
|
if projectFile == systemFileIdx:
|
||||||
|
|
@ -123,8 +125,11 @@ proc compileProject*(graph: ModuleGraph; projectFileIdx = InvalidFileIDX) =
|
||||||
graph.compileSystemModule()
|
graph.compileSystemModule()
|
||||||
discard graph.compileModule(projectFile, {sfMainModule})
|
discard graph.compileModule(projectFile, {sfMainModule})
|
||||||
|
|
||||||
proc makeModule*(graph: ModuleGraph; filename: string): PSym =
|
proc makeModule*(graph: ModuleGraph; filename: AbsoluteFile): PSym =
|
||||||
result = graph.newModule(fileInfoIdx(graph.config, filename))
|
result = graph.newModule(fileInfoIdx(graph.config, filename))
|
||||||
result.id = getID()
|
result.id = getID()
|
||||||
|
|
||||||
proc makeStdinModule*(graph: ModuleGraph): PSym = graph.makeModule"stdin"
|
proc makeModule*(graph: ModuleGraph; filename: string): PSym =
|
||||||
|
result = makeModule(graph, AbsoluteFile filename)
|
||||||
|
|
||||||
|
proc makeStdinModule*(graph: ModuleGraph): PSym = graph.makeModule(AbsoluteFile"stdin")
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
import
|
import
|
||||||
options, strutils, os, tables, ropes, platform, terminal, macros,
|
options, strutils, os, tables, ropes, platform, terminal, macros,
|
||||||
lineinfos
|
lineinfos, pathutils
|
||||||
|
|
||||||
proc toCChar*(c: char; result: var string) =
|
proc toCChar*(c: char; result: var string) =
|
||||||
case c
|
case c
|
||||||
|
|
@ -35,20 +35,20 @@ proc makeCString*(s: string): Rope =
|
||||||
add(result, rope(res))
|
add(result, rope(res))
|
||||||
|
|
||||||
|
|
||||||
proc newFileInfo(fullPath, projPath: string): TFileInfo =
|
proc newFileInfo(fullPath: AbsoluteFile, projPath: RelativeFile): TFileInfo =
|
||||||
result.fullPath = fullPath
|
result.fullPath = fullPath
|
||||||
#shallow(result.fullPath)
|
#shallow(result.fullPath)
|
||||||
result.projPath = projPath
|
result.projPath = projPath
|
||||||
#shallow(result.projPath)
|
#shallow(result.projPath)
|
||||||
let fileName = projPath.extractFilename
|
let fileName = fullPath.extractFilename
|
||||||
result.shortName = fileName.changeFileExt("")
|
result.shortName = fileName.changeFileExt("")
|
||||||
result.quotedName = fileName.makeCString
|
result.quotedName = fileName.makeCString
|
||||||
result.quotedFullName = fullPath.makeCString
|
result.quotedFullName = fullPath.string.makeCString
|
||||||
result.lines = @[]
|
result.lines = @[]
|
||||||
when defined(nimpretty):
|
when defined(nimpretty):
|
||||||
if result.fullPath.len > 0:
|
if not result.fullPath.isEmpty:
|
||||||
try:
|
try:
|
||||||
result.fullContent = readFile(result.fullPath)
|
result.fullContent = readFile(result.fullPath.string)
|
||||||
except IOError:
|
except IOError:
|
||||||
#rawMessage(errCannotOpenFile, result.fullPath)
|
#rawMessage(errCannotOpenFile, result.fullPath)
|
||||||
# XXX fixme
|
# XXX fixme
|
||||||
|
|
@ -58,39 +58,39 @@ when defined(nimpretty):
|
||||||
proc fileSection*(conf: ConfigRef; fid: FileIndex; a, b: int): string =
|
proc fileSection*(conf: ConfigRef; fid: FileIndex; a, b: int): string =
|
||||||
substr(conf.m.fileInfos[fid.int].fullContent, a, b)
|
substr(conf.m.fileInfos[fid.int].fullContent, a, b)
|
||||||
|
|
||||||
proc fileInfoKnown*(conf: ConfigRef; filename: string): bool =
|
proc fileInfoKnown*(conf: ConfigRef; filename: AbsoluteFile): bool =
|
||||||
var
|
var
|
||||||
canon: string
|
canon: AbsoluteFile
|
||||||
try:
|
try:
|
||||||
canon = canonicalizePath(conf, filename)
|
canon = canonicalizePath(conf, filename)
|
||||||
except:
|
except OSError:
|
||||||
canon = filename
|
canon = filename
|
||||||
result = conf.m.filenameToIndexTbl.hasKey(canon)
|
result = conf.m.filenameToIndexTbl.hasKey(canon.string)
|
||||||
|
|
||||||
proc fileInfoIdx*(conf: ConfigRef; filename: string; isKnownFile: var bool): FileIndex =
|
proc fileInfoIdx*(conf: ConfigRef; filename: AbsoluteFile; isKnownFile: var bool): FileIndex =
|
||||||
var
|
var
|
||||||
canon: string
|
canon: AbsoluteFile
|
||||||
pseudoPath = false
|
pseudoPath = false
|
||||||
|
|
||||||
try:
|
try:
|
||||||
canon = canonicalizePath(conf, filename)
|
canon = canonicalizePath(conf, filename)
|
||||||
shallow(canon)
|
shallow(canon.string)
|
||||||
except:
|
except OSError:
|
||||||
canon = filename
|
canon = filename
|
||||||
# The compiler uses "filenames" such as `command line` or `stdin`
|
# The compiler uses "filenames" such as `command line` or `stdin`
|
||||||
# This flag indicates that we are working with such a path here
|
# This flag indicates that we are working with such a path here
|
||||||
pseudoPath = true
|
pseudoPath = true
|
||||||
|
|
||||||
if conf.m.filenameToIndexTbl.hasKey(canon):
|
if conf.m.filenameToIndexTbl.hasKey(canon.string):
|
||||||
result = conf.m.filenameToIndexTbl[canon]
|
result = conf.m.filenameToIndexTbl[canon.string]
|
||||||
else:
|
else:
|
||||||
isKnownFile = false
|
isKnownFile = false
|
||||||
result = conf.m.fileInfos.len.FileIndex
|
result = conf.m.fileInfos.len.FileIndex
|
||||||
conf.m.fileInfos.add(newFileInfo(canon, if pseudoPath: filename
|
conf.m.fileInfos.add(newFileInfo(canon, if pseudoPath: RelativeFile filename
|
||||||
else: shortenDir(conf, canon)))
|
else: relativeTo(canon, conf.projectPath)))
|
||||||
conf.m.filenameToIndexTbl[canon] = result
|
conf.m.filenameToIndexTbl[canon.string] = result
|
||||||
|
|
||||||
proc fileInfoIdx*(conf: ConfigRef; filename: string): FileIndex =
|
proc fileInfoIdx*(conf: ConfigRef; filename: AbsoluteFile): FileIndex =
|
||||||
var dummy: bool
|
var dummy: bool
|
||||||
result = fileInfoIdx(conf, filename, dummy)
|
result = fileInfoIdx(conf, filename, dummy)
|
||||||
|
|
||||||
|
|
@ -99,7 +99,7 @@ proc newLineInfo*(fileInfoIdx: FileIndex, line, col: int): TLineInfo =
|
||||||
result.line = uint16(line)
|
result.line = uint16(line)
|
||||||
result.col = int16(col)
|
result.col = int16(col)
|
||||||
|
|
||||||
proc newLineInfo*(conf: ConfigRef; filename: string, line, col: int): TLineInfo {.inline.} =
|
proc newLineInfo*(conf: ConfigRef; filename: AbsoluteFile, line, col: int): TLineInfo {.inline.} =
|
||||||
result = newLineInfo(fileInfoIdx(conf, filename), line, col)
|
result = newLineInfo(fileInfoIdx(conf, filename), line, col)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -152,13 +152,16 @@ proc getInfoContext*(conf: ConfigRef; index: int): TLineInfo =
|
||||||
else: result = conf.m.msgContext[i]
|
else: result = conf.m.msgContext[i]
|
||||||
|
|
||||||
template toFilename*(conf: ConfigRef; fileIdx: FileIndex): string =
|
template toFilename*(conf: ConfigRef; fileIdx: FileIndex): string =
|
||||||
(if fileIdx.int32 < 0 or conf == nil: "???" else: conf.m.fileInfos[fileIdx.int32].projPath)
|
if fileIdx.int32 < 0 or conf == nil:
|
||||||
|
"???"
|
||||||
|
else:
|
||||||
|
conf.m.fileInfos[fileIdx.int32].projPath.string
|
||||||
|
|
||||||
proc toFullPath*(conf: ConfigRef; fileIdx: FileIndex): string =
|
proc toFullPath*(conf: ConfigRef; fileIdx: FileIndex): string =
|
||||||
if fileIdx.int32 < 0 or conf == nil: result = "???"
|
if fileIdx.int32 < 0 or conf == nil: result = "???"
|
||||||
else: result = conf.m.fileInfos[fileIdx.int32].fullPath
|
else: result = conf.m.fileInfos[fileIdx.int32].fullPath.string
|
||||||
|
|
||||||
proc setDirtyFile*(conf: ConfigRef; fileIdx: FileIndex; filename: string) =
|
proc setDirtyFile*(conf: ConfigRef; fileIdx: FileIndex; filename: AbsoluteFile) =
|
||||||
assert fileIdx.int32 >= 0
|
assert fileIdx.int32 >= 0
|
||||||
conf.m.fileInfos[fileIdx.int32].dirtyFile = filename
|
conf.m.fileInfos[fileIdx.int32].dirtyFile = filename
|
||||||
|
|
||||||
|
|
@ -170,10 +173,10 @@ proc getHash*(conf: ConfigRef; fileIdx: FileIndex): string =
|
||||||
assert fileIdx.int32 >= 0
|
assert fileIdx.int32 >= 0
|
||||||
shallowCopy(result, conf.m.fileInfos[fileIdx.int32].hash)
|
shallowCopy(result, conf.m.fileInfos[fileIdx.int32].hash)
|
||||||
|
|
||||||
proc toFullPathConsiderDirty*(conf: ConfigRef; fileIdx: FileIndex): string =
|
proc toFullPathConsiderDirty*(conf: ConfigRef; fileIdx: FileIndex): AbsoluteFile =
|
||||||
if fileIdx.int32 < 0:
|
if fileIdx.int32 < 0:
|
||||||
result = "???"
|
result = AbsoluteFile"???"
|
||||||
elif conf.m.fileInfos[fileIdx.int32].dirtyFile.len > 0:
|
elif not conf.m.fileInfos[fileIdx.int32].dirtyFile.isEmpty:
|
||||||
result = conf.m.fileInfos[fileIdx.int32].dirtyFile
|
result = conf.m.fileInfos[fileIdx.int32].dirtyFile
|
||||||
else:
|
else:
|
||||||
result = conf.m.fileInfos[fileIdx.int32].fullPath
|
result = conf.m.fileInfos[fileIdx.int32].fullPath
|
||||||
|
|
@ -188,9 +191,9 @@ proc toMsgFilename*(conf: ConfigRef; info: TLineInfo): string =
|
||||||
if info.fileIndex.int32 < 0:
|
if info.fileIndex.int32 < 0:
|
||||||
result = "???"
|
result = "???"
|
||||||
elif optListFullPaths in conf.globalOptions:
|
elif optListFullPaths in conf.globalOptions:
|
||||||
result = conf.m.fileInfos[info.fileIndex.int32].fullPath
|
result = conf.m.fileInfos[info.fileIndex.int32].fullPath.string
|
||||||
else:
|
else:
|
||||||
result = conf.m.fileInfos[info.fileIndex.int32].projPath
|
result = conf.m.fileInfos[info.fileIndex.int32].projPath.string
|
||||||
|
|
||||||
proc toLinenumber*(info: TLineInfo): int {.inline.} =
|
proc toLinenumber*(info: TLineInfo): int {.inline.} =
|
||||||
result = int info.line
|
result = int info.line
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
## This module implements the generation of ``.ndi`` files for better debugging
|
## This module implements the generation of ``.ndi`` files for better debugging
|
||||||
## support of Nim code. "ndi" stands for "Nim debug info".
|
## support of Nim code. "ndi" stands for "Nim debug info".
|
||||||
|
|
||||||
import ast, msgs, ropes, options
|
import ast, msgs, ropes, options, pathutils
|
||||||
|
|
||||||
type
|
type
|
||||||
NdiFile* = object
|
NdiFile* = object
|
||||||
|
|
@ -30,10 +30,10 @@ proc doWrite(f: var NdiFile; s: PSym; conf: ConfigRef) =
|
||||||
template writeMangledName*(f: NdiFile; s: PSym; conf: ConfigRef) =
|
template writeMangledName*(f: NdiFile; s: PSym; conf: ConfigRef) =
|
||||||
if f.enabled: doWrite(f, s, conf)
|
if f.enabled: doWrite(f, s, conf)
|
||||||
|
|
||||||
proc open*(f: var NdiFile; filename: string; conf: ConfigRef) =
|
proc open*(f: var NdiFile; filename: AbsoluteFile; conf: ConfigRef) =
|
||||||
f.enabled = filename.len > 0
|
f.enabled = not filename.isEmpty
|
||||||
if f.enabled:
|
if f.enabled:
|
||||||
f.f = open(filename, fmWrite, 8000)
|
f.f = open(filename.string, fmWrite, 8000)
|
||||||
f.buf = newStringOfCap(20)
|
f.buf = newStringOfCap(20)
|
||||||
|
|
||||||
proc close*(f: var NdiFile) =
|
proc close*(f: var NdiFile) =
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,8 @@ when defined(i386) and defined(windows) and defined(vcc):
|
||||||
import
|
import
|
||||||
commands, lexer, condsyms, options, msgs, nversion, nimconf, ropes,
|
commands, lexer, condsyms, options, msgs, nversion, nimconf, ropes,
|
||||||
extccomp, strutils, os, osproc, platform, main, parseopt,
|
extccomp, strutils, os, osproc, platform, main, parseopt,
|
||||||
nodejs, scriptconfig, idents, modulegraphs, lineinfos, cmdlinehelper
|
nodejs, scriptconfig, idents, modulegraphs, lineinfos, cmdlinehelper,
|
||||||
|
pathutils
|
||||||
|
|
||||||
when hasTinyCBackend:
|
when hasTinyCBackend:
|
||||||
import tccgen
|
import tccgen
|
||||||
|
|
@ -30,10 +31,10 @@ when defined(profiler) or defined(memProfiler):
|
||||||
{.hint: "Profiling support is turned on!".}
|
{.hint: "Profiling support is turned on!".}
|
||||||
import nimprof
|
import nimprof
|
||||||
|
|
||||||
proc prependCurDir(f: string): string =
|
proc prependCurDir(f: AbsoluteFile): AbsoluteFile =
|
||||||
when defined(unix):
|
when defined(unix):
|
||||||
if os.isAbsolute(f): result = f
|
if os.isAbsolute(f.string): result = f
|
||||||
else: result = "./" & f
|
else: result = AbsoluteFile("./" & f.string)
|
||||||
else:
|
else:
|
||||||
result = f
|
result = f
|
||||||
|
|
||||||
|
|
@ -78,15 +79,15 @@ proc handleCmdLine(cache: IdentCache; conf: ConfigRef) =
|
||||||
if optRun in conf.globalOptions:
|
if optRun in conf.globalOptions:
|
||||||
if conf.cmd == cmdCompileToJS:
|
if conf.cmd == cmdCompileToJS:
|
||||||
var ex: string
|
var ex: string
|
||||||
if conf.outFile.len > 0:
|
if not conf.outFile.isEmpty:
|
||||||
ex = conf.outFile.prependCurDir.quoteShell
|
ex = conf.outFile.prependCurDir.quoteShell
|
||||||
else:
|
else:
|
||||||
ex = quoteShell(
|
ex = quoteShell(
|
||||||
completeCFilePath(conf, changeFileExt(conf.projectFull, "js").prependCurDir))
|
completeCFilePath(conf, changeFileExt(conf.projectFull, "js").prependCurDir))
|
||||||
execExternalProgram(conf, findNodeJs() & " " & ex & ' ' & conf.arguments)
|
execExternalProgram(conf, findNodeJs() & " " & ex & ' ' & conf.arguments)
|
||||||
else:
|
else:
|
||||||
var binPath: string
|
var binPath: AbsoluteFile
|
||||||
if conf.outFile.len > 0:
|
if not conf.outFile.isEmpty:
|
||||||
# If the user specified an outFile path, use that directly.
|
# If the user specified an outFile path, use that directly.
|
||||||
binPath = conf.outFile.prependCurDir
|
binPath = conf.outFile.prependCurDir
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@
|
||||||
## Implements some helper procs for Nimble (Nim's package manager) support.
|
## Implements some helper procs for Nimble (Nim's package manager) support.
|
||||||
|
|
||||||
import parseutils, strutils, strtabs, os, options, msgs, sequtils,
|
import parseutils, strutils, strtabs, os, options, msgs, sequtils,
|
||||||
lineinfos
|
lineinfos, pathutils
|
||||||
|
|
||||||
proc addPath*(conf: ConfigRef; path: string, info: TLineInfo) =
|
proc addPath*(conf: ConfigRef; path: AbsoluteDir, info: TLineInfo) =
|
||||||
if not conf.searchPaths.contains(path):
|
if not conf.searchPaths.contains(path):
|
||||||
conf.searchPaths.insert(path, 0)
|
conf.searchPaths.insert(path, 0)
|
||||||
|
|
||||||
|
|
@ -112,9 +112,9 @@ proc addNimblePath(conf: ConfigRef; p: string, info: TLineInfo) =
|
||||||
if not path.isAbsolute():
|
if not path.isAbsolute():
|
||||||
path = p / path
|
path = p / path
|
||||||
|
|
||||||
if not contains(conf.searchPaths, path):
|
if not contains(conf.searchPaths, AbsoluteDir path):
|
||||||
message(conf, info, hintPath, path)
|
message(conf, info, hintPath, path)
|
||||||
conf.lazyPaths.insert(path, 0)
|
conf.lazyPaths.insert(AbsoluteDir path, 0)
|
||||||
|
|
||||||
proc addPathRec(conf: ConfigRef; dir: string, info: TLineInfo) =
|
proc addPathRec(conf: ConfigRef; dir: string, info: TLineInfo) =
|
||||||
var packages = newStringTable(modeStyleInsensitive)
|
var packages = newStringTable(modeStyleInsensitive)
|
||||||
|
|
@ -126,9 +126,9 @@ proc addPathRec(conf: ConfigRef; dir: string, info: TLineInfo) =
|
||||||
for p in packages.chosen:
|
for p in packages.chosen:
|
||||||
addNimblePath(conf, p, info)
|
addNimblePath(conf, p, info)
|
||||||
|
|
||||||
proc nimblePath*(conf: ConfigRef; path: string, info: TLineInfo) =
|
proc nimblePath*(conf: ConfigRef; path: AbsoluteDir, info: TLineInfo) =
|
||||||
addPathRec(conf, path, info)
|
addPathRec(conf, path.string, info)
|
||||||
addNimblePath(conf, path, info)
|
addNimblePath(conf, path.string, info)
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
proc v(s: string): Version = s.newVersion
|
proc v(s: string): Version = s.newVersion
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
import
|
import
|
||||||
llstream, nversion, commands, os, strutils, msgs, platform, condsyms, lexer,
|
llstream, nversion, commands, os, strutils, msgs, platform, condsyms, lexer,
|
||||||
options, idents, wordrecg, strtabs, lineinfos
|
options, idents, wordrecg, strtabs, lineinfos, pathutils
|
||||||
|
|
||||||
# ---------------- configuration file parser -----------------------------
|
# ---------------- configuration file parser -----------------------------
|
||||||
# we use Nim's scanner here to save space and work
|
# we use Nim's scanner here to save space and work
|
||||||
|
|
@ -201,8 +201,8 @@ proc parseAssignment(L: var TLexer, tok: var TToken;
|
||||||
else:
|
else:
|
||||||
processSwitch(s, val, passPP, info, config)
|
processSwitch(s, val, passPP, info, config)
|
||||||
|
|
||||||
proc readConfigFile(
|
proc readConfigFile(filename: AbsoluteFile; cache: IdentCache;
|
||||||
filename: string; cache: IdentCache; config: ConfigRef): bool =
|
config: ConfigRef): bool =
|
||||||
var
|
var
|
||||||
L: TLexer
|
L: TLexer
|
||||||
tok: TToken
|
tok: TToken
|
||||||
|
|
@ -219,24 +219,24 @@ proc readConfigFile(
|
||||||
closeLexer(L)
|
closeLexer(L)
|
||||||
return true
|
return true
|
||||||
|
|
||||||
proc getUserConfigPath*(filename: string): string =
|
proc getUserConfigPath*(filename: RelativeFile): AbsoluteFile =
|
||||||
result = joinPath([getConfigDir(), "nim", filename])
|
result = getConfigDir().AbsoluteDir / RelativeDir"nim" / filename
|
||||||
|
|
||||||
proc getSystemConfigPath*(conf: ConfigRef; filename: string): string =
|
proc getSystemConfigPath*(conf: ConfigRef; filename: RelativeFile): AbsoluteFile =
|
||||||
# try standard configuration file (installation did not distribute files
|
# try standard configuration file (installation did not distribute files
|
||||||
# the UNIX way)
|
# the UNIX way)
|
||||||
let p = getPrefixDir(conf)
|
let p = getPrefixDir(conf)
|
||||||
result = joinPath([p, "config", filename])
|
result = p / RelativeDir"config" / filename
|
||||||
when defined(unix):
|
when defined(unix):
|
||||||
if not existsFile(result): result = joinPath([p, "etc/nim", filename])
|
if not fileExists(result): result = p / RelativeDir"etc/nim" / filename
|
||||||
if not existsFile(result): result = "/etc/nim/" & filename
|
if not fileExists(result): result = AbsoluteDir"/etc/nim" / filename
|
||||||
|
|
||||||
proc loadConfigs*(cfg: string; cache: IdentCache; conf: ConfigRef) =
|
proc loadConfigs*(cfg: RelativeFile; cache: IdentCache; conf: ConfigRef) =
|
||||||
setDefaultLibpath(conf)
|
setDefaultLibpath(conf)
|
||||||
|
|
||||||
var configFiles = newSeq[string]()
|
var configFiles = newSeq[AbsoluteFile]()
|
||||||
|
|
||||||
template readConfigFile(path: string) =
|
template readConfigFile(path) =
|
||||||
let configPath = path
|
let configPath = path
|
||||||
if readConfigFile(configPath, cache, conf):
|
if readConfigFile(configPath, cache, conf):
|
||||||
add(configFiles, configPath)
|
add(configFiles, configPath)
|
||||||
|
|
@ -247,10 +247,10 @@ proc loadConfigs*(cfg: string; cache: IdentCache; conf: ConfigRef) =
|
||||||
if optSkipUserConfigFile notin conf.globalOptions:
|
if optSkipUserConfigFile notin conf.globalOptions:
|
||||||
readConfigFile(getUserConfigPath(cfg))
|
readConfigFile(getUserConfigPath(cfg))
|
||||||
|
|
||||||
let pd = if conf.projectPath.len > 0: conf.projectPath else: getCurrentDir()
|
let pd = if not conf.projectPath.isEmpty: conf.projectPath else: AbsoluteDir(getCurrentDir())
|
||||||
if optSkipParentConfigFiles notin conf.globalOptions:
|
if optSkipParentConfigFiles notin conf.globalOptions:
|
||||||
for dir in parentDirs(pd, fromRoot=true, inclusive=false):
|
for dir in parentDirs(pd.string, fromRoot=true, inclusive=false):
|
||||||
readConfigFile(dir / cfg)
|
readConfigFile(AbsoluteDir(dir) / cfg)
|
||||||
|
|
||||||
if optSkipProjConfigFile notin conf.globalOptions:
|
if optSkipProjConfigFile notin conf.globalOptions:
|
||||||
readConfigFile(pd / cfg)
|
readConfigFile(pd / cfg)
|
||||||
|
|
@ -264,4 +264,4 @@ proc loadConfigs*(cfg: string; cache: IdentCache; conf: ConfigRef) =
|
||||||
|
|
||||||
for filename in configFiles:
|
for filename in configFiles:
|
||||||
# delayed to here so that `hintConf` is honored
|
# delayed to here so that `hintConf` is honored
|
||||||
rawMessage(conf, hintConf, filename)
|
rawMessage(conf, hintConf, filename.string)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
import
|
import
|
||||||
ast, astalgo, modules, passes, condsyms,
|
ast, astalgo, modules, passes, condsyms,
|
||||||
options, sem, semdata, llstream, vm, vmdef,
|
options, sem, semdata, llstream, vm, vmdef,
|
||||||
modulegraphs, idents, os
|
modulegraphs, idents, os, pathutils
|
||||||
|
|
||||||
type
|
type
|
||||||
Interpreter* = ref object ## Use Nim as an interpreter with this object
|
Interpreter* = ref object ## Use Nim as an interpreter with this object
|
||||||
|
|
@ -103,8 +103,8 @@ proc createInterpreter*(scriptName: string;
|
||||||
registerPass(graph, evalPass)
|
registerPass(graph, evalPass)
|
||||||
|
|
||||||
for p in searchPaths:
|
for p in searchPaths:
|
||||||
conf.searchPaths.add(p)
|
conf.searchPaths.add(AbsoluteDir p)
|
||||||
if conf.libpath.len == 0: conf.libpath = p
|
if conf.libpath.isEmpty: conf.libpath = AbsoluteDir p
|
||||||
|
|
||||||
var m = graph.makeModule(scriptName)
|
var m = graph.makeModule(scriptName)
|
||||||
incl(m.flags, sfMainModule)
|
incl(m.flags, sfMainModule)
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,6 @@ const
|
||||||
VersionAsString* = system.NimVersion
|
VersionAsString* = system.NimVersion
|
||||||
RodFileVersion* = "1223" # modify this if the rod-format changes!
|
RodFileVersion* = "1223" # modify this if the rod-format changes!
|
||||||
|
|
||||||
NimCompilerApiVersion* = 2 ## Check for the existance of this before accessing it
|
NimCompilerApiVersion* = 3 ## Check for the existance of this before accessing it
|
||||||
## as older versions of the compiler API do not
|
## as older versions of the compiler API do not
|
||||||
## declare this.
|
## declare this.
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
import
|
import
|
||||||
os, strutils, strtabs, osproc, sets, lineinfos, platform,
|
os, strutils, strtabs, osproc, sets, lineinfos, platform,
|
||||||
prefixmatches
|
prefixmatches, pathutils
|
||||||
|
|
||||||
from terminal import isatty
|
from terminal import isatty
|
||||||
from times import utc, fromUnix, local, getTime, format, DateTime
|
from times import utc, fromUnix, local, getTime, format, DateTime
|
||||||
|
|
@ -121,7 +121,8 @@ type
|
||||||
notnil,
|
notnil,
|
||||||
dynamicBindSym,
|
dynamicBindSym,
|
||||||
forLoopMacros,
|
forLoopMacros,
|
||||||
caseStmtMacros
|
caseStmtMacros,
|
||||||
|
codeReordering,
|
||||||
|
|
||||||
SymbolFilesOption* = enum
|
SymbolFilesOption* = enum
|
||||||
disabledSf, writeOnlySf, readOnlySf, v2Sf
|
disabledSf, writeOnlySf, readOnlySf, v2Sf
|
||||||
|
|
@ -135,7 +136,7 @@ type
|
||||||
External ## file was introduced via .compile pragma
|
External ## file was introduced via .compile pragma
|
||||||
|
|
||||||
Cfile* = object
|
Cfile* = object
|
||||||
cname*, obj*: string
|
cname*, obj*: AbsoluteFile
|
||||||
flags*: set[CFileFlag]
|
flags*: set[CFileFlag]
|
||||||
CfileList* = seq[Cfile]
|
CfileList* = seq[Cfile]
|
||||||
|
|
||||||
|
|
@ -203,13 +204,14 @@ type
|
||||||
## symbols are always guaranteed to be style
|
## symbols are always guaranteed to be style
|
||||||
## insensitive. Otherwise hell would break lose.
|
## insensitive. Otherwise hell would break lose.
|
||||||
packageCache*: StringTableRef
|
packageCache*: StringTableRef
|
||||||
searchPaths*: seq[string]
|
searchPaths*: seq[AbsoluteDir]
|
||||||
lazyPaths*: seq[string]
|
lazyPaths*: seq[AbsoluteDir]
|
||||||
outFile*, prefixDir*, libpath*, nimcacheDir*: string
|
outFile*: AbsoluteFile
|
||||||
|
prefixDir*, libpath*, nimcacheDir*: AbsoluteDir
|
||||||
dllOverrides, moduleOverrides*: StringTableRef
|
dllOverrides, moduleOverrides*: StringTableRef
|
||||||
projectName*: string # holds a name like 'nim'
|
projectName*: string # holds a name like 'nim'
|
||||||
projectPath*: string # holds a path like /home/alice/projects/nim/compiler/
|
projectPath*: AbsoluteDir # holds a path like /home/alice/projects/nim/compiler/
|
||||||
projectFull*: string # projectPath/projectName
|
projectFull*: AbsoluteFile # projectPath/projectName
|
||||||
projectIsStdin*: bool # whether we're compiling from stdin
|
projectIsStdin*: bool # whether we're compiling from stdin
|
||||||
projectMainIdx*: FileIndex # the canonical path id of the main module
|
projectMainIdx*: FileIndex # the canonical path id of the main module
|
||||||
command*: string # the main command (e.g. cc, check, scan, etc)
|
command*: string # the main command (e.g. cc, check, scan, etc)
|
||||||
|
|
@ -221,9 +223,9 @@ type
|
||||||
# The string uses the formatting variables `path` and `line`.
|
# The string uses the formatting variables `path` and `line`.
|
||||||
|
|
||||||
# the used compiler
|
# the used compiler
|
||||||
cIncludes*: seq[string] # directories to search for included files
|
cIncludes*: seq[AbsoluteDir] # directories to search for included files
|
||||||
cLibs*: seq[string] # directories to search for lib files
|
cLibs*: seq[AbsoluteDir] # directories to search for lib files
|
||||||
cLinkedLibs*: seq[string] # libraries to link
|
cLinkedLibs*: seq[string] # libraries to link
|
||||||
|
|
||||||
externalToLink*: seq[string] # files to link in addition to the file
|
externalToLink*: seq[string] # files to link in addition to the file
|
||||||
# we compiled (*)
|
# we compiled (*)
|
||||||
|
|
@ -302,12 +304,13 @@ proc newConfigRef*(): ConfigRef =
|
||||||
packageCache: newPackageCache(),
|
packageCache: newPackageCache(),
|
||||||
searchPaths: @[],
|
searchPaths: @[],
|
||||||
lazyPaths: @[],
|
lazyPaths: @[],
|
||||||
outFile: "", prefixDir: "", libpath: "", nimcacheDir: "",
|
outFile: AbsoluteFile"", prefixDir: AbsoluteDir"",
|
||||||
|
libpath: AbsoluteDir"", nimcacheDir: AbsoluteDir"",
|
||||||
dllOverrides: newStringTable(modeCaseInsensitive),
|
dllOverrides: newStringTable(modeCaseInsensitive),
|
||||||
moduleOverrides: newStringTable(modeStyleInsensitive),
|
moduleOverrides: newStringTable(modeStyleInsensitive),
|
||||||
projectName: "", # holds a name like 'nim'
|
projectName: "", # holds a name like 'nim'
|
||||||
projectPath: "", # holds a path like /home/alice/projects/nim/compiler/
|
projectPath: AbsoluteDir"", # holds a path like /home/alice/projects/nim/compiler/
|
||||||
projectFull: "", # projectPath/projectName
|
projectFull: AbsoluteFile"", # projectPath/projectName
|
||||||
projectIsStdin: false, # whether we're compiling from stdin
|
projectIsStdin: false, # whether we're compiling from stdin
|
||||||
projectMainIdx: FileIndex(0'i32), # the canonical path id of the main module
|
projectMainIdx: FileIndex(0'i32), # the canonical path id of the main module
|
||||||
command: "", # the main command (e.g. cc, check, scan, etc)
|
command: "", # the main command (e.g. cc, check, scan, etc)
|
||||||
|
|
@ -401,7 +404,7 @@ template optPreserveOrigSource*(conf: ConfigRef): untyped =
|
||||||
optEmbedOrigSrc in conf.globalOptions
|
optEmbedOrigSrc in conf.globalOptions
|
||||||
|
|
||||||
const
|
const
|
||||||
genSubDir* = "nimcache"
|
genSubDir* = RelativeDir"nimcache"
|
||||||
NimExt* = "nim"
|
NimExt* = "nim"
|
||||||
RodExt* = "rod"
|
RodExt* = "rod"
|
||||||
HtmlExt* = "html"
|
HtmlExt* = "html"
|
||||||
|
|
@ -409,10 +412,10 @@ const
|
||||||
TagsExt* = "tags"
|
TagsExt* = "tags"
|
||||||
TexExt* = "tex"
|
TexExt* = "tex"
|
||||||
IniExt* = "ini"
|
IniExt* = "ini"
|
||||||
DefaultConfig* = "nim.cfg"
|
DefaultConfig* = RelativeFile"nim.cfg"
|
||||||
DefaultConfigNims* = "config.nims"
|
DefaultConfigNims* = RelativeFile"config.nims"
|
||||||
DocConfig* = "nimdoc.cfg"
|
DocConfig* = RelativeFile"nimdoc.cfg"
|
||||||
DocTexConfig* = "nimdoc.tex.cfg"
|
DocTexConfig* = RelativeFile"nimdoc.tex.cfg"
|
||||||
|
|
||||||
const oKeepVariableNames* = true
|
const oKeepVariableNames* = true
|
||||||
|
|
||||||
|
|
@ -437,56 +440,61 @@ proc getConfigVar*(conf: ConfigRef; key: string, default = ""): string =
|
||||||
proc setConfigVar*(conf: ConfigRef; key, val: string) =
|
proc setConfigVar*(conf: ConfigRef; key, val: string) =
|
||||||
conf.configVars[key] = val
|
conf.configVars[key] = val
|
||||||
|
|
||||||
proc getOutFile*(conf: ConfigRef; filename, ext: string): string =
|
proc getOutFile*(conf: ConfigRef; filename: RelativeFile, ext: string): AbsoluteFile =
|
||||||
if conf.outFile != "": result = conf.outFile
|
if not conf.outFile.isEmpty: result = conf.outFile
|
||||||
else: result = changeFileExt(filename, ext)
|
else: result = conf.projectPath / changeFileExt(filename, ext)
|
||||||
|
|
||||||
proc getPrefixDir*(conf: ConfigRef): string =
|
proc getPrefixDir*(conf: ConfigRef): AbsoluteDir =
|
||||||
## Gets the prefix dir, usually the parent directory where the binary resides.
|
## Gets the prefix dir, usually the parent directory where the binary resides.
|
||||||
##
|
##
|
||||||
## This is overridden by some tools (namely nimsuggest) via the ``conf.prefixDir``
|
## This is overridden by some tools (namely nimsuggest) via the ``conf.prefixDir``
|
||||||
## global.
|
## field.
|
||||||
if conf.prefixDir != "": result = conf.prefixDir
|
if not conf.prefixDir.isEmpty: result = conf.prefixDir
|
||||||
else: result = splitPath(getAppDir()).head
|
else: result = AbsoluteDir splitPath(getAppDir()).head
|
||||||
|
|
||||||
proc setDefaultLibpath*(conf: ConfigRef) =
|
proc setDefaultLibpath*(conf: ConfigRef) =
|
||||||
# set default value (can be overwritten):
|
# set default value (can be overwritten):
|
||||||
if conf.libpath == "":
|
if conf.libpath.isEmpty:
|
||||||
# choose default libpath:
|
# choose default libpath:
|
||||||
var prefix = getPrefixDir(conf)
|
var prefix = getPrefixDir(conf)
|
||||||
when defined(posix):
|
when defined(posix):
|
||||||
if prefix == "/usr": conf.libpath = "/usr/lib/nim"
|
if prefix == AbsoluteDir"/usr":
|
||||||
elif prefix == "/usr/local": conf.libpath = "/usr/local/lib/nim"
|
conf.libpath = AbsoluteDir"/usr/lib/nim"
|
||||||
else: conf.libpath = joinPath(prefix, "lib")
|
elif prefix == AbsoluteDir"/usr/local":
|
||||||
else: conf.libpath = joinPath(prefix, "lib")
|
conf.libpath = AbsoluteDir"/usr/local/lib/nim"
|
||||||
|
else:
|
||||||
|
conf.libpath = prefix / RelativeDir"lib"
|
||||||
|
else:
|
||||||
|
conf.libpath = prefix / RelativeDir"lib"
|
||||||
|
|
||||||
# Special rule to support other tools (nimble) which import the compiler
|
# Special rule to support other tools (nimble) which import the compiler
|
||||||
# modules and make use of them.
|
# modules and make use of them.
|
||||||
let realNimPath = findExe("nim")
|
let realNimPath = findExe("nim")
|
||||||
# Find out if $nim/../../lib/system.nim exists.
|
# Find out if $nim/../../lib/system.nim exists.
|
||||||
let parentNimLibPath = realNimPath.parentDir.parentDir / "lib"
|
let parentNimLibPath = realNimPath.parentDir.parentDir / "lib"
|
||||||
if not fileExists(conf.libpath / "system.nim") and
|
if not fileExists(conf.libpath.string / "system.nim") and
|
||||||
fileExists(parentNimlibPath / "system.nim"):
|
fileExists(parentNimlibPath / "system.nim"):
|
||||||
conf.libpath = parentNimLibPath
|
conf.libpath = AbsoluteDir parentNimLibPath
|
||||||
|
|
||||||
proc canonicalizePath*(conf: ConfigRef; path: string): string =
|
proc canonicalizePath*(conf: ConfigRef; path: AbsoluteFile): AbsoluteFile =
|
||||||
# on Windows, 'expandFilename' calls getFullPathName which doesn't do
|
# on Windows, 'expandFilename' calls getFullPathName which doesn't do
|
||||||
# case corrections, so we have to use this convoluted way of retrieving
|
# case corrections, so we have to use this convoluted way of retrieving
|
||||||
# the true filename (see tests/modules and Nimble uses 'import Uri' instead
|
# the true filename (see tests/modules and Nimble uses 'import Uri' instead
|
||||||
# of 'import uri'):
|
# of 'import uri'):
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
result = path.expandFilename
|
result = AbsoluteFile path.string.expandFilename
|
||||||
for x in walkFiles(result):
|
for x in walkFiles(result.string):
|
||||||
return x
|
return AbsoluteFile x
|
||||||
else:
|
else:
|
||||||
result = path.expandFilename
|
result = AbsoluteFile path.string.expandFilename
|
||||||
|
|
||||||
proc shortenDir*(conf: ConfigRef; dir: string): string =
|
proc shortenDir*(conf: ConfigRef; dir: string): string {.
|
||||||
|
deprecated: "use 'relativeTo' instead".} =
|
||||||
## returns the interesting part of a dir
|
## returns the interesting part of a dir
|
||||||
var prefix = conf.projectPath & DirSep
|
var prefix = conf.projectPath.string & DirSep
|
||||||
if startsWith(dir, prefix):
|
if startsWith(dir, prefix):
|
||||||
return substr(dir, len(prefix))
|
return substr(dir, len(prefix))
|
||||||
prefix = getPrefixDir(conf) & DirSep
|
prefix = getPrefixDir(conf).string & DirSep
|
||||||
if startsWith(dir, prefix):
|
if startsWith(dir, prefix):
|
||||||
return substr(dir, len(prefix))
|
return substr(dir, len(prefix))
|
||||||
result = dir
|
result = dir
|
||||||
|
|
@ -507,89 +515,89 @@ proc getOsCacheDir(): string =
|
||||||
when defined(posix):
|
when defined(posix):
|
||||||
result = getEnv("XDG_CACHE_HOME", getHomeDir() / ".cache") / "nim"
|
result = getEnv("XDG_CACHE_HOME", getHomeDir() / ".cache") / "nim"
|
||||||
else:
|
else:
|
||||||
result = getHomeDir() / genSubDir
|
result = getHomeDir() / genSubDir.string
|
||||||
|
|
||||||
proc getNimcacheDir*(conf: ConfigRef): string =
|
proc getNimcacheDir*(conf: ConfigRef): AbsoluteDir =
|
||||||
# XXX projectName should always be without a file extension!
|
# XXX projectName should always be without a file extension!
|
||||||
result = if conf.nimcacheDir.len > 0:
|
result = if not conf.nimcacheDir.isEmpty:
|
||||||
conf.nimcacheDir
|
conf.nimcacheDir
|
||||||
elif conf.cmd == cmdCompileToJS:
|
elif conf.cmd == cmdCompileToJS:
|
||||||
shortenDir(conf, conf.projectPath) / genSubDir
|
conf.projectPath / genSubDir
|
||||||
else: getOsCacheDir() / splitFile(conf.projectName).name &
|
else:
|
||||||
(if isDefined(conf, "release"): "_r" else: "_d")
|
AbsoluteDir(getOsCacheDir() / splitFile(conf.projectName).name &
|
||||||
|
(if isDefined(conf, "release"): "_r" else: "_d"))
|
||||||
|
|
||||||
proc pathSubs*(conf: ConfigRef; p, config: string): string =
|
proc pathSubs*(conf: ConfigRef; p, config: string): string =
|
||||||
let home = removeTrailingDirSep(os.getHomeDir())
|
let home = removeTrailingDirSep(os.getHomeDir())
|
||||||
result = unixToNativePath(p % [
|
result = unixToNativePath(p % [
|
||||||
"nim", getPrefixDir(conf),
|
"nim", getPrefixDir(conf).string,
|
||||||
"lib", conf.libpath,
|
"lib", conf.libpath.string,
|
||||||
"home", home,
|
"home", home,
|
||||||
"config", config,
|
"config", config,
|
||||||
"projectname", conf.projectName,
|
"projectname", conf.projectName,
|
||||||
"projectpath", conf.projectPath,
|
"projectpath", conf.projectPath.string,
|
||||||
"projectdir", conf.projectPath,
|
"projectdir", conf.projectPath.string,
|
||||||
"nimcache", getNimcacheDir(conf)])
|
"nimcache", getNimcacheDir(conf).string])
|
||||||
if "~/" in result:
|
if "~/" in result:
|
||||||
result = result.replace("~/", home & '/')
|
result = result.replace("~/", home & '/')
|
||||||
|
|
||||||
proc toGeneratedFile*(conf: ConfigRef; path, ext: string): string =
|
proc toGeneratedFile*(conf: ConfigRef; path: AbsoluteFile,
|
||||||
|
ext: string): AbsoluteFile =
|
||||||
## converts "/home/a/mymodule.nim", "rod" to "/home/a/nimcache/mymodule.rod"
|
## converts "/home/a/mymodule.nim", "rod" to "/home/a/nimcache/mymodule.rod"
|
||||||
var (head, tail) = splitPath(path)
|
let (head, tail) = splitPath(path.string)
|
||||||
#if len(head) > 0: head = shortenDir(head & dirSep)
|
result = getNimcacheDir(conf) / RelativeFile changeFileExt(tail, ext)
|
||||||
result = joinPath([getNimcacheDir(conf), changeFileExt(tail, ext)])
|
|
||||||
#echo "toGeneratedFile(", path, ", ", ext, ") = ", result
|
|
||||||
|
|
||||||
proc completeGeneratedFilePath*(conf: ConfigRef; f: string, createSubDir: bool = true): string =
|
proc completeGeneratedFilePath*(conf: ConfigRef; f: AbsoluteFile,
|
||||||
var (head, tail) = splitPath(f)
|
createSubDir: bool = true): AbsoluteFile =
|
||||||
#if len(head) > 0: head = removeTrailingDirSep(shortenDir(head & dirSep))
|
let (head, tail) = splitPath(f.string)
|
||||||
var subdir = getNimcacheDir(conf) # / head
|
let subdir = getNimcacheDir(conf)
|
||||||
if createSubDir:
|
if createSubDir:
|
||||||
try:
|
try:
|
||||||
createDir(subdir)
|
createDir(subdir.string)
|
||||||
except OSError:
|
except OSError:
|
||||||
writeLine(stdout, "cannot create directory: " & subdir)
|
writeLine(stdout, "cannot create directory: " & subdir.string)
|
||||||
quit(1)
|
quit(1)
|
||||||
result = joinPath(subdir, tail)
|
result = subdir / RelativeFile tail
|
||||||
#echo "completeGeneratedFilePath(", f, ") = ", result
|
#echo "completeGeneratedFilePath(", f, ") = ", result
|
||||||
|
|
||||||
proc rawFindFile(conf: ConfigRef; f: string; suppressStdlib: bool): string =
|
proc rawFindFile(conf: ConfigRef; f: RelativeFile; suppressStdlib: bool): AbsoluteFile =
|
||||||
for it in conf.searchPaths:
|
for it in conf.searchPaths:
|
||||||
if suppressStdlib and it.startsWith(conf.libpath):
|
if suppressStdlib and it.string.startsWith(conf.libpath.string):
|
||||||
continue
|
continue
|
||||||
result = joinPath(it, f)
|
result = it / f
|
||||||
if existsFile(result):
|
if fileExists(result):
|
||||||
return canonicalizePath(conf, result)
|
return canonicalizePath(conf, result)
|
||||||
result = ""
|
result = AbsoluteFile""
|
||||||
|
|
||||||
proc rawFindFile2(conf: ConfigRef; f: string): string =
|
proc rawFindFile2(conf: ConfigRef; f: RelativeFile): AbsoluteFile =
|
||||||
for i, it in conf.lazyPaths:
|
for i, it in conf.lazyPaths:
|
||||||
result = joinPath(it, f)
|
result = it / f
|
||||||
if existsFile(result):
|
if fileExists(result):
|
||||||
# bring to front
|
# bring to front
|
||||||
for j in countDown(i,1):
|
for j in countDown(i,1):
|
||||||
swap(conf.lazyPaths[j], conf.lazyPaths[j-1])
|
swap(conf.lazyPaths[j], conf.lazyPaths[j-1])
|
||||||
|
|
||||||
return canonicalizePath(conf, result)
|
return canonicalizePath(conf, result)
|
||||||
result = ""
|
result = AbsoluteFile""
|
||||||
|
|
||||||
template patchModule(conf: ConfigRef) {.dirty.} =
|
template patchModule(conf: ConfigRef) {.dirty.} =
|
||||||
if result.len > 0 and conf.moduleOverrides.len > 0:
|
if not result.isEmpty and conf.moduleOverrides.len > 0:
|
||||||
let key = getPackageName(conf, result) & "_" & splitFile(result).name
|
let key = getPackageName(conf, result.string) & "_" & splitFile(result).name
|
||||||
if conf.moduleOverrides.hasKey(key):
|
if conf.moduleOverrides.hasKey(key):
|
||||||
let ov = conf.moduleOverrides[key]
|
let ov = conf.moduleOverrides[key]
|
||||||
if ov.len > 0: result = ov
|
if ov.len > 0: result = AbsoluteFile(ov)
|
||||||
|
|
||||||
proc findFile*(conf: ConfigRef; f: string; suppressStdlib = false): string {.procvar.} =
|
proc findFile*(conf: ConfigRef; f: string; suppressStdlib = false): AbsoluteFile {.procvar.} =
|
||||||
if f.isAbsolute:
|
if f.isAbsolute:
|
||||||
result = if f.existsFile: f else: ""
|
result = if f.existsFile: AbsoluteFile(f) else: AbsoluteFile""
|
||||||
else:
|
else:
|
||||||
result = rawFindFile(conf, f, suppressStdlib)
|
result = rawFindFile(conf, RelativeFile f, suppressStdlib)
|
||||||
if result.len == 0:
|
if result.isEmpty:
|
||||||
result = rawFindFile(conf, f.toLowerAscii, suppressStdlib)
|
result = rawFindFile(conf, RelativeFile f.toLowerAscii, suppressStdlib)
|
||||||
if result.len == 0:
|
if result.isEmpty:
|
||||||
result = rawFindFile2(conf, f)
|
result = rawFindFile2(conf, RelativeFile f)
|
||||||
if result.len == 0:
|
if result.isEmpty:
|
||||||
result = rawFindFile2(conf, f.toLowerAscii)
|
result = rawFindFile2(conf, RelativeFile f.toLowerAscii)
|
||||||
patchModule(conf)
|
patchModule(conf)
|
||||||
|
|
||||||
const stdlibDirs = [
|
const stdlibDirs = [
|
||||||
|
|
@ -599,7 +607,7 @@ const stdlibDirs = [
|
||||||
"wrappers", "wrappers/linenoise",
|
"wrappers", "wrappers/linenoise",
|
||||||
"windows", "posix", "js"]
|
"windows", "posix", "js"]
|
||||||
|
|
||||||
proc findModule*(conf: ConfigRef; modulename, currentModule: string): string =
|
proc findModule*(conf: ConfigRef; modulename, currentModule: string): AbsoluteFile =
|
||||||
# returns path to module
|
# returns path to module
|
||||||
const pkgPrefix = "pkg/"
|
const pkgPrefix = "pkg/"
|
||||||
const stdPrefix = "std/"
|
const stdPrefix = "std/"
|
||||||
|
|
@ -610,13 +618,13 @@ proc findModule*(conf: ConfigRef; modulename, currentModule: string): string =
|
||||||
if m.startsWith(stdPrefix):
|
if m.startsWith(stdPrefix):
|
||||||
let stripped = m.substr(stdPrefix.len)
|
let stripped = m.substr(stdPrefix.len)
|
||||||
for candidate in stdlibDirs:
|
for candidate in stdlibDirs:
|
||||||
let path = (conf.libpath / candidate / stripped)
|
let path = (conf.libpath.string / candidate / stripped)
|
||||||
if fileExists(path):
|
if fileExists(path):
|
||||||
m = path
|
m = path
|
||||||
break
|
break
|
||||||
let currentPath = currentModule.splitFile.dir
|
let currentPath = currentModule.splitFile.dir
|
||||||
result = currentPath / m
|
result = AbsoluteFile currentPath / m
|
||||||
if not existsFile(result):
|
if not fileExists(result):
|
||||||
result = findFile(conf, m)
|
result = findFile(conf, m)
|
||||||
patchModule(conf)
|
patchModule(conf)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,10 +41,10 @@ proc getPackageName*(conf: ConfigRef; path: string): string =
|
||||||
dec parents
|
dec parents
|
||||||
if parents <= 0: break
|
if parents <= 0: break
|
||||||
|
|
||||||
proc withPackageName*(conf: ConfigRef; path: string): string =
|
proc withPackageName*(conf: ConfigRef; path: AbsoluteFile): AbsoluteFile =
|
||||||
let x = getPackageName(conf, path)
|
let x = getPackageName(conf, path.string)
|
||||||
if x.len == 0:
|
if x.len == 0:
|
||||||
result = path
|
result = path
|
||||||
else:
|
else:
|
||||||
let (p, file, ext) = path.splitFile
|
let (p, file, ext) = path.splitFile
|
||||||
result = (p / (x & '_' & file)) & ext
|
result = p / RelativeFile((x & '_' & file) & ext)
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,8 @@ when isMainModule:
|
||||||
outp.close
|
outp.close
|
||||||
|
|
||||||
import
|
import
|
||||||
llstream, lexer, idents, strutils, ast, astalgo, msgs, options, lineinfos
|
llstream, lexer, idents, strutils, ast, astalgo, msgs, options, lineinfos,
|
||||||
|
pathutils
|
||||||
|
|
||||||
when defined(nimpretty2):
|
when defined(nimpretty2):
|
||||||
import layouter
|
import layouter
|
||||||
|
|
@ -114,7 +115,7 @@ proc openParser*(p: var TParser, fileIdx: FileIndex, inputStream: PLLStream,
|
||||||
p.strongSpaces = strongSpaces
|
p.strongSpaces = strongSpaces
|
||||||
p.emptyNode = newNode(nkEmpty)
|
p.emptyNode = newNode(nkEmpty)
|
||||||
|
|
||||||
proc openParser*(p: var TParser, filename: string, inputStream: PLLStream,
|
proc openParser*(p: var TParser, filename: AbsoluteFile, inputStream: PLLStream,
|
||||||
cache: IdentCache; config: ConfigRef;
|
cache: IdentCache; config: ConfigRef;
|
||||||
strongSpaces=false) =
|
strongSpaces=false) =
|
||||||
openParser(p, fileInfoIdx(config, filename), inputStream, cache, config, strongSpaces)
|
openParser(p, fileInfoIdx(config, filename), inputStream, cache, config, strongSpaces)
|
||||||
|
|
@ -2238,7 +2239,7 @@ proc parseString*(s: string; cache: IdentCache; config: ConfigRef;
|
||||||
# XXX for now the builtin 'parseStmt/Expr' functions do not know about strong
|
# XXX for now the builtin 'parseStmt/Expr' functions do not know about strong
|
||||||
# spaces...
|
# spaces...
|
||||||
parser.lex.errorHandler = errorHandler
|
parser.lex.errorHandler = errorHandler
|
||||||
openParser(parser, filename, stream, cache, config, false)
|
openParser(parser, AbsoluteFile filename, stream, cache, config, false)
|
||||||
|
|
||||||
result = parser.parseAll
|
result = parser.parseAll
|
||||||
closeParser(parser)
|
closeParser(parser)
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import
|
||||||
strutils, options, ast, astalgo, llstream, msgs, platform, os,
|
strutils, options, ast, astalgo, llstream, msgs, platform, os,
|
||||||
condsyms, idents, renderer, types, extccomp, math, magicsys, nversion,
|
condsyms, idents, renderer, types, extccomp, math, magicsys, nversion,
|
||||||
nimsets, syntaxes, times, idgen, modulegraphs, reorder, rod,
|
nimsets, syntaxes, times, idgen, modulegraphs, reorder, rod,
|
||||||
lineinfos
|
lineinfos, pathutils
|
||||||
|
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
@ -106,7 +106,7 @@ proc processTopLevelStmt(n: PNode, a: var TPassContextArray): bool =
|
||||||
|
|
||||||
proc resolveMod(conf: ConfigRef; module, relativeTo: string): FileIndex =
|
proc resolveMod(conf: ConfigRef; module, relativeTo: string): FileIndex =
|
||||||
let fullPath = findModule(conf, module, relativeTo)
|
let fullPath = findModule(conf, module, relativeTo)
|
||||||
if fullPath.len == 0:
|
if fullPath.isEmpty:
|
||||||
result = InvalidFileIDX
|
result = InvalidFileIDX
|
||||||
else:
|
else:
|
||||||
result = fileInfoIdx(conf, fullPath)
|
result = fileInfoIdx(conf, fullPath)
|
||||||
|
|
@ -160,7 +160,7 @@ proc processModule*(graph: ModuleGraph; module: PSym, stream: PLLStream): bool {
|
||||||
let filename = toFullPathConsiderDirty(graph.config, fileIdx)
|
let filename = toFullPathConsiderDirty(graph.config, fileIdx)
|
||||||
s = llStreamOpen(filename, fmRead)
|
s = llStreamOpen(filename, fmRead)
|
||||||
if s == nil:
|
if s == nil:
|
||||||
rawMessage(graph.config, errCannotOpenFile, filename)
|
rawMessage(graph.config, errCannotOpenFile, filename.string)
|
||||||
return false
|
return false
|
||||||
else:
|
else:
|
||||||
s = stream
|
s = stream
|
||||||
|
|
|
||||||
260
compiler/pathutils.nim
Normal file
260
compiler/pathutils.nim
Normal file
|
|
@ -0,0 +1,260 @@
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# The Nim Compiler
|
||||||
|
# (c) Copyright 2018 Andreas Rumpf
|
||||||
|
#
|
||||||
|
# See the file "copying.txt", included in this
|
||||||
|
# distribution, for details about the copyright.
|
||||||
|
#
|
||||||
|
|
||||||
|
## Path handling utilities for Nim. Strictly typed code in order
|
||||||
|
## to avoid the never ending time sink in getting path handling right.
|
||||||
|
## Might be a candidate for the stdlib later.
|
||||||
|
|
||||||
|
import os, strutils
|
||||||
|
|
||||||
|
type
|
||||||
|
AbsoluteFile* = distinct string
|
||||||
|
AbsoluteDir* = distinct string
|
||||||
|
RelativeFile* = distinct string
|
||||||
|
RelativeDir* = distinct string
|
||||||
|
|
||||||
|
proc isEmpty*(x: AbsoluteFile): bool {.inline.} = x.string.len == 0
|
||||||
|
proc isEmpty*(x: AbsoluteDir): bool {.inline.} = x.string.len == 0
|
||||||
|
proc isEmpty*(x: RelativeFile): bool {.inline.} = x.string.len == 0
|
||||||
|
proc isEmpty*(x: RelativeDir): bool {.inline.} = x.string.len == 0
|
||||||
|
|
||||||
|
proc copyFile*(source, dest: AbsoluteFile) =
|
||||||
|
os.copyFile(source.string, dest.string)
|
||||||
|
|
||||||
|
proc removeFile*(x: AbsoluteFile) {.borrow.}
|
||||||
|
|
||||||
|
proc splitFile*(x: AbsoluteFile): tuple[dir: AbsoluteDir, name, ext: string] =
|
||||||
|
let (a, b, c) = splitFile(x.string)
|
||||||
|
result = (dir: AbsoluteDir(a), name: b, ext: c)
|
||||||
|
|
||||||
|
proc extractFilename*(x: AbsoluteFile): string {.borrow.}
|
||||||
|
|
||||||
|
proc fileExists*(x: AbsoluteFile): bool {.borrow.}
|
||||||
|
proc dirExists*(x: AbsoluteDir): bool {.borrow.}
|
||||||
|
|
||||||
|
proc quoteShell*(x: AbsoluteFile): string {.borrow.}
|
||||||
|
proc quoteShell*(x: AbsoluteDir): string {.borrow.}
|
||||||
|
|
||||||
|
proc cmpPaths*(x, y: AbsoluteDir): int {.borrow.}
|
||||||
|
|
||||||
|
proc createDir*(x: AbsoluteDir) {.borrow.}
|
||||||
|
|
||||||
|
type
|
||||||
|
PathIter = object
|
||||||
|
i, prev: int
|
||||||
|
notFirst: bool
|
||||||
|
|
||||||
|
proc hasNext(it: PathIter; x: string): bool =
|
||||||
|
it.i < x.len
|
||||||
|
|
||||||
|
proc next(it: var PathIter; x: string): (int, int) =
|
||||||
|
it.prev = it.i
|
||||||
|
if not it.notFirst and x[it.i] in {DirSep, AltSep}:
|
||||||
|
# absolute path:
|
||||||
|
inc it.i
|
||||||
|
else:
|
||||||
|
while it.i < x.len and x[it.i] notin {DirSep, AltSep}: inc it.i
|
||||||
|
if it.i > it.prev:
|
||||||
|
result = (it.prev, it.i-1)
|
||||||
|
elif hasNext(it, x):
|
||||||
|
result = next(it, x)
|
||||||
|
|
||||||
|
# skip all separators:
|
||||||
|
while it.i < x.len and x[it.i] in {DirSep, AltSep}: inc it.i
|
||||||
|
it.notFirst = true
|
||||||
|
|
||||||
|
iterator dirs(x: string): (int, int) =
|
||||||
|
var it: PathIter
|
||||||
|
while hasNext(it, x): yield next(it, x)
|
||||||
|
|
||||||
|
when false:
|
||||||
|
iterator dirs(x: string): (int, int) =
|
||||||
|
var i = 0
|
||||||
|
var first = true
|
||||||
|
while i < x.len:
|
||||||
|
let prev = i
|
||||||
|
if first and x[i] in {DirSep, AltSep}:
|
||||||
|
# absolute path:
|
||||||
|
inc i
|
||||||
|
else:
|
||||||
|
while i < x.len and x[i] notin {DirSep, AltSep}: inc i
|
||||||
|
if i > prev:
|
||||||
|
yield (prev, i-1)
|
||||||
|
first = false
|
||||||
|
# skip all separators:
|
||||||
|
while i < x.len and x[i] in {DirSep, AltSep}: inc i
|
||||||
|
|
||||||
|
proc isDot(x: string; bounds: (int, int)): bool =
|
||||||
|
bounds[1] == bounds[0] and x[bounds[0]] == '.'
|
||||||
|
|
||||||
|
proc isDotDot(x: string; bounds: (int, int)): bool =
|
||||||
|
bounds[1] == bounds[0] + 1 and x[bounds[0]] == '.' and x[bounds[0]+1] == '.'
|
||||||
|
|
||||||
|
proc isSlash(x: string; bounds: (int, int)): bool =
|
||||||
|
bounds[1] == bounds[0] and x[bounds[0]] in {DirSep, AltSep}
|
||||||
|
|
||||||
|
proc canon(x: string; result: var string; state: var int) =
|
||||||
|
# state: 0th bit set if isAbsolute path. Other bits count
|
||||||
|
# the number of path components.
|
||||||
|
for b in dirs(x):
|
||||||
|
if (state shr 1 == 0) and isSlash(x, b):
|
||||||
|
result.add DirSep
|
||||||
|
state = state or 1
|
||||||
|
elif result.len > (state and 1) and isDotDot(x, b):
|
||||||
|
var d = result.len
|
||||||
|
# f/..
|
||||||
|
while d > (state and 1) and result[d-1] != DirSep:
|
||||||
|
dec d
|
||||||
|
if d > 0: setLen(result, d-1)
|
||||||
|
elif isDot(x, b):
|
||||||
|
discard "discard the dot"
|
||||||
|
elif b[1] > b[0]:
|
||||||
|
if result.len > 0 and result[^1] != DirSep:
|
||||||
|
result.add DirSep
|
||||||
|
result.add substr(x, b[0], b[1])
|
||||||
|
inc state, 2
|
||||||
|
|
||||||
|
proc canon(x: string): string =
|
||||||
|
# - Turn multiple slashes into single slashes.
|
||||||
|
# - Resolve '/foo/../bar' to '/bar'.
|
||||||
|
# - Remove './' from the path.
|
||||||
|
result = newStringOfCap(x.len)
|
||||||
|
var state = 0
|
||||||
|
canon(x, result, state)
|
||||||
|
|
||||||
|
when FileSystemCaseSensitive:
|
||||||
|
template `!=?`(a, b: char): bool = toLowerAscii(a) != toLowerAscii(b)
|
||||||
|
else:
|
||||||
|
template `!=?`(a, b: char): bool = a != b
|
||||||
|
|
||||||
|
proc relativeTo(full, base: string; sep = DirSep): string =
|
||||||
|
if full.len == 0: return ""
|
||||||
|
var f, b: PathIter
|
||||||
|
var ff = (0, -1)
|
||||||
|
var bb = (0, -1) # (int, int)
|
||||||
|
result = newStringOfCap(full.len)
|
||||||
|
# skip the common prefix:
|
||||||
|
while f.hasNext(full) and b.hasNext(base):
|
||||||
|
ff = next(f, full)
|
||||||
|
bb = next(b, base)
|
||||||
|
let diff = ff[1] - ff[0]
|
||||||
|
if diff != bb[1] - bb[0]: break
|
||||||
|
var same = true
|
||||||
|
for i in 0..diff:
|
||||||
|
if full[i + ff[0]] !=? base[i + bb[0]]:
|
||||||
|
same = false
|
||||||
|
break
|
||||||
|
if not same: break
|
||||||
|
ff = (0, -1)
|
||||||
|
bb = (0, -1)
|
||||||
|
# for i in 0..diff:
|
||||||
|
# result.add base[i + bb[0]]
|
||||||
|
|
||||||
|
# /foo/bar/xxx/ -- base
|
||||||
|
# /foo/bar/baz -- full path
|
||||||
|
# ../baz
|
||||||
|
# every directory that is in 'base', needs to add '..'
|
||||||
|
while true:
|
||||||
|
if bb[1] >= bb[0]:
|
||||||
|
if result.len > 0 and result[^1] != sep:
|
||||||
|
result.add sep
|
||||||
|
result.add ".."
|
||||||
|
if not b.hasNext(base): break
|
||||||
|
bb = b.next(base)
|
||||||
|
|
||||||
|
# add the rest of 'full':
|
||||||
|
while true:
|
||||||
|
if ff[1] >= ff[0]:
|
||||||
|
if result.len > 0 and result[^1] != sep:
|
||||||
|
result.add sep
|
||||||
|
for i in 0..ff[1] - ff[0]:
|
||||||
|
result.add full[i + ff[0]]
|
||||||
|
if not f.hasNext(full): break
|
||||||
|
ff = f.next(full)
|
||||||
|
|
||||||
|
when true:
|
||||||
|
proc eqImpl(x, y: string): bool =
|
||||||
|
when FileSystemCaseSensitive:
|
||||||
|
result = cmpIgnoreCase(canon x, canon y) == 0
|
||||||
|
else:
|
||||||
|
result = canon(x) == canon(y)
|
||||||
|
|
||||||
|
proc `==`*(x, y: AbsoluteFile): bool = eqImpl(x.string, y.string)
|
||||||
|
proc `==`*(x, y: AbsoluteDir): bool = eqImpl(x.string, y.string)
|
||||||
|
proc `==`*(x, y: RelativeFile): bool = eqImpl(x.string, y.string)
|
||||||
|
proc `==`*(x, y: RelativeDir): bool = eqImpl(x.string, y.string)
|
||||||
|
|
||||||
|
proc `/`*(base: AbsoluteDir; f: RelativeFile): AbsoluteFile =
|
||||||
|
#assert isAbsolute(base.string)
|
||||||
|
assert(not isAbsolute(f.string))
|
||||||
|
result = AbsoluteFile newStringOfCap(base.string.len + f.string.len)
|
||||||
|
var state = 0
|
||||||
|
canon(base.string, result.string, state)
|
||||||
|
canon(f.string, result.string, state)
|
||||||
|
|
||||||
|
proc `/`*(base: AbsoluteDir; f: RelativeDir): AbsoluteDir =
|
||||||
|
#assert isAbsolute(base.string)
|
||||||
|
assert(not isAbsolute(f.string))
|
||||||
|
result = AbsoluteDir newStringOfCap(base.string.len + f.string.len)
|
||||||
|
var state = 0
|
||||||
|
canon(base.string, result.string, state)
|
||||||
|
canon(f.string, result.string, state)
|
||||||
|
|
||||||
|
proc relativeTo*(fullPath: AbsoluteFile, baseFilename: AbsoluteDir;
|
||||||
|
sep = DirSep): RelativeFile =
|
||||||
|
RelativeFile(relativeTo(fullPath.string, baseFilename.string, sep))
|
||||||
|
|
||||||
|
proc toAbsolute*(file: string; base: AbsoluteDir): AbsoluteFile =
|
||||||
|
if isAbsolute(file): result = AbsoluteFile(file)
|
||||||
|
else: result = base / RelativeFile file
|
||||||
|
|
||||||
|
proc changeFileExt*(x: AbsoluteFile; ext: string): AbsoluteFile {.borrow.}
|
||||||
|
proc changeFileExt*(x: RelativeFile; ext: string): RelativeFile {.borrow.}
|
||||||
|
|
||||||
|
proc addFileExt*(x: AbsoluteFile; ext: string): AbsoluteFile {.borrow.}
|
||||||
|
proc addFileExt*(x: RelativeFile; ext: string): RelativeFile {.borrow.}
|
||||||
|
|
||||||
|
proc writeFile*(x: AbsoluteFile; content: string) {.borrow.}
|
||||||
|
|
||||||
|
when isMainModule and defined(posix):
|
||||||
|
doAssert canon"/foo/../bar" == "/bar"
|
||||||
|
doAssert canon"foo/../bar" == "bar"
|
||||||
|
|
||||||
|
doAssert canon"/f/../bar///" == "/bar"
|
||||||
|
doAssert canon"f/..////bar" == "bar"
|
||||||
|
|
||||||
|
doAssert canon"../bar" == "../bar"
|
||||||
|
doAssert canon"/../bar" == "/../bar"
|
||||||
|
|
||||||
|
doAssert canon("foo/../../bar/") == "../bar"
|
||||||
|
doAssert canon("./bla/blob/") == "bla/blob"
|
||||||
|
doAssert canon(".hiddenFile") == ".hiddenFile"
|
||||||
|
doAssert canon("./bla/../../blob/./zoo.nim") == "../blob/zoo.nim"
|
||||||
|
|
||||||
|
doAssert canon("C:/file/to/this/long") == "C:/file/to/this/long"
|
||||||
|
doAssert canon("") == ""
|
||||||
|
doAssert canon("foobar") == "foobar"
|
||||||
|
doAssert canon("f/////////") == "f"
|
||||||
|
|
||||||
|
doAssert relativeTo("/foo/bar//baz.nim", "/foo") == "bar/baz.nim"
|
||||||
|
|
||||||
|
doAssert relativeTo("/Users/me/bar/z.nim", "/Users/other/bad") == "../../me/bar/z.nim"
|
||||||
|
|
||||||
|
doAssert relativeTo("/Users/me/bar/z.nim", "/Users/other") == "../me/bar/z.nim"
|
||||||
|
doAssert relativeTo("/Users///me/bar//z.nim", "//Users/") == "me/bar/z.nim"
|
||||||
|
doAssert relativeTo("/Users/me/bar/z.nim", "/Users/me") == "bar/z.nim"
|
||||||
|
doAssert relativeTo("", "/users/moo") == ""
|
||||||
|
doAssert relativeTo("foo", "") == "foo"
|
||||||
|
|
||||||
|
doAssert AbsoluteDir"/Users/me///" / RelativeFile"z.nim" == AbsoluteFile"/Users/me/z.nim"
|
||||||
|
doAssert relativeTo("/foo/bar.nim", "/foo/") == "bar.nim"
|
||||||
|
|
||||||
|
when isMainModule and defined(windows):
|
||||||
|
let nasty = string(AbsoluteDir(r"C:\Users\rumpf\projects\nim\tests\nimble\nimbleDir\linkedPkgs\pkgB-#head\../../simplePkgs/pkgB-#head/") / RelativeFile"pkgA/module.nim")
|
||||||
|
doAssert nasty == r"C:\Users\rumpf\projects\nim\tests\nimble\nimbleDir\simplePkgs\pkgB-#head\pkgA\module.nim"
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
import
|
import
|
||||||
os, platform, condsyms, ast, astalgo, idents, semdata, msgs, renderer,
|
os, platform, condsyms, ast, astalgo, idents, semdata, msgs, renderer,
|
||||||
wordrecg, ropes, options, strutils, extccomp, math, magicsys, trees,
|
wordrecg, ropes, options, strutils, extccomp, math, magicsys, trees,
|
||||||
types, lookups, lineinfos
|
types, lookups, lineinfos, pathutils
|
||||||
|
|
||||||
const
|
const
|
||||||
FirstCallConv* = wNimcall
|
FirstCallConv* = wNimcall
|
||||||
|
|
@ -231,8 +231,17 @@ proc onOff(c: PContext, n: PNode, op: TOptions, resOptions: var TOptions) =
|
||||||
else: resOptions = resOptions - op
|
else: resOptions = resOptions - op
|
||||||
|
|
||||||
proc pragmaNoForward(c: PContext, n: PNode; flag=sfNoForward) =
|
proc pragmaNoForward(c: PContext, n: PNode; flag=sfNoForward) =
|
||||||
if isTurnedOn(c, n): incl(c.module.flags, flag)
|
if isTurnedOn(c, n):
|
||||||
else: excl(c.module.flags, flag)
|
incl(c.module.flags, flag)
|
||||||
|
c.features.incl codeReordering
|
||||||
|
else:
|
||||||
|
excl(c.module.flags, flag)
|
||||||
|
# c.features.excl codeReordering
|
||||||
|
|
||||||
|
# deprecated as of 0.18.1
|
||||||
|
message(c.config, n.info, warnDeprecated,
|
||||||
|
"use {.experimental: \"codeReordering.\".} instead; " &
|
||||||
|
(if flag == sfNoForward: "{.noForward.}" else: "{.reorder.}"))
|
||||||
|
|
||||||
proc processCallConv(c: PContext, n: PNode) =
|
proc processCallConv(c: PContext, n: PNode) =
|
||||||
if n.kind in nkPragmaCallKinds and n.len == 2 and n.sons[1].kind == nkIdent:
|
if n.kind in nkPragmaCallKinds and n.len == 2 and n.sons[1].kind == nkIdent:
|
||||||
|
|
@ -351,7 +360,13 @@ proc processExperimental(c: PContext; n: PNode) =
|
||||||
case n[1].kind
|
case n[1].kind
|
||||||
of nkStrLit, nkRStrLit, nkTripleStrLit:
|
of nkStrLit, nkRStrLit, nkTripleStrLit:
|
||||||
try:
|
try:
|
||||||
c.features.incl parseEnum[Feature](n[1].strVal)
|
let feature = parseEnum[Feature](n[1].strVal)
|
||||||
|
c.features.incl feature
|
||||||
|
if feature == codeReordering:
|
||||||
|
if not isTopLevel(c):
|
||||||
|
localError(c.config, n.info,
|
||||||
|
"Code reordering experimental pragma only valid at toplevel")
|
||||||
|
c.module.flags.incl sfReorder
|
||||||
except ValueError:
|
except ValueError:
|
||||||
localError(c.config, n[1].info, "unknown experimental feature")
|
localError(c.config, n[1].info, "unknown experimental feature")
|
||||||
else:
|
else:
|
||||||
|
|
@ -442,26 +457,22 @@ proc processUndef(c: PContext, n: PNode) =
|
||||||
else:
|
else:
|
||||||
invalidPragma(c, n)
|
invalidPragma(c, n)
|
||||||
|
|
||||||
type
|
proc relativeFile(c: PContext; n: PNode; ext=""): AbsoluteFile =
|
||||||
TLinkFeature = enum
|
|
||||||
linkNormal, linkSys
|
|
||||||
|
|
||||||
proc relativeFile(c: PContext; n: PNode; ext=""): string =
|
|
||||||
var s = expectStrLit(c, n)
|
var s = expectStrLit(c, n)
|
||||||
if ext.len > 0 and splitFile(s).ext == "":
|
if ext.len > 0 and splitFile(s).ext == "":
|
||||||
s = addFileExt(s, ext)
|
s = addFileExt(s, ext)
|
||||||
result = parentDir(toFullPath(c.config, n.info)) / s
|
result = AbsoluteFile parentDir(toFullPath(c.config, n.info)) / s
|
||||||
if not fileExists(result):
|
if not fileExists(result):
|
||||||
if isAbsolute(s): result = s
|
if isAbsolute(s): result = AbsoluteFile s
|
||||||
else:
|
else:
|
||||||
result = findFile(c.config, s)
|
result = findFile(c.config, s)
|
||||||
if result.len == 0: result = s
|
if result.isEmpty: result = AbsoluteFile s
|
||||||
|
|
||||||
proc processCompile(c: PContext, n: PNode) =
|
proc processCompile(c: PContext, n: PNode) =
|
||||||
proc docompile(c: PContext; it: PNode; src, dest: string) =
|
proc docompile(c: PContext; it: PNode; src, dest: AbsoluteFile) =
|
||||||
var cf = Cfile(cname: src, obj: dest, flags: {CfileFlag.External})
|
var cf = Cfile(cname: src, obj: dest, flags: {CfileFlag.External})
|
||||||
extccomp.addExternalFileToCompile(c.config, cf)
|
extccomp.addExternalFileToCompile(c.config, cf)
|
||||||
recordPragma(c, it, "compile", src, dest)
|
recordPragma(c, it, "compile", src.string, dest.string)
|
||||||
|
|
||||||
proc getStrLit(c: PContext, n: PNode; i: int): string =
|
proc getStrLit(c: PContext, n: PNode; i: int): string =
|
||||||
n.sons[i] = c.semConstExpr(c, n[i])
|
n.sons[i] = c.semConstExpr(c, n[i])
|
||||||
|
|
@ -478,30 +489,23 @@ proc processCompile(c: PContext, n: PNode) =
|
||||||
let dest = getStrLit(c, it, 1)
|
let dest = getStrLit(c, it, 1)
|
||||||
var found = parentDir(toFullPath(c.config, n.info)) / s
|
var found = parentDir(toFullPath(c.config, n.info)) / s
|
||||||
for f in os.walkFiles(found):
|
for f in os.walkFiles(found):
|
||||||
let obj = completeCFilePath(c.config, dest % extractFilename(f))
|
let obj = completeCFilePath(c.config, AbsoluteFile(dest % extractFilename(f)))
|
||||||
docompile(c, it, f, obj)
|
docompile(c, it, AbsoluteFile f, obj)
|
||||||
else:
|
else:
|
||||||
let s = expectStrLit(c, n)
|
let s = expectStrLit(c, n)
|
||||||
var found = parentDir(toFullPath(c.config, n.info)) / s
|
var found = AbsoluteFile(parentDir(toFullPath(c.config, n.info)) / s)
|
||||||
if not fileExists(found):
|
if not fileExists(found):
|
||||||
if isAbsolute(s): found = s
|
if isAbsolute(s): found = AbsoluteFile s
|
||||||
else:
|
else:
|
||||||
found = findFile(c.config, s)
|
found = findFile(c.config, s)
|
||||||
if found.len == 0: found = s
|
if found.isEmpty: found = AbsoluteFile s
|
||||||
let obj = toObjFile(c.config, completeCFilePath(c.config, found, false))
|
let obj = toObjFile(c.config, completeCFilePath(c.config, found, false))
|
||||||
docompile(c, it, found, obj)
|
docompile(c, it, found, obj)
|
||||||
|
|
||||||
proc processCommonLink(c: PContext, n: PNode, feature: TLinkFeature) =
|
proc processLink(c: PContext, n: PNode) =
|
||||||
let found = relativeFile(c, n, CC[c.config.cCompiler].objExt)
|
let found = relativeFile(c, n, CC[c.config.cCompiler].objExt)
|
||||||
case feature
|
extccomp.addExternalFileToLink(c.config, found)
|
||||||
of linkNormal:
|
recordPragma(c, n, "link", found.string)
|
||||||
extccomp.addExternalFileToLink(c.config, found)
|
|
||||||
recordPragma(c, n, "link", found)
|
|
||||||
of linkSys:
|
|
||||||
let dest = c.config.libpath / completeCFilePath(c.config, found, false)
|
|
||||||
extccomp.addExternalFileToLink(c.config, dest)
|
|
||||||
recordPragma(c, n, "link", dest)
|
|
||||||
else: internalError(c.config, n.info, "processCommonLink")
|
|
||||||
|
|
||||||
proc pragmaBreakpoint(c: PContext, n: PNode) =
|
proc pragmaBreakpoint(c: PContext, n: PNode) =
|
||||||
discard getOptionalStr(c, n, "")
|
discard getOptionalStr(c, n, "")
|
||||||
|
|
@ -594,8 +598,14 @@ proc pragmaLine(c: PContext, n: PNode) =
|
||||||
elif y.kind != nkIntLit:
|
elif y.kind != nkIntLit:
|
||||||
localError(c.config, n.info, errIntLiteralExpected)
|
localError(c.config, n.info, errIntLiteralExpected)
|
||||||
else:
|
else:
|
||||||
# XXX this produces weird paths which are not properly resolved:
|
if c.config.projectPath.isEmpty:
|
||||||
n.info.fileIndex = msgs.fileInfoIdx(c.config, x.strVal)
|
n.info.fileIndex = fileInfoIdx(c.config, AbsoluteFile(x.strVal))
|
||||||
|
else:
|
||||||
|
# XXX this is still suspicous:
|
||||||
|
let dir = toFullPath(c.config, n.info).splitFile.dir
|
||||||
|
let rel = if isAbsolute(x.strVal): relativeTo(AbsoluteFile(x.strVal), c.config.projectPath)
|
||||||
|
else: RelativeFile(x.strVal)
|
||||||
|
n.info.fileIndex = fileInfoIdx(c.config, AbsoluteDir(dir) / rel)
|
||||||
n.info.line = uint16(y.intVal)
|
n.info.line = uint16(y.intVal)
|
||||||
else:
|
else:
|
||||||
localError(c.config, n.info, "tuple expected")
|
localError(c.config, n.info, "tuple expected")
|
||||||
|
|
@ -822,7 +832,7 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int,
|
||||||
incl(sym.flags, {sfThread, sfGlobal})
|
incl(sym.flags, {sfThread, sfGlobal})
|
||||||
of wDeadCodeElimUnused: discard # deprecated, dead code elim always on
|
of wDeadCodeElimUnused: discard # deprecated, dead code elim always on
|
||||||
of wNoForward: pragmaNoForward(c, it)
|
of wNoForward: pragmaNoForward(c, it)
|
||||||
of wReorder: pragmaNoForward(c, it, sfReorder)
|
of wReorder: pragmaNoForward(c, it, flag = sfReorder)
|
||||||
of wMagic: processMagic(c, it, sym)
|
of wMagic: processMagic(c, it, sym)
|
||||||
of wCompileTime:
|
of wCompileTime:
|
||||||
noVal(c, it)
|
noVal(c, it)
|
||||||
|
|
@ -959,8 +969,7 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int,
|
||||||
of wDefine: processDefine(c, it)
|
of wDefine: processDefine(c, it)
|
||||||
of wUndef: processUndef(c, it)
|
of wUndef: processUndef(c, it)
|
||||||
of wCompile: processCompile(c, it)
|
of wCompile: processCompile(c, it)
|
||||||
of wLink: processCommonLink(c, it, linkNormal)
|
of wLink: processLink(c, it)
|
||||||
of wLinksys: processCommonLink(c, it, linkSys)
|
|
||||||
of wPassl:
|
of wPassl:
|
||||||
let s = expectStrLit(c, it)
|
let s = expectStrLit(c, it)
|
||||||
extccomp.addLinkOption(c.config, s)
|
extccomp.addLinkOption(c.config, s)
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,12 @@ import
|
||||||
type
|
type
|
||||||
TRenderFlag* = enum
|
TRenderFlag* = enum
|
||||||
renderNone, renderNoBody, renderNoComments, renderDocComments,
|
renderNone, renderNoBody, renderNoComments, renderDocComments,
|
||||||
renderNoPragmas, renderIds, renderNoProcDefs
|
renderNoPragmas, renderIds, renderNoProcDefs, renderSyms
|
||||||
TRenderFlags* = set[TRenderFlag]
|
TRenderFlags* = set[TRenderFlag]
|
||||||
TRenderTok* = object
|
TRenderTok* = object
|
||||||
kind*: TTokType
|
kind*: TTokType
|
||||||
length*: int16
|
length*: int16
|
||||||
|
sym*: PSym
|
||||||
|
|
||||||
TRenderTokSeq* = seq[TRenderTok]
|
TRenderTokSeq* = seq[TRenderTok]
|
||||||
TSrcGen* = object
|
TSrcGen* = object
|
||||||
|
|
@ -105,11 +106,12 @@ proc initSrcGen(g: var TSrcGen, renderFlags: TRenderFlags; config: ConfigRef) =
|
||||||
g.inGenericParams = false
|
g.inGenericParams = false
|
||||||
g.config = config
|
g.config = config
|
||||||
|
|
||||||
proc addTok(g: var TSrcGen, kind: TTokType, s: string) =
|
proc addTok(g: var TSrcGen, kind: TTokType, s: string; sym: PSym = nil) =
|
||||||
var length = len(g.tokens)
|
var length = len(g.tokens)
|
||||||
setLen(g.tokens, length + 1)
|
setLen(g.tokens, length + 1)
|
||||||
g.tokens[length].kind = kind
|
g.tokens[length].kind = kind
|
||||||
g.tokens[length].length = int16(len(s))
|
g.tokens[length].length = int16(len(s))
|
||||||
|
g.tokens[length].sym = sym
|
||||||
add(g.buf, s)
|
add(g.buf, s)
|
||||||
|
|
||||||
proc addPendingNL(g: var TSrcGen) =
|
proc addPendingNL(g: var TSrcGen) =
|
||||||
|
|
@ -165,11 +167,11 @@ proc dedent(g: var TSrcGen) =
|
||||||
dec(g.pendingNL, IndentWidth)
|
dec(g.pendingNL, IndentWidth)
|
||||||
dec(g.lineLen, IndentWidth)
|
dec(g.lineLen, IndentWidth)
|
||||||
|
|
||||||
proc put(g: var TSrcGen, kind: TTokType, s: string) =
|
proc put(g: var TSrcGen, kind: TTokType, s: string; sym: PSym = nil) =
|
||||||
if kind != tkSpaces:
|
if kind != tkSpaces:
|
||||||
addPendingNL(g)
|
addPendingNL(g)
|
||||||
if len(s) > 0:
|
if len(s) > 0:
|
||||||
addTok(g, kind, s)
|
addTok(g, kind, s, sym)
|
||||||
inc(g.lineLen, len(s))
|
inc(g.lineLen, len(s))
|
||||||
else:
|
else:
|
||||||
g.pendingWhitespace = s.len
|
g.pendingWhitespace = s.len
|
||||||
|
|
@ -836,7 +838,7 @@ proc gident(g: var TSrcGen, n: PNode) =
|
||||||
t = tkSymbol
|
t = tkSymbol
|
||||||
else:
|
else:
|
||||||
t = tkOpr
|
t = tkOpr
|
||||||
put(g, t, s)
|
put(g, t, s, if n.kind == nkSym and renderSyms in g.flags: n.sym else: nil)
|
||||||
if n.kind == nkSym and (renderIds in g.flags or sfGenSym in n.sym.flags):
|
if n.kind == nkSym and (renderIds in g.flags or sfGenSym in n.sym.flags):
|
||||||
when defined(debugMagics):
|
when defined(debugMagics):
|
||||||
put(g, tkIntLit, $n.sym.id & $n.sym.magic)
|
put(g, tkIntLit, $n.sym.id & $n.sym.magic)
|
||||||
|
|
@ -1541,3 +1543,9 @@ proc getNextTok*(r: var TSrcGen, kind: var TTokType, literal: var string) =
|
||||||
inc(r.idx)
|
inc(r.idx)
|
||||||
else:
|
else:
|
||||||
kind = tkEof
|
kind = tkEof
|
||||||
|
|
||||||
|
proc getTokSym*(r: TSrcGen): PSym =
|
||||||
|
if r.idx > 0 and r.idx <= len(r.tokens):
|
||||||
|
result = r.tokens[r.idx-1].sym
|
||||||
|
else:
|
||||||
|
result = nil
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
import strutils, os, intsets, tables, ropes, db_sqlite, msgs, options, types,
|
import strutils, os, intsets, tables, ropes, db_sqlite, msgs, options, types,
|
||||||
renderer, rodutils, idents, astalgo, btrees, magicsys, cgmeth, extccomp,
|
renderer, rodutils, idents, astalgo, btrees, magicsys, cgmeth, extccomp,
|
||||||
btrees, trees, condsyms, nversion
|
btrees, trees, condsyms, nversion, pathutils
|
||||||
|
|
||||||
## Todo:
|
## Todo:
|
||||||
## - Dependency computation should use *signature* hashes in order to
|
## - Dependency computation should use *signature* hashes in order to
|
||||||
|
|
@ -796,7 +796,7 @@ proc replay(g: ModuleGraph; module: PSym; n: PNode) =
|
||||||
flags: {CfileFlag.External})
|
flags: {CfileFlag.External})
|
||||||
extccomp.addExternalFileToCompile(g.config, cf)
|
extccomp.addExternalFileToCompile(g.config, cf)
|
||||||
of "link":
|
of "link":
|
||||||
extccomp.addExternalFileToLink(g.config, n[1].strVal)
|
extccomp.addExternalFileToLink(g.config, AbsoluteFile n[1].strVal)
|
||||||
of "passl":
|
of "passl":
|
||||||
extccomp.addLinkOption(g.config, n[1].strVal)
|
extccomp.addLinkOption(g.config, n[1].strVal)
|
||||||
of "passc":
|
of "passc":
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,8 @@
|
||||||
import
|
import
|
||||||
hashes
|
hashes
|
||||||
|
|
||||||
|
from pathutils import AbsoluteFile
|
||||||
|
|
||||||
type
|
type
|
||||||
FormatStr* = string # later we may change it to CString for better
|
FormatStr* = string # later we may change it to CString for better
|
||||||
# performance of the code generator (assignments
|
# performance of the code generator (assignments
|
||||||
|
|
@ -183,9 +185,9 @@ proc writeRope*(f: File, r: Rope) =
|
||||||
## writes a rope to a file.
|
## writes a rope to a file.
|
||||||
for s in leaves(r): write(f, s)
|
for s in leaves(r): write(f, s)
|
||||||
|
|
||||||
proc writeRope*(head: Rope, filename: string): bool =
|
proc writeRope*(head: Rope, filename: AbsoluteFile): bool =
|
||||||
var f: File
|
var f: File
|
||||||
if open(f, filename, fmWrite):
|
if open(f, filename.string, fmWrite):
|
||||||
if head != nil: writeRope(f, head)
|
if head != nil: writeRope(f, head)
|
||||||
close(f)
|
close(f)
|
||||||
result = true
|
result = true
|
||||||
|
|
@ -314,16 +316,16 @@ proc equalsFile*(r: Rope, f: File): bool =
|
||||||
result = readBuffer(f, addr(buf[0]), 1) == 0 and
|
result = readBuffer(f, addr(buf[0]), 1) == 0 and
|
||||||
btotal == rtotal # check that we've read all
|
btotal == rtotal # check that we've read all
|
||||||
|
|
||||||
proc equalsFile*(r: Rope, filename: string): bool =
|
proc equalsFile*(r: Rope, filename: AbsoluteFile): bool =
|
||||||
## returns true if the contents of the file `f` equal `r`. If `f` does not
|
## returns true if the contents of the file `f` equal `r`. If `f` does not
|
||||||
## exist, false is returned.
|
## exist, false is returned.
|
||||||
var f: File
|
var f: File
|
||||||
result = open(f, filename)
|
result = open(f, filename.string)
|
||||||
if result:
|
if result:
|
||||||
result = equalsFile(r, f)
|
result = equalsFile(r, f)
|
||||||
close(f)
|
close(f)
|
||||||
|
|
||||||
proc writeRopeIfNotEqual*(r: Rope, filename: string): bool =
|
proc writeRopeIfNotEqual*(r: Rope, filename: AbsoluteFile): bool =
|
||||||
# returns true if overwritten
|
# returns true if overwritten
|
||||||
if not equalsFile(r, filename):
|
if not equalsFile(r, filename):
|
||||||
result = writeRope(r, filename)
|
result = writeRope(r, filename)
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
import
|
import
|
||||||
ast, modules, idents, passes, passaux, condsyms,
|
ast, modules, idents, passes, passaux, condsyms,
|
||||||
options, nimconf, sem, semdata, llstream, vm, vmdef, commands, msgs,
|
options, nimconf, sem, semdata, llstream, vm, vmdef, commands, msgs,
|
||||||
os, times, osproc, wordrecg, strtabs, modulegraphs, lineinfos
|
os, times, osproc, wordrecg, strtabs, modulegraphs, lineinfos, pathutils
|
||||||
|
|
||||||
# we support 'cmpIgnoreStyle' natively for efficiency:
|
# we support 'cmpIgnoreStyle' natively for efficiency:
|
||||||
from strutils import cmpIgnoreStyle, contains
|
from strutils import cmpIgnoreStyle, contains
|
||||||
|
|
@ -105,7 +105,7 @@ proc setupVM*(module: PSym; cache: IdentCache; scriptName: string;
|
||||||
cbconf exists:
|
cbconf exists:
|
||||||
setResult(a, options.existsConfigVar(conf, a.getString 0))
|
setResult(a, options.existsConfigVar(conf, a.getString 0))
|
||||||
cbconf nimcacheDir:
|
cbconf nimcacheDir:
|
||||||
setResult(a, options.getNimcacheDir(conf))
|
setResult(a, options.getNimcacheDir(conf).string)
|
||||||
cbconf paramStr:
|
cbconf paramStr:
|
||||||
setResult(a, os.paramStr(int a.getInt 0))
|
setResult(a, os.paramStr(int a.getInt 0))
|
||||||
cbconf paramCount:
|
cbconf paramCount:
|
||||||
|
|
@ -120,8 +120,8 @@ proc setupVM*(module: PSym; cache: IdentCache; scriptName: string;
|
||||||
if arg.len > 0:
|
if arg.len > 0:
|
||||||
conf.projectName = arg
|
conf.projectName = arg
|
||||||
let path =
|
let path =
|
||||||
if conf.projectName.isAbsolute: conf.projectName
|
if conf.projectName.isAbsolute: AbsoluteFile(conf.projectName)
|
||||||
else: conf.projectPath / conf.projectName
|
else: conf.projectPath / RelativeFile(conf.projectName)
|
||||||
try:
|
try:
|
||||||
conf.projectFull = canonicalizePath(conf, path)
|
conf.projectFull = canonicalizePath(conf, path)
|
||||||
except OSError:
|
except OSError:
|
||||||
|
|
@ -149,9 +149,9 @@ proc setupVM*(module: PSym; cache: IdentCache; scriptName: string;
|
||||||
cbconf cppDefine:
|
cbconf cppDefine:
|
||||||
options.cppDefine(conf, a.getString(0))
|
options.cppDefine(conf, a.getString(0))
|
||||||
|
|
||||||
proc runNimScript*(cache: IdentCache; scriptName: string;
|
proc runNimScript*(cache: IdentCache; scriptName: AbsoluteFile;
|
||||||
freshDefines=true; conf: ConfigRef) =
|
freshDefines=true; conf: ConfigRef) =
|
||||||
rawMessage(conf, hintConf, scriptName)
|
rawMessage(conf, hintConf, scriptName.string)
|
||||||
|
|
||||||
let graph = newModuleGraph(cache, conf)
|
let graph = newModuleGraph(cache, conf)
|
||||||
connectCallbacks(graph)
|
connectCallbacks(graph)
|
||||||
|
|
@ -169,7 +169,7 @@ proc runNimScript*(cache: IdentCache; scriptName: string;
|
||||||
|
|
||||||
var m = graph.makeModule(scriptName)
|
var m = graph.makeModule(scriptName)
|
||||||
incl(m.flags, sfMainModule)
|
incl(m.flags, sfMainModule)
|
||||||
graph.vm = setupVM(m, cache, scriptName, graph)
|
graph.vm = setupVM(m, cache, scriptName.string, graph)
|
||||||
|
|
||||||
graph.compileSystemModule() # TODO: see why this unsets hintConf in conf.notes
|
graph.compileSystemModule() # TODO: see why this unsets hintConf in conf.notes
|
||||||
discard graph.processModule(m, llStreamOpen(scriptName, fmRead))
|
discard graph.processModule(m, llStreamOpen(scriptName, fmRead))
|
||||||
|
|
|
||||||
|
|
@ -367,8 +367,11 @@ proc handleGenericInvocation(cl: var TReplTypeVars, t: PType): PType =
|
||||||
# can come here for tyGenericInst too, see tests/metatype/ttypeor.nim
|
# can come here for tyGenericInst too, see tests/metatype/ttypeor.nim
|
||||||
# need to look into this issue later
|
# need to look into this issue later
|
||||||
assert newbody.kind in {tyRef, tyPtr}
|
assert newbody.kind in {tyRef, tyPtr}
|
||||||
assert newbody.lastSon.typeInst == nil
|
if newbody.lastSon.typeInst != nil:
|
||||||
newbody.lastSon.typeInst = result
|
#internalError(cl.c.config, cl.info, "ref already has a 'typeInst' field")
|
||||||
|
discard
|
||||||
|
else:
|
||||||
|
newbody.lastSon.typeInst = result
|
||||||
cl.c.typesWithOps.add((newbody, result))
|
cl.c.typesWithOps.add((newbody, result))
|
||||||
let methods = skipTypes(bbody, abstractPtrs).methods
|
let methods = skipTypes(bbody, abstractPtrs).methods
|
||||||
for col, meth in items(methods):
|
for col, meth in items(methods):
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,8 @@ else:
|
||||||
toBase64a(cast[cstring](unsafeAddr u), sizeof(u))
|
toBase64a(cast[cstring](unsafeAddr u), sizeof(u))
|
||||||
proc `&=`(c: var MD5Context, s: string) = md5Update(c, s, s.len)
|
proc `&=`(c: var MD5Context, s: string) = md5Update(c, s, s.len)
|
||||||
proc `&=`(c: var MD5Context, ch: char) = md5Update(c, unsafeAddr ch, 1)
|
proc `&=`(c: var MD5Context, ch: char) = md5Update(c, unsafeAddr ch, 1)
|
||||||
|
proc `&=`(c: var MD5Context, r: Rope) =
|
||||||
|
for l in leaves(r): md5Update(c, l, l.len)
|
||||||
proc `&=`(c: var MD5Context, i: BiggestInt) =
|
proc `&=`(c: var MD5Context, i: BiggestInt) =
|
||||||
md5Update(c, cast[cstring](unsafeAddr i), sizeof(i))
|
md5Update(c, cast[cstring](unsafeAddr i), sizeof(i))
|
||||||
|
|
||||||
|
|
@ -173,19 +175,23 @@ proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) =
|
||||||
c.hashSym(t.sym)
|
c.hashSym(t.sym)
|
||||||
of tyObject, tyEnum:
|
of tyObject, tyEnum:
|
||||||
if t.typeInst != nil:
|
if t.typeInst != nil:
|
||||||
assert t.typeInst.kind == tyGenericInst
|
# prevent against infinite recursions here, see bug #8883:
|
||||||
for i in countup(0, sonsLen(t.typeInst) - 2):
|
let inst = t.typeInst
|
||||||
c.hashType t.typeInst.sons[i], flags
|
t.typeInst = nil
|
||||||
|
assert inst.kind == tyGenericInst
|
||||||
|
for i in countup(0, inst.len - 2):
|
||||||
|
c.hashType inst.sons[i], flags
|
||||||
|
t.typeInst = inst
|
||||||
return
|
return
|
||||||
c &= char(t.kind)
|
c &= char(t.kind)
|
||||||
# Every cyclic type in Nim need to be constructed via some 't.sym', so this
|
# Every cyclic type in Nim need to be constructed via some 't.sym', so this
|
||||||
# is actually safe without an infinite recursion check:
|
# is actually safe without an infinite recursion check:
|
||||||
if t.sym != nil:
|
if t.sym != nil:
|
||||||
#if "Future:" in t.sym.name.s and t.typeInst == nil:
|
if {sfCompilerProc} * t.sym.flags != {}:
|
||||||
# writeStackTrace()
|
doAssert t.sym.loc.r != nil
|
||||||
# echo "yes ", t.sym.name.s
|
# The user has set a specific name for this type
|
||||||
# #quit 1
|
c &= t.sym.loc.r
|
||||||
if CoOwnerSig in flags:
|
elif CoOwnerSig in flags:
|
||||||
c.hashTypeSym(t.sym)
|
c.hashTypeSym(t.sym)
|
||||||
else:
|
else:
|
||||||
c.hashSym(t.sym)
|
c.hashSym(t.sym)
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
# included from sigmatch.nim
|
# included from sigmatch.nim
|
||||||
|
|
||||||
import algorithm, prefixmatches, lineinfos
|
import algorithm, prefixmatches, lineinfos, pathutils
|
||||||
from wordrecg import wDeprecated
|
from wordrecg import wDeprecated
|
||||||
|
|
||||||
when defined(nimsuggest):
|
when defined(nimsuggest):
|
||||||
|
|
@ -319,7 +319,7 @@ proc suggestFieldAccess(c: PContext, n, field: PNode, outputs: var Suggestions)
|
||||||
if n.kind == nkSym and n.sym.kind == skError and c.config.suggestVersion == 0:
|
if n.kind == nkSym and n.sym.kind == skError and c.config.suggestVersion == 0:
|
||||||
# consider 'foo.|' where 'foo' is some not imported module.
|
# consider 'foo.|' where 'foo' is some not imported module.
|
||||||
let fullPath = findModule(c.config, n.sym.name.s, toFullPath(c.config, n.info))
|
let fullPath = findModule(c.config, n.sym.name.s, toFullPath(c.config, n.info))
|
||||||
if fullPath.len == 0:
|
if fullPath.isEmpty:
|
||||||
# error: no known module name:
|
# error: no known module name:
|
||||||
typ = nil
|
typ = nil
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
import
|
import
|
||||||
strutils, llstream, ast, astalgo, idents, lexer, options, msgs, parser,
|
strutils, llstream, ast, astalgo, idents, lexer, options, msgs, parser,
|
||||||
filters, filter_tmpl, renderer, lineinfos
|
filters, filter_tmpl, renderer, lineinfos, pathutils
|
||||||
|
|
||||||
type
|
type
|
||||||
TFilterKind* = enum
|
TFilterKind* = enum
|
||||||
|
|
@ -58,7 +58,7 @@ proc containsShebang(s: string, i: int): bool =
|
||||||
while j < s.len and s[j] in Whitespace: inc(j)
|
while j < s.len and s[j] in Whitespace: inc(j)
|
||||||
result = s[j] == '/'
|
result = s[j] == '/'
|
||||||
|
|
||||||
proc parsePipe(filename: string, inputStream: PLLStream; cache: IdentCache;
|
proc parsePipe(filename: AbsoluteFile, inputStream: PLLStream; cache: IdentCache;
|
||||||
config: ConfigRef): PNode =
|
config: ConfigRef): PNode =
|
||||||
result = newNode(nkEmpty)
|
result = newNode(nkEmpty)
|
||||||
var s = llStreamOpen(filename, fmRead)
|
var s = llStreamOpen(filename, fmRead)
|
||||||
|
|
@ -100,7 +100,7 @@ proc getCallee(conf: ConfigRef; n: PNode): PIdent =
|
||||||
else:
|
else:
|
||||||
localError(conf, n.info, "invalid filter: " & renderTree(n))
|
localError(conf, n.info, "invalid filter: " & renderTree(n))
|
||||||
|
|
||||||
proc applyFilter(p: var TParsers, n: PNode, filename: string,
|
proc applyFilter(p: var TParsers, n: PNode, filename: AbsoluteFile,
|
||||||
stdin: PLLStream): PLLStream =
|
stdin: PLLStream): PLLStream =
|
||||||
var ident = getCallee(p.config, n)
|
var ident = getCallee(p.config, n)
|
||||||
var f = getFilter(ident)
|
var f = getFilter(ident)
|
||||||
|
|
@ -121,7 +121,7 @@ proc applyFilter(p: var TParsers, n: PNode, filename: string,
|
||||||
msgWriteln(p.config, result.s)
|
msgWriteln(p.config, result.s)
|
||||||
rawMessage(p.config, hintCodeEnd, [])
|
rawMessage(p.config, hintCodeEnd, [])
|
||||||
|
|
||||||
proc evalPipe(p: var TParsers, n: PNode, filename: string,
|
proc evalPipe(p: var TParsers, n: PNode, filename: AbsoluteFile,
|
||||||
start: PLLStream): PLLStream =
|
start: PLLStream): PLLStream =
|
||||||
assert p.config != nil
|
assert p.config != nil
|
||||||
result = start
|
result = start
|
||||||
|
|
@ -161,8 +161,8 @@ proc parseFile*(fileIdx: FileIndex; cache: IdentCache; config: ConfigRef): PNode
|
||||||
p: TParsers
|
p: TParsers
|
||||||
f: File
|
f: File
|
||||||
let filename = toFullPathConsiderDirty(config, fileIdx)
|
let filename = toFullPathConsiderDirty(config, fileIdx)
|
||||||
if not open(f, filename):
|
if not open(f, filename.string):
|
||||||
rawMessage(config, errGenerated, "cannot open file: " & filename)
|
rawMessage(config, errGenerated, "cannot open file: " & filename.string)
|
||||||
return
|
return
|
||||||
openParsers(p, fileIdx, llStreamOpen(f), cache, config)
|
openParsers(p, fileIdx, llStreamOpen(f), cache, config)
|
||||||
result = parseAll(p)
|
result = parseAll(p)
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ proc opSlurp*(file: string, info: TLineInfo, module: PSym; conf: ConfigRef): str
|
||||||
try:
|
try:
|
||||||
var filename = parentDir(toFullPath(conf, info)) / file
|
var filename = parentDir(toFullPath(conf, info)) / file
|
||||||
if not fileExists(filename):
|
if not fileExists(filename):
|
||||||
filename = findFile(conf, file)
|
filename = findFile(conf, file).string
|
||||||
result = readFile(filename)
|
result = readFile(filename)
|
||||||
# we produce a fake include statement for every slurped filename, so that
|
# we produce a fake include statement for every slurped filename, so that
|
||||||
# the module dependencies are accurate:
|
# the module dependencies are accurate:
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
import pathutils
|
||||||
|
|
||||||
template setX(k, field) {.dirty.} =
|
template setX(k, field) {.dirty.} =
|
||||||
var s: seq[TFullReg]
|
var s: seq[TFullReg]
|
||||||
move(s, cast[seq[TFullReg]](a.slots))
|
move(s, cast[seq[TFullReg]](a.slots))
|
||||||
|
|
@ -38,6 +40,8 @@ proc setResult*(a: VmArgs; n: PNode) =
|
||||||
s[a.ra].kind = rkNode
|
s[a.ra].kind = rkNode
|
||||||
s[a.ra].node = n
|
s[a.ra].node = n
|
||||||
|
|
||||||
|
proc setResult*(a: VmArgs; v: AbsoluteDir) = setResult(a, v.string)
|
||||||
|
|
||||||
proc setResult*(a: VmArgs; v: seq[string]) =
|
proc setResult*(a: VmArgs; v: seq[string]) =
|
||||||
var s: seq[TFullReg]
|
var s: seq[TFullReg]
|
||||||
move(s, cast[seq[TFullReg]](a.slots))
|
move(s, cast[seq[TFullReg]](a.slots))
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ proc registerAdditionalOps*(c: PCtx) =
|
||||||
setResult a, newTree(nkTupleConstr, newStrNode(nkStrLit, s), newIntNode(nkIntLit, e))
|
setResult a, newTree(nkTupleConstr, newStrNode(nkStrLit, s), newIntNode(nkIntLit, e))
|
||||||
|
|
||||||
proc getProjectPathWrapper(a: VmArgs) =
|
proc getProjectPathWrapper(a: VmArgs) =
|
||||||
setResult a, c.config.projectPath
|
setResult a, c.config.projectPath.string
|
||||||
|
|
||||||
wrap1f_math(sqrt)
|
wrap1f_math(sqrt)
|
||||||
wrap1f_math(ln)
|
wrap1f_math(ln)
|
||||||
|
|
|
||||||
29
doc/lib.rst
29
doc/lib.rst
|
|
@ -425,7 +425,7 @@ Miscellaneous
|
||||||
Turns access violations or segfaults into a ``NilAccessError`` exception.
|
Turns access violations or segfaults into a ``NilAccessError`` exception.
|
||||||
|
|
||||||
Modules for JS backend
|
Modules for JS backend
|
||||||
---------------------------
|
----------------------
|
||||||
|
|
||||||
* `dom <dom.html>`_
|
* `dom <dom.html>`_
|
||||||
Declaration of the Document Object Model for the JS backend.
|
Declaration of the Document Object Model for the JS backend.
|
||||||
|
|
@ -440,30 +440,6 @@ Modules for JS backend
|
||||||
Wrapper of core JavaScript functions. For most purposes you should be using
|
Wrapper of core JavaScript functions. For most purposes you should be using
|
||||||
the ``math``, ``json``, and ``times`` stdlib modules instead of this module.
|
the ``math``, ``json``, and ``times`` stdlib modules instead of this module.
|
||||||
|
|
||||||
Deprecated modules
|
|
||||||
------------------
|
|
||||||
|
|
||||||
* `asyncio <asyncio.html>`_
|
|
||||||
This module implements an asynchronous event loop for sockets.
|
|
||||||
**Deprecated since version 0.11.2:**
|
|
||||||
Use the `asyncnet <asyncnet.html>`_ together with the
|
|
||||||
`asyncdispatch <asyncdispatch.html>`_ module instead.
|
|
||||||
|
|
||||||
* `ftpclient <ftpclient.html>`_
|
|
||||||
This module implements an FTP client.
|
|
||||||
**Deprecated since version 0.11.3:**
|
|
||||||
Use the `asyncftpclient <asyncftpclient.html>`_ module instead.
|
|
||||||
|
|
||||||
* `sockets <sockets.html>`_
|
|
||||||
This module implements a simple portable type-safe sockets layer.
|
|
||||||
**Deprecated since version 0.11.2:**
|
|
||||||
Use the `net <net.html>`_ or the `rawsockets <rawsockets.html>`_ module
|
|
||||||
instead.
|
|
||||||
|
|
||||||
* `rawsockets <rawsockets.html>`_
|
|
||||||
**Deprecated since version 0.11.4:**
|
|
||||||
This module has been renamed to `nativesockets <nativesockets.html>`_.
|
|
||||||
|
|
||||||
|
|
||||||
Impure libraries
|
Impure libraries
|
||||||
================
|
================
|
||||||
|
|
@ -475,9 +451,6 @@ Regular expressions
|
||||||
This module contains procedures and operators for handling regular
|
This module contains procedures and operators for handling regular
|
||||||
expressions. The current implementation uses PCRE.
|
expressions. The current implementation uses PCRE.
|
||||||
|
|
||||||
* `nre <nre.html>`_
|
|
||||||
Another implementation of procedures for using regular expressions. Also uses
|
|
||||||
PCRE.
|
|
||||||
|
|
||||||
|
|
||||||
Database support
|
Database support
|
||||||
|
|
|
||||||
154
doc/manual.rst
154
doc/manual.rst
|
|
@ -6534,6 +6534,111 @@ iterator in which case the overloading resolution takes place:
|
||||||
var x = 4
|
var x = 4
|
||||||
write(stdout, x) # not ambiguous: uses the module C's x
|
write(stdout, x) # not ambiguous: uses the module C's x
|
||||||
|
|
||||||
|
Code reordering
|
||||||
|
~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
**Note**: Code reordering is experimental and must be enabled via the
|
||||||
|
``{.experimental.}`` pragma.
|
||||||
|
|
||||||
|
The code reordering feature can implicitly rearrange procedure, template, and
|
||||||
|
macro definitions along with variable declarations and initializations at the top
|
||||||
|
level scope so that, to a large extent, a programmer should not have to worry
|
||||||
|
about ordering definitions correctly or be forced to use forward declarations to
|
||||||
|
preface definitions inside a module.
|
||||||
|
|
||||||
|
..
|
||||||
|
NOTE: The following was documentation for the code reordering precursor,
|
||||||
|
which was {.noForward.}.
|
||||||
|
|
||||||
|
In this mode, procedure definitions may appear out of order and the compiler
|
||||||
|
will postpone their semantic analysis and compilation until it actually needs
|
||||||
|
to generate code using the definitions. In this regard, this mode is similar
|
||||||
|
to the modus operandi of dynamic scripting languages, where the function
|
||||||
|
calls are not resolved until the code is executed. Here is the detailed
|
||||||
|
algorithm taken by the compiler:
|
||||||
|
|
||||||
|
1. When a callable symbol is first encountered, the compiler will only note
|
||||||
|
the symbol callable name and it will add it to the appropriate overload set
|
||||||
|
in the current scope. At this step, it won't try to resolve any of the type
|
||||||
|
expressions used in the signature of the symbol (so they can refer to other
|
||||||
|
not yet defined symbols).
|
||||||
|
|
||||||
|
2. When a top level call is encountered (usually at the very end of the
|
||||||
|
module), the compiler will try to determine the actual types of all of the
|
||||||
|
symbols in the matching overload set. This is a potentially recursive process
|
||||||
|
as the signatures of the symbols may include other call expressions, whose
|
||||||
|
types will be resolved at this point too.
|
||||||
|
|
||||||
|
3. Finally, after the best overload is picked, the compiler will start
|
||||||
|
compiling the body of the respective symbol. This in turn will lead the
|
||||||
|
compiler to discover more call expressions that need to be resolved and steps
|
||||||
|
2 and 3 will be repeated as necessary.
|
||||||
|
|
||||||
|
Please note that if a callable symbol is never used in this scenario, its
|
||||||
|
body will never be compiled. This is the default behavior leading to best
|
||||||
|
compilation times, but if exhaustive compilation of all definitions is
|
||||||
|
required, using ``nim check`` provides this option as well.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
.. code-block:: nim
|
||||||
|
|
||||||
|
{.experimental: "codeReordering".}
|
||||||
|
|
||||||
|
proc foo(x: int) =
|
||||||
|
bar(x)
|
||||||
|
|
||||||
|
proc bar(x: int) =
|
||||||
|
echo(x)
|
||||||
|
|
||||||
|
foo(10)
|
||||||
|
|
||||||
|
Variables can also be reordered as well. Variables that are *initialized* (i.e.
|
||||||
|
variables that have their declaration and assignment combined in a single
|
||||||
|
statement) can have their entire initialization statement reordered. Be wary of
|
||||||
|
what code is executed at the top level:
|
||||||
|
|
||||||
|
.. code-block:: nim
|
||||||
|
{.experimental: "codeReordering".}
|
||||||
|
|
||||||
|
proc a() =
|
||||||
|
echo(foo)
|
||||||
|
|
||||||
|
var foo = 5
|
||||||
|
|
||||||
|
a() # outputs: "5"
|
||||||
|
|
||||||
|
..
|
||||||
|
TODO: Let's table this for now. This is an *experimental feature* and so the
|
||||||
|
specific manner in which ``declared`` operates with it can be decided in
|
||||||
|
eventuality, because right now it works a bit weirdly.
|
||||||
|
|
||||||
|
The values of expressions involving ``declared`` are decided *before* the
|
||||||
|
code reordering process, and not after. As an example, the output of this
|
||||||
|
code is the same as it would be with code reordering disabled.
|
||||||
|
|
||||||
|
.. code-block:: nim
|
||||||
|
{.experimental: "codeReordering".}
|
||||||
|
|
||||||
|
proc x() =
|
||||||
|
echo(declared(foo))
|
||||||
|
|
||||||
|
var foo = 4
|
||||||
|
|
||||||
|
x() # "false"
|
||||||
|
|
||||||
|
It is important to note that reordering *only* works for symbols at top level
|
||||||
|
scope. Therefore, the following will *fail to compile:*
|
||||||
|
|
||||||
|
.. code-block:: nim
|
||||||
|
{.experimental: "codeReordering".}
|
||||||
|
|
||||||
|
proc a() =
|
||||||
|
b()
|
||||||
|
proc b() =
|
||||||
|
echo("Hello!")
|
||||||
|
|
||||||
|
a()
|
||||||
|
|
||||||
Compiler Messages
|
Compiler Messages
|
||||||
=================
|
=================
|
||||||
|
|
@ -6943,55 +7048,6 @@ the created global variables within a module is not defined, but all of them
|
||||||
will be initialized after any top-level variables in their originating module
|
will be initialized after any top-level variables in their originating module
|
||||||
and before any variable in a module that imports it.
|
and before any variable in a module that imports it.
|
||||||
|
|
||||||
|
|
||||||
..
|
|
||||||
NoForward pragma
|
|
||||||
----------------
|
|
||||||
The ``noforward`` pragma can be used to turn on and off a special compilation
|
|
||||||
mode that to large extent eliminates the need for forward declarations. In this
|
|
||||||
mode, the proc definitions may appear out of order and the compiler will postpone
|
|
||||||
their semantic analysis and compilation until it actually needs to generate code
|
|
||||||
using the definitions. In this regard, this mode is similar to the modus operandi
|
|
||||||
of dynamic scripting languages, where the function calls are not resolved until
|
|
||||||
the code is executed. Here is the detailed algorithm taken by the compiler:
|
|
||||||
|
|
||||||
1. When a callable symbol is first encountered, the compiler will only note the
|
|
||||||
symbol callable name and it will add it to the appropriate overload set in the
|
|
||||||
current scope. At this step, it won't try to resolve any of the type expressions
|
|
||||||
used in the signature of the symbol (so they can refer to other not yet defined
|
|
||||||
symbols).
|
|
||||||
|
|
||||||
2. When a top level call is encountered (usually at the very end of the module),
|
|
||||||
the compiler will try to determine the actual types of all of the symbols in the
|
|
||||||
matching overload set. This is a potentially recursive process as the signatures
|
|
||||||
of the symbols may include other call expressions, whose types will be resolved
|
|
||||||
at this point too.
|
|
||||||
|
|
||||||
3. Finally, after the best overload is picked, the compiler will start
|
|
||||||
compiling the body of the respective symbol. This in turn will lead the
|
|
||||||
compiler to discover more call expressions that need to be resolved and steps
|
|
||||||
2 and 3 will be repeated as necessary.
|
|
||||||
|
|
||||||
Please note that if a callable symbol is never used in this scenario, its body
|
|
||||||
will never be compiled. This is the default behavior leading to best compilation
|
|
||||||
times, but if exhaustive compilation of all definitions is required, using
|
|
||||||
``nim check`` provides this option as well.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
.. code-block:: nim
|
|
||||||
|
|
||||||
{.noforward: on.}
|
|
||||||
|
|
||||||
proc foo(x: int) =
|
|
||||||
bar x
|
|
||||||
|
|
||||||
proc bar(x: int) =
|
|
||||||
echo x
|
|
||||||
|
|
||||||
foo(10)
|
|
||||||
|
|
||||||
|
|
||||||
pragma pragma
|
pragma pragma
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ Tools available with Nim
|
||||||
The standard distribution ships with the following tools:
|
The standard distribution ships with the following tools:
|
||||||
|
|
||||||
- | `Documentation generator <docgen.html>`_
|
- | `Documentation generator <docgen.html>`_
|
||||||
| The builtin document generator ``nim doc2`` generates HTML documentation
|
| The builtin document generator ``nim doc`` generates HTML documentation
|
||||||
from ``.nim`` source files.
|
from ``.nim`` source files.
|
||||||
|
|
||||||
- | `Nimsuggest for IDE support <nimsuggest.html>`_
|
- | `Nimsuggest for IDE support <nimsuggest.html>`_
|
||||||
|
|
@ -13,17 +13,8 @@ The standard distribution ships with the following tools:
|
||||||
and obtain useful information like definition of symbols or suggestions for
|
and obtain useful information like definition of symbols or suggestions for
|
||||||
completion.
|
completion.
|
||||||
|
|
||||||
- | `Nim Installation Generator <niminst.html>`_
|
|
||||||
| How to generate a nice installer for your Nim program.
|
|
||||||
|
|
||||||
- | `C2nim <c2nim.html>`_
|
- | `C2nim <c2nim.html>`_
|
||||||
| C to Nim source converter. Translates C header files to Nim.
|
| C to Nim source converter. Translates C header files to Nim.
|
||||||
|
|
||||||
- | `nimgrep <nimgrep.html>`_
|
- | `nimgrep <nimgrep.html>`_
|
||||||
| Nim search and replace utility.
|
| Nim search and replace utility.
|
||||||
|
|
||||||
- | `endb <endb.html>`_
|
|
||||||
| Nim's slow platform independent embedded debugger.
|
|
||||||
|
|
||||||
- | `estp <estp.html>`_
|
|
||||||
| Nim's slow platform independent embedded stack trace profiler.
|
|
||||||
88
koch.nim
88
koch.nim
|
|
@ -23,6 +23,8 @@ when defined(i386) and defined(windows) and defined(vcc):
|
||||||
import
|
import
|
||||||
os, strutils, parseopt, osproc, streams
|
os, strutils, parseopt, osproc, streams
|
||||||
|
|
||||||
|
import tools / kochdocs
|
||||||
|
|
||||||
const VersionAsString = system.NimVersion
|
const VersionAsString = system.NimVersion
|
||||||
|
|
||||||
const
|
const
|
||||||
|
|
@ -49,9 +51,7 @@ Boot options:
|
||||||
(not needed on Windows)
|
(not needed on Windows)
|
||||||
|
|
||||||
Commands for core developers:
|
Commands for core developers:
|
||||||
web [options] generates the website and the full documentation
|
docs [options] generates the full documentation
|
||||||
(see `nimweb.nim` for cmd line options)
|
|
||||||
website [options] generates only the website
|
|
||||||
csource -d:release builds the C sources for installation
|
csource -d:release builds the C sources for installation
|
||||||
pdf builds the PDF documentation
|
pdf builds the PDF documentation
|
||||||
zip builds the installation zip package
|
zip builds the installation zip package
|
||||||
|
|
@ -67,13 +67,6 @@ Web options:
|
||||||
build the official docs, use UA-48159761-1
|
build the official docs, use UA-48159761-1
|
||||||
"""
|
"""
|
||||||
|
|
||||||
const gaCode = " --googleAnalytics:UA-48159761-1"
|
|
||||||
|
|
||||||
proc exe(f: string): string =
|
|
||||||
result = addFileExt(f, ExeExt)
|
|
||||||
when defined(windows):
|
|
||||||
result = result.replace('/','\\')
|
|
||||||
|
|
||||||
template withDir(dir, body) =
|
template withDir(dir, body) =
|
||||||
let old = getCurrentDir()
|
let old = getCurrentDir()
|
||||||
try:
|
try:
|
||||||
|
|
@ -82,43 +75,6 @@ template withDir(dir, body) =
|
||||||
finally:
|
finally:
|
||||||
setCurrentdir(old)
|
setCurrentdir(old)
|
||||||
|
|
||||||
proc findNim(): string =
|
|
||||||
var nim = "nim".exe
|
|
||||||
result = "bin" / nim
|
|
||||||
if existsFile(result): return
|
|
||||||
for dir in split(getEnv("PATH"), PathSep):
|
|
||||||
if existsFile(dir / nim): return dir / nim
|
|
||||||
# assume there is a symlink to the exe or something:
|
|
||||||
return nim
|
|
||||||
|
|
||||||
proc exec(cmd: string, errorcode: int = QuitFailure, additionalPath = "") =
|
|
||||||
let prevPath = getEnv("PATH")
|
|
||||||
if additionalPath.len > 0:
|
|
||||||
var absolute = additionalPATH
|
|
||||||
if not absolute.isAbsolute:
|
|
||||||
absolute = getCurrentDir() / absolute
|
|
||||||
echo("Adding to $PATH: ", absolute)
|
|
||||||
putEnv("PATH", (if prevPath.len > 0: prevPath & PathSep else: "") & absolute)
|
|
||||||
echo(cmd)
|
|
||||||
if execShellCmd(cmd) != 0: quit("FAILURE", errorcode)
|
|
||||||
putEnv("PATH", prevPath)
|
|
||||||
|
|
||||||
proc nimexec(cmd: string) =
|
|
||||||
exec findNim() & " " & cmd
|
|
||||||
|
|
||||||
proc execCleanPath(cmd: string,
|
|
||||||
additionalPath = ""; errorcode: int = QuitFailure) =
|
|
||||||
# simulate a poor man's virtual environment
|
|
||||||
let prevPath = getEnv("PATH")
|
|
||||||
when defined(windows):
|
|
||||||
let CleanPath = r"$1\system32;$1;$1\System32\Wbem" % getEnv"SYSTEMROOT"
|
|
||||||
else:
|
|
||||||
const CleanPath = r"/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin"
|
|
||||||
putEnv("PATH", CleanPath & PathSep & additionalPath)
|
|
||||||
echo(cmd)
|
|
||||||
if execShellCmd(cmd) != 0: quit("FAILURE", errorcode)
|
|
||||||
putEnv("PATH", prevPath)
|
|
||||||
|
|
||||||
proc testUnixInstall() =
|
proc testUnixInstall() =
|
||||||
let oldCurrentDir = getCurrentDir()
|
let oldCurrentDir = getCurrentDir()
|
||||||
try:
|
try:
|
||||||
|
|
@ -136,7 +92,7 @@ proc testUnixInstall() =
|
||||||
execCleanPath("./bin/nim c koch.nim")
|
execCleanPath("./bin/nim c koch.nim")
|
||||||
execCleanPath("./koch boot -d:release", destDir / "bin")
|
execCleanPath("./koch boot -d:release", destDir / "bin")
|
||||||
# check the docs build:
|
# check the docs build:
|
||||||
execCleanPath("./koch web", destDir / "bin")
|
execCleanPath("./koch docs", destDir / "bin")
|
||||||
# check nimble builds:
|
# check nimble builds:
|
||||||
execCleanPath("./koch tools")
|
execCleanPath("./koch tools")
|
||||||
# check the tests work:
|
# check the tests work:
|
||||||
|
|
@ -210,7 +166,7 @@ proc buildNimble(latest: bool) =
|
||||||
else:
|
else:
|
||||||
exec("git checkout -f stable")
|
exec("git checkout -f stable")
|
||||||
exec("git pull")
|
exec("git pull")
|
||||||
nimexec("c --noNimblePath -p:compiler --nilseqs:on -d:release " & installDir / "src/nimble.nim")
|
nimexec("c --noNimblePath -p:compiler --nilseqs:on " & installDir / "src/nimble.nim")
|
||||||
copyExe(installDir / "src/nimble".exe, "bin/nimble".exe)
|
copyExe(installDir / "src/nimble".exe, "bin/nimble".exe)
|
||||||
|
|
||||||
proc bundleNimsuggest(buildExe: bool) =
|
proc bundleNimsuggest(buildExe: bool) =
|
||||||
|
|
@ -295,18 +251,19 @@ proc install(args: string) =
|
||||||
geninstall()
|
geninstall()
|
||||||
exec("sh ./install.sh $#" % args)
|
exec("sh ./install.sh $#" % args)
|
||||||
|
|
||||||
proc web(args: string) =
|
when false:
|
||||||
nimexec("js tools/dochack/dochack.nim")
|
proc web(args: string) =
|
||||||
nimexec("cc -r tools/nimweb.nim $# web/website.ini --putenv:nimversion=$#" %
|
nimexec("js tools/dochack/dochack.nim")
|
||||||
[args, VersionAsString])
|
nimexec("cc -r tools/nimweb.nim $# web/website.ini --putenv:nimversion=$#" %
|
||||||
|
[args, VersionAsString])
|
||||||
|
|
||||||
proc website(args: string) =
|
proc website(args: string) =
|
||||||
nimexec("cc -r tools/nimweb.nim $# --website web/website.ini --putenv:nimversion=$#" %
|
nimexec("cc -r tools/nimweb.nim $# --website web/website.ini --putenv:nimversion=$#" %
|
||||||
[args, VersionAsString])
|
[args, VersionAsString])
|
||||||
|
|
||||||
proc pdf(args="") =
|
proc pdf(args="") =
|
||||||
exec("$# cc -r tools/nimweb.nim $# --pdf web/website.ini --putenv:nimversion=$#" %
|
exec("$# cc -r tools/nimweb.nim $# --pdf web/website.ini --putenv:nimversion=$#" %
|
||||||
[findNim(), args, VersionAsString], additionalPATH=findNim().splitFile.dir)
|
[findNim(), args, VersionAsString], additionalPATH=findNim().splitFile.dir)
|
||||||
|
|
||||||
# -------------- boot ---------------------------------------------------------
|
# -------------- boot ---------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -429,7 +386,7 @@ proc winRelease*() =
|
||||||
# anymore!
|
# anymore!
|
||||||
# Build -docs file:
|
# Build -docs file:
|
||||||
when true:
|
when true:
|
||||||
web(gaCode)
|
buildDocs(gaCode)
|
||||||
withDir "web/upload/" & VersionAsString:
|
withDir "web/upload/" & VersionAsString:
|
||||||
exec "7z a -tzip docs-$#.zip *.html" % VersionAsString
|
exec "7z a -tzip docs-$#.zip *.html" % VersionAsString
|
||||||
overwriteFile "web/upload/$1/docs-$1.zip" % VersionAsString,
|
overwriteFile "web/upload/$1/docs-$1.zip" % VersionAsString,
|
||||||
|
|
@ -553,14 +510,11 @@ when isMainModule:
|
||||||
case normalize(op.key)
|
case normalize(op.key)
|
||||||
of "boot": boot(op.cmdLineRest)
|
of "boot": boot(op.cmdLineRest)
|
||||||
of "clean": clean(op.cmdLineRest)
|
of "clean": clean(op.cmdLineRest)
|
||||||
of "web": web(op.cmdLineRest)
|
of "doc", "docs": buildDocs(op.cmdLineRest)
|
||||||
of "doc", "docs": web("--onlyDocs " & op.cmdLineRest)
|
of "doc0", "docs0":
|
||||||
of "json2": web("--json2 " & op.cmdLineRest)
|
|
||||||
of "website": website(op.cmdLineRest & gaCode)
|
|
||||||
of "web0":
|
|
||||||
# undocumented command for Araq-the-merciful:
|
# undocumented command for Araq-the-merciful:
|
||||||
web(op.cmdLineRest & gaCode)
|
buildDocs(op.cmdLineRest & gaCode)
|
||||||
of "pdf": pdf()
|
of "pdf": buildPdfDoc(op.cmdLineRest, "doc/pdf")
|
||||||
of "csource", "csources": csource(op.cmdLineRest)
|
of "csource", "csources": csource(op.cmdLineRest)
|
||||||
of "zip": zip(op.cmdLineRest)
|
of "zip": zip(op.cmdLineRest)
|
||||||
of "xz": xz(op.cmdLineRest)
|
of "xz": xz(op.cmdLineRest)
|
||||||
|
|
|
||||||
|
|
@ -85,8 +85,8 @@ proc init(p: var CodeBlockParams) =
|
||||||
proc initRstGenerator*(g: var RstGenerator, target: OutputTarget,
|
proc initRstGenerator*(g: var RstGenerator, target: OutputTarget,
|
||||||
config: StringTableRef, filename: string,
|
config: StringTableRef, filename: string,
|
||||||
options: RstParseOptions,
|
options: RstParseOptions,
|
||||||
findFile: FindFileHandler=nil,
|
findFile: FindFileHandler = nil,
|
||||||
msgHandler: MsgHandler=nil) =
|
msgHandler: MsgHandler = nil) =
|
||||||
## Initializes a ``RstGenerator``.
|
## Initializes a ``RstGenerator``.
|
||||||
##
|
##
|
||||||
## You need to call this before using a ``RstGenerator`` with any other
|
## You need to call this before using a ``RstGenerator`` with any other
|
||||||
|
|
@ -255,9 +255,9 @@ proc renderRstToOut*(d: var RstGenerator, n: PRstNode, result: var string)
|
||||||
## .. code-block:: nim
|
## .. code-block:: nim
|
||||||
##
|
##
|
||||||
## # ...configure gen and rst vars...
|
## # ...configure gen and rst vars...
|
||||||
## var generatedHTML = ""
|
## var generatedHtml = ""
|
||||||
## renderRstToOut(gen, rst, generatedHTML)
|
## renderRstToOut(gen, rst, generatedHtml)
|
||||||
## echo generatedHTML
|
## echo generatedHtml
|
||||||
|
|
||||||
proc renderAux(d: PDoc, n: PRstNode, result: var string) =
|
proc renderAux(d: PDoc, n: PRstNode, result: var string) =
|
||||||
for i in countup(0, len(n)-1): renderRstToOut(d, n.sons[i], result)
|
for i in countup(0, len(n)-1): renderRstToOut(d, n.sons[i], result)
|
||||||
|
|
@ -282,20 +282,26 @@ proc quoteIndexColumn(text: string): string =
|
||||||
## * ``"\\"`` => ``"\\\\"``
|
## * ``"\\"`` => ``"\\\\"``
|
||||||
## * ``"\n"`` => ``"\\n"``
|
## * ``"\n"`` => ``"\\n"``
|
||||||
## * ``"\t"`` => ``"\\t"``
|
## * ``"\t"`` => ``"\\t"``
|
||||||
result = text.replace("\\", "\\\\").replace("\n", "\\n").replace("\t", "\\t")
|
result = newStringOfCap(text.len + 3)
|
||||||
|
for c in text:
|
||||||
|
case c
|
||||||
|
of '\\': result.add "\\"
|
||||||
|
of '\L': result.add "\\n"
|
||||||
|
of '\C': discard
|
||||||
|
of '\t': result.add "\\t"
|
||||||
|
else: result.add c
|
||||||
|
|
||||||
proc unquoteIndexColumn(text: string): string =
|
proc unquoteIndexColumn(text: string): string =
|
||||||
## Returns the unquoted version generated by ``quoteIndexColumn``.
|
## Returns the unquoted version generated by ``quoteIndexColumn``.
|
||||||
result = text.replace("\\t", "\t").replace("\\n", "\n").replace("\\\\", "\\")
|
result = text.multiReplace(("\\t", "\t"), ("\\n", "\n"), ("\\\\", "\\"))
|
||||||
|
|
||||||
proc setIndexTerm*(d: var RstGenerator, id, term: string,
|
proc setIndexTerm*(d: var RstGenerator, htmlFile, id, term: string,
|
||||||
linkTitle, linkDesc = "") =
|
linkTitle, linkDesc = "") =
|
||||||
## Adds a `term` to the index using the specified hyperlink identifier.
|
## Adds a `term` to the index using the specified hyperlink identifier.
|
||||||
##
|
##
|
||||||
## A new entry will be added to the index using the format
|
## A new entry will be added to the index using the format
|
||||||
## ``term<tab>file#id``. The file part will come from the `filename`
|
## ``term<tab>file#id``. The file part will come from the `htmlFile`
|
||||||
## parameter used in a previous call to the `initRstGenerator()
|
## parameter.
|
||||||
## <#initRstGenerator>`_ proc.
|
|
||||||
##
|
##
|
||||||
## The `id` will be appended with a hash character only if its length is not
|
## The `id` will be appended with a hash character only if its length is not
|
||||||
## zero, otherwise no specific anchor will be generated. In general you
|
## zero, otherwise no specific anchor will be generated. In general you
|
||||||
|
|
@ -316,7 +322,6 @@ proc setIndexTerm*(d: var RstGenerator, id, term: string,
|
||||||
entry = term
|
entry = term
|
||||||
isTitle = false
|
isTitle = false
|
||||||
entry.add('\t')
|
entry.add('\t')
|
||||||
let htmlFile = changeFileExt(extractFilename(d.filename), HtmlExt)
|
|
||||||
entry.add(htmlFile)
|
entry.add(htmlFile)
|
||||||
if id.len > 0:
|
if id.len > 0:
|
||||||
entry.add('#')
|
entry.add('#')
|
||||||
|
|
@ -356,7 +361,7 @@ proc renderIndexTerm*(d: PDoc, n: PRstNode, result: var string) =
|
||||||
|
|
||||||
var term = ""
|
var term = ""
|
||||||
renderAux(d, n, term)
|
renderAux(d, n, term)
|
||||||
setIndexTerm(d, id, term, d.currentSection)
|
setIndexTerm(d, changeFileExt(extractFilename(d.filename), HtmlExt), id, term, d.currentSection)
|
||||||
dispA(d.target, result, "<span id=\"$1\">$2</span>", "$2\\label{$1}",
|
dispA(d.target, result, "<span id=\"$1\">$2</span>", "$2\\label{$1}",
|
||||||
[id, term])
|
[id, term])
|
||||||
|
|
||||||
|
|
@ -364,15 +369,15 @@ type
|
||||||
IndexEntry = object
|
IndexEntry = object
|
||||||
keyword: string
|
keyword: string
|
||||||
link: string
|
link: string
|
||||||
linkTitle: string ## If not nil, contains a prettier text for the href
|
linkTitle: string ## contains a prettier text for the href
|
||||||
linkDesc: string ## If not nil, the title attribute of the final href
|
linkDesc: string ## the title attribute of the final href
|
||||||
|
|
||||||
IndexedDocs = Table[IndexEntry, seq[IndexEntry]] ## \
|
IndexedDocs = Table[IndexEntry, seq[IndexEntry]] ## \
|
||||||
## Contains the index sequences for doc types.
|
## Contains the index sequences for doc types.
|
||||||
##
|
##
|
||||||
## The key is a *fake* IndexEntry which will contain the title of the
|
## The key is a *fake* IndexEntry which will contain the title of the
|
||||||
## document in the `keyword` field and `link` will contain the html
|
## document in the `keyword` field and `link` will contain the html
|
||||||
## filename for the document. `linkTitle` and `linkDesc` will be nil.
|
## filename for the document. `linkTitle` and `linkDesc` will be empty.
|
||||||
##
|
##
|
||||||
## The value indexed by this IndexEntry is a sequence with the real index
|
## The value indexed by this IndexEntry is a sequence with the real index
|
||||||
## entries found in the ``.idx`` file.
|
## entries found in the ``.idx`` file.
|
||||||
|
|
@ -433,13 +438,13 @@ proc generateSymbolIndex(symbols: seq[IndexEntry]): string =
|
||||||
var i = 0
|
var i = 0
|
||||||
while i < symbols.len:
|
while i < symbols.len:
|
||||||
let keyword = symbols[i].keyword
|
let keyword = symbols[i].keyword
|
||||||
let cleaned_keyword = keyword.escapeLink
|
let cleanedKeyword = keyword.escapeLink
|
||||||
result.addf("<dt><a name=\"$2\" href=\"#$2\"><span>$1:</span></a></dt><dd><ul class=\"simple\">\n",
|
result.addf("<dt><a name=\"$2\" href=\"#$2\"><span>$1:</span></a></dt><dd><ul class=\"simple\">\n",
|
||||||
[keyword, cleaned_keyword])
|
[keyword, cleanedKeyword])
|
||||||
var j = i
|
var j = i
|
||||||
while j < symbols.len and keyword == symbols[j].keyword:
|
while j < symbols.len and keyword == symbols[j].keyword:
|
||||||
let
|
let
|
||||||
url = symbols[j].link.escapeLink
|
url = symbols[j].link #.escapeLink
|
||||||
text = if symbols[j].linkTitle.len > 0: symbols[j].linkTitle else: url
|
text = if symbols[j].linkTitle.len > 0: symbols[j].linkTitle else: url
|
||||||
desc = if symbols[j].linkDesc.len > 0: symbols[j].linkDesc else: ""
|
desc = if symbols[j].linkDesc.len > 0: symbols[j].linkDesc else: ""
|
||||||
if desc.len > 0:
|
if desc.len > 0:
|
||||||
|
|
@ -462,12 +467,12 @@ proc isDocumentationTitle(hyperlink: string): bool =
|
||||||
## for a more detailed explanation.
|
## for a more detailed explanation.
|
||||||
result = hyperlink.find('#') < 0
|
result = hyperlink.find('#') < 0
|
||||||
|
|
||||||
proc stripTOCLevel(s: string): tuple[level: int, text: string] =
|
proc stripTocLevel(s: string): tuple[level: int, text: string] =
|
||||||
## Returns the *level* of the toc along with the text without it.
|
## Returns the *level* of the toc along with the text without it.
|
||||||
for c in 0 .. <s.len:
|
for c in 0 ..< s.len:
|
||||||
result.level = c
|
result.level = c
|
||||||
if s[c] != ' ': break
|
if s[c] != ' ': break
|
||||||
result.text = s[result.level .. <s.len]
|
result.text = s[result.level ..< s.len]
|
||||||
|
|
||||||
proc indentToLevel(level: var int, newLevel: int): string =
|
proc indentToLevel(level: var int, newLevel: int): string =
|
||||||
## Returns the sequence of <ul>|</ul> characters to switch to `newLevel`.
|
## Returns the sequence of <ul>|</ul> characters to switch to `newLevel`.
|
||||||
|
|
@ -483,7 +488,7 @@ proc indentToLevel(level: var int, newLevel: int): string =
|
||||||
result = repeat("</ul></li>", level - newLevel)
|
result = repeat("</ul></li>", level - newLevel)
|
||||||
level = newLevel
|
level = newLevel
|
||||||
|
|
||||||
proc generateDocumentationTOC(entries: seq[IndexEntry]): string =
|
proc generateDocumentationToc(entries: seq[IndexEntry]): string =
|
||||||
## Returns the sequence of index entries in an HTML hierarchical list.
|
## Returns the sequence of index entries in an HTML hierarchical list.
|
||||||
result = ""
|
result = ""
|
||||||
# Build a list of levels and extracted titles to make processing easier.
|
# Build a list of levels and extracted titles to make processing easier.
|
||||||
|
|
@ -495,7 +500,7 @@ proc generateDocumentationTOC(entries: seq[IndexEntry]): string =
|
||||||
level = 1
|
level = 1
|
||||||
levels.newSeq(entries.len)
|
levels.newSeq(entries.len)
|
||||||
for entry in entries:
|
for entry in entries:
|
||||||
let (rawLevel, rawText) = stripTOCLevel(entry.linkTitle or entry.keyword)
|
let (rawLevel, rawText) = stripTocLevel(entry.linkTitle or entry.keyword)
|
||||||
if rawLevel < 1:
|
if rawLevel < 1:
|
||||||
# This is a normal symbol, push it *inside* one level from the last one.
|
# This is a normal symbol, push it *inside* one level from the last one.
|
||||||
levels[L].level = level + 1
|
levels[L].level = level + 1
|
||||||
|
|
@ -519,9 +524,9 @@ proc generateDocumentationTOC(entries: seq[IndexEntry]): string =
|
||||||
titleTag = levels[L].text
|
titleTag = levels[L].text
|
||||||
else:
|
else:
|
||||||
result.add(level.indentToLevel(levels[L].level))
|
result.add(level.indentToLevel(levels[L].level))
|
||||||
result.addf("""<li><a class="reference" data-doc-search-tag="$1" href="$2">
|
result.addf("""<li><a class="reference" data-doc-search-tag="$1: $2" href="$3">
|
||||||
$3</a></li>
|
$3</a></li>
|
||||||
""", [titleTag & " : " & levels[L].text, link, levels[L].text])
|
""", [titleTag, levels[L].text, link, levels[L].text])
|
||||||
inc L
|
inc L
|
||||||
result.add(level.indentToLevel(1) & "</ul>\n")
|
result.add(level.indentToLevel(1) & "</ul>\n")
|
||||||
|
|
||||||
|
|
@ -534,7 +539,7 @@ proc generateDocumentationIndex(docs: IndexedDocs): string =
|
||||||
sort(titles, cmp)
|
sort(titles, cmp)
|
||||||
|
|
||||||
for title in titles:
|
for title in titles:
|
||||||
let tocList = generateDocumentationTOC(docs.getOrDefault(title))
|
let tocList = generateDocumentationToc(docs.getOrDefault(title))
|
||||||
result.add("<ul><li><a href=\"" &
|
result.add("<ul><li><a href=\"" &
|
||||||
title.link & "\">" & title.keyword & "</a>\n" & tocList & "</li></ul>\n")
|
title.link & "\">" & title.keyword & "</a>\n" & tocList & "</li></ul>\n")
|
||||||
|
|
||||||
|
|
@ -575,8 +580,8 @@ proc readIndexDir(dir: string):
|
||||||
setLen(result.symbols, 0)
|
setLen(result.symbols, 0)
|
||||||
var L = 0
|
var L = 0
|
||||||
# Scan index files and build the list of symbols.
|
# Scan index files and build the list of symbols.
|
||||||
for kind, path in walkDir(dir):
|
for path in walkDirRec(dir):
|
||||||
if kind == pcFile and path.endsWith(IndexExt):
|
if path.endsWith(IndexExt):
|
||||||
var
|
var
|
||||||
fileEntries: seq[IndexEntry]
|
fileEntries: seq[IndexEntry]
|
||||||
title: IndexEntry
|
title: IndexEntry
|
||||||
|
|
@ -606,7 +611,7 @@ proc readIndexDir(dir: string):
|
||||||
inc F
|
inc F
|
||||||
# Depending on type add this to the list of symbols or table of APIs.
|
# Depending on type add this to the list of symbols or table of APIs.
|
||||||
if title.keyword.len == 0:
|
if title.keyword.len == 0:
|
||||||
for i in 0 .. <F:
|
for i in 0 ..< F:
|
||||||
# Don't add to symbols TOC entries (they start with a whitespace).
|
# Don't add to symbols TOC entries (they start with a whitespace).
|
||||||
let toc = fileEntries[i].linkTitle
|
let toc = fileEntries[i].linkTitle
|
||||||
if toc.len > 0 and toc[0] == ' ':
|
if toc.len > 0 and toc[0] == ' ':
|
||||||
|
|
@ -615,7 +620,14 @@ proc readIndexDir(dir: string):
|
||||||
setLen(result.symbols, L + 1)
|
setLen(result.symbols, L + 1)
|
||||||
result.symbols[L] = fileEntries[i]
|
result.symbols[L] = fileEntries[i]
|
||||||
inc L
|
inc L
|
||||||
result.modules.add(path.splitFile.name)
|
if fileEntries.len > 0:
|
||||||
|
var x = fileEntries[0].link
|
||||||
|
let i = find(x, '#')
|
||||||
|
if i > 0:
|
||||||
|
x = x.substr(0, i-1)
|
||||||
|
if i != 0:
|
||||||
|
# don't add entries starting with '#'
|
||||||
|
result.modules.add(x.changeFileExt(""))
|
||||||
else:
|
else:
|
||||||
# Generate the symbolic anchor for index quickjumps.
|
# Generate the symbolic anchor for index quickjumps.
|
||||||
title.linkTitle = "doc_toc_" & $result.docs.len
|
title.linkTitle = "doc_toc_" & $result.docs.len
|
||||||
|
|
@ -662,10 +674,11 @@ proc mergeIndexes*(dir: string): string =
|
||||||
result.add(generateModuleJumps(modules))
|
result.add(generateModuleJumps(modules))
|
||||||
result.add("<p />")
|
result.add("<p />")
|
||||||
|
|
||||||
# Generate the HTML block with API documents.
|
when false:
|
||||||
if docs.len > 0:
|
# Generate the HTML block with API documents.
|
||||||
result.add("<h2>Documentation files</h2>\n")
|
if docs.len > 0:
|
||||||
result.add(generateDocumentationIndex(docs))
|
result.add("<h2>Documentation files</h2>\n")
|
||||||
|
result.add(generateDocumentationIndex(docs))
|
||||||
|
|
||||||
# Generate the HTML block with symbols.
|
# Generate the HTML block with symbols.
|
||||||
if symbols.len > 0:
|
if symbols.len > 0:
|
||||||
|
|
@ -676,7 +689,7 @@ proc mergeIndexes*(dir: string): string =
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
proc stripTOCHTML(s: string): string =
|
proc stripTocHtml(s: string): string =
|
||||||
## Ugly quick hack to remove HTML tags from TOC titles.
|
## Ugly quick hack to remove HTML tags from TOC titles.
|
||||||
##
|
##
|
||||||
## A TocEntry.header field already contains rendered HTML tags. Instead of
|
## A TocEntry.header field already contains rendered HTML tags. Instead of
|
||||||
|
|
@ -724,7 +737,7 @@ proc renderHeadline(d: PDoc, n: PRstNode, result: var string) =
|
||||||
|
|
||||||
# Generate index entry using spaces to indicate TOC level for the output HTML.
|
# Generate index entry using spaces to indicate TOC level for the output HTML.
|
||||||
assert n.level >= 0
|
assert n.level >= 0
|
||||||
setIndexTerm(d, refname, tmp.stripTOCHTML,
|
setIndexTerm(d, changeFileExt(extractFilename(d.filename), HtmlExt), refname, tmp.stripTocHtml,
|
||||||
spaces(max(0, n.level)) & tmp)
|
spaces(max(0, n.level)) & tmp)
|
||||||
|
|
||||||
proc renderOverline(d: PDoc, n: PRstNode, result: var string) =
|
proc renderOverline(d: PDoc, n: PRstNode, result: var string) =
|
||||||
|
|
@ -872,7 +885,7 @@ proc parseCodeBlockParams(d: PDoc, n: PRstNode): CodeBlockParams =
|
||||||
if result.langStr != "":
|
if result.langStr != "":
|
||||||
result.lang = getSourceLanguage(result.langStr)
|
result.lang = getSourceLanguage(result.langStr)
|
||||||
|
|
||||||
proc buildLinesHTMLTable(d: PDoc; params: CodeBlockParams, code: string):
|
proc buildLinesHtmlTable(d: PDoc; params: CodeBlockParams, code: string):
|
||||||
tuple[beginTable, endTable: string] =
|
tuple[beginTable, endTable: string] =
|
||||||
## Returns the necessary tags to start/end a code block in HTML.
|
## Returns the necessary tags to start/end a code block in HTML.
|
||||||
##
|
##
|
||||||
|
|
@ -922,7 +935,7 @@ proc renderCodeBlock(d: PDoc, n: PRstNode, result: var string) =
|
||||||
if params.testCmd.len > 0 and d.onTestSnippet != nil:
|
if params.testCmd.len > 0 and d.onTestSnippet != nil:
|
||||||
d.onTestSnippet(d, params.filename, params.testCmd, params.status, m.text)
|
d.onTestSnippet(d, params.filename, params.testCmd, params.status, m.text)
|
||||||
|
|
||||||
let (blockStart, blockEnd) = buildLinesHTMLTable(d, params, m.text)
|
let (blockStart, blockEnd) = buildLinesHtmlTable(d, params, m.text)
|
||||||
|
|
||||||
dispA(d.target, result, blockStart, "\\begin{rstpre}\n", [])
|
dispA(d.target, result, blockStart, "\\begin{rstpre}\n", [])
|
||||||
if params.lang == langNone:
|
if params.lang == langNone:
|
||||||
|
|
|
||||||
|
|
@ -317,7 +317,7 @@ macro scanf*(input: string; pattern: static[string]; results: varargs[typed]): b
|
||||||
|
|
||||||
template at(s: string; i: int): char = (if i < s.len: s[i] else: '\0')
|
template at(s: string; i: int): char = (if i < s.len: s[i] else: '\0')
|
||||||
template matchError() =
|
template matchError() =
|
||||||
error("type mismatch between pattern '$" & pattern[p] & "' (position: " & $p & ") and " & $getType(results[i]) &
|
error("type mismatch between pattern '$" & pattern[p] & "' (position: " & $p & ") and " & repr(getType(results[i])) &
|
||||||
" var '" & repr(results[i]) & "'")
|
" var '" & repr(results[i]) & "'")
|
||||||
|
|
||||||
var i = 0
|
var i = 0
|
||||||
|
|
|
||||||
|
|
@ -1237,6 +1237,8 @@ proc cmp*[T](x, y: T): int {.procvar.} =
|
||||||
|
|
||||||
proc cmp*(x, y: string): int {.noSideEffect, procvar.}
|
proc cmp*(x, y: string): int {.noSideEffect, procvar.}
|
||||||
## Compare proc for strings. More efficient than the generic version.
|
## Compare proc for strings. More efficient than the generic version.
|
||||||
|
## **Note**: The precise result values depend on the used C runtime library and
|
||||||
|
## can differ between operating systems!
|
||||||
|
|
||||||
proc `@`* [IDX, T](a: array[IDX, T]): seq[T] {.
|
proc `@`* [IDX, T](a: array[IDX, T]): seq[T] {.
|
||||||
magic: "ArrToSeq", nosideeffect.}
|
magic: "ArrToSeq", nosideeffect.}
|
||||||
|
|
@ -3127,8 +3129,8 @@ when not defined(JS): #and not defined(nimscript):
|
||||||
|
|
||||||
proc readLine*(f: File, line: var TaintedString): bool {.tags: [ReadIOEffect],
|
proc readLine*(f: File, line: var TaintedString): bool {.tags: [ReadIOEffect],
|
||||||
benign.}
|
benign.}
|
||||||
## reads a line of text from the file `f` into `line`. `line` must not be
|
## reads a line of text from the file `f` into `line`. May throw an IO
|
||||||
## ``nil``! May throw an IO exception.
|
## exception.
|
||||||
## A line of text may be delimited by ``LF`` or ``CRLF``. The newline
|
## A line of text may be delimited by ``LF`` or ``CRLF``. The newline
|
||||||
## character(s) are not part of the returned string. Returns ``false``
|
## character(s) are not part of the returned string. Returns ``false``
|
||||||
## if the end of the file has been reached, ``true`` otherwise. If
|
## if the end of the file has been reached, ``true`` otherwise. If
|
||||||
|
|
@ -4130,13 +4132,13 @@ template once*(body: untyped): untyped =
|
||||||
## re-executed on each module reload.
|
## re-executed on each module reload.
|
||||||
##
|
##
|
||||||
## .. code-block:: nim
|
## .. code-block:: nim
|
||||||
## proc draw(t: Triangle) =
|
|
||||||
## once:
|
|
||||||
## graphicsInit()
|
|
||||||
##
|
##
|
||||||
## line(t.p1, t.p2)
|
## proc draw(t: Triangle) =
|
||||||
## line(t.p2, t.p3)
|
## once:
|
||||||
## line(t.p3, t.p1)
|
## graphicsInit()
|
||||||
|
## line(t.p1, t.p2)
|
||||||
|
## line(t.p2, t.p3)
|
||||||
|
## line(t.p3, t.p1)
|
||||||
##
|
##
|
||||||
var alreadyExecuted {.global.} = false
|
var alreadyExecuted {.global.} = false
|
||||||
if not alreadyExecuted:
|
if not alreadyExecuted:
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,6 @@
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
#
|
#
|
||||||
|
|
||||||
when declared(ThisIsSystem):
|
|
||||||
# we are in system module:
|
|
||||||
{.pragma: codegenType, compilerproc.}
|
|
||||||
else:
|
|
||||||
{.pragma: codegenType.}
|
|
||||||
|
|
||||||
type
|
type
|
||||||
# This should be the same as ast.TTypeKind
|
# This should be the same as ast.TTypeKind
|
||||||
# many enum fields are not used at runtime
|
# many enum fields are not used at runtime
|
||||||
|
|
@ -79,7 +73,7 @@ type
|
||||||
tyVoidHidden
|
tyVoidHidden
|
||||||
|
|
||||||
TNimNodeKind = enum nkNone, nkSlot, nkList, nkCase
|
TNimNodeKind = enum nkNone, nkSlot, nkList, nkCase
|
||||||
TNimNode {.codegenType.} = object
|
TNimNode {.compilerProc.} = object
|
||||||
kind: TNimNodeKind
|
kind: TNimNodeKind
|
||||||
offset: int
|
offset: int
|
||||||
typ: ptr TNimType
|
typ: ptr TNimType
|
||||||
|
|
@ -92,7 +86,7 @@ type
|
||||||
ntfAcyclic = 1, # type cannot form a cycle
|
ntfAcyclic = 1, # type cannot form a cycle
|
||||||
ntfEnumHole = 2 # enum has holes and thus `$` for them needs the slow
|
ntfEnumHole = 2 # enum has holes and thus `$` for them needs the slow
|
||||||
# version
|
# version
|
||||||
TNimType {.codegenType.} = object
|
TNimType {.compilerProc.} = object
|
||||||
size: int
|
size: int
|
||||||
kind: TNimKind
|
kind: TNimKind
|
||||||
flags: set[TNimTypeFlag]
|
flags: set[TNimTypeFlag]
|
||||||
|
|
@ -109,6 +103,6 @@ type
|
||||||
PNimType = ptr TNimType
|
PNimType = ptr TNimType
|
||||||
|
|
||||||
when defined(nimTypeNames):
|
when defined(nimTypeNames):
|
||||||
var nimTypeRoot {.codegenType.}: PNimType
|
var nimTypeRoot {.compilerProc.}: PNimType
|
||||||
|
|
||||||
# node.len may be the ``first`` element of a set
|
# node.len may be the ``first`` element of a set
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ proc readLine(f: File, line: var TaintedString): bool =
|
||||||
var last = cast[ByteAddress](m) - cast[ByteAddress](addr line.string[0])
|
var last = cast[ByteAddress](m) - cast[ByteAddress](addr line.string[0])
|
||||||
if last > 0 and line.string[last-1] == '\c':
|
if last > 0 and line.string[last-1] == '\c':
|
||||||
line.string.setLen(last-1)
|
line.string.setLen(last-1)
|
||||||
return fgetsSuccess
|
return last > 1 or fgetsSuccess
|
||||||
# We have to distinguish between two possible cases:
|
# We have to distinguish between two possible cases:
|
||||||
# \0\l\0 => line ending in a null character.
|
# \0\l\0 => line ending in a null character.
|
||||||
# \0\l\l => last line without newline, null was put there by fgets.
|
# \0\l\l => last line without newline, null was put there by fgets.
|
||||||
|
|
@ -169,7 +169,7 @@ proc readLine(f: File, line: var TaintedString): bool =
|
||||||
if last < pos + sp - 1 and line.string[last+1] != '\0':
|
if last < pos + sp - 1 and line.string[last+1] != '\0':
|
||||||
dec last
|
dec last
|
||||||
line.string.setLen(last)
|
line.string.setLen(last)
|
||||||
return fgetsSuccess
|
return last > 0 or fgetsSuccess
|
||||||
else:
|
else:
|
||||||
# fgets will have inserted a null byte at the end of the string.
|
# fgets will have inserted a null byte at the end of the string.
|
||||||
dec sp
|
dec sp
|
||||||
|
|
|
||||||
32
nimdoc/tester.nim
Normal file
32
nimdoc/tester.nim
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
# Small program that runs the test cases for 'nim doc'.
|
||||||
|
|
||||||
|
import strutils, os
|
||||||
|
|
||||||
|
var
|
||||||
|
failures = 0
|
||||||
|
|
||||||
|
proc test(dir: string; fixup = false) =
|
||||||
|
putEnv("SOURCE_DATE_EPOCH", "100000")
|
||||||
|
if execShellCmd("nim doc --project --index:on -o:$1/htmldocs $1/testproject.nim" % dir) != 0:
|
||||||
|
quit("FAILURE: nim doc failed")
|
||||||
|
|
||||||
|
if execShellCmd("nim buildIndex -o:$1/htmldocs/theindex.html $1/htmldocs" % [dir]) != 0:
|
||||||
|
quit("FAILURE: nim buildIndex failed")
|
||||||
|
|
||||||
|
for expected in walkDirRec(dir / "expected/"):
|
||||||
|
let produced = expected.replace('\\', '/').replace("/expected/", "/htmldocs/")
|
||||||
|
if not fileExists(produced):
|
||||||
|
echo "FAILURE: files not found: ", produced
|
||||||
|
inc failures
|
||||||
|
elif readFile(expected) != readFile(produced):
|
||||||
|
echo "FAILURE: files differ: ", produced
|
||||||
|
discard execShellCmd("diff -uNdr " & expected & " " & produced)
|
||||||
|
inc failures
|
||||||
|
if fixup:
|
||||||
|
copyFile(produced, expected)
|
||||||
|
else:
|
||||||
|
echo "SUCCESS: files identical: ", produced
|
||||||
|
removeDir(dir / "htmldocs")
|
||||||
|
|
||||||
|
test("nimdoc/testproject", false)
|
||||||
|
if failures > 0: quit($failures & " failures occurred.")
|
||||||
1301
nimdoc/testproject/expected/subdir/subdir_b/utils.html
Normal file
1301
nimdoc/testproject/expected/subdir/subdir_b/utils.html
Normal file
File diff suppressed because it is too large
Load diff
1334
nimdoc/testproject/expected/testproject.html
Normal file
1334
nimdoc/testproject/expected/testproject.html
Normal file
File diff suppressed because it is too large
Load diff
1266
nimdoc/testproject/expected/theindex.html
Normal file
1266
nimdoc/testproject/expected/theindex.html
Normal file
File diff suppressed because it is too large
Load diff
10
nimdoc/testproject/subdir/subdir_b/utils.nim
Normal file
10
nimdoc/testproject/subdir/subdir_b/utils.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
|
||||||
|
type
|
||||||
|
SomeType* = enum
|
||||||
|
enumValueA,
|
||||||
|
enumValueB,
|
||||||
|
enumValueC
|
||||||
|
|
||||||
|
proc someType*(): SomeType =
|
||||||
|
## constructor.
|
||||||
|
SomeType(2)
|
||||||
22
nimdoc/testproject/testproject.nim
Normal file
22
nimdoc/testproject/testproject.nim
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
|
||||||
|
import subdir / subdir_b / utils
|
||||||
|
|
||||||
|
## This is the top level module.
|
||||||
|
runnableExamples:
|
||||||
|
import subdir / subdir_b / utils
|
||||||
|
doAssert bar(3, 4) == 7
|
||||||
|
foo(enumValueA, enumValueB)
|
||||||
|
|
||||||
|
|
||||||
|
template foo*(a, b: SomeType) =
|
||||||
|
## This does nothing
|
||||||
|
##
|
||||||
|
discard
|
||||||
|
|
||||||
|
proc bar*[T](a, b: T): T =
|
||||||
|
result = a + b
|
||||||
|
|
||||||
|
import std/macros
|
||||||
|
|
||||||
|
macro bar*(): untyped =
|
||||||
|
result = newStmtList()
|
||||||
0
nimdoc/testproject/testproject.nimble
Normal file
0
nimdoc/testproject/testproject.nimble
Normal file
|
|
@ -12,7 +12,7 @@
|
||||||
when not defined(nimpretty):
|
when not defined(nimpretty):
|
||||||
{.error: "This needs to be compiled with --define:nimPretty".}
|
{.error: "This needs to be compiled with --define:nimPretty".}
|
||||||
|
|
||||||
import ../compiler / [idents, msgs, ast, syntaxes, renderer, options]
|
import ../compiler / [idents, msgs, ast, syntaxes, renderer, options, pathutils]
|
||||||
|
|
||||||
import parseopt, strutils, os
|
import parseopt, strutils, os
|
||||||
|
|
||||||
|
|
@ -42,8 +42,8 @@ proc writeVersion() =
|
||||||
|
|
||||||
proc prettyPrint(infile, outfile: string) =
|
proc prettyPrint(infile, outfile: string) =
|
||||||
var conf = newConfigRef()
|
var conf = newConfigRef()
|
||||||
let fileIdx = fileInfoIdx(conf, infile)
|
let fileIdx = fileInfoIdx(conf, AbsoluteFile infile)
|
||||||
conf.outFile = outfile
|
conf.outFile = AbsoluteFile outfile
|
||||||
when defined(nimpretty2):
|
when defined(nimpretty2):
|
||||||
discard parseFile(fileIdx, newIdentCache(), conf)
|
discard parseFile(fileIdx, newIdentCache(), conf)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@ import compiler / [options, commands, modules, sem,
|
||||||
passes, passaux, msgs, nimconf,
|
passes, passaux, msgs, nimconf,
|
||||||
extccomp, condsyms,
|
extccomp, condsyms,
|
||||||
sigmatch, ast, scriptconfig,
|
sigmatch, ast, scriptconfig,
|
||||||
idents, modulegraphs, vm, prefixmatches, lineinfos, cmdlinehelper]
|
idents, modulegraphs, vm, prefixmatches, lineinfos, cmdlinehelper,
|
||||||
|
pathutils]
|
||||||
|
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
import winlean
|
import winlean
|
||||||
|
|
@ -158,10 +159,11 @@ proc symFromInfo(graph: ModuleGraph; trackPos: TLineInfo): PSym =
|
||||||
if m != nil and m.ast != nil:
|
if m != nil and m.ast != nil:
|
||||||
result = findNode(m.ast, trackPos)
|
result = findNode(m.ast, trackPos)
|
||||||
|
|
||||||
proc execute(cmd: IdeCmd, file, dirtyfile: string, line, col: int;
|
proc execute(cmd: IdeCmd, file, dirtyfile: AbsoluteFile, line, col: int;
|
||||||
graph: ModuleGraph) =
|
graph: ModuleGraph) =
|
||||||
let conf = graph.config
|
let conf = graph.config
|
||||||
myLog("cmd: " & $cmd & ", file: " & file & ", dirtyFile: " & dirtyfile &
|
myLog("cmd: " & $cmd & ", file: " & file.string &
|
||||||
|
", dirtyFile: " & dirtyfile.string &
|
||||||
"[" & $line & ":" & $col & "]")
|
"[" & $line & ":" & $col & "]")
|
||||||
conf.ideCmd = cmd
|
conf.ideCmd = cmd
|
||||||
if cmd == ideChk:
|
if cmd == ideChk:
|
||||||
|
|
@ -175,8 +177,8 @@ proc execute(cmd: IdeCmd, file, dirtyfile: string, line, col: int;
|
||||||
var isKnownFile = true
|
var isKnownFile = true
|
||||||
let dirtyIdx = fileInfoIdx(conf, file, isKnownFile)
|
let dirtyIdx = fileInfoIdx(conf, file, isKnownFile)
|
||||||
|
|
||||||
if dirtyfile.len != 0: msgs.setDirtyFile(conf, dirtyIdx, dirtyfile)
|
if not dirtyfile.isEmpty: msgs.setDirtyFile(conf, dirtyIdx, dirtyfile)
|
||||||
else: msgs.setDirtyFile(conf, dirtyIdx, "")
|
else: msgs.setDirtyFile(conf, dirtyIdx, AbsoluteFile"")
|
||||||
|
|
||||||
conf.m.trackPos = newLineInfo(dirtyIdx, line, col)
|
conf.m.trackPos = newLineInfo(dirtyIdx, line, col)
|
||||||
conf.m.trackPosAttached = false
|
conf.m.trackPosAttached = false
|
||||||
|
|
@ -186,7 +188,7 @@ proc execute(cmd: IdeCmd, file, dirtyfile: string, line, col: int;
|
||||||
if not isKnownFile:
|
if not isKnownFile:
|
||||||
graph.compileProject()
|
graph.compileProject()
|
||||||
if conf.suggestVersion == 0 and conf.ideCmd in {ideUse, ideDus} and
|
if conf.suggestVersion == 0 and conf.ideCmd in {ideUse, ideDus} and
|
||||||
dirtyfile.len == 0:
|
dirtyfile.isEmpty:
|
||||||
discard "no need to recompile anything"
|
discard "no need to recompile anything"
|
||||||
else:
|
else:
|
||||||
let modIdx = graph.parentModule(dirtyIdx)
|
let modIdx = graph.parentModule(dirtyIdx)
|
||||||
|
|
@ -204,12 +206,12 @@ proc execute(cmd: IdeCmd, file, dirtyfile: string, line, col: int;
|
||||||
proc executeEpc(cmd: IdeCmd, args: SexpNode;
|
proc executeEpc(cmd: IdeCmd, args: SexpNode;
|
||||||
graph: ModuleGraph) =
|
graph: ModuleGraph) =
|
||||||
let
|
let
|
||||||
file = args[0].getStr
|
file = AbsoluteFile args[0].getStr
|
||||||
line = args[1].getNum
|
line = args[1].getNum
|
||||||
column = args[2].getNum
|
column = args[2].getNum
|
||||||
var dirtyfile = ""
|
var dirtyfile = AbsoluteFile""
|
||||||
if len(args) > 3:
|
if len(args) > 3:
|
||||||
dirtyfile = args[3].getStr("")
|
dirtyfile = AbsoluteFile args[3].getStr("")
|
||||||
execute(cmd, file, dirtyfile, int(line), int(column), graph)
|
execute(cmd, file, dirtyfile, int(line), int(column), graph)
|
||||||
|
|
||||||
proc returnEpc(socket: Socket, uid: BiggestInt, s: SexpNode|string,
|
proc returnEpc(socket: Socket, uid: BiggestInt, s: SexpNode|string,
|
||||||
|
|
@ -431,11 +433,11 @@ proc execCmd(cmd: string; graph: ModuleGraph; cachedMsgs: CachedMsgs) =
|
||||||
i += parseInt(cmd, col, i)
|
i += parseInt(cmd, col, i)
|
||||||
|
|
||||||
if conf.ideCmd == ideKnown:
|
if conf.ideCmd == ideKnown:
|
||||||
results.send(Suggest(section: ideKnown, quality: ord(fileInfoKnown(conf, orig))))
|
results.send(Suggest(section: ideKnown, quality: ord(fileInfoKnown(conf, AbsoluteFile orig))))
|
||||||
else:
|
else:
|
||||||
if conf.ideCmd == ideChk:
|
if conf.ideCmd == ideChk:
|
||||||
for cm in cachedMsgs: errorHook(conf, cm.info, cm.msg, cm.sev)
|
for cm in cachedMsgs: errorHook(conf, cm.info, cm.msg, cm.sev)
|
||||||
execute(conf.ideCmd, orig, dirtyfile, line, col, graph)
|
execute(conf.ideCmd, AbsoluteFile orig, AbsoluteFile dirtyfile, line, col, graph)
|
||||||
sentinel()
|
sentinel()
|
||||||
|
|
||||||
proc recompileFullProject(graph: ModuleGraph) =
|
proc recompileFullProject(graph: ModuleGraph) =
|
||||||
|
|
@ -451,7 +453,7 @@ proc mainThread(graph: ModuleGraph) =
|
||||||
let conf = graph.config
|
let conf = graph.config
|
||||||
if gLogging:
|
if gLogging:
|
||||||
for it in conf.searchPaths:
|
for it in conf.searchPaths:
|
||||||
log(it)
|
log(it.string)
|
||||||
|
|
||||||
proc wrHook(line: string) {.closure.} =
|
proc wrHook(line: string) {.closure.} =
|
||||||
if gMode == mepc:
|
if gMode == mepc:
|
||||||
|
|
@ -496,7 +498,7 @@ proc mainCommand(graph: ModuleGraph) =
|
||||||
wantMainModule(conf)
|
wantMainModule(conf)
|
||||||
|
|
||||||
if not fileExists(conf.projectFull):
|
if not fileExists(conf.projectFull):
|
||||||
quit "cannot find file: " & conf.projectFull
|
quit "cannot find file: " & conf.projectFull.string
|
||||||
|
|
||||||
add(conf.searchPaths, conf.libpath)
|
add(conf.searchPaths, conf.libpath)
|
||||||
|
|
||||||
|
|
@ -518,9 +520,9 @@ proc mainCommand(graph: ModuleGraph) =
|
||||||
of mtcp: createThread(inputThread, replTcp, (gPort, gAddress))
|
of mtcp: createThread(inputThread, replTcp, (gPort, gAddress))
|
||||||
of mepc: createThread(inputThread, replEpc, (gPort, gAddress))
|
of mepc: createThread(inputThread, replEpc, (gPort, gAddress))
|
||||||
of mcmdsug: createThread(inputThread, replCmdline,
|
of mcmdsug: createThread(inputThread, replCmdline,
|
||||||
(gPort, "sug \"" & conf.projectFull & "\":" & gAddress))
|
(gPort, "sug \"" & conf.projectFull.string & "\":" & gAddress))
|
||||||
of mcmdcon: createThread(inputThread, replCmdline,
|
of mcmdcon: createThread(inputThread, replCmdline,
|
||||||
(gPort, "con \"" & conf.projectFull & "\":" & gAddress))
|
(gPort, "con \"" & conf.projectFull.string & "\":" & gAddress))
|
||||||
mainThread(graph)
|
mainThread(graph)
|
||||||
joinThread(inputThread)
|
joinThread(inputThread)
|
||||||
close(requests)
|
close(requests)
|
||||||
|
|
@ -602,11 +604,12 @@ proc handleCmdLine(cache: IdentCache; conf: ConfigRef) =
|
||||||
if binaryPath == "":
|
if binaryPath == "":
|
||||||
raise newException(IOError,
|
raise newException(IOError,
|
||||||
"Cannot find Nim standard library: Nim compiler not in PATH")
|
"Cannot find Nim standard library: Nim compiler not in PATH")
|
||||||
conf.prefixDir = binaryPath.splitPath().head.parentDir()
|
conf.prefixDir = AbsoluteDir binaryPath.splitPath().head.parentDir()
|
||||||
if not dirExists(conf.prefixDir / "lib"): conf.prefixDir = ""
|
if not dirExists(conf.prefixDir / RelativeDir"lib"):
|
||||||
|
conf.prefixDir = AbsoluteDir""
|
||||||
|
|
||||||
#msgs.writelnHook = proc (line: string) = log(line)
|
#msgs.writelnHook = proc (line: string) = log(line)
|
||||||
myLog("START " & conf.projectFull)
|
myLog("START " & conf.projectFull.string)
|
||||||
|
|
||||||
discard self.loadConfigsAndRunMainCommand(cache, conf)
|
discard self.loadConfigsAndRunMainCommand(cache, conf)
|
||||||
|
|
||||||
|
|
|
||||||
10
tests/ccgbugs/t8964.nim
Normal file
10
tests/ccgbugs/t8964.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
discard """
|
||||||
|
targets: "c cpp"
|
||||||
|
"""
|
||||||
|
|
||||||
|
from json import JsonParsingError
|
||||||
|
import marshal
|
||||||
|
|
||||||
|
const nothing = ""
|
||||||
|
doAssertRaises(JsonParsingError):
|
||||||
|
var bar = marshal.to[int](nothing)
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
targets: "cpp"
|
targets: "cpp"
|
||||||
output: "hello"
|
output: "hello"
|
||||||
cmd: "nim cpp --nilseqs:on $file"
|
cmd: "nim cpp --nilseqs:on --nimblePath:tests/deps $file"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# bug #3299
|
# bug #3299
|
||||||
|
|
|
||||||
1350
tests/deps/jester-#head/jester.nim
Normal file
1350
tests/deps/jester-#head/jester.nim
Normal file
File diff suppressed because it is too large
Load diff
22
tests/deps/jester-#head/jester.nimble
Normal file
22
tests/deps/jester-#head/jester.nimble
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
# Package
|
||||||
|
|
||||||
|
version = "0.4.0" # Be sure to update jester.jesterVer too!
|
||||||
|
author = "Dominik Picheta"
|
||||||
|
description = "A sinatra-like web framework for Nim."
|
||||||
|
license = "MIT"
|
||||||
|
|
||||||
|
skipFiles = @["todo.markdown"]
|
||||||
|
skipDirs = @["tests"]
|
||||||
|
|
||||||
|
# Deps
|
||||||
|
|
||||||
|
requires "nim >= 0.18.1"
|
||||||
|
|
||||||
|
when not defined(windows):
|
||||||
|
requires "httpbeast >= 0.2.0"
|
||||||
|
|
||||||
|
# For tests
|
||||||
|
requires "asynctools"
|
||||||
|
|
||||||
|
task test, "Runs the test suite.":
|
||||||
|
exec "nimble c -y -r tests/tester"
|
||||||
141
tests/deps/jester-#head/jester/patterns.nim
Normal file
141
tests/deps/jester-#head/jester/patterns.nim
Normal file
|
|
@ -0,0 +1,141 @@
|
||||||
|
# Copyright (C) 2012-2018 Dominik Picheta
|
||||||
|
# MIT License - Look at license.txt for details.
|
||||||
|
import parseutils, tables
|
||||||
|
type
|
||||||
|
NodeType* = enum
|
||||||
|
NodeText, NodeField
|
||||||
|
Node* = object
|
||||||
|
typ*: NodeType
|
||||||
|
text*: string
|
||||||
|
optional*: bool
|
||||||
|
|
||||||
|
Pattern* = seq[Node]
|
||||||
|
|
||||||
|
#/show/@id/?
|
||||||
|
proc parsePattern*(pattern: string): Pattern =
|
||||||
|
result = @[]
|
||||||
|
template addNode(result: var Pattern, theT: NodeType, theText: string,
|
||||||
|
isOptional: bool): typed =
|
||||||
|
block:
|
||||||
|
var newNode: Node
|
||||||
|
newNode.typ = theT
|
||||||
|
newNode.text = theText
|
||||||
|
newNode.optional = isOptional
|
||||||
|
result.add(newNode)
|
||||||
|
|
||||||
|
template `{}`(s: string, i: int): char =
|
||||||
|
if i >= len(s):
|
||||||
|
'\0'
|
||||||
|
else:
|
||||||
|
s[i]
|
||||||
|
|
||||||
|
var i = 0
|
||||||
|
var text = ""
|
||||||
|
while i < pattern.len():
|
||||||
|
case pattern[i]
|
||||||
|
of '@':
|
||||||
|
# Add the stored text.
|
||||||
|
if text != "":
|
||||||
|
result.addNode(NodeText, text, false)
|
||||||
|
text = ""
|
||||||
|
# Parse named parameter.
|
||||||
|
inc(i) # Skip @
|
||||||
|
var nparam = ""
|
||||||
|
i += pattern.parseUntil(nparam, {'/', '?'}, i)
|
||||||
|
var optional = pattern{i} == '?'
|
||||||
|
result.addNode(NodeField, nparam, optional)
|
||||||
|
if pattern{i} == '?': inc(i) # Only skip ?. / should not be skipped.
|
||||||
|
of '?':
|
||||||
|
var optionalChar = text[^1]
|
||||||
|
setLen(text, text.len-1) # Truncate ``text``.
|
||||||
|
# Add the stored text.
|
||||||
|
if text != "":
|
||||||
|
result.addNode(NodeText, text, false)
|
||||||
|
text = ""
|
||||||
|
# Add optional char.
|
||||||
|
inc(i) # Skip ?
|
||||||
|
result.addNode(NodeText, $optionalChar, true)
|
||||||
|
of '\\':
|
||||||
|
inc i # Skip \
|
||||||
|
if pattern[i] notin {'?', '@', '\\'}:
|
||||||
|
raise newException(ValueError,
|
||||||
|
"This character does not require escaping: " & pattern[i])
|
||||||
|
text.add(pattern{i})
|
||||||
|
inc i # Skip ``pattern[i]``
|
||||||
|
else:
|
||||||
|
text.add(pattern{i})
|
||||||
|
inc(i)
|
||||||
|
|
||||||
|
if text != "":
|
||||||
|
result.addNode(NodeText, text, false)
|
||||||
|
|
||||||
|
proc findNextText(pattern: Pattern, i: int, toNode: var Node): bool =
|
||||||
|
## Finds the next NodeText in the pattern, starts looking from ``i``.
|
||||||
|
result = false
|
||||||
|
for n in i..pattern.len()-1:
|
||||||
|
if pattern[n].typ == NodeText:
|
||||||
|
toNode = pattern[n]
|
||||||
|
return true
|
||||||
|
|
||||||
|
proc check(n: Node, s: string, i: int): bool =
|
||||||
|
let cutTo = (n.text.len-1)+i
|
||||||
|
if cutTo > s.len-1: return false
|
||||||
|
return s.substr(i, cutTo) == n.text
|
||||||
|
|
||||||
|
proc match*(pattern: Pattern, s: string):
|
||||||
|
tuple[matched: bool, params: Table[string, string]] =
|
||||||
|
var i = 0 # Location in ``s``.
|
||||||
|
|
||||||
|
result.matched = true
|
||||||
|
result.params = initTable[string, string]()
|
||||||
|
|
||||||
|
for ncount, node in pattern:
|
||||||
|
case node.typ
|
||||||
|
of NodeText:
|
||||||
|
if node.optional:
|
||||||
|
if check(node, s, i):
|
||||||
|
inc(i, node.text.len) # Skip over this optional character.
|
||||||
|
else:
|
||||||
|
# If it's not there, we have nothing to do. It's optional after all.
|
||||||
|
discard
|
||||||
|
else:
|
||||||
|
if check(node, s, i):
|
||||||
|
inc(i, node.text.len) # Skip over this
|
||||||
|
else:
|
||||||
|
# No match.
|
||||||
|
result.matched = false
|
||||||
|
return
|
||||||
|
of NodeField:
|
||||||
|
var nextTxtNode: Node
|
||||||
|
var stopChar = '/'
|
||||||
|
if findNextText(pattern, ncount, nextTxtNode):
|
||||||
|
stopChar = nextTxtNode.text[0]
|
||||||
|
var matchNamed = ""
|
||||||
|
i += s.parseUntil(matchNamed, stopChar, i)
|
||||||
|
result.params[node.text] = matchNamed
|
||||||
|
if matchNamed == "" and not node.optional:
|
||||||
|
result.matched = false
|
||||||
|
return
|
||||||
|
|
||||||
|
if s.len != i:
|
||||||
|
result.matched = false
|
||||||
|
|
||||||
|
when isMainModule:
|
||||||
|
let f = parsePattern("/show/@id/test/@show?/?")
|
||||||
|
doAssert match(f, "/show/12/test/hallo/").matched
|
||||||
|
doAssert match(f, "/show/2131726/test/jjjuuwąąss").matched
|
||||||
|
doAssert(not match(f, "/").matched)
|
||||||
|
doAssert(not match(f, "/show//test//").matched)
|
||||||
|
doAssert(match(f, "/show/asd/test//").matched)
|
||||||
|
doAssert(not match(f, "/show/asd/asd/test/jjj/").matched)
|
||||||
|
doAssert(match(f, "/show/@łę¶ŧ←/test/asd/").params["id"] == "@łę¶ŧ←")
|
||||||
|
|
||||||
|
let f2 = parsePattern("/test42/somefile.?@ext?/?")
|
||||||
|
doAssert(match(f2, "/test42/somefile/").params["ext"] == "")
|
||||||
|
doAssert(match(f2, "/test42/somefile.txt").params["ext"] == "txt")
|
||||||
|
doAssert(match(f2, "/test42/somefile.txt/").params["ext"] == "txt")
|
||||||
|
|
||||||
|
let f3 = parsePattern(r"/test32/\@\\\??")
|
||||||
|
doAssert(match(f3, r"/test32/@\").matched)
|
||||||
|
doAssert(not match(f3, r"/test32/@\\").matched)
|
||||||
|
doAssert(match(f3, r"/test32/@\?").matched)
|
||||||
19
tests/deps/jester-#head/jester/private/errorpages.nim
Normal file
19
tests/deps/jester-#head/jester/private/errorpages.nim
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Copyright (C) 2012 Dominik Picheta
|
||||||
|
# MIT License - Look at license.txt for details.
|
||||||
|
import htmlgen
|
||||||
|
proc error*(err, jesterVer: string): string =
|
||||||
|
return html(head(title(err)),
|
||||||
|
body(h1(err),
|
||||||
|
"<hr/>",
|
||||||
|
p("Jester " & jesterVer),
|
||||||
|
style = "text-align: center;"
|
||||||
|
),
|
||||||
|
xmlns="http://www.w3.org/1999/xhtml")
|
||||||
|
|
||||||
|
proc routeException*(error: string, jesterVer: string): string =
|
||||||
|
return html(head(title("Jester route exception")),
|
||||||
|
body(
|
||||||
|
h1("An error has occured in one of your routes."),
|
||||||
|
p(b("Detail: "), error)
|
||||||
|
),
|
||||||
|
xmlns="http://www.w3.org/1999/xhtml")
|
||||||
195
tests/deps/jester-#head/jester/private/utils.nim
Normal file
195
tests/deps/jester-#head/jester/private/utils.nim
Normal file
|
|
@ -0,0 +1,195 @@
|
||||||
|
# Copyright (C) 2012 Dominik Picheta
|
||||||
|
# MIT License - Look at license.txt for details.
|
||||||
|
import parseutils, strtabs, strutils, tables, net, mimetypes, asyncdispatch, os
|
||||||
|
from cgi import decodeUrl
|
||||||
|
|
||||||
|
const
|
||||||
|
useHttpBeast* = false # not defined(windows) and not defined(useStdLib)
|
||||||
|
|
||||||
|
type
|
||||||
|
MultiData* = OrderedTable[string, tuple[fields: StringTableRef, body: string]]
|
||||||
|
|
||||||
|
Settings* = ref object
|
||||||
|
staticDir*: string # By default ./public
|
||||||
|
appName*: string
|
||||||
|
mimes*: MimeDb
|
||||||
|
port*: Port
|
||||||
|
bindAddr*: string
|
||||||
|
reusePort*: bool
|
||||||
|
futureErrorHandler*: proc (fut: Future[void]) {.closure, gcsafe.}
|
||||||
|
|
||||||
|
JesterError* = object of Exception
|
||||||
|
|
||||||
|
proc parseUrlQuery*(query: string, result: var Table[string, string])
|
||||||
|
{.deprecated: "use stdlib".} =
|
||||||
|
var i = 0
|
||||||
|
i = query.skip("?")
|
||||||
|
while i < query.len()-1:
|
||||||
|
var key = ""
|
||||||
|
var val = ""
|
||||||
|
i += query.parseUntil(key, '=', i)
|
||||||
|
if query[i] != '=':
|
||||||
|
raise newException(ValueError, "Expected '=' at " & $i &
|
||||||
|
" but got: " & $query[i])
|
||||||
|
inc(i) # Skip =
|
||||||
|
i += query.parseUntil(val, '&', i)
|
||||||
|
inc(i) # Skip &
|
||||||
|
result[decodeUrl(key)] = decodeUrl(val)
|
||||||
|
|
||||||
|
template parseContentDisposition(): typed =
|
||||||
|
var hCount = 0
|
||||||
|
while hCount < hValue.len()-1:
|
||||||
|
var key = ""
|
||||||
|
hCount += hValue.parseUntil(key, {';', '='}, hCount)
|
||||||
|
if hValue[hCount] == '=':
|
||||||
|
var value = hvalue.captureBetween('"', start = hCount)
|
||||||
|
hCount += value.len+2
|
||||||
|
inc(hCount) # Skip ;
|
||||||
|
hCount += hValue.skipWhitespace(hCount)
|
||||||
|
if key == "name": name = value
|
||||||
|
newPart[0][key] = value
|
||||||
|
else:
|
||||||
|
inc(hCount)
|
||||||
|
hCount += hValue.skipWhitespace(hCount)
|
||||||
|
|
||||||
|
proc parseMultiPart*(body: string, boundary: string): MultiData =
|
||||||
|
result = initOrderedTable[string, tuple[fields: StringTableRef, body: string]]()
|
||||||
|
var mboundary = "--" & boundary
|
||||||
|
|
||||||
|
var i = 0
|
||||||
|
var partsLeft = true
|
||||||
|
while partsLeft:
|
||||||
|
var firstBoundary = body.skip(mboundary, i)
|
||||||
|
if firstBoundary == 0:
|
||||||
|
raise newException(ValueError, "Expected boundary. Got: " & body.substr(i, i+25))
|
||||||
|
i += firstBoundary
|
||||||
|
i += body.skipWhitespace(i)
|
||||||
|
|
||||||
|
# Headers
|
||||||
|
var newPart: tuple[fields: StringTableRef, body: string] = ({:}.newStringTable, "")
|
||||||
|
var name = ""
|
||||||
|
while true:
|
||||||
|
if body[i] == '\c':
|
||||||
|
inc(i, 2) # Skip \c\L
|
||||||
|
break
|
||||||
|
var hName = ""
|
||||||
|
i += body.parseUntil(hName, ':', i)
|
||||||
|
if body[i] != ':':
|
||||||
|
raise newException(ValueError, "Expected : in headers.")
|
||||||
|
inc(i) # Skip :
|
||||||
|
i += body.skipWhitespace(i)
|
||||||
|
var hValue = ""
|
||||||
|
i += body.parseUntil(hValue, {'\c', '\L'}, i)
|
||||||
|
if toLowerAscii(hName) == "content-disposition":
|
||||||
|
parseContentDisposition()
|
||||||
|
newPart[0][hName] = hValue
|
||||||
|
i += body.skip("\c\L", i) # Skip *one* \c\L
|
||||||
|
|
||||||
|
# Parse body.
|
||||||
|
while true:
|
||||||
|
if body[i] == '\c' and body[i+1] == '\L' and
|
||||||
|
body.skip(mboundary, i+2) != 0:
|
||||||
|
if body.skip("--", i+2+mboundary.len) != 0:
|
||||||
|
partsLeft = false
|
||||||
|
break
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
newPart[1].add(body[i])
|
||||||
|
inc(i)
|
||||||
|
i += body.skipWhitespace(i)
|
||||||
|
|
||||||
|
result.add(name, newPart)
|
||||||
|
|
||||||
|
proc parseMPFD*(contentType: string, body: string): MultiData =
|
||||||
|
var boundaryEqIndex = contentType.find("boundary=")+9
|
||||||
|
var boundary = contentType.substr(boundaryEqIndex, contentType.len()-1)
|
||||||
|
return parseMultiPart(body, boundary)
|
||||||
|
|
||||||
|
proc parseCookies*(s: string): Table[string, string] =
|
||||||
|
## parses cookies into a string table.
|
||||||
|
##
|
||||||
|
## The proc is meant to parse the Cookie header set by a client, not the
|
||||||
|
## "Set-Cookie" header set by servers.
|
||||||
|
|
||||||
|
result = initTable[string, string]()
|
||||||
|
var i = 0
|
||||||
|
while true:
|
||||||
|
i += skipWhile(s, {' ', '\t'}, i)
|
||||||
|
var keystart = i
|
||||||
|
i += skipUntil(s, {'='}, i)
|
||||||
|
var keyend = i-1
|
||||||
|
if i >= len(s): break
|
||||||
|
inc(i) # skip '='
|
||||||
|
var valstart = i
|
||||||
|
i += skipUntil(s, {';'}, i)
|
||||||
|
result[substr(s, keystart, keyend)] = substr(s, valstart, i-1)
|
||||||
|
if i >= len(s): break
|
||||||
|
inc(i) # skip ';'
|
||||||
|
|
||||||
|
type
|
||||||
|
SameSite* = enum
|
||||||
|
None, Lax, Strict
|
||||||
|
|
||||||
|
proc makeCookie*(key, value, expires: string, domain = "", path = "",
|
||||||
|
secure = false, httpOnly = false,
|
||||||
|
sameSite = Lax): string =
|
||||||
|
result = ""
|
||||||
|
result.add key & "=" & value
|
||||||
|
if domain != "": result.add("; Domain=" & domain)
|
||||||
|
if path != "": result.add("; Path=" & path)
|
||||||
|
if expires != "": result.add("; Expires=" & expires)
|
||||||
|
if secure: result.add("; Secure")
|
||||||
|
if httpOnly: result.add("; HttpOnly")
|
||||||
|
if sameSite != None:
|
||||||
|
result.add("; SameSite=" & $sameSite)
|
||||||
|
|
||||||
|
when not declared(tables.getOrDefault):
|
||||||
|
template getOrDefault*(tab, key): untyped = tab[key]
|
||||||
|
|
||||||
|
when not declared(normalizePath) and not declared(normalizedPath):
|
||||||
|
proc normalizePath*(path: var string) =
|
||||||
|
## Normalize a path.
|
||||||
|
##
|
||||||
|
## Consecutive directory separators are collapsed, including an initial double slash.
|
||||||
|
##
|
||||||
|
## On relative paths, double dot (..) sequences are collapsed if possible.
|
||||||
|
## On absolute paths they are always collapsed.
|
||||||
|
##
|
||||||
|
## Warning: URL-encoded and Unicode attempts at directory traversal are not detected.
|
||||||
|
## Triple dot is not handled.
|
||||||
|
let isAbs = isAbsolute(path)
|
||||||
|
var stack: seq[string] = @[]
|
||||||
|
for p in split(path, {DirSep}):
|
||||||
|
case p
|
||||||
|
of "", ".":
|
||||||
|
continue
|
||||||
|
of "..":
|
||||||
|
if stack.len == 0:
|
||||||
|
if isAbs:
|
||||||
|
discard # collapse all double dots on absoluta paths
|
||||||
|
else:
|
||||||
|
stack.add(p)
|
||||||
|
elif stack[^1] == "..":
|
||||||
|
stack.add(p)
|
||||||
|
else:
|
||||||
|
discard stack.pop()
|
||||||
|
else:
|
||||||
|
stack.add(p)
|
||||||
|
|
||||||
|
if isAbs:
|
||||||
|
path = DirSep & join(stack, $DirSep)
|
||||||
|
elif stack.len > 0:
|
||||||
|
path = join(stack, $DirSep)
|
||||||
|
else:
|
||||||
|
path = "."
|
||||||
|
|
||||||
|
proc normalizedPath*(path: string): string =
|
||||||
|
## Returns a normalized path for the current OS. See `<#normalizePath>`_
|
||||||
|
result = path
|
||||||
|
normalizePath(result)
|
||||||
|
|
||||||
|
when isMainModule:
|
||||||
|
var r = {:}.newStringTable
|
||||||
|
parseUrlQuery("FirstName=Mickey", r)
|
||||||
|
echo r
|
||||||
|
|
||||||
184
tests/deps/jester-#head/jester/request.nim
Normal file
184
tests/deps/jester-#head/jester/request.nim
Normal file
|
|
@ -0,0 +1,184 @@
|
||||||
|
import uri, cgi, tables, logging, strutils, re, options
|
||||||
|
|
||||||
|
import jester/private/utils
|
||||||
|
|
||||||
|
when useHttpBeast:
|
||||||
|
import httpbeast except Settings
|
||||||
|
import options, httpcore
|
||||||
|
|
||||||
|
type
|
||||||
|
NativeRequest* = httpbeast.Request
|
||||||
|
else:
|
||||||
|
import asynchttpserver
|
||||||
|
|
||||||
|
type
|
||||||
|
NativeRequest* = asynchttpserver.Request
|
||||||
|
|
||||||
|
type
|
||||||
|
Request* = object
|
||||||
|
req: NativeRequest
|
||||||
|
patternParams: Option[Table[string, string]]
|
||||||
|
reMatches: array[MaxSubpatterns, string]
|
||||||
|
settings*: Settings
|
||||||
|
|
||||||
|
proc body*(req: Request): string =
|
||||||
|
## Body of the request, only for POST.
|
||||||
|
##
|
||||||
|
## You're probably looking for ``formData``
|
||||||
|
## instead.
|
||||||
|
when useHttpBeast:
|
||||||
|
req.req.body.get("")
|
||||||
|
else:
|
||||||
|
req.req.body
|
||||||
|
|
||||||
|
proc headers*(req: Request): HttpHeaders =
|
||||||
|
## Headers received with the request.
|
||||||
|
## Retrieving these is case insensitive.
|
||||||
|
when useHttpBeast:
|
||||||
|
if req.req.headers.isNone:
|
||||||
|
newHttpHeaders()
|
||||||
|
else:
|
||||||
|
req.req.headers.get()
|
||||||
|
else:
|
||||||
|
req.req.headers
|
||||||
|
|
||||||
|
proc path*(req: Request): string =
|
||||||
|
## Path of request without the query string.
|
||||||
|
when useHttpBeast:
|
||||||
|
let p = req.req.path.get("")
|
||||||
|
let queryStart = p.find('?')
|
||||||
|
if unlikely(queryStart != -1):
|
||||||
|
return p[0 .. queryStart-1]
|
||||||
|
else:
|
||||||
|
return p
|
||||||
|
else:
|
||||||
|
let u = req.req.url
|
||||||
|
return u.path
|
||||||
|
|
||||||
|
proc reqMethod*(req: Request): HttpMethod =
|
||||||
|
## Request method, eg. HttpGet, HttpPost
|
||||||
|
when useHttpBeast:
|
||||||
|
req.req.httpMethod.get()
|
||||||
|
else:
|
||||||
|
req.req.reqMethod
|
||||||
|
proc reqMeth*(req: Request): HttpMethod {.deprecated.} =
|
||||||
|
req.reqMethod
|
||||||
|
|
||||||
|
proc ip*(req: Request): string =
|
||||||
|
## IP address of the requesting client.
|
||||||
|
when useHttpBeast:
|
||||||
|
result = req.req.ip
|
||||||
|
else:
|
||||||
|
result = req.req.hostname
|
||||||
|
|
||||||
|
let headers = req.headers
|
||||||
|
if headers.hasKey("REMOTE_ADDR"):
|
||||||
|
result = headers["REMOTE_ADDR"]
|
||||||
|
if headers.hasKey("x-forwarded-for"):
|
||||||
|
result = headers["x-forwarded-for"]
|
||||||
|
|
||||||
|
proc params*(req: Request): Table[string, string] =
|
||||||
|
## Parameters from the pattern and the query string.
|
||||||
|
if req.patternParams.isSome():
|
||||||
|
result = req.patternParams.get()
|
||||||
|
else:
|
||||||
|
result = initTable[string, string]()
|
||||||
|
|
||||||
|
when useHttpBeast:
|
||||||
|
let query = req.req.path.get("").parseUri().query
|
||||||
|
else:
|
||||||
|
let query = req.req.url.query
|
||||||
|
|
||||||
|
try:
|
||||||
|
for key, val in cgi.decodeData(query):
|
||||||
|
result[key] = val
|
||||||
|
except CgiError:
|
||||||
|
logging.warn("Incorrect query. Got: $1" % [query])
|
||||||
|
|
||||||
|
let contentType = req.headers.getOrDefault("Content-Type")
|
||||||
|
if contentType.startswith("application/x-www-form-urlencoded"):
|
||||||
|
try:
|
||||||
|
parseUrlQuery(req.body, result)
|
||||||
|
except:
|
||||||
|
logging.warn("Could not parse URL query.")
|
||||||
|
|
||||||
|
proc formData*(req: Request): MultiData =
|
||||||
|
let contentType = req.headers.getOrDefault("Content-Type")
|
||||||
|
if contentType.startsWith("multipart/form-data"):
|
||||||
|
result = parseMPFD(contentType, req.body)
|
||||||
|
|
||||||
|
proc matches*(req: Request): array[MaxSubpatterns, string] =
|
||||||
|
req.reMatches
|
||||||
|
|
||||||
|
proc secure*(req: Request): bool =
|
||||||
|
if req.headers.hasKey("x-forwarded-proto"):
|
||||||
|
let proto = req.headers["x-forwarded-proto"]
|
||||||
|
case proto.toLowerAscii()
|
||||||
|
of "https":
|
||||||
|
result = true
|
||||||
|
of "http":
|
||||||
|
result = false
|
||||||
|
else:
|
||||||
|
logging.warn("Unknown x-forwarded-proto ", proto)
|
||||||
|
|
||||||
|
proc port*(req: Request): int =
|
||||||
|
if (let p = req.headers.getOrDefault("SERVER_PORT"); p != ""):
|
||||||
|
result = p.parseInt
|
||||||
|
else:
|
||||||
|
result = if req.secure: 443 else: 80
|
||||||
|
|
||||||
|
proc host*(req: Request): string =
|
||||||
|
req.headers.getOrDefault("HOST")
|
||||||
|
|
||||||
|
proc appName*(req: Request): string =
|
||||||
|
## This is set by the user in ``run``, it is
|
||||||
|
## overriden by the "SCRIPT_NAME" scgi
|
||||||
|
## parameter.
|
||||||
|
req.settings.appName
|
||||||
|
|
||||||
|
proc stripAppName(path, appName: string): string =
|
||||||
|
result = path
|
||||||
|
if appname.len > 0:
|
||||||
|
var slashAppName = appName
|
||||||
|
if slashAppName[0] != '/' and path[0] == '/':
|
||||||
|
slashAppName = '/' & slashAppName
|
||||||
|
|
||||||
|
if path.startsWith(slashAppName):
|
||||||
|
if slashAppName.len() == path.len:
|
||||||
|
return "/"
|
||||||
|
else:
|
||||||
|
return path[slashAppName.len .. path.len-1]
|
||||||
|
else:
|
||||||
|
raise newException(ValueError,
|
||||||
|
"Expected script name at beginning of path. Got path: " &
|
||||||
|
path & " script name: " & slashAppName)
|
||||||
|
|
||||||
|
proc pathInfo*(req: Request): string =
|
||||||
|
## This is ``.path`` without ``.appName``.
|
||||||
|
req.path.stripAppName(req.appName)
|
||||||
|
|
||||||
|
# TODO: Can cookie keys be duplicated?
|
||||||
|
proc cookies*(req: Request): Table[string, string] =
|
||||||
|
## Cookies from the browser.
|
||||||
|
if (let cookie = req.headers.getOrDefault("Cookie"); cookie != ""):
|
||||||
|
result = parseCookies(cookie)
|
||||||
|
else:
|
||||||
|
result = initTable[string, string]()
|
||||||
|
|
||||||
|
#[ Protected procs ]#
|
||||||
|
|
||||||
|
proc initRequest*(req: NativeRequest, settings: Settings): Request {.inline.} =
|
||||||
|
Request(
|
||||||
|
req: req,
|
||||||
|
settings: settings
|
||||||
|
)
|
||||||
|
|
||||||
|
proc getNativeReq*(req: Request): NativeRequest =
|
||||||
|
req.req
|
||||||
|
|
||||||
|
#[ Only to be used by our route macro. ]#
|
||||||
|
proc setPatternParams*(req: var Request, p: Table[string, string]) =
|
||||||
|
req.patternParams = some(p)
|
||||||
|
|
||||||
|
proc setReMatches*(req: var Request, r: array[MaxSubpatterns, string]) =
|
||||||
|
req.reMatches = r
|
||||||
326
tests/deps/opengl-1.1.0/glu.nim
Normal file
326
tests/deps/opengl-1.1.0/glu.nim
Normal file
|
|
@ -0,0 +1,326 @@
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Adaption of the delphi3d.net OpenGL units to FreePascal
|
||||||
|
# Sebastian Guenther (sg@freepascal.org) in 2002
|
||||||
|
# These units are free to use
|
||||||
|
#******************************************************************************
|
||||||
|
# Converted to Delphi by Tom Nuydens (tom@delphi3d.net)
|
||||||
|
# For the latest updates, visit Delphi3D: http://www.delphi3d.net
|
||||||
|
#******************************************************************************
|
||||||
|
|
||||||
|
import opengl
|
||||||
|
|
||||||
|
{.deadCodeElim: on.}
|
||||||
|
|
||||||
|
when defined(windows):
|
||||||
|
{.push, callconv: stdcall.}
|
||||||
|
else:
|
||||||
|
{.push, callconv: cdecl.}
|
||||||
|
|
||||||
|
when defined(windows):
|
||||||
|
const
|
||||||
|
dllname = "glu32.dll"
|
||||||
|
elif defined(macosx):
|
||||||
|
const
|
||||||
|
dllname = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib"
|
||||||
|
else:
|
||||||
|
const
|
||||||
|
dllname = "libGLU.so.1"
|
||||||
|
|
||||||
|
type
|
||||||
|
ViewPortArray* = array[0..3, GLint]
|
||||||
|
T16dArray* = array[0..15, GLdouble]
|
||||||
|
CallBack* = proc () {.cdecl.}
|
||||||
|
T3dArray* = array[0..2, GLdouble]
|
||||||
|
T4pArray* = array[0..3, pointer]
|
||||||
|
T4fArray* = array[0..3, GLfloat]
|
||||||
|
|
||||||
|
{.deprecated: [
|
||||||
|
TViewPortArray: ViewPortArray,
|
||||||
|
TCallBack: CallBack,
|
||||||
|
].}
|
||||||
|
|
||||||
|
type
|
||||||
|
GLUnurbs*{.final.} = ptr object
|
||||||
|
GLUquadric*{.final.} = ptr object
|
||||||
|
GLUtesselator*{.final.} = ptr object
|
||||||
|
GLUnurbsObj* = GLUnurbs
|
||||||
|
GLUquadricObj* = GLUquadric
|
||||||
|
GLUtesselatorObj* = GLUtesselator
|
||||||
|
GLUtriangulatorObj* = GLUtesselator
|
||||||
|
|
||||||
|
proc gluErrorString*(errCode: GLenum): cstring{.dynlib: dllname,
|
||||||
|
importc: "gluErrorString".}
|
||||||
|
when defined(Windows):
|
||||||
|
proc gluErrorUnicodeStringEXT*(errCode: GLenum): ptr int16{.dynlib: dllname,
|
||||||
|
importc: "gluErrorUnicodeStringEXT".}
|
||||||
|
proc gluGetString*(name: GLenum): cstring{.dynlib: dllname,
|
||||||
|
importc: "gluGetString".}
|
||||||
|
proc gluOrtho2D*(left, right, bottom, top: GLdouble){.dynlib: dllname,
|
||||||
|
importc: "gluOrtho2D".}
|
||||||
|
proc gluPerspective*(fovy, aspect, zNear, zFar: GLdouble){.dynlib: dllname,
|
||||||
|
importc: "gluPerspective".}
|
||||||
|
proc gluPickMatrix*(x, y, width, height: GLdouble, viewport: var ViewPortArray){.
|
||||||
|
dynlib: dllname, importc: "gluPickMatrix".}
|
||||||
|
proc gluLookAt*(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz: GLdouble){.
|
||||||
|
dynlib: dllname, importc: "gluLookAt".}
|
||||||
|
proc gluProject*(objx, objy, objz: GLdouble,
|
||||||
|
modelMatrix, projMatrix: var T16dArray,
|
||||||
|
viewport: var ViewPortArray, winx, winy, winz: ptr GLdouble): int{.
|
||||||
|
dynlib: dllname, importc: "gluProject".}
|
||||||
|
proc gluUnProject*(winx, winy, winz: GLdouble,
|
||||||
|
modelMatrix, projMatrix: var T16dArray,
|
||||||
|
viewport: var ViewPortArray, objx, objy, objz: ptr GLdouble): int{.
|
||||||
|
dynlib: dllname, importc: "gluUnProject".}
|
||||||
|
proc gluScaleImage*(format: GLenum, widthin, heightin: GLint, typein: GLenum,
|
||||||
|
datain: pointer, widthout, heightout: GLint,
|
||||||
|
typeout: GLenum, dataout: pointer): int{.dynlib: dllname,
|
||||||
|
importc: "gluScaleImage".}
|
||||||
|
proc gluBuild1DMipmaps*(target: GLenum, components, width: GLint,
|
||||||
|
format, atype: GLenum, data: pointer): int{.
|
||||||
|
dynlib: dllname, importc: "gluBuild1DMipmaps".}
|
||||||
|
proc gluBuild2DMipmaps*(target: GLenum, components, width, height: GLint,
|
||||||
|
format, atype: GLenum, data: pointer): int{.
|
||||||
|
dynlib: dllname, importc: "gluBuild2DMipmaps".}
|
||||||
|
proc gluNewQuadric*(): GLUquadric{.dynlib: dllname, importc: "gluNewQuadric".}
|
||||||
|
proc gluDeleteQuadric*(state: GLUquadric){.dynlib: dllname,
|
||||||
|
importc: "gluDeleteQuadric".}
|
||||||
|
proc gluQuadricNormals*(quadObject: GLUquadric, normals: GLenum){.
|
||||||
|
dynlib: dllname, importc: "gluQuadricNormals".}
|
||||||
|
proc gluQuadricTexture*(quadObject: GLUquadric, textureCoords: GLboolean){.
|
||||||
|
dynlib: dllname, importc: "gluQuadricTexture".}
|
||||||
|
proc gluQuadricOrientation*(quadObject: GLUquadric, orientation: GLenum){.
|
||||||
|
dynlib: dllname, importc: "gluQuadricOrientation".}
|
||||||
|
proc gluQuadricDrawStyle*(quadObject: GLUquadric, drawStyle: GLenum){.
|
||||||
|
dynlib: dllname, importc: "gluQuadricDrawStyle".}
|
||||||
|
proc gluCylinder*(qobj: GLUquadric, baseRadius, topRadius, height: GLdouble,
|
||||||
|
slices, stacks: GLint){.dynlib: dllname,
|
||||||
|
importc: "gluCylinder".}
|
||||||
|
proc gluDisk*(qobj: GLUquadric, innerRadius, outerRadius: GLdouble,
|
||||||
|
slices, loops: GLint){.dynlib: dllname, importc: "gluDisk".}
|
||||||
|
proc gluPartialDisk*(qobj: GLUquadric, innerRadius, outerRadius: GLdouble,
|
||||||
|
slices, loops: GLint, startAngle, sweepAngle: GLdouble){.
|
||||||
|
dynlib: dllname, importc: "gluPartialDisk".}
|
||||||
|
proc gluSphere*(qobj: GLuquadric, radius: GLdouble, slices, stacks: GLint){.
|
||||||
|
dynlib: dllname, importc: "gluSphere".}
|
||||||
|
proc gluQuadricCallback*(qobj: GLUquadric, which: GLenum, fn: CallBack){.
|
||||||
|
dynlib: dllname, importc: "gluQuadricCallback".}
|
||||||
|
proc gluNewTess*(): GLUtesselator{.dynlib: dllname, importc: "gluNewTess".}
|
||||||
|
proc gluDeleteTess*(tess: GLUtesselator){.dynlib: dllname,
|
||||||
|
importc: "gluDeleteTess".}
|
||||||
|
proc gluTessBeginPolygon*(tess: GLUtesselator, polygon_data: pointer){.
|
||||||
|
dynlib: dllname, importc: "gluTessBeginPolygon".}
|
||||||
|
proc gluTessBeginContour*(tess: GLUtesselator){.dynlib: dllname,
|
||||||
|
importc: "gluTessBeginContour".}
|
||||||
|
proc gluTessVertex*(tess: GLUtesselator, coords: var T3dArray, data: pointer){.
|
||||||
|
dynlib: dllname, importc: "gluTessVertex".}
|
||||||
|
proc gluTessEndContour*(tess: GLUtesselator){.dynlib: dllname,
|
||||||
|
importc: "gluTessEndContour".}
|
||||||
|
proc gluTessEndPolygon*(tess: GLUtesselator){.dynlib: dllname,
|
||||||
|
importc: "gluTessEndPolygon".}
|
||||||
|
proc gluTessProperty*(tess: GLUtesselator, which: GLenum, value: GLdouble){.
|
||||||
|
dynlib: dllname, importc: "gluTessProperty".}
|
||||||
|
proc gluTessNormal*(tess: GLUtesselator, x, y, z: GLdouble){.dynlib: dllname,
|
||||||
|
importc: "gluTessNormal".}
|
||||||
|
proc gluTessCallback*(tess: GLUtesselator, which: GLenum, fn: CallBack){.
|
||||||
|
dynlib: dllname, importc: "gluTessCallback".}
|
||||||
|
proc gluGetTessProperty*(tess: GLUtesselator, which: GLenum, value: ptr GLdouble){.
|
||||||
|
dynlib: dllname, importc: "gluGetTessProperty".}
|
||||||
|
proc gluNewNurbsRenderer*(): GLUnurbs{.dynlib: dllname,
|
||||||
|
importc: "gluNewNurbsRenderer".}
|
||||||
|
proc gluDeleteNurbsRenderer*(nobj: GLUnurbs){.dynlib: dllname,
|
||||||
|
importc: "gluDeleteNurbsRenderer".}
|
||||||
|
proc gluBeginSurface*(nobj: GLUnurbs){.dynlib: dllname,
|
||||||
|
importc: "gluBeginSurface".}
|
||||||
|
proc gluBeginCurve*(nobj: GLUnurbs){.dynlib: dllname, importc: "gluBeginCurve".}
|
||||||
|
proc gluEndCurve*(nobj: GLUnurbs){.dynlib: dllname, importc: "gluEndCurve".}
|
||||||
|
proc gluEndSurface*(nobj: GLUnurbs){.dynlib: dllname, importc: "gluEndSurface".}
|
||||||
|
proc gluBeginTrim*(nobj: GLUnurbs){.dynlib: dllname, importc: "gluBeginTrim".}
|
||||||
|
proc gluEndTrim*(nobj: GLUnurbs){.dynlib: dllname, importc: "gluEndTrim".}
|
||||||
|
proc gluPwlCurve*(nobj: GLUnurbs, count: GLint, aarray: ptr GLfloat,
|
||||||
|
stride: GLint, atype: GLenum){.dynlib: dllname,
|
||||||
|
importc: "gluPwlCurve".}
|
||||||
|
proc gluNurbsCurve*(nobj: GLUnurbs, nknots: GLint, knot: ptr GLfloat,
|
||||||
|
stride: GLint, ctlarray: ptr GLfloat, order: GLint,
|
||||||
|
atype: GLenum){.dynlib: dllname, importc: "gluNurbsCurve".}
|
||||||
|
proc gluNurbsSurface*(nobj: GLUnurbs, sknot_count: GLint, sknot: ptr GLfloat,
|
||||||
|
tknot_count: GLint, tknot: ptr GLfloat,
|
||||||
|
s_stride, t_stride: GLint, ctlarray: ptr GLfloat,
|
||||||
|
sorder, torder: GLint, atype: GLenum){.dynlib: dllname,
|
||||||
|
importc: "gluNurbsSurface".}
|
||||||
|
proc gluLoadSamplingMatrices*(nobj: GLUnurbs,
|
||||||
|
modelMatrix, projMatrix: var T16dArray,
|
||||||
|
viewport: var ViewPortArray){.dynlib: dllname,
|
||||||
|
importc: "gluLoadSamplingMatrices".}
|
||||||
|
proc gluNurbsProperty*(nobj: GLUnurbs, aproperty: GLenum, value: GLfloat){.
|
||||||
|
dynlib: dllname, importc: "gluNurbsProperty".}
|
||||||
|
proc gluGetNurbsProperty*(nobj: GLUnurbs, aproperty: GLenum, value: ptr GLfloat){.
|
||||||
|
dynlib: dllname, importc: "gluGetNurbsProperty".}
|
||||||
|
proc gluNurbsCallback*(nobj: GLUnurbs, which: GLenum, fn: CallBack){.
|
||||||
|
dynlib: dllname, importc: "gluNurbsCallback".}
|
||||||
|
#*** Callback function prototypes ***
|
||||||
|
type # gluQuadricCallback
|
||||||
|
GLUquadricErrorProc* = proc (p: GLenum) # gluTessCallback
|
||||||
|
GLUtessBeginProc* = proc (p: GLenum)
|
||||||
|
GLUtessEdgeFlagProc* = proc (p: GLboolean)
|
||||||
|
GLUtessVertexProc* = proc (p: pointer)
|
||||||
|
GLUtessEndProc* = proc ()
|
||||||
|
GLUtessErrorProc* = proc (p: GLenum)
|
||||||
|
GLUtessCombineProc* = proc (p1: var T3dArray, p2: T4pArray, p3: T4fArray,
|
||||||
|
p4: ptr pointer)
|
||||||
|
GLUtessBeginDataProc* = proc (p1: GLenum, p2: pointer)
|
||||||
|
GLUtessEdgeFlagDataProc* = proc (p1: GLboolean, p2: pointer)
|
||||||
|
GLUtessVertexDataProc* = proc (p1, p2: pointer)
|
||||||
|
GLUtessEndDataProc* = proc (p: pointer)
|
||||||
|
GLUtessErrorDataProc* = proc (p1: GLenum, p2: pointer)
|
||||||
|
GLUtessCombineDataProc* = proc (p1: var T3dArray, p2: var T4pArray,
|
||||||
|
p3: var T4fArray, p4: ptr pointer, p5: pointer) #
|
||||||
|
GLUnurbsErrorProc* = proc (p: GLenum) #*** Generic constants ****/
|
||||||
|
|
||||||
|
const # Version
|
||||||
|
GLU_VERSION_1_1* = 1
|
||||||
|
GLU_VERSION_1_2* = 1 # Errors: (return value 0 = no error)
|
||||||
|
GLU_INVALID_ENUM* = 100900
|
||||||
|
GLU_INVALID_VALUE* = 100901
|
||||||
|
GLU_OUT_OF_MEMORY* = 100902
|
||||||
|
GLU_INCOMPATIBLE_GL_VERSION* = 100903 # StringName
|
||||||
|
GLU_VERSION* = 100800
|
||||||
|
GLU_EXTENSIONS* = 100801 # Boolean
|
||||||
|
GLU_TRUE* = GL_TRUE
|
||||||
|
GLU_FALSE* = GL_FALSE #*** Quadric constants ****/
|
||||||
|
# QuadricNormal
|
||||||
|
GLU_SMOOTH* = 100000
|
||||||
|
GLU_FLAT* = 100001
|
||||||
|
GLU_NONE* = 100002 # QuadricDrawStyle
|
||||||
|
GLU_POINT* = 100010
|
||||||
|
GLU_LINE* = 100011
|
||||||
|
GLU_FILL* = 100012
|
||||||
|
GLU_SILHOUETTE* = 100013 # QuadricOrientation
|
||||||
|
GLU_OUTSIDE* = 100020
|
||||||
|
GLU_INSIDE* = 100021 # Callback types:
|
||||||
|
# GLU_ERROR = 100103;
|
||||||
|
#*** Tesselation constants ****/
|
||||||
|
GLU_TESS_MAX_COORD* = 1.00000e+150 # TessProperty
|
||||||
|
GLU_TESS_WINDING_RULE* = 100140
|
||||||
|
GLU_TESS_BOUNDARY_ONLY* = 100141
|
||||||
|
GLU_TESS_TOLERANCE* = 100142 # TessWinding
|
||||||
|
GLU_TESS_WINDING_ODD* = 100130
|
||||||
|
GLU_TESS_WINDING_NONZERO* = 100131
|
||||||
|
GLU_TESS_WINDING_POSITIVE* = 100132
|
||||||
|
GLU_TESS_WINDING_NEGATIVE* = 100133
|
||||||
|
GLU_TESS_WINDING_ABS_GEQ_TWO* = 100134 # TessCallback
|
||||||
|
GLU_TESS_BEGIN* = 100100 # void (CALLBACK*)(GLenum type)
|
||||||
|
constGLU_TESS_VERTEX* = 100101 # void (CALLBACK*)(void *data)
|
||||||
|
GLU_TESS_END* = 100102 # void (CALLBACK*)(void)
|
||||||
|
GLU_TESS_ERROR* = 100103 # void (CALLBACK*)(GLenum errno)
|
||||||
|
GLU_TESS_EDGE_FLAG* = 100104 # void (CALLBACK*)(GLboolean boundaryEdge)
|
||||||
|
GLU_TESS_COMBINE* = 100105 # void (CALLBACK*)(GLdouble coords[3],
|
||||||
|
# void *data[4],
|
||||||
|
# GLfloat weight[4],
|
||||||
|
# void **dataOut)
|
||||||
|
GLU_TESS_BEGIN_DATA* = 100106 # void (CALLBACK*)(GLenum type,
|
||||||
|
# void *polygon_data)
|
||||||
|
GLU_TESS_VERTEX_DATA* = 100107 # void (CALLBACK*)(void *data,
|
||||||
|
# void *polygon_data)
|
||||||
|
GLU_TESS_END_DATA* = 100108 # void (CALLBACK*)(void *polygon_data)
|
||||||
|
GLU_TESS_ERROR_DATA* = 100109 # void (CALLBACK*)(GLenum errno,
|
||||||
|
# void *polygon_data)
|
||||||
|
GLU_TESS_EDGE_FLAG_DATA* = 100110 # void (CALLBACK*)(GLboolean boundaryEdge,
|
||||||
|
# void *polygon_data)
|
||||||
|
GLU_TESS_COMBINE_DATA* = 100111 # void (CALLBACK*)(GLdouble coords[3],
|
||||||
|
# void *data[4],
|
||||||
|
# GLfloat weight[4],
|
||||||
|
# void **dataOut,
|
||||||
|
# void *polygon_data)
|
||||||
|
# TessError
|
||||||
|
GLU_TESS_ERROR1* = 100151
|
||||||
|
GLU_TESS_ERROR2* = 100152
|
||||||
|
GLU_TESS_ERROR3* = 100153
|
||||||
|
GLU_TESS_ERROR4* = 100154
|
||||||
|
GLU_TESS_ERROR5* = 100155
|
||||||
|
GLU_TESS_ERROR6* = 100156
|
||||||
|
GLU_TESS_ERROR7* = 100157
|
||||||
|
GLU_TESS_ERROR8* = 100158
|
||||||
|
GLU_TESS_MISSING_BEGIN_POLYGON* = GLU_TESS_ERROR1
|
||||||
|
GLU_TESS_MISSING_BEGIN_CONTOUR* = GLU_TESS_ERROR2
|
||||||
|
GLU_TESS_MISSING_END_POLYGON* = GLU_TESS_ERROR3
|
||||||
|
GLU_TESS_MISSING_END_CONTOUR* = GLU_TESS_ERROR4
|
||||||
|
GLU_TESS_COORD_TOO_LARGE* = GLU_TESS_ERROR5
|
||||||
|
GLU_TESS_NEED_COMBINE_CALLBACK* = GLU_TESS_ERROR6 #*** NURBS constants ****/
|
||||||
|
# NurbsProperty
|
||||||
|
GLU_AUTO_LOAD_MATRIX* = 100200
|
||||||
|
GLU_CULLING* = 100201
|
||||||
|
GLU_SAMPLING_TOLERANCE* = 100203
|
||||||
|
GLU_DISPLAY_MODE* = 100204
|
||||||
|
GLU_PARAMETRIC_TOLERANCE* = 100202
|
||||||
|
GLU_SAMPLING_METHOD* = 100205
|
||||||
|
GLU_U_STEP* = 100206
|
||||||
|
GLU_V_STEP* = 100207 # NurbsSampling
|
||||||
|
GLU_PATH_LENGTH* = 100215
|
||||||
|
GLU_PARAMETRIC_ERROR* = 100216
|
||||||
|
GLU_DOMAIN_DISTANCE* = 100217 # NurbsTrim
|
||||||
|
GLU_MAP1_TRIM_2* = 100210
|
||||||
|
GLU_MAP1_TRIM_3* = 100211 # NurbsDisplay
|
||||||
|
# GLU_FILL = 100012;
|
||||||
|
GLU_OUTLINE_POLYGON* = 100240
|
||||||
|
GLU_OUTLINE_PATCH* = 100241 # NurbsCallback
|
||||||
|
# GLU_ERROR = 100103;
|
||||||
|
# NurbsErrors
|
||||||
|
GLU_NURBS_ERROR1* = 100251
|
||||||
|
GLU_NURBS_ERROR2* = 100252
|
||||||
|
GLU_NURBS_ERROR3* = 100253
|
||||||
|
GLU_NURBS_ERROR4* = 100254
|
||||||
|
GLU_NURBS_ERROR5* = 100255
|
||||||
|
GLU_NURBS_ERROR6* = 100256
|
||||||
|
GLU_NURBS_ERROR7* = 100257
|
||||||
|
GLU_NURBS_ERROR8* = 100258
|
||||||
|
GLU_NURBS_ERROR9* = 100259
|
||||||
|
GLU_NURBS_ERROR10* = 100260
|
||||||
|
GLU_NURBS_ERROR11* = 100261
|
||||||
|
GLU_NURBS_ERROR12* = 100262
|
||||||
|
GLU_NURBS_ERROR13* = 100263
|
||||||
|
GLU_NURBS_ERROR14* = 100264
|
||||||
|
GLU_NURBS_ERROR15* = 100265
|
||||||
|
GLU_NURBS_ERROR16* = 100266
|
||||||
|
GLU_NURBS_ERROR17* = 100267
|
||||||
|
GLU_NURBS_ERROR18* = 100268
|
||||||
|
GLU_NURBS_ERROR19* = 100269
|
||||||
|
GLU_NURBS_ERROR20* = 100270
|
||||||
|
GLU_NURBS_ERROR21* = 100271
|
||||||
|
GLU_NURBS_ERROR22* = 100272
|
||||||
|
GLU_NURBS_ERROR23* = 100273
|
||||||
|
GLU_NURBS_ERROR24* = 100274
|
||||||
|
GLU_NURBS_ERROR25* = 100275
|
||||||
|
GLU_NURBS_ERROR26* = 100276
|
||||||
|
GLU_NURBS_ERROR27* = 100277
|
||||||
|
GLU_NURBS_ERROR28* = 100278
|
||||||
|
GLU_NURBS_ERROR29* = 100279
|
||||||
|
GLU_NURBS_ERROR30* = 100280
|
||||||
|
GLU_NURBS_ERROR31* = 100281
|
||||||
|
GLU_NURBS_ERROR32* = 100282
|
||||||
|
GLU_NURBS_ERROR33* = 100283
|
||||||
|
GLU_NURBS_ERROR34* = 100284
|
||||||
|
GLU_NURBS_ERROR35* = 100285
|
||||||
|
GLU_NURBS_ERROR36* = 100286
|
||||||
|
GLU_NURBS_ERROR37* = 100287 #*** Backwards compatibility for old tesselator ****/
|
||||||
|
|
||||||
|
proc gluBeginPolygon*(tess: GLUtesselator){.dynlib: dllname,
|
||||||
|
importc: "gluBeginPolygon".}
|
||||||
|
proc gluNextContour*(tess: GLUtesselator, atype: GLenum){.dynlib: dllname,
|
||||||
|
importc: "gluNextContour".}
|
||||||
|
proc gluEndPolygon*(tess: GLUtesselator){.dynlib: dllname,
|
||||||
|
importc: "gluEndPolygon".}
|
||||||
|
const # Contours types -- obsolete!
|
||||||
|
GLU_CW* = 100120
|
||||||
|
GLU_CCW* = 100121
|
||||||
|
GLU_INTERIOR* = 100122
|
||||||
|
GLU_EXTERIOR* = 100123
|
||||||
|
GLU_UNKNOWN* = 100124 # Names without "TESS_" prefix
|
||||||
|
GLU_BEGIN* = GLU_TESS_BEGIN
|
||||||
|
GLU_VERTEX* = constGLU_TESS_VERTEX
|
||||||
|
GLU_END* = GLU_TESS_END
|
||||||
|
GLU_ERROR* = GLU_TESS_ERROR
|
||||||
|
GLU_EDGE_FLAG* = GLU_TESS_EDGE_FLAG
|
||||||
|
|
||||||
|
{.pop.}
|
||||||
|
# implementation
|
||||||
366
tests/deps/opengl-1.1.0/glut.nim
Normal file
366
tests/deps/opengl-1.1.0/glut.nim
Normal file
|
|
@ -0,0 +1,366 @@
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Adaption of the delphi3d.net OpenGL units to FreePascal
|
||||||
|
# Sebastian Guenther (sg@freepascal.org) in 2002
|
||||||
|
# These units are free to use
|
||||||
|
#
|
||||||
|
|
||||||
|
# Copyright (c) Mark J. Kilgard, 1994, 1995, 1996.
|
||||||
|
# This program is freely distributable without licensing fees and is
|
||||||
|
# provided without guarantee or warrantee expressed or implied. This
|
||||||
|
# program is -not- in the public domain.
|
||||||
|
#******************************************************************************
|
||||||
|
# Converted to Delphi by Tom Nuydens (tom@delphi3d.net)
|
||||||
|
# Contributions by Igor Karpov (glygrik@hotbox.ru)
|
||||||
|
# For the latest updates, visit Delphi3D: http://www.delphi3d.net
|
||||||
|
#******************************************************************************
|
||||||
|
|
||||||
|
import opengl
|
||||||
|
|
||||||
|
{.deadCodeElim: on.}
|
||||||
|
|
||||||
|
when defined(windows):
|
||||||
|
const
|
||||||
|
dllname = "glut32.dll"
|
||||||
|
elif defined(macosx):
|
||||||
|
const
|
||||||
|
dllname = "/System/Library/Frameworks/GLUT.framework/GLUT"
|
||||||
|
else:
|
||||||
|
const
|
||||||
|
dllname = "libglut.so.3"
|
||||||
|
type
|
||||||
|
TGlutVoidCallback* = proc (){.cdecl.}
|
||||||
|
TGlut1IntCallback* = proc (value: cint){.cdecl.}
|
||||||
|
TGlut2IntCallback* = proc (v1, v2: cint){.cdecl.}
|
||||||
|
TGlut3IntCallback* = proc (v1, v2, v3: cint){.cdecl.}
|
||||||
|
TGlut4IntCallback* = proc (v1, v2, v3, v4: cint){.cdecl.}
|
||||||
|
TGlut1Char2IntCallback* = proc (c: int8, v1, v2: cint){.cdecl.}
|
||||||
|
TGlut1UInt3IntCallback* = proc (u, v1, v2, v3: cint){.cdecl.}
|
||||||
|
|
||||||
|
{.deprecated: [Pointer: pointer].}
|
||||||
|
|
||||||
|
const
|
||||||
|
GLUT_API_VERSION* = 3
|
||||||
|
GLUT_XLIB_IMPLEMENTATION* = 12 # Display mode bit masks.
|
||||||
|
GLUT_RGB* = 0
|
||||||
|
GLUT_RGBA* = GLUT_RGB
|
||||||
|
GLUT_INDEX* = 1
|
||||||
|
GLUT_SINGLE* = 0
|
||||||
|
GLUT_DOUBLE* = 2
|
||||||
|
GLUT_ACCUM* = 4
|
||||||
|
GLUT_ALPHA* = 8
|
||||||
|
GLUT_DEPTH* = 16
|
||||||
|
GLUT_STENCIL* = 32
|
||||||
|
GLUT_MULTISAMPLE* = 128
|
||||||
|
GLUT_STEREO* = 256
|
||||||
|
GLUT_LUMINANCE* = 512 # Mouse buttons.
|
||||||
|
GLUT_LEFT_BUTTON* = 0
|
||||||
|
GLUT_MIDDLE_BUTTON* = 1
|
||||||
|
GLUT_RIGHT_BUTTON* = 2 # Mouse button state.
|
||||||
|
GLUT_DOWN* = 0
|
||||||
|
GLUT_UP* = 1 # function keys
|
||||||
|
GLUT_KEY_F1* = 1
|
||||||
|
GLUT_KEY_F2* = 2
|
||||||
|
GLUT_KEY_F3* = 3
|
||||||
|
GLUT_KEY_F4* = 4
|
||||||
|
GLUT_KEY_F5* = 5
|
||||||
|
GLUT_KEY_F6* = 6
|
||||||
|
GLUT_KEY_F7* = 7
|
||||||
|
GLUT_KEY_F8* = 8
|
||||||
|
GLUT_KEY_F9* = 9
|
||||||
|
GLUT_KEY_F10* = 10
|
||||||
|
GLUT_KEY_F11* = 11
|
||||||
|
GLUT_KEY_F12* = 12 # directional keys
|
||||||
|
GLUT_KEY_LEFT* = 100
|
||||||
|
GLUT_KEY_UP* = 101
|
||||||
|
GLUT_KEY_RIGHT* = 102
|
||||||
|
GLUT_KEY_DOWN* = 103
|
||||||
|
GLUT_KEY_PAGE_UP* = 104
|
||||||
|
GLUT_KEY_PAGE_DOWN* = 105
|
||||||
|
GLUT_KEY_HOME* = 106
|
||||||
|
GLUT_KEY_END* = 107
|
||||||
|
GLUT_KEY_INSERT* = 108 # Entry/exit state.
|
||||||
|
GLUT_LEFT* = 0
|
||||||
|
GLUT_ENTERED* = 1 # Menu usage state.
|
||||||
|
GLUT_MENU_NOT_IN_USE* = 0
|
||||||
|
GLUT_MENU_IN_USE* = 1 # Visibility state.
|
||||||
|
GLUT_NOT_VISIBLE* = 0
|
||||||
|
GLUT_VISIBLE* = 1 # Window status state.
|
||||||
|
GLUT_HIDDEN* = 0
|
||||||
|
GLUT_FULLY_RETAINED* = 1
|
||||||
|
GLUT_PARTIALLY_RETAINED* = 2
|
||||||
|
GLUT_FULLY_COVERED* = 3 # Color index component selection values.
|
||||||
|
GLUT_RED* = 0
|
||||||
|
GLUT_GREEN* = 1
|
||||||
|
GLUT_BLUE* = 2 # Layers for use.
|
||||||
|
GLUT_NORMAL* = 0
|
||||||
|
GLUT_OVERLAY* = 1
|
||||||
|
|
||||||
|
when defined(Windows):
|
||||||
|
const # Stroke font constants (use these in GLUT program).
|
||||||
|
GLUT_STROKE_ROMAN* = cast[pointer](0)
|
||||||
|
GLUT_STROKE_MONO_ROMAN* = cast[pointer](1) # Bitmap font constants (use these in GLUT program).
|
||||||
|
GLUT_BITMAP_9_BY_15* = cast[pointer](2)
|
||||||
|
GLUT_BITMAP_8_BY_13* = cast[pointer](3)
|
||||||
|
GLUT_BITMAP_TIMES_ROMAN_10* = cast[pointer](4)
|
||||||
|
GLUT_BITMAP_TIMES_ROMAN_24* = cast[pointer](5)
|
||||||
|
GLUT_BITMAP_HELVETICA_10* = cast[pointer](6)
|
||||||
|
GLUT_BITMAP_HELVETICA_12* = cast[pointer](7)
|
||||||
|
GLUT_BITMAP_HELVETICA_18* = cast[pointer](8)
|
||||||
|
else:
|
||||||
|
var # Stroke font constants (use these in GLUT program).
|
||||||
|
GLUT_STROKE_ROMAN*: pointer
|
||||||
|
GLUT_STROKE_MONO_ROMAN*: pointer # Bitmap font constants (use these in GLUT program).
|
||||||
|
GLUT_BITMAP_9_BY_15*: pointer
|
||||||
|
GLUT_BITMAP_8_BY_13*: pointer
|
||||||
|
GLUT_BITMAP_TIMES_ROMAN_10*: pointer
|
||||||
|
GLUT_BITMAP_TIMES_ROMAN_24*: pointer
|
||||||
|
GLUT_BITMAP_HELVETICA_10*: pointer
|
||||||
|
GLUT_BITMAP_HELVETICA_12*: pointer
|
||||||
|
GLUT_BITMAP_HELVETICA_18*: pointer
|
||||||
|
const # glutGet parameters.
|
||||||
|
GLUT_WINDOW_X* = 100
|
||||||
|
GLUT_WINDOW_Y* = 101
|
||||||
|
GLUT_WINDOW_WIDTH* = 102
|
||||||
|
GLUT_WINDOW_HEIGHT* = 103
|
||||||
|
GLUT_WINDOW_BUFFER_SIZE* = 104
|
||||||
|
GLUT_WINDOW_STENCIL_SIZE* = 105
|
||||||
|
GLUT_WINDOW_DEPTH_SIZE* = 106
|
||||||
|
GLUT_WINDOW_RED_SIZE* = 107
|
||||||
|
GLUT_WINDOW_GREEN_SIZE* = 108
|
||||||
|
GLUT_WINDOW_BLUE_SIZE* = 109
|
||||||
|
GLUT_WINDOW_ALPHA_SIZE* = 110
|
||||||
|
GLUT_WINDOW_ACCUM_RED_SIZE* = 111
|
||||||
|
GLUT_WINDOW_ACCUM_GREEN_SIZE* = 112
|
||||||
|
GLUT_WINDOW_ACCUM_BLUE_SIZE* = 113
|
||||||
|
GLUT_WINDOW_ACCUM_ALPHA_SIZE* = 114
|
||||||
|
GLUT_WINDOW_DOUBLEBUFFER* = 115
|
||||||
|
GLUT_WINDOW_RGBA* = 116
|
||||||
|
GLUT_WINDOW_PARENT* = 117
|
||||||
|
GLUT_WINDOW_NUM_CHILDREN* = 118
|
||||||
|
GLUT_WINDOW_COLORMAP_SIZE* = 119
|
||||||
|
GLUT_WINDOW_NUM_SAMPLES* = 120
|
||||||
|
GLUT_WINDOW_STEREO* = 121
|
||||||
|
GLUT_WINDOW_CURSOR* = 122
|
||||||
|
GLUT_SCREEN_WIDTH* = 200
|
||||||
|
GLUT_SCREEN_HEIGHT* = 201
|
||||||
|
GLUT_SCREEN_WIDTH_MM* = 202
|
||||||
|
GLUT_SCREEN_HEIGHT_MM* = 203
|
||||||
|
GLUT_MENU_NUM_ITEMS* = 300
|
||||||
|
GLUT_DISPLAY_MODE_POSSIBLE* = 400
|
||||||
|
GLUT_INIT_WINDOW_X* = 500
|
||||||
|
GLUT_INIT_WINDOW_Y* = 501
|
||||||
|
GLUT_INIT_WINDOW_WIDTH* = 502
|
||||||
|
GLUT_INIT_WINDOW_HEIGHT* = 503
|
||||||
|
constGLUT_INIT_DISPLAY_MODE* = 504
|
||||||
|
GLUT_ELAPSED_TIME* = 700
|
||||||
|
GLUT_WINDOW_FORMAT_ID* = 123 # glutDeviceGet parameters.
|
||||||
|
GLUT_HAS_KEYBOARD* = 600
|
||||||
|
GLUT_HAS_MOUSE* = 601
|
||||||
|
GLUT_HAS_SPACEBALL* = 602
|
||||||
|
GLUT_HAS_DIAL_AND_BUTTON_BOX* = 603
|
||||||
|
GLUT_HAS_TABLET* = 604
|
||||||
|
GLUT_NUM_MOUSE_BUTTONS* = 605
|
||||||
|
GLUT_NUM_SPACEBALL_BUTTONS* = 606
|
||||||
|
GLUT_NUM_BUTTON_BOX_BUTTONS* = 607
|
||||||
|
GLUT_NUM_DIALS* = 608
|
||||||
|
GLUT_NUM_TABLET_BUTTONS* = 609
|
||||||
|
GLUT_DEVICE_IGNORE_KEY_REPEAT* = 610
|
||||||
|
GLUT_DEVICE_KEY_REPEAT* = 611
|
||||||
|
GLUT_HAS_JOYSTICK* = 612
|
||||||
|
GLUT_OWNS_JOYSTICK* = 613
|
||||||
|
GLUT_JOYSTICK_BUTTONS* = 614
|
||||||
|
GLUT_JOYSTICK_AXES* = 615
|
||||||
|
GLUT_JOYSTICK_POLL_RATE* = 616 # glutLayerGet parameters.
|
||||||
|
GLUT_OVERLAY_POSSIBLE* = 800
|
||||||
|
GLUT_LAYER_IN_USE* = 801
|
||||||
|
GLUT_HAS_OVERLAY* = 802
|
||||||
|
GLUT_TRANSPARENT_INDEX* = 803
|
||||||
|
GLUT_NORMAL_DAMAGED* = 804
|
||||||
|
GLUT_OVERLAY_DAMAGED* = 805 # glutVideoResizeGet parameters.
|
||||||
|
GLUT_VIDEO_RESIZE_POSSIBLE* = 900
|
||||||
|
GLUT_VIDEO_RESIZE_IN_USE* = 901
|
||||||
|
GLUT_VIDEO_RESIZE_X_DELTA* = 902
|
||||||
|
GLUT_VIDEO_RESIZE_Y_DELTA* = 903
|
||||||
|
GLUT_VIDEO_RESIZE_WIDTH_DELTA* = 904
|
||||||
|
GLUT_VIDEO_RESIZE_HEIGHT_DELTA* = 905
|
||||||
|
GLUT_VIDEO_RESIZE_X* = 906
|
||||||
|
GLUT_VIDEO_RESIZE_Y* = 907
|
||||||
|
GLUT_VIDEO_RESIZE_WIDTH* = 908
|
||||||
|
GLUT_VIDEO_RESIZE_HEIGHT* = 909 # glutGetModifiers return mask.
|
||||||
|
GLUT_ACTIVE_SHIFT* = 1
|
||||||
|
GLUT_ACTIVE_CTRL* = 2
|
||||||
|
GLUT_ACTIVE_ALT* = 4 # glutSetCursor parameters.
|
||||||
|
# Basic arrows.
|
||||||
|
GLUT_CURSOR_RIGHT_ARROW* = 0
|
||||||
|
GLUT_CURSOR_LEFT_ARROW* = 1 # Symbolic cursor shapes.
|
||||||
|
GLUT_CURSOR_INFO* = 2
|
||||||
|
GLUT_CURSOR_DESTROY* = 3
|
||||||
|
GLUT_CURSOR_HELP* = 4
|
||||||
|
GLUT_CURSOR_CYCLE* = 5
|
||||||
|
GLUT_CURSOR_SPRAY* = 6
|
||||||
|
GLUT_CURSOR_WAIT* = 7
|
||||||
|
GLUT_CURSOR_TEXT* = 8
|
||||||
|
GLUT_CURSOR_CROSSHAIR* = 9 # Directional cursors.
|
||||||
|
GLUT_CURSOR_UP_DOWN* = 10
|
||||||
|
GLUT_CURSOR_LEFT_RIGHT* = 11 # Sizing cursors.
|
||||||
|
GLUT_CURSOR_TOP_SIDE* = 12
|
||||||
|
GLUT_CURSOR_BOTTOM_SIDE* = 13
|
||||||
|
GLUT_CURSOR_LEFT_SIDE* = 14
|
||||||
|
GLUT_CURSOR_RIGHT_SIDE* = 15
|
||||||
|
GLUT_CURSOR_TOP_LEFT_CORNER* = 16
|
||||||
|
GLUT_CURSOR_TOP_RIGHT_CORNER* = 17
|
||||||
|
GLUT_CURSOR_BOTTOM_RIGHT_CORNER* = 18
|
||||||
|
GLUT_CURSOR_BOTTOM_LEFT_CORNER* = 19 # Inherit from parent window.
|
||||||
|
GLUT_CURSOR_INHERIT* = 100 # Blank cursor.
|
||||||
|
GLUT_CURSOR_NONE* = 101 # Fullscreen crosshair (if available).
|
||||||
|
GLUT_CURSOR_FULL_CROSSHAIR* = 102 # GLUT device control sub-API.
|
||||||
|
# glutSetKeyRepeat modes.
|
||||||
|
GLUT_KEY_REPEAT_OFF* = 0
|
||||||
|
GLUT_KEY_REPEAT_ON* = 1
|
||||||
|
GLUT_KEY_REPEAT_DEFAULT* = 2 # Joystick button masks.
|
||||||
|
GLUT_JOYSTICK_BUTTON_A* = 1
|
||||||
|
GLUT_JOYSTICK_BUTTON_B* = 2
|
||||||
|
GLUT_JOYSTICK_BUTTON_C* = 4
|
||||||
|
GLUT_JOYSTICK_BUTTON_D* = 8 # GLUT game mode sub-API.
|
||||||
|
# glutGameModeGet.
|
||||||
|
GLUT_GAME_MODE_ACTIVE* = 0
|
||||||
|
GLUT_GAME_MODE_POSSIBLE* = 1
|
||||||
|
GLUT_GAME_MODE_WIDTH* = 2
|
||||||
|
GLUT_GAME_MODE_HEIGHT* = 3
|
||||||
|
GLUT_GAME_MODE_PIXEL_DEPTH* = 4
|
||||||
|
GLUT_GAME_MODE_REFRESH_RATE* = 5
|
||||||
|
GLUT_GAME_MODE_DISPLAY_CHANGED* = 6 # GLUT initialization sub-API.
|
||||||
|
|
||||||
|
{.push dynlib: dllname, importc.}
|
||||||
|
proc glutInit*(argcp: ptr cint, argv: pointer)
|
||||||
|
|
||||||
|
proc glutInit*() =
|
||||||
|
## version that passes `argc` and `argc` implicitely.
|
||||||
|
var
|
||||||
|
cmdLine {.importc: "cmdLine".}: array[0..255, cstring]
|
||||||
|
cmdCount {.importc: "cmdCount".}: cint
|
||||||
|
glutInit(addr(cmdCount), addr(cmdLine))
|
||||||
|
|
||||||
|
proc glutInitDisplayMode*(mode: int16)
|
||||||
|
proc glutInitDisplayString*(str: cstring)
|
||||||
|
proc glutInitWindowPosition*(x, y: int)
|
||||||
|
proc glutInitWindowSize*(width, height: int)
|
||||||
|
proc glutMainLoop*()
|
||||||
|
# GLUT window sub-API.
|
||||||
|
proc glutCreateWindow*(title: cstring): int
|
||||||
|
proc glutCreateSubWindow*(win, x, y, width, height: int): int
|
||||||
|
proc glutDestroyWindow*(win: int)
|
||||||
|
proc glutPostRedisplay*()
|
||||||
|
proc glutPostWindowRedisplay*(win: int)
|
||||||
|
proc glutSwapBuffers*()
|
||||||
|
proc glutSetWindow*(win: int)
|
||||||
|
proc glutSetWindowTitle*(title: cstring)
|
||||||
|
proc glutSetIconTitle*(title: cstring)
|
||||||
|
proc glutPositionWindow*(x, y: int)
|
||||||
|
proc glutReshapeWindow*(width, height: int)
|
||||||
|
proc glutPopWindow*()
|
||||||
|
proc glutPushWindow*()
|
||||||
|
proc glutIconifyWindow*()
|
||||||
|
proc glutShowWindow*()
|
||||||
|
proc glutHideWindow*()
|
||||||
|
proc glutFullScreen*()
|
||||||
|
proc glutSetCursor*(cursor: int)
|
||||||
|
proc glutWarpPointer*(x, y: int)
|
||||||
|
# GLUT overlay sub-API.
|
||||||
|
proc glutEstablishOverlay*()
|
||||||
|
proc glutRemoveOverlay*()
|
||||||
|
proc glutUseLayer*(layer: GLenum)
|
||||||
|
proc glutPostOverlayRedisplay*()
|
||||||
|
proc glutPostWindowOverlayRedisplay*(win: int)
|
||||||
|
proc glutShowOverlay*()
|
||||||
|
proc glutHideOverlay*()
|
||||||
|
# GLUT menu sub-API.
|
||||||
|
proc glutCreateMenu*(callback: TGlut1IntCallback): int
|
||||||
|
proc glutDestroyMenu*(menu: int)
|
||||||
|
proc glutSetMenu*(menu: int)
|
||||||
|
proc glutAddMenuEntry*(caption: cstring, value: int)
|
||||||
|
proc glutAddSubMenu*(caption: cstring, submenu: int)
|
||||||
|
proc glutChangeToMenuEntry*(item: int, caption: cstring, value: int)
|
||||||
|
proc glutChangeToSubMenu*(item: int, caption: cstring, submenu: int)
|
||||||
|
proc glutRemoveMenuItem*(item: int)
|
||||||
|
proc glutAttachMenu*(button: int)
|
||||||
|
proc glutDetachMenu*(button: int)
|
||||||
|
# GLUT window callback sub-API.
|
||||||
|
proc glutDisplayFunc*(f: TGlutVoidCallback)
|
||||||
|
proc glutReshapeFunc*(f: TGlut2IntCallback)
|
||||||
|
proc glutKeyboardFunc*(f: TGlut1Char2IntCallback)
|
||||||
|
proc glutMouseFunc*(f: TGlut4IntCallback)
|
||||||
|
proc glutMotionFunc*(f: TGlut2IntCallback)
|
||||||
|
proc glutPassiveMotionFunc*(f: TGlut2IntCallback)
|
||||||
|
proc glutEntryFunc*(f: TGlut1IntCallback)
|
||||||
|
proc glutVisibilityFunc*(f: TGlut1IntCallback)
|
||||||
|
proc glutIdleFunc*(f: TGlutVoidCallback)
|
||||||
|
proc glutTimerFunc*(millis: int16, f: TGlut1IntCallback, value: int)
|
||||||
|
proc glutMenuStateFunc*(f: TGlut1IntCallback)
|
||||||
|
proc glutSpecialFunc*(f: TGlut3IntCallback)
|
||||||
|
proc glutSpaceballMotionFunc*(f: TGlut3IntCallback)
|
||||||
|
proc glutSpaceballRotateFunc*(f: TGlut3IntCallback)
|
||||||
|
proc glutSpaceballButtonFunc*(f: TGlut2IntCallback)
|
||||||
|
proc glutButtonBoxFunc*(f: TGlut2IntCallback)
|
||||||
|
proc glutDialsFunc*(f: TGlut2IntCallback)
|
||||||
|
proc glutTabletMotionFunc*(f: TGlut2IntCallback)
|
||||||
|
proc glutTabletButtonFunc*(f: TGlut4IntCallback)
|
||||||
|
proc glutMenuStatusFunc*(f: TGlut3IntCallback)
|
||||||
|
proc glutOverlayDisplayFunc*(f: TGlutVoidCallback)
|
||||||
|
proc glutWindowStatusFunc*(f: TGlut1IntCallback)
|
||||||
|
proc glutKeyboardUpFunc*(f: TGlut1Char2IntCallback)
|
||||||
|
proc glutSpecialUpFunc*(f: TGlut3IntCallback)
|
||||||
|
proc glutJoystickFunc*(f: TGlut1UInt3IntCallback, pollInterval: int)
|
||||||
|
# GLUT color index sub-API.
|
||||||
|
proc glutSetColor*(cell: int, red, green, blue: GLfloat)
|
||||||
|
proc glutGetColor*(ndx, component: int): GLfloat
|
||||||
|
proc glutCopyColormap*(win: int)
|
||||||
|
# GLUT state retrieval sub-API.
|
||||||
|
# GLUT extension support sub-API
|
||||||
|
proc glutExtensionSupported*(name: cstring): int
|
||||||
|
# GLUT font sub-API
|
||||||
|
proc glutBitmapCharacter*(font: pointer, character: int)
|
||||||
|
proc glutBitmapWidth*(font: pointer, character: int): int
|
||||||
|
proc glutStrokeCharacter*(font: pointer, character: int)
|
||||||
|
proc glutStrokeWidth*(font: pointer, character: int): int
|
||||||
|
proc glutBitmapLength*(font: pointer, str: cstring): int
|
||||||
|
proc glutStrokeLength*(font: pointer, str: cstring): int
|
||||||
|
# GLUT pre-built models sub-API
|
||||||
|
proc glutWireSphere*(radius: GLdouble, slices, stacks: GLint)
|
||||||
|
proc glutSolidSphere*(radius: GLdouble, slices, stacks: GLint)
|
||||||
|
proc glutWireCone*(base, height: GLdouble, slices, stacks: GLint)
|
||||||
|
proc glutSolidCone*(base, height: GLdouble, slices, stacks: GLint)
|
||||||
|
proc glutWireCube*(size: GLdouble)
|
||||||
|
proc glutSolidCube*(size: GLdouble)
|
||||||
|
proc glutWireTorus*(innerRadius, outerRadius: GLdouble, sides, rings: GLint)
|
||||||
|
proc glutSolidTorus*(innerRadius, outerRadius: GLdouble, sides, rings: GLint)
|
||||||
|
proc glutWireDodecahedron*()
|
||||||
|
proc glutSolidDodecahedron*()
|
||||||
|
proc glutWireTeapot*(size: GLdouble)
|
||||||
|
proc glutSolidTeapot*(size: GLdouble)
|
||||||
|
proc glutWireOctahedron*()
|
||||||
|
proc glutSolidOctahedron*()
|
||||||
|
proc glutWireTetrahedron*()
|
||||||
|
proc glutSolidTetrahedron*()
|
||||||
|
proc glutWireIcosahedron*()
|
||||||
|
proc glutSolidIcosahedron*()
|
||||||
|
# GLUT video resize sub-API.
|
||||||
|
proc glutVideoResizeGet*(param: GLenum): int
|
||||||
|
proc glutSetupVideoResizing*()
|
||||||
|
proc glutStopVideoResizing*()
|
||||||
|
proc glutVideoResize*(x, y, width, height: int)
|
||||||
|
proc glutVideoPan*(x, y, width, height: int)
|
||||||
|
# GLUT debugging sub-API.
|
||||||
|
proc glutReportErrors*()
|
||||||
|
# GLUT device control sub-API.
|
||||||
|
proc glutIgnoreKeyRepeat*(ignore: int)
|
||||||
|
proc glutSetKeyRepeat*(repeatMode: int)
|
||||||
|
proc glutForceJoystickFunc*()
|
||||||
|
# GLUT game mode sub-API.
|
||||||
|
#example glutGameModeString('1280x1024:32@75');
|
||||||
|
proc glutGameModeString*(AString: cstring)
|
||||||
|
proc glutLeaveGameMode*()
|
||||||
|
proc glutGameModeGet*(mode: GLenum): int
|
||||||
|
# implementation
|
||||||
|
{.pop.} # dynlib: dllname, importc
|
||||||
154
tests/deps/opengl-1.1.0/glx.nim
Normal file
154
tests/deps/opengl-1.1.0/glx.nim
Normal file
|
|
@ -0,0 +1,154 @@
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Translation of the Mesa GLX headers for FreePascal
|
||||||
|
# Copyright (C) 1999 Sebastian Guenther
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Mesa 3-D graphics library
|
||||||
|
# Version: 3.0
|
||||||
|
# Copyright (C) 1995-1998 Brian Paul
|
||||||
|
#
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Library General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2 of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Library General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Library General Public
|
||||||
|
# License along with this library; if not, write to the Free
|
||||||
|
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
#
|
||||||
|
|
||||||
|
import X, XLib, XUtil, opengl
|
||||||
|
|
||||||
|
{.deadCodeElim: on.}
|
||||||
|
|
||||||
|
when defined(windows):
|
||||||
|
const
|
||||||
|
dllname = "GL.dll"
|
||||||
|
elif defined(macosx):
|
||||||
|
const
|
||||||
|
dllname = "/usr/X11R6/lib/libGL.dylib"
|
||||||
|
else:
|
||||||
|
const
|
||||||
|
dllname = "libGL.so"
|
||||||
|
const
|
||||||
|
GLX_USE_GL* = 1'i32
|
||||||
|
GLX_BUFFER_SIZE* = 2'i32
|
||||||
|
GLX_LEVEL* = 3'i32
|
||||||
|
GLX_RGBA* = 4'i32
|
||||||
|
GLX_DOUBLEBUFFER* = 5'i32
|
||||||
|
GLX_STEREO* = 6'i32
|
||||||
|
GLX_AUX_BUFFERS* = 7'i32
|
||||||
|
GLX_RED_SIZE* = 8'i32
|
||||||
|
GLX_GREEN_SIZE* = 9'i32
|
||||||
|
GLX_BLUE_SIZE* = 10'i32
|
||||||
|
GLX_ALPHA_SIZE* = 11'i32
|
||||||
|
GLX_DEPTH_SIZE* = 12'i32
|
||||||
|
GLX_STENCIL_SIZE* = 13'i32
|
||||||
|
GLX_ACCUM_RED_SIZE* = 14'i32
|
||||||
|
GLX_ACCUM_GREEN_SIZE* = 15'i32
|
||||||
|
GLX_ACCUM_BLUE_SIZE* = 16'i32
|
||||||
|
GLX_ACCUM_ALPHA_SIZE* = 17'i32 # GLX_EXT_visual_info extension
|
||||||
|
GLX_X_VISUAL_TYPE_EXT* = 0x00000022
|
||||||
|
GLX_TRANSPARENT_TYPE_EXT* = 0x00000023
|
||||||
|
GLX_TRANSPARENT_INDEX_VALUE_EXT* = 0x00000024
|
||||||
|
GLX_TRANSPARENT_RED_VALUE_EXT* = 0x00000025
|
||||||
|
GLX_TRANSPARENT_GREEN_VALUE_EXT* = 0x00000026
|
||||||
|
GLX_TRANSPARENT_BLUE_VALUE_EXT* = 0x00000027
|
||||||
|
GLX_TRANSPARENT_ALPHA_VALUE_EXT* = 0x00000028 # Error codes returned by glXGetConfig:
|
||||||
|
GLX_BAD_SCREEN* = 1
|
||||||
|
GLX_BAD_ATTRIBUTE* = 2
|
||||||
|
GLX_NO_EXTENSION* = 3
|
||||||
|
GLX_BAD_VISUAL* = 4
|
||||||
|
GLX_BAD_CONTEXT* = 5
|
||||||
|
GLX_BAD_VALUE* = 6
|
||||||
|
GLX_BAD_ENUM* = 7 # GLX 1.1 and later:
|
||||||
|
GLX_VENDOR* = 1
|
||||||
|
GLX_VERSION* = 2
|
||||||
|
GLX_EXTENSIONS* = 3 # GLX_visual_info extension
|
||||||
|
GLX_TRUE_COLOR_EXT* = 0x00008002
|
||||||
|
GLX_DIRECT_COLOR_EXT* = 0x00008003
|
||||||
|
GLX_PSEUDO_COLOR_EXT* = 0x00008004
|
||||||
|
GLX_STATIC_COLOR_EXT* = 0x00008005
|
||||||
|
GLX_GRAY_SCALE_EXT* = 0x00008006
|
||||||
|
GLX_STATIC_GRAY_EXT* = 0x00008007
|
||||||
|
GLX_NONE_EXT* = 0x00008000
|
||||||
|
GLX_TRANSPARENT_RGB_EXT* = 0x00008008
|
||||||
|
GLX_TRANSPARENT_INDEX_EXT* = 0x00008009
|
||||||
|
|
||||||
|
type # From XLib:
|
||||||
|
XPixmap* = TXID
|
||||||
|
XFont* = TXID
|
||||||
|
XColormap* = TXID
|
||||||
|
GLXContext* = pointer
|
||||||
|
GLXPixmap* = TXID
|
||||||
|
GLXDrawable* = TXID
|
||||||
|
GLXContextID* = TXID
|
||||||
|
TXPixmap* = XPixmap
|
||||||
|
TXFont* = XFont
|
||||||
|
TXColormap* = XColormap
|
||||||
|
TGLXContext* = GLXContext
|
||||||
|
TGLXPixmap* = GLXPixmap
|
||||||
|
TGLXDrawable* = GLXDrawable
|
||||||
|
TGLXContextID* = GLXContextID
|
||||||
|
|
||||||
|
proc glXChooseVisual*(dpy: PDisplay, screen: int, attribList: ptr int32): PXVisualInfo{.
|
||||||
|
cdecl, dynlib: dllname, importc: "glXChooseVisual".}
|
||||||
|
proc glXCreateContext*(dpy: PDisplay, vis: PXVisualInfo, shareList: GLXContext,
|
||||||
|
direct: bool): GLXContext{.cdecl, dynlib: dllname,
|
||||||
|
importc: "glXCreateContext".}
|
||||||
|
proc glXDestroyContext*(dpy: PDisplay, ctx: GLXContext){.cdecl, dynlib: dllname,
|
||||||
|
importc: "glXDestroyContext".}
|
||||||
|
proc glXMakeCurrent*(dpy: PDisplay, drawable: GLXDrawable, ctx: GLXContext): bool{.
|
||||||
|
cdecl, dynlib: dllname, importc: "glXMakeCurrent".}
|
||||||
|
proc glXCopyContext*(dpy: PDisplay, src, dst: GLXContext, mask: int32){.cdecl,
|
||||||
|
dynlib: dllname, importc: "glXCopyContext".}
|
||||||
|
proc glXSwapBuffers*(dpy: PDisplay, drawable: GLXDrawable){.cdecl,
|
||||||
|
dynlib: dllname, importc: "glXSwapBuffers".}
|
||||||
|
proc glXCreateGLXPixmap*(dpy: PDisplay, visual: PXVisualInfo, pixmap: XPixmap): GLXPixmap{.
|
||||||
|
cdecl, dynlib: dllname, importc: "glXCreateGLXPixmap".}
|
||||||
|
proc glXDestroyGLXPixmap*(dpy: PDisplay, pixmap: GLXPixmap){.cdecl,
|
||||||
|
dynlib: dllname, importc: "glXDestroyGLXPixmap".}
|
||||||
|
proc glXQueryExtension*(dpy: PDisplay, errorb, event: var int): bool{.cdecl,
|
||||||
|
dynlib: dllname, importc: "glXQueryExtension".}
|
||||||
|
proc glXQueryVersion*(dpy: PDisplay, maj, min: var int): bool{.cdecl,
|
||||||
|
dynlib: dllname, importc: "glXQueryVersion".}
|
||||||
|
proc glXIsDirect*(dpy: PDisplay, ctx: GLXContext): bool{.cdecl, dynlib: dllname,
|
||||||
|
importc: "glXIsDirect".}
|
||||||
|
proc glXGetConfig*(dpy: PDisplay, visual: PXVisualInfo, attrib: int,
|
||||||
|
value: var int): int{.cdecl, dynlib: dllname,
|
||||||
|
importc: "glXGetConfig".}
|
||||||
|
proc glXGetCurrentContext*(): GLXContext{.cdecl, dynlib: dllname,
|
||||||
|
importc: "glXGetCurrentContext".}
|
||||||
|
proc glXGetCurrentDrawable*(): GLXDrawable{.cdecl, dynlib: dllname,
|
||||||
|
importc: "glXGetCurrentDrawable".}
|
||||||
|
proc glXWaitGL*(){.cdecl, dynlib: dllname, importc: "glXWaitGL".}
|
||||||
|
proc glXWaitX*(){.cdecl, dynlib: dllname, importc: "glXWaitX".}
|
||||||
|
proc glXUseXFont*(font: XFont, first, count, list: int){.cdecl, dynlib: dllname,
|
||||||
|
importc: "glXUseXFont".}
|
||||||
|
# GLX 1.1 and later
|
||||||
|
proc glXQueryExtensionsString*(dpy: PDisplay, screen: int): cstring{.cdecl,
|
||||||
|
dynlib: dllname, importc: "glXQueryExtensionsString".}
|
||||||
|
proc glXQueryServerString*(dpy: PDisplay, screen, name: int): cstring{.cdecl,
|
||||||
|
dynlib: dllname, importc: "glXQueryServerString".}
|
||||||
|
proc glXGetClientString*(dpy: PDisplay, name: int): cstring{.cdecl,
|
||||||
|
dynlib: dllname, importc: "glXGetClientString".}
|
||||||
|
# Mesa GLX Extensions
|
||||||
|
proc glXCreateGLXPixmapMESA*(dpy: PDisplay, visual: PXVisualInfo,
|
||||||
|
pixmap: XPixmap, cmap: XColormap): GLXPixmap{.
|
||||||
|
cdecl, dynlib: dllname, importc: "glXCreateGLXPixmapMESA".}
|
||||||
|
proc glXReleaseBufferMESA*(dpy: PDisplay, d: GLXDrawable): bool{.cdecl,
|
||||||
|
dynlib: dllname, importc: "glXReleaseBufferMESA".}
|
||||||
|
proc glXCopySubBufferMESA*(dpy: PDisplay, drawbale: GLXDrawable,
|
||||||
|
x, y, width, height: int){.cdecl, dynlib: dllname,
|
||||||
|
importc: "glXCopySubBufferMESA".}
|
||||||
|
proc glXGetVideoSyncSGI*(counter: var int32): int{.cdecl, dynlib: dllname,
|
||||||
|
importc: "glXGetVideoSyncSGI".}
|
||||||
|
proc glXWaitVideoSyncSGI*(divisor, remainder: int, count: var int32): int{.
|
||||||
|
cdecl, dynlib: dllname, importc: "glXWaitVideoSyncSGI".}
|
||||||
|
# implementation
|
||||||
8481
tests/deps/opengl-1.1.0/opengl.nim
Normal file
8481
tests/deps/opengl-1.1.0/opengl.nim
Normal file
File diff suppressed because it is too large
Load diff
12
tests/deps/opengl-1.1.0/opengl.nimble
Normal file
12
tests/deps/opengl-1.1.0/opengl.nimble
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
# Package
|
||||||
|
|
||||||
|
version = "1.1.0"
|
||||||
|
author = "Andreas Rumpf"
|
||||||
|
description = "an OpenGL wrapper"
|
||||||
|
license = "MIT"
|
||||||
|
|
||||||
|
srcDir = "src"
|
||||||
|
|
||||||
|
# Dependencies"
|
||||||
|
|
||||||
|
requires "nim >= 0.10.3", "x11"
|
||||||
369
tests/deps/opengl-1.1.0/wingl.nim
Normal file
369
tests/deps/opengl-1.1.0/wingl.nim
Normal file
|
|
@ -0,0 +1,369 @@
|
||||||
|
import opengl, windows
|
||||||
|
|
||||||
|
{.deadCodeElim: on.}
|
||||||
|
|
||||||
|
proc wglGetExtensionsStringARB*(hdc: HDC): cstring{.dynlib: dllname,
|
||||||
|
importc: "wglGetExtensionsStringARB".}
|
||||||
|
const
|
||||||
|
WGL_FRONT_COLOR_BUFFER_BIT_ARB* = 0x00000001
|
||||||
|
WGL_BACK_COLOR_BUFFER_BIT_ARB* = 0x00000002
|
||||||
|
WGL_DEPTH_BUFFER_BIT_ARB* = 0x00000004
|
||||||
|
WGL_STENCIL_BUFFER_BIT_ARB* = 0x00000008
|
||||||
|
|
||||||
|
proc WinChoosePixelFormat*(DC: HDC, p2: PPixelFormatDescriptor): int{.
|
||||||
|
dynlib: "gdi32", importc: "ChoosePixelFormat".}
|
||||||
|
proc wglCreateBufferRegionARB*(hDC: HDC, iLayerPlane: TGLint, uType: TGLuint): THandle{.
|
||||||
|
dynlib: dllname, importc: "wglCreateBufferRegionARB".}
|
||||||
|
proc wglDeleteBufferRegionARB*(hRegion: THandle){.dynlib: dllname,
|
||||||
|
importc: "wglDeleteBufferRegionARB".}
|
||||||
|
proc wglSaveBufferRegionARB*(hRegion: THandle, x: TGLint, y: TGLint,
|
||||||
|
width: TGLint, height: TGLint): BOOL{.
|
||||||
|
dynlib: dllname, importc: "wglSaveBufferRegionARB".}
|
||||||
|
proc wglRestoreBufferRegionARB*(hRegion: THandle, x: TGLint, y: TGLint,
|
||||||
|
width: TGLint, height: TGLint, xSrc: TGLint,
|
||||||
|
ySrc: TGLint): BOOL{.dynlib: dllname,
|
||||||
|
importc: "wglRestoreBufferRegionARB".}
|
||||||
|
proc wglAllocateMemoryNV*(size: TGLsizei, readFrequency: TGLfloat,
|
||||||
|
writeFrequency: TGLfloat, priority: TGLfloat): PGLvoid{.
|
||||||
|
dynlib: dllname, importc: "wglAllocateMemoryNV".}
|
||||||
|
proc wglFreeMemoryNV*(pointer: PGLvoid){.dynlib: dllname,
|
||||||
|
importc: "wglFreeMemoryNV".}
|
||||||
|
const
|
||||||
|
WGL_IMAGE_BUFFER_MIN_ACCESS_I3D* = 0x00000001
|
||||||
|
WGL_IMAGE_BUFFER_LOCK_I3D* = 0x00000002
|
||||||
|
|
||||||
|
proc wglCreateImageBufferI3D*(hDC: HDC, dwSize: DWORD, uFlags: UINT): PGLvoid{.
|
||||||
|
dynlib: dllname, importc: "wglCreateImageBufferI3D".}
|
||||||
|
proc wglDestroyImageBufferI3D*(hDC: HDC, pAddress: PGLvoid): BOOL{.
|
||||||
|
dynlib: dllname, importc: "wglDestroyImageBufferI3D".}
|
||||||
|
proc wglAssociateImageBufferEventsI3D*(hdc: HDC, pEvent: PHandle,
|
||||||
|
pAddress: PGLvoid, pSize: PDWORD,
|
||||||
|
count: UINT): BOOL{.dynlib: dllname,
|
||||||
|
importc: "wglAssociateImageBufferEventsI3D".}
|
||||||
|
proc wglReleaseImageBufferEventsI3D*(hdc: HDC, pAddress: PGLvoid, count: UINT): BOOL{.
|
||||||
|
dynlib: dllname, importc: "wglReleaseImageBufferEventsI3D".}
|
||||||
|
proc wglEnableFrameLockI3D*(): BOOL{.dynlib: dllname,
|
||||||
|
importc: "wglEnableFrameLockI3D".}
|
||||||
|
proc wglDisableFrameLockI3D*(): BOOL{.dynlib: dllname,
|
||||||
|
importc: "wglDisableFrameLockI3D".}
|
||||||
|
proc wglIsEnabledFrameLockI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname,
|
||||||
|
importc: "wglIsEnabledFrameLockI3D".}
|
||||||
|
proc wglQueryFrameLockMasterI3D*(pFlag: PBOOL): BOOL{.dynlib: dllname,
|
||||||
|
importc: "wglQueryFrameLockMasterI3D".}
|
||||||
|
proc wglGetFrameUsageI3D*(pUsage: PGLfloat): BOOL{.dynlib: dllname,
|
||||||
|
importc: "wglGetFrameUsageI3D".}
|
||||||
|
proc wglBeginFrameTrackingI3D*(): BOOL{.dynlib: dllname,
|
||||||
|
importc: "wglBeginFrameTrackingI3D".}
|
||||||
|
proc wglEndFrameTrackingI3D*(): BOOL{.dynlib: dllname,
|
||||||
|
importc: "wglEndFrameTrackingI3D".}
|
||||||
|
proc wglQueryFrameTrackingI3D*(pFrameCount: PDWORD, pMissedFrames: PDWORD,
|
||||||
|
pLastMissedUsage: PGLfloat): BOOL{.
|
||||||
|
dynlib: dllname, importc: "wglQueryFrameTrackingI3D".}
|
||||||
|
const
|
||||||
|
WGL_NUMBER_PIXEL_FORMATS_ARB* = 0x00002000
|
||||||
|
WGL_DRAW_TO_WINDOW_ARB* = 0x00002001
|
||||||
|
WGL_DRAW_TO_BITMAP_ARB* = 0x00002002
|
||||||
|
WGL_ACCELERATION_ARB* = 0x00002003
|
||||||
|
WGL_NEED_PALETTE_ARB* = 0x00002004
|
||||||
|
WGL_NEED_SYSTEM_PALETTE_ARB* = 0x00002005
|
||||||
|
WGL_SWAP_LAYER_BUFFERS_ARB* = 0x00002006
|
||||||
|
WGL_SWAP_METHOD_ARB* = 0x00002007
|
||||||
|
WGL_NUMBER_OVERLAYS_ARB* = 0x00002008
|
||||||
|
WGL_NUMBER_UNDERLAYS_ARB* = 0x00002009
|
||||||
|
WGL_TRANSPARENT_ARB* = 0x0000200A
|
||||||
|
WGL_TRANSPARENT_RED_VALUE_ARB* = 0x00002037
|
||||||
|
WGL_TRANSPARENT_GREEN_VALUE_ARB* = 0x00002038
|
||||||
|
WGL_TRANSPARENT_BLUE_VALUE_ARB* = 0x00002039
|
||||||
|
WGL_TRANSPARENT_ALPHA_VALUE_ARB* = 0x0000203A
|
||||||
|
WGL_TRANSPARENT_INDEX_VALUE_ARB* = 0x0000203B
|
||||||
|
WGL_SHARE_DEPTH_ARB* = 0x0000200C
|
||||||
|
WGL_SHARE_STENCIL_ARB* = 0x0000200D
|
||||||
|
WGL_SHARE_ACCUM_ARB* = 0x0000200E
|
||||||
|
WGL_SUPPORT_GDI_ARB* = 0x0000200F
|
||||||
|
WGL_SUPPORT_OPENGL_ARB* = 0x00002010
|
||||||
|
WGL_DOUBLE_BUFFER_ARB* = 0x00002011
|
||||||
|
WGL_STEREO_ARB* = 0x00002012
|
||||||
|
WGL_PIXEL_TYPE_ARB* = 0x00002013
|
||||||
|
WGL_COLOR_BITS_ARB* = 0x00002014
|
||||||
|
WGL_RED_BITS_ARB* = 0x00002015
|
||||||
|
WGL_RED_SHIFT_ARB* = 0x00002016
|
||||||
|
WGL_GREEN_BITS_ARB* = 0x00002017
|
||||||
|
WGL_GREEN_SHIFT_ARB* = 0x00002018
|
||||||
|
WGL_BLUE_BITS_ARB* = 0x00002019
|
||||||
|
WGL_BLUE_SHIFT_ARB* = 0x0000201A
|
||||||
|
WGL_ALPHA_BITS_ARB* = 0x0000201B
|
||||||
|
WGL_ALPHA_SHIFT_ARB* = 0x0000201C
|
||||||
|
WGL_ACCUM_BITS_ARB* = 0x0000201D
|
||||||
|
WGL_ACCUM_RED_BITS_ARB* = 0x0000201E
|
||||||
|
WGL_ACCUM_GREEN_BITS_ARB* = 0x0000201F
|
||||||
|
WGL_ACCUM_BLUE_BITS_ARB* = 0x00002020
|
||||||
|
WGL_ACCUM_ALPHA_BITS_ARB* = 0x00002021
|
||||||
|
WGL_DEPTH_BITS_ARB* = 0x00002022
|
||||||
|
WGL_STENCIL_BITS_ARB* = 0x00002023
|
||||||
|
WGL_AUX_BUFFERS_ARB* = 0x00002024
|
||||||
|
WGL_NO_ACCELERATION_ARB* = 0x00002025
|
||||||
|
WGL_GENERIC_ACCELERATION_ARB* = 0x00002026
|
||||||
|
WGL_FULL_ACCELERATION_ARB* = 0x00002027
|
||||||
|
WGL_SWAP_EXCHANGE_ARB* = 0x00002028
|
||||||
|
WGL_SWAP_COPY_ARB* = 0x00002029
|
||||||
|
WGL_SWAP_UNDEFINED_ARB* = 0x0000202A
|
||||||
|
WGL_TYPE_RGBA_ARB* = 0x0000202B
|
||||||
|
WGL_TYPE_COLORINDEX_ARB* = 0x0000202C
|
||||||
|
|
||||||
|
proc wglGetPixelFormatAttribivARB*(hdc: HDC, iPixelFormat: TGLint,
|
||||||
|
iLayerPlane: TGLint, nAttributes: TGLuint,
|
||||||
|
piAttributes: PGLint, piValues: PGLint): BOOL{.
|
||||||
|
dynlib: dllname, importc: "wglGetPixelFormatAttribivARB".}
|
||||||
|
proc wglGetPixelFormatAttribfvARB*(hdc: HDC, iPixelFormat: TGLint,
|
||||||
|
iLayerPlane: TGLint, nAttributes: TGLuint,
|
||||||
|
piAttributes: PGLint, pfValues: PGLfloat): BOOL{.
|
||||||
|
dynlib: dllname, importc: "wglGetPixelFormatAttribfvARB".}
|
||||||
|
proc wglChoosePixelFormatARB*(hdc: HDC, piAttribIList: PGLint,
|
||||||
|
pfAttribFList: PGLfloat, nMaxFormats: TGLuint,
|
||||||
|
piFormats: PGLint, nNumFormats: PGLuint): BOOL{.
|
||||||
|
dynlib: dllname, importc: "wglChoosePixelFormatARB".}
|
||||||
|
const
|
||||||
|
WGL_ERROR_INVALID_PIXEL_TYPE_ARB* = 0x00002043
|
||||||
|
WGL_ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB* = 0x00002054
|
||||||
|
|
||||||
|
proc wglMakeContextCurrentARB*(hDrawDC: HDC, hReadDC: HDC, hglrc: HGLRC): BOOL{.
|
||||||
|
dynlib: dllname, importc: "wglMakeContextCurrentARB".}
|
||||||
|
proc wglGetCurrentReadDCARB*(): HDC{.dynlib: dllname,
|
||||||
|
importc: "wglGetCurrentReadDCARB".}
|
||||||
|
const
|
||||||
|
WGL_DRAW_TO_PBUFFER_ARB* = 0x0000202D # WGL_DRAW_TO_PBUFFER_ARB { already defined }
|
||||||
|
WGL_MAX_PBUFFER_PIXELS_ARB* = 0x0000202E
|
||||||
|
WGL_MAX_PBUFFER_WIDTH_ARB* = 0x0000202F
|
||||||
|
WGL_MAX_PBUFFER_HEIGHT_ARB* = 0x00002030
|
||||||
|
WGL_PBUFFER_LARGEST_ARB* = 0x00002033
|
||||||
|
WGL_PBUFFER_WIDTH_ARB* = 0x00002034
|
||||||
|
WGL_PBUFFER_HEIGHT_ARB* = 0x00002035
|
||||||
|
WGL_PBUFFER_LOST_ARB* = 0x00002036
|
||||||
|
|
||||||
|
proc wglCreatePbufferARB*(hDC: HDC, iPixelFormat: TGLint, iWidth: TGLint,
|
||||||
|
iHeight: TGLint, piAttribList: PGLint): THandle{.
|
||||||
|
dynlib: dllname, importc: "wglCreatePbufferARB".}
|
||||||
|
proc wglGetPbufferDCARB*(hPbuffer: THandle): HDC{.dynlib: dllname,
|
||||||
|
importc: "wglGetPbufferDCARB".}
|
||||||
|
proc wglReleasePbufferDCARB*(hPbuffer: THandle, hDC: HDC): TGLint{.
|
||||||
|
dynlib: dllname, importc: "wglReleasePbufferDCARB".}
|
||||||
|
proc wglDestroyPbufferARB*(hPbuffer: THandle): BOOL{.dynlib: dllname,
|
||||||
|
importc: "wglDestroyPbufferARB".}
|
||||||
|
proc wglQueryPbufferARB*(hPbuffer: THandle, iAttribute: TGLint, piValue: PGLint): BOOL{.
|
||||||
|
dynlib: dllname, importc: "wglQueryPbufferARB".}
|
||||||
|
proc wglSwapIntervalEXT*(interval: TGLint): BOOL{.dynlib: dllname,
|
||||||
|
importc: "wglSwapIntervalEXT".}
|
||||||
|
proc wglGetSwapIntervalEXT*(): TGLint{.dynlib: dllname,
|
||||||
|
importc: "wglGetSwapIntervalEXT".}
|
||||||
|
const
|
||||||
|
WGL_BIND_TO_TEXTURE_RGB_ARB* = 0x00002070
|
||||||
|
WGL_BIND_TO_TEXTURE_RGBA_ARB* = 0x00002071
|
||||||
|
WGL_TEXTURE_FORMAT_ARB* = 0x00002072
|
||||||
|
WGL_TEXTURE_TARGET_ARB* = 0x00002073
|
||||||
|
WGL_MIPMAP_TEXTURE_ARB* = 0x00002074
|
||||||
|
WGL_TEXTURE_RGB_ARB* = 0x00002075
|
||||||
|
WGL_TEXTURE_RGBA_ARB* = 0x00002076
|
||||||
|
WGL_NO_TEXTURE_ARB* = 0x00002077
|
||||||
|
WGL_TEXTURE_CUBE_MAP_ARB* = 0x00002078
|
||||||
|
WGL_TEXTURE_1D_ARB* = 0x00002079
|
||||||
|
WGL_TEXTURE_2D_ARB* = 0x0000207A # WGL_NO_TEXTURE_ARB { already defined }
|
||||||
|
WGL_MIPMAP_LEVEL_ARB* = 0x0000207B
|
||||||
|
WGL_CUBE_MAP_FACE_ARB* = 0x0000207C
|
||||||
|
WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB* = 0x0000207D
|
||||||
|
WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB* = 0x0000207E
|
||||||
|
WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB* = 0x0000207F
|
||||||
|
WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB* = 0x00002080
|
||||||
|
WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB* = 0x00002081
|
||||||
|
WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB* = 0x00002082
|
||||||
|
WGL_FRONT_LEFT_ARB* = 0x00002083
|
||||||
|
WGL_FRONT_RIGHT_ARB* = 0x00002084
|
||||||
|
WGL_BACK_LEFT_ARB* = 0x00002085
|
||||||
|
WGL_BACK_RIGHT_ARB* = 0x00002086
|
||||||
|
WGL_AUX0_ARB* = 0x00002087
|
||||||
|
WGL_AUX1_ARB* = 0x00002088
|
||||||
|
WGL_AUX2_ARB* = 0x00002089
|
||||||
|
WGL_AUX3_ARB* = 0x0000208A
|
||||||
|
WGL_AUX4_ARB* = 0x0000208B
|
||||||
|
WGL_AUX5_ARB* = 0x0000208C
|
||||||
|
WGL_AUX6_ARB* = 0x0000208D
|
||||||
|
WGL_AUX7_ARB* = 0x0000208E
|
||||||
|
WGL_AUX8_ARB* = 0x0000208F
|
||||||
|
WGL_AUX9_ARB* = 0x00002090
|
||||||
|
|
||||||
|
proc wglBindTexImageARB*(hPbuffer: THandle, iBuffer: TGLint): BOOL{.
|
||||||
|
dynlib: dllname, importc: "wglBindTexImageARB".}
|
||||||
|
proc wglReleaseTexImageARB*(hPbuffer: THandle, iBuffer: TGLint): BOOL{.
|
||||||
|
dynlib: dllname, importc: "wglReleaseTexImageARB".}
|
||||||
|
proc wglSetPbufferAttribARB*(hPbuffer: THandle, piAttribList: PGLint): BOOL{.
|
||||||
|
dynlib: dllname, importc: "wglSetPbufferAttribARB".}
|
||||||
|
proc wglGetExtensionsStringEXT*(): cstring{.dynlib: dllname,
|
||||||
|
importc: "wglGetExtensionsStringEXT".}
|
||||||
|
proc wglMakeContextCurrentEXT*(hDrawDC: HDC, hReadDC: HDC, hglrc: HGLRC): BOOL{.
|
||||||
|
dynlib: dllname, importc: "wglMakeContextCurrentEXT".}
|
||||||
|
proc wglGetCurrentReadDCEXT*(): HDC{.dynlib: dllname,
|
||||||
|
importc: "wglGetCurrentReadDCEXT".}
|
||||||
|
const
|
||||||
|
WGL_DRAW_TO_PBUFFER_EXT* = 0x0000202D
|
||||||
|
WGL_MAX_PBUFFER_PIXELS_EXT* = 0x0000202E
|
||||||
|
WGL_MAX_PBUFFER_WIDTH_EXT* = 0x0000202F
|
||||||
|
WGL_MAX_PBUFFER_HEIGHT_EXT* = 0x00002030
|
||||||
|
WGL_OPTIMAL_PBUFFER_WIDTH_EXT* = 0x00002031
|
||||||
|
WGL_OPTIMAL_PBUFFER_HEIGHT_EXT* = 0x00002032
|
||||||
|
WGL_PBUFFER_LARGEST_EXT* = 0x00002033
|
||||||
|
WGL_PBUFFER_WIDTH_EXT* = 0x00002034
|
||||||
|
WGL_PBUFFER_HEIGHT_EXT* = 0x00002035
|
||||||
|
|
||||||
|
proc wglCreatePbufferEXT*(hDC: HDC, iPixelFormat: TGLint, iWidth: TGLint,
|
||||||
|
iHeight: TGLint, piAttribList: PGLint): THandle{.
|
||||||
|
dynlib: dllname, importc: "wglCreatePbufferEXT".}
|
||||||
|
proc wglGetPbufferDCEXT*(hPbuffer: THandle): HDC{.dynlib: dllname,
|
||||||
|
importc: "wglGetPbufferDCEXT".}
|
||||||
|
proc wglReleasePbufferDCEXT*(hPbuffer: THandle, hDC: HDC): TGLint{.
|
||||||
|
dynlib: dllname, importc: "wglReleasePbufferDCEXT".}
|
||||||
|
proc wglDestroyPbufferEXT*(hPbuffer: THandle): BOOL{.dynlib: dllname,
|
||||||
|
importc: "wglDestroyPbufferEXT".}
|
||||||
|
proc wglQueryPbufferEXT*(hPbuffer: THandle, iAttribute: TGLint, piValue: PGLint): BOOL{.
|
||||||
|
dynlib: dllname, importc: "wglQueryPbufferEXT".}
|
||||||
|
const
|
||||||
|
WGL_NUMBER_PIXEL_FORMATS_EXT* = 0x00002000
|
||||||
|
WGL_DRAW_TO_WINDOW_EXT* = 0x00002001
|
||||||
|
WGL_DRAW_TO_BITMAP_EXT* = 0x00002002
|
||||||
|
WGL_ACCELERATION_EXT* = 0x00002003
|
||||||
|
WGL_NEED_PALETTE_EXT* = 0x00002004
|
||||||
|
WGL_NEED_SYSTEM_PALETTE_EXT* = 0x00002005
|
||||||
|
WGL_SWAP_LAYER_BUFFERS_EXT* = 0x00002006
|
||||||
|
WGL_SWAP_METHOD_EXT* = 0x00002007
|
||||||
|
WGL_NUMBER_OVERLAYS_EXT* = 0x00002008
|
||||||
|
WGL_NUMBER_UNDERLAYS_EXT* = 0x00002009
|
||||||
|
WGL_TRANSPARENT_EXT* = 0x0000200A
|
||||||
|
WGL_TRANSPARENT_VALUE_EXT* = 0x0000200B
|
||||||
|
WGL_SHARE_DEPTH_EXT* = 0x0000200C
|
||||||
|
WGL_SHARE_STENCIL_EXT* = 0x0000200D
|
||||||
|
WGL_SHARE_ACCUM_EXT* = 0x0000200E
|
||||||
|
WGL_SUPPORT_GDI_EXT* = 0x0000200F
|
||||||
|
WGL_SUPPORT_OPENGL_EXT* = 0x00002010
|
||||||
|
WGL_DOUBLE_BUFFER_EXT* = 0x00002011
|
||||||
|
WGL_STEREO_EXT* = 0x00002012
|
||||||
|
WGL_PIXEL_TYPE_EXT* = 0x00002013
|
||||||
|
WGL_COLOR_BITS_EXT* = 0x00002014
|
||||||
|
WGL_RED_BITS_EXT* = 0x00002015
|
||||||
|
WGL_RED_SHIFT_EXT* = 0x00002016
|
||||||
|
WGL_GREEN_BITS_EXT* = 0x00002017
|
||||||
|
WGL_GREEN_SHIFT_EXT* = 0x00002018
|
||||||
|
WGL_BLUE_BITS_EXT* = 0x00002019
|
||||||
|
WGL_BLUE_SHIFT_EXT* = 0x0000201A
|
||||||
|
WGL_ALPHA_BITS_EXT* = 0x0000201B
|
||||||
|
WGL_ALPHA_SHIFT_EXT* = 0x0000201C
|
||||||
|
WGL_ACCUM_BITS_EXT* = 0x0000201D
|
||||||
|
WGL_ACCUM_RED_BITS_EXT* = 0x0000201E
|
||||||
|
WGL_ACCUM_GREEN_BITS_EXT* = 0x0000201F
|
||||||
|
WGL_ACCUM_BLUE_BITS_EXT* = 0x00002020
|
||||||
|
WGL_ACCUM_ALPHA_BITS_EXT* = 0x00002021
|
||||||
|
WGL_DEPTH_BITS_EXT* = 0x00002022
|
||||||
|
WGL_STENCIL_BITS_EXT* = 0x00002023
|
||||||
|
WGL_AUX_BUFFERS_EXT* = 0x00002024
|
||||||
|
WGL_NO_ACCELERATION_EXT* = 0x00002025
|
||||||
|
WGL_GENERIC_ACCELERATION_EXT* = 0x00002026
|
||||||
|
WGL_FULL_ACCELERATION_EXT* = 0x00002027
|
||||||
|
WGL_SWAP_EXCHANGE_EXT* = 0x00002028
|
||||||
|
WGL_SWAP_COPY_EXT* = 0x00002029
|
||||||
|
WGL_SWAP_UNDEFINED_EXT* = 0x0000202A
|
||||||
|
WGL_TYPE_RGBA_EXT* = 0x0000202B
|
||||||
|
WGL_TYPE_COLORINDEX_EXT* = 0x0000202C
|
||||||
|
|
||||||
|
proc wglGetPixelFormatAttribivEXT*(hdc: HDC, iPixelFormat: TGLint,
|
||||||
|
iLayerPlane: TGLint, nAttributes: TGLuint,
|
||||||
|
piAttributes: PGLint, piValues: PGLint): BOOL{.
|
||||||
|
dynlib: dllname, importc: "wglGetPixelFormatAttribivEXT".}
|
||||||
|
proc wglGetPixelFormatAttribfvEXT*(hdc: HDC, iPixelFormat: TGLint,
|
||||||
|
iLayerPlane: TGLint, nAttributes: TGLuint,
|
||||||
|
piAttributes: PGLint, pfValues: PGLfloat): BOOL{.
|
||||||
|
dynlib: dllname, importc: "wglGetPixelFormatAttribfvEXT".}
|
||||||
|
proc wglChoosePixelFormatEXT*(hdc: HDC, piAttribIList: PGLint,
|
||||||
|
pfAttribFList: PGLfloat, nMaxFormats: TGLuint,
|
||||||
|
piFormats: PGLint, nNumFormats: PGLuint): BOOL{.
|
||||||
|
dynlib: dllname, importc: "wglChoosePixelFormatEXT".}
|
||||||
|
const
|
||||||
|
WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D* = 0x00002050
|
||||||
|
WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D* = 0x00002051
|
||||||
|
WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D* = 0x00002052
|
||||||
|
WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D* = 0x00002053
|
||||||
|
|
||||||
|
proc wglGetDigitalVideoParametersI3D*(hDC: HDC, iAttribute: TGLint,
|
||||||
|
piValue: PGLint): BOOL{.dynlib: dllname,
|
||||||
|
importc: "wglGetDigitalVideoParametersI3D".}
|
||||||
|
proc wglSetDigitalVideoParametersI3D*(hDC: HDC, iAttribute: TGLint,
|
||||||
|
piValue: PGLint): BOOL{.dynlib: dllname,
|
||||||
|
importc: "wglSetDigitalVideoParametersI3D".}
|
||||||
|
const
|
||||||
|
WGL_GAMMA_TABLE_SIZE_I3D* = 0x0000204E
|
||||||
|
WGL_GAMMA_EXCLUDE_DESKTOP_I3D* = 0x0000204F
|
||||||
|
|
||||||
|
proc wglGetGammaTableParametersI3D*(hDC: HDC, iAttribute: TGLint,
|
||||||
|
piValue: PGLint): BOOL{.dynlib: dllname,
|
||||||
|
importc: "wglGetGammaTableParametersI3D".}
|
||||||
|
proc wglSetGammaTableParametersI3D*(hDC: HDC, iAttribute: TGLint,
|
||||||
|
piValue: PGLint): BOOL{.dynlib: dllname,
|
||||||
|
importc: "wglSetGammaTableParametersI3D".}
|
||||||
|
proc wglGetGammaTableI3D*(hDC: HDC, iEntries: TGLint, puRed: PGLUSHORT,
|
||||||
|
puGreen: PGLUSHORT, puBlue: PGLUSHORT): BOOL{.
|
||||||
|
dynlib: dllname, importc: "wglGetGammaTableI3D".}
|
||||||
|
proc wglSetGammaTableI3D*(hDC: HDC, iEntries: TGLint, puRed: PGLUSHORT,
|
||||||
|
puGreen: PGLUSHORT, puBlue: PGLUSHORT): BOOL{.
|
||||||
|
dynlib: dllname, importc: "wglSetGammaTableI3D".}
|
||||||
|
const
|
||||||
|
WGL_GENLOCK_SOURCE_MULTIVIEW_I3D* = 0x00002044
|
||||||
|
WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D* = 0x00002045
|
||||||
|
WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D* = 0x00002046
|
||||||
|
WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D* = 0x00002047
|
||||||
|
WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D* = 0x00002048
|
||||||
|
WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D* = 0x00002049
|
||||||
|
WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D* = 0x0000204A
|
||||||
|
WGL_GENLOCK_SOURCE_EDGE_RISING_I3D* = 0x0000204B
|
||||||
|
WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D* = 0x0000204C
|
||||||
|
WGL_FLOAT_COMPONENTS_NV* = 0x000020B0
|
||||||
|
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV* = 0x000020B1
|
||||||
|
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV* = 0x000020B2
|
||||||
|
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV* = 0x000020B3
|
||||||
|
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV* = 0x000020B4
|
||||||
|
WGL_TEXTURE_FLOAT_R_NV* = 0x000020B5
|
||||||
|
WGL_TEXTURE_FLOAT_RG_NV* = 0x000020B6
|
||||||
|
WGL_TEXTURE_FLOAT_RGB_NV* = 0x000020B7
|
||||||
|
WGL_TEXTURE_FLOAT_RGBA_NV* = 0x000020B8
|
||||||
|
|
||||||
|
proc wglEnableGenlockI3D*(hDC: HDC): BOOL{.dynlib: dllname,
|
||||||
|
importc: "wglEnableGenlockI3D".}
|
||||||
|
proc wglDisableGenlockI3D*(hDC: HDC): BOOL{.dynlib: dllname,
|
||||||
|
importc: "wglDisableGenlockI3D".}
|
||||||
|
proc wglIsEnabledGenlockI3D*(hDC: HDC, pFlag: PBOOL): BOOL{.dynlib: dllname,
|
||||||
|
importc: "wglIsEnabledGenlockI3D".}
|
||||||
|
proc wglGenlockSourceI3D*(hDC: HDC, uSource: TGLuint): BOOL{.dynlib: dllname,
|
||||||
|
importc: "wglGenlockSourceI3D".}
|
||||||
|
proc wglGetGenlockSourceI3D*(hDC: HDC, uSource: PGLUINT): BOOL{.dynlib: dllname,
|
||||||
|
importc: "wglGetGenlockSourceI3D".}
|
||||||
|
proc wglGenlockSourceEdgeI3D*(hDC: HDC, uEdge: TGLuint): BOOL{.dynlib: dllname,
|
||||||
|
importc: "wglGenlockSourceEdgeI3D".}
|
||||||
|
proc wglGetGenlockSourceEdgeI3D*(hDC: HDC, uEdge: PGLUINT): BOOL{.
|
||||||
|
dynlib: dllname, importc: "wglGetGenlockSourceEdgeI3D".}
|
||||||
|
proc wglGenlockSampleRateI3D*(hDC: HDC, uRate: TGLuint): BOOL{.dynlib: dllname,
|
||||||
|
importc: "wglGenlockSampleRateI3D".}
|
||||||
|
proc wglGetGenlockSampleRateI3D*(hDC: HDC, uRate: PGLUINT): BOOL{.
|
||||||
|
dynlib: dllname, importc: "wglGetGenlockSampleRateI3D".}
|
||||||
|
proc wglGenlockSourceDelayI3D*(hDC: HDC, uDelay: TGLuint): BOOL{.
|
||||||
|
dynlib: dllname, importc: "wglGenlockSourceDelayI3D".}
|
||||||
|
proc wglGetGenlockSourceDelayI3D*(hDC: HDC, uDelay: PGLUINT): BOOL{.
|
||||||
|
dynlib: dllname, importc: "wglGetGenlockSourceDelayI3D".}
|
||||||
|
proc wglQueryGenlockMaxSourceDelayI3D*(hDC: HDC, uMaxLineDelay: PGLUINT,
|
||||||
|
uMaxPixelDelay: PGLUINT): BOOL{.
|
||||||
|
dynlib: dllname, importc: "wglQueryGenlockMaxSourceDelayI3D".}
|
||||||
|
const
|
||||||
|
WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV* = 0x000020A0
|
||||||
|
WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV* = 0x000020A1
|
||||||
|
WGL_TEXTURE_RECTANGLE_NV* = 0x000020A2
|
||||||
|
|
||||||
|
const
|
||||||
|
WGL_RGBA_FLOAT_MODE_ATI* = 0x00008820
|
||||||
|
WGL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI* = 0x00008835
|
||||||
|
WGL_TYPE_RGBA_FLOAT_ATI* = 0x000021A0
|
||||||
|
|
||||||
|
# implementation
|
||||||
110
tests/deps/x11-1.0/cursorfont.nim
Normal file
110
tests/deps/x11-1.0/cursorfont.nim
Normal file
|
|
@ -0,0 +1,110 @@
|
||||||
|
# $Xorg: cursorfont.h,v 1.4 2001/02/09 02:03:39 xorgcvs Exp $
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#Copyright 1987, 1998 The Open Group
|
||||||
|
#
|
||||||
|
#Permission to use, copy, modify, distribute, and sell this software and its
|
||||||
|
#documentation for any purpose is hereby granted without fee, provided that
|
||||||
|
#the above copyright notice appear in all copies and that both that
|
||||||
|
#copyright notice and this permission notice appear in supporting
|
||||||
|
#documentation.
|
||||||
|
#
|
||||||
|
#The above copyright notice and this permission notice shall be included
|
||||||
|
#in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
#OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
#MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
#IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
#OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
#ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
#OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#
|
||||||
|
#Except as contained in this notice, the name of The Open Group shall
|
||||||
|
#not be used in advertising or otherwise to promote the sale, use or
|
||||||
|
#other dealings in this Software without prior written authorization
|
||||||
|
#from The Open Group.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
const
|
||||||
|
XC_num_glyphs* = 154
|
||||||
|
XC_X_cursor* = 0
|
||||||
|
XC_arrow* = 2
|
||||||
|
XC_based_arrow_down* = 4
|
||||||
|
XC_based_arrow_up* = 6
|
||||||
|
XC_boat* = 8
|
||||||
|
XC_bogosity* = 10
|
||||||
|
XC_bottom_left_corner* = 12
|
||||||
|
XC_bottom_right_corner* = 14
|
||||||
|
XC_bottom_side* = 16
|
||||||
|
XC_bottom_tee* = 18
|
||||||
|
XC_box_spiral* = 20
|
||||||
|
XC_center_ptr* = 22
|
||||||
|
XC_circle* = 24
|
||||||
|
XC_clock* = 26
|
||||||
|
XC_coffee_mug* = 28
|
||||||
|
XC_cross* = 30
|
||||||
|
XC_cross_reverse* = 32
|
||||||
|
XC_crosshair* = 34
|
||||||
|
XC_diamond_cross* = 36
|
||||||
|
XC_dot* = 38
|
||||||
|
XC_dotbox* = 40
|
||||||
|
XC_double_arrow* = 42
|
||||||
|
XC_draft_large* = 44
|
||||||
|
XC_draft_small* = 46
|
||||||
|
XC_draped_box* = 48
|
||||||
|
XC_exchange* = 50
|
||||||
|
XC_fleur* = 52
|
||||||
|
XC_gobbler* = 54
|
||||||
|
XC_gumby* = 56
|
||||||
|
XC_hand1* = 58
|
||||||
|
XC_hand2* = 60
|
||||||
|
XC_heart* = 62
|
||||||
|
XC_icon* = 64
|
||||||
|
XC_iron_cross* = 66
|
||||||
|
XC_left_ptr* = 68
|
||||||
|
XC_left_side* = 70
|
||||||
|
XC_left_tee* = 72
|
||||||
|
XC_leftbutton* = 74
|
||||||
|
XC_ll_angle* = 76
|
||||||
|
XC_lr_angle* = 78
|
||||||
|
XC_man* = 80
|
||||||
|
XC_middlebutton* = 82
|
||||||
|
XC_mouse* = 84
|
||||||
|
XC_pencil* = 86
|
||||||
|
XC_pirate* = 88
|
||||||
|
XC_plus* = 90
|
||||||
|
XC_question_arrow* = 92
|
||||||
|
XC_right_ptr* = 94
|
||||||
|
XC_right_side* = 96
|
||||||
|
XC_right_tee* = 98
|
||||||
|
XC_rightbutton* = 100
|
||||||
|
XC_rtl_logo* = 102
|
||||||
|
XC_sailboat* = 104
|
||||||
|
XC_sb_down_arrow* = 106
|
||||||
|
XC_sb_h_double_arrow* = 108
|
||||||
|
XC_sb_left_arrow* = 110
|
||||||
|
XC_sb_right_arrow* = 112
|
||||||
|
XC_sb_up_arrow* = 114
|
||||||
|
XC_sb_v_double_arrow* = 116
|
||||||
|
XC_shuttle* = 118
|
||||||
|
XC_sizing* = 120
|
||||||
|
XC_spider* = 122
|
||||||
|
XC_spraycan* = 124
|
||||||
|
XC_star* = 126
|
||||||
|
XC_target* = 128
|
||||||
|
XC_tcross* = 130
|
||||||
|
XC_top_left_arrow* = 132
|
||||||
|
XC_top_left_corner* = 134
|
||||||
|
XC_top_right_corner* = 136
|
||||||
|
XC_top_side* = 138
|
||||||
|
XC_top_tee* = 140
|
||||||
|
XC_trek* = 142
|
||||||
|
XC_ul_angle* = 144
|
||||||
|
XC_umbrella* = 146
|
||||||
|
XC_ur_angle* = 148
|
||||||
|
XC_watch* = 150
|
||||||
|
XC_xterm* = 152
|
||||||
|
|
||||||
|
# implementation
|
||||||
1926
tests/deps/x11-1.0/keysym.nim
Normal file
1926
tests/deps/x11-1.0/keysym.nim
Normal file
File diff suppressed because it is too large
Load diff
400
tests/deps/x11-1.0/x.nim
Normal file
400
tests/deps/x11-1.0/x.nim
Normal file
|
|
@ -0,0 +1,400 @@
|
||||||
|
|
||||||
|
#
|
||||||
|
# Automatically converted by H2Pas 0.99.15 from x.h
|
||||||
|
# The following command line parameters were used:
|
||||||
|
# -p
|
||||||
|
# -T
|
||||||
|
# -S
|
||||||
|
# -d
|
||||||
|
# -c
|
||||||
|
# x.h
|
||||||
|
#
|
||||||
|
# Pointers to basic pascal types, inserted by h2pas conversion program.
|
||||||
|
|
||||||
|
const
|
||||||
|
X_PROTOCOL* = 11
|
||||||
|
X_PROTOCOL_REVISION* = 0
|
||||||
|
|
||||||
|
type
|
||||||
|
PXID* = ptr TXID
|
||||||
|
TXID* = culong
|
||||||
|
PMask* = ptr TMask
|
||||||
|
TMask* = culong
|
||||||
|
PPAtom* = ptr PAtom
|
||||||
|
PAtom* = ptr TAtom
|
||||||
|
TAtom* = culong
|
||||||
|
PVisualID* = ptr TVisualID
|
||||||
|
TVisualID* = culong
|
||||||
|
PTime* = ptr TTime
|
||||||
|
TTime* = culong
|
||||||
|
PPWindow* = ptr PWindow
|
||||||
|
PWindow* = ptr TWindow
|
||||||
|
TWindow* = TXID
|
||||||
|
PDrawable* = ptr TDrawable
|
||||||
|
TDrawable* = TXID
|
||||||
|
PFont* = ptr TFont
|
||||||
|
TFont* = TXID
|
||||||
|
PPixmap* = ptr TPixmap
|
||||||
|
TPixmap* = TXID
|
||||||
|
PCursor* = ptr TCursor
|
||||||
|
TCursor* = TXID
|
||||||
|
PColormap* = ptr TColormap
|
||||||
|
TColormap* = TXID
|
||||||
|
PGContext* = ptr TGContext
|
||||||
|
TGContext* = TXID
|
||||||
|
PKeySym* = ptr TKeySym
|
||||||
|
TKeySym* = TXID
|
||||||
|
PKeyCode* = ptr TKeyCode
|
||||||
|
TKeyCode* = cuchar
|
||||||
|
|
||||||
|
proc `==`*(a, b: TAtom): bool =
|
||||||
|
return system.`==`(a,b)
|
||||||
|
|
||||||
|
const
|
||||||
|
None* = 0
|
||||||
|
ParentRelative* = 1
|
||||||
|
CopyFromParent* = 0
|
||||||
|
PointerWindow* = 0
|
||||||
|
InputFocus* = 1
|
||||||
|
PointerRoot* = 1
|
||||||
|
AnyPropertyType* = 0
|
||||||
|
AnyKey* = 0
|
||||||
|
AnyButton* = 0
|
||||||
|
AllTemporary* = 0
|
||||||
|
CurrentTime* = 0
|
||||||
|
NoSymbol* = 0
|
||||||
|
NoEventMask* = 0
|
||||||
|
KeyPressMask* = 1 shl 0
|
||||||
|
KeyReleaseMask* = 1 shl 1
|
||||||
|
ButtonPressMask* = 1 shl 2
|
||||||
|
ButtonReleaseMask* = 1 shl 3
|
||||||
|
EnterWindowMask* = 1 shl 4
|
||||||
|
LeaveWindowMask* = 1 shl 5
|
||||||
|
PointerMotionMask* = 1 shl 6
|
||||||
|
PointerMotionHintMask* = 1 shl 7
|
||||||
|
Button1MotionMask* = 1 shl 8
|
||||||
|
Button2MotionMask* = 1 shl 9
|
||||||
|
Button3MotionMask* = 1 shl 10
|
||||||
|
Button4MotionMask* = 1 shl 11
|
||||||
|
Button5MotionMask* = 1 shl 12
|
||||||
|
ButtonMotionMask* = 1 shl 13
|
||||||
|
KeymapStateMask* = 1 shl 14
|
||||||
|
ExposureMask* = 1 shl 15
|
||||||
|
VisibilityChangeMask* = 1 shl 16
|
||||||
|
StructureNotifyMask* = 1 shl 17
|
||||||
|
ResizeRedirectMask* = 1 shl 18
|
||||||
|
SubstructureNotifyMask* = 1 shl 19
|
||||||
|
SubstructureRedirectMask* = 1 shl 20
|
||||||
|
FocusChangeMask* = 1 shl 21
|
||||||
|
PropertyChangeMask* = 1 shl 22
|
||||||
|
ColormapChangeMask* = 1 shl 23
|
||||||
|
OwnerGrabButtonMask* = 1 shl 24
|
||||||
|
KeyPress* = 2
|
||||||
|
KeyRelease* = 3
|
||||||
|
ButtonPress* = 4
|
||||||
|
ButtonRelease* = 5
|
||||||
|
MotionNotify* = 6
|
||||||
|
EnterNotify* = 7
|
||||||
|
LeaveNotify* = 8
|
||||||
|
FocusIn* = 9
|
||||||
|
FocusOut* = 10
|
||||||
|
KeymapNotify* = 11
|
||||||
|
Expose* = 12
|
||||||
|
GraphicsExpose* = 13
|
||||||
|
NoExpose* = 14
|
||||||
|
VisibilityNotify* = 15
|
||||||
|
CreateNotify* = 16
|
||||||
|
DestroyNotify* = 17
|
||||||
|
UnmapNotify* = 18
|
||||||
|
MapNotify* = 19
|
||||||
|
MapRequest* = 20
|
||||||
|
ReparentNotify* = 21
|
||||||
|
ConfigureNotify* = 22
|
||||||
|
ConfigureRequest* = 23
|
||||||
|
GravityNotify* = 24
|
||||||
|
ResizeRequest* = 25
|
||||||
|
CirculateNotify* = 26
|
||||||
|
CirculateRequest* = 27
|
||||||
|
PropertyNotify* = 28
|
||||||
|
SelectionClear* = 29
|
||||||
|
SelectionRequest* = 30
|
||||||
|
SelectionNotify* = 31
|
||||||
|
ColormapNotify* = 32
|
||||||
|
ClientMessage* = 33
|
||||||
|
MappingNotify* = 34
|
||||||
|
LASTEvent* = 35
|
||||||
|
ShiftMask* = 1 shl 0
|
||||||
|
LockMask* = 1 shl 1
|
||||||
|
ControlMask* = 1 shl 2
|
||||||
|
Mod1Mask* = 1 shl 3
|
||||||
|
Mod2Mask* = 1 shl 4
|
||||||
|
Mod3Mask* = 1 shl 5
|
||||||
|
Mod4Mask* = 1 shl 6
|
||||||
|
Mod5Mask* = 1 shl 7
|
||||||
|
ShiftMapIndex* = 0
|
||||||
|
LockMapIndex* = 1
|
||||||
|
ControlMapIndex* = 2
|
||||||
|
Mod1MapIndex* = 3
|
||||||
|
Mod2MapIndex* = 4
|
||||||
|
Mod3MapIndex* = 5
|
||||||
|
Mod4MapIndex* = 6
|
||||||
|
Mod5MapIndex* = 7
|
||||||
|
Button1Mask* = 1 shl 8
|
||||||
|
Button2Mask* = 1 shl 9
|
||||||
|
Button3Mask* = 1 shl 10
|
||||||
|
Button4Mask* = 1 shl 11
|
||||||
|
Button5Mask* = 1 shl 12
|
||||||
|
AnyModifier* = 1 shl 15
|
||||||
|
Button1* = 1
|
||||||
|
Button2* = 2
|
||||||
|
Button3* = 3
|
||||||
|
Button4* = 4
|
||||||
|
Button5* = 5
|
||||||
|
NotifyNormal* = 0
|
||||||
|
NotifyGrab* = 1
|
||||||
|
NotifyUngrab* = 2
|
||||||
|
NotifyWhileGrabbed* = 3
|
||||||
|
NotifyHint* = 1
|
||||||
|
NotifyAncestor* = 0
|
||||||
|
NotifyVirtual* = 1
|
||||||
|
NotifyInferior* = 2
|
||||||
|
NotifyNonlinear* = 3
|
||||||
|
NotifyNonlinearVirtual* = 4
|
||||||
|
NotifyPointer* = 5
|
||||||
|
NotifyPointerRoot* = 6
|
||||||
|
NotifyDetailNone* = 7
|
||||||
|
VisibilityUnobscured* = 0
|
||||||
|
VisibilityPartiallyObscured* = 1
|
||||||
|
VisibilityFullyObscured* = 2
|
||||||
|
PlaceOnTop* = 0
|
||||||
|
PlaceOnBottom* = 1
|
||||||
|
FamilyInternet* = 0
|
||||||
|
FamilyDECnet* = 1
|
||||||
|
FamilyChaos* = 2
|
||||||
|
FamilyInternet6* = 6
|
||||||
|
FamilyServerInterpreted* = 5
|
||||||
|
PropertyNewValue* = 0
|
||||||
|
PropertyDelete* = 1
|
||||||
|
ColormapUninstalled* = 0
|
||||||
|
ColormapInstalled* = 1
|
||||||
|
GrabModeSync* = 0
|
||||||
|
GrabModeAsync* = 1
|
||||||
|
GrabSuccess* = 0
|
||||||
|
AlreadyGrabbed* = 1
|
||||||
|
GrabInvalidTime* = 2
|
||||||
|
GrabNotViewable* = 3
|
||||||
|
GrabFrozen* = 4
|
||||||
|
AsyncPointer* = 0
|
||||||
|
SyncPointer* = 1
|
||||||
|
ReplayPointer* = 2
|
||||||
|
AsyncKeyboard* = 3
|
||||||
|
SyncKeyboard* = 4
|
||||||
|
ReplayKeyboard* = 5
|
||||||
|
AsyncBoth* = 6
|
||||||
|
SyncBoth* = 7
|
||||||
|
RevertToNone* = None
|
||||||
|
RevertToPointerRoot* = PointerRoot
|
||||||
|
RevertToParent* = 2
|
||||||
|
Success* = 0
|
||||||
|
BadRequest* = 1
|
||||||
|
BadValue* = 2
|
||||||
|
BadWindow* = 3
|
||||||
|
BadPixmap* = 4
|
||||||
|
BadAtom* = 5
|
||||||
|
BadCursor* = 6
|
||||||
|
BadFont* = 7
|
||||||
|
BadMatch* = 8
|
||||||
|
BadDrawable* = 9
|
||||||
|
BadAccess* = 10
|
||||||
|
BadAlloc* = 11
|
||||||
|
BadColor* = 12
|
||||||
|
BadGC* = 13
|
||||||
|
BadIDChoice* = 14
|
||||||
|
BadName* = 15
|
||||||
|
BadLength* = 16
|
||||||
|
BadImplementation* = 17
|
||||||
|
FirstExtensionError* = 128
|
||||||
|
LastExtensionError* = 255
|
||||||
|
InputOutput* = 1
|
||||||
|
InputOnly* = 2
|
||||||
|
CWBackPixmap* = 1 shl 0
|
||||||
|
CWBackPixel* = 1 shl 1
|
||||||
|
CWBorderPixmap* = 1 shl 2
|
||||||
|
CWBorderPixel* = 1 shl 3
|
||||||
|
CWBitGravity* = 1 shl 4
|
||||||
|
CWWinGravity* = 1 shl 5
|
||||||
|
CWBackingStore* = 1 shl 6
|
||||||
|
CWBackingPlanes* = 1 shl 7
|
||||||
|
CWBackingPixel* = 1 shl 8
|
||||||
|
CWOverrideRedirect* = 1 shl 9
|
||||||
|
CWSaveUnder* = 1 shl 10
|
||||||
|
CWEventMask* = 1 shl 11
|
||||||
|
CWDontPropagate* = 1 shl 12
|
||||||
|
CWColormap* = 1 shl 13
|
||||||
|
CWCursor* = 1 shl 14
|
||||||
|
CWX* = 1 shl 0
|
||||||
|
CWY* = 1 shl 1
|
||||||
|
CWWidth* = 1 shl 2
|
||||||
|
CWHeight* = 1 shl 3
|
||||||
|
CWBorderWidth* = 1 shl 4
|
||||||
|
CWSibling* = 1 shl 5
|
||||||
|
CWStackMode* = 1 shl 6
|
||||||
|
ForgetGravity* = 0
|
||||||
|
NorthWestGravity* = 1
|
||||||
|
NorthGravity* = 2
|
||||||
|
NorthEastGravity* = 3
|
||||||
|
WestGravity* = 4
|
||||||
|
CenterGravity* = 5
|
||||||
|
EastGravity* = 6
|
||||||
|
SouthWestGravity* = 7
|
||||||
|
SouthGravity* = 8
|
||||||
|
SouthEastGravity* = 9
|
||||||
|
StaticGravity* = 10
|
||||||
|
UnmapGravity* = 0
|
||||||
|
NotUseful* = 0
|
||||||
|
WhenMapped* = 1
|
||||||
|
Always* = 2
|
||||||
|
IsUnmapped* = 0
|
||||||
|
IsUnviewable* = 1
|
||||||
|
IsViewable* = 2
|
||||||
|
SetModeInsert* = 0
|
||||||
|
SetModeDelete* = 1
|
||||||
|
DestroyAll* = 0
|
||||||
|
RetainPermanent* = 1
|
||||||
|
RetainTemporary* = 2
|
||||||
|
Above* = 0
|
||||||
|
Below* = 1
|
||||||
|
TopIf* = 2
|
||||||
|
BottomIf* = 3
|
||||||
|
Opposite* = 4
|
||||||
|
RaiseLowest* = 0
|
||||||
|
LowerHighest* = 1
|
||||||
|
PropModeReplace* = 0
|
||||||
|
PropModePrepend* = 1
|
||||||
|
PropModeAppend* = 2
|
||||||
|
GXclear* = 0x00000000
|
||||||
|
GXand* = 0x00000001
|
||||||
|
GXandReverse* = 0x00000002
|
||||||
|
GXcopy* = 0x00000003
|
||||||
|
GXandInverted* = 0x00000004
|
||||||
|
GXnoop* = 0x00000005
|
||||||
|
GXxor* = 0x00000006
|
||||||
|
GXor* = 0x00000007
|
||||||
|
GXnor* = 0x00000008
|
||||||
|
GXequiv* = 0x00000009
|
||||||
|
GXinvert* = 0x0000000A
|
||||||
|
GXorReverse* = 0x0000000B
|
||||||
|
GXcopyInverted* = 0x0000000C
|
||||||
|
GXorInverted* = 0x0000000D
|
||||||
|
GXnand* = 0x0000000E
|
||||||
|
GXset* = 0x0000000F
|
||||||
|
LineSolid* = 0
|
||||||
|
LineOnOffDash* = 1
|
||||||
|
LineDoubleDash* = 2
|
||||||
|
CapNotLast* = 0
|
||||||
|
CapButt* = 1
|
||||||
|
CapRound* = 2
|
||||||
|
CapProjecting* = 3
|
||||||
|
JoinMiter* = 0
|
||||||
|
JoinRound* = 1
|
||||||
|
JoinBevel* = 2
|
||||||
|
FillSolid* = 0
|
||||||
|
FillTiled* = 1
|
||||||
|
FillStippled* = 2
|
||||||
|
FillOpaqueStippled* = 3
|
||||||
|
EvenOddRule* = 0
|
||||||
|
WindingRule* = 1
|
||||||
|
ClipByChildren* = 0
|
||||||
|
IncludeInferiors* = 1
|
||||||
|
Unsorted* = 0
|
||||||
|
YSorted* = 1
|
||||||
|
YXSorted* = 2
|
||||||
|
YXBanded* = 3
|
||||||
|
CoordModeOrigin* = 0
|
||||||
|
CoordModePrevious* = 1
|
||||||
|
Complex* = 0
|
||||||
|
Nonconvex* = 1
|
||||||
|
Convex* = 2
|
||||||
|
ArcChord* = 0
|
||||||
|
ArcPieSlice* = 1
|
||||||
|
GCFunction* = 1 shl 0
|
||||||
|
GCPlaneMask* = 1 shl 1
|
||||||
|
GCForeground* = 1 shl 2
|
||||||
|
GCBackground* = 1 shl 3
|
||||||
|
GCLineWidth* = 1 shl 4
|
||||||
|
GCLineStyle* = 1 shl 5
|
||||||
|
GCCapStyle* = 1 shl 6
|
||||||
|
GCJoinStyle* = 1 shl 7
|
||||||
|
GCFillStyle* = 1 shl 8
|
||||||
|
GCFillRule* = 1 shl 9
|
||||||
|
GCTile* = 1 shl 10
|
||||||
|
GCStipple* = 1 shl 11
|
||||||
|
GCTileStipXOrigin* = 1 shl 12
|
||||||
|
GCTileStipYOrigin* = 1 shl 13
|
||||||
|
GCFont* = 1 shl 14
|
||||||
|
GCSubwindowMode* = 1 shl 15
|
||||||
|
GCGraphicsExposures* = 1 shl 16
|
||||||
|
GCClipXOrigin* = 1 shl 17
|
||||||
|
GCClipYOrigin* = 1 shl 18
|
||||||
|
GCClipMask* = 1 shl 19
|
||||||
|
GCDashOffset* = 1 shl 20
|
||||||
|
GCDashList* = 1 shl 21
|
||||||
|
GCArcMode* = 1 shl 22
|
||||||
|
GCLastBit* = 22
|
||||||
|
FontLeftToRight* = 0
|
||||||
|
FontRightToLeft* = 1
|
||||||
|
FontChange* = 255
|
||||||
|
XYBitmap* = 0
|
||||||
|
XYPixmap* = 1
|
||||||
|
ZPixmap* = 2
|
||||||
|
AllocNone* = 0
|
||||||
|
AllocAll* = 1
|
||||||
|
DoRed* = 1 shl 0
|
||||||
|
DoGreen* = 1 shl 1
|
||||||
|
DoBlue* = 1 shl 2
|
||||||
|
CursorShape* = 0
|
||||||
|
TileShape* = 1
|
||||||
|
StippleShape* = 2
|
||||||
|
AutoRepeatModeOff* = 0
|
||||||
|
AutoRepeatModeOn* = 1
|
||||||
|
AutoRepeatModeDefault* = 2
|
||||||
|
LedModeOff* = 0
|
||||||
|
LedModeOn* = 1
|
||||||
|
KBKeyClickPercent* = 1 shl 0
|
||||||
|
KBBellPercent* = 1 shl 1
|
||||||
|
KBBellPitch* = 1 shl 2
|
||||||
|
KBBellDuration* = 1 shl 3
|
||||||
|
KBLed* = 1 shl 4
|
||||||
|
KBLedMode* = 1 shl 5
|
||||||
|
KBKey* = 1 shl 6
|
||||||
|
KBAutoRepeatMode* = 1 shl 7
|
||||||
|
MappingSuccess* = 0
|
||||||
|
MappingBusy* = 1
|
||||||
|
MappingFailed* = 2
|
||||||
|
MappingModifier* = 0
|
||||||
|
MappingKeyboard* = 1
|
||||||
|
MappingPointer* = 2
|
||||||
|
DontPreferBlanking* = 0
|
||||||
|
PreferBlanking* = 1
|
||||||
|
DefaultBlanking* = 2
|
||||||
|
DisableScreenSaver* = 0
|
||||||
|
DisableScreenInterval* = 0
|
||||||
|
DontAllowExposures* = 0
|
||||||
|
AllowExposures* = 1
|
||||||
|
DefaultExposures* = 2
|
||||||
|
ScreenSaverReset* = 0
|
||||||
|
ScreenSaverActive* = 1
|
||||||
|
HostInsert* = 0
|
||||||
|
HostDelete* = 1
|
||||||
|
EnableAccess* = 1
|
||||||
|
DisableAccess* = 0
|
||||||
|
StaticGray* = 0
|
||||||
|
GrayScale* = 1
|
||||||
|
StaticColor* = 2
|
||||||
|
PseudoColor* = 3
|
||||||
|
TrueColor* = 4
|
||||||
|
DirectColor* = 5
|
||||||
|
LSBFirst* = 0
|
||||||
|
MSBFirst* = 1
|
||||||
|
|
||||||
|
# implementation
|
||||||
11
tests/deps/x11-1.0/x11.nimble
Normal file
11
tests/deps/x11-1.0/x11.nimble
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
[Package]
|
||||||
|
name: "x11"
|
||||||
|
version: "1.0"
|
||||||
|
author: "Andreas Rumpf"
|
||||||
|
description: "Wrapper for X11"
|
||||||
|
license: "MIT"
|
||||||
|
|
||||||
|
srcDir: "src"
|
||||||
|
|
||||||
|
[Deps]
|
||||||
|
requires: "nimrod > 0.9.2"
|
||||||
20
tests/deps/x11-1.0/x11pragma.nim
Normal file
20
tests/deps/x11-1.0/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(|.6)"
|
||||||
|
|
||||||
|
{.pragma: libx11, cdecl, dynlib: libX11, importc.}
|
||||||
|
{.pragma: libx11c, cdecl, dynlib: libX11.}
|
||||||
81
tests/deps/x11-1.0/xatom.nim
Normal file
81
tests/deps/x11-1.0/xatom.nim
Normal file
|
|
@ -0,0 +1,81 @@
|
||||||
|
#
|
||||||
|
# THIS IS A GENERATED FILE
|
||||||
|
#
|
||||||
|
# Do not change! Changing this file implies a protocol change!
|
||||||
|
#
|
||||||
|
|
||||||
|
import
|
||||||
|
X
|
||||||
|
|
||||||
|
const
|
||||||
|
XA_PRIMARY* = TAtom(1)
|
||||||
|
XA_SECONDARY* = TAtom(2)
|
||||||
|
XA_ARC* = TAtom(3)
|
||||||
|
XA_ATOM* = TAtom(4)
|
||||||
|
XA_BITMAP* = TAtom(5)
|
||||||
|
XA_CARDINAL* = TAtom(6)
|
||||||
|
XA_COLORMAP* = TAtom(7)
|
||||||
|
XA_CURSOR* = TAtom(8)
|
||||||
|
XA_CUT_BUFFER0* = TAtom(9)
|
||||||
|
XA_CUT_BUFFER1* = TAtom(10)
|
||||||
|
XA_CUT_BUFFER2* = TAtom(11)
|
||||||
|
XA_CUT_BUFFER3* = TAtom(12)
|
||||||
|
XA_CUT_BUFFER4* = TAtom(13)
|
||||||
|
XA_CUT_BUFFER5* = TAtom(14)
|
||||||
|
XA_CUT_BUFFER6* = TAtom(15)
|
||||||
|
XA_CUT_BUFFER7* = TAtom(16)
|
||||||
|
XA_DRAWABLE* = TAtom(17)
|
||||||
|
XA_FONT* = TAtom(18)
|
||||||
|
XA_INTEGER* = TAtom(19)
|
||||||
|
XA_PIXMAP* = TAtom(20)
|
||||||
|
XA_POINT* = TAtom(21)
|
||||||
|
XA_RECTANGLE* = TAtom(22)
|
||||||
|
XA_RESOURCE_MANAGER* = TAtom(23)
|
||||||
|
XA_RGB_COLOR_MAP* = TAtom(24)
|
||||||
|
XA_RGB_BEST_MAP* = TAtom(25)
|
||||||
|
XA_RGB_BLUE_MAP* = TAtom(26)
|
||||||
|
XA_RGB_DEFAULT_MAP* = TAtom(27)
|
||||||
|
XA_RGB_GRAY_MAP* = TAtom(28)
|
||||||
|
XA_RGB_GREEN_MAP* = TAtom(29)
|
||||||
|
XA_RGB_RED_MAP* = TAtom(30)
|
||||||
|
XA_STRING* = TAtom(31)
|
||||||
|
XA_VISUALID* = TAtom(32)
|
||||||
|
XA_WINDOW* = TAtom(33)
|
||||||
|
XA_WM_COMMAND* = TAtom(34)
|
||||||
|
XA_WM_HINTS* = TAtom(35)
|
||||||
|
XA_WM_CLIENT_MACHINE* = TAtom(36)
|
||||||
|
XA_WM_ICON_NAME* = TAtom(37)
|
||||||
|
XA_WM_ICON_SIZE* = TAtom(38)
|
||||||
|
XA_WM_NAME* = TAtom(39)
|
||||||
|
XA_WM_NORMAL_HINTS* = TAtom(40)
|
||||||
|
XA_WM_SIZE_HINTS* = TAtom(41)
|
||||||
|
XA_WM_ZOOM_HINTS* = TAtom(42)
|
||||||
|
XA_MIN_SPACE* = TAtom(43)
|
||||||
|
XA_NORM_SPACE* = TAtom(44)
|
||||||
|
XA_MAX_SPACE* = TAtom(45)
|
||||||
|
XA_END_SPACE* = TAtom(46)
|
||||||
|
XA_SUPERSCRIPT_X* = TAtom(47)
|
||||||
|
XA_SUPERSCRIPT_Y* = TAtom(48)
|
||||||
|
XA_SUBSCRIPT_X* = TAtom(49)
|
||||||
|
XA_SUBSCRIPT_Y* = TAtom(50)
|
||||||
|
XA_UNDERLINE_POSITION* = TAtom(51)
|
||||||
|
XA_UNDERLINE_THICKNESS* = TAtom(52)
|
||||||
|
XA_STRIKEOUT_ASCENT* = TAtom(53)
|
||||||
|
XA_STRIKEOUT_DESCENT* = TAtom(54)
|
||||||
|
XA_ITALIC_ANGLE* = TAtom(55)
|
||||||
|
XA_X_HEIGHT* = TAtom(56)
|
||||||
|
XA_QUAD_WIDTH* = TAtom(57)
|
||||||
|
XA_WEIGHT* = TAtom(58)
|
||||||
|
XA_POINT_SIZE* = TAtom(59)
|
||||||
|
XA_RESOLUTION* = TAtom(60)
|
||||||
|
XA_COPYRIGHT* = TAtom(61)
|
||||||
|
XA_NOTICE* = TAtom(62)
|
||||||
|
XA_FONT_NAME* = TAtom(63)
|
||||||
|
XA_FAMILY_NAME* = TAtom(64)
|
||||||
|
XA_FULL_NAME* = TAtom(65)
|
||||||
|
XA_CAP_HEIGHT* = TAtom(66)
|
||||||
|
XA_WM_CLASS* = TAtom(67)
|
||||||
|
XA_WM_TRANSIENT_FOR* = TAtom(68)
|
||||||
|
XA_LAST_PREDEFINED* = TAtom(68)
|
||||||
|
|
||||||
|
# implementation
|
||||||
389
tests/deps/x11-1.0/xcms.nim
Normal file
389
tests/deps/x11-1.0/xcms.nim
Normal file
|
|
@ -0,0 +1,389 @@
|
||||||
|
|
||||||
|
import
|
||||||
|
x, xlib
|
||||||
|
|
||||||
|
#const
|
||||||
|
# libX11* = "X11"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Automatically converted by H2Pas 0.99.15 from xcms.h
|
||||||
|
# The following command line parameters were used:
|
||||||
|
# -p
|
||||||
|
# -T
|
||||||
|
# -S
|
||||||
|
# -d
|
||||||
|
# -c
|
||||||
|
# xcms.h
|
||||||
|
#
|
||||||
|
|
||||||
|
const
|
||||||
|
XcmsFailure* = 0
|
||||||
|
XcmsSuccess* = 1
|
||||||
|
XcmsSuccessWithCompression* = 2
|
||||||
|
|
||||||
|
type
|
||||||
|
PXcmsColorFormat* = ptr TXcmsColorFormat
|
||||||
|
TXcmsColorFormat* = int32
|
||||||
|
|
||||||
|
proc XcmsUndefinedFormat*(): TXcmsColorFormat
|
||||||
|
proc XcmsCIEXYZFormat*(): TXcmsColorFormat
|
||||||
|
proc XcmsCIEuvYFormat*(): TXcmsColorFormat
|
||||||
|
proc XcmsCIExyYFormat*(): TXcmsColorFormat
|
||||||
|
proc XcmsCIELabFormat*(): TXcmsColorFormat
|
||||||
|
proc XcmsCIELuvFormat*(): TXcmsColorFormat
|
||||||
|
proc XcmsTekHVCFormat*(): TXcmsColorFormat
|
||||||
|
proc XcmsRGBFormat*(): TXcmsColorFormat
|
||||||
|
proc XcmsRGBiFormat*(): TXcmsColorFormat
|
||||||
|
const
|
||||||
|
XcmsInitNone* = 0x00000000
|
||||||
|
XcmsInitSuccess* = 0x00000001
|
||||||
|
XcmsInitFailure* = 0x000000FF
|
||||||
|
|
||||||
|
type
|
||||||
|
PXcmsFloat* = ptr TXcmsFloat
|
||||||
|
TXcmsFloat* = float64
|
||||||
|
PXcmsRGB* = ptr TXcmsRGB
|
||||||
|
TXcmsRGB*{.final.} = object
|
||||||
|
red*: int16
|
||||||
|
green*: int16
|
||||||
|
blue*: int16
|
||||||
|
|
||||||
|
PXcmsRGBi* = ptr TXcmsRGBi
|
||||||
|
TXcmsRGBi*{.final.} = object
|
||||||
|
red*: TXcmsFloat
|
||||||
|
green*: TXcmsFloat
|
||||||
|
blue*: TXcmsFloat
|
||||||
|
|
||||||
|
PXcmsCIEXYZ* = ptr TXcmsCIEXYZ
|
||||||
|
TXcmsCIEXYZ*{.final.} = object
|
||||||
|
X*: TXcmsFloat
|
||||||
|
Y*: TXcmsFloat
|
||||||
|
Z*: TXcmsFloat
|
||||||
|
|
||||||
|
PXcmsCIEuvY* = ptr TXcmsCIEuvY
|
||||||
|
TXcmsCIEuvY*{.final.} = object
|
||||||
|
u_prime*: TXcmsFloat
|
||||||
|
v_prime*: TXcmsFloat
|
||||||
|
Y*: TXcmsFloat
|
||||||
|
|
||||||
|
PXcmsCIExyY* = ptr TXcmsCIExyY
|
||||||
|
TXcmsCIExyY*{.final.} = object
|
||||||
|
x*: TXcmsFloat
|
||||||
|
y*: TXcmsFloat
|
||||||
|
theY*: TXcmsFloat
|
||||||
|
|
||||||
|
PXcmsCIELab* = ptr TXcmsCIELab
|
||||||
|
TXcmsCIELab*{.final.} = object
|
||||||
|
L_star*: TXcmsFloat
|
||||||
|
a_star*: TXcmsFloat
|
||||||
|
b_star*: TXcmsFloat
|
||||||
|
|
||||||
|
PXcmsCIELuv* = ptr TXcmsCIELuv
|
||||||
|
TXcmsCIELuv*{.final.} = object
|
||||||
|
L_star*: TXcmsFloat
|
||||||
|
u_star*: TXcmsFloat
|
||||||
|
v_star*: TXcmsFloat
|
||||||
|
|
||||||
|
PXcmsTekHVC* = ptr TXcmsTekHVC
|
||||||
|
TXcmsTekHVC*{.final.} = object
|
||||||
|
H*: TXcmsFloat
|
||||||
|
V*: TXcmsFloat
|
||||||
|
C*: TXcmsFloat
|
||||||
|
|
||||||
|
PXcmsPad* = ptr TXcmsPad
|
||||||
|
TXcmsPad*{.final.} = object
|
||||||
|
pad0*: TXcmsFloat
|
||||||
|
pad1*: TXcmsFloat
|
||||||
|
pad2*: TXcmsFloat
|
||||||
|
pad3*: TXcmsFloat
|
||||||
|
|
||||||
|
PXcmsColor* = ptr TXcmsColor
|
||||||
|
TXcmsColor*{.final.} = object # spec : record
|
||||||
|
# case longint of
|
||||||
|
# 0 : ( RGB : TXcmsRGB );
|
||||||
|
# 1 : ( RGBi : TXcmsRGBi );
|
||||||
|
# 2 : ( CIEXYZ : TXcmsCIEXYZ );
|
||||||
|
# 3 : ( CIEuvY : TXcmsCIEuvY );
|
||||||
|
# 4 : ( CIExyY : TXcmsCIExyY );
|
||||||
|
# 5 : ( CIELab : TXcmsCIELab );
|
||||||
|
# 6 : ( CIELuv : TXcmsCIELuv );
|
||||||
|
# 7 : ( TekHVC : TXcmsTekHVC );
|
||||||
|
# 8 : ( Pad : TXcmsPad );
|
||||||
|
# end;
|
||||||
|
pad*: TXcmsPad
|
||||||
|
pixel*: int32
|
||||||
|
format*: TXcmsColorFormat
|
||||||
|
|
||||||
|
PXcmsPerScrnInfo* = ptr TXcmsPerScrnInfo
|
||||||
|
TXcmsPerScrnInfo*{.final.} = object
|
||||||
|
screenWhitePt*: TXcmsColor
|
||||||
|
functionSet*: TXPointer
|
||||||
|
screenData*: TXPointer
|
||||||
|
state*: int8
|
||||||
|
pad*: array[0..2, char]
|
||||||
|
|
||||||
|
PXcmsCCC* = ptr TXcmsCCC
|
||||||
|
TXcmsCompressionProc* = proc (para1: PXcmsCCC, para2: PXcmsColor,
|
||||||
|
para3: int32, para4: int32, para5: PBool): TStatus{.
|
||||||
|
cdecl.}
|
||||||
|
TXcmsWhiteAdjustProc* = proc (para1: PXcmsCCC, para2: PXcmsColor,
|
||||||
|
para3: PXcmsColor, para4: TXcmsColorFormat,
|
||||||
|
para5: PXcmsColor, para6: int32, para7: PBool): TStatus{.
|
||||||
|
cdecl.}
|
||||||
|
TXcmsCCC*{.final.} = object
|
||||||
|
dpy*: PDisplay
|
||||||
|
screenNumber*: int32
|
||||||
|
visual*: PVisual
|
||||||
|
clientWhitePt*: TXcmsColor
|
||||||
|
gamutCompProc*: TXcmsCompressionProc
|
||||||
|
gamutCompClientData*: TXPointer
|
||||||
|
whitePtAdjProc*: TXcmsWhiteAdjustProc
|
||||||
|
whitePtAdjClientData*: TXPointer
|
||||||
|
pPerScrnInfo*: PXcmsPerScrnInfo
|
||||||
|
|
||||||
|
TXcmsCCCRec* = TXcmsCCC
|
||||||
|
PXcmsCCCRec* = ptr TXcmsCCCRec
|
||||||
|
TXcmsScreenInitProc* = proc (para1: PDisplay, para2: int32,
|
||||||
|
para3: PXcmsPerScrnInfo): TStatus{.cdecl.}
|
||||||
|
TXcmsScreenFreeProc* = proc (para1: TXPointer){.cdecl.}
|
||||||
|
TXcmsConversionProc* = proc (){.cdecl.}
|
||||||
|
PXcmsFuncListPtr* = ptr TXcmsFuncListPtr
|
||||||
|
TXcmsFuncListPtr* = TXcmsConversionProc
|
||||||
|
TXcmsParseStringProc* = proc (para1: cstring, para2: PXcmsColor): int32{.cdecl.}
|
||||||
|
PXcmsColorSpace* = ptr TXcmsColorSpace
|
||||||
|
TXcmsColorSpace*{.final.} = object
|
||||||
|
prefix*: cstring
|
||||||
|
id*: TXcmsColorFormat
|
||||||
|
parseString*: TXcmsParseStringProc
|
||||||
|
to_CIEXYZ*: TXcmsFuncListPtr
|
||||||
|
from_CIEXYZ*: TXcmsFuncListPtr
|
||||||
|
inverse_flag*: int32
|
||||||
|
|
||||||
|
PXcmsFunctionSet* = ptr TXcmsFunctionSet
|
||||||
|
TXcmsFunctionSet*{.final.} = object # error
|
||||||
|
#extern Status XcmsAddColorSpace (
|
||||||
|
#in declaration at line 323
|
||||||
|
DDColorSpaces*: ptr PXcmsColorSpace
|
||||||
|
screenInitProc*: TXcmsScreenInitProc
|
||||||
|
screenFreeProc*: TXcmsScreenFreeProc
|
||||||
|
|
||||||
|
|
||||||
|
proc XcmsAddFunctionSet*(para1: PXcmsFunctionSet): TStatus{.cdecl,
|
||||||
|
dynlib: libX11, importc.}
|
||||||
|
proc XcmsAllocColor*(para1: PDisplay, para2: TColormap, para3: PXcmsColor,
|
||||||
|
para4: TXcmsColorFormat): TStatus{.cdecl, dynlib: libX11,
|
||||||
|
importc.}
|
||||||
|
proc XcmsAllocNamedColor*(para1: PDisplay, para2: TColormap, para3: cstring,
|
||||||
|
para4: PXcmsColor, para5: PXcmsColor,
|
||||||
|
para6: TXcmsColorFormat): TStatus{.cdecl,
|
||||||
|
dynlib: libX11, importc.}
|
||||||
|
proc XcmsCCCOfColormap*(para1: PDisplay, para2: TColormap): TXcmsCCC{.cdecl,
|
||||||
|
dynlib: libX11, importc.}
|
||||||
|
proc XcmsCIELabClipab*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||||
|
para4: int32, para5: PBool): TStatus{.cdecl,
|
||||||
|
dynlib: libX11, importc.}
|
||||||
|
proc XcmsCIELabClipL*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||||
|
para4: int32, para5: PBool): TStatus{.cdecl,
|
||||||
|
dynlib: libX11, importc.}
|
||||||
|
proc XcmsCIELabClipLab*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||||
|
para4: int32, para5: PBool): TStatus{.cdecl,
|
||||||
|
dynlib: libX11, importc.}
|
||||||
|
proc XcmsCIELabQueryMaxC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat,
|
||||||
|
para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11,
|
||||||
|
importc.}
|
||||||
|
proc XcmsCIELabQueryMaxL*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat,
|
||||||
|
para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11,
|
||||||
|
importc.}
|
||||||
|
proc XcmsCIELabQueryMaxLC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: PXcmsColor): TStatus{.
|
||||||
|
cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsCIELabQueryMinL*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat,
|
||||||
|
para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11,
|
||||||
|
importc.}
|
||||||
|
proc XcmsCIELabToCIEXYZ*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor,
|
||||||
|
para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsCIELabWhiteShiftColors*(para1: TXcmsCCC, para2: PXcmsColor,
|
||||||
|
para3: PXcmsColor, para4: TXcmsColorFormat,
|
||||||
|
para5: PXcmsColor, para6: int32, para7: PBool): TStatus{.
|
||||||
|
cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsCIELuvClipL*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||||
|
para4: int32, para5: PBool): TStatus{.cdecl,
|
||||||
|
dynlib: libX11, importc.}
|
||||||
|
proc XcmsCIELuvClipLuv*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||||
|
para4: int32, para5: PBool): TStatus{.cdecl,
|
||||||
|
dynlib: libX11, importc.}
|
||||||
|
proc XcmsCIELuvClipuv*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||||
|
para4: int32, para5: PBool): TStatus{.cdecl,
|
||||||
|
dynlib: libX11, importc.}
|
||||||
|
proc XcmsCIELuvQueryMaxC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat,
|
||||||
|
para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11,
|
||||||
|
importc.}
|
||||||
|
proc XcmsCIELuvQueryMaxL*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat,
|
||||||
|
para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11,
|
||||||
|
importc.}
|
||||||
|
proc XcmsCIELuvQueryMaxLC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: PXcmsColor): TStatus{.
|
||||||
|
cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsCIELuvQueryMinL*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat,
|
||||||
|
para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11,
|
||||||
|
importc.}
|
||||||
|
proc XcmsCIELuvToCIEuvY*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor,
|
||||||
|
para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsCIELuvWhiteShiftColors*(para1: TXcmsCCC, para2: PXcmsColor,
|
||||||
|
para3: PXcmsColor, para4: TXcmsColorFormat,
|
||||||
|
para5: PXcmsColor, para6: int32, para7: PBool): TStatus{.
|
||||||
|
cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsCIEXYZToCIELab*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor,
|
||||||
|
para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsCIEXYZToCIEuvY*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor,
|
||||||
|
para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsCIEXYZToCIExyY*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor,
|
||||||
|
para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsCIEXYZToRGBi*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||||
|
para4: PBool): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsCIEuvYToCIELuv*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor,
|
||||||
|
para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsCIEuvYToCIEXYZ*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor,
|
||||||
|
para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsCIEuvYToTekHVC*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor,
|
||||||
|
para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsCIExyYToCIEXYZ*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor,
|
||||||
|
para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsClientWhitePointOfCCC*(para1: TXcmsCCC): PXcmsColor{.cdecl,
|
||||||
|
dynlib: libX11, importc.}
|
||||||
|
proc XcmsConvertColors*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||||
|
para4: TXcmsColorFormat, para5: PBool): TStatus{.cdecl,
|
||||||
|
dynlib: libX11, importc.}
|
||||||
|
proc XcmsCreateCCC*(para1: PDisplay, para2: int32, para3: PVisual,
|
||||||
|
para4: PXcmsColor, para5: TXcmsCompressionProc,
|
||||||
|
para6: TXPointer, para7: TXcmsWhiteAdjustProc,
|
||||||
|
para8: TXPointer): TXcmsCCC{.cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsDefaultCCC*(para1: PDisplay, para2: int32): TXcmsCCC{.cdecl,
|
||||||
|
dynlib: libX11, importc.}
|
||||||
|
proc XcmsDisplayOfCCC*(para1: TXcmsCCC): PDisplay{.cdecl, dynlib: libX11,
|
||||||
|
importc.}
|
||||||
|
proc XcmsFormatOfPrefix*(para1: cstring): TXcmsColorFormat{.cdecl,
|
||||||
|
dynlib: libX11, importc.}
|
||||||
|
proc XcmsFreeCCC*(para1: TXcmsCCC){.cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsLookupColor*(para1: PDisplay, para2: TColormap, para3: cstring,
|
||||||
|
para4: PXcmsColor, para5: PXcmsColor,
|
||||||
|
para6: TXcmsColorFormat): TStatus{.cdecl, dynlib: libX11,
|
||||||
|
importc.}
|
||||||
|
proc XcmsPrefixOfFormat*(para1: TXcmsColorFormat): cstring{.cdecl,
|
||||||
|
dynlib: libX11, importc.}
|
||||||
|
proc XcmsQueryBlack*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{.
|
||||||
|
cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsQueryBlue*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{.
|
||||||
|
cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsQueryColor*(para1: PDisplay, para2: TColormap, para3: PXcmsColor,
|
||||||
|
para4: TXcmsColorFormat): TStatus{.cdecl, dynlib: libX11,
|
||||||
|
importc.}
|
||||||
|
proc XcmsQueryColors*(para1: PDisplay, para2: TColormap, para3: PXcmsColor,
|
||||||
|
para4: int32, para5: TXcmsColorFormat): TStatus{.cdecl,
|
||||||
|
dynlib: libX11, importc.}
|
||||||
|
proc XcmsQueryGreen*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{.
|
||||||
|
cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsQueryRed*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{.
|
||||||
|
cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsQueryWhite*(para1: TXcmsCCC, para2: TXcmsColorFormat, para3: PXcmsColor): TStatus{.
|
||||||
|
cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsRGBiToCIEXYZ*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||||
|
para4: PBool): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsRGBiToRGB*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||||
|
para4: PBool): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsRGBToRGBi*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||||
|
para4: PBool): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsScreenNumberOfCCC*(para1: TXcmsCCC): int32{.cdecl, dynlib: libX11,
|
||||||
|
importc.}
|
||||||
|
proc XcmsScreenWhitePointOfCCC*(para1: TXcmsCCC): PXcmsColor{.cdecl,
|
||||||
|
dynlib: libX11, importc.}
|
||||||
|
proc XcmsSetCCCOfColormap*(para1: PDisplay, para2: TColormap, para3: TXcmsCCC): TXcmsCCC{.
|
||||||
|
cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsSetCompressionProc*(para1: TXcmsCCC, para2: TXcmsCompressionProc,
|
||||||
|
para3: TXPointer): TXcmsCompressionProc{.cdecl,
|
||||||
|
dynlib: libX11, importc.}
|
||||||
|
proc XcmsSetWhiteAdjustProc*(para1: TXcmsCCC, para2: TXcmsWhiteAdjustProc,
|
||||||
|
para3: TXPointer): TXcmsWhiteAdjustProc{.cdecl,
|
||||||
|
dynlib: libX11, importc.}
|
||||||
|
proc XcmsSetWhitePoint*(para1: TXcmsCCC, para2: PXcmsColor): TStatus{.cdecl,
|
||||||
|
dynlib: libX11, importc.}
|
||||||
|
proc XcmsStoreColor*(para1: PDisplay, para2: TColormap, para3: PXcmsColor): TStatus{.
|
||||||
|
cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsStoreColors*(para1: PDisplay, para2: TColormap, para3: PXcmsColor,
|
||||||
|
para4: int32, para5: PBool): TStatus{.cdecl,
|
||||||
|
dynlib: libX11, importc.}
|
||||||
|
proc XcmsTekHVCClipC*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||||
|
para4: int32, para5: PBool): TStatus{.cdecl,
|
||||||
|
dynlib: libX11, importc.}
|
||||||
|
proc XcmsTekHVCClipV*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||||
|
para4: int32, para5: PBool): TStatus{.cdecl,
|
||||||
|
dynlib: libX11, importc.}
|
||||||
|
proc XcmsTekHVCClipVC*(para1: TXcmsCCC, para2: PXcmsColor, para3: int32,
|
||||||
|
para4: int32, para5: PBool): TStatus{.cdecl,
|
||||||
|
dynlib: libX11, importc.}
|
||||||
|
proc XcmsTekHVCQueryMaxC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat,
|
||||||
|
para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11,
|
||||||
|
importc.}
|
||||||
|
proc XcmsTekHVCQueryMaxV*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat,
|
||||||
|
para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11,
|
||||||
|
importc.}
|
||||||
|
proc XcmsTekHVCQueryMaxVC*(para1: TXcmsCCC, para2: TXcmsFloat, para3: PXcmsColor): TStatus{.
|
||||||
|
cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsTekHVCQueryMaxVSamples*(para1: TXcmsCCC, para2: TXcmsFloat,
|
||||||
|
para3: PXcmsColor, para4: int32): TStatus{.
|
||||||
|
cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsTekHVCQueryMinV*(para1: TXcmsCCC, para2: TXcmsFloat, para3: TXcmsFloat,
|
||||||
|
para4: PXcmsColor): TStatus{.cdecl, dynlib: libX11,
|
||||||
|
importc.}
|
||||||
|
proc XcmsTekHVCToCIEuvY*(para1: TXcmsCCC, para2: PXcmsColor, para3: PXcmsColor,
|
||||||
|
para4: int32): TStatus{.cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsTekHVCWhiteShiftColors*(para1: TXcmsCCC, para2: PXcmsColor,
|
||||||
|
para3: PXcmsColor, para4: TXcmsColorFormat,
|
||||||
|
para5: PXcmsColor, para6: int32, para7: PBool): TStatus{.
|
||||||
|
cdecl, dynlib: libX11, importc.}
|
||||||
|
proc XcmsVisualOfCCC*(para1: TXcmsCCC): PVisual{.cdecl, dynlib: libX11, importc.}
|
||||||
|
# implementation
|
||||||
|
|
||||||
|
proc XcmsUndefinedFormat(): TXcmsColorFormat =
|
||||||
|
result = 0x00000000'i32
|
||||||
|
|
||||||
|
proc XcmsCIEXYZFormat(): TXcmsColorFormat =
|
||||||
|
result = 0x00000001'i32
|
||||||
|
|
||||||
|
proc XcmsCIEuvYFormat(): TXcmsColorFormat =
|
||||||
|
result = 0x00000002'i32
|
||||||
|
|
||||||
|
proc XcmsCIExyYFormat(): TXcmsColorFormat =
|
||||||
|
result = 0x00000003'i32
|
||||||
|
|
||||||
|
proc XcmsCIELabFormat(): TXcmsColorFormat =
|
||||||
|
result = 0x00000004'i32
|
||||||
|
|
||||||
|
proc XcmsCIELuvFormat(): TXcmsColorFormat =
|
||||||
|
result = 0x00000005'i32
|
||||||
|
|
||||||
|
proc XcmsTekHVCFormat(): TXcmsColorFormat =
|
||||||
|
result = 0x00000006'i32
|
||||||
|
|
||||||
|
proc XcmsRGBFormat(): TXcmsColorFormat =
|
||||||
|
result = 0x80000000'i32
|
||||||
|
|
||||||
|
proc XcmsRGBiFormat(): TXcmsColorFormat =
|
||||||
|
result = 0x80000001'i32
|
||||||
|
|
||||||
|
#when defined(MACROS):
|
||||||
|
proc DisplayOfCCC(ccc: TXcmsCCC): PDisplay =
|
||||||
|
result = ccc.dpy
|
||||||
|
|
||||||
|
proc ScreenNumberOfCCC(ccc: TXcmsCCC): int32 =
|
||||||
|
result = ccc.screenNumber
|
||||||
|
|
||||||
|
proc VisualOfCCC(ccc: TXcmsCCC): PVisual =
|
||||||
|
result = ccc.visual
|
||||||
|
|
||||||
|
proc ClientWhitePointOfCCC(ccc: var TXcmsCCC): ptr TXcmsColor =
|
||||||
|
result = addr(ccc.clientWhitePt)
|
||||||
|
|
||||||
|
proc ScreenWhitePointOfCCC(ccc: var TXcmsCCC): ptr TXcmsColor =
|
||||||
|
result = addr(ccc.pPerScrnInfo.screenWhitePt)
|
||||||
|
|
||||||
|
proc FunctionSetOfCCC(ccc: TXcmsCCC): TXpointer =
|
||||||
|
result = ccc.pPerScrnInfo.functionSet
|
||||||
235
tests/deps/x11-1.0/xf86dga.nim
Normal file
235
tests/deps/x11-1.0/xf86dga.nim
Normal file
|
|
@ -0,0 +1,235 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 1999 XFree86 Inc
|
||||||
|
#
|
||||||
|
# $XFree86: xc/include/extensions/xf86dga.h,v 3.20 1999/10/13 04:20:48 dawes Exp $
|
||||||
|
|
||||||
|
import
|
||||||
|
x, xlib
|
||||||
|
|
||||||
|
const
|
||||||
|
libXxf86dga* = "libXxf86dga.so"
|
||||||
|
|
||||||
|
#type
|
||||||
|
# cfloat* = float32
|
||||||
|
|
||||||
|
# $XFree86: xc/include/extensions/xf86dga1.h,v 1.2 1999/04/17 07:05:41 dawes Exp $
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#Copyright (c) 1995 Jon Tombs
|
||||||
|
#Copyright (c) 1995 XFree86 Inc
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#************************************************************************
|
||||||
|
#
|
||||||
|
# THIS IS THE OLD DGA API AND IS OBSOLETE. PLEASE DO NOT USE IT ANYMORE
|
||||||
|
#
|
||||||
|
#************************************************************************
|
||||||
|
|
||||||
|
type
|
||||||
|
PPcchar* = ptr ptr cstring
|
||||||
|
|
||||||
|
const
|
||||||
|
X_XF86DGAQueryVersion* = 0
|
||||||
|
X_XF86DGAGetVideoLL* = 1
|
||||||
|
X_XF86DGADirectVideo* = 2
|
||||||
|
X_XF86DGAGetViewPortSize* = 3
|
||||||
|
X_XF86DGASetViewPort* = 4
|
||||||
|
X_XF86DGAGetVidPage* = 5
|
||||||
|
X_XF86DGASetVidPage* = 6
|
||||||
|
X_XF86DGAInstallColormap* = 7
|
||||||
|
X_XF86DGAQueryDirectVideo* = 8
|
||||||
|
X_XF86DGAViewPortChanged* = 9
|
||||||
|
XF86DGADirectPresent* = 0x00000001
|
||||||
|
XF86DGADirectGraphics* = 0x00000002
|
||||||
|
XF86DGADirectMouse* = 0x00000004
|
||||||
|
XF86DGADirectKeyb* = 0x00000008
|
||||||
|
XF86DGAHasColormap* = 0x00000100
|
||||||
|
XF86DGADirectColormap* = 0x00000200
|
||||||
|
|
||||||
|
proc XF86DGAQueryVersion*(dpy: PDisplay, majorVersion: Pcint,
|
||||||
|
minorVersion: Pcint): TBool{.cdecl,
|
||||||
|
dynlib: libXxf86dga, importc.}
|
||||||
|
proc XF86DGAQueryExtension*(dpy: PDisplay, event_base: Pcint, error_base: Pcint): TBool{.
|
||||||
|
cdecl, dynlib: libXxf86dga, importc.}
|
||||||
|
proc XF86DGAGetVideoLL*(dpy: PDisplay, screen: cint, base_addr: Pcint,
|
||||||
|
width: Pcint, bank_size: Pcint, ram_size: Pcint): TStatus{.
|
||||||
|
cdecl, dynlib: libXxf86dga, importc.}
|
||||||
|
proc XF86DGAGetVideo*(dpy: PDisplay, screen: cint, base_addr: PPcchar,
|
||||||
|
width: Pcint, bank_size: Pcint, ram_size: Pcint): TStatus{.
|
||||||
|
cdecl, dynlib: libXxf86dga, importc.}
|
||||||
|
proc XF86DGADirectVideo*(dpy: PDisplay, screen: cint, enable: cint): TStatus{.
|
||||||
|
cdecl, dynlib: libXxf86dga, importc.}
|
||||||
|
proc XF86DGADirectVideoLL*(dpy: PDisplay, screen: cint, enable: cint): TStatus{.
|
||||||
|
cdecl, dynlib: libXxf86dga, importc.}
|
||||||
|
proc XF86DGAGetViewPortSize*(dpy: PDisplay, screen: cint, width: Pcint,
|
||||||
|
height: Pcint): TStatus{.cdecl,
|
||||||
|
dynlib: libXxf86dga, importc.}
|
||||||
|
proc XF86DGASetViewPort*(dpy: PDisplay, screen: cint, x: cint, y: cint): TStatus{.
|
||||||
|
cdecl, dynlib: libXxf86dga, importc.}
|
||||||
|
proc XF86DGAGetVidPage*(dpy: PDisplay, screen: cint, vid_page: Pcint): TStatus{.
|
||||||
|
cdecl, dynlib: libXxf86dga, importc.}
|
||||||
|
proc XF86DGASetVidPage*(dpy: PDisplay, screen: cint, vid_page: cint): TStatus{.
|
||||||
|
cdecl, dynlib: libXxf86dga, importc.}
|
||||||
|
proc XF86DGAInstallColormap*(dpy: PDisplay, screen: cint, Colormap: TColormap): TStatus{.
|
||||||
|
cdecl, dynlib: libXxf86dga, importc.}
|
||||||
|
proc XF86DGAForkApp*(screen: cint): cint{.cdecl, dynlib: libXxf86dga, importc.}
|
||||||
|
proc XF86DGAQueryDirectVideo*(dpy: PDisplay, screen: cint, flags: Pcint): TStatus{.
|
||||||
|
cdecl, dynlib: libXxf86dga, importc.}
|
||||||
|
proc XF86DGAViewPortChanged*(dpy: PDisplay, screen: cint, n: cint): TBool{.
|
||||||
|
cdecl, dynlib: libXxf86dga, importc.}
|
||||||
|
const
|
||||||
|
X_XDGAQueryVersion* = 0 # 1 through 9 are in xf86dga1.pp
|
||||||
|
# 10 and 11 are reserved to avoid conflicts with rogue DGA extensions
|
||||||
|
X_XDGAQueryModes* = 12
|
||||||
|
X_XDGASetMode* = 13
|
||||||
|
X_XDGASetViewport* = 14
|
||||||
|
X_XDGAInstallColormap* = 15
|
||||||
|
X_XDGASelectInput* = 16
|
||||||
|
X_XDGAFillRectangle* = 17
|
||||||
|
X_XDGACopyArea* = 18
|
||||||
|
X_XDGACopyTransparentArea* = 19
|
||||||
|
X_XDGAGetViewportStatus* = 20
|
||||||
|
X_XDGASync* = 21
|
||||||
|
X_XDGAOpenFramebuffer* = 22
|
||||||
|
X_XDGACloseFramebuffer* = 23
|
||||||
|
X_XDGASetClientVersion* = 24
|
||||||
|
X_XDGAChangePixmapMode* = 25
|
||||||
|
X_XDGACreateColormap* = 26
|
||||||
|
XDGAConcurrentAccess* = 0x00000001
|
||||||
|
XDGASolidFillRect* = 0x00000002
|
||||||
|
XDGABlitRect* = 0x00000004
|
||||||
|
XDGABlitTransRect* = 0x00000008
|
||||||
|
XDGAPixmap* = 0x00000010
|
||||||
|
XDGAInterlaced* = 0x00010000
|
||||||
|
XDGADoublescan* = 0x00020000
|
||||||
|
XDGAFlipImmediate* = 0x00000001
|
||||||
|
XDGAFlipRetrace* = 0x00000002
|
||||||
|
XDGANeedRoot* = 0x00000001
|
||||||
|
XF86DGANumberEvents* = 7
|
||||||
|
XDGAPixmapModeLarge* = 0
|
||||||
|
XDGAPixmapModeSmall* = 1
|
||||||
|
XF86DGAClientNotLocal* = 0
|
||||||
|
XF86DGANoDirectVideoMode* = 1
|
||||||
|
XF86DGAScreenNotActive* = 2
|
||||||
|
XF86DGADirectNotActivated* = 3
|
||||||
|
XF86DGAOperationNotSupported* = 4
|
||||||
|
XF86DGANumberErrors* = (XF86DGAOperationNotSupported + 1)
|
||||||
|
|
||||||
|
type
|
||||||
|
PXDGAMode* = ptr TXDGAMode
|
||||||
|
TXDGAMode*{.final.} = object
|
||||||
|
num*: cint # A unique identifier for the mode (num > 0)
|
||||||
|
name*: cstring # name of mode given in the XF86Config
|
||||||
|
verticalRefresh*: cfloat
|
||||||
|
flags*: cint # DGA_CONCURRENT_ACCESS, etc...
|
||||||
|
imageWidth*: cint # linear accessible portion (pixels)
|
||||||
|
imageHeight*: cint
|
||||||
|
pixmapWidth*: cint # Xlib accessible portion (pixels)
|
||||||
|
pixmapHeight*: cint # both fields ignored if no concurrent access
|
||||||
|
bytesPerScanline*: cint
|
||||||
|
byteOrder*: cint # MSBFirst, LSBFirst
|
||||||
|
depth*: cint
|
||||||
|
bitsPerPixel*: cint
|
||||||
|
redMask*: culong
|
||||||
|
greenMask*: culong
|
||||||
|
blueMask*: culong
|
||||||
|
visualClass*: cshort
|
||||||
|
viewportWidth*: cint
|
||||||
|
viewportHeight*: cint
|
||||||
|
xViewportStep*: cint # viewport position granularity
|
||||||
|
yViewportStep*: cint
|
||||||
|
maxViewportX*: cint # max viewport origin
|
||||||
|
maxViewportY*: cint
|
||||||
|
viewportFlags*: cint # types of page flipping possible
|
||||||
|
reserved1*: cint
|
||||||
|
reserved2*: cint
|
||||||
|
|
||||||
|
PXDGADevice* = ptr TXDGADevice
|
||||||
|
TXDGADevice*{.final.} = object
|
||||||
|
mode*: TXDGAMode
|
||||||
|
data*: Pcuchar
|
||||||
|
pixmap*: TPixmap
|
||||||
|
|
||||||
|
PXDGAButtonEvent* = ptr TXDGAButtonEvent
|
||||||
|
TXDGAButtonEvent*{.final.} = object
|
||||||
|
theType*: cint
|
||||||
|
serial*: culong
|
||||||
|
display*: PDisplay
|
||||||
|
screen*: cint
|
||||||
|
time*: TTime
|
||||||
|
state*: cuint
|
||||||
|
button*: cuint
|
||||||
|
|
||||||
|
PXDGAKeyEvent* = ptr TXDGAKeyEvent
|
||||||
|
TXDGAKeyEvent*{.final.} = object
|
||||||
|
theType*: cint
|
||||||
|
serial*: culong
|
||||||
|
display*: PDisplay
|
||||||
|
screen*: cint
|
||||||
|
time*: TTime
|
||||||
|
state*: cuint
|
||||||
|
keycode*: cuint
|
||||||
|
|
||||||
|
PXDGAMotionEvent* = ptr TXDGAMotionEvent
|
||||||
|
TXDGAMotionEvent*{.final.} = object
|
||||||
|
theType*: cint
|
||||||
|
serial*: culong
|
||||||
|
display*: PDisplay
|
||||||
|
screen*: cint
|
||||||
|
time*: TTime
|
||||||
|
state*: cuint
|
||||||
|
dx*: cint
|
||||||
|
dy*: cint
|
||||||
|
|
||||||
|
PXDGAEvent* = ptr TXDGAEvent
|
||||||
|
TXDGAEvent*{.final.} = object
|
||||||
|
pad*: array[0..23, clong] # sorry you have to cast if you want access
|
||||||
|
#Case LongInt Of
|
||||||
|
# 0 : (_type : cint);
|
||||||
|
# 1 : (xbutton : TXDGAButtonEvent);
|
||||||
|
# 2 : (xkey : TXDGAKeyEvent);
|
||||||
|
# 3 : (xmotion : TXDGAMotionEvent);
|
||||||
|
# 4 : (pad : Array[0..23] Of clong);
|
||||||
|
|
||||||
|
|
||||||
|
proc XDGAQueryExtension*(dpy: PDisplay, eventBase: Pcint, erroBase: Pcint): TBool{.
|
||||||
|
cdecl, dynlib: libXxf86dga, importc.}
|
||||||
|
proc XDGAQueryVersion*(dpy: PDisplay, majorVersion: Pcint, minorVersion: Pcint): TBool{.
|
||||||
|
cdecl, dynlib: libXxf86dga, importc.}
|
||||||
|
proc XDGAQueryModes*(dpy: PDisplay, screen: cint, num: Pcint): PXDGAMode{.cdecl,
|
||||||
|
dynlib: libXxf86dga, importc.}
|
||||||
|
proc XDGASetMode*(dpy: PDisplay, screen: cint, mode: cint): PXDGADevice{.cdecl,
|
||||||
|
dynlib: libXxf86dga, importc.}
|
||||||
|
proc XDGAOpenFramebuffer*(dpy: PDisplay, screen: cint): TBool{.cdecl,
|
||||||
|
dynlib: libXxf86dga, importc.}
|
||||||
|
proc XDGACloseFramebuffer*(dpy: PDisplay, screen: cint){.cdecl,
|
||||||
|
dynlib: libXxf86dga, importc.}
|
||||||
|
proc XDGASetViewport*(dpy: PDisplay, screen: cint, x: cint, y: cint, flags: cint){.
|
||||||
|
cdecl, dynlib: libXxf86dga, importc.}
|
||||||
|
proc XDGAInstallColormap*(dpy: PDisplay, screen: cint, cmap: TColormap){.cdecl,
|
||||||
|
dynlib: libXxf86dga, importc.}
|
||||||
|
proc XDGACreateColormap*(dpy: PDisplay, screen: cint, device: PXDGADevice,
|
||||||
|
alloc: cint): TColormap{.cdecl, dynlib: libXxf86dga,
|
||||||
|
importc.}
|
||||||
|
proc XDGASelectInput*(dpy: PDisplay, screen: cint, event_mask: clong){.cdecl,
|
||||||
|
dynlib: libXxf86dga, importc.}
|
||||||
|
proc XDGAFillRectangle*(dpy: PDisplay, screen: cint, x: cint, y: cint,
|
||||||
|
width: cuint, height: cuint, color: culong){.cdecl,
|
||||||
|
dynlib: libXxf86dga, importc.}
|
||||||
|
proc XDGACopyArea*(dpy: PDisplay, screen: cint, srcx: cint, srcy: cint,
|
||||||
|
width: cuint, height: cuint, dstx: cint, dsty: cint){.cdecl,
|
||||||
|
dynlib: libXxf86dga, importc.}
|
||||||
|
proc XDGACopyTransparentArea*(dpy: PDisplay, screen: cint, srcx: cint,
|
||||||
|
srcy: cint, width: cuint, height: cuint,
|
||||||
|
dstx: cint, dsty: cint, key: culong){.cdecl,
|
||||||
|
dynlib: libXxf86dga, importc.}
|
||||||
|
proc XDGAGetViewportStatus*(dpy: PDisplay, screen: cint): cint{.cdecl,
|
||||||
|
dynlib: libXxf86dga, importc.}
|
||||||
|
proc XDGASync*(dpy: PDisplay, screen: cint){.cdecl, dynlib: libXxf86dga, importc.}
|
||||||
|
proc XDGASetClientVersion*(dpy: PDisplay): TBool{.cdecl, dynlib: libXxf86dga,
|
||||||
|
importc.}
|
||||||
|
proc XDGAChangePixmapMode*(dpy: PDisplay, screen: cint, x: Pcint, y: Pcint,
|
||||||
|
mode: cint){.cdecl, dynlib: libXxf86dga, importc.}
|
||||||
|
proc XDGAKeyEventToXKeyEvent*(dk: PXDGAKeyEvent, xk: PXKeyEvent){.cdecl,
|
||||||
|
dynlib: libXxf86dga, importc.}
|
||||||
|
# implementation
|
||||||
229
tests/deps/x11-1.0/xf86vmode.nim
Normal file
229
tests/deps/x11-1.0/xf86vmode.nim
Normal file
|
|
@ -0,0 +1,229 @@
|
||||||
|
# $XFree86: xc/include/extensions/xf86vmode.h,v 3.30 2001/05/07 20:09:50 mvojkovi Exp $
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#Copyright 1995 Kaleb S. KEITHLEY
|
||||||
|
#
|
||||||
|
#Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
#a copy of this software and associated documentation files (the
|
||||||
|
#"Software"), to deal in the Software without restriction, including
|
||||||
|
#without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
#distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
#permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
#the following conditions:
|
||||||
|
#
|
||||||
|
#The above copyright notice and this permission notice shall be
|
||||||
|
#included in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
#EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
#MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
#IN NO EVENT SHALL Kaleb S. KEITHLEY BE LIABLE FOR ANY CLAIM, DAMAGES
|
||||||
|
#OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
#ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
#OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#
|
||||||
|
#Except as contained in this notice, the name of Kaleb S. KEITHLEY
|
||||||
|
#shall not be used in advertising or otherwise to promote the sale, use
|
||||||
|
#or other dealings in this Software without prior written authorization
|
||||||
|
#from Kaleb S. KEITHLEY
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# $Xorg: xf86vmode.h,v 1.3 2000/08/18 04:05:46 coskrey Exp $
|
||||||
|
# THIS IS NOT AN X CONSORTIUM STANDARD OR AN X PROJECT TEAM SPECIFICATION
|
||||||
|
|
||||||
|
import
|
||||||
|
x, xlib
|
||||||
|
|
||||||
|
const
|
||||||
|
libXxf86vm* = "libXxf86vm.so"
|
||||||
|
|
||||||
|
type
|
||||||
|
PINT32* = ptr int32
|
||||||
|
|
||||||
|
const
|
||||||
|
X_XF86VidModeQueryVersion* = 0
|
||||||
|
X_XF86VidModeGetModeLine* = 1
|
||||||
|
X_XF86VidModeModModeLine* = 2
|
||||||
|
X_XF86VidModeSwitchMode* = 3
|
||||||
|
X_XF86VidModeGetMonitor* = 4
|
||||||
|
X_XF86VidModeLockModeSwitch* = 5
|
||||||
|
X_XF86VidModeGetAllModeLines* = 6
|
||||||
|
X_XF86VidModeAddModeLine* = 7
|
||||||
|
X_XF86VidModeDeleteModeLine* = 8
|
||||||
|
X_XF86VidModeValidateModeLine* = 9
|
||||||
|
X_XF86VidModeSwitchToMode* = 10
|
||||||
|
X_XF86VidModeGetViewPort* = 11
|
||||||
|
X_XF86VidModeSetViewPort* = 12 # new for version 2.x of this extension
|
||||||
|
X_XF86VidModeGetDotClocks* = 13
|
||||||
|
X_XF86VidModeSetClientVersion* = 14
|
||||||
|
X_XF86VidModeSetGamma* = 15
|
||||||
|
X_XF86VidModeGetGamma* = 16
|
||||||
|
X_XF86VidModeGetGammaRamp* = 17
|
||||||
|
X_XF86VidModeSetGammaRamp* = 18
|
||||||
|
X_XF86VidModeGetGammaRampSize* = 19
|
||||||
|
X_XF86VidModeGetPermissions* = 20
|
||||||
|
CLKFLAG_PROGRAMABLE* = 1
|
||||||
|
|
||||||
|
when defined(XF86VIDMODE_EVENTS):
|
||||||
|
const
|
||||||
|
XF86VidModeNotify* = 0
|
||||||
|
XF86VidModeNumberEvents* = (XF86VidModeNotify + 1)
|
||||||
|
XF86VidModeNotifyMask* = 0x00000001
|
||||||
|
XF86VidModeNonEvent* = 0
|
||||||
|
XF86VidModeModeChange* = 1
|
||||||
|
else:
|
||||||
|
const
|
||||||
|
XF86VidModeNumberEvents* = 0
|
||||||
|
const
|
||||||
|
XF86VidModeBadClock* = 0
|
||||||
|
XF86VidModeBadHTimings* = 1
|
||||||
|
XF86VidModeBadVTimings* = 2
|
||||||
|
XF86VidModeModeUnsuitable* = 3
|
||||||
|
XF86VidModeExtensionDisabled* = 4
|
||||||
|
XF86VidModeClientNotLocal* = 5
|
||||||
|
XF86VidModeZoomLocked* = 6
|
||||||
|
XF86VidModeNumberErrors* = (XF86VidModeZoomLocked + 1)
|
||||||
|
XF86VM_READ_PERMISSION* = 1
|
||||||
|
XF86VM_WRITE_PERMISSION* = 2
|
||||||
|
|
||||||
|
type
|
||||||
|
PXF86VidModeModeLine* = ptr TXF86VidModeModeLine
|
||||||
|
TXF86VidModeModeLine*{.final.} = object
|
||||||
|
hdisplay*: cushort
|
||||||
|
hsyncstart*: cushort
|
||||||
|
hsyncend*: cushort
|
||||||
|
htotal*: cushort
|
||||||
|
hskew*: cushort
|
||||||
|
vdisplay*: cushort
|
||||||
|
vsyncstart*: cushort
|
||||||
|
vsyncend*: cushort
|
||||||
|
vtotal*: cushort
|
||||||
|
flags*: cuint
|
||||||
|
privsize*: cint
|
||||||
|
c_private*: PINT32
|
||||||
|
|
||||||
|
PPPXF86VidModeModeInfo* = ptr PPXF86VidModeModeInfo
|
||||||
|
PPXF86VidModeModeInfo* = ptr PXF86VidModeModeInfo
|
||||||
|
PXF86VidModeModeInfo* = ptr TXF86VidModeModeInfo
|
||||||
|
TXF86VidModeModeInfo*{.final.} = object
|
||||||
|
dotclock*: cuint
|
||||||
|
hdisplay*: cushort
|
||||||
|
hsyncstart*: cushort
|
||||||
|
hsyncend*: cushort
|
||||||
|
htotal*: cushort
|
||||||
|
hskew*: cushort
|
||||||
|
vdisplay*: cushort
|
||||||
|
vsyncstart*: cushort
|
||||||
|
vsyncend*: cushort
|
||||||
|
vtotal*: cushort
|
||||||
|
flags*: cuint
|
||||||
|
privsize*: cint
|
||||||
|
c_private*: PINT32
|
||||||
|
|
||||||
|
PXF86VidModeSyncRange* = ptr TXF86VidModeSyncRange
|
||||||
|
TXF86VidModeSyncRange*{.final.} = object
|
||||||
|
hi*: cfloat
|
||||||
|
lo*: cfloat
|
||||||
|
|
||||||
|
PXF86VidModeMonitor* = ptr TXF86VidModeMonitor
|
||||||
|
TXF86VidModeMonitor*{.final.} = object
|
||||||
|
vendor*: cstring
|
||||||
|
model*: cstring
|
||||||
|
EMPTY*: cfloat
|
||||||
|
nhsync*: cuchar
|
||||||
|
hsync*: PXF86VidModeSyncRange
|
||||||
|
nvsync*: cuchar
|
||||||
|
vsync*: PXF86VidModeSyncRange
|
||||||
|
|
||||||
|
PXF86VidModeNotifyEvent* = ptr TXF86VidModeNotifyEvent
|
||||||
|
TXF86VidModeNotifyEvent*{.final.} = object
|
||||||
|
theType*: cint # of event
|
||||||
|
serial*: culong # # of last request processed by server
|
||||||
|
send_event*: TBool # true if this came from a SendEvent req
|
||||||
|
display*: PDisplay # Display the event was read from
|
||||||
|
root*: TWindow # root window of event screen
|
||||||
|
state*: cint # What happened
|
||||||
|
kind*: cint # What happened
|
||||||
|
forced*: TBool # extents of new region
|
||||||
|
time*: TTime # event timestamp
|
||||||
|
|
||||||
|
PXF86VidModeGamma* = ptr TXF86VidModeGamma
|
||||||
|
TXF86VidModeGamma*{.final.} = object
|
||||||
|
red*: cfloat # Red Gamma value
|
||||||
|
green*: cfloat # Green Gamma value
|
||||||
|
blue*: cfloat # Blue Gamma value
|
||||||
|
|
||||||
|
|
||||||
|
when defined(MACROS):
|
||||||
|
proc XF86VidModeSelectNextMode*(disp: PDisplay, scr: cint): TBool
|
||||||
|
proc XF86VidModeSelectPrevMode*(disp: PDisplay, scr: cint): TBool
|
||||||
|
proc XF86VidModeQueryVersion*(dpy: PDisplay, majorVersion: Pcint,
|
||||||
|
minorVersion: Pcint): TBool{.cdecl,
|
||||||
|
dynlib: libXxf86vm, importc.}
|
||||||
|
proc XF86VidModeQueryExtension*(dpy: PDisplay, event_base: Pcint,
|
||||||
|
error_base: Pcint): TBool{.cdecl,
|
||||||
|
dynlib: libXxf86vm, importc.}
|
||||||
|
proc XF86VidModeSetClientVersion*(dpy: PDisplay): TBool{.cdecl,
|
||||||
|
dynlib: libXxf86vm, importc.}
|
||||||
|
proc XF86VidModeGetModeLine*(dpy: PDisplay, screen: cint, dotclock: Pcint,
|
||||||
|
modeline: PXF86VidModeModeLine): TBool{.cdecl,
|
||||||
|
dynlib: libXxf86vm, importc.}
|
||||||
|
proc XF86VidModeGetAllModeLines*(dpy: PDisplay, screen: cint, modecount: Pcint,
|
||||||
|
modelinesPtr: PPPXF86VidModeModeInfo): TBool{.
|
||||||
|
cdecl, dynlib: libXxf86vm, importc.}
|
||||||
|
proc XF86VidModeAddModeLine*(dpy: PDisplay, screen: cint,
|
||||||
|
new_modeline: PXF86VidModeModeInfo,
|
||||||
|
after_modeline: PXF86VidModeModeInfo): TBool{.
|
||||||
|
cdecl, dynlib: libXxf86vm, importc.}
|
||||||
|
proc XF86VidModeDeleteModeLine*(dpy: PDisplay, screen: cint,
|
||||||
|
modeline: PXF86VidModeModeInfo): TBool{.cdecl,
|
||||||
|
dynlib: libXxf86vm, importc.}
|
||||||
|
proc XF86VidModeModModeLine*(dpy: PDisplay, screen: cint,
|
||||||
|
modeline: PXF86VidModeModeLine): TBool{.cdecl,
|
||||||
|
dynlib: libXxf86vm, importc.}
|
||||||
|
proc XF86VidModeValidateModeLine*(dpy: PDisplay, screen: cint,
|
||||||
|
modeline: PXF86VidModeModeInfo): TStatus{.
|
||||||
|
cdecl, dynlib: libXxf86vm, importc.}
|
||||||
|
proc XF86VidModeSwitchMode*(dpy: PDisplay, screen: cint, zoom: cint): TBool{.
|
||||||
|
cdecl, dynlib: libXxf86vm, importc.}
|
||||||
|
proc XF86VidModeSwitchToMode*(dpy: PDisplay, screen: cint,
|
||||||
|
modeline: PXF86VidModeModeInfo): TBool{.cdecl,
|
||||||
|
dynlib: libXxf86vm, importc.}
|
||||||
|
proc XF86VidModeLockModeSwitch*(dpy: PDisplay, screen: cint, lock: cint): TBool{.
|
||||||
|
cdecl, dynlib: libXxf86vm, importc.}
|
||||||
|
proc XF86VidModeGetMonitor*(dpy: PDisplay, screen: cint,
|
||||||
|
monitor: PXF86VidModeMonitor): TBool{.cdecl,
|
||||||
|
dynlib: libXxf86vm, importc.}
|
||||||
|
proc XF86VidModeGetViewPort*(dpy: PDisplay, screen: cint, x_return: Pcint,
|
||||||
|
y_return: Pcint): TBool{.cdecl, dynlib: libXxf86vm,
|
||||||
|
importc.}
|
||||||
|
proc XF86VidModeSetViewPort*(dpy: PDisplay, screen: cint, x: cint, y: cint): TBool{.
|
||||||
|
cdecl, dynlib: libXxf86vm, importc.}
|
||||||
|
proc XF86VidModeGetDotClocks*(dpy: PDisplay, screen: cint, flags_return: Pcint,
|
||||||
|
number_of_clocks_return: Pcint,
|
||||||
|
max_dot_clock_return: Pcint, clocks_return: PPcint): TBool{.
|
||||||
|
cdecl, dynlib: libXxf86vm, importc.}
|
||||||
|
proc XF86VidModeGetGamma*(dpy: PDisplay, screen: cint, Gamma: PXF86VidModeGamma): TBool{.
|
||||||
|
cdecl, dynlib: libXxf86vm, importc.}
|
||||||
|
proc XF86VidModeSetGamma*(dpy: PDisplay, screen: cint, Gamma: PXF86VidModeGamma): TBool{.
|
||||||
|
cdecl, dynlib: libXxf86vm, importc.}
|
||||||
|
proc XF86VidModeSetGammaRamp*(dpy: PDisplay, screen: cint, size: cint,
|
||||||
|
red_array: Pcushort, green_array: Pcushort,
|
||||||
|
blue_array: Pcushort): TBool{.cdecl,
|
||||||
|
dynlib: libXxf86vm, importc.}
|
||||||
|
proc XF86VidModeGetGammaRamp*(dpy: PDisplay, screen: cint, size: cint,
|
||||||
|
red_array: Pcushort, green_array: Pcushort,
|
||||||
|
blue_array: Pcushort): TBool{.cdecl,
|
||||||
|
dynlib: libXxf86vm, importc.}
|
||||||
|
proc XF86VidModeGetGammaRampSize*(dpy: PDisplay, screen: cint, size: Pcint): TBool{.
|
||||||
|
cdecl, dynlib: libXxf86vm, importc.}
|
||||||
|
proc XF86VidModeGetPermissions*(dpy: PDisplay, screen: cint, permissions: Pcint): TBool{.
|
||||||
|
cdecl, dynlib: libXxf86vm, importc.}
|
||||||
|
# implementation
|
||||||
|
|
||||||
|
#when defined(MACROS):
|
||||||
|
proc XF86VidModeSelectNextMode(disp: PDisplay, scr: cint): TBool =
|
||||||
|
XF86VidModeSwitchMode(disp, scr, 1)
|
||||||
|
|
||||||
|
proc XF86VidModeSelectPrevMode(disp: PDisplay, scr: cint): TBool =
|
||||||
|
XF86VidModeSwitchMode(disp, scr, - 1)
|
||||||
307
tests/deps/x11-1.0/xi.nim
Normal file
307
tests/deps/x11-1.0/xi.nim
Normal file
|
|
@ -0,0 +1,307 @@
|
||||||
|
#
|
||||||
|
# $Xorg: XI.h,v 1.4 2001/02/09 02:03:23 xorgcvs Exp $
|
||||||
|
#
|
||||||
|
#************************************************************
|
||||||
|
#
|
||||||
|
#Copyright 1989, 1998 The Open Group
|
||||||
|
#
|
||||||
|
#Permission to use, copy, modify, distribute, and sell this software and its
|
||||||
|
#documentation for any purpose is hereby granted without fee, provided that
|
||||||
|
#the above copyright notice appear in all copies and that both that
|
||||||
|
#copyright notice and this permission notice appear in supporting
|
||||||
|
#documentation.
|
||||||
|
#
|
||||||
|
#The above copyright notice and this permission notice shall be included in
|
||||||
|
#all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
#OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||||
|
#AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
#CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#
|
||||||
|
#Except as contained in this notice, the name of The Open Group shall not be
|
||||||
|
#used in advertising or otherwise to promote the sale, use or other dealings
|
||||||
|
#in this Software without prior written authorization from The Open Group.
|
||||||
|
#
|
||||||
|
#Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
|
||||||
|
#
|
||||||
|
# All Rights Reserved
|
||||||
|
#
|
||||||
|
#Permission to use, copy, modify, and distribute this software and its
|
||||||
|
#documentation for any purpose and without fee is hereby granted,
|
||||||
|
#provided that the above copyright notice appear in all copies and that
|
||||||
|
#both that copyright notice and this permission notice appear in
|
||||||
|
#supporting documentation, and that the name of Hewlett-Packard not be
|
||||||
|
#used in advertising or publicity pertaining to distribution of the
|
||||||
|
#software without specific, written prior permission.
|
||||||
|
#
|
||||||
|
#HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||||
|
#ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
||||||
|
#HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
||||||
|
#ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||||
|
#WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||||
|
#ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||||
|
#SOFTWARE.
|
||||||
|
#
|
||||||
|
#********************************************************/
|
||||||
|
# $XFree86: xc/include/extensions/XI.h,v 1.5 2001/12/14 19:53:28 dawes Exp $
|
||||||
|
#
|
||||||
|
# Definitions used by the server, library and client
|
||||||
|
#
|
||||||
|
# Pascal Convertion was made by Ido Kannner - kanerido@actcom.net.il
|
||||||
|
#
|
||||||
|
#Histroy:
|
||||||
|
# 2004/10/15 - Fixed a bug of accessing second based records by removing "paced record" and chnaged it to
|
||||||
|
# "reocrd" only.
|
||||||
|
# 2004/10/07 - Removed the "uses X;" line. The unit does not need it.
|
||||||
|
# 2004/10/03 - Conversion from C header to Pascal unit.
|
||||||
|
#
|
||||||
|
|
||||||
|
const
|
||||||
|
sz_xGetExtensionVersionReq* = 8
|
||||||
|
sz_xGetExtensionVersionReply* = 32
|
||||||
|
sz_xListInputDevicesReq* = 4
|
||||||
|
sz_xListInputDevicesReply* = 32
|
||||||
|
sz_xOpenDeviceReq* = 8
|
||||||
|
sz_xOpenDeviceReply* = 32
|
||||||
|
sz_xCloseDeviceReq* = 8
|
||||||
|
sz_xSetDeviceModeReq* = 8
|
||||||
|
sz_xSetDeviceModeReply* = 32
|
||||||
|
sz_xSelectExtensionEventReq* = 12
|
||||||
|
sz_xGetSelectedExtensionEventsReq* = 8
|
||||||
|
sz_xGetSelectedExtensionEventsReply* = 32
|
||||||
|
sz_xChangeDeviceDontPropagateListReq* = 12
|
||||||
|
sz_xGetDeviceDontPropagateListReq* = 8
|
||||||
|
sz_xGetDeviceDontPropagateListReply* = 32
|
||||||
|
sz_xGetDeviceMotionEventsReq* = 16
|
||||||
|
sz_xGetDeviceMotionEventsReply* = 32
|
||||||
|
sz_xChangeKeyboardDeviceReq* = 8
|
||||||
|
sz_xChangeKeyboardDeviceReply* = 32
|
||||||
|
sz_xChangePointerDeviceReq* = 8
|
||||||
|
sz_xChangePointerDeviceReply* = 32
|
||||||
|
sz_xGrabDeviceReq* = 20
|
||||||
|
sz_xGrabDeviceReply* = 32
|
||||||
|
sz_xUngrabDeviceReq* = 12
|
||||||
|
sz_xGrabDeviceKeyReq* = 20
|
||||||
|
sz_xGrabDeviceKeyReply* = 32
|
||||||
|
sz_xUngrabDeviceKeyReq* = 16
|
||||||
|
sz_xGrabDeviceButtonReq* = 20
|
||||||
|
sz_xGrabDeviceButtonReply* = 32
|
||||||
|
sz_xUngrabDeviceButtonReq* = 16
|
||||||
|
sz_xAllowDeviceEventsReq* = 12
|
||||||
|
sz_xGetDeviceFocusReq* = 8
|
||||||
|
sz_xGetDeviceFocusReply* = 32
|
||||||
|
sz_xSetDeviceFocusReq* = 16
|
||||||
|
sz_xGetFeedbackControlReq* = 8
|
||||||
|
sz_xGetFeedbackControlReply* = 32
|
||||||
|
sz_xChangeFeedbackControlReq* = 12
|
||||||
|
sz_xGetDeviceKeyMappingReq* = 8
|
||||||
|
sz_xGetDeviceKeyMappingReply* = 32
|
||||||
|
sz_xChangeDeviceKeyMappingReq* = 8
|
||||||
|
sz_xGetDeviceModifierMappingReq* = 8
|
||||||
|
sz_xSetDeviceModifierMappingReq* = 8
|
||||||
|
sz_xSetDeviceModifierMappingReply* = 32
|
||||||
|
sz_xGetDeviceButtonMappingReq* = 8
|
||||||
|
sz_xGetDeviceButtonMappingReply* = 32
|
||||||
|
sz_xSetDeviceButtonMappingReq* = 8
|
||||||
|
sz_xSetDeviceButtonMappingReply* = 32
|
||||||
|
sz_xQueryDeviceStateReq* = 8
|
||||||
|
sz_xQueryDeviceStateReply* = 32
|
||||||
|
sz_xSendExtensionEventReq* = 16
|
||||||
|
sz_xDeviceBellReq* = 8
|
||||||
|
sz_xSetDeviceValuatorsReq* = 8
|
||||||
|
sz_xSetDeviceValuatorsReply* = 32
|
||||||
|
sz_xGetDeviceControlReq* = 8
|
||||||
|
sz_xGetDeviceControlReply* = 32
|
||||||
|
sz_xChangeDeviceControlReq* = 8
|
||||||
|
sz_xChangeDeviceControlReply* = 32
|
||||||
|
|
||||||
|
const
|
||||||
|
INAME* = "XInputExtension"
|
||||||
|
|
||||||
|
const
|
||||||
|
XI_KEYBOARD* = "KEYBOARD"
|
||||||
|
XI_MOUSE* = "MOUSE"
|
||||||
|
XI_TABLET* = "TABLET"
|
||||||
|
XI_TOUCHSCREEN* = "TOUCHSCREEN"
|
||||||
|
XI_TOUCHPAD* = "TOUCHPAD"
|
||||||
|
XI_BARCODE* = "BARCODE"
|
||||||
|
XI_BUTTONBOX* = "BUTTONBOX"
|
||||||
|
XI_KNOB_BOX* = "KNOB_BOX"
|
||||||
|
XI_ONE_KNOB* = "ONE_KNOB"
|
||||||
|
XI_NINE_KNOB* = "NINE_KNOB"
|
||||||
|
XI_TRACKBALL* = "TRACKBALL"
|
||||||
|
XI_QUADRATURE* = "QUADRATURE"
|
||||||
|
XI_ID_MODULE* = "ID_MODULE"
|
||||||
|
XI_SPACEBALL* = "SPACEBALL"
|
||||||
|
XI_DATAGLOVE* = "DATAGLOVE"
|
||||||
|
XI_EYETRACKER* = "EYETRACKER"
|
||||||
|
XI_CURSORKEYS* = "CURSORKEYS"
|
||||||
|
XI_FOOTMOUSE* = "FOOTMOUSE"
|
||||||
|
|
||||||
|
const
|
||||||
|
Dont_Check* = 0
|
||||||
|
XInput_Initial_Release* = 1
|
||||||
|
XInput_Add_XDeviceBell* = 2
|
||||||
|
XInput_Add_XSetDeviceValuators* = 3
|
||||||
|
XInput_Add_XChangeDeviceControl* = 4
|
||||||
|
|
||||||
|
const
|
||||||
|
XI_Absent* = 0
|
||||||
|
XI_Present* = 1
|
||||||
|
|
||||||
|
const
|
||||||
|
XI_Initial_Release_Major* = 1
|
||||||
|
XI_Initial_Release_Minor* = 0
|
||||||
|
|
||||||
|
const
|
||||||
|
XI_Add_XDeviceBell_Major* = 1
|
||||||
|
XI_Add_XDeviceBell_Minor* = 1
|
||||||
|
|
||||||
|
const
|
||||||
|
XI_Add_XSetDeviceValuators_Major* = 1
|
||||||
|
XI_Add_XSetDeviceValuators_Minor* = 2
|
||||||
|
|
||||||
|
const
|
||||||
|
XI_Add_XChangeDeviceControl_Major* = 1
|
||||||
|
XI_Add_XChangeDeviceControl_Minor* = 3
|
||||||
|
|
||||||
|
const
|
||||||
|
DEVICE_RESOLUTION* = 1
|
||||||
|
|
||||||
|
const
|
||||||
|
NoSuchExtension* = 1
|
||||||
|
|
||||||
|
const
|
||||||
|
COUNT* = 0
|
||||||
|
CREATE* = 1
|
||||||
|
|
||||||
|
const
|
||||||
|
NewPointer* = 0
|
||||||
|
NewKeyboard* = 1
|
||||||
|
|
||||||
|
const
|
||||||
|
XPOINTER* = 0
|
||||||
|
XKEYBOARD* = 1
|
||||||
|
|
||||||
|
const
|
||||||
|
UseXKeyboard* = 0x000000FF
|
||||||
|
|
||||||
|
const
|
||||||
|
IsXPointer* = 0
|
||||||
|
IsXKeyboard* = 1
|
||||||
|
IsXExtensionDevice* = 2
|
||||||
|
|
||||||
|
const
|
||||||
|
AsyncThisDevice* = 0
|
||||||
|
SyncThisDevice* = 1
|
||||||
|
ReplayThisDevice* = 2
|
||||||
|
AsyncOtherDevices* = 3
|
||||||
|
AsyncAll* = 4
|
||||||
|
SyncAll* = 5
|
||||||
|
|
||||||
|
const
|
||||||
|
FollowKeyboard* = 3
|
||||||
|
RevertToFollowKeyboard* = 3
|
||||||
|
|
||||||
|
const
|
||||||
|
DvAccelNum* = int(1) shl 0
|
||||||
|
DvAccelDenom* = int(1) shl 1
|
||||||
|
DvThreshold* = int(1) shl 2
|
||||||
|
|
||||||
|
const
|
||||||
|
DvKeyClickPercent* = int(1) shl 0
|
||||||
|
DvPercent* = int(1) shl 1
|
||||||
|
DvPitch* = int(1) shl 2
|
||||||
|
DvDuration* = int(1) shl 3
|
||||||
|
DvLed* = int(1) shl 4
|
||||||
|
DvLedMode* = int(1) shl 5
|
||||||
|
DvKey* = int(1) shl 6
|
||||||
|
DvAutoRepeatMode* = 1 shl 7
|
||||||
|
|
||||||
|
const
|
||||||
|
DvString* = int(1) shl 0
|
||||||
|
|
||||||
|
const
|
||||||
|
DvInteger* = int(1) shl 0
|
||||||
|
|
||||||
|
const
|
||||||
|
DeviceMode* = int(1) shl 0
|
||||||
|
Relative* = 0
|
||||||
|
Absolute* = 1 # Merged from Metrolink tree for XINPUT stuff
|
||||||
|
TS_Raw* = 57
|
||||||
|
TS_Scaled* = 58
|
||||||
|
SendCoreEvents* = 59
|
||||||
|
DontSendCoreEvents* = 60 # End of merged section
|
||||||
|
|
||||||
|
const
|
||||||
|
ProximityState* = int(1) shl 1
|
||||||
|
InProximity* = int(0) shl 1
|
||||||
|
OutOfProximity* = int(1) shl 1
|
||||||
|
|
||||||
|
const
|
||||||
|
AddToList* = 0
|
||||||
|
DeleteFromList* = 1
|
||||||
|
|
||||||
|
const
|
||||||
|
KeyClass* = 0
|
||||||
|
ButtonClass* = 1
|
||||||
|
ValuatorClass* = 2
|
||||||
|
FeedbackClass* = 3
|
||||||
|
ProximityClass* = 4
|
||||||
|
FocusClass* = 5
|
||||||
|
OtherClass* = 6
|
||||||
|
|
||||||
|
const
|
||||||
|
KbdFeedbackClass* = 0
|
||||||
|
PtrFeedbackClass* = 1
|
||||||
|
StringFeedbackClass* = 2
|
||||||
|
IntegerFeedbackClass* = 3
|
||||||
|
LedFeedbackClass* = 4
|
||||||
|
BellFeedbackClass* = 5
|
||||||
|
|
||||||
|
const
|
||||||
|
devicePointerMotionHint* = 0
|
||||||
|
deviceButton1Motion* = 1
|
||||||
|
deviceButton2Motion* = 2
|
||||||
|
deviceButton3Motion* = 3
|
||||||
|
deviceButton4Motion* = 4
|
||||||
|
deviceButton5Motion* = 5
|
||||||
|
deviceButtonMotion* = 6
|
||||||
|
deviceButtonGrab* = 7
|
||||||
|
deviceOwnerGrabButton* = 8
|
||||||
|
noExtensionEvent* = 9
|
||||||
|
|
||||||
|
const
|
||||||
|
XI_BadDevice* = 0
|
||||||
|
XI_BadEvent* = 1
|
||||||
|
XI_BadMode* = 2
|
||||||
|
XI_DeviceBusy* = 3
|
||||||
|
XI_BadClass* = 4 # Make XEventClass be a CARD32 for 64 bit servers. Don't affect client
|
||||||
|
# definition of XEventClass since that would be a library interface change.
|
||||||
|
# See the top of X.h for more _XSERVER64 magic.
|
||||||
|
#
|
||||||
|
|
||||||
|
when defined(XSERVER64):
|
||||||
|
type
|
||||||
|
XEventClass* = CARD32
|
||||||
|
else:
|
||||||
|
type
|
||||||
|
XEventClass* = int32
|
||||||
|
#******************************************************************
|
||||||
|
# *
|
||||||
|
# * Extension version structure.
|
||||||
|
# *
|
||||||
|
#
|
||||||
|
|
||||||
|
type
|
||||||
|
PXExtensionVersion* = ptr TXExtensionVersion
|
||||||
|
TXExtensionVersion*{.final.} = object
|
||||||
|
present*: int16
|
||||||
|
major_version*: int16
|
||||||
|
minor_version*: int16
|
||||||
|
|
||||||
|
|
||||||
|
# implementation
|
||||||
25
tests/deps/x11-1.0/xinerama.nim
Normal file
25
tests/deps/x11-1.0/xinerama.nim
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
# Converted from X11/Xinerama.h
|
||||||
|
import
|
||||||
|
xlib
|
||||||
|
|
||||||
|
const
|
||||||
|
xineramaLib = "libXinerama.so"
|
||||||
|
|
||||||
|
type
|
||||||
|
PXineramaScreenInfo* = ptr TXineramaScreenInfo
|
||||||
|
TXineramaScreenInfo*{.final.} = object
|
||||||
|
screen_number*: cint
|
||||||
|
x_org*: int16
|
||||||
|
y_org*: int16
|
||||||
|
width*: int16
|
||||||
|
height*: int16
|
||||||
|
|
||||||
|
|
||||||
|
proc XineramaQueryExtension*(dpy: PDisplay, event_base: Pcint, error_base: Pcint): TBool{.
|
||||||
|
cdecl, dynlib: xineramaLib, importc.}
|
||||||
|
proc XineramaQueryVersion*(dpy: PDisplay, major: Pcint, minor: Pcint): TStatus{.
|
||||||
|
cdecl, dynlib: xineramaLib, importc.}
|
||||||
|
proc XineramaIsActive*(dpy: PDisplay): TBool{.cdecl, dynlib: xineramaLib, importc.}
|
||||||
|
proc XineramaQueryScreens*(dpy: PDisplay, number: Pcint): PXineramaScreenInfo{.
|
||||||
|
cdecl, dynlib: xineramaLib, importc.}
|
||||||
|
|
||||||
2387
tests/deps/x11-1.0/xkb.nim
Normal file
2387
tests/deps/x11-1.0/xkb.nim
Normal file
File diff suppressed because it is too large
Load diff
661
tests/deps/x11-1.0/xkblib.nim
Normal file
661
tests/deps/x11-1.0/xkblib.nim
Normal file
|
|
@ -0,0 +1,661 @@
|
||||||
|
# $Xorg: XKBlib.h,v 1.6 2000/08/17 19:45:03 cpqbld Exp $
|
||||||
|
#************************************************************
|
||||||
|
#Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
|
||||||
|
#
|
||||||
|
#Permission to use, copy, modify, and distribute this
|
||||||
|
#software and its documentation for any purpose and without
|
||||||
|
#fee is hereby granted, provided that the above copyright
|
||||||
|
#notice appear in all copies and that both that copyright
|
||||||
|
#notice and this permission notice appear in supporting
|
||||||
|
#documentation, and that the name of Silicon Graphics not be
|
||||||
|
#used in advertising or publicity pertaining to distribution
|
||||||
|
#of the software without specific prior written permission.
|
||||||
|
#Silicon Graphics makes no representation about the suitability
|
||||||
|
#of this software for any purpose. It is provided "as is"
|
||||||
|
#without any express or implied warranty.
|
||||||
|
#
|
||||||
|
#SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
||||||
|
#SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
#AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
||||||
|
#GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
|
||||||
|
#DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING `from` LOSS OF USE,
|
||||||
|
#DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||||
|
#OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
|
||||||
|
#THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
#
|
||||||
|
#********************************************************/
|
||||||
|
# $XFree86: xc/lib/X11/XKBlib.h,v 3.3 2001/08/01 00:44:38 tsi Exp $
|
||||||
|
#
|
||||||
|
# Pascal Convertion was made by Ido Kannner - kanerido@actcom.net.il
|
||||||
|
#
|
||||||
|
#Thanks:
|
||||||
|
# I want to thanks to oliebol for putting up with all of the problems that was found
|
||||||
|
# while translating this code. ;)
|
||||||
|
#
|
||||||
|
# I want to thanks #fpc channel in freenode irc, for helping me, and to put up with my
|
||||||
|
# wierd questions ;)
|
||||||
|
#
|
||||||
|
# Thanks for mmc in #xlib on freenode irc And so for the channel itself for the helping me to
|
||||||
|
# understanding some of the problems I had converting this headers and pointing me to resources
|
||||||
|
# that helped translating this headers.
|
||||||
|
#
|
||||||
|
# Ido
|
||||||
|
#
|
||||||
|
#History:
|
||||||
|
# 2004/10/15 - Fixed a bug of accessing second based records by removing "paced record" and
|
||||||
|
# chnaged it to "reocrd" only.
|
||||||
|
# 2004/10/10 - Added to TXkbGetAtomNameFunc and TXkbInternAtomFunc the cdecl call.
|
||||||
|
# 2004/10/06 - 09 - Convertion `from` the c header of XKBlib.h
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
import
|
||||||
|
X, Xlib, XKB
|
||||||
|
|
||||||
|
|
||||||
|
include "x11pragma.nim"
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
PXkbAnyEvent* = ptr TXkbAnyEvent
|
||||||
|
TXkbAnyEvent*{.final.} = object
|
||||||
|
theType*: int16 # XkbAnyEvent
|
||||||
|
serial*: int32 # # of last req processed by server
|
||||||
|
send_event*: bool # is this `from` a SendEvent request?
|
||||||
|
display*: PDisplay # Display the event was read `from`
|
||||||
|
time*: TTime # milliseconds;
|
||||||
|
xkb_type*: int16 # XKB event minor code
|
||||||
|
device*: int16 # device ID
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
PXkbNewKeyboardNotifyEvent* = ptr TXkbNewKeyboardNotifyEvent
|
||||||
|
TXkbNewKeyboardNotifyEvent*{.final.} = object
|
||||||
|
theType*: int16 # XkbAnyEvent
|
||||||
|
serial*: int32 # of last req processed by server
|
||||||
|
send_event*: bool # is this `from` a SendEvent request?
|
||||||
|
display*: PDisplay # Display the event was read `from`
|
||||||
|
time*: TTime # milliseconds
|
||||||
|
xkb_type*: int16 # XkbNewKeyboardNotify
|
||||||
|
device*: int16 # device ID
|
||||||
|
old_device*: int16 # device ID of previous keyboard
|
||||||
|
min_key_code*: int16 # minimum key code
|
||||||
|
max_key_code*: int16 # maximum key code
|
||||||
|
old_min_key_code*: int16 # min key code of previous kbd
|
||||||
|
old_max_key_code*: int16 # max key code of previous kbd
|
||||||
|
changed*: int16 # changed aspects of the keyboard
|
||||||
|
req_major*: int8 # major and minor opcode of req
|
||||||
|
req_minor*: int8 # that caused change, if applicable
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
PXkbMapNotifyEvent* = ptr TXkbMapNotifyEvent
|
||||||
|
TXkbMapNotifyEvent*{.final.} = object
|
||||||
|
theType*: int16 # XkbAnyEvent
|
||||||
|
serial*: int32 # of last req processed by server
|
||||||
|
send_event*: bool # is this `from` a SendEvent request
|
||||||
|
display*: PDisplay # Display the event was read `from`
|
||||||
|
time*: TTime # milliseconds
|
||||||
|
xkb_type*: int16 # XkbMapNotify
|
||||||
|
device*: int16 # device ID
|
||||||
|
changed*: int16 # fields which have been changed
|
||||||
|
flags*: int16 # reserved
|
||||||
|
first_type*: int16 # first changed key type
|
||||||
|
num_types*: int16 # number of changed key types
|
||||||
|
min_key_code*: TKeyCode
|
||||||
|
max_key_code*: TKeyCode
|
||||||
|
first_key_sym*: TKeyCode
|
||||||
|
first_key_act*: TKeyCode
|
||||||
|
first_key_behavior*: TKeyCode
|
||||||
|
first_key_explicit*: TKeyCode
|
||||||
|
first_modmap_key*: TKeyCode
|
||||||
|
first_vmodmap_key*: TKeyCode
|
||||||
|
num_key_syms*: int16
|
||||||
|
num_key_acts*: int16
|
||||||
|
num_key_behaviors*: int16
|
||||||
|
num_key_explicit*: int16
|
||||||
|
num_modmap_keys*: int16
|
||||||
|
num_vmodmap_keys*: int16
|
||||||
|
vmods*: int16 # mask of changed virtual mods
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
PXkbStateNotifyEvent* = ptr TXkbStateNotifyEvent
|
||||||
|
TXkbStateNotifyEvent*{.final.} = object
|
||||||
|
theType*: int16 # XkbAnyEvent
|
||||||
|
serial*: int32 # # of last req processed by server
|
||||||
|
send_event*: bool # is this `from` a SendEvent request?
|
||||||
|
display*: PDisplay # Display the event was read `from`
|
||||||
|
time*: TTime # milliseconds
|
||||||
|
xkb_type*: int16 # XkbStateNotify
|
||||||
|
device*: int16 # device ID
|
||||||
|
changed*: int16 # mask of changed state components
|
||||||
|
group*: int16 # keyboard group
|
||||||
|
base_group*: int16 # base keyboard group
|
||||||
|
latched_group*: int16 # latched keyboard group
|
||||||
|
locked_group*: int16 # locked keyboard group
|
||||||
|
mods*: int16 # modifier state
|
||||||
|
base_mods*: int16 # base modifier state
|
||||||
|
latched_mods*: int16 # latched modifiers
|
||||||
|
locked_mods*: int16 # locked modifiers
|
||||||
|
compat_state*: int16 # compatibility state
|
||||||
|
grab_mods*: int8 # mods used for grabs
|
||||||
|
compat_grab_mods*: int8 # grab mods for non-XKB clients
|
||||||
|
lookup_mods*: int8 # mods sent to clients
|
||||||
|
compat_lookup_mods*: int8 # mods sent to non-XKB clients
|
||||||
|
ptr_buttons*: int16 # pointer button state
|
||||||
|
keycode*: TKeyCode # keycode that caused the change
|
||||||
|
event_type*: int8 # KeyPress or KeyRelease
|
||||||
|
req_major*: int8 # Major opcode of request
|
||||||
|
req_minor*: int8 # Minor opcode of request
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
PXkbControlsNotifyEvent* = ptr TXkbControlsNotifyEvent
|
||||||
|
TXkbControlsNotifyEvent*{.final.} = object
|
||||||
|
theType*: int16 # XkbAnyEvent
|
||||||
|
serial*: int32 # of last req processed by server
|
||||||
|
send_event*: bool # is this `from` a SendEvent request?
|
||||||
|
display*: PDisplay # Display the event was read `from`
|
||||||
|
time*: TTime # milliseconds
|
||||||
|
xkb_type*: int16 # XkbControlsNotify
|
||||||
|
device*: int16 # device ID
|
||||||
|
changed_ctrls*: int16 # controls with changed sub-values
|
||||||
|
enabled_ctrls*: int16 # controls currently enabled
|
||||||
|
enabled_ctrl_changes*: int16 # controls just {en,dis}abled
|
||||||
|
num_groups*: int16 # total groups on keyboard
|
||||||
|
keycode*: TKeyCode # key that caused change or 0
|
||||||
|
event_type*: int8 # type of event that caused change
|
||||||
|
req_major*: int8 # if keycode==0, major and minor
|
||||||
|
req_minor*: int8 # opcode of req that caused change
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
PXkbIndicatorNotifyEvent* = ptr TXkbIndicatorNotifyEvent
|
||||||
|
TXkbIndicatorNotifyEvent*{.final.} = object
|
||||||
|
theType*: int16 # XkbAnyEvent
|
||||||
|
serial*: int32 # of last req processed by server
|
||||||
|
send_event*: bool # is this `from` a SendEvent request?
|
||||||
|
display*: PDisplay # Display the event was read `from`
|
||||||
|
time*: TTime # milliseconds
|
||||||
|
xkb_type*: int16 # XkbIndicatorNotify
|
||||||
|
device*: int16 # device
|
||||||
|
changed*: int16 # indicators with new state or map
|
||||||
|
state*: int16 # current state of all indicators
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
PXkbNamesNotifyEvent* = ptr TXkbNamesNotifyEvent
|
||||||
|
TXkbNamesNotifyEvent*{.final.} = object
|
||||||
|
theType*: int16 # XkbAnyEvent
|
||||||
|
serial*: int32 # of last req processed by server
|
||||||
|
send_event*: bool # is this `from` a SendEvent request?
|
||||||
|
display*: PDisplay # Display the event was read `from`
|
||||||
|
time*: TTime # milliseconds
|
||||||
|
xkb_type*: int16 # XkbNamesNotify
|
||||||
|
device*: int16 # device ID
|
||||||
|
changed*: int32 # names that have changed
|
||||||
|
first_type*: int16 # first key type with new name
|
||||||
|
num_types*: int16 # number of key types with new names
|
||||||
|
first_lvl*: int16 # first key type new new level names
|
||||||
|
num_lvls*: int16 # # of key types w/new level names
|
||||||
|
num_aliases*: int16 # total number of key aliases
|
||||||
|
num_radio_groups*: int16 # total number of radio groups
|
||||||
|
changed_vmods*: int16 # virtual modifiers with new names
|
||||||
|
changed_groups*: int16 # groups with new names
|
||||||
|
changed_indicators*: int16 # indicators with new names
|
||||||
|
first_key*: int16 # first key with new name
|
||||||
|
num_keys*: int16 # number of keys with new names
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
PXkbCompatMapNotifyEvent* = ptr TXkbCompatMapNotifyEvent
|
||||||
|
TXkbCompatMapNotifyEvent*{.final.} = object
|
||||||
|
theType*: int16 # XkbAnyEvent
|
||||||
|
serial*: int32 # of last req processed by server
|
||||||
|
send_event*: bool # is this `from` a SendEvent request?
|
||||||
|
display*: PDisplay # Display the event was read `from`
|
||||||
|
time*: TTime # milliseconds
|
||||||
|
xkb_type*: int16 # XkbCompatMapNotify
|
||||||
|
device*: int16 # device ID
|
||||||
|
changed_groups*: int16 # groups with new compat maps
|
||||||
|
first_si*: int16 # first new symbol interp
|
||||||
|
num_si*: int16 # number of new symbol interps
|
||||||
|
num_total_si*: int16 # total # of symbol interps
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
PXkbBellNotifyEvent* = ptr TXkbBellNotifyEvent
|
||||||
|
TXkbBellNotifyEvent*{.final.} = object
|
||||||
|
theType*: int16 # XkbAnyEvent
|
||||||
|
serial*: int32 # of last req processed by server
|
||||||
|
send_event*: bool # is this `from` a SendEvent request?
|
||||||
|
display*: PDisplay # Display the event was read `from`
|
||||||
|
time*: TTime # milliseconds
|
||||||
|
xkb_type*: int16 # XkbBellNotify
|
||||||
|
device*: int16 # device ID
|
||||||
|
percent*: int16 # requested volume as a % of maximum
|
||||||
|
pitch*: int16 # requested pitch in Hz
|
||||||
|
duration*: int16 # requested duration in useconds
|
||||||
|
bell_class*: int16 # (input extension) feedback class
|
||||||
|
bell_id*: int16 # (input extension) ID of feedback
|
||||||
|
name*: TAtom # "name" of requested bell
|
||||||
|
window*: TWindow # window associated with event
|
||||||
|
event_only*: bool # "event only" requested
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
PXkbActionMessageEvent* = ptr TXkbActionMessageEvent
|
||||||
|
TXkbActionMessageEvent*{.final.} = object
|
||||||
|
theType*: int16 # XkbAnyEvent
|
||||||
|
serial*: int32 # of last req processed by server
|
||||||
|
send_event*: bool # is this `from` a SendEvent request?
|
||||||
|
display*: PDisplay # Display the event was read `from`
|
||||||
|
time*: TTime # milliseconds
|
||||||
|
xkb_type*: int16 # XkbActionMessage
|
||||||
|
device*: int16 # device ID
|
||||||
|
keycode*: TKeyCode # key that generated the event
|
||||||
|
press*: bool # true if act caused by key press
|
||||||
|
key_event_follows*: bool # true if key event also generated
|
||||||
|
group*: int16 # effective group
|
||||||
|
mods*: int16 # effective mods
|
||||||
|
message*: array[0..XkbActionMessageLength, char] # message -- leave space for NUL
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
PXkbAccessXNotifyEvent* = ptr TXkbAccessXNotifyEvent
|
||||||
|
TXkbAccessXNotifyEvent*{.final.} = object
|
||||||
|
theType*: int16 # XkbAnyEvent
|
||||||
|
serial*: int32 # of last req processed by server
|
||||||
|
send_event*: bool # is this `from` a SendEvent request?
|
||||||
|
display*: PDisplay # Display the event was read `from`
|
||||||
|
time*: TTime # milliseconds
|
||||||
|
xkb_type*: int16 # XkbAccessXNotify
|
||||||
|
device*: int16 # device ID
|
||||||
|
detail*: int16 # XkbAXN_*
|
||||||
|
keycode*: int16 # key of event
|
||||||
|
sk_delay*: int16 # current slow keys delay
|
||||||
|
debounce_delay*: int16 # current debounce delay
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
PXkbExtensionDeviceNotifyEvent* = ptr TXkbExtensionDeviceNotifyEvent
|
||||||
|
TXkbExtensionDeviceNotifyEvent*{.final.} = object
|
||||||
|
theType*: int16 # XkbAnyEvent
|
||||||
|
serial*: int32 # of last req processed by server
|
||||||
|
send_event*: bool # is this `from` a SendEvent request?
|
||||||
|
display*: PDisplay # Display the event was read `from`
|
||||||
|
time*: TTime # milliseconds
|
||||||
|
xkb_type*: int16 # XkbExtensionDeviceNotify
|
||||||
|
device*: int16 # device ID
|
||||||
|
reason*: int16 # reason for the event
|
||||||
|
supported*: int16 # mask of supported features
|
||||||
|
unsupported*: int16 # mask of unsupported features
|
||||||
|
# that some app tried to use
|
||||||
|
first_btn*: int16 # first button that changed
|
||||||
|
num_btns*: int16 # range of buttons changed
|
||||||
|
leds_defined*: int16 # indicators with names or maps
|
||||||
|
led_state*: int16 # current state of the indicators
|
||||||
|
led_class*: int16 # feedback class for led changes
|
||||||
|
led_id*: int16 # feedback id for led changes
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
PXkbEvent* = ptr TXkbEvent
|
||||||
|
TXkbEvent*{.final.} = object
|
||||||
|
theType*: int16
|
||||||
|
any*: TXkbAnyEvent
|
||||||
|
new_kbd*: TXkbNewKeyboardNotifyEvent
|
||||||
|
map*: TXkbMapNotifyEvent
|
||||||
|
state*: TXkbStateNotifyEvent
|
||||||
|
ctrls*: TXkbControlsNotifyEvent
|
||||||
|
indicators*: TXkbIndicatorNotifyEvent
|
||||||
|
names*: TXkbNamesNotifyEvent
|
||||||
|
compat*: TXkbCompatMapNotifyEvent
|
||||||
|
bell*: TXkbBellNotifyEvent
|
||||||
|
message*: TXkbActionMessageEvent
|
||||||
|
accessx*: TXkbAccessXNotifyEvent
|
||||||
|
device*: TXkbExtensionDeviceNotifyEvent
|
||||||
|
core*: TXEvent
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
PXkbKbdDpyStatePtr* = ptr TXkbKbdDpyStateRec
|
||||||
|
TXkbKbdDpyStateRec*{.final.} = object # XkbOpenDisplay error codes
|
||||||
|
|
||||||
|
const
|
||||||
|
XkbOD_Success* = 0
|
||||||
|
XkbOD_BadLibraryVersion* = 1
|
||||||
|
XkbOD_ConnectionRefused* = 2
|
||||||
|
XkbOD_NonXkbServer* = 3
|
||||||
|
XkbOD_BadServerVersion* = 4 # Values for XlibFlags
|
||||||
|
|
||||||
|
const
|
||||||
|
XkbLC_ForceLatin1Lookup* = 1 shl 0
|
||||||
|
XkbLC_ConsumeLookupMods* = 1 shl 1
|
||||||
|
XkbLC_AlwaysConsumeShiftAndLock* = 1 shl 2
|
||||||
|
XkbLC_IgnoreNewKeyboards* = 1 shl 3
|
||||||
|
XkbLC_ControlFallback* = 1 shl 4
|
||||||
|
XkbLC_ConsumeKeysOnComposeFail* = 1 shl 29
|
||||||
|
XkbLC_ComposeLED* = 1 shl 30
|
||||||
|
XkbLC_BeepOnComposeFail* = 1 shl 31
|
||||||
|
XkbLC_AllComposeControls* = 0xC0000000
|
||||||
|
XkbLC_AllControls* = 0xC000001F
|
||||||
|
|
||||||
|
proc XkbIgnoreExtension*(ignore: bool): bool{.libx11c,
|
||||||
|
importc: "XkbIgnoreExtension".}
|
||||||
|
proc XkbOpenDisplay*(name: cstring, ev_rtrn, err_rtrn, major_rtrn, minor_rtrn,
|
||||||
|
reason: ptr int16): PDisplay{.libx11c, importc: "XkbOpenDisplay".}
|
||||||
|
proc XkbQueryExtension*(dpy: PDisplay, opcodeReturn, eventBaseReturn,
|
||||||
|
errorBaseReturn, majorRtrn, minorRtrn: ptr int16): bool{.
|
||||||
|
libx11c, importc: "XkbQueryExtension".}
|
||||||
|
proc XkbUseExtension*(dpy: PDisplay, major_rtrn, minor_rtrn: ptr int16): bool{.
|
||||||
|
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{.
|
||||||
|
cdecl.}
|
||||||
|
|
||||||
|
type
|
||||||
|
TXkbGetAtomNameFunc* = proc (dpy: PDisplay, atom: TAtom): cstring{.cdecl.}
|
||||||
|
|
||||||
|
proc XkbSetAtomFuncs*(getAtom: TXkbInternAtomFunc, getName: TXkbGetAtomNameFunc){.
|
||||||
|
libx11c, importc: "XkbSetAtomFuncs".}
|
||||||
|
proc XkbKeycodeToKeysym*(dpy: PDisplay, kc: TKeyCode, group, level: int16): TKeySym{.
|
||||||
|
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{.
|
||||||
|
libx11c, importc: "XkbLookupKeySym".}
|
||||||
|
proc XkbLookupKeyBinding*(dpy: PDisplay, sym_rtrn: TKeySym, mods: int16,
|
||||||
|
buffer: cstring, nbytes: int16, extra_rtrn: ptr int16): int16{.
|
||||||
|
libx11c, importc: "XkbLookupKeyBinding".}
|
||||||
|
proc XkbTranslateKeyCode*(xkb: PXkbDescPtr, keycode: TKeyCode,
|
||||||
|
modifiers, modifiers_return: int16,
|
||||||
|
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{.
|
||||||
|
libx11c, importc: "XkbTranslateKeySym".}
|
||||||
|
proc XkbSetAutoRepeatRate*(dpy: PDisplay, deviceSpec, delay, interval: int16): bool{.
|
||||||
|
libx11c, importc: "XkbSetAutoRepeatRate".}
|
||||||
|
proc XkbGetAutoRepeatRate*(dpy: PDisplay, deviceSpec: int16,
|
||||||
|
delayRtrn, intervalRtrn: PWord): bool{.libx11c, importc: "XkbGetAutoRepeatRate".}
|
||||||
|
proc XkbChangeEnabledControls*(dpy: PDisplay, deviceSpec, affect, values: int16): bool{.
|
||||||
|
libx11c, importc: "XkbChangeEnabledControls".}
|
||||||
|
proc XkbDeviceBell*(dpy: PDisplay, win: TWindow,
|
||||||
|
deviceSpec, bellClass, bellID, percent: int16, name: TAtom): bool{.
|
||||||
|
libx11c, importc: "XkbDeviceBell".}
|
||||||
|
proc XkbForceDeviceBell*(dpy: PDisplay,
|
||||||
|
deviceSpec, bellClass, bellID, percent: int16): bool{.
|
||||||
|
libx11c, importc: "XkbForceDeviceBell".}
|
||||||
|
proc XkbDeviceBellEvent*(dpy: PDisplay, win: TWindow,
|
||||||
|
deviceSpec, bellClass, bellID, percent: int16,
|
||||||
|
name: TAtom): bool{.libx11c,
|
||||||
|
importc: "XkbDeviceBellEvent".}
|
||||||
|
proc XkbBell*(dpy: PDisplay, win: TWindow, percent: int16, name: TAtom): bool{.
|
||||||
|
libx11c, importc: "XkbBell".}
|
||||||
|
proc XkbForceBell*(dpy: PDisplay, percent: int16): bool{.libx11c,
|
||||||
|
importc: "XkbForceBell".}
|
||||||
|
proc XkbBellEvent*(dpy: PDisplay, win: TWindow, percent: int16, name: TAtom): bool{.
|
||||||
|
libx11c, importc: "XkbBellEvent".}
|
||||||
|
proc XkbSelectEvents*(dpy: PDisplay, deviceID, affect, values: int16): bool{.
|
||||||
|
libx11c, importc: "XkbSelectEvents".}
|
||||||
|
proc XkbSelectEventDetails*(dpy: PDisplay, deviceID, eventType: int16,
|
||||||
|
affect, details: int32): bool{.libx11c, importc: "XkbSelectEventDetails".}
|
||||||
|
proc XkbNoteMapChanges*(old: PXkbMapChangesPtr, new: PXkbMapNotifyEvent,
|
||||||
|
wanted: int16){.libx11c,
|
||||||
|
importc: "XkbNoteMapChanges".}
|
||||||
|
proc XkbNoteNameChanges*(old: PXkbNameChangesPtr, new: PXkbNamesNotifyEvent,
|
||||||
|
wanted: int16){.libx11c,
|
||||||
|
importc: "XkbNoteNameChanges".}
|
||||||
|
proc XkbGetIndicatorState*(dpy: PDisplay, deviceSpec: int16, pStateRtrn: PWord): TStatus{.
|
||||||
|
libx11c, importc: "XkbGetIndicatorState".}
|
||||||
|
proc XkbGetDeviceIndicatorState*(dpy: PDisplay,
|
||||||
|
deviceSpec, ledClass, ledID: int16,
|
||||||
|
pStateRtrn: PWord): TStatus{.libx11c, importc: "XkbGetDeviceIndicatorState".}
|
||||||
|
proc XkbGetIndicatorMap*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): TStatus{.
|
||||||
|
libx11c, importc: "XkbGetIndicatorMap".}
|
||||||
|
proc XkbSetIndicatorMap*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): bool{.
|
||||||
|
libx11c, importc: "XkbSetIndicatorMap".}
|
||||||
|
proc XkbNoteIndicatorMapChanges*(o, n: PXkbIndicatorChangesPtr, w: int16)
|
||||||
|
proc XkbNoteIndicatorStateChanges*(o, n: PXkbIndicatorChangesPtr, w: int16)
|
||||||
|
proc XkbGetIndicatorMapChanges*(d: PDisplay, x: PXkbDescPtr,
|
||||||
|
c: PXkbIndicatorChangesPtr): TStatus
|
||||||
|
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{.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{.libx11c, importc: "XkbGetNamedDeviceIndicator".}
|
||||||
|
proc XkbSetNamedIndicator*(dpy: PDisplay, name: TAtom,
|
||||||
|
changeState, state, createNewMap: bool,
|
||||||
|
pMap: PXkbIndicatorMapPtr): bool{.libx11c, importc: "XkbSetNamedIndicator".}
|
||||||
|
proc XkbSetNamedDeviceIndicator*(dpy: PDisplay,
|
||||||
|
deviceSpec, ledClass, ledID: int16,
|
||||||
|
name: TAtom,
|
||||||
|
changeState, state, createNewMap: bool,
|
||||||
|
pMap: PXkbIndicatorMapPtr): bool{.libx11c, importc: "XkbSetNamedDeviceIndicator".}
|
||||||
|
proc XkbLockModifiers*(dpy: PDisplay, deviceSpec, affect, values: int16): bool{.
|
||||||
|
libx11c, importc: "XkbLockModifiers".}
|
||||||
|
proc XkbLatchModifiers*(dpy: PDisplay, deviceSpec, affect, values: int16): bool{.
|
||||||
|
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{.libx11c, importc: "XkbSetServerInternalMods".}
|
||||||
|
proc XkbSetIgnoreLockMods*(dpy: PDisplay, deviceSpec, affectReal, realValues,
|
||||||
|
affectVirtual, virtualValues: int16): bool{.libx11c,
|
||||||
|
importc: "XkbSetIgnoreLockMods".}
|
||||||
|
proc XkbVirtualModsToReal*(dpy: PDisplay, virtual_mask: int16, mask_rtrn: PWord): bool{.
|
||||||
|
libx11c, importc: "XkbVirtualModsToReal".}
|
||||||
|
proc XkbComputeEffectiveMap*(xkb: PXkbDescPtr, theType: PXkbKeyTypePtr,
|
||||||
|
map_rtrn: PByte): bool{.libx11c,
|
||||||
|
importc: "XkbComputeEffectiveMap".}
|
||||||
|
proc XkbInitCanonicalKeyTypes*(xkb: PXkbDescPtr, which: int16, keypadVMod: int16): TStatus{.
|
||||||
|
libx11c, importc: "XkbInitCanonicalKeyTypes".}
|
||||||
|
proc XkbAllocKeyboard*(): PXkbDescPtr{.libx11c,
|
||||||
|
importc: "XkbAllocKeyboard".}
|
||||||
|
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{.
|
||||||
|
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{.
|
||||||
|
libx11c, importc: "XkbAddKeyType".}
|
||||||
|
proc XkbAllocIndicatorMaps*(xkb: PXkbDescPtr): TStatus{.libx11c,
|
||||||
|
importc: "XkbAllocIndicatorMaps".}
|
||||||
|
proc XkbFreeIndicatorMaps*(xkb: PXkbDescPtr){.libx11c,
|
||||||
|
importc: "XkbFreeIndicatorMaps".}
|
||||||
|
proc XkbGetMap*(dpy: PDisplay, which, deviceSpec: int16): PXkbDescPtr{.libx11c, importc: "XkbGetMap".}
|
||||||
|
proc XkbGetUpdatedMap*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): TStatus{.
|
||||||
|
libx11c, importc: "XkbGetUpdatedMap".}
|
||||||
|
proc XkbGetMapChanges*(dpy: PDisplay, xkb: PXkbDescPtr,
|
||||||
|
changes: PXkbMapChangesPtr): TStatus{.libx11c, importc: "XkbGetMapChanges".}
|
||||||
|
proc XkbRefreshKeyboardMapping*(event: PXkbMapNotifyEvent): TStatus{.libx11c, importc: "XkbRefreshKeyboardMapping".}
|
||||||
|
proc XkbGetKeyTypes*(dpy: PDisplay, first, num: int16, xkb: PXkbDescPtr): TStatus{.
|
||||||
|
libx11c, importc: "XkbGetKeyTypes".}
|
||||||
|
proc XkbGetKeySyms*(dpy: PDisplay, first, num: int16, xkb: PXkbDescPtr): TStatus{.
|
||||||
|
libx11c, importc: "XkbGetKeySyms".}
|
||||||
|
proc XkbGetKeyActions*(dpy: PDisplay, first, num: int16, xkb: PXkbDescPtr): TStatus{.
|
||||||
|
libx11c, importc: "XkbGetKeyActions".}
|
||||||
|
proc XkbGetKeyBehaviors*(dpy: PDisplay, firstKey, nKeys: int16,
|
||||||
|
desc: PXkbDescPtr): TStatus{.libx11c,
|
||||||
|
importc: "XkbGetKeyBehaviors".}
|
||||||
|
proc XkbGetVirtualMods*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): TStatus{.
|
||||||
|
libx11c, importc: "XkbGetVirtualMods".}
|
||||||
|
proc XkbGetKeyExplicitComponents*(dpy: PDisplay, firstKey, nKeys: int16,
|
||||||
|
desc: PXkbDescPtr): TStatus{.libx11c, importc: "XkbGetKeyExplicitComponents".}
|
||||||
|
proc XkbGetKeyModifierMap*(dpy: PDisplay, firstKey, nKeys: int16,
|
||||||
|
desc: PXkbDescPtr): TStatus{.libx11c,
|
||||||
|
importc: "XkbGetKeyModifierMap".}
|
||||||
|
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{.
|
||||||
|
libx11c, importc: "XkbGetControls".}
|
||||||
|
proc XkbSetControls*(dpy: PDisplay, which: int32, desc: PXkbDescPtr): bool{.
|
||||||
|
libx11c, importc: "XkbSetControls".}
|
||||||
|
proc XkbNoteControlsChanges*(old: PXkbControlsChangesPtr,
|
||||||
|
new: PXkbControlsNotifyEvent, wanted: int16){.
|
||||||
|
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{.
|
||||||
|
libx11c, importc: "XkbAllocCompatMap".}
|
||||||
|
proc XkbFreeCompatMap*(xkib: PXkbDescPtr, which: int16, freeMap: bool){.libx11c, importc: "XkbFreeCompatMap".}
|
||||||
|
proc XkbGetCompatMap*(dpy: PDisplay, which: int16, xkb: PXkbDescPtr): TStatus{.
|
||||||
|
libx11c, importc: "XkbGetCompatMap".}
|
||||||
|
proc XkbSetCompatMap*(dpy: PDisplay, which: int16, xkb: PXkbDescPtr,
|
||||||
|
updateActions: bool): bool{.libx11c,
|
||||||
|
importc: "XkbSetCompatMap".}
|
||||||
|
proc XkbAddSymInterpret*(xkb: PXkbDescPtr, si: PXkbSymInterpretPtr,
|
||||||
|
updateMap: bool, changes: PXkbChangesPtr): PXkbSymInterpretPtr{.
|
||||||
|
libx11c, importc: "XkbAddSymInterpret".}
|
||||||
|
proc XkbAllocNames*(xkb: PXkbDescPtr, which: int16,
|
||||||
|
nTotalRG, nTotalAliases: int16): TStatus{.libx11c, importc: "XkbAllocNames".}
|
||||||
|
proc XkbGetNames*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): TStatus{.
|
||||||
|
libx11c, importc: "XkbGetNames".}
|
||||||
|
proc XkbSetNames*(dpy: PDisplay, which, firstType, nTypes: int16,
|
||||||
|
desc: PXkbDescPtr): bool{.libx11c,
|
||||||
|
importc: "XkbSetNames".}
|
||||||
|
proc XkbChangeNames*(dpy: PDisplay, xkb: PXkbDescPtr,
|
||||||
|
changes: PXkbNameChangesPtr): bool{.libx11c,
|
||||||
|
importc: "XkbChangeNames".}
|
||||||
|
proc XkbFreeNames*(xkb: PXkbDescPtr, which: int16, freeMap: bool){.libx11c, importc: "XkbFreeNames".}
|
||||||
|
proc XkbGetState*(dpy: PDisplay, deviceSpec: int16, rtrnState: PXkbStatePtr): TStatus{.
|
||||||
|
libx11c, importc: "XkbGetState".}
|
||||||
|
proc XkbSetMap*(dpy: PDisplay, which: int16, desc: PXkbDescPtr): bool{.libx11c, importc: "XkbSetMap".}
|
||||||
|
proc XkbChangeMap*(dpy: PDisplay, desc: PXkbDescPtr, changes: PXkbMapChangesPtr): bool{.
|
||||||
|
libx11c, importc: "XkbChangeMap".}
|
||||||
|
proc XkbSetDetectableAutoRepeat*(dpy: PDisplay, detectable: bool,
|
||||||
|
supported: ptr bool): bool{.libx11c, importc: "XkbSetDetectableAutoRepeat".}
|
||||||
|
proc XkbGetDetectableAutoRepeat*(dpy: PDisplay, supported: ptr bool): bool{.
|
||||||
|
libx11c, importc: "XkbGetDetectableAutoRepeat".}
|
||||||
|
proc XkbSetAutoResetControls*(dpy: PDisplay, changes: int16,
|
||||||
|
auto_ctrls, auto_values: PWord): bool{.libx11c, importc: "XkbSetAutoResetControls".}
|
||||||
|
proc XkbGetAutoResetControls*(dpy: PDisplay, auto_ctrls, auto_ctrl_values: PWord): bool{.
|
||||||
|
libx11c, importc: "XkbGetAutoResetControls".}
|
||||||
|
proc XkbSetPerClientControls*(dpy: PDisplay, change: int16, values: PWord): bool{.
|
||||||
|
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{.
|
||||||
|
libx11c, importc: "XkbCopyKeyTypes".}
|
||||||
|
proc XkbResizeKeyType*(xkb: PXkbDescPtr, type_ndx, map_count: int16,
|
||||||
|
want_preserve: bool, new_num_lvls: int16): TStatus{.
|
||||||
|
libx11c, importc: "XkbResizeKeyType".}
|
||||||
|
proc XkbResizeKeySyms*(desc: PXkbDescPtr, forKey, symsNeeded: int16): PKeySym{.
|
||||||
|
libx11c, importc: "XkbResizeKeySyms".}
|
||||||
|
proc XkbResizeKeyActions*(desc: PXkbDescPtr, forKey, actsNeeded: int16): PXkbAction{.
|
||||||
|
libx11c, importc: "XkbResizeKeyActions".}
|
||||||
|
proc XkbChangeTypesOfKey*(xkb: PXkbDescPtr, key, num_groups: int16,
|
||||||
|
groups: int16, newTypes: ptr int16,
|
||||||
|
pChanges: PXkbMapChangesPtr): TStatus{.libx11c, importc: "XkbChangeTypesOfKey".}
|
||||||
|
|
||||||
|
proc XkbListComponents*(dpy: PDisplay, deviceSpec: int16,
|
||||||
|
ptrns: PXkbComponentNamesPtr, max_inout: ptr int16): PXkbComponentListPtr{.
|
||||||
|
libx11c, importc: "XkbListComponents".}
|
||||||
|
proc XkbFreeComponentList*(list: PXkbComponentListPtr){.libx11c,
|
||||||
|
importc: "XkbFreeComponentList".}
|
||||||
|
proc XkbGetKeyboard*(dpy: PDisplay, which, deviceSpec: int16): PXkbDescPtr{.
|
||||||
|
libx11c, importc: "XkbGetKeyboard".}
|
||||||
|
proc XkbGetKeyboardByName*(dpy: PDisplay, deviceSpec: int16,
|
||||||
|
names: PXkbComponentNamesPtr, want, need: int16,
|
||||||
|
load: bool): PXkbDescPtr{.libx11c,
|
||||||
|
importc: "XkbGetKeyboardByName".}
|
||||||
|
|
||||||
|
proc XkbKeyTypesForCoreSymbols*(xkb: PXkbDescPtr,
|
||||||
|
map_width: int16, # keyboard device
|
||||||
|
core_syms: PKeySym, # always mapWidth symbols
|
||||||
|
protected: int16, # explicit key types
|
||||||
|
types_inout: ptr int16, # always four type indices
|
||||||
|
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{.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{.libx11c, importc: "XkbUpdateMapFromCore".}
|
||||||
|
|
||||||
|
proc XkbAddDeviceLedInfo*(devi: PXkbDeviceInfoPtr, ledClass, ledId: int16): PXkbDeviceLedInfoPtr{.
|
||||||
|
libx11c, importc: "XkbAddDeviceLedInfo".}
|
||||||
|
proc XkbResizeDeviceButtonActions*(devi: PXkbDeviceInfoPtr, newTotal: int16): TStatus{.
|
||||||
|
libx11c, importc: "XkbResizeDeviceButtonActions".}
|
||||||
|
proc XkbAllocDeviceInfo*(deviceSpec, nButtons, szLeds: int16): PXkbDeviceInfoPtr{.
|
||||||
|
libx11c, importc: "XkbAllocDeviceInfo".}
|
||||||
|
proc XkbFreeDeviceInfo*(devi: PXkbDeviceInfoPtr, which: int16, freeDevI: bool){.
|
||||||
|
libx11c, importc: "XkbFreeDeviceInfo".}
|
||||||
|
proc XkbNoteDeviceChanges*(old: PXkbDeviceChangesPtr,
|
||||||
|
new: PXkbExtensionDeviceNotifyEvent, wanted: int16){.
|
||||||
|
libx11c, importc: "XkbNoteDeviceChanges".}
|
||||||
|
proc XkbGetDeviceInfo*(dpy: PDisplay, which, deviceSpec, ledClass, ledID: int16): PXkbDeviceInfoPtr{.
|
||||||
|
libx11c, importc: "XkbGetDeviceInfo".}
|
||||||
|
proc XkbGetDeviceInfoChanges*(dpy: PDisplay, devi: PXkbDeviceInfoPtr,
|
||||||
|
changes: PXkbDeviceChangesPtr): TStatus{.libx11c, importc: "XkbGetDeviceInfoChanges".}
|
||||||
|
proc XkbGetDeviceButtonActions*(dpy: PDisplay, devi: PXkbDeviceInfoPtr,
|
||||||
|
all: bool, first, nBtns: int16): TStatus{.libx11c, importc: "XkbGetDeviceButtonActions".}
|
||||||
|
proc XkbGetDeviceLedInfo*(dpy: PDisplay, devi: PXkbDeviceInfoPtr,
|
||||||
|
ledClass, ledId, which: int16): TStatus{.libx11c, importc: "XkbGetDeviceLedInfo".}
|
||||||
|
proc XkbSetDeviceInfo*(dpy: PDisplay, which: int16, devi: PXkbDeviceInfoPtr): bool{.
|
||||||
|
libx11c, importc: "XkbSetDeviceInfo".}
|
||||||
|
proc XkbChangeDeviceInfo*(dpy: PDisplay, desc: PXkbDeviceInfoPtr,
|
||||||
|
changes: PXkbDeviceChangesPtr): bool{.libx11c, importc: "XkbChangeDeviceInfo".}
|
||||||
|
proc XkbSetDeviceLedInfo*(dpy: PDisplay, devi: PXkbDeviceInfoPtr,
|
||||||
|
ledClass, ledID, which: int16): bool{.libx11c, importc: "XkbSetDeviceLedInfo".}
|
||||||
|
proc XkbSetDeviceButtonActions*(dpy: PDisplay, devi: PXkbDeviceInfoPtr,
|
||||||
|
first, nBtns: int16): bool{.libx11c, importc: "XkbSetDeviceButtonActions".}
|
||||||
|
|
||||||
|
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{.
|
||||||
|
libx11c, importc: "XkbSetDebuggingFlags".}
|
||||||
|
proc XkbApplyVirtualModChanges*(xkb: PXkbDescPtr, changed: int16,
|
||||||
|
changes: PXkbChangesPtr): bool{.libx11c, importc: "XkbApplyVirtualModChanges".}
|
||||||
|
|
||||||
|
# implementation
|
||||||
|
|
||||||
|
proc XkbNoteIndicatorMapChanges(o, n: PXkbIndicatorChangesPtr, w: int16) =
|
||||||
|
##define XkbNoteIndicatorMapChanges(o,n,w) ((o)->map_changes|=((n)->map_changes&(w)))
|
||||||
|
o.map_changes = o.map_changes or (n.map_changes and w)
|
||||||
|
|
||||||
|
proc XkbNoteIndicatorStateChanges(o, n: PXkbIndicatorChangesPtr, w: int16) =
|
||||||
|
##define XkbNoteIndicatorStateChanges(o,n,w) ((o)->state_changes|=((n)->state_changes&(w)))
|
||||||
|
o.state_changes = o.state_changes or (n.state_changes and (w))
|
||||||
|
|
||||||
|
proc XkbGetIndicatorMapChanges(d: PDisplay, x: PXkbDescPtr,
|
||||||
|
c: PXkbIndicatorChangesPtr): TStatus =
|
||||||
|
##define XkbGetIndicatorMapChanges(d,x,c) (XkbGetIndicatorMap((d),(c)->map_changes,x)
|
||||||
|
result = XkbGetIndicatorMap(d, c.map_changes, x)
|
||||||
|
|
||||||
|
proc XkbChangeIndicatorMaps(d: PDisplay, x: PXkbDescPtr,
|
||||||
|
c: PXkbIndicatorChangesPtr): bool =
|
||||||
|
##define XkbChangeIndicatorMaps(d,x,c) (XkbSetIndicatorMap((d),(c)->map_changes,x))
|
||||||
|
result = XkbSetIndicatorMap(d, c.map_changes, x)
|
||||||
|
|
||||||
|
proc XkbGetControlsChanges(d: PDisplay, x: PXkbDescPtr,
|
||||||
|
c: PXkbControlsChangesPtr): TStatus =
|
||||||
|
##define XkbGetControlsChanges(d,x,c) XkbGetControls(d,(c)->changed_ctrls,x)
|
||||||
|
result = XkbGetControls(d, c.changed_ctrls, x)
|
||||||
|
|
||||||
|
proc XkbChangeControls(d: PDisplay, x: PXkbDescPtr, c: PXkbControlsChangesPtr): bool =
|
||||||
|
##define XkbChangeControls(d,x,c) XkbSetControls(d,(c)->changed_ctrls,x)
|
||||||
|
result = XkbSetControls(d, c.changed_ctrls, x)
|
||||||
2026
tests/deps/x11-1.0/xlib.nim
Normal file
2026
tests/deps/x11-1.0/xlib.nim
Normal file
File diff suppressed because it is too large
Load diff
194
tests/deps/x11-1.0/xrandr.nim
Normal file
194
tests/deps/x11-1.0/xrandr.nim
Normal file
|
|
@ -0,0 +1,194 @@
|
||||||
|
#
|
||||||
|
# $XFree86: xc/lib/Xrandr/Xrandr.h,v 1.9 2002/09/29 23:39:44 keithp Exp $
|
||||||
|
#
|
||||||
|
# Copyright (C) 2000 Compaq Computer Corporation, Inc.
|
||||||
|
# Copyright (C) 2002 Hewlett-Packard Company, Inc.
|
||||||
|
#
|
||||||
|
# Permission to use, copy, modify, distribute, and sell this software and its
|
||||||
|
# documentation for any purpose is hereby granted without fee, provided that
|
||||||
|
# the above copyright notice appear in all copies and that both that
|
||||||
|
# copyright notice and this permission notice appear in supporting
|
||||||
|
# documentation, and that the name of Compaq not be used in advertising or
|
||||||
|
# publicity pertaining to distribution of the software without specific,
|
||||||
|
# written prior permission. HP makes no representations about the
|
||||||
|
# suitability of this software for any purpose. It is provided "as is"
|
||||||
|
# without express or implied warranty.
|
||||||
|
#
|
||||||
|
# HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL COMPAQ
|
||||||
|
# BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||||
|
# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||||
|
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
#
|
||||||
|
# Author: Jim Gettys, HP Labs, HP.
|
||||||
|
#
|
||||||
|
|
||||||
|
import
|
||||||
|
x, xlib
|
||||||
|
|
||||||
|
const
|
||||||
|
libXrandr* = "libXrandr.so"
|
||||||
|
|
||||||
|
# * $XFree86: xc/include/extensions/randr.h,v 1.4 2001/11/24 07:24:58 keithp Exp $
|
||||||
|
# *
|
||||||
|
# * Copyright (C) 2000, Compaq Computer Corporation,
|
||||||
|
# * Copyright (C) 2002, Hewlett Packard, Inc.
|
||||||
|
# *
|
||||||
|
# * Permission to use, copy, modify, distribute, and sell this software and its
|
||||||
|
# * documentation for any purpose is hereby granted without fee, provided that
|
||||||
|
# * the above copyright notice appear in all copies and that both that
|
||||||
|
# * copyright notice and this permission notice appear in supporting
|
||||||
|
# * documentation, and that the name of Compaq or HP not be used in advertising
|
||||||
|
# * or publicity pertaining to distribution of the software without specific,
|
||||||
|
# * written prior permission. HP makes no representations about the
|
||||||
|
# * suitability of this software for any purpose. It is provided "as is"
|
||||||
|
# * without express or implied warranty.
|
||||||
|
# *
|
||||||
|
# * HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
|
||||||
|
# * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL HP
|
||||||
|
# * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
# * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||||
|
# * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||||
|
# * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
# *
|
||||||
|
# * Author: Jim Gettys, HP Labs, Hewlett-Packard, Inc.
|
||||||
|
# *
|
||||||
|
|
||||||
|
type
|
||||||
|
PRotation* = ptr TRotation
|
||||||
|
TRotation* = cushort
|
||||||
|
PSizeID* = ptr TSizeID
|
||||||
|
TSizeID* = cushort
|
||||||
|
PSubpixelOrder* = ptr TSubpixelOrder
|
||||||
|
TSubpixelOrder* = cushort
|
||||||
|
|
||||||
|
const
|
||||||
|
RANDR_NAME* = "RANDR"
|
||||||
|
RANDR_MAJOR* = 1
|
||||||
|
RANDR_MINOR* = 1
|
||||||
|
RRNumberErrors* = 0
|
||||||
|
RRNumberEvents* = 1
|
||||||
|
constX_RRQueryVersion* = 0 # we skip 1 to make old clients fail pretty immediately
|
||||||
|
X_RROldGetScreenInfo* = 1
|
||||||
|
X_RR1_0SetScreenConfig* = 2 # V1.0 apps share the same set screen config request id
|
||||||
|
constX_RRSetScreenConfig* = 2
|
||||||
|
X_RROldScreenChangeSelectInput* = 3 # 3 used to be ScreenChangeSelectInput; deprecated
|
||||||
|
constX_RRSelectInput* = 4
|
||||||
|
constX_RRGetScreenInfo* = 5 # used in XRRSelectInput
|
||||||
|
RRScreenChangeNotifyMask* = 1 shl 0
|
||||||
|
RRScreenChangeNotify* = 0 # used in the rotation field; rotation and reflection in 0.1 proto.
|
||||||
|
RR_Rotate_0* = 1
|
||||||
|
RR_Rotate_90* = 2
|
||||||
|
RR_Rotate_180* = 4
|
||||||
|
RR_Rotate_270* = 8 # new in 1.0 protocol, to allow reflection of screen
|
||||||
|
RR_Reflect_X* = 16
|
||||||
|
RR_Reflect_Y* = 32
|
||||||
|
RRSetConfigSuccess* = 0
|
||||||
|
RRSetConfigInvalidConfigTime* = 1
|
||||||
|
RRSetConfigInvalidTime* = 2
|
||||||
|
RRSetConfigFailed* = 3
|
||||||
|
|
||||||
|
type
|
||||||
|
PXRRScreenSize* = ptr TXRRScreenSize
|
||||||
|
TXRRScreenSize*{.final.} = object #
|
||||||
|
# Events.
|
||||||
|
#
|
||||||
|
width*, height*: cint
|
||||||
|
mwidth*, mheight*: cint
|
||||||
|
|
||||||
|
TXRRScreenChangeNotifyEvent*{.final.} = object # internal representation is private to the library
|
||||||
|
typ*: cint # event base
|
||||||
|
serial*: culong # # of last request processed by server
|
||||||
|
send_event*: TBool # true if this came from a SendEvent request
|
||||||
|
display*: PDisplay # Display the event was read from
|
||||||
|
window*: TWindow # window which selected for this event
|
||||||
|
root*: TWindow # Root window for changed screen
|
||||||
|
timestamp*: TTime # when the screen change occurred
|
||||||
|
config_timestamp*: TTime # when the last configuration change
|
||||||
|
size_index*: TSizeID
|
||||||
|
subpixel_order*: TSubpixelOrder
|
||||||
|
rotation*: TRotation
|
||||||
|
width*: cint
|
||||||
|
height*: cint
|
||||||
|
mwidth*: cint
|
||||||
|
mheight*: cint
|
||||||
|
|
||||||
|
PXRRScreenConfiguration* = ptr TXRRScreenConfiguration
|
||||||
|
TXRRScreenConfiguration*{.final.} = object
|
||||||
|
|
||||||
|
proc XRRQueryExtension*(dpy: PDisplay, event_basep, error_basep: Pcint): TBool{.
|
||||||
|
cdecl, dynlib: libXrandr, importc.}
|
||||||
|
proc XRRQueryVersion*(dpy: PDisplay, major_versionp: Pcint,
|
||||||
|
minor_versionp: Pcint): TStatus{.cdecl, dynlib: libXrandr,
|
||||||
|
importc.}
|
||||||
|
proc XRRGetScreenInfo*(dpy: PDisplay, draw: TDrawable): PXRRScreenConfiguration{.
|
||||||
|
cdecl, dynlib: libXrandr, importc.}
|
||||||
|
proc XRRFreeScreenConfigInfo*(config: PXRRScreenConfiguration){.cdecl,
|
||||||
|
dynlib: libXrandr, importc.}
|
||||||
|
#
|
||||||
|
# Note that screen configuration changes are only permitted if the client can
|
||||||
|
# prove it has up to date configuration information. We are trying to
|
||||||
|
# insist that it become possible for screens to change dynamically, so
|
||||||
|
# we want to ensure the client knows what it is talking about when requesting
|
||||||
|
# changes.
|
||||||
|
#
|
||||||
|
proc XRRSetScreenConfig*(dpy: PDisplay, config: PXRRScreenConfiguration,
|
||||||
|
draw: TDrawable, size_index: cint, rotation: TRotation,
|
||||||
|
timestamp: TTime): TStatus{.cdecl, dynlib: libXrandr,
|
||||||
|
importc.}
|
||||||
|
# added in v1.1, sorry for the lame name
|
||||||
|
proc XRRSetScreenConfigAndRate*(dpy: PDisplay, config: PXRRScreenConfiguration,
|
||||||
|
draw: TDrawable, size_index: cint,
|
||||||
|
rotation: TRotation, rate: cshort,
|
||||||
|
timestamp: TTime): TStatus{.cdecl,
|
||||||
|
dynlib: libXrandr, importc.}
|
||||||
|
proc XRRConfigRotations*(config: PXRRScreenConfiguration,
|
||||||
|
current_rotation: PRotation): TRotation{.cdecl,
|
||||||
|
dynlib: libXrandr, importc.}
|
||||||
|
proc XRRConfigTimes*(config: PXRRScreenConfiguration, config_timestamp: PTime): TTime{.
|
||||||
|
cdecl, dynlib: libXrandr, importc.}
|
||||||
|
proc XRRConfigSizes*(config: PXRRScreenConfiguration, nsizes: Pcint): PXRRScreenSize{.
|
||||||
|
cdecl, dynlib: libXrandr, importc.}
|
||||||
|
proc XRRConfigRates*(config: PXRRScreenConfiguration, sizeID: cint,
|
||||||
|
nrates: Pcint): ptr int16{.cdecl, dynlib: libXrandr, importc.}
|
||||||
|
proc XRRConfigCurrentConfiguration*(config: PXRRScreenConfiguration,
|
||||||
|
rotation: PRotation): TSizeID{.cdecl,
|
||||||
|
dynlib: libXrandr, importc.}
|
||||||
|
proc XRRConfigCurrentRate*(config: PXRRScreenConfiguration): cshort{.cdecl,
|
||||||
|
dynlib: libXrandr, importc.}
|
||||||
|
proc XRRRootToScreen*(dpy: PDisplay, root: TWindow): cint{.cdecl,
|
||||||
|
dynlib: libXrandr, importc.}
|
||||||
|
#
|
||||||
|
# returns the screen configuration for the specified screen; does a lazy
|
||||||
|
# evalution to delay getting the information, and caches the result.
|
||||||
|
# These routines should be used in preference to XRRGetScreenInfo
|
||||||
|
# to avoid unneeded round trips to the X server. These are new
|
||||||
|
# in protocol version 0.1.
|
||||||
|
#
|
||||||
|
proc XRRScreenConfig*(dpy: PDisplay, screen: cint): PXRRScreenConfiguration{.
|
||||||
|
cdecl, dynlib: libXrandr, importc.}
|
||||||
|
proc XRRConfig*(screen: PScreen): PXRRScreenConfiguration{.cdecl,
|
||||||
|
dynlib: libXrandr, importc.}
|
||||||
|
proc XRRSelectInput*(dpy: PDisplay, window: TWindow, mask: cint){.cdecl,
|
||||||
|
dynlib: libXrandr, importc.}
|
||||||
|
#
|
||||||
|
# the following are always safe to call, even if RandR is not implemented
|
||||||
|
# on a screen
|
||||||
|
#
|
||||||
|
proc XRRRotations*(dpy: PDisplay, screen: cint, current_rotation: PRotation): TRotation{.
|
||||||
|
cdecl, dynlib: libXrandr, importc.}
|
||||||
|
proc XRRSizes*(dpy: PDisplay, screen: cint, nsizes: Pcint): PXRRScreenSize{.
|
||||||
|
cdecl, dynlib: libXrandr, importc.}
|
||||||
|
proc XRRRates*(dpy: PDisplay, screen: cint, sizeID: cint, nrates: Pcint): ptr int16{.
|
||||||
|
cdecl, dynlib: libXrandr, importc.}
|
||||||
|
proc XRRTimes*(dpy: PDisplay, screen: cint, config_timestamp: PTime): TTime{.
|
||||||
|
cdecl, dynlib: libXrandr, importc.}
|
||||||
|
#
|
||||||
|
# intended to take RRScreenChangeNotify, or
|
||||||
|
# ConfigureNotify (on the root window)
|
||||||
|
# returns 1 if it is an event type it understands, 0 if not
|
||||||
|
#
|
||||||
|
proc XRRUpdateConfiguration*(event: PXEvent): cint{.cdecl, dynlib: libXrandr,
|
||||||
|
importc.}
|
||||||
|
# implementation
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue