Merge branch 'devel' into yield-in-try

This commit is contained in:
Yuriy Glukhov 2018-05-15 19:54:52 +03:00
commit cfe40a3e6e
121 changed files with 5545 additions and 5491 deletions

View file

@ -126,6 +126,7 @@ proc tryExec*(db: DbConn, query: SqlQuery,
args: varargs[string, `$`]): bool {.
tags: [ReadDbEffect, WriteDbEffect].} =
## tries to execute the query and returns true if successful, false otherwise.
assert(not db.isNil, "Database not connected.")
var q = dbFormat(query, args)
var stmt: sqlite3.Pstmt
if prepare_v2(db, q, q.len.cint, stmt, nil) == SQLITE_OK:
@ -144,6 +145,7 @@ proc newRow(L: int): Row =
proc setupQuery(db: DbConn, query: SqlQuery,
args: varargs[string]): Pstmt =
assert(not db.isNil, "Database not connected.")
var q = dbFormat(query, args)
if prepare_v2(db, q, q.len.cint, result, nil) != SQLITE_OK: dbError(db)
@ -267,6 +269,7 @@ proc tryInsertID*(db: DbConn, query: SqlQuery,
{.tags: [WriteDbEffect], raises: [].} =
## executes the query (typically "INSERT") and returns the
## generated ID for the row or -1 in case of an error.
assert(not db.isNil, "Database not connected.")
var q = dbFormat(query, args)
var stmt: sqlite3.Pstmt
result = -1

View file

@ -62,6 +62,7 @@ type
frames*: seq[TFrame]
screen*: Screen
performance*: Performance
onpopstate*: proc (event: Event)
Frame* = ref FrameObj
FrameObj {.importc.} = object of WindowObj
@ -175,6 +176,12 @@ type
text*: cstring
value*: cstring
TextAreaElement* = ref object of ElementObj
value*: cstring
selectionStart*, selectionEnd*: int
selectionDirection*: cstring
rows*, cols*: int
FormElement* = ref FormObj
FormObj {.importc.} = object of ElementObj
action*: cstring
@ -446,6 +453,7 @@ type
proc addEventListener*(et: EventTarget, ev: cstring, cb: proc(ev: Event), useCapture: bool = false)
proc addEventListener*(et: EventTarget, ev: cstring, cb: proc(ev: Event), options: AddEventListenerOptions)
proc removeEventListener*(et: EventTarget, ev: cstring, cb: proc(ev: Event), useCapture: bool = false)
proc dispatchEvent*(et: EventTarget, ev: Event)
# Window "methods"
proc alert*(w: Window, msg: cstring)
@ -500,7 +508,7 @@ proc removeAttributeNode*(n, attr: Node)
proc removeChild*(n, child: Node)
proc replaceChild*(n, newNode, oldNode: Node)
proc replaceData*(n: Node, start, len: int, text: cstring)
proc scrollIntoView*(n: Node)
proc scrollIntoView*(n: Node, alignToTop: bool=true)
proc setAttribute*(n: Node, name, value: cstring)
proc setAttributeNode*(n: Node, attr: Node)
@ -596,6 +604,7 @@ proc parseFloat*(s: cstring): BiggestFloat {.importc, nodecl.}
proc parseInt*(s: cstring): int {.importc, nodecl.}
proc parseInt*(s: cstring, radix: int):int {.importc, nodecl.}
proc newEvent*(name: cstring): Event {.importcpp: "new Event(@)", constructor.}
type
TEventHandlers* {.deprecated.} = EventTargetObj

View file

@ -43,8 +43,8 @@ type
mwUnsupportedField
MsgHandler* = proc (filename: string, line, col: int, msgKind: MsgKind,
arg: string) {.nimcall.} ## what to do in case of an error
FindFileHandler* = proc (filename: string): string {.nimcall.}
arg: string) {.closure.} ## what to do in case of an error
FindFileHandler* = proc (filename: string): string {.closure.}
const
messages: array[MsgKind, string] = [

View file

@ -331,7 +331,7 @@ proc slave(w: ptr Worker) {.thread.} =
await(w.taskArrived)
# XXX Somebody needs to look into this (why does this assertion fail
# in Visual Studio?)
when not defined(vcc): assert(not w.ready)
when not defined(vcc) and not defined(tcc): assert(not w.ready)
withLock numSlavesLock:
inc numSlavesRunning

View file

@ -832,6 +832,9 @@ proc toJson(x: NimNode): NimNode {.compiletime.} =
result = newCall(bindSym"newJObject")
of nnkNilLit:
result = newCall(bindSym"newJNull")
of nnkPar:
if x.len == 1: result = toJson(x[0])
else: result = newCall(bindSym"%", x)
else:
result = newCall(bindSym"%", x)

View file

@ -241,7 +241,7 @@ when defined(vcc):
else:
{.error: "invalid CAS instruction".}
elif defined(tcc) and not defined(windows):
elif defined(tcc):
when defined(amd64):
{.emit:"""
static int __tcc_cas(int *ptr, int oldVal, int newVal)
@ -262,7 +262,7 @@ static int __tcc_cas(int *ptr, int oldVal, int newVal)
}
""".}
else:
assert sizeof(int) == 4
#assert sizeof(int) == 4
{.emit:"""
static int __tcc_cas(int *ptr, int oldVal, int newVal)
{