Created
June 16, 2017 18:22
-
-
Save vvuk/3f5eefee56ee5a1cf22141e96d3df62d to your computer and use it in GitHub Desktop.
Revisions
-
vvuk created this gist
Jun 16, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,75 @@ using System; using System.Collections.Generic; using System.Linq; using V8.Net; namespace Test1 { class GlobalUtils { public static void WriteLine(string s) { Console.WriteLine(s); } } public class TestClass { public TestClass() { } public void Foo() { Console.WriteLine("base Foo called"); } public void Bar() { Console.WriteLine("base Bar called"); } } class Program { public static void Main(string[] args) { var js = new V8Engine(); js.SetFlagsFromString("--use-strict"); js.RegisterType<GlobalUtils>("utils", false, ScriptMemberSecurity.Locked); js.GlobalObject.SetProperty(typeof(GlobalUtils)); js.RegisterType<TestClass>(); js.GlobalObject.SetProperty(typeof(TestClass)); js.ConsoleExecute(jssrc); } private static string jssrc = @" class Derived extends TestClass { constructor() { super(); utils.WriteLine('derived constructor'); } Foo() { utils.WriteLine('Derived foo'); } Something() { utils.WriteLine('Something'); } } // BUG 1 -- this crashes //utils.WriteLine(Object.getPrototypeOf('Derived')); var d = new Derived(); d.Foo(); d.Bar(); d.Something(); "; } }