2 using System
.Runtime
.InteropServices
;
4 using MethodDescriptor
= Mozilla
.XPCOM
.TypeInfo
.MethodDescriptor
;
8 [DllImport("xpcom-dotnet.so")]
9 static extern int StartXPCOM(out IntPtr srvmgr
);
13 [DllImport("test.so", EntryPoint
="GetImpl")]
14 public static extern IntPtr
GetTestImpl();
16 public static int xptinfo_test(string[] args
)
18 int index
= Int32
.Parse(args
[2]);
19 MethodDescriptor meth
= TypeInfo
.GetMethodData(args
[1], index
);
20 Console
.WriteLine("{0}#{1}: {2}", args
[1], index
, meth
.ToString());
24 public static int xptinvoke_test_cb()
26 object o
= new object();
28 IntPtr impl
= GetTestImpl();
29 Invoker
.Invoke(impl
, "test", "callback", o
);
33 public static int xptinvoke_test_add(string[] args
)
35 int a
= Int32
.Parse(args
[1]);
36 int b
= Int32
.Parse(args
[2]);
38 IntPtr impl
= GetTestImpl();
39 Invoker
.Invoke(impl
, "test", "add", a
, b
);
43 public static int Main(string[] args
)
45 int res
= StartXPCOM(out srvmgr
);
48 Console
.WriteLine("StartXPCOM failed: {0:X2}", res
);
53 return xptinvoke_test_add(args
);
54 if (args
[0] == "xptinfo")
55 return xptinfo_test(args
);
57 return xptinvoke_test_cb();
58 Console
.WriteLine("Unknown test mode: {0}", args
[0]);