3 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
5 // Permission is hereby granted, free of charge, to any person obtaining
6 // a copy of this software and associated documentation files (the
7 // "Software"), to deal in the Software without restriction, including
8 // without limitation the rights to use, copy, modify, merge, publish,
9 // distribute, sublicense, and/or sell copies of the Software, and to
10 // permit persons to whom the Software is furnished to do so, subject to
11 // the following conditions:
13 // The above copyright notice and this permission notice shall be
14 // included in all copies or substantial portions of the Software.
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 // System.Reflection.Emit/SignatureHelper.cs
29 // Paolo Molaro (lupus@ximian.com)
31 // (C) 2001 Ximian, Inc. http://www.ximian.com
35 using System
.Reflection
;
36 using System
.Reflection
.Emit
;
37 using System
.Globalization
;
38 using System
.Runtime
.CompilerServices
;
39 using System
.Runtime
.InteropServices
;
41 namespace System
.Reflection
.Emit
{
44 [ComDefaultInterface (typeof (_SignatureHelper
))]
46 [ClassInterface (ClassInterfaceType
.None
)]
47 public sealed class SignatureHelper
: _SignatureHelper
{
48 internal enum SignatureHelperType
{
55 private ModuleBuilder module
;
56 private Type
[] arguments
;
57 private SignatureHelperType type
;
58 private Type returnType
;
59 private CallingConventions callConv
;
60 private CallingConvention unmanagedCallConv
;
62 internal SignatureHelper (ModuleBuilder module
, SignatureHelperType type
)
68 public static SignatureHelper
GetFieldSigHelper (Module mod
)
70 if (!(mod
is ModuleBuilder
))
71 throw new NotImplementedException ();
73 return new SignatureHelper ((ModuleBuilder
) mod
, SignatureHelperType
.HELPER_FIELD
);
76 public static SignatureHelper
GetLocalVarSigHelper (Module mod
)
78 if (!(mod
is ModuleBuilder
))
79 throw new NotImplementedException ();
81 return new SignatureHelper ((ModuleBuilder
) mod
, SignatureHelperType
.HELPER_LOCAL
);
84 public static SignatureHelper
GetMethodSigHelper( Module mod
, CallingConventions callingConvention
, Type returnType
)
86 return GetMethodSigHelper (mod
, callingConvention
, (CallingConvention
)0, returnType
, null);
89 public static SignatureHelper
GetMethodSigHelper( Module mod
, CallingConvention unmanagedCallingConvention
, Type returnType
)
91 return GetMethodSigHelper (mod
, CallingConventions
.Standard
, unmanagedCallingConvention
, returnType
, null);
94 public static SignatureHelper
GetMethodSigHelper( Module mod
, Type returnType
, Type
[] parameterTypes
)
96 return GetMethodSigHelper (mod
, CallingConventions
.Standard
,
97 (CallingConvention
)0, returnType
,
100 [MonoTODO("Not implemented")]
101 public static SignatureHelper
GetPropertySigHelper( Module mod
, Type returnType
, Type
[] parameterTypes
)
103 throw new NotImplementedException ();
106 public void AddArgument (Type clsArgument
)
108 if (arguments
!= null) {
109 Type
[] new_a
= new Type
[arguments
.Length
+ 1];
110 System
.Array
.Copy (arguments
, new_a
, arguments
.Length
);
111 new_a
[arguments
.Length
] = clsArgument
;
114 arguments
= new Type
[1];
115 arguments
[0] = clsArgument
;
119 [MonoTODO("Not implemented")]
120 public void AddSentinel ()
122 throw new NotImplementedException ();
125 [MonoTODO("Not implemented")]
126 public override bool Equals (object obj
)
128 throw new NotImplementedException ();
131 [MonoTODO("Not implemented")]
132 public override int GetHashCode ()
134 throw new NotImplementedException ();
137 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
138 internal extern byte[] get_signature_local ();
140 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
141 internal extern byte[] get_signature_field ();
143 public byte[] GetSignature ()
146 case SignatureHelperType
.HELPER_LOCAL
:
147 return get_signature_local ();
148 case SignatureHelperType
.HELPER_FIELD
:
149 return get_signature_field ();
151 throw new NotImplementedException ();
155 public override string ToString() {
156 return "SignatureHelper";
159 internal static SignatureHelper
GetMethodSigHelper( Module mod
, CallingConventions callConv
, CallingConvention unmanagedCallConv
, Type returnType
,
162 if (!(mod
is ModuleBuilder
))
163 throw new NotImplementedException ();
165 SignatureHelper helper
=
166 new SignatureHelper ((ModuleBuilder
)mod
, SignatureHelperType
.HELPER_METHOD
);
167 helper
.returnType
= returnType
;
168 helper
.callConv
= callConv
;
169 helper
.unmanagedCallConv
= unmanagedCallConv
;
171 if (parameters
!= null) {
172 helper
.arguments
= new Type
[parameters
.Length
];
173 for (int i
= 0; i
< parameters
.Length
; ++i
)
174 helper
.arguments
[i
] = parameters
[i
];
180 void _SignatureHelper
.GetIDsOfNames([In
] ref Guid riid
, IntPtr rgszNames
, uint cNames
, uint lcid
, IntPtr rgDispId
)
182 throw new NotImplementedException ();
185 void _SignatureHelper
.GetTypeInfo (uint iTInfo
, uint lcid
, IntPtr ppTInfo
)
187 throw new NotImplementedException ();
190 void _SignatureHelper
.GetTypeInfoCount (out uint pcTInfo
)
192 throw new NotImplementedException ();
195 void _SignatureHelper
.Invoke (uint dispIdMember
, [In
] ref Guid riid
, uint lcid
, short wFlags
, IntPtr pDispParams
, IntPtr pVarResult
, IntPtr pExcepInfo
, IntPtr puArgErr
)
197 throw new NotImplementedException ();