Initial support for #56
This commit is contained in:
parent
d6e9a49194
commit
46f7940f30
2 changed files with 46 additions and 1 deletions
|
|
@ -99,6 +99,9 @@ proc getToast(fullpath: string, recurse: bool = false): string =
|
|||
for i in gStateCT.includeDirs:
|
||||
cmd.add &"--includeDirs+={i.quoteShell} "
|
||||
|
||||
for i in gStateCT.symOverride:
|
||||
cmd.add &"--symOverride+={i} "
|
||||
|
||||
cmd.add &"{fullpath.quoteShell}"
|
||||
echo cmd
|
||||
(result, ret) = gorgeEx(cmd, cache=getCacheValue(fullpath))
|
||||
|
|
@ -112,6 +115,48 @@ proc getGccPaths(mode = "c"): string =
|
|||
|
||||
(result, ret) = gorgeEx("gcc -Wp,-v -x" & mmode & " " & nul)
|
||||
|
||||
macro cOverride*(body): untyped =
|
||||
## When the wrapper code generated by nimterop is missing certain symbols or not
|
||||
## accurate, it may be required to hand wrap them. Define them in a ``cOverride()``
|
||||
## macro block so that Nimterop no longer defines these symbols.
|
||||
##
|
||||
## For example:
|
||||
##
|
||||
## .. code-block:: c
|
||||
##
|
||||
## int svGetCallerInfo(const char** fileName, int *lineNumber);
|
||||
##
|
||||
## This could get mapped to:
|
||||
##
|
||||
## .. code-block:: nim
|
||||
##
|
||||
## proc svGetCallerInfo(fileName: ptr cstring; lineNumber: var cint)
|
||||
##
|
||||
## Whereas it might mean:
|
||||
##
|
||||
## .. code-block:: nim
|
||||
##
|
||||
## cOverride:
|
||||
## proc svGetCallerInfo(fileName: var cstring; lineNumber: var cint)
|
||||
##
|
||||
## Using the ``cOverride()`` block, nimterop can be instructed to skip over
|
||||
## ``svGetCallerInfo()``. This works for procs, consts and types.
|
||||
|
||||
for sym in body:
|
||||
case sym.kind:
|
||||
of nnkProcDef:
|
||||
gStateCT.symOverride.add $sym[0]
|
||||
of nnkConstSection, nnkTypeSection:
|
||||
for ssym in sym:
|
||||
gStateCT.symOverride.add $ssym[0]
|
||||
else:
|
||||
discard
|
||||
|
||||
result = body
|
||||
|
||||
if gStateCT.debug:
|
||||
echo "Overriding " & gStateCT.symOverride.join(" ")
|
||||
|
||||
proc cSearchPath*(path: string): string {.compileTime.}=
|
||||
## Return a file or directory found in search path configured using
|
||||
## ``cSearchPath()``
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ type
|
|||
regex*: Regex
|
||||
|
||||
State = object
|
||||
compile*, defines*, headers*, includeDirs*, searchDirs*: seq[string]
|
||||
compile*, defines*, headers*, includeDirs*, searchDirs*, symOverride*: seq[string]
|
||||
|
||||
nocache*, debug*, past*, preprocess*, pnim*, pretty*, recurse*: bool
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue