5 // Jackson Harper (Jackson@LatitudeGeo.com)
7 // (C) 2003 Jackson Harper, All right reserved
12 using System.Collections;
14 namespace Mono.ILASM {
16 public class EventDef : ICustomAttrTarget {
18 private FeatureAttr attr;
20 private BaseTypeRef type;
21 private PEAPI.Event event_def;
22 private bool is_resolved;
23 private ArrayList customattr_list;
25 private MethodRef addon;
26 private MethodRef fire;
27 private ArrayList other_list;
28 private MethodRef removeon;
30 public EventDef (FeatureAttr attr, BaseTypeRef type, string name)
38 public void AddCustomAttribute (CustomAttr customattr)
40 if (customattr_list == null)
41 customattr_list = new ArrayList ();
43 customattr_list.Add (customattr);
46 public PEAPI.Event Resolve (CodeGen code_gen, PEAPI.ClassDef classdef)
51 type.Resolve (code_gen);
52 event_def = classdef.AddEvent (name, type.PeapiType);
54 if ((attr & FeatureAttr.Rtspecialname) != 0)
55 event_def.SetRTSpecialName ();
57 if ((attr & FeatureAttr.Specialname) != 0)
58 event_def.SetSpecialName ();
60 if (customattr_list != null)
61 foreach (CustomAttr customattr in customattr_list)
62 customattr.AddTo (code_gen, event_def);
69 private PEAPI.MethodDef AsMethodDef (PEAPI.Method method, string type)
71 PEAPI.MethodDef methoddef = method as PEAPI.MethodDef;
72 if (methoddef == null)
73 Report.Error (type + " method of event " + name + " not found");
77 public void Define (CodeGen code_gen, PEAPI.ClassDef classdef)
80 Resolve (code_gen, classdef);
83 addon.Resolve (code_gen);
84 event_def.AddAddon (AsMethodDef (addon.PeapiMethod, "addon"));
88 fire.Resolve (code_gen);
89 event_def.AddFire (AsMethodDef (fire.PeapiMethod, "fire"));
92 if (other_list != null) {
93 foreach (MethodRef otherm in other_list) {
94 otherm.Resolve (code_gen);
95 event_def.AddOther (AsMethodDef (otherm.PeapiMethod, "other"));
99 if (removeon != null) {
100 removeon.Resolve (code_gen);
101 event_def.AddRemoveOn (AsMethodDef (removeon.PeapiMethod, "removeon"));
105 public void AddAddon (MethodRef method_ref)
110 public void AddFire (MethodRef method_ref)
115 public void AddOther (MethodRef method_ref)
117 if (other_list == null)
118 other_list = new ArrayList ();
119 other_list.Add (method_ref);
122 public void AddRemoveon (MethodRef method_ref)
124 removeon = method_ref;