changeset 4:64226294e26b

Added some information on using the interop interface generator
author Ivo Smits
date Wed, 04 May 2011 21:15:22 +0200
parents b0033e69105a
children 00fb4879d273
files InteropCodeGen/gendotnet.cs
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/InteropCodeGen/gendotnet.cs	Wed May 04 16:32:10 2011 +0200
+++ b/InteropCodeGen/gendotnet.cs	Wed May 04 21:15:22 2011 +0200
@@ -1,3 +1,22 @@
+/* This script can be used to generate C# interface definitions for XPCOM
+ * interop, based on an xidl file. It is currently not very flexible and
+ * biased towards VirtualBox.
+ * 
+ * To use, put the appropriate VirtualBox.xidl file in the same directory as
+ * the application, and run it while piping it's output to a file:
+ *  mono InteropCodeGen.exe > VirtualBox.cs
+ * Then, for compatibility with the interop assembly generated by VS.Net, a
+ * few modifications need to be made using the following regular expressions:
+ *  sed -i VirtualBox.cs "s/void LockMachine(\[MarshalAs(UnmanagedType.Interface)\] ISession psession, LockType plockType);/void LockMachine([MarshalAs(UnmanagedType.Interface)\] Session psession, LockType plockType);/"
+ *  sed -i VirtualBox.cs "s/LaunchVMProcess(\[MarshalAs(UnmanagedType\.Interface)\] ISession psession,/LaunchVMProcess([MarshalAs(UnmanagedType.Interface)] Session psession,/"
+ *  sed -i VirtualBox.cs "s/\(interface IVirtualBoxErrorInfo {\)/\1\n\tvoid dummy1();void dummy2();void dummy3();void dummy4();void dummy5(); void dummy6(); void dummy7(); void dummy8(); void dummy9(); void dummy10();/"
+ * Then, a few lines need to be appended to the file:
+ *  namespace VirtualBox {
+ *   [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)][Guid("12F4DCDB-12B2-4EC1-B7CD-DDD9F6C5BF4D")][ComImport()]interface Session : ISession {}
+ *  }
+ * Then, compile the generated file:
+ *  gmcs -target:library -out:Interop.VirtualBox.XPCOM.dll VirtualBox.cs
+ */
 //+reference System.dll
 //+reference System.Xml.dll
 using System;