33ce936f2e2c956fb3f3c49817a149e34df53ea1
[mono.git] / interface.cs
1 //
2 // interface.cs: Interface handler
3 //
4 // Author: Miguel de Icaza (miguel@gnu.org)
5 //                 Anirban Bhattacharjee (banirban@novell.com)
6 //
7 // Licensed under the terms of the GNU GPL
8 //
9 // (C) 2001 Ximian, Inc (http://www.ximian.com)
10 //
11
12 /*This file will go off shortly
13  * after copying the interface class 
14  * in class.cs file
15  */
16
17 #define CACHE
18 using System.Collections;
19 using System;
20 using System.IO;
21 using System.Reflection;
22 using System.Reflection.Emit;
23
24 namespace Mono.MonoBASIC {
25
26         /// <summary>
27         ///   Interfaces
28         /// </summary>
29
30
31         /// <summary>
32         ///   Interfaces
33         /// </summary>
34         public class Interface : Mono.MonoBASIC.Class /*TypeContainer , IMemberContainer */\r
35         {
36                 /// <summary>
37                 ///   Modifiers allowed in a class declaration
38                 /// </summary>
39                 public new const int AllowedModifiers =
40                         Modifiers.NEW       |
41                         Modifiers.PUBLIC    |
42                         Modifiers.PROTECTED |
43                         Modifiers.INTERNAL  |
44                         Modifiers.PRIVATE;
45
46                 public Interface (TypeContainer parent, string name, int mod,
47                                                         Attributes attrs, Location l)
48                         : base (parent, name, 0, null, l)
49                 {
50                         int accmods;
51
52                         if (parent.Parent == null)
53                                 accmods = Modifiers.INTERNAL;
54                         else
55                                 accmods = Modifiers.PUBLIC;
56
57                         this.ModFlags = Modifiers.Check (AllowedModifiers, mod, accmods, l);
58                         this.ModFlags |= Modifiers.ABSTRACT;
59                         this.attributes = attrs;
60                 }
61
62                 /*public override AttributeTargets AttributeTargets \r
63                 {
64                         get \r
65                         {
66                                 return AttributeTargets.Interface;
67                         }
68                 }*/
69
70                 public override TypeAttributes TypeAttr \r
71                 {
72                         get \r
73                         {
74                                 return base.TypeAttr |
75                                         TypeAttributes.AutoLayout |
76                                         TypeAttributes.Abstract |
77                                         TypeAttributes.Interface;
78                         }
79                 }
80         }
81
82 /*
83         public class InterfaceMemberBase {
84                 public readonly string Name;
85                 public readonly bool IsNew;
86                 public Attributes OptAttributes;
87                 
88                 public InterfaceMemberBase (string name, bool is_new, Attributes attrs)
89                 {
90                         Name = name;
91                         IsNew = is_new;
92                         OptAttributes = attrs;
93                 }
94         }
95         
96         public class InterfaceProperty : InterfaceMemberBase {
97                 public readonly bool HasSet;
98                 public readonly bool HasGet;
99                 public readonly Location Location;
100                 public Expression Type;
101                 
102                 public InterfaceProperty (Expression type, string name,
103                                           bool is_new, bool has_get, bool has_set,
104                                           Attributes attrs, Location loc)
105                         : base (name, is_new, attrs)
106                 {
107                         Type = type;
108                         HasGet = has_get;
109                         HasSet = has_set;
110                         Location = loc;
111                 }
112         }
113 */
114 /*      public class InterfaceEvent : InterfaceMemberBase {
115                 public readonly Location Location;
116                 public Expression Type;
117                 
118                 public InterfaceEvent (Expression type, string name, bool is_new, Attributes attrs,
119                                        Location loc)
120                         : base (name, is_new, attrs)
121                 {
122                         Type = type;
123                         Location = loc;
124                 }
125         }
126 /*      
127         public class InterfaceMethod : InterfaceMemberBase {
128                 public readonly Expression ReturnType;
129                 public readonly Parameters Parameters;
130                 public readonly Location Location;
131                 
132                 public InterfaceMethod (Expression return_type, string name, bool is_new, Parameters args,
133                                         Attributes attrs, Location l)
134                         : base (name, is_new, attrs)
135                 {
136                         this.ReturnType = return_type;
137                         this.Parameters = args;
138                         Location = l;
139                 }
140
141                 /// <summary>
142                 ///   Returns the signature for this interface method
143                 /// </summary>
144                 public string GetSignature (DeclSpace ds)
145                 {
146                         Type ret = ds.ResolveType (ReturnType, false, Location);
147                         string args = Parameters.GetSignature (ds);
148
149                         if ((ret == null) || (args == null))
150                                 return null;
151                         
152                         return (IsNew ? "new-" : "") + ret.FullName + "(" + args + ")";
153                 }
154
155                 public Type [] ParameterTypes (DeclSpace ds)
156                 {
157                         return Parameters.GetParameterInfo (ds);
158                 }
159         }
160
161         public class InterfaceIndexer : InterfaceMemberBase {
162                 public readonly bool HasGet, HasSet;
163                 public readonly Parameters Parameters;
164                 public readonly Location Location;
165                 public Expression Type;
166                 
167                 public InterfaceIndexer (Expression type, Parameters args, bool do_get, bool do_set,
168                                          bool is_new, Attributes attrs, Location loc)
169                         : base ("", is_new, attrs)
170                 {
171                         Type = type;
172                         Parameters = args;
173                         HasGet = do_get;
174                         HasSet = do_set;
175                         Location = loc;
176                 }
177
178                 public Type [] ParameterTypes (DeclSpace ds)
179                 {
180                         return Parameters.GetParameterInfo (ds);
181                 }
182         }*/
183 }