Merge remote-tracking branch 'upstream/devel' into devel

This commit is contained in:
Oscar Campbell 2015-06-07 13:16:08 +02:00
commit 858cdd0b05
25 changed files with 278 additions and 141 deletions

0
bootstrap.sh Normal file → Executable file
View file

View file

@ -1346,7 +1346,7 @@ proc propagateToOwner*(owner, elem: PType) =
owner.flags.incl tfHasAsgn owner.flags.incl tfHasAsgn
if owner.kind notin {tyProc, tyGenericInst, tyGenericBody, if owner.kind notin {tyProc, tyGenericInst, tyGenericBody,
tyGenericInvocation}: tyGenericInvocation, tyPtr}:
let elemB = elem.skipTypes({tyGenericInst}) let elemB = elem.skipTypes({tyGenericInst})
if elemB.isGCedMem or tfHasGCedMem in elemB.flags: if elemB.isGCedMem or tfHasGCedMem in elemB.flags:
# for simplicity, we propagate this flag even to generics. We then # for simplicity, we propagate this flag even to generics. We then

View file

@ -2150,7 +2150,7 @@ proc genNamedConstExpr(p: BProc, n: PNode): Rope =
proc genConstSimpleList(p: BProc, n: PNode): Rope = proc genConstSimpleList(p: BProc, n: PNode): Rope =
var length = sonsLen(n) var length = sonsLen(n)
result = rope("{") result = rope("{")
for i in countup(0, length - 2): for i in countup(ord(n.kind == nkObjConstr), length - 2):
addf(result, "$1,$n", [genNamedConstExpr(p, n.sons[i])]) addf(result, "$1,$n", [genNamedConstExpr(p, n.sons[i])])
if length > 0: add(result, genNamedConstExpr(p, n.sons[length - 1])) if length > 0: add(result, genNamedConstExpr(p, n.sons[length - 1]))
addf(result, "}$n", []) addf(result, "}$n", [])

View file

@ -721,6 +721,8 @@ proc genProcPrototype(m: BModule, sym: PSym) =
getTypeDesc(m, sym.loc.t), mangleDynLibProc(sym))) getTypeDesc(m, sym.loc.t), mangleDynLibProc(sym)))
elif not containsOrIncl(m.declaredProtos, sym.id): elif not containsOrIncl(m.declaredProtos, sym.id):
var header = genProcHeader(m, sym) var header = genProcHeader(m, sym)
if sfNoReturn in sym.flags and hasDeclspec in extccomp.CC[cCompiler].props:
header = "__declspec(noreturn) " & header
if sym.typ.callConv != ccInline and crossesCppBoundary(m, sym): if sym.typ.callConv != ccInline and crossesCppBoundary(m, sym):
header = "extern \"C\" " & header header = "extern \"C\" " & header
if sfPure in sym.flags and hasAttribute in CC[cCompiler].props: if sfPure in sym.flags and hasAttribute in CC[cCompiler].props:

View file

@ -34,7 +34,9 @@ type
errNoneSpeedOrSizeExpectedButXFound, errGuiConsoleOrLibExpectedButXFound, errNoneSpeedOrSizeExpectedButXFound, errGuiConsoleOrLibExpectedButXFound,
errUnknownOS, errUnknownCPU, errGenOutExpectedButXFound, errUnknownOS, errUnknownCPU, errGenOutExpectedButXFound,
errArgsNeedRunOption, errInvalidMultipleAsgn, errColonOrEqualsExpected, errArgsNeedRunOption, errInvalidMultipleAsgn, errColonOrEqualsExpected,
errExprExpected, errUndeclaredIdentifier, errUseQualifier, errTypeExpected, errExprExpected, errUndeclaredIdentifier, errUndeclaredField,
errUndeclaredRoutine, errUseQualifier,
errTypeExpected,
errSystemNeeds, errExecutionOfProgramFailed, errNotOverloadable, errSystemNeeds, errExecutionOfProgramFailed, errNotOverloadable,
errInvalidArgForX, errStmtHasNoEffect, errXExpectsTypeOrValue, errInvalidArgForX, errStmtHasNoEffect, errXExpectsTypeOrValue,
errXExpectsArrayType, errIteratorCannotBeInstantiated, errExprXAmbiguous, errXExpectsArrayType, errIteratorCannotBeInstantiated, errExprXAmbiguous,
@ -190,6 +192,8 @@ const
errColonOrEqualsExpected: "\':\' or \'=\' expected, but found \'$1\'", errColonOrEqualsExpected: "\':\' or \'=\' expected, but found \'$1\'",
errExprExpected: "expression expected, but found \'$1\'", errExprExpected: "expression expected, but found \'$1\'",
errUndeclaredIdentifier: "undeclared identifier: \'$1\'", errUndeclaredIdentifier: "undeclared identifier: \'$1\'",
errUndeclaredField: "undeclared field: \'$1\'",
errUndeclaredRoutine: "attempting to call undeclared routine: \'$1\'",
errUseQualifier: "ambiguous identifier: \'$1\' -- use a qualifier", errUseQualifier: "ambiguous identifier: \'$1\' -- use a qualifier",
errTypeExpected: "type expected", errTypeExpected: "type expected",
errSystemNeeds: "system module needs \'$1\'", errSystemNeeds: "system module needs \'$1\'",

View file

@ -209,7 +209,10 @@ proc resolveOverloads(c: PContext, n, orig: PNode,
pickBest(callOp) pickBest(callOp)
if overloadsState == csEmpty and result.state == csEmpty: if overloadsState == csEmpty and result.state == csEmpty:
localError(n.info, errUndeclaredIdentifier, considerQuotedIdent(f).s) if nfDotField in n.flags and nfExplicitCall notin n.flags:
localError(n.info, errUndeclaredField, considerQuotedIdent(f).s)
else:
localError(n.info, errUndeclaredRoutine, considerQuotedIdent(f).s)
return return
elif result.state != csMatch: elif result.state != csMatch:
if nfExprCall in n.flags: if nfExprCall in n.flags:

View file

@ -207,9 +207,9 @@ proc markGcUnsafe(a: PEffects; reason: PNode) =
a.owner.gcUnsafetyReason = newSym(skUnknown, getIdent("<unknown>"), a.owner.gcUnsafetyReason = newSym(skUnknown, getIdent("<unknown>"),
a.owner, reason.info) a.owner, reason.info)
proc listGcUnsafety(s: PSym; onlyWarning: bool) = proc listGcUnsafety(s: PSym; onlyWarning: bool; cycleCheck: var IntSet) =
let u = s.gcUnsafetyReason let u = s.gcUnsafetyReason
if u != nil: if u != nil and not cycleCheck.containsOrIncl(u.id):
let msgKind = if onlyWarning: warnGcUnsafe2 else: errGenerated let msgKind = if onlyWarning: warnGcUnsafe2 else: errGenerated
if u.kind in {skLet, skVar}: if u.kind in {skLet, skVar}:
message(s.info, msgKind, message(s.info, msgKind,
@ -218,7 +218,7 @@ proc listGcUnsafety(s: PSym; onlyWarning: bool) =
elif u.kind in routineKinds: elif u.kind in routineKinds:
# recursive call *always* produces only a warning so the full error # recursive call *always* produces only a warning so the full error
# message is printed: # message is printed:
listGcUnsafety(u, true) listGcUnsafety(u, true, cycleCheck)
message(s.info, msgKind, message(s.info, msgKind,
"'$#' is not GC-safe as it calls '$#'" % "'$#' is not GC-safe as it calls '$#'" %
[s.name.s, u.name.s]) [s.name.s, u.name.s])
@ -227,6 +227,10 @@ proc listGcUnsafety(s: PSym; onlyWarning: bool) =
message(u.info, msgKind, message(u.info, msgKind,
"'$#' is not GC-safe as it performs an indirect call here" % s.name.s) "'$#' is not GC-safe as it performs an indirect call here" % s.name.s)
proc listGcUnsafety(s: PSym; onlyWarning: bool) =
var cycleCheck = initIntSet()
listGcUnsafety(s, onlyWarning, cycleCheck)
proc useVar(a: PEffects, n: PNode) = proc useVar(a: PEffects, n: PNode) =
let s = n.sym let s = n.sym
if isLocalVar(a, s): if isLocalVar(a, s):

View file

@ -340,6 +340,8 @@ proc `[]`*(x: Any, fieldName: string): Any =
if n != nil: if n != nil:
result.value = x.value +!! n.offset result.value = x.value +!! n.offset
result.rawType = n.typ result.rawType = n.typ
elif x.rawType.kind == tyObject and x.rawType.base != nil:
return `[]`(TAny(value: x.value, rawType: x.rawType.base), fieldName)
else: else:
raise newException(ValueError, "invalid field name: " & fieldName) raise newException(ValueError, "invalid field name: " & fieldName)

View file

@ -99,16 +99,13 @@ proc lowerBound*[T](a: openArray[T], key: T, cmp: proc(x,y: T): int {.closure.})
## arr.insert(4, arr.lowerBound(4)) ## arr.insert(4, arr.lowerBound(4))
## `after running the above arr is `[1,2,3,4,5,6,7,8,9]` ## `after running the above arr is `[1,2,3,4,5,6,7,8,9]`
result = a.low result = a.low
var pos = result var count = a.high - a.low + 1
var count, step: int var step, pos: int
count = a.high - a.low + 1
while count != 0: while count != 0:
pos = result
step = count div 2 step = count div 2
pos += step pos = result + step
if cmp(a[pos], key) < 0: if cmp(a[pos], key) < 0:
pos.inc result = pos + 1
result = pos
count -= step + 1 count -= step + 1
else: else:
count = step count = step
@ -331,3 +328,16 @@ proc prevPermutation*[T](x: var openarray[T]): bool {.discardable.} =
swap x[i-1], x[j] swap x[i-1], x[j]
result = true result = true
when isMainModule:
# Tests for lowerBound
var arr = @[1,2,3,5,6,7,8,9]
assert arr.lowerBound(0) == 0
assert arr.lowerBound(4) == 3
assert arr.lowerBound(5) == 3
assert arr.lowerBound(10) == 8
arr = @[1,5,10]
assert arr.lowerBound(4) == 1
assert arr.lowerBound(5) == 1
assert arr.lowerBound(6) == 2

View file

@ -91,13 +91,13 @@ type
# TODO: Save AF, domain etc info and reuse it in procs which need it like connect. # TODO: Save AF, domain etc info and reuse it in procs which need it like connect.
proc newAsyncSocket*(fd: AsyncFD, isBuff: bool): AsyncSocket = proc newAsyncSocket*(fd: AsyncFD, buffered = true): AsyncSocket =
## Creates a new ``AsyncSocket`` based on the supplied params. ## Creates a new ``AsyncSocket`` based on the supplied params.
assert fd != osInvalidSocket.AsyncFD assert fd != osInvalidSocket.AsyncFD
new(result) new(result)
result.fd = fd.SocketHandle result.fd = fd.SocketHandle
result.isBuffered = isBuff result.isBuffered = buffered
if isBuff: if buffered:
result.currPos = 0 result.currPos = 0
proc newAsyncSocket*(domain: Domain = AF_INET, typ: SockType = SOCK_STREAM, proc newAsyncSocket*(domain: Domain = AF_INET, typ: SockType = SOCK_STREAM,

View file

@ -13,7 +13,7 @@
when defined(windows): when defined(windows):
import winlean, os, strutils, math import winlean, os, strutils, math
proc `-`(a, b: TFILETIME): int64 = a.rdFileTime - b.rdFileTime proc `-`(a, b: FILETIME): int64 = a.rdFileTime - b.rdFileTime
elif defined(linux): elif defined(linux):
from cpuinfo import countProcessors from cpuinfo import countProcessors
@ -25,16 +25,16 @@ type
ThreadPoolState* = object ThreadPoolState* = object
when defined(windows): when defined(windows):
prevSysKernel, prevSysUser, prevProcKernel, prevProcUser: TFILETIME prevSysKernel, prevSysUser, prevProcKernel, prevProcUser: FILETIME
calls*: int calls*: int
proc advice*(s: var ThreadPoolState): ThreadPoolAdvice = proc advice*(s: var ThreadPoolState): ThreadPoolAdvice =
when defined(windows): when defined(windows):
var var
sysIdle, sysKernel, sysUser, sysIdle, sysKernel, sysUser,
procCreation, procExit, procKernel, procUser: TFILETIME procCreation, procExit, procKernel, procUser: FILETIME
if getSystemTimes(sysIdle, sysKernel, sysUser) == 0 or if getSystemTimes(sysIdle, sysKernel, sysUser) == 0 or
getProcessTimes(Handle(-1), procCreation, procExit, getProcessTimes(Handle(-1), procCreation, procExit,
procKernel, procUser) == 0: procKernel, procUser) == 0:
return doNothing return doNothing
if s.calls > 0: if s.calls > 0:
@ -57,7 +57,7 @@ proc advice*(s: var ThreadPoolState): ThreadPoolAdvice =
s.prevProcKernel = procKernel s.prevProcKernel = procKernel
s.prevProcUser = procUser s.prevProcUser = procUser
elif defined(linux): elif defined(linux):
proc fscanf(c: File, frmt: cstring) {.varargs, importc, proc fscanf(c: File, frmt: cstring) {.varargs, importc,
header: "<stdio.h>".} header: "<stdio.h>".}
var f = open("/proc/loadavg") var f = open("/proc/loadavg")

View file

@ -108,7 +108,7 @@ proc del*(monitor: FSMonitor, wd: cint) =
proc getEvent(m: FSMonitor, fd: cint): seq[MonitorEvent] = proc getEvent(m: FSMonitor, fd: cint): seq[MonitorEvent] =
result = @[] result = @[]
let size = (sizeof(TINotifyEvent)+2000)*MaxEvents let size = (sizeof(INotifyEvent)+2000)*MaxEvents
var buffer = newString(size) var buffer = newString(size)
let le = read(fd, addr(buffer[0]), size) let le = read(fd, addr(buffer[0]), size)
@ -117,7 +117,7 @@ proc getEvent(m: FSMonitor, fd: cint): seq[MonitorEvent] =
var i = 0 var i = 0
while i < le: while i < le:
var event = cast[ptr TINotifyEvent](addr(buffer[i])) var event = cast[ptr INotifyEvent](addr(buffer[i]))
var mev: MonitorEvent var mev: MonitorEvent
mev.wd = event.wd mev.wd = event.wd
if event.len.int != 0: if event.len.int != 0:
@ -129,7 +129,7 @@ proc getEvent(m: FSMonitor, fd: cint): seq[MonitorEvent] =
if (event.mask.int and IN_MOVED_FROM) != 0: if (event.mask.int and IN_MOVED_FROM) != 0:
# Moved from event, add to m's collection # Moved from event, add to m's collection
movedFrom.add(event.cookie.cint, (mev.wd, mev.name)) movedFrom.add(event.cookie.cint, (mev.wd, mev.name))
inc(i, sizeof(TINotifyEvent) + event.len.int) inc(i, sizeof(INotifyEvent) + event.len.int)
continue continue
elif (event.mask.int and IN_MOVED_TO) != 0: elif (event.mask.int and IN_MOVED_TO) != 0:
mev.kind = MonitorMoved mev.kind = MonitorMoved
@ -159,7 +159,7 @@ proc getEvent(m: FSMonitor, fd: cint): seq[MonitorEvent] =
mev.fullname = "" mev.fullname = ""
result.add(mev) result.add(mev)
inc(i, sizeof(TINotifyEvent) + event.len.int) inc(i, sizeof(INotifyEvent) + event.len.int)
# If movedFrom events have not been matched with a moveTo. File has # If movedFrom events have not been matched with a moveTo. File has
# been moved to an unwatched location, emit a MonitorDelete. # been moved to an unwatched location, emit a MonitorDelete.

View file

@ -119,13 +119,13 @@ proc toOSFlags*(socketFlags: set[SocketFlag]): cint =
result = result or MSG_PEEK result = result or MSG_PEEK
of SocketFlag.SafeDisconn: continue of SocketFlag.SafeDisconn: continue
proc newSocket(fd: SocketHandle, isBuff: bool): Socket = proc newSocket*(fd: SocketHandle, buffered = true): Socket =
## Creates a new socket as specified by the params. ## Creates a new socket as specified by the params.
assert fd != osInvalidSocket assert fd != osInvalidSocket
new(result) new(result)
result.fd = fd result.fd = fd
result.isBuffered = isBuff result.isBuffered = buffered
if isBuff: if buffered:
result.currPos = 0 result.currPos = 0
proc newSocket*(domain, typ, protocol: cint, buffered = true): Socket = proc newSocket*(domain, typ, protocol: cint, buffered = true): Socket =

View file

@ -17,17 +17,114 @@ proc raiseOverflow {.compilerproc, noinline.} =
proc raiseDivByZero {.compilerproc, noinline.} = proc raiseDivByZero {.compilerproc, noinline.} =
sysFatal(DivByZeroError, "division by zero") sysFatal(DivByZeroError, "division by zero")
proc addInt64(a, b: int64): int64 {.compilerProc, inline.} = when defined(builtinOverflow):
result = a +% b # Builtin compiler functions for improved performance
if (result xor a) >= int64(0) or (result xor b) >= int64(0): when sizeof(clong) == 8:
return result proc addInt64Overflow[T: int64|int](a, b: T, c: var T): bool {.
raiseOverflow() importc: "__builtin_saddl_overflow", nodecl, nosideeffect.}
proc subInt64(a, b: int64): int64 {.compilerProc, inline.} = proc subInt64Overflow[T: int64|int](a, b: T, c: var T): bool {.
result = a -% b importc: "__builtin_ssubl_overflow", nodecl, nosideeffect.}
if (result xor a) >= int64(0) or (result xor not b) >= int64(0):
return result proc mulInt64Overflow[T: int64|int](a, b: T, c: var T): bool {.
raiseOverflow() importc: "__builtin_smull_overflow", nodecl, nosideeffect.}
elif sizeof(clonglong) == 8:
proc addInt64Overflow[T: int64|int](a, b: T, c: var T): bool {.
importc: "__builtin_saddll_overflow", nodecl, nosideeffect.}
proc subInt64Overflow[T: int64|int](a, b: T, c: var T): bool {.
importc: "__builtin_ssubll_overflow", nodecl, nosideeffect.}
proc mulInt64Overflow[T: int64|int](a, b: T, c: var T): bool {.
importc: "__builtin_smulll_overflow", nodecl, nosideeffect.}
when sizeof(int) == 8:
proc addIntOverflow(a, b: int, c: var int): bool {.inline.} =
addInt64Overflow(a, b, c)
proc subIntOverflow(a, b: int, c: var int): bool {.inline.} =
subInt64Overflow(a, b, c)
proc mulIntOverflow(a, b: int, c: var int): bool {.inline.} =
mulInt64Overflow(a, b, c)
elif sizeof(int) == 4 and sizeof(cint) == 4:
proc addIntOverflow(a, b: int, c: var int): bool {.
importc: "__builtin_sadd_overflow", nodecl, nosideeffect.}
proc subIntOverflow(a, b: int, c: var int): bool {.
importc: "__builtin_ssub_overflow", nodecl, nosideeffect.}
proc mulIntOverflow(a, b: int, c: var int): bool {.
importc: "__builtin_smul_overflow", nodecl, nosideeffect.}
proc addInt64(a, b: int64): int64 {.compilerProc, inline.} =
if addInt64Overflow(a, b, result):
raiseOverflow()
proc subInt64(a, b: int64): int64 {.compilerProc, inline.} =
if subInt64Overflow(a, b, result):
raiseOverflow()
proc mulInt64(a, b: int64): int64 {.compilerproc, inline.} =
if mulInt64Overflow(a, b, result):
raiseOverflow()
else:
proc addInt64(a, b: int64): int64 {.compilerProc, inline.} =
result = a +% b
if (result xor a) >= int64(0) or (result xor b) >= int64(0):
return result
raiseOverflow()
proc subInt64(a, b: int64): int64 {.compilerProc, inline.} =
result = a -% b
if (result xor a) >= int64(0) or (result xor not b) >= int64(0):
return result
raiseOverflow()
#
# This code has been inspired by Python's source code.
# The native int product x*y is either exactly right or *way* off, being
# just the last n bits of the true product, where n is the number of bits
# in an int (the delivered product is the true product plus i*2**n for
# some integer i).
#
# The native float64 product x*y is subject to three
# rounding errors: on a sizeof(int)==8 box, each cast to double can lose
# info, and even on a sizeof(int)==4 box, the multiplication can lose info.
# But, unlike the native int product, it's not in *range* trouble: even
# if sizeof(int)==32 (256-bit ints), the product easily fits in the
# dynamic range of a float64. So the leading 50 (or so) bits of the float64
# product are correct.
#
# We check these two ways against each other, and declare victory if they're
# approximately the same. Else, because the native int product is the only
# one that can lose catastrophic amounts of information, it's the native int
# product that must have overflowed.
#
proc mulInt64(a, b: int64): int64 {.compilerproc.} =
var
resAsFloat, floatProd: float64
result = a *% b
floatProd = toBiggestFloat(a) # conversion
floatProd = floatProd * toBiggestFloat(b)
resAsFloat = toBiggestFloat(result)
# Fast path for normal case: small multiplicands, and no info
# is lost in either method.
if resAsFloat == floatProd: return result
# Somebody somewhere lost info. Close enough, or way off? Note
# that a != 0 and b != 0 (else resAsFloat == floatProd == 0).
# The difference either is or isn't significant compared to the
# true value (of which floatProd is a good approximation).
# abs(diff)/abs(prod) <= 1/32 iff
# 32 * abs(diff) <= abs(prod) -- 5 good bits is "close enough"
if 32.0 * abs(resAsFloat - floatProd) <= abs(floatProd):
return result
raiseOverflow()
proc negInt64(a: int64): int64 {.compilerProc, inline.} = proc negInt64(a: int64): int64 {.compilerProc, inline.} =
if a != low(int64): return -a if a != low(int64): return -a
@ -51,50 +148,6 @@ proc modInt64(a, b: int64): int64 {.compilerProc, inline.} =
raiseDivByZero() raiseDivByZero()
return a mod b return a mod b
#
# This code has been inspired by Python's source code.
# The native int product x*y is either exactly right or *way* off, being
# just the last n bits of the true product, where n is the number of bits
# in an int (the delivered product is the true product plus i*2**n for
# some integer i).
#
# The native float64 product x*y is subject to three
# rounding errors: on a sizeof(int)==8 box, each cast to double can lose
# info, and even on a sizeof(int)==4 box, the multiplication can lose info.
# But, unlike the native int product, it's not in *range* trouble: even
# if sizeof(int)==32 (256-bit ints), the product easily fits in the
# dynamic range of a float64. So the leading 50 (or so) bits of the float64
# product are correct.
#
# We check these two ways against each other, and declare victory if they're
# approximately the same. Else, because the native int product is the only
# one that can lose catastrophic amounts of information, it's the native int
# product that must have overflowed.
#
proc mulInt64(a, b: int64): int64 {.compilerproc.} =
var
resAsFloat, floatProd: float64
result = a *% b
floatProd = toBiggestFloat(a) # conversion
floatProd = floatProd * toBiggestFloat(b)
resAsFloat = toBiggestFloat(result)
# Fast path for normal case: small multiplicands, and no info
# is lost in either method.
if resAsFloat == floatProd: return result
# Somebody somewhere lost info. Close enough, or way off? Note
# that a != 0 and b != 0 (else resAsFloat == floatProd == 0).
# The difference either is or isn't significant compared to the
# true value (of which floatProd is a good approximation).
# abs(diff)/abs(prod) <= 1/32 iff
# 32 * abs(diff) <= abs(prod) -- 5 good bits is "close enough"
if 32.0 * abs(resAsFloat - floatProd) <= abs(floatProd):
return result
raiseOverflow()
proc absInt(a: int): int {.compilerProc, inline.} = proc absInt(a: int): int {.compilerProc, inline.} =
if a != low(int): if a != low(int):
if a >= 0: return a if a >= 0: return a
@ -246,6 +299,21 @@ elif false: # asmVersion and (defined(gcc) or defined(llvm_gcc)):
:"%edx" :"%edx"
""" """
when not declared(addInt) and defined(builtinOverflow):
proc addInt(a, b: int): int {.compilerProc, inline.} =
if addIntOverflow(a, b, result):
raiseOverflow()
when not declared(subInt) and defined(builtinOverflow):
proc subInt(a, b: int): int {.compilerProc, inline.} =
if subIntOverflow(a, b, result):
raiseOverflow()
when not declared(mulInt) and defined(builtinOverflow):
proc mulInt(a, b: int): int {.compilerProc, inline.} =
if mulIntOverflow(a, b, result):
raiseOverflow()
# Platform independent versions of the above (slower!) # Platform independent versions of the above (slower!)
when not declared(addInt): when not declared(addInt):
proc addInt(a, b: int): int {.compilerProc, inline.} = proc addInt(a, b: int): int {.compilerProc, inline.} =

View file

@ -60,7 +60,7 @@ else:
type type
Arg* = int Arg* = int
SArg* = int SArg* = int
{deprecated: [TArg: Arg, TSArg: SArg].} {.deprecated: [TArg: Arg, TSArg: SArg].}
when defined(windows) and defined(x86): when defined(windows) and defined(x86):
type type

View file

@ -29,7 +29,7 @@ elif defined(macosx):
else: else:
const const
readlineDll* = "libreadline.so.6(|.0)" readlineDll* = "libreadline.so.6(|.0)"
# mangle "'TCommandFunc'" TCommandFunc # mangle "'CommandFunc'" CommandFunc
# mangle TvcpFunc TvcpFunc # mangle TvcpFunc TvcpFunc
import rltypedefs import rltypedefs
@ -80,7 +80,7 @@ const
type type
KEYMAP_ENTRY*{.pure, final.} = object KEYMAP_ENTRY*{.pure, final.} = object
typ*: char typ*: char
function*: TCommandFunc function*: CommandFunc
{.deprecated: [TKEYMAP_ENTRY: KEYMAP_ENTRY].} {.deprecated: [TKEYMAP_ENTRY: KEYMAP_ENTRY].}
@ -243,7 +243,7 @@ when not defined(macosx):
type type
FUNMAP*{.pure, final.} = object FUNMAP*{.pure, final.} = object
name*: cstring name*: cstring
function*: TCommandFunc function*: CommandFunc
{.deprecated: [TFUNMAP: FUNMAP].} {.deprecated: [TFUNMAP: FUNMAP].}
@ -610,31 +610,31 @@ proc discard_argument*(): cint{.cdecl, importc: "rl_discard_argument",
dynlib: readlineDll.} dynlib: readlineDll.}
# Utility functions to bind keys to readline commands. # Utility functions to bind keys to readline commands.
proc add_defun*(a2: cstring, a3: TCommandFunc, a4: cint): cint{.cdecl, proc add_defun*(a2: cstring, a3: CommandFunc, a4: cint): cint{.cdecl,
importc: "rl_add_defun", dynlib: readlineDll.} importc: "rl_add_defun", dynlib: readlineDll.}
proc bind_key*(a2: cint, a3: TCommandFunc): cint{.cdecl, proc bind_key*(a2: cint, a3: CommandFunc): cint{.cdecl,
importc: "rl_bind_key", dynlib: readlineDll.} importc: "rl_bind_key", dynlib: readlineDll.}
proc bind_key_in_map*(a2: cint, a3: TCommandFunc, a4: PKeymap): cint{.cdecl, proc bind_key_in_map*(a2: cint, a3: CommandFunc, a4: PKeymap): cint{.cdecl,
importc: "rl_bind_key_in_map", dynlib: readlineDll.} importc: "rl_bind_key_in_map", dynlib: readlineDll.}
proc unbind_key*(a2: cint): cint{.cdecl, importc: "rl_unbind_key", proc unbind_key*(a2: cint): cint{.cdecl, importc: "rl_unbind_key",
dynlib: readlineDll.} dynlib: readlineDll.}
proc unbind_key_in_map*(a2: cint, a3: PKeymap): cint{.cdecl, proc unbind_key_in_map*(a2: cint, a3: PKeymap): cint{.cdecl,
importc: "rl_unbind_key_in_map", dynlib: readlineDll.} importc: "rl_unbind_key_in_map", dynlib: readlineDll.}
proc bind_key_if_unbound*(a2: cint, a3: TCommandFunc): cint{.cdecl, proc bind_key_if_unbound*(a2: cint, a3: CommandFunc): cint{.cdecl,
importc: "rl_bind_key_if_unbound", dynlib: readlineDll.} importc: "rl_bind_key_if_unbound", dynlib: readlineDll.}
proc bind_key_if_unbound_in_map*(a2: cint, a3: TCommandFunc, a4: PKeymap): cint{. proc bind_key_if_unbound_in_map*(a2: cint, a3: CommandFunc, a4: PKeymap): cint{.
cdecl, importc: "rl_bind_key_if_unbound_in_map", dynlib: readlineDll.} cdecl, importc: "rl_bind_key_if_unbound_in_map", dynlib: readlineDll.}
proc unbind_function_in_map*(a2: TCommandFunc, a3: PKeymap): cint{.cdecl, proc unbind_function_in_map*(a2: CommandFunc, a3: PKeymap): cint{.cdecl,
importc: "rl_unbind_function_in_map", dynlib: readlineDll.} importc: "rl_unbind_function_in_map", dynlib: readlineDll.}
proc unbind_command_in_map*(a2: cstring, a3: PKeymap): cint{.cdecl, proc unbind_command_in_map*(a2: cstring, a3: PKeymap): cint{.cdecl,
importc: "rl_unbind_command_in_map", dynlib: readlineDll.} importc: "rl_unbind_command_in_map", dynlib: readlineDll.}
proc bind_keyseq*(a2: cstring, a3: TCommandFunc): cint{.cdecl, proc bind_keyseq*(a2: cstring, a3: CommandFunc): cint{.cdecl,
importc: "rl_bind_keyseq", dynlib: readlineDll.} importc: "rl_bind_keyseq", dynlib: readlineDll.}
proc bind_keyseq_in_map*(a2: cstring, a3: TCommandFunc, a4: PKeymap): cint{. proc bind_keyseq_in_map*(a2: cstring, a3: CommandFunc, a4: PKeymap): cint{.
cdecl, importc: "rl_bind_keyseq_in_map", dynlib: readlineDll.} cdecl, importc: "rl_bind_keyseq_in_map", dynlib: readlineDll.}
proc bind_keyseq_if_unbound*(a2: cstring, a3: TCommandFunc): cint{.cdecl, proc bind_keyseq_if_unbound*(a2: cstring, a3: CommandFunc): cint{.cdecl,
importc: "rl_bind_keyseq_if_unbound", dynlib: readlineDll.} importc: "rl_bind_keyseq_if_unbound", dynlib: readlineDll.}
proc bind_keyseq_if_unbound_in_map*(a2: cstring, a3: TCommandFunc, proc bind_keyseq_if_unbound_in_map*(a2: cstring, a3: CommandFunc,
a4: PKeymap): cint{.cdecl, a4: PKeymap): cint{.cdecl,
importc: "rl_bind_keyseq_if_unbound_in_map", dynlib: readlineDll.} importc: "rl_bind_keyseq_if_unbound_in_map", dynlib: readlineDll.}
proc generic_bind*(a2: cint, a3: cstring, a4: cstring, a5: PKeymap): cint{. proc generic_bind*(a2: cint, a3: cstring, a4: cstring, a5: PKeymap): cint{.
@ -645,7 +645,7 @@ proc variable_bind*(a2: cstring, a3: cstring): cint{.cdecl,
importc: "rl_variable_bind", dynlib: readlineDll.} importc: "rl_variable_bind", dynlib: readlineDll.}
# Backwards compatibility, use rl_bind_keyseq_in_map instead. # Backwards compatibility, use rl_bind_keyseq_in_map instead.
proc set_key*(a2: cstring, a3: TCommandFunc, a4: PKeymap): cint{.cdecl, proc set_key*(a2: cstring, a3: CommandFunc, a4: PKeymap): cint{.cdecl,
importc: "rl_set_key", dynlib: readlineDll.} importc: "rl_set_key", dynlib: readlineDll.}
# Backwards compatibility, use rl_generic_bind instead. # Backwards compatibility, use rl_generic_bind instead.
@ -657,15 +657,15 @@ proc translate_keyseq*(a2: cstring, a3: cstring, a4: ptr cint): cint{.cdecl,
importc: "rl_translate_keyseq", dynlib: readlineDll.} importc: "rl_translate_keyseq", dynlib: readlineDll.}
proc untranslate_keyseq*(a2: cint): cstring{.cdecl, proc untranslate_keyseq*(a2: cint): cstring{.cdecl,
importc: "rl_untranslate_keyseq", dynlib: readlineDll.} importc: "rl_untranslate_keyseq", dynlib: readlineDll.}
proc named_function*(a2: cstring): TCommandFunc{.cdecl, proc named_function*(a2: cstring): CommandFunc{.cdecl,
importc: "rl_named_function", dynlib: readlineDll.} importc: "rl_named_function", dynlib: readlineDll.}
proc function_of_keyseq*(a2: cstring, a3: PKeymap, a4: ptr cint): TCommandFunc{. proc function_of_keyseq*(a2: cstring, a3: PKeymap, a4: ptr cint): CommandFunc{.
cdecl, importc: "rl_function_of_keyseq", dynlib: readlineDll.} cdecl, importc: "rl_function_of_keyseq", dynlib: readlineDll.}
proc list_funmap_names*(){.cdecl, importc: "rl_list_funmap_names", proc list_funmap_names*(){.cdecl, importc: "rl_list_funmap_names",
dynlib: readlineDll.} dynlib: readlineDll.}
proc invoking_keyseqs_in_map*(a2: TCommandFunc, a3: PKeymap): cstringArray{. proc invoking_keyseqs_in_map*(a2: CommandFunc, a3: PKeymap): cstringArray{.
cdecl, importc: "rl_invoking_keyseqs_in_map", dynlib: readlineDll.} cdecl, importc: "rl_invoking_keyseqs_in_map", dynlib: readlineDll.}
proc invoking_keyseqs*(a2: TCommandFunc): cstringArray{.cdecl, proc invoking_keyseqs*(a2: CommandFunc): cstringArray{.cdecl,
importc: "rl_invoking_keyseqs", dynlib: readlineDll.} importc: "rl_invoking_keyseqs", dynlib: readlineDll.}
proc function_dumper*(a2: cint){.cdecl, importc: "rl_function_dumper", proc function_dumper*(a2: cint){.cdecl, importc: "rl_function_dumper",
dynlib: readlineDll.} dynlib: readlineDll.}
@ -688,7 +688,7 @@ proc get_keymap_name_from_edit_mode*(): cstring{.cdecl,
importc: "rl_get_keymap_name_from_edit_mode", dynlib: readlineDll.} importc: "rl_get_keymap_name_from_edit_mode", dynlib: readlineDll.}
# Functions for manipulating the funmap, which maps command names to functions. # Functions for manipulating the funmap, which maps command names to functions.
proc add_funmap_entry*(a2: cstring, a3: TCommandFunc): cint{.cdecl, proc add_funmap_entry*(a2: cstring, a3: CommandFunc): cint{.cdecl,
importc: "rl_add_funmap_entry", dynlib: readlineDll.} importc: "rl_add_funmap_entry", dynlib: readlineDll.}
proc funmap_names*(): cstringArray{.cdecl, importc: "rl_funmap_names", proc funmap_names*(): cstringArray{.cdecl, importc: "rl_funmap_names",
dynlib: readlineDll.} dynlib: readlineDll.}
@ -828,7 +828,7 @@ proc username_completion_function*(a2: cstring, a3: cint): cstring{.cdecl,
importc: "rl_username_completion_function", dynlib: readlineDll.} importc: "rl_username_completion_function", dynlib: readlineDll.}
proc filename_completion_function*(a2: cstring, a3: cint): cstring{.cdecl, proc filename_completion_function*(a2: cstring, a3: cint): cstring{.cdecl,
importc: "rl_filename_completion_function", dynlib: readlineDll.} importc: "rl_filename_completion_function", dynlib: readlineDll.}
proc completion_mode*(a2: TCommandFunc): cint{.cdecl, proc completion_mode*(a2: CommandFunc): cint{.cdecl,
importc: "rl_completion_mode", dynlib: readlineDll.} importc: "rl_completion_mode", dynlib: readlineDll.}
# **************************************************************** # ****************************************************************
# #
@ -883,7 +883,7 @@ when false:
# The current value of the numeric argument specified by the user. # The current value of the numeric argument specified by the user.
var numeric_arg*{.importc: "rl_numeric_arg", dynlib: readlineDll.}: cint var numeric_arg*{.importc: "rl_numeric_arg", dynlib: readlineDll.}: cint
# The address of the last command function Readline executed. # The address of the last command function Readline executed.
var last_func*{.importc: "rl_last_func", dynlib: readlineDll.}: TCommandFunc var last_func*{.importc: "rl_last_func", dynlib: readlineDll.}: CommandFunc
# The name of the terminal to use. # The name of the terminal to use.
var terminal_name*{.importc: "rl_terminal_name", dynlib: readlineDll.}: cstring var terminal_name*{.importc: "rl_terminal_name", dynlib: readlineDll.}: cstring
# The input and output streams. # The input and output streams.
@ -1186,7 +1186,7 @@ type
rlstate*: cint rlstate*: cint
done*: cint done*: cint
kmap*: PKeymap # input state kmap*: PKeymap # input state
lastfunc*: TCommandFunc lastfunc*: CommandFunc
insmode*: cint insmode*: cint
edmode*: cint edmode*: cint
kseqlen*: cint kseqlen*: cint

View file

@ -775,7 +775,7 @@ type
Arg*{.final.} = object Arg*{.final.} = object
buf*: array[0..ERR_MAX_STRLEN - 1, int8] buf*: array[0..ERR_MAX_STRLEN - 1, int8]
Perror* = ptr Terror Perror* = ptr Error
Error*{.final.} = object # This is a numeric value corresponding to the current error Error*{.final.} = object # This is a numeric value corresponding to the current error
# SDL_rwops.h types # SDL_rwops.h types
# This is the read/write operation structure -- very basic # This is the read/write operation structure -- very basic
@ -814,7 +814,7 @@ type
theType*: cint theType*: cint
mem*: Mem mem*: Mem
RWops* = RWops # SDL_timer.h types # SDL_timer.h types
# Function prototype for the timer callback function # Function prototype for the timer callback function
TimerCallback* = proc (interval: int32): int32{.cdecl.} TimerCallback* = proc (interval: int32): int32{.cdecl.}
NewTimerCallback* = proc (interval: int32, param: pointer): int32{.cdecl.} NewTimerCallback* = proc (interval: int32, param: pointer): int32{.cdecl.}
@ -950,8 +950,8 @@ type
EventAction* = enum # Application visibility event structure EventAction* = enum # Application visibility event structure
ADDEVENT, PEEKEVENT, GETEVENT ADDEVENT, PEEKEVENT, GETEVENT
PActiveEvent* = ptr ActiveEvent PActiveEvent* = ptr TActiveEvent
ActiveEvent*{.final.} = object # SDL_ACTIVEEVENT TActiveEvent*{.final.} = object # SDL_ACTIVEEVENT
# Keyboard event structure # Keyboard event structure
kind*: EventKind kind*: EventKind
gain*: byte # Whether given states were gained or lost (1/0) gain*: byte # Whether given states were gained or lost (1/0)
@ -1032,8 +1032,8 @@ type
w*: cint # New width w*: cint # New width
h*: cint # New height h*: cint # New height
PUserEvent* = ptr UserEvent PUserEvent* = ptr TUserEvent
UserEvent*{.final.} = object # SDL_USEREVENT through SDL_NUMEVENTS-1 TUserEvent*{.final.} = object # SDL_USEREVENT through SDL_NUMEVENTS-1
kind*: EventKind kind*: EventKind
code*: cint # User defined event code code*: cint # User defined event code
data1*: pointer # User defined data pointer data1*: pointer # User defined data pointer
@ -1044,7 +1044,7 @@ type
TWrite: Write, TBool: Bool, TUInt8Array: UInt8Array, TWrite: Write, TBool: Bool, TUInt8Array: UInt8Array,
TGrabMode: GrabMode, Terrorcode: Errorcode, TStdio: Stdio, TGrabMode: GrabMode, Terrorcode: Errorcode, TStdio: Stdio,
TMem: Mem, TSeek: Seek, TRead: Read, TClose: Close, TMem: Mem, TSeek: Seek, TRead: Read, TClose: Close,
TTimerCallback: TimerCallback, TNewTimerCallback: NewTimerCallabck, TTimerCallback: TimerCallback, TNewTimerCallback: NewTimerCallback,
TTimerID: TimerID, TAudioSpecCallback: AudioSpecCallback, TTimerID: TimerID, TAudioSpecCallback: AudioSpecCallback,
TAudioSpec: AudioSpec, TAudioCVTFilter: AudioCVTFilter, TAudioSpec: AudioSpec, TAudioCVTFilter: AudioCVTFilter,
TAudioCVTFilterArray: AudioCVTFilterArray, TAudioCVT: AudioCVT, TAudioCVTFilterArray: AudioCVTFilterArray, TAudioCVT: AudioCVT,
@ -1053,16 +1053,19 @@ type
TJoystick: Joystick, TJoyAxisEvent: JoyAxisEvent, TRWops: RWops, TJoystick: Joystick, TJoyAxisEvent: JoyAxisEvent, TRWops: RWops,
TJoyBallEvent: JoyBallEvent, TJoyHatEvent: JoyHatEvent, TJoyBallEvent: JoyBallEvent, TJoyHatEvent: JoyHatEvent,
TJoyButtonEvent: JoyButtonEvent, TBallDelta: BallDelta, TJoyButtonEvent: JoyButtonEvent, TBallDelta: BallDelta,
Tversion: Version, TMod: Mod, TActiveEvent: ActiveEvent, Tversion: Version, TMod: Mod,
# TActiveEvent: ActiveEvent, # Naming conflict when we drop the `T`
TMouseMotionEvent: MouseMotionEvent, TMouseButtonEvent: MouseButtonEvent, TMouseMotionEvent: MouseMotionEvent, TMouseButtonEvent: MouseButtonEvent,
TResizeEvent: ResizeEvent, TUserEvent: UserEvent].} TResizeEvent: ResizeEvent,
# TUserEvent: UserEvent # Naming conflict when we drop the `T`
].}
when defined(Unix): when defined(Unix):
type #These are the various supported subsystems under UNIX type #These are the various supported subsystems under UNIX
SysWm* = enum SysWm* = enum
SYSWM_X11 SYSWM_X11
{.deprecated: [TSysWm: SysWm].} {.deprecated: [TSysWm: SysWm].}
when defined(WINDOWS): when defined(WINDOWS):
type type
PSysWMmsg* = ptr SysWMmsg PSysWMmsg* = ptr SysWMmsg
SysWMmsg*{.final.} = object SysWMmsg*{.final.} = object
@ -1136,8 +1139,8 @@ else:
{.deprecated: [TSysWMinfo: SysWMinfo].} {.deprecated: [TSysWMinfo: SysWMinfo].}
type type
PSysWMEvent* = ptr SysWMEvent PSysWMEvent* = ptr TSysWMEvent
SysWMEvent*{.final.} = object TSysWMEvent*{.final.} = object
kind*: EventKind kind*: EventKind
msg*: PSysWMmsg msg*: PSysWMmsg
@ -1172,12 +1175,12 @@ type
PColorArray* = ptr ColorArray PColorArray* = ptr ColorArray
ColorArray* = array[0..65000, Color] ColorArray* = array[0..65000, Color]
PPalette* = ptr TPalette PPalette* = ptr Palette
Palette*{.final.} = object # Everything in the pixel format structure is read-only Palette*{.final.} = object # Everything in the pixel format structure is read-only
ncolors*: int ncolors*: int
colors*: PColorArray colors*: PColorArray
PPixelFormat* = ptr TPixelFormat PPixelFormat* = ptr PixelFormat
PixelFormat*{.final.} = object # The structure passed to the low level blit functions PixelFormat*{.final.} = object # The structure passed to the low level blit functions
palette*: PPalette palette*: PPalette
bitsPerPixel*: byte bitsPerPixel*: byte
@ -1254,10 +1257,10 @@ type
hwOverlay*: int32 # This will be set to 1 if the overlay is hardware accelerated. hwOverlay*: int32 # This will be set to 1 if the overlay is hardware accelerated.
GLAttr* = enum GLAttr* = enum
GL_RED_SIZE, GL_GREEN_SIZE, GL_BLUE_SIZE, GL_ALPHA_SIZE, GL_BUFFER_SIZE, GL_RED_SIZE, GL_GREEN_SIZE, GL_BLUE_SIZE, GL_ALPHA_SIZE, GL_BUFFER_SIZE,
GL_DOUBLEBUFFER, GL_DEPTH_SIZE, GL_STENCIL_SIZE, GL_ACCUM_RED_SIZE, GL_DOUBLEBUFFER, GL_DEPTH_SIZE, GL_STENCIL_SIZE, GL_ACCUM_RED_SIZE,
GL_ACCUM_GREEN_SIZE, GL_ACCUM_BLUE_SIZE, GL_ACCUM_ALPHA_SIZE, GL_STEREO, GL_ACCUM_GREEN_SIZE, GL_ACCUM_BLUE_SIZE, GL_ACCUM_ALPHA_SIZE, GL_STEREO,
GL_MULTISAMPLEBUFFERS, GL_MULTISAMPLESAMPLES, GL_ACCELERATED_VISUAL, GL_MULTISAMPLEBUFFERS, GL_MULTISAMPLESAMPLES, GL_ACCELERATED_VISUAL,
GL_SWAP_CONTROL GL_SWAP_CONTROL
PCursor* = ptr Cursor PCursor* = ptr Cursor
Cursor*{.final.} = object # SDL_mutex.h types Cursor*{.final.} = object # SDL_mutex.h types
@ -1269,7 +1272,8 @@ type
wmCursor*: pointer # Window-manager cursor wmCursor*: pointer # Window-manager cursor
{.deprecated: [TRect: Rect, TSurface: Surface, TEvent: Event, TColor: Color, {.deprecated: [TRect: Rect, TSurface: Surface, TEvent: Event, TColor: Color,
TEventFilter: EventFilter, TColorArray: ColorArray, TEventFilter: EventFilter, TColorArray: ColorArray,
TSysWMEvent: SysWMEvent, TExposeEvent: ExposeEvent, # TSysWMEvent: SysWMEvent, # Naming conflict when we drop the `T`
TExposeEvent: ExposeEvent,
TQuitEvent: QuitEvent, TPalette: Palette, TPixelFormat: PixelFormat, TQuitEvent: QuitEvent, TPalette: Palette, TPixelFormat: PixelFormat,
TBlitInfo: BlitInfo, TBlit: Blit, TVideoInfo: VideoInfo, TBlitInfo: BlitInfo, TBlit: Blit, TVideoInfo: VideoInfo,
TOverlay: Overlay, TGLAttr: GLAttr, TCursor: Cursor].} TOverlay: Overlay, TGLAttr: GLAttr, TCursor: Cursor].}
@ -1285,11 +1289,11 @@ type
Cond*{.final.} = object # SDL_thread.h types Cond*{.final.} = object # SDL_thread.h types
{.deprecated: [TCond: Cond, TSem: Sem, TMutex: Mutex, Tsemaphore: Semaphore].} {.deprecated: [TCond: Cond, TSem: Sem, TMutex: Mutex, Tsemaphore: Semaphore].}
when defined(WINDOWS): when defined(WINDOWS):
type type
SYS_ThreadHandle* = Handle SYS_ThreadHandle* = Handle
{.deprecated: [TSYS_ThreadHandle: SYS_ThreadHandle].} {.deprecated: [TSYS_ThreadHandle: SYS_ThreadHandle].}
when defined(Unix): when defined(Unix):
type type
SYS_ThreadHandle* = pointer SYS_ThreadHandle* = pointer
{.deprecated: [TSYS_ThreadHandle: SYS_ThreadHandle].} {.deprecated: [TSYS_ThreadHandle: SYS_ThreadHandle].}
@ -1300,7 +1304,7 @@ type # This is the system-independent thread info struc
threadid*: int32 threadid*: int32
handle*: SYS_ThreadHandle handle*: SYS_ThreadHandle
status*: int status*: int
errbuf*: Terror errbuf*: Error
data*: pointer data*: pointer
PKeyStateArr* = ptr KeyStateArr PKeyStateArr* = ptr KeyStateArr
@ -2211,7 +2215,7 @@ proc glLoadLibrary*(filename: cstring): int{.cdecl,
proc glGetProcAddress*(procname: cstring): pointer{.cdecl, proc glGetProcAddress*(procname: cstring): pointer{.cdecl,
importc: "SDL_GL_GetProcAddress", dynlib: LibName.} importc: "SDL_GL_GetProcAddress", dynlib: LibName.}
# Set an attribute of the OpenGL subsystem before intialization. # Set an attribute of the OpenGL subsystem before intialization.
proc glSetAttribute*(attr: TGLAttr, value: int): int{.cdecl, proc glSetAttribute*(attr: GLAttr, value: int): int{.cdecl,
importc: "SDL_GL_SetAttribute", dynlib: LibName.} importc: "SDL_GL_SetAttribute", dynlib: LibName.}
# Get an attribute of the OpenGL subsystem from the windowing # Get an attribute of the OpenGL subsystem from the windowing
# interface, such as glX. This is of course different from getting # interface, such as glX. This is of course different from getting
@ -2220,7 +2224,7 @@ proc glSetAttribute*(attr: TGLAttr, value: int): int{.cdecl,
# #
# Developers should track the values they pass into SDL_GL_SetAttribute # Developers should track the values they pass into SDL_GL_SetAttribute
# themselves if they want to retrieve these values. # themselves if they want to retrieve these values.
proc glGetAttribute*(attr: TGLAttr, value: var int): int{.cdecl, proc glGetAttribute*(attr: GLAttr, value: var int): int{.cdecl,
importc: "SDL_GL_GetAttribute", dynlib: LibName.} importc: "SDL_GL_GetAttribute", dynlib: LibName.}
# Swap the OpenGL buffers, if double-buffering is supported. # Swap the OpenGL buffers, if double-buffering is supported.
proc glSwapBuffers*(){.cdecl, importc: "SDL_GL_SwapBuffers", dynlib: LibName.} proc glSwapBuffers*(){.cdecl, importc: "SDL_GL_SwapBuffers", dynlib: LibName.}
@ -2267,7 +2271,7 @@ proc wmToggleFullScreen*(surface: PSurface): int{.cdecl,
# Grabbing means that the mouse is confined to the application window, # Grabbing means that the mouse is confined to the application window,
# and nearly all keyboard input is passed directly to the application, # and nearly all keyboard input is passed directly to the application,
# and not interpreted by a window manager, if any. # and not interpreted by a window manager, if any.
proc wmGrabInput*(mode: TGrabMode): GrabMode{.cdecl, proc wmGrabInput*(mode: GrabMode): GrabMode{.cdecl,
importc: "SDL_WM_GrabInput", dynlib: LibName.} importc: "SDL_WM_GrabInput", dynlib: LibName.}
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# mouse-routines # mouse-routines

View file

@ -1,6 +1,6 @@
discard """ discard """
line: 7 line: 7
errormsg: "undeclared identifier: 'items'" errormsg: "attempting to call undeclared routine: 'items'"
""" """
type a = enum b,c,d type a = enum b,c,d

View file

@ -1,7 +1,7 @@
discard """ discard """
file: "tissue710.nim" file: "tissue710.nim"
line: 8 line: 8
errorMsg: "undeclared identifier: '||'" errorMsg: "attempting to call undeclared routine: '||'"
""" """
var sum = 0 var sum = 0
for x in 3..1000: for x in 3..1000:

View file

@ -1,7 +1,7 @@
discard """ discard """
file: "tnoop.nim" file: "tnoop.nim"
line: 11 line: 11
errormsg: "undeclared identifier: 'a'" errormsg: "attempting to call undeclared routine: 'a'"
""" """

View file

@ -1,16 +1,16 @@
discard """ discard """
file: "topaque.nim" file: "topaque.nim"
line: 16 line: 16
errormsg: "undeclared identifier: \'buffer\'" errormsg: "undeclared field: \'buffer\'"
""" """
# Test the new opaque types # Test the new opaque types
import import
mopaque mopaque
var var
L: TLexer L: TLexer
L.filename = "ha" L.filename = "ha"
L.line = 34 L.line = 34
L.buffer[0] = '\0' #ERROR_MSG undeclared field: 'buffer' L.buffer[0] = '\0' #ERROR_MSG undeclared field: 'buffer'

View file

@ -0,0 +1,26 @@
# bug #2854
import locks, threadpool, osproc
const MAX_WORKERS = 10
type
Killer = object
lock: Lock
bailed {.guard: lock.}: bool
processes {.guard: lock.}: array[0..MAX_WORKERS-1, foreign ptr Process]
template hold(lock: Lock, body: stmt) =
lock.acquire
defer: lock.release
{.locks: [lock].}:
body
proc initKiller*(): Killer =
initLock(result.lock)
result.lock.hold:
result.bailed = false
for i, _ in result.processes:
result.processes[i] = nil
var killer = initKiller()

View file

@ -1,7 +1,7 @@
discard """ discard """
file: "twrongtupleaccess.nim" file: "twrongtupleaccess.nim"
line: 9 line: 9
errormsg: "undeclared identifier: \'setBLAH\'" errormsg: "attempting to call undeclared routine: \'setBLAH\'"
""" """
# Bugfix # Bugfix

14
tests/vm/tconstobj.nim Normal file
View file

@ -0,0 +1,14 @@
discard """
output: '''(name: hello)'''
"""
# bug #2774
type Foo = object
name: string
const fooArray = [
Foo(name: "hello")
]
echo fooArray[0]

View file

@ -538,7 +538,7 @@ when haveZipLib:
var n = "$#.zip" % proj var n = "$#.zip" % proj
if c.outdir.len == 0: n = "build" / n if c.outdir.len == 0: n = "build" / n
else: n = c.outdir / n else: n = c.outdir / n
var z: TZipArchive var z: ZipArchive
if open(z, n, fmWrite): if open(z, n, fmWrite):
addFile(z, proj / buildBatFile32, "build" / buildBatFile32) addFile(z, proj / buildBatFile32, "build" / buildBatFile32)
addFile(z, proj / buildBatFile64, "build" / buildBatFile64) addFile(z, proj / buildBatFile64, "build" / buildBatFile64)