28 lines
527 B
Nim
28 lines
527 B
Nim
{.pragma: some, header: "cb.h".}
|
|
|
|
type
|
|
OnHeaderCallback = proc (s: cstring) {.cdecl.}
|
|
|
|
proc callbackFn(json: string) {.exportc, cdecl.} =
|
|
echo "callbackFn", json
|
|
|
|
# callbackFn "some"
|
|
|
|
proc HelloFromNim(): cstring {.exportc.} =
|
|
return "Hello, World From Nim\n"
|
|
|
|
var headerCallback: OnHeaderCallback
|
|
|
|
proc setHeaderCallback*(cb: OnHeaderCallback) {.exportc.} =
|
|
headerCallback = cb
|
|
|
|
proc invokeHeaderCallback*() {.exportc.} =
|
|
headerCallback("inside Nim 2222")
|
|
|
|
proc testEcho*() {.exportc.} =
|
|
echo "in testEcho"
|
|
|
|
|
|
|
|
|