diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index fcc36e4fdf..1a5334a98a 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -2111,8 +2111,10 @@ proc expr(p: BProc, n: PNode, d: var TLoc) = initLocExpr(p, n.sons[0], a) of nkAsmStmt: genAsmStmt(p, n) of nkTryStmt: - if p.module.compileToCpp: genTryCpp(p, n, d) - else: genTry(p, n, d) + if p.module.compileToCpp and optNoCppExceptions notin gGlobalOptions: + genTryCpp(p, n, d) + else: + genTry(p, n, d) of nkRaiseStmt: genRaiseStmt(p, n) of nkTypeSection: # we have to emit the type information for object types here to support diff --git a/compiler/commands.nim b/compiler/commands.nim index 02c0b84866..2622d64f4c 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -327,7 +327,7 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo) = lists.excludePath(options.lazyPaths, strippedPath) of "nimcache": expectArg(switch, arg, pass, info) - options.nimcacheDir = processPath(arg) + options.nimcacheDir = processPath(arg, true) of "out", "o": expectArg(switch, arg, pass, info) options.outFile = arg @@ -619,6 +619,10 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo) = cAssembler = nameToCC(arg) if cAssembler notin cValidAssemblers: localError(info, errGenerated, "'$1' is not a valid assembler." % [arg]) + of "nocppexceptions": + expectNoArg(switch, arg, pass, info) + incl(gGlobalOptions, optNoCppExceptions) + defineSymbol("noCppExceptions") else: if strutils.find(switch, '.') >= 0: options.setConfigVar(switch, arg) else: invalidCmdLineOption(pass, switch, info) diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim index 3882bdd036..16a8b8bd4a 100644 --- a/compiler/extccomp.nim +++ b/compiler/extccomp.nim @@ -731,6 +731,8 @@ proc callCCompiler*(projectfile: string) = builddll = "" if options.outFile.len > 0: exefile = options.outFile.expandTilde + if not exefile.isAbsolute(): + exefile = getCurrentDir() / exefile if not noAbsolutePaths(): if not exefile.isAbsolute(): exefile = joinPath(splitFile(projectfile).dir, exefile) diff --git a/compiler/options.nim b/compiler/options.nim index 82d18e2422..29cdd96fbc 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -66,6 +66,7 @@ type # please make sure we have under 32 options # also: generate header file optIdeDebug # idetools: debug mode optIdeTerse # idetools: use terse descriptions + optNoCppExceptions # use C exception handling even with CPP TGlobalOptions* = set[TGlobalOption] TCommands* = enum # Nim's commands # **keep binary compatible** diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 79d7884fa7..f10d552a1d 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -443,6 +443,7 @@ proc semAsmOrEmit*(con: PContext, n: PNode, marker: char): PNode = var e = searchInScopes(con, getIdent(sub)) if e != nil: if e.kind == skStub: loadStub(e) + incl(e.flags, sfUsed) addSon(result, newSymNode(e)) else: addSon(result, newStrNode(nkStrLit, sub)) diff --git a/doc/advopt.txt b/doc/advopt.txt index 02849498f4..02aada4fbd 100644 --- a/doc/advopt.txt +++ b/doc/advopt.txt @@ -69,6 +69,7 @@ Advanced options: --putenv:key=value set an environment variable --NimblePath:PATH add a path for Nimble support --noNimblePath deactivate the Nimble path + --noCppExceptions use default exception handling with C++ backend --excludePath:PATH exclude a path from the list of search paths --dynlibOverride:SYMBOL marks SYMBOL so that dynlib:SYMBOL has no effect and can be statically linked instead; diff --git a/doc/lib.txt b/doc/lib.txt index 90cf36240f..5ff6de7fd0 100644 --- a/doc/lib.txt +++ b/doc/lib.txt @@ -46,6 +46,9 @@ Core * `locks `_ Locks and condition variables for Nim. +* `rlocks `_ + Reentrant locks for Nim. + * `macros `_ Contains the AST API and documentation of Nim for writing macros. diff --git a/doc/manual/ffi.txt b/doc/manual/ffi.txt index f9056b1595..f08be6ad38 100644 --- a/doc/manual/ffi.txt +++ b/doc/manual/ffi.txt @@ -127,7 +127,7 @@ Produces roughly this C code: } MySeq; The bounds checking done at compile time is not disabled for now, so to access -``s.data[C]`` (where ``C`` is a constant) the array's index needs needs to +``s.data[C]`` (where ``C`` is a constant) the array's index needs to include ``C``. The base type of the unchecked array may not contain any GC'ed memory but this diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 872d4848dc..eda7936204 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -601,7 +601,7 @@ proc last*(node: NimNode): NimNode {.compileTime.} = node[".} = object + SysLockAttr {.importc: "pthread_mutexattr_t", pure, final + header: "".} = object SysCond {.importc: "pthread_cond_t", pure, final, header: "".} = object + SysLockType = distinct cint - proc initSysLock(L: var SysLock, attr: pointer = nil) {. + proc SysLockType_Reentrant: SysLockType = + {.emit: "`result` = PTHREAD_MUTEX_RECURSIVE;".} + + proc initSysLock(L: var SysLock, attr: ptr SysLockAttr = nil) {. importc: "pthread_mutex_init", header: "", noSideEffect.} + proc initSysLockAttr(a: var SysLockAttr) {. + importc: "pthread_mutexattr_init", header: "", noSideEffect.} + + proc setSysLockType(a: var SysLockAttr, t: SysLockType) {. + importc: "pthread_mutexattr_settype", header: "", noSideEffect.} + proc acquireSys(L: var SysLock) {.noSideEffect, importc: "pthread_mutex_lock", header: "".} proc tryAcquireSysAux(L: var SysLock): cint {.noSideEffect, diff --git a/lib/windows/winlean.nim b/lib/windows/winlean.nim index d12c661d67..d00964a6df 100644 --- a/lib/windows/winlean.nim +++ b/lib/windows/winlean.nim @@ -309,9 +309,9 @@ when useWinUnicode: stdcall, dynlib: "kernel32", importc: "FindNextFileW".} else: proc findFirstFileA*(lpFileName: cstring, - lpFindFileData: var WIN32_FIND_DATA): THANDLE {. + lpFindFileData: var WIN32_FIND_DATA): Handle {. stdcall, dynlib: "kernel32", importc: "FindFirstFileA".} - proc findNextFileA*(hFindFile: THANDLE, + proc findNextFileA*(hFindFile: Handle, lpFindFileData: var WIN32_FIND_DATA): int32 {. stdcall, dynlib: "kernel32", importc: "FindNextFileA".} @@ -685,7 +685,7 @@ else: proc createFileA*(lpFileName: cstring, dwDesiredAccess, dwShareMode: DWORD, lpSecurityAttributes: pointer, dwCreationDisposition, dwFlagsAndAttributes: DWORD, - hTemplateFile: THANDLE): THANDLE {. + hTemplateFile: Handle): Handle {. stdcall, dynlib: "kernel32", importc: "CreateFileA".} proc deleteFileA*(pathName: cstring): int32 {. importc: "DeleteFileA", dynlib: "kernel32", stdcall.} @@ -715,10 +715,10 @@ proc createFileMappingW*(hFile: Handle, stdcall, dynlib: "kernel32", importc: "CreateFileMappingW".} when not useWinUnicode: - proc createFileMappingA*(hFile: THANDLE, + proc createFileMappingA*(hFile: Handle, lpFileMappingAttributes: pointer, flProtect, dwMaximumSizeHigh: DWORD, - dwMaximumSizeLow: DWORD, lpName: cstring): THANDLE {. + dwMaximumSizeLow: DWORD, lpName: cstring): Handle {. stdcall, dynlib: "kernel32", importc: "CreateFileMappingA".} proc unmapViewOfFile*(lpBaseAddress: pointer): WINBOOL {.stdcall, diff --git a/web/community.txt b/web/community.txt index f63ad5c250..9ce87b5466 100644 --- a/web/community.txt +++ b/web/community.txt @@ -127,9 +127,13 @@ Nim's Community Gittip .. raw:: html - + + + BountySource + + .. raw:: html + + Paypal .. raw:: html diff --git a/web/news.txt b/web/news.txt index ddb8da0424..d854347a58 100644 --- a/web/news.txt +++ b/web/news.txt @@ -2,6 +2,29 @@ News ==== +2016-XX-XX Version 0.13.1 released +================================== + +Changes affecting backwards compatibility +----------------------------------------- + +- ``--out`` and ``--nimcache`` command line arguments are now relative to + current directory. Previously they were relative to project directory. + +Library Additions +----------------- + +- The rlocks module has been added providing reentrant lock synchronization + primitive + +Compiler Additions +------------------ + +- Added a new ``--noCppExceptions`` switch that allows to use default exception + handling (no ``throw`` or ``try``/``catch`` generated) when compiling to C++ + code + + 2016-01-27 Nim in Action is now available! ========================================== @@ -11,7 +34,6 @@ News New in Manning Early Access Program: Nim in Action! - We are proud to announce that *Nim in Action*, a book about the Nim programming language, is now available! diff --git a/web/question.txt b/web/question.txt index 4e7c15a106..c0c61c46eb 100644 --- a/web/question.txt +++ b/web/question.txt @@ -126,7 +126,7 @@ General FAQ -------------------------- - Nim IDE: https://github.com/nim-lang/Aporia - - Emacs: https://github.com/reactormonk/nim-mode + - Emacs: https://github.com/nim-lang/nim-mode - Vim: https://github.com/zah/nimrod.vim/ - Scite: Included - Gedit: The `Aporia .lang file `_ diff --git a/web/website.ini b/web/website.ini index 46564d19fd..d1f8a04bf3 100644 --- a/web/website.ini +++ b/web/website.ini @@ -54,7 +54,7 @@ srcdoc2: "pure/collections/tables;pure/collections/sets;pure/collections/lists" srcdoc2: "pure/collections/intsets;pure/collections/queues;pure/encodings" srcdoc2: "pure/events;pure/collections/sequtils;pure/cookies" srcdoc2: "pure/memfiles;pure/subexes;pure/collections/critbits" -srcdoc2: "deprecated/pure/asyncio;deprecated/pure/actors;core/locks;pure/oids;pure/endians;pure/uri" +srcdoc2: "deprecated/pure/asyncio;deprecated/pure/actors;core/locks;core/rlocks;pure/oids;pure/endians;pure/uri" srcdoc2: "pure/nimprof;pure/unittest;packages/docutils/highlite" srcdoc2: "packages/docutils/rst;packages/docutils/rstast" srcdoc2: "packages/docutils/rstgen;pure/logging;pure/options;pure/asyncdispatch;pure/asyncnet"