diff options
| author | Ganesh Viswanathan <dev@genotrance.com> | 2019-04-10 22:28:28 -0500 |
|---|---|---|
| committer | Ganesh Viswanathan <dev@genotrance.com> | 2019-04-10 22:28:28 -0500 |
| commit | 46ddc05e2e2b13d37dae4ea5074fa9e99582cfc5 (patch) | |
| tree | fea593198c3003cb91151ff54c7865f3579fbd9f | |
| parent | 1114b7edbe02bb775bc7bf1c590caf5abecf08cd (diff) | |
| download | nimterop-46ddc05e2e2b13d37dae4ea5074fa9e99582cfc5.tar.gz nimterop-46ddc05e2e2b13d37dae4ea5074fa9e99582cfc5.zip | |
Prefix stripping example
| -rw-r--r-- | nimterop/cimport.nim | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/nimterop/cimport.nim b/nimterop/cimport.nim index 1f0de30..1f82b6f 100644 --- a/nimterop/cimport.nim +++ b/nimterop/cimport.nim @@ -235,9 +235,19 @@ macro cPlugin*(body): untyped = cPlugin: import strutils + # Strip leading and trailing underscores proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} = 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 data = "import nimterop/plugin\n\n" & body.repr hash = data.hash().abs() |
