diff options
| author | Ganesh Viswanathan <dev@genotrance.com> | 2019-11-01 17:45:33 -0500 |
|---|---|---|
| committer | Ganesh Viswanathan <dev@genotrance.com> | 2019-11-01 17:45:33 -0500 |
| commit | 31527a82402efe58c3eef7e60b196861defe486c (patch) | |
| tree | 0ec2279ce8c4243f884f4c254af0a89d79439403 | |
| parent | 36726e2442f9e78afda7906b1765e02432ff9489 (diff) | |
| download | nimterop-issue149.tar.gz nimterop-issue149.zip | |
Update docs, minor optimizationissue149
| -rw-r--r-- | nimterop/cimport.nim | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/nimterop/cimport.nim b/nimterop/cimport.nim index aabeadc..65a5401 100644 --- a/nimterop/cimport.nim +++ b/nimterop/cimport.nim @@ -198,8 +198,10 @@ macro cOverride*(body): untyped = ## can be instructed to use this definition of `svGetCallerInfo()` instead. ## This works for procs, consts and types. ## - ## `cOverride() <cimport.html#cOverride.m>`_ only affects calls to - ## `cImport() <cimport.html#cImport.m%2C%2Cstring%2Cstring%2Cstring>`_ that follow it. + ## `cOverride()` only affects the next `cImport()` call. This is because any + ## recognized symbols get overridden in place and any remaining symbols get + ## added to the top. If reused, the next `cImport()` would add those symbols + ## again leading to redefinition errors. iterator findOverrides(node: NimNode): tuple[name, override: string, kind: NimNodeKind] = for child in node: @@ -571,6 +573,10 @@ macro cImport*(filename: static string, recurse: static bool = false, dynlib: st ## be ignored for the foreseeable future. ## ## `flags` can be used to pass any other command line arguments to `toast`. + ## + ## `cImport()` consumes and resets preceding `cOverride()` calls. `cPlugin()` + ## is retained for the next `cImport()` call unless a new `cPlugin()` call is + ## defined. result = newNimNode(nnkStmtList) @@ -587,8 +593,9 @@ macro cImport*(filename: static string, recurse: static bool = false, dynlib: st output = getToast(fullpath, recurse, dynlib, mode, flags) # Reset plugin and overrides for next cImport - gStateCT.pluginSourcePath = "" - gStateCT.overrides = "" + if gStateCT.overrides.nBl: + gStateCT.pluginSourcePath = "" + gStateCT.overrides = "" if gStateCT.debug: echo output |
