public void OnLoaded(DuktapeVM vm) { tests(); vm.AddSearchPath("Assets/Duktape/Examples/Scripts/out"); do { if (experimentalDebugger) { // DuktapeDLL.duk_example_attach_debugger(vm.context.rawValue); DuktapeDebugger.CreateDebugger(vm); if (waitForDebuggerClient) { Debug.Log("wait for debugger connection"); DuktapeDebugger.onAttached = () => { DuktapeDebugger.onAttached = null; RunScript(vm); }; break; } } RunScript(vm); } while (false); // vm.EvalFile("test.js"); _loaded = true; }
public void OnBinded(DuktapeVM vm, int numRegs) { if (numRegs == 0) { throw new Exception("no type binding registered, please run <MENU>/Duktape/Generate Bindings in Unity Editor Mode before the first running of this project."); } }
void Awake() { vm = new DuktapeVM(null, 1024 * 1024 * 4); // vm = new DuktapeVM(); // vm.Initialize(new RFileSystem(), this); vm.Initialize(this); }
private void RunScript(DuktapeVM vm) { if (jsBytecode) { var fr = vm.fileResolver; var bytecode = fr.ReadAllBytes(launchScript + ".bytes"); if (bytecode != null) { vm.EvalMain(launchScript, bytecode); } else { var source = fr.ReadAllBytes(launchScript); bytecode = vm.DumpBytecode(launchScript, source); Debug.LogFormat("{0} => {1} (bytecode)", source.Length, bytecode.Length); System.IO.File.WriteAllBytes("Assets/Duktape/Examples/Scripts/out/" + launchScript + ".bytes", bytecode); vm.EvalMain(launchScript, bytecode); } } else { var f = vm.EvalSource("eval", System.Text.Encoding.UTF8.GetBytes("function x() { console.log('hello, eval.'); };x")) as DuktapeFunction; if (f != null) { var a = f.ToDelegate <Action>(); a?.Invoke(); } vm.EvalMain(launchScript); } }
void OnDestroy() { // DuktapeDebugger.Shutdown(); if (vm.context != null) { DuktapeDLL.duk_example_detach_debugger(vm.context.rawValue, IntPtr.Zero); } vm.Destroy(); vm = null; }
public void OnLoaded(DuktapeVM vm) { tests(); vm.AddSearchPath("Assets/Examples/Scripts/out"); if (experimentalDebugger) { DuktapeDLL.duk_example_attach_debugger(vm.context.rawValue); } // vm.EvalFile("test.js"); vm.EvalMain(launchScript); _loaded = true; }
private void RunScript(DuktapeVM vm) { if (jsBytecode) { var fr = vm.fileResolver; var bytecode = fr.ReadAllBytes(launchScript + ".bytes"); if (bytecode != null) { vm.EvalMain(launchScript, bytecode); } else { var source = fr.ReadAllBytes(launchScript); bytecode = vm.DumpBytecode(launchScript, source); Debug.LogFormat("{0} => {1} (bytecode)", source.Length, bytecode.Length); System.IO.File.WriteAllBytes("Assets/Duktape/Examples/Scripts/out/" + launchScript + ".bytes", bytecode); vm.EvalMain(launchScript, bytecode); } } else { vm.EvalMain(launchScript); } }
public void OnProgress(DuktapeVM vm, int step, int total) { }
public void OnBindingError(DuktapeVM vm, Type type) { }
public void OnTypesBinding(DuktapeVM vm) { // 此处进行手工导入 // var ctx = vm.context.rawValue; // xxx.reg(ctx); }
// void Update() // { // Debug.LogFormat("Update"); // } // void OnApplicationQuit() // { // Debug.LogFormat("OnApplicationQuit"); // } void OnDestroy() { vm.Destroy(); vm = null; }