-
-
Save zacharycarter/cc0e1f40fd5f7df6c8d683c1543f7fdc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import plugin_manager | |
type | |
FooPlugin* {.exportc.} = ref object of Plugin | |
{.pragma: rtl, exportc, dynlib, cdecl.} | |
proc create*(): FooPlugin {.rtl.} = | |
result = new(FooPlugin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type | |
Plugin* = ref object of RootObj |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment