// Checks protocol methods before protocol. private bool DoPriorProtocolHasMethod(NativeProtocol protocol, string mname, bool isClass) { bool has = false; for (int i = 0; i < m_interface.Protocols.Length && m_interface.Protocols[i] != protocol.Name && !has; ++i) { NativeProtocol p = m_objects.FindProtocol(m_interface.Protocols[i]); if (p.Methods.Count > 0) has = p.Methods.Any(m => m.Name == mname && m.IsClass == isClass); } return has; }
// Protocol := Deprecated? Availability? '@protocol' C Identifier ProtocolList? InterfaceMember* '@end' C; private void DoAnalyzeProtocol(XmlNode node) { string deprecated = DoFindDeprecated(node); XmlNode identifier = DoFind(node, "Identifier"); XmlNode protocolsNode = DoFind(node, "IdentifierList"); // the ProtocolList returns the IdentifierList instead of itself string[] protocols = protocolsNode != null ? DoAnalyzeIdentifierList(protocolsNode) : new string[0]; var protocol = new NativeProtocol{Name = identifier.InnerText, Protocols = protocols}; foreach (XmlNode child in node.ChildNodes) { if ("InterfaceMember" == child.Name) { NativeMethod method = DoAnalyzeInterfaceMember(child, deprecated); if (method != null) protocol.Add(method); } } m_objects.AddProtocol(protocol); }
private bool DoGenerateMethod(NativeMethod nm, bool writeBlank, NativeProtocol protocol) { bool wrote = false; bool defined = false; if (protocol != null) { defined = DoPriorProtocolHasMethod(protocol, nm.Name, nm.IsClass); if (!defined) defined = DoInterfaceHasMethod(nm.Name, nm.IsClass); if (!defined) defined = DoBaseHasMethod(m_interface.BaseName, nm.Name, nm.IsClass); } else if (m_interface.Category != null) { if (m_objects.EmittedType(m_interface.Name)) { defined = DoInterfaceHasMethod(nm.Name, nm.IsClass); if (!defined) { NativeInterface ri = m_objects.FindInterface(m_interface.Name); defined = DoBaseHasMethod(ri.BaseName, nm.Name, nm.IsClass); } } } else { defined = DoBaseHasMethod(m_interface.BaseName, nm.Name, nm.IsClass); } if (!defined) { Blacklist black = m_blacklist.SingleOrDefault(b => b.Interface == m_interface.Name && b.Method == nm.Name); if (black == null) { if (nm.ArgTypes.Length > 0 && nm.ArgTypes[nm.ArgTypes.Length - 1] == "...") { DoWrite(" // skipping variadic {0}", nm.Name); Console.Error.WriteLine("Ignoring {0}::{1} (it's variadic)", m_interface.Name, nm.Name); } else if (nm.ArgTypes.Length > 0 && nm.ArgTypes.Any(t => t.Contains("( * )"))) { DoWrite(" // skipping function pointer {0}", nm.Name); Console.Error.WriteLine("Ignoring {0}::{1} (it uses a function pointer)", m_interface.Name, nm.Name); } else if (nm.ArgTypes.Length > 0 && (nm.ArgTypes.Any(t => t.Contains("( ^ )")) || nm.ArgTypes.Any(t => t.Contains("(^)")))) { DoWrite(" // skipping block {0}", nm.Name); Console.Error.WriteLine("Ignoring {0}::{1} (it uses a block)", m_interface.Name, nm.Name); } else if (nm.ReturnType.Contains("( ^ )") || nm.ReturnType.Contains("(^)")) { DoWrite(" // skipping block {0}", nm.Name); Console.Error.WriteLine("Ignoring {0}::{1} (it uses a block)", m_interface.Name, nm.Name); } else { if (writeBlank) DoWrite("\t\t"); DoWrite(" \t/// <exclude/>"); DoWriteMethod(nm); wrote = true; } } else { DoWrite(" // skipping {0} {1}", black.Method, black.Reason); } } else DoWrite(" // skipping {0} (it's already defined)", nm.Name); return wrote; }