Skip to content

Instantly share code, notes, and snippets.

@zacharycarter
Created December 11, 2018 06:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zacharycarter/cc0e1f40fd5f7df6c8d683c1543f7fdc to your computer and use it in GitHub Desktop.
Save zacharycarter/cc0e1f40fd5f7df6c8d683c1543f7fdc to your computer and use it in GitHub Desktop.
import plugin_manager
type
FooPlugin* {.exportc.} = ref object of Plugin
{.pragma: rtl, exportc, dynlib, cdecl.}
proc create*(): FooPlugin {.rtl.} =
result = new(FooPlugin)
import dynlib, plugin_manager
type
FooPlugin {.importc.} = ref object of Plugin
creator = proc(): FooPlugin {.gcsafe, cdecl.}
var lib = dynlib.loadLib("libfoo.dylib")
let create = cast[creator](lib.symAddr("create"))
let fooPlugin = create()
echo repr fooPlugin
lib.unloadLib()
type
Plugin* = ref object of RootObj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment