protected virtual void CreateAdapterMethods(ClassDefinition cls)
{
foreach (SupertypingAdapter adapter in cls.Adapters) {
adapter.AdapteeField =
adapter.TypeBuilder.DefineField("__adaptee",
adapter.AdapteeType.RawType,
FieldAttributes.Private);
Type[] types = new Type[] { adapter.AdapteeType.RawType };
adapter.Constructor =
DefineConstructor(adapter.TypeBuilder,
MethodAttributes.Public,
CallingConventions.Standard,
types);
ArrayList adapteeMethods =
adapter.AdapteeType.Methods;
ArrayList supertypeMethods =
adapter.TypeData.AncestorMethods;
foreach (MethodData adapteeMethod in adapteeMethods) {
ArrayList conformableMethods =
CheckMethodConformance(adapteeMethod, supertypeMethods);
foreach (MethodData m in conformableMethods) {
AddAdapterMethod(adapter,
m.MethodInfo,
adapteeMethod.MethodInfo);
}
}
TypeData builtinMethodContainer =
typeManager.GetBuiltinMethodContainer(adapter.AdapteeType);
if (builtinMethodContainer != null) {
ArrayList adapteeBuiltinMethods =
builtinMethodContainer.Methods;
foreach (MethodData adapteeMethod in adapteeBuiltinMethods) {
ArrayList conformableMethods =
CheckMethodConformance(adapteeMethod,
supertypeMethods);
foreach (MethodData m in conformableMethods) {
AddAdapterMethod(adapter,
m.MethodInfo,
adapteeMethod.MethodInfo);
}
}
}
foreach (MethodData method in supertypeMethods) {
report.Error(cls.Location,
"no implementation for {0} in {1}",
method, adapter.AdapteeType.FullName);
}
}
}