Carrying on from last post…
// C# public static void typeTest(object arg) { System.Type wtf = arg.GetType(); Console.WriteLine(wtf.ToString()); Console.WriteLine("Base = "+wtf.BaseType.ToString()); System.Type[] iface = wtf.GetInterfaces(); Console.WriteLine("# interfaces = " + iface.Length); foreach (System.Type t in iface) Console.WriteLine(":: "+t.ToString()) }
##Ruby caller q = Observer.new JsharpToRuby::ClassDictionary.typeTest q
yields disappointing results
Observer Base = Ruby.Object # interfaces = 0
Oh dear! it doesn't seem to work the naïve way for proper interfaces
// C# namespace JsharpToRuby { public interface ITest { Boolean isPresent(); }
##Ruby class EyeTest include JsharpToRuby::ITest def isPresent 1 end end q = EyeTest.new puts q.class q.class.ancestors.each { |x| puts x } JsharpToRuby::ClassDictionary.typeTest q
yields
EyeTest EyeTest ITest Object Kernel EyeTest Base = Ruby.Object # interfaces = 0
This is of course the bit missed out in the interop tutorial, alas; I think for the good and simple reason that it is not yet implemented (from a quick inspection of the code).
*le sigh*
Maybe not all is lost. It would mean more hand-rolled adapter classes to wrap the objects and delegate by reflection.
But later, definitely, later.
No comments:
Post a Comment