/// <summary> /// Traverse AST node that represents class declaration /// </summary> /// <param name="node">AST node.</param> public override void VisitClassDeclaration(ClassDeclarationSyntax node) { try { if (!node.Identifier.Span.IsEmpty) { var symbol = _sm.GetDeclaredSymbol(node); // Classes can be partial, however, currently, srclib only support one definition per symbol if (!_defined.Contains(symbol)) { _defined.Add(symbol); var def = Def.For(symbol: symbol, type: "class", name: symbol.Name).At(_path, node.Identifier.Span); if (symbol.IsExported()) { def.Exported = true; } AddDef(def, DocProcessor.ForClass(symbol)); } } base.VisitClassDeclaration(node); } catch (Exception e) { } }
/// <summary> /// Traverse AST node that represents struct declaration /// </summary> /// <param name="node">AST node.</param> public override void VisitStructDeclaration(StructDeclarationSyntax node) { try { if (!node.Identifier.Span.IsEmpty) { var symbol = _sm.GetDeclaredSymbol(node); // Structs can also be partial if (!_defined.Contains(symbol)) { _defined.Add(symbol); var def = Def.For(symbol: symbol, type: "struct", name: symbol.Name).At(_path, node.Identifier.Span); if (symbol.IsExported()) { def.Exported = true; } AddDef(def, DocProcessor.ForClass(symbol)); } } base.VisitStructDeclaration(node); } catch (Exception e) { } }
private static void WriteDocumentation(BindStreamWriter sw, Function f) { try { string path = Path.Combine(Settings.DocPath, Settings.FunctionPrefix + f.WrappedDelegate.Name + ".xml"); if (!File.Exists(path)) { path = Path.Combine(Settings.DocPath, Settings.FunctionPrefix + f.TrimmedName + ".xml"); } if (!File.Exists(path)) { path = Path.Combine(Settings.DocPath, Settings.FunctionPrefix + f.TrimmedName.TrimEnd(numbers) + ".xml"); } if (File.Exists(path)) { DocProcessor doc_processor = new DocProcessor(Path.Combine(Settings.DocPath, Settings.DocFile)); sw.WriteLine(doc_processor.ProcessFile(path)); } } catch (FileNotFoundException) { } }
public virtual void Process() { var overrides = Settings.OverridesFiles.SelectMany(GetFiles); GLTypes = SpecReader.ReadTypeMap(Path.Combine(Settings.InputPath, glTypemap)); CSTypes = SpecReader.ReadCSTypeMap(Path.Combine(Settings.InputPath, csTypemap)); // Read enum signatures SpecReader.ReadEnums(Path.Combine(Settings.InputPath, enumSpec), Enums, Profile, Version); foreach (var file in overrides) { SpecReader.ReadEnums(file, Enums, Profile, Version); } // Read delegate signatures SpecReader.ReadDelegates(Path.Combine(Settings.InputPath, glSpec), Delegates, Profile, Version); foreach (var file in overrides) { SpecReader.ReadDelegates(file, Delegates, Profile, Version); } var enum_processor = new EnumProcessor(this, overrides); var func_processor = new FuncProcessor(this, overrides); var doc_processor = new DocProcessor(this); Enums = enum_processor.Process(Enums, Profile); Wrappers = func_processor.Process(enum_processor, doc_processor, Delegates, Enums, Profile, Version); }
public virtual void Process() { var overrides = Settings.OverridesFiles.SelectMany(GetFiles); GLTypes = SpecReader.ReadTypeMap(Path.Combine(Settings.InputPath, glTypemap)); CSTypes = SpecReader.ReadCSTypeMap(Path.Combine(Settings.InputPath, csTypemap)); // Read enum signatures SpecReader.ReadEnums(Path.Combine(Settings.InputPath, enumSpec), Enums, Profile, Version); foreach (var file in overrides) { SpecReader.ReadEnums(file, Enums, Profile, Version); } // Read delegate signatures SpecReader.ReadDelegates(Path.Combine(Settings.InputPath, glSpec), Delegates, Profile, Version); foreach (var file in overrides) { SpecReader.ReadDelegates(file, Delegates, Profile, Version); } HashSet <string> extensions = new HashSet <string>(); foreach (var(name, list) in Delegates) { var @delegate = list[0]; if (string.IsNullOrEmpty(@delegate.Category) == false) { foreach (var part in @delegate.Category.Split('|')) { extensions.Add(part); } } } foreach (var(name, @enum) in Enums) { var match = Utilities.Extensions.Match(name); if (match.Index == 0 && match.Length != 0) { extensions.Add(name); } } var enum_processor = new EnumProcessor(this, overrides); var func_processor = new FuncProcessor(this, overrides); var doc_processor = new DocProcessor(this); Enums = enum_processor.Process(Enums, Profile, extensions); Wrappers = func_processor.Process(enum_processor, doc_processor, Delegates, Enums, Profile, Version); }
public virtual void Process() { string overrides = Path.Combine(Settings.InputPath, Settings.OverridesFile); GLTypes = SpecReader.ReadTypeMap(Path.Combine(Settings.InputPath, glTypemap)); CSTypes = SpecReader.ReadCSTypeMap(Path.Combine(Settings.InputPath, csTypemap)); SpecReader.ReadEnums(Path.Combine(Settings.InputPath, enumSpec), Enums, Profile, Version); SpecReader.ReadEnums(overrides, Enums, Profile, Version); SpecReader.ReadDelegates(Path.Combine(Settings.InputPath, glSpec), Delegates, Profile, Version); SpecReader.ReadDelegates(overrides, Delegates, Profile, Version); var enum_processor = new EnumProcessor(this, overrides); var func_processor = new FuncProcessor(this, overrides); var doc_processor = new DocProcessor(this); Enums = enum_processor.Process(Enums, Profile); Wrappers = func_processor.Process(enum_processor, doc_processor, Delegates, Enums, Profile, Version); }
/// <summary> /// Traverse AST node that represents method declaration /// </summary> /// <param name="node">AST node.</param> public override void VisitMethodDeclaration(MethodDeclarationSyntax node) { try { if (!node.Identifier.Span.IsEmpty) { var symbol = _sm.GetDeclaredSymbol(node); _defined.Add(symbol); var def = Def.For(symbol: symbol, type: "method", name: symbol.Name).At(_path, node.Identifier.Span); if (symbol.IsExported()) { def.Exported = true; } AddDef(def, DocProcessor.ForMethod(symbol)); } base.VisitMethodDeclaration(node); } catch (Exception e) { } }
private static void WriteDocumentation(BindStreamWriter sw, Function f) { try { string path = Path.Combine(Settings.DocPath, Settings.FunctionPrefix + f.WrappedDelegate.Name + ".xml"); if (!File.Exists(path)) path = Path.Combine(Settings.DocPath, Settings.FunctionPrefix + f.TrimmedName + ".xml"); if (!File.Exists(path)) path = Path.Combine(Settings.DocPath, Settings.FunctionPrefix + f.TrimmedName.TrimEnd(numbers) + ".xml"); if (File.Exists(path)) { DocProcessor doc_processor = new DocProcessor(Path.Combine(Settings.DocPath, Settings.DocFile)); sw.WriteLine(doc_processor.ProcessFile(path)); } } catch (FileNotFoundException) { } }
public void WriteWrappers(BindStreamWriter sw, FunctionCollection wrappers, Dictionary<string, string> CSTypes) { Trace.WriteLine(String.Format("Writing wrappers to:\t{0}.{1}", Settings.OutputNamespace, Settings.OutputClass)); sw.WriteLine("#pragma warning disable 3019"); // CLSCompliant attribute sw.WriteLine("#pragma warning disable 1591"); // Missing doc comments sw.WriteLine("#pragma warning disable 1572"); // Wrong param comments sw.WriteLine("#pragma warning disable 1573"); // Missing param comments sw.WriteLine(); sw.WriteLine("partial class {0}", Settings.OutputClass); sw.WriteLine("{"); sw.Indent(); //sw.WriteLine("static {0}() {1} {2}", className, "{", "}"); // Static init in GLHelper.cs sw.WriteLine(); int current = 0; foreach (string key in wrappers.Keys) { if (((Settings.Compatibility & Settings.Legacy.NoSeparateFunctionNamespaces) == Settings.Legacy.None) && key != "Core") { if (!Char.IsDigit(key[0])) { sw.WriteLine("public static partial class {0}", key); } else { // Identifiers cannot start with a number: sw.WriteLine("public static partial class {0}{1}", Settings.ConstantPrefix, key); } sw.WriteLine("{"); sw.Indent(); } wrappers[key].Sort(); foreach (Function f in wrappers[key]) { if ((Settings.Compatibility & Settings.Legacy.NoDocumentation) == 0) { Console.WriteLine("Creating docs for #{0} ({1})", current++, f.Name); try { string path = Path.Combine(Settings.DocPath, Settings.FunctionPrefix + f.WrappedDelegate.Name + ".xml"); if (!File.Exists(path)) path = Path.Combine(Settings.DocPath, Settings.FunctionPrefix + f.TrimmedName + ".xml"); if (!File.Exists(path)) path = Path.Combine(Settings.DocPath, Settings.FunctionPrefix + f.TrimmedName.TrimEnd(numbers) + ".xml"); if (File.Exists(path)) { DocProcessor doc_processor = new DocProcessor(Path.Combine(Settings.DocPath, Settings.DocFile)); sw.WriteLine(doc_processor.ProcessFile(path)); } } catch (FileNotFoundException) { } } if (!f.CLSCompliant) { sw.WriteLine("[System.CLSCompliant(false)]"); } sw.WriteLine("[AutoGenerated(Category = \"{0}\", Version = \"{1}\", EntryPoint = \"{2}\")]", f.Category, f.Version, Settings.FunctionPrefix + f.WrappedDelegate.Name); sw.WriteLine("public static "); sw.Write(f); sw.WriteLine(); } if (((Settings.Compatibility & Settings.Legacy.NoSeparateFunctionNamespaces) == Settings.Legacy.None) && key != "Core") { sw.Unindent(); sw.WriteLine("}"); sw.WriteLine(); } } sw.Unindent(); sw.WriteLine("}"); }
public void WriteWrappers(BindStreamWriter sw, FunctionCollection wrappers, Dictionary <string, string> CSTypes) { Trace.WriteLine(String.Format("Writing wrappers to:\t{0}.{1}", Settings.OutputNamespace, Settings.OutputClass)); sw.WriteLine("#pragma warning disable 3019"); // CLSCompliant attribute sw.WriteLine("#pragma warning disable 1591"); // Missing doc comments sw.WriteLine("#pragma warning disable 1572"); // Wrong param comments sw.WriteLine("#pragma warning disable 1573"); // Missing param comments sw.WriteLine(); sw.WriteLine("partial class {0}", Settings.OutputClass); sw.WriteLine("{"); sw.Indent(); //sw.WriteLine("static {0}() {1} {2}", className, "{", "}"); // Static init in GLHelper.cs sw.WriteLine(); int current = 0; foreach (string key in wrappers.Keys) { if (((Settings.Compatibility & Settings.Legacy.NoSeparateFunctionNamespaces) == Settings.Legacy.None) && key != "Core") { if (!Char.IsDigit(key[0])) { sw.WriteLine("public static partial class {0}", key); } else { // Identifiers cannot start with a number: sw.WriteLine("public static partial class {0}{1}", Settings.ConstantPrefix, key); } sw.WriteLine("{"); sw.Indent(); } wrappers[key].Sort(); foreach (Function f in wrappers[key]) { if ((Settings.Compatibility & Settings.Legacy.NoDocumentation) == 0) { Console.WriteLine("Creating docs for #{0} ({1})", current++, f.Name); try { string path = Path.Combine(Settings.DocPath, Settings.FunctionPrefix + f.WrappedDelegate.Name + ".xml"); if (!File.Exists(path)) { path = Path.Combine(Settings.DocPath, Settings.FunctionPrefix + f.TrimmedName + ".xml"); } if (!File.Exists(path)) { path = Path.Combine(Settings.DocPath, Settings.FunctionPrefix + f.TrimmedName.TrimEnd(numbers) + ".xml"); } if (File.Exists(path)) { DocProcessor doc_processor = new DocProcessor(Path.Combine(Settings.DocPath, Settings.DocFile)); sw.WriteLine(doc_processor.ProcessFile(path)); } } catch (FileNotFoundException) { } } if (!f.CLSCompliant) { sw.WriteLine("[System.CLSCompliant(false)]"); } sw.WriteLine("[AutoGenerated(Category = \"{0}\", Version = \"{1}\", EntryPoint = \"{2}\")]", f.Category, f.Version, Settings.FunctionPrefix + f.WrappedDelegate.Name); sw.WriteLine("public static "); sw.Write(f); sw.WriteLine(); } if (((Settings.Compatibility & Settings.Legacy.NoSeparateFunctionNamespaces) == Settings.Legacy.None) && key != "Core") { sw.Unindent(); sw.WriteLine("}"); sw.WriteLine(); } } sw.Unindent(); sw.WriteLine("}"); }