Author: jbevain
Date: 2005-04-28 17:51:01 -0400 (Thu, 28 Apr 2005)
New Revision: 43749

Added:
   trunk/cecil/lib/Mono.Cecil/IMarshalSpec.cs
   trunk/cecil/lib/Mono.Cecil/VariantType.cs
Modified:
   trunk/cecil/lib/Mono.Cecil.Signatures/MarshalSpec.cs
   trunk/cecil/lib/Mono.Cecil.Signatures/SignatureReader.cs
   trunk/cecil/lib/Mono.Cecil.dll.sources
   trunk/cecil/lib/Mono.Cecil/NativeType.cs
Log:
work on marshal spec

Added: trunk/cecil/lib/Mono.Cecil/IMarshalSpec.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil/IMarshalSpec.cs  2005-04-28 21:23:26 UTC (rev 
43748)
+++ trunk/cecil/lib/Mono.Cecil/IMarshalSpec.cs  2005-04-28 21:51:01 UTC (rev 
43749)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2004 DotNetGuru and the individuals listed
+ * on the ChangeLog entries.
+ *
+ * Authors :
+ *   Jb Evain   ([EMAIL PROTECTED])
+ *
+ * This is a free software distributed under a MIT/X11 license
+ * See LICENSE.MIT file for more details
+ *
+ *****************************************************************************/
+
+namespace Mono.Cecil {
+
+    using System;
+
+    public interface IMarshalSpec {
+
+        NativeType NativeIntrinsic { get; }
+        bool HasMoreData { get; }
+
+        IExtendedMarshalSpec ExtendedData { get; }
+    }
+
+    public interface IExtendedMarshalSpec {
+    }
+
+    public interface IArrayDesc : IExtendedMarshalSpec {
+
+        NativeType ElemType { get; set; }
+        int ParamNum { get; set; }
+        int ElemMult { get; set; }
+        int NumElem { get; set; }
+    }
+
+    public interface ICustomMarshalerDesc : IExtendedMarshalSpec {
+
+        Guid Guid { get; set; }
+        string UnmanagedType { get; set; }
+        ITypeDefinition ManagedType { get; set; }
+        string Cookie { get; set; }
+    }
+
+    public interface IFixedArrayDesc : IExtendedMarshalSpec {
+
+        int NumElem { get; set; }
+        NativeType ElemType { get; set; }
+    }
+
+    public interface ISafeArrayDesc : IExtendedMarshalSpec {
+
+        VariantType ElemType { get; set; }
+    }
+}
+

Modified: trunk/cecil/lib/Mono.Cecil/NativeType.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil/NativeType.cs    2005-04-28 21:23:26 UTC (rev 
43748)
+++ trunk/cecil/lib/Mono.Cecil/NativeType.cs    2005-04-28 21:51:01 UTC (rev 
43749)
@@ -13,7 +13,7 @@
 namespace Mono.Cecil {
 
     public enum NativeType {
-        Boolean = 0x02,
+        BOOLEAN = 0x02,
         I1 = 0x03,
         U1 = 0x04,
         I2 = 0x05,
@@ -28,6 +28,28 @@
         INT = 0x1f,
         UINT = 0x20,
         FUNC = 0x26,
-        ARRAY = 0x2a
+        ARRAY = 0x2a,
+
+        // Msft specific
+        CURRENCY = 0x0f,
+        BSTR = 0x13,
+        LPWSTR = 0x15,
+        LPTSTR = 0x16,
+        FIXEDSYSSTRING = 0x17,
+        IUNKNOWN = 0x19,
+        IDISPATCH = 0x1a,
+        STRUCT = 0x1b,
+        INTF = 0x1c,
+        SAFEARRAY = 0x1d,
+        FIXEDARRAY = 0x1e,
+        BYVALSTR = 0x22,
+        ANSIBSTR = 0x23,
+        TBSTR = 0x24,
+        VARIANTBOOL = 0x25,
+        ASANY = 0x28,
+        LPSTRUCT = 0x2b,
+        CUSTOMMARSHALER = 0x2c,
+        ERROR = 0x2d,
+        MAX = 0x50
     }
 }

Added: trunk/cecil/lib/Mono.Cecil/VariantType.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil/VariantType.cs   2005-04-28 21:23:26 UTC (rev 
43748)
+++ trunk/cecil/lib/Mono.Cecil/VariantType.cs   2005-04-28 21:51:01 UTC (rev 
43749)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2004 DotNetGuru and the individuals listed
+ * on the ChangeLog entries.
+ *
+ * Authors :
+ *   Jb Evain   ([EMAIL PROTECTED])
+ *
+ * This is a free software distributed under a MIT/X11 license
+ * See LICENSE.MIT file for more details
+ *
+ *****************************************************************************/
+
+namespace Mono.Cecil {
+
+    public enum VariantType {
+        I2 = 2,
+        I4 = 3,
+        R4 = 4,
+        R8 = 5,
+        CY = 6,
+        DATE = 7,
+        BSTR = 8,
+        DISPATCH = 9,
+        ERROR = 10,
+        BOOL = 11,
+        VARIANT = 12,
+        UNKNOWN = 13,
+        DECIMAL = 14,
+        I1 = 16,
+        UI1 = 17,
+        UI2 = 18,
+        UI4 = 19,
+        INT = 22,
+        UINT = 23
+    }
+}

Modified: trunk/cecil/lib/Mono.Cecil.Signatures/MarshalSpec.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil.Signatures/MarshalSpec.cs        2005-04-28 
21:23:26 UTC (rev 43748)
+++ trunk/cecil/lib/Mono.Cecil.Signatures/MarshalSpec.cs        2005-04-28 
21:51:01 UTC (rev 43749)
@@ -12,36 +12,45 @@
 
 namespace Mono.Cecil.Signatures {
 
+    using System;
+
     using Mono.Cecil;
 
     internal class MarshalSpec {
 
         public NativeType NativeInstrinsic;
-        public MarshalSpecArray SpecArray;
+        public ValueType Spec;
 
-        public bool IsArray {
-            get { return this.NativeInstrinsic == NativeType.ARRAY; }
-        }
-
         public MarshalSpec (NativeType nt)
         {
             this.NativeInstrinsic = nt;
         }
 
-        internal struct MarshalSpecArray {
+        internal struct Array {
 
-            public NativeType NativeInstrinsic;
+            public NativeType ArrayElemType;
             public int ParamNum;
             public int ElemMult;
             public int NumElem;
+        }
 
-            public MarshalSpecArray (NativeType nt, int paramNum, int 
elemMult, int numElem)
-            {
-                this.NativeInstrinsic = nt;
-                this.ParamNum = paramNum;
-                this.ElemMult = elemMult;
-                this.NumElem = numElem;
-            }
+        internal struct CustomMarshaler {
+
+            public string Guid;
+            public string UnmanagedType;
+            public string ManagedType;
+            public string Cookie;
         }
+
+        internal struct FixedArray {
+
+            public int NumElem;
+            public NativeType ArrayElemType;
+        }
+
+        internal struct SafeArray {
+
+            public VariantType ArrayElemType;
+        }
     }
 }

Modified: trunk/cecil/lib/Mono.Cecil.Signatures/SignatureReader.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil.Signatures/SignatureReader.cs    2005-04-28 
21:23:26 UTC (rev 43748)
+++ trunk/cecil/lib/Mono.Cecil.Signatures/SignatureReader.cs    2005-04-28 
21:51:01 UTC (rev 43749)
@@ -749,13 +749,44 @@
         {
             int start;
             MarshalSpec ms = new MarshalSpec ((NativeType) 
Utilities.ReadCompressedInteger (data, 0, out start));
-            if (ms.IsArray) {
-                ms.SpecArray.NativeInstrinsic = (NativeType) 
Utilities.ReadCompressedInteger (data, start, out start);
-                ms.SpecArray.ParamNum = Utilities.ReadCompressedInteger (data, 
start, out start);
-                ms.SpecArray.ElemMult = Utilities.ReadCompressedInteger (data, 
start, out start);
-                ms.SpecArray.NumElem = Utilities.ReadCompressedInteger (data, 
start, out start);
+            switch (ms.NativeInstrinsic) {
+            case NativeType.ARRAY:
+                MarshalSpec.Array ar = new MarshalSpec.Array ();
+                ar.ArrayElemType = (NativeType) 
Utilities.ReadCompressedInteger (data, start, out start);
+                ar.ParamNum = Utilities.ReadCompressedInteger (data, start, 
out start);
+                ar.ElemMult = Utilities.ReadCompressedInteger (data, start, 
out start);
+                ar.NumElem = Utilities.ReadCompressedInteger (data, start, out 
start);
+                ms.Spec = ar;
+                break;
+            case NativeType.CUSTOMMARSHALER:
+                MarshalSpec.CustomMarshaler cm = new 
MarshalSpec.CustomMarshaler ();
+                cm.Guid = ReadUTF8String (data, start, out start);
+                cm.UnmanagedType = ReadUTF8String (data, start, out start);
+                cm.ManagedType = ReadUTF8String (data, start, out start);
+                cm.Cookie = ReadUTF8String (data, start, out start);
+                ms.Spec = cm;
+                break;
+            case NativeType.FIXEDARRAY:
+                MarshalSpec.FixedArray fa = new MarshalSpec.FixedArray ();
+                fa.NumElem = Utilities.ReadCompressedInteger (data, start, out 
start);
+                fa.ArrayElemType = (NativeType) 
Utilities.ReadCompressedInteger (data, start, out start);
+                ms.Spec = fa;
+                break;
+            case NativeType.SAFEARRAY:
+                MarshalSpec.SafeArray sa = new MarshalSpec.SafeArray ();
+                sa.ArrayElemType = (VariantType) 
Utilities.ReadCompressedInteger (data, start, out start);
+                ms.Spec = sa;
+                break;
             }
             return ms;
         }
+
+        private string ReadUTF8String (byte [] data, int pos, out int start)
+        {
+            int length = Utilities.ReadCompressedInteger (data, pos, out 
start);
+            byte [] str = new byte [length];
+            Buffer.BlockCopy (data, start, str, 0, length);
+            return Encoding.UTF8.GetString (str);
+        }
     }
 }

Modified: trunk/cecil/lib/Mono.Cecil.dll.sources
===================================================================
--- trunk/cecil/lib/Mono.Cecil.dll.sources      2005-04-28 21:23:26 UTC (rev 
43748)
+++ trunk/cecil/lib/Mono.Cecil.dll.sources      2005-04-28 21:51:01 UTC (rev 
43749)
@@ -28,6 +28,7 @@
 ./Mono.Cecil/IInterfaceCollection.cs
 ./Mono.Cecil/ILinkedResource.cs
 ./Mono.Cecil/ImageFormatException.cs
+./Mono.Cecil/IMarshalSpec.cs
 ./Mono.Cecil/IMember.cs
 ./Mono.Cecil/IMetadataScope.cs
 ./Mono.Cecil/IMethod.cs
@@ -77,6 +78,7 @@
 ./Mono.Cecil/ReflectionException.cs
 ./Mono.Cecil/SecurityAction.cs
 ./Mono.Cecil/TypeAttributes.cs
+./Mono.Cecil/VariantType.cs
 ./Mono.Cecil.Binary/CLIHeader.cs
 ./Mono.Cecil.Binary/DataDirectory.cs
 ./Mono.Cecil.Binary/DOSHeader.cs

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to