aboutsummaryrefslogtreecommitdiffstatsci
path: root/Samples/HelloWorld/main.cs
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2020-05-20 13:57:11 +0200
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2020-05-20 13:57:11 +0200
commit35978d4bf612d3f3afdbe20a56c55b34b6988320 (patch)
treef078837415adf542e97fd241b26c4c5e6adf5235 /Samples/HelloWorld/main.cs
parent2befc4ca0c8c20f1db20ffa199950d988915911d (diff)
Diffstat (limited to 'Samples/HelloWorld/main.cs')
-rw-r--r--Samples/HelloWorld/main.cs36
1 files changed, 35 insertions, 1 deletions
diff --git a/Samples/HelloWorld/main.cs b/Samples/HelloWorld/main.cs
index 44ec3fb8..3efd1096 100644
--- a/Samples/HelloWorld/main.cs
+++ b/Samples/HelloWorld/main.cs
@@ -1,14 +1,48 @@
using System;
+using System.Reflection;
+using System.Reflection.Emit;
using Crow;
+using Crow.IML;
namespace HelloWorld
{
class Program {
- static void Main (string[] args) {
+ /*static void Main (string[] args) {
using (Interface app = new Interface ()) {
app.Initialized += (sender, e) => (sender as Interface).Load ("#HelloWorld.helloworld.crow");
app.Run ();
}
+ }*/
+ public static void testMethod (Group w, Widget z) {
+ Console.WriteLine (w);
+ Console.WriteLine (z);
}
+ static void Main (string[] args) {
+ using (Interface app = new Interface ()) {
+ Instantiator inst = new Instantiator (app);
+ IMLContext ctx = new IMLContext (typeof (Widget));
+
+ ctx.EmitCreateWidget (typeof (Group));
+ MethodInfo mi = typeof (Program).GetMethod ("testMethod", BindingFlags.Static | BindingFlags.Public);
+ ctx.Emit (OpCodes.Ldloc_0);//load child on stack for parenting
+ ctx.il.Emit (OpCodes.Castclass, typeof (Group));
+
+ ctx.Emit (OpCodes.Dup);
+ ctx.EmitCreateWidget (typeof (Widget));
+ ctx.Emit (OpCodes.Ldloc_0);//load child on stack for parenting
+
+ ctx.il.Emit (OpCodes.Call, mi);
+ ctx.Emit (OpCodes.Stloc_0);
+
+ //ctx.Emit (OpCodes.Pop);
+ //ctx.Emit (OpCodes.Pop);
+
+ InstanciatorInvoker del = ctx.CreateDelegate (inst);
+
+ Widget w = (Widget)del (app);
+ Console.WriteLine ("widget ok");
+ }
+ }
+
}
}