Prefix stripping example
This commit is contained in:
parent
1114b7edbe
commit
46ddc05e2e
1 changed files with 10 additions and 0 deletions
|
|
@ -235,9 +235,19 @@ macro cPlugin*(body): untyped =
|
||||||
cPlugin:
|
cPlugin:
|
||||||
import strutils
|
import strutils
|
||||||
|
|
||||||
|
# Strip leading and trailing underscores
|
||||||
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
|
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
|
||||||
sym.name = sym.name.strip(chars={'_'})
|
sym.name = sym.name.strip(chars={'_'})
|
||||||
|
|
||||||
|
runnableExamples:
|
||||||
|
cPlugin:
|
||||||
|
import strutils
|
||||||
|
|
||||||
|
# Strip prefix from procs
|
||||||
|
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
|
||||||
|
if sym.kind == nskProc and sym.name.contains("SDL_"):
|
||||||
|
sym.name = sym.name.replace("SDL_", "")
|
||||||
|
|
||||||
let
|
let
|
||||||
data = "import nimterop/plugin\n\n" & body.repr
|
data = "import nimterop/plugin\n\n" & body.repr
|
||||||
hash = data.hash().abs()
|
hash = data.hash().abs()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue