public static InterfaceGen CreateInterface(XElement pkg, XElement elem, CodeGenerationOptions options) { var iface = new InterfaceGen(CreateGenBaseSupport(pkg, elem, true)) { ArgsType = elem.XGetAttribute("argsType"), HasManagedName = elem.Attribute("managedName") != null, NoAlternatives = elem.XGetAttribute("no-alternatives") == "true", // Only use an explicitly set XML attribute Unnest = elem.XGetAttribute("unnest") == "true" ? true : elem.XGetAttribute("unnest") == "false" ? false : !options.SupportNestedInterfaceTypes }; FillApiSince(iface, pkg, elem); SetLineInfo(iface, elem, options); foreach (var child in elem.Elements()) { switch (child.Name.LocalName) { case "implements": string iname = child.XGetAttribute("name-generic-aware"); iname = iname.Length > 0 ? iname : child.XGetAttribute("name"); iface.AddImplementedInterface(iname); break; case "method": if (child.XGetAttribute("visibility") != "kotlin-internal") { iface.AddMethod(CreateMethod(iface, child, options)); } break; case "field": if (child.XGetAttribute("visibility") != "kotlin-internal") { iface.AddField(CreateField(iface, child, options)); } break; case "typeParameters": break; // handled at GenBaseSupport default: Report.LogCodedWarning(0, Report.WarningUnexpectedInterfaceChild, iface, child.ToString()); break; } } return(iface); }
public static InterfaceGen CreateInterface(XElement pkg, XElement elem) { var iface = new InterfaceGen(CreateGenBaseSupport(pkg, elem, true)) { ArgsType = elem.XGetAttribute("argsType"), HasManagedName = elem.Attribute("managedName") != null }; foreach (var child in elem.Elements()) { switch (child.Name.LocalName) { case "implements": string iname = child.XGetAttribute("name-generic-aware"); iname = iname.Length > 0 ? iname : child.XGetAttribute("name"); iface.AddImplementedInterface(iname); break; case "method": iface.AddMethod(CreateMethod(iface, child)); break; case "field": iface.AddField(CreateField(child)); break; case "typeParameters": break; // handled at GenBaseSupport default: Report.Warning(0, Report.WarningInterfaceGen + 0, "unexpected interface child {0}.", child); break; } } return(iface); }
public static InterfaceGen CreateInterface(TypeDefinition t, CodeGenerationOptions opt) { var iface = new InterfaceGen(CreateGenBaseSupport(t, opt)) { IsShallow = opt.UseShallowReferencedTypes, }; foreach (var ifaceImpl in t.Interfaces) { iface.AddImplementedInterface(ifaceImpl.InterfaceType.FullNameCorrected()); } Action populate = () => { foreach (var m in t.Methods) { if (m.IsPrivate || m.IsAssembly || GetRegisterAttribute(m.CustomAttributes) == null) { continue; } iface.AddMethod(CreateMethod(iface, m)); } }; if (iface.IsShallow) { iface.PopulateAction = populate; } else { populate(); } iface.MayHaveManagedGenericArguments = !iface.IsAcw; return(iface); }