2003-12-08 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / corlib / System.Reflection.Emit / SignatureHelper.cs
index 34974bbd38782a9c3a89f0e6d6b3362e6b362de4..21332ceccbaf0635970b0bd17839b261e02c251c 100755 (executable)
@@ -16,6 +16,7 @@ using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
 namespace System.Reflection.Emit {
+
        public sealed class SignatureHelper {
                internal enum SignatureHelperType {
                        HELPER_FIELD,
@@ -27,6 +28,9 @@ namespace System.Reflection.Emit {
                private ModuleBuilder module;
                private Type[] arguments;
                private SignatureHelperType type;
+               private Type returnType;
+               private CallingConventions callConv;
+               private CallingConvention unmanagedCallConv;
 
                internal SignatureHelper (ModuleBuilder module, SignatureHelperType type)
                {
@@ -41,6 +45,7 @@ namespace System.Reflection.Emit {
 
                        return new SignatureHelper ((ModuleBuilder) mod, SignatureHelperType.HELPER_FIELD);
                }
+
                public static SignatureHelper GetLocalVarSigHelper (Module mod)
                {
                        if (!(mod is ModuleBuilder))
@@ -48,21 +53,29 @@ namespace System.Reflection.Emit {
 
                        return new SignatureHelper ((ModuleBuilder) mod, SignatureHelperType.HELPER_LOCAL);
                }
-               [MonoTODO]
+
                public static SignatureHelper GetMethodSigHelper( Module mod, CallingConventions callingConvention, Type returnType)
                {
-                       throw new NotImplementedException ();
+                       return GetMethodSigHelper (mod, callingConvention, (CallingConvention)0, returnType, null);
                }
-               [MonoTODO]
+
+               public static SignatureHelper GetMethodSigHelper( Module mod, CallingConvention unmanagedCallingConvention, Type returnType)
+               {
+                       return GetMethodSigHelper (mod, CallingConventions.Standard, unmanagedCallingConvention, returnType, null);
+               }
+
                public static SignatureHelper GetMethodSigHelper( Module mod, Type returnType, Type[] parameterTypes)
                {
-                       throw new NotImplementedException ();
+                       return GetMethodSigHelper (mod, CallingConventions.Standard, 
+                                                                          (CallingConvention)0, returnType, 
+                                                                          parameterTypes);
                }
                [MonoTODO]
                public static SignatureHelper GetPropertySigHelper( Module mod, Type returnType, Type[] parameterTypes)
                {
                        throw new NotImplementedException ();
                }
+
                public void AddArgument (Type clsArgument)
                {
                        if (arguments != null) {
@@ -113,6 +126,26 @@ namespace System.Reflection.Emit {
                        return "SignatureHelper";
                }
 
+               internal static SignatureHelper GetMethodSigHelper( Module mod, CallingConventions callConv, CallingConvention unmanagedCallConv, Type returnType,
+                                                                                                                  Type [] parameters)
+               {
+                       if (!(mod is ModuleBuilder))
+                               throw new NotImplementedException ();
+
+                       SignatureHelper helper = 
+                               new SignatureHelper ((ModuleBuilder)mod, SignatureHelperType.HELPER_METHOD);
+                       helper.returnType = returnType;
+                       helper.callConv = callConv;
+                       helper.unmanagedCallConv = unmanagedCallConv;
+
+                       if (parameters != null) {
+                               helper.arguments = new Type [parameters.Length];
+                               for (int i = 0; i < parameters.Length; ++i)
+                                       helper.arguments [i] = parameters [i];
+                       }
+
+                       return helper;
+               }
 
 
        }