791941ba60a2a01d692bc3bd4b20c41bbb9cb707
[mono.git] / mcs / class / corlib / System.Reflection.Emit / ModuleBuilder.cs
1
2 //
3 // System.Reflection.Emit/ModuleBuilder.cs
4 //
5 // Author:
6 //   Paolo Molaro (lupus@ximian.com)
7 //
8 // (C) 2001 Ximian, Inc.  http://www.ximian.com
9 //
10
11 using System;
12 using System.Reflection;
13 using System.Runtime.CompilerServices;
14
15 namespace System.Reflection.Emit {
16         public class ModuleBuilder : Module {
17                 private TypeBuilder[] types;
18                 private int table_idx;
19                 internal AssemblyBuilder assemblyb;
20
21                 internal ModuleBuilder (AssemblyBuilder assb, string name, string fullyqname) {
22                         this.name = this.scopename = name;
23                         this.fqname = fullyqname;
24                         this.assemblyb = assb;
25                         table_idx = assb.get_next_table_index (0x00, true);
26                 }
27         
28                 public override string FullyQualifiedName {get { return fqname;}}
29
30                 public TypeBuilder DefineType (string name) {
31                         // FIXME: LAMESPEC: what other attributes should we use here as default?
32                         return DefineType (name, TypeAttributes.Public, typeof(object), null);
33                 }
34
35                 public TypeBuilder DefineType (string name, TypeAttributes attr) {
36                         return DefineType (name, attr, typeof(object), null);
37                 }
38
39                 public TypeBuilder DefineType (string name, TypeAttributes attr, Type parent) {
40                         return DefineType (name, attr, parent, null);
41                 }
42
43                 public TypeBuilder DefineType (string name, TypeAttributes attr, Type parent, Type[] interfaces) {
44                         TypeBuilder res = new TypeBuilder (this, name, attr, parent, interfaces);
45                         if (types != null) {
46                                 TypeBuilder[] new_types = new TypeBuilder [types.Length];
47                                 System.Array.Copy (types, new_types, types.Length);
48                                 new_types [types.Length] = res;
49                                 types = new_types;
50                         } else {
51                                 types = new TypeBuilder [1];
52                                 types [0] = res;
53                         }
54                         return res;
55                 }
56
57                 public TypeBuilder DefineType (string name, TypeAttributes attr, Type parent, int typesize) {
58                         return DefineType (name, attr, parent, null);
59                 }
60
61                 public TypeBuilder DefineType (string name, TypeAttributes attr, Type parent, PackingSize packsize) {
62                         return DefineType (name, attr, parent, null);
63                 }
64
65                 public TypeBuilder DefineType (string name, TypeAttributes attr, Type parent, PackingSize packsize, int typesize) {
66                         return DefineType (name, attr, parent, null);
67                 }
68
69         }
70 }