~ubuntu-branches/ubuntu/dapper/ikvm/dapper

« back to all changes in this revision

Viewing changes to runtime/attributes.cs

  • Committer: Bazaar Package Importer
  • Author(s): John Goerzen
  • Date: 2004-08-26 10:18:19 UTC
  • Revision ID: james.westby@ubuntu.com-20040826101819-plz8au2mx4uk1cvc
Tags: upstream-0.8.0.0
ImportĀ upstreamĀ versionĀ 0.8.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  Copyright (C) 2002, 2003, 2004 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
using System.Reflection;
 
26
using System.Reflection.Emit;
 
27
 
 
28
[AttributeUsage(AttributeTargets.Class)]
 
29
public sealed class ExceptionIsUnsafeForMappingAttribute : Attribute
 
30
{
 
31
}
 
32
 
 
33
[AttributeUsage(AttributeTargets.Method)]
 
34
public sealed class RemappedInterfaceMethodAttribute : Attribute
 
35
{
 
36
        private string name;
 
37
        private string mappedTo;
 
38
 
 
39
        public RemappedInterfaceMethodAttribute(string name, string mappedTo)
 
40
        {
 
41
                this.name = name;
 
42
                this.mappedTo = mappedTo;
 
43
        }
 
44
 
 
45
        public string Name
 
46
        {
 
47
                get
 
48
                {
 
49
                        return name;
 
50
                }
 
51
        }
 
52
 
 
53
        public string MappedTo
 
54
        {
 
55
                get
 
56
                {
 
57
                        return mappedTo;
 
58
                }
 
59
        }
 
60
}
 
61
 
 
62
[AttributeUsage(AttributeTargets.Assembly)]
 
63
public sealed class RemappedClassAttribute : Attribute
 
64
{
 
65
        private string name;
 
66
        private Type remappedType;
 
67
 
 
68
        public RemappedClassAttribute(string name, Type remappedType)
 
69
        {
 
70
                this.name = name;
 
71
                this.remappedType = remappedType;
 
72
        }
 
73
 
 
74
        public string Name
 
75
        {
 
76
                get
 
77
                {
 
78
                        return name;
 
79
                }
 
80
        }
 
81
 
 
82
        public Type RemappedType
 
83
        {
 
84
                get
 
85
                {
 
86
                        return remappedType;
 
87
                }
 
88
        }
 
89
}
 
90
 
 
91
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)]
 
92
public sealed class RemappedTypeAttribute : Attribute
 
93
{
 
94
        private Type type;
 
95
 
 
96
        public RemappedTypeAttribute(Type type)
 
97
        {
 
98
                this.type = type;
 
99
        }
 
100
 
 
101
        public Type Type
 
102
        {
 
103
                get
 
104
                {
 
105
                        return type;
 
106
                }
 
107
        }
 
108
}
 
109
 
 
110
[AttributeUsage(AttributeTargets.Module)]
 
111
public sealed class JavaModuleAttribute : Attribute
 
112
{
 
113
}
 
114
 
 
115
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface | AttributeTargets.Assembly)]
 
116
public sealed class NoPackagePrefixAttribute : Attribute
 
117
{
 
118
}
 
119
 
 
120
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Method)]
 
121
public sealed class UnloadableTypeAttribute : Attribute
 
122
{
 
123
        private string name;
 
124
 
 
125
        public UnloadableTypeAttribute(string name)
 
126
        {
 
127
                this.name = name;
 
128
        }
 
129
 
 
130
        public string Name
 
131
        {
 
132
                get
 
133
                {
 
134
                        return name;
 
135
                }
 
136
        }
 
137
}
 
138
 
 
139
[AttributeUsage(AttributeTargets.Struct)]
 
140
public sealed class GhostInterfaceAttribute : Attribute
 
141
{
 
142
}
 
143
 
 
144
// Whenever the VM or compiler generates a helper class/method/field, it should be marked
 
145
// with this custom attribute, so that it can be hidden from Java reflection.
 
146
// NOTE when this attribute is applied to a class, it means that instances of this class
 
147
// will appear to be instances of the base class.
 
148
[AttributeUsage(AttributeTargets.All)]
 
149
public sealed class HideFromReflectionAttribute : Attribute
 
150
{
 
151
}
 
152
 
 
153
[Flags]
 
154
public enum Modifiers : ushort
 
155
{
 
156
        Public                  = 0x0001,
 
157
        Private                 = 0x0002,
 
158
        Protected               = 0x0004,
 
159
        Static                  = 0x0008,
 
160
        Final                   = 0x0010,
 
161
        Super                   = 0x0020,
 
162
        Synchronized    = 0x0020,
 
163
        Volatile                = 0x0040,
 
164
        Transient               = 0x0080,
 
165
        Native                  = 0x0100,
 
166
        Interface               = 0x0200,
 
167
        Abstract                = 0x0400,
 
168
        Strictfp                = 0x0800
 
169
}
 
170
 
 
171
[AttributeUsage(AttributeTargets.All)]
 
172
public sealed class ModifiersAttribute : Attribute
 
173
{
 
174
        private Modifiers modifiers;
 
175
 
 
176
        public ModifiersAttribute(Modifiers modifiers)
 
177
        {
 
178
                this.modifiers = modifiers;
 
179
        }
 
180
 
 
181
        public Modifiers Modifiers
 
182
        {
 
183
                get
 
184
                {
 
185
                        return modifiers;
 
186
                }
 
187
        }
 
188
}
 
189
 
 
190
[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method)]
 
191
public sealed class ThrowsAttribute : Attribute
 
192
{
 
193
        private string[] classes;
 
194
 
 
195
        // NOTE this is not CLS compliant, so maybe we should have a couple of overloads
 
196
        public ThrowsAttribute(string[] classes)
 
197
        {
 
198
                this.classes = classes;
 
199
        }
 
200
 
 
201
        // dotted Java class names (e.g. java.lang.Throwable)
 
202
        public string[] Classes
 
203
        {
 
204
                get
 
205
                {
 
206
                        return classes;
 
207
                }
 
208
        }
 
209
}
 
210
 
 
211
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)]
 
212
public sealed class ImplementsAttribute : Attribute
 
213
{
 
214
        private string[] interfaces;
 
215
 
 
216
        // NOTE this is not CLS compliant, so maybe we should have a couple of overloads
 
217
        public ImplementsAttribute(string[] interfaces)
 
218
        {
 
219
                this.interfaces = interfaces;
 
220
        }
 
221
 
 
222
        public string[] Interfaces
 
223
        {
 
224
                get
 
225
                {
 
226
                        return interfaces;
 
227
                }
 
228
        }
 
229
}
 
230
 
 
231
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)]
 
232
public sealed class InnerClassAttribute : Attribute
 
233
{
 
234
        private string innerClassName;
 
235
        private string outerClassName;
 
236
        private string name;
 
237
        private Modifiers modifiers;
 
238
 
 
239
        public InnerClassAttribute(string innerClassName, string outerClassName, string name, Modifiers modifiers)
 
240
        {
 
241
                this.innerClassName = innerClassName;
 
242
                this.outerClassName = outerClassName;
 
243
                this.name = name;
 
244
                this.modifiers = modifiers;
 
245
        }
 
246
 
 
247
        public string InnerClassName
 
248
        {
 
249
                get
 
250
                {
 
251
                        return innerClassName;
 
252
                }
 
253
        }
 
254
 
 
255
        public string OuterClassName
 
256
        {
 
257
                get
 
258
                {
 
259
                        return OuterClassName;
 
260
                }
 
261
        }
 
262
 
 
263
        // NOTE returns null for anonymous inner classes
 
264
        public string Name
 
265
        {
 
266
                get
 
267
                {
 
268
                        return name;
 
269
                }
 
270
        }
 
271
 
 
272
        public Modifiers Modifiers
 
273
        {
 
274
                get
 
275
                {
 
276
                        return modifiers;
 
277
                }
 
278
        }
 
279
}