Merged pull request #58 from XTZGZoReX/master.
[mono.git] / mcs / class / IKVM.Reflection / Emit / ConstructorBuilder.cs
1 /*
2   Copyright (C) 2008 Jeroen Frijters
3
4   This software is provided 'as-is', without any express or implied
5   warranty.  In no event will the authors be held liable for any damages
6   arising from the use of this software.
7
8   Permission is granted to anyone to use this software for any purpose,
9   including commercial applications, and to alter it and redistribute it
10   freely, subject to the following restrictions:
11
12   1. The origin of this software must not be misrepresented; you must not
13      claim that you wrote the original software. If you use this software
14      in a product, an acknowledgment in the product documentation would be
15      appreciated but is not required.
16   2. Altered source versions must be plainly marked as such, and must not be
17      misrepresented as being the original software.
18   3. This notice may not be removed or altered from any source distribution.
19
20   Jeroen Frijters
21   jeroen@frijters.net
22   
23 */
24 using System;
25
26 namespace IKVM.Reflection.Emit
27 {
28         public sealed class ConstructorBuilder : ConstructorInfo
29         {
30                 private readonly MethodBuilder methodBuilder;
31
32                 internal ConstructorBuilder(MethodBuilder mb)
33                 {
34                         this.methodBuilder = mb;
35                 }
36
37                 public override bool Equals(object obj)
38                 {
39                         ConstructorBuilder other = obj as ConstructorBuilder;
40                         return other != null && other.methodBuilder.Equals(methodBuilder);
41                 }
42
43                 public override int GetHashCode()
44                 {
45                         return methodBuilder.GetHashCode();
46                 }
47
48                 public void __SetSignature(Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
49                 {
50                         methodBuilder.SetSignature(returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers);
51                 }
52
53                 public ParameterBuilder DefineParameter(int position, ParameterAttributes attributes, string strParamName)
54                 {
55                         return methodBuilder.DefineParameter(position, attributes, strParamName);
56                 }
57
58                 public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
59                 {
60                         methodBuilder.SetCustomAttribute(customBuilder);
61                 }
62
63                 public void SetCustomAttribute(ConstructorInfo con,     byte[] binaryAttribute)
64                 {
65                         methodBuilder.SetCustomAttribute(con, binaryAttribute);
66                 }
67
68                 public void __AddDeclarativeSecurity(CustomAttributeBuilder customBuilder)
69                 {
70                         methodBuilder.__AddDeclarativeSecurity(customBuilder);
71                 }
72
73                 public void AddDeclarativeSecurity(System.Security.Permissions.SecurityAction securityAction, System.Security.PermissionSet permissionSet)
74                 {
75                         methodBuilder.AddDeclarativeSecurity(securityAction, permissionSet);
76                 }
77
78                 public void SetImplementationFlags(MethodImplAttributes attributes)
79                 {
80                         methodBuilder.SetImplementationFlags(attributes);
81                 }
82
83                 public ILGenerator GetILGenerator()
84                 {
85                         return methodBuilder.GetILGenerator();
86                 }
87
88                 public ILGenerator GetILGenerator(int streamSize)
89                 {
90                         return methodBuilder.GetILGenerator(streamSize);
91                 }
92
93                 public void __ReleaseILGenerator()
94                 {
95                         methodBuilder.__ReleaseILGenerator();
96                 }
97
98                 public override CallingConventions CallingConvention
99                 {
100                         get { return methodBuilder.CallingConvention; }
101                 }
102
103                 public override MethodAttributes Attributes
104                 {
105                         get { return methodBuilder.Attributes; }
106                 }
107
108                 public override MethodImplAttributes GetMethodImplementationFlags()
109                 {
110                         return methodBuilder.GetMethodImplementationFlags();
111                 }
112
113                 public Type ReturnType
114                 {
115                         get { return methodBuilder.ReturnType; }
116                 }
117
118                 internal override int ParameterCount
119                 {
120                         get { return methodBuilder.ParameterCount; }
121                 }
122
123                 public override Type DeclaringType
124                 {
125                         get { return methodBuilder.DeclaringType; }
126                 }
127
128                 public override string Name
129                 {
130                         get { return methodBuilder.Name; }
131                 }
132
133                 public override int MetadataToken
134                 {
135                         get { return methodBuilder.MetadataToken; }
136                 }
137
138                 public override Module Module
139                 {
140                         get { return methodBuilder.Module; }
141                 }
142
143                 public Module GetModule()
144                 {
145                         return methodBuilder.GetModule();
146                 }
147
148                 public MethodToken GetToken()
149                 {
150                         return methodBuilder.GetToken();
151                 }
152
153                 public override MethodBody GetMethodBody()
154                 {
155                         return methodBuilder.GetMethodBody();
156                 }
157
158                 public bool InitLocals
159                 {
160                         get { return methodBuilder.InitLocals; }
161                         set { methodBuilder.InitLocals = value; }
162                 }
163
164                 internal override MethodInfo GetMethodInfo()
165                 {
166                         return methodBuilder;
167                 }
168
169                 internal override MethodInfo GetMethodOnTypeDefinition()
170                 {
171                         return methodBuilder;
172                 }
173
174                 internal override MethodSignature MethodSignature
175                 {
176                         get { return methodBuilder.MethodSignature; }
177                 }
178
179                 internal override int ImportTo(ModuleBuilder module)
180                 {
181                         return module.ImportMember(methodBuilder);
182                 }
183         }
184 }