public Declarations GetDeclarations(DataType dt, CppType type) { var baseTypes = new HashSet <DataType>(); var fieldTypes = new HashSet <DataType>(); var hIncludes = new HashSet <string>(); var hDeclarations = new HashSet <string>(); var hTypes = new HashSet <DataType>(); var incIncludes = new HashSet <string>(); var incTypes = new HashSet <DataType>(); var cppTypes = new HashSet <DataType>(); var cppIncludes = new HashSet <string>(); var cppDeclarations = new HashSet <string>(); Resolve(dt, baseTypes, fieldTypes, hTypes, incTypes, cppTypes); foreach (var t in type.Dependencies) { Add(cppTypes, t); } foreach (var t in type.PrecalcedTypes) { Add(cppTypes, t); } foreach (var m in type.MethodTypes) { foreach (var t in m.Dependencies) { Add(cppTypes, t); } foreach (var t in m.PrecalcedTypes) { Add(cppTypes, t); } } if (_backend.HasForwardDeclaration(dt)) { hDeclarations.Add(_backend.GetForwardDeclaration(dt)); } foreach (var e in fieldTypes) { if (e.IsStruct && !_backend.IsOpaque(e)) { baseTypes.Add(e.MasterDefinition); } else { hTypes.Add(e.MasterDefinition); } } foreach (var e in baseTypes) { hIncludes.Add(_backend.GetIncludeFilename(e)); hTypes.Remove(e.MasterDefinition); incTypes.Remove(e.MasterDefinition); cppTypes.Add(e.MasterDefinition); } foreach (var e in hTypes) { hDeclarations.Add(_backend.GetForwardDeclaration(e)); cppTypes.Add(e.MasterDefinition); } foreach (var e in incTypes) { incIncludes.Add(_backend.GetIncludeFilename(e)); } foreach (var e in cppTypes) { cppIncludes.Add(_backend.GetIncludeFilename(e)); } if (hIncludes.Count == 0) { hIncludes.Add("Uno.h"); } foreach (var e in _env.GetSet(dt, "Header.Declaration")) { hDeclarations.Add(e.Trim()); } foreach (var e in _env.GetSet(dt, "Header.Include")) { hIncludes.Add(e.Trim()); } foreach (var e in _env.GetSet(dt, "Header.Import")) { hDeclarations.Add("#import <" + e.Trim() + ">"); } foreach (var e in _env.GetSet(dt, "Source.Declaration")) { cppDeclarations.Add(e.Trim()); } foreach (var e in _env.GetSet(dt, "Source.Include")) { cppIncludes.Add(e.Trim()); } foreach (var e in _env.GetSet(dt, "Source.Import")) { cppDeclarations.Add("#import <" + e.Trim() + ">"); } SourceValue val; if (_env.TryGetValue(dt, "ForwardDeclaration", out val)) { hDeclarations.Add(val.String.Trim()); } if (_env.TryGetValue(dt, "Include", out val)) { hIncludes.Add(val.String.Trim()); } foreach (var e in hIncludes) { cppIncludes.Remove(e); incIncludes.Remove(e); } foreach (var e in incIncludes) { cppIncludes.Remove(e); } foreach (var e in hIncludes) { hDeclarations.Add("#include <" + e + ">"); } foreach (var e in cppIncludes) { cppDeclarations.Add("#include <" + e + ">"); } hDeclarations.Remove(null); cppDeclarations.Remove(null); incIncludes.Remove(null); var inlineDeclarations = incIncludes.ToArray(); for (int i = 0; i < inlineDeclarations.Length; i++) { inlineDeclarations[i] = "#include <" + inlineDeclarations[i] + ">"; } var result = new Declarations { Header = hDeclarations.ToArray(), Source = cppDeclarations.ToArray(), Inline = inlineDeclarations, }; Array.Sort(result.Header); Array.Sort(result.Source); Array.Sort(result.Inline); return(result); }
public override string GetForwardDeclaration(Source src, DataType dt) { return(_backend.GetForwardDeclaration(dt)); }