public static IntPtr DestroyScope() { if (engine != null) { // FreeLibrary直前の関数の呼び出し。 try { DoString("DestroyScope()", "DestroyScope"); } catch (Exception) { } engine = null; } SetCodePage((IntPtr)default_codepage); iDllBindHandle = 0; tmpVar = null; iDebuggingPort = 0; dpr = null; core.Dispose(); core = null; return((IntPtr)0); }
private static V8EngineCore CreateCore() { var pathResolver = new ModulePathResolver("", new[] { ".js", ".json", ".dll" }, "index"); var loaderFactory = new ModuleLoaderFactory(); core = new V8EngineCore(pathResolver, loaderFactory, iDebuggingPort); return(core); }
//---------------------------------------------------------------------------------------------- public static IntPtr CreateScope() { // まだエンジンが作られていなければ if (engine == null) { try { core = CreateCore(); engine = core.Engine; core.ExposeGlobalRequire(); // requireが使えるように // 秀丸クラスの登録 hm = new Hidemaru(); engine.AddHostType("hm", typeof(Hidemaru)); // consoleの簡易版 console = new hmV8Console(); engine.AddHostType("console", typeof(hmV8Console)); // ①ヒアドキュメント用の関数 // ②:空のDestory関数 String expression = @" function R(text){ return text.toString().match(/\/\*([\s\S]*)\*\//)[1].toString(); } hm.Macro.Var = new Proxy(()=>{}, { apply: function(target, that, args) { if (args.length > 1 ) { return hm.Macro.__Var(args[0], args[1]); } else if (args.length == 1 ) { return hm.Macro.__Var(args[0]); } }, get(target, prop, receiver) { return hm.Macro.__Var(prop); }, set(target, prop, val, receiver) { return hm.Macro.__Var(prop, val); } } ) "; engine.Execute(expression); engine.Script.DestroyScope = new Action(() => { }); dpr = new DllPathResolver(); engine.AddHostObject("AssemblyPath", new List <String>()); // ヒアドキュメント用の関数 R(text) return((IntPtr)1); } catch (Exception e) { OutputDebugStream(e.Message); return((IntPtr)0); } } return((IntPtr)1); }