dynlib allow path, don't delete project, fix proc inline comment

This commit is contained in:
Ganesh Viswanathan 2020-06-23 23:20:15 -05:00
commit a8ea96055d
6 changed files with 20 additions and 4 deletions

View file

@ -27,6 +27,7 @@ https://github.com/nimterop/nimterop/compare/v0.5.9...v0.6.0
- `getHeader()` now detects and links against `.lib` files as part of enabling Conan.io. Not all `.lib` files are compatible with MinGW as already stated above but for those that work, this is a required capability.
- The `dynlib` command line parameter to `toast` and `cImport()` can also be the path to a shared library (dll|so|dylib) in place of a Nim const string containing the path. This allows for the traditional use case of passing `"xxxLPath"` to `cImport()` as well as simply passing the path to the library on the command line as is. This allows the creation of standalone cached wrappers as well as the usage of the `--check` and the `--stub` functionality that `toast` provides via `cImport()`.
## Version 0.5.0

View file

@ -217,7 +217,7 @@ Options:
-C=, --convention= string "cdecl" calling convention for wrapped procs
-d, --debug bool false enable debug output
-D=, --defines= strings {} definitions to pass to preprocessor
-l=, --dynlib= string "" import symbols from library in specified Nim string
-l=, --dynlib= string "" {.dynlib.} pragma to import symbols - Nim const string or file path
-f=, --feature= Features ast1 flags to enable experimental features
-I=, --includeDirs= strings {} include directory to pass to preprocessor
-m=, --mode= string "" language parser: c or cpp

View file

@ -392,6 +392,12 @@ macro getHeader*(
else:
getLocalPath(header, outdir)
static:
# Don't delete project
when not `nameStd` and (`nameGit` or `nameDL` or `nameConan` or `nameJBB`):
doAssert `outdir`.len != 0, "getHeader():outdir cannot be blank"
doAssert `outdir` != getProjectPath(), "getHeader():outdir cannot be the project path"
const
`version`* {.strdefine.} = `verVal`
`lname` =

View file

@ -240,7 +240,7 @@ when isMainModule:
"convention": "calling convention for wrapped procs",
"debug": "enable debug output",
"defines": "definitions to pass to preprocessor",
"dynlib": "import symbols from library in specified Nim string",
"dynlib": "{.dynlib.} pragma to import symbols - Nim const string or file path",
"feature": "flags to enable experimental features",
"includeDirs": "include directory to pass to preprocessor",
"mode": "language parser: c or cpp",

View file

@ -1805,7 +1805,10 @@ proc setupPragmas(gState: State, root: TSNode, fullpath: string) =
# {.pragma: impnameDyn, dynlib: libname.}
let
dynPragma = gState.newPragma(root, "pragma", gState.getIdent(gState.impShort & "Dyn"))
gState.addPragma(root, dynPragma, "dynlib", gState.getIdent(gState.dynlib))
if '.' in gState.dynlib:
gState.addPragma(root, dynPragma, "dynlib", newStrNode(nkStrLit, gState.dynlib))
else:
gState.addPragma(root, dynPragma, "dynlib", gState.getIdent(gState.dynlib))
gState.pragmaSection.add dynPragma
count += 1

View file

@ -154,7 +154,13 @@ proc firstChildInTree*(node: TSNode, ntype: string): TSNode =
while not cnode.isNil:
if cnode.getName() == ntype:
return cnode
cnode = cnode[0]
if cnode.len != 0:
for i in 0 ..< cnode.len:
if cnode[i].getName() != "comment":
cnode = cnode[i]
break
else:
cnode = cnode[0]
proc anyChildInTree*(node: TSNode, ntype: string): TSNode =
# Search for node type anywhere in tree - depth first