- Fixed baseline aligning calcs
[mono.git] / mcs / mbas / 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 */
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, attrs, 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                 }
60
61                 public override AttributeTargets AttributeTargets {
62                         get {
63                                 return AttributeTargets.Interface;
64                         }
65                 }
66
67                 public override TypeAttributes TypeAttr 
68                 {
69                         get 
70                         {
71                                 return base.TypeAttr |
72                                         TypeAttributes.AutoLayout |
73                                         TypeAttributes.Abstract |
74                                         TypeAttributes.Interface;
75                         }
76                 }
77         }
78
79 /*
80         public class InterfaceMemberBase {
81                 public readonly string Name;
82                 public readonly bool IsNew;
83                 public Attributes OptAttributes;
84                 
85                 public InterfaceMemberBase (string name, bool is_new, Attributes attrs)
86                 {
87                         Name = name;
88                         IsNew = is_new;
89                         OptAttributes = attrs;
90                 }
91         }
92         
93         public class InterfaceProperty : InterfaceMemberBase {
94                 public readonly bool HasSet;
95                 public readonly bool HasGet;
96                 public readonly Location Location;
97                 public Expression Type;
98                 
99                 public InterfaceProperty (Expression type, string name,
100                                           bool is_new, bool has_get, bool has_set,
101                                           Attributes attrs, Location loc)
102                         : base (name, is_new, attrs)
103                 {
104                         Type = type;
105                         HasGet = has_get;
106                         HasSet = has_set;
107                         Location = loc;
108                 }
109         }
110 */
111 /*      public class InterfaceEvent : InterfaceMemberBase {
112                 public readonly Location Location;
113                 public Expression Type;
114                 
115                 public InterfaceEvent (Expression type, string name, bool is_new, Attributes attrs,
116                                        Location loc)
117                         : base (name, is_new, attrs)
118                 {
119                         Type = type;
120                         Location = loc;
121                 }
122         }
123 /*      
124         public class InterfaceMethod : InterfaceMemberBase {
125                 public readonly Expression ReturnType;
126                 public readonly Parameters Parameters;
127                 public readonly Location Location;
128                 
129                 public InterfaceMethod (Expression return_type, string name, bool is_new, Parameters args,
130                                         Attributes attrs, Location l)
131                         : base (name, is_new, attrs)
132                 {
133                         this.ReturnType = return_type;
134                         this.Parameters = args;
135                         Location = l;
136                 }
137
138                 /// <summary>
139                 ///   Returns the signature for this interface method
140                 /// </summary>
141                 public string GetSignature (DeclSpace ds)
142                 {
143                         Type ret = ds.ResolveType (ReturnType, false, Location);
144                         string args = Parameters.GetSignature (ds);
145
146                         if ((ret == null) || (args == null))
147                                 return null;
148                         
149                         return (IsNew ? "new-" : "") + ret.FullName + "(" + args + ")";
150                 }
151
152                 public Type [] ParameterTypes (DeclSpace ds)
153                 {
154                         return Parameters.GetParameterInfo (ds);
155                 }
156         }
157
158         public class InterfaceIndexer : InterfaceMemberBase {
159                 public readonly bool HasGet, HasSet;
160                 public readonly Parameters Parameters;
161                 public readonly Location Location;
162                 public Expression Type;
163                 
164                 public InterfaceIndexer (Expression type, Parameters args, bool do_get, bool do_set,
165                                          bool is_new, Attributes attrs, Location loc)
166                         : base ("", is_new, attrs)
167                 {
168                         Type = type;
169                         Parameters = args;
170                         HasGet = do_get;
171                         HasSet = do_set;
172                         Location = loc;
173                 }
174
175                 public Type [] ParameterTypes (DeclSpace ds)
176                 {
177                         return Parameters.GetParameterInfo (ds);
178                 }
179         }*/
180 }