(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / corlib / System.Reflection.Emit / ParameterBuilder.cs
blobb7765488ba0569218d785b047147a249fe4fec8e
2 //
3 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
4 //
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:
12 //
13 // The above copyright notice and this permission notice shall be
14 // included in all copies or substantial portions of the Software.
15 //
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.
27 // System.Reflection.Emit/ParameterBuilder.cs
29 // Author:
30 // Paolo Molaro (lupus@ximian.com)
32 // (C) 2001 Ximian, Inc. http://www.ximian.com
35 using System;
36 using System.Reflection;
37 using System.Reflection.Emit;
38 using System.Globalization;
39 using System.Runtime.CompilerServices;
40 using System.Runtime.InteropServices;
42 namespace System.Reflection.Emit {
43 public class ParameterBuilder {
44 private MethodBase methodb; /* MethodBuilder or ConstructorBuilder */
45 private string name;
46 private CustomAttributeBuilder[] cattrs;
47 private UnmanagedMarshal marshal_info;
48 private ParameterAttributes attrs;
49 private int position;
50 private int table_idx;
51 object def_value;
53 internal ParameterBuilder (MethodBase mb, int pos, ParameterAttributes attributes, string strParamName) {
54 name = strParamName;
55 position = pos;
56 attrs = attributes;
57 methodb = mb;
58 table_idx = mb.get_next_table_index (this, 0x08, true);
61 public virtual int Attributes {
62 get {return (int)attrs;}
64 public bool IsIn {
65 get {return ((int)attrs & (int)ParameterAttributes.In) != 0;}
67 public bool IsOut {
68 get {return ((int)attrs & (int)ParameterAttributes.Out) != 0;}
70 public bool IsOptional {
71 get {return ((int)attrs & (int)ParameterAttributes.Optional) != 0;}
73 public virtual string Name {
74 get {return name;}
76 public virtual int Position {
77 get {return position;}
80 public virtual ParameterToken GetToken() {
81 return new ParameterToken (0x08 | table_idx);
84 public virtual void SetConstant (object defaultValue)
86 def_value = defaultValue;
87 attrs |= ParameterAttributes.HasDefault;
90 public void SetCustomAttribute( CustomAttributeBuilder customBuilder) {
91 string attrname = customBuilder.Ctor.ReflectedType.FullName;
92 if (attrname == "System.Runtime.InteropServices.InAttribute") {
93 attrs |= ParameterAttributes.In;
94 return;
95 } else if (attrname == "System.Runtime.InteropServices.OutAttribute") {
96 attrs |= ParameterAttributes.Out;
97 return;
98 } else if (attrname == "System.Runtime.InteropServices.OptionalAttribute") {
99 attrs |= ParameterAttributes.Optional;
100 return;
101 } else if (attrname == "System.Runtime.InteropServices.MarshalAsAttribute") {
102 marshal_info = CustomAttributeBuilder.get_umarshal (customBuilder, true);
103 /* FIXME: check for errors */
104 return;
106 if (cattrs != null) {
107 CustomAttributeBuilder[] new_array = new CustomAttributeBuilder [cattrs.Length + 1];
108 cattrs.CopyTo (new_array, 0);
109 new_array [cattrs.Length] = customBuilder;
110 cattrs = new_array;
111 } else {
112 cattrs = new CustomAttributeBuilder [1];
113 cattrs [0] = customBuilder;
116 public void SetCustomAttribute( ConstructorInfo con, byte[] binaryAttribute) {
117 SetCustomAttribute (new CustomAttributeBuilder (con, binaryAttribute));
120 public virtual void SetMarshal( UnmanagedMarshal unmanagedMarshal) {
121 marshal_info = unmanagedMarshal;
122 attrs |= ParameterAttributes.HasFieldMarshal;