From f4d8ee1c5cf8b7422b8cb66811fa0d9518cee787 Mon Sep 17 00:00:00 2001 From: Ganesh Viswanathan Date: Thu, 24 Jan 2019 22:59:51 -0600 Subject: Documentation, fix tmath on Windows --- nimterop/cimport.nim | 12 ++++++++++++ tests/tmath.nim | 7 +++++++ 2 files changed, 19 insertions(+) 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() `_ and `cSkipSymbol() `_ + ## are not adequate, the `cPlugin() `_ 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 -- cgit v1.2.3