Context
package eval.vm
Available on macro
Static methods
staticaddBreakpoint(file:String, line:Int):Void
staticbreakHere():Void
staticcallMacroApi(s:String):Dynamic
staticloadPlugin<T>(filePath:String):T
Loads and returns a plugin from file filePath
.
If Haxe is built natively, the extension automatically defaults to .cmxs
, even if a different extension is provided in filePath
. In bytecode mode, the default extension is .cmo
.
Sample plugin:
open EvalValue
open EvalContext
open EvalEncode
let add_int = vfun2 (fun v1 v2 -> match v1,v2 with
| VInt32 i1,VInt32 i2 -> vint32 (Int32.add i1 i2)
| _ -> exc_string "Expected int + int"
)
;;
EvalStdLib.StdContext.register ["add_int",add_int]
Usage from Haxe:
var module:TestPlugin = eval.vm.Context.loadPlugin("testPlugin.cmo");
trace(module.add_int(4, 3));
Plugins have to be compiled with the same OCaml version as the Haxe compiler and using the same Haxe version. If a plugin cannot be loaded, an exception of type String
is thrown.
© 2005–2020 Haxe Foundation
Licensed under a MIT license.
https://api.haxe.org/eval/vm/Context.html