Skip to content

Instantly share code, notes, and snippets.

@zacharycarter
Created June 6, 2017 11:01
import
dynlib,
engine_types
type PluginCreator = (proc(engine: Engine):Plugin)
proc load*(manager: PluginManager, path: string): Plugin =
var pathWithExt: string
when defined(macosx):
pathWithExt = path & ".dylib"
let lib = dynlib.loadLib(pathWithExt)
if not lib.isNil:
let creatorPtr = dynlib.symAddr(lib, "createPlugin")
if not creatorPtr.isNil:
let creator = cast[PluginCreator](creatorPtr)
result = creator(manager.engine)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment