aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGanesh Viswanathan <dev@genotrance.com>2019-01-24 22:59:51 -0600
committergenotrance <dev@genotrance.com>2019-01-27 22:05:54 -0600
commit44b529f5f5f76007f00e8157f158a496c7604779 (patch)
tree09d73d550fd5410bb7e1619b9a76b21919f4b706
parentd8c75a43f725ca3fc4111a55587ce5ca69d024e9 (diff)
downloadnimterop-44b529f5f5f76007f00e8157f158a496c7604779.tar.gz
nimterop-44b529f5f5f76007f00e8157f158a496c7604779.zip
Documentation, fix tmath on Windows
-rw-r--r--nimterop/cimport.nim12
-rw-r--r--tests/tmath.nim7
2 files changed, 19 insertions, 0 deletions
diff --git a/nimterop/cimport.nim b/nimterop/cimport.nim
index 8fcf66e..330654f 100644
--- a/nimterop/cimport.nim
+++ b/nimterop/cimport.nim
@@ -174,6 +174,18 @@ macro cSkipSymbol*(skips: varargs[string]): untyped =
gStateCT.symOverride.add skip.strVal
macro cPlugin*(body): untyped =
+ ## When `cOverride() <cimport.html#cOverride.m,>`_ and `cSkipSymbol() <cimport.html#cSkipSymbol.m%2Cvarargs[string]>`_
+ ## are not adequate, the `cPlugin() <cimport.html#cPlugin.m,>`_ macro can be used to customize the generated Nim output.
+ ## The following callbacks are available at this time.
+ ##
+ ## .. code-block:: nim
+ ##
+ ## cPlugin:
+ ## import strutils
+ ##
+ ## proc onSymbol*(sym: string): string {.exportc, dynlib.} =
+ ## return sym.strip(chars={'_'})
+
let
data = body.repr
path = getTempDir() / "nimterop" & ($data.hash() & ".nim")
diff --git a/tests/tmath.nim b/tests/tmath.nim
index f32a1f5..5e98968 100644
--- a/tests/tmath.nim
+++ b/tests/tmath.nim
@@ -10,6 +10,13 @@ cDebug()
cDisableCaching()
cAddStdDir()
+
+cPlugin:
+ import strutils
+
+ proc onSymbol*(sym: string): string {.exportc, dynlib.} =
+ return sym.strip(chars={'_'})
+
cImport cSearchPath("math.h")
check sin(5) == -0.9589242746631385