本文整理汇总了C#中Bind.BindStreamWriter.WriteLine方法的典型用法代码示例。如果您正苦于以下问题:C# BindStreamWriter.WriteLine方法的具体用法?C# BindStreamWriter.WriteLine怎么用?C# BindStreamWriter.WriteLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bind.BindStreamWriter
的用法示例。
在下文中一共展示了BindStreamWriter.WriteLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteWrapper
int WriteWrapper(BindStreamWriter sw, int current, Function f, EnumCollection enums)
{
if ((Settings.Compatibility & Settings.Legacy.NoDocumentation) == 0)
{
string text = String.Format("Writing function #{0}: {1}", current++, f.ToString());
ConsoleRewrite(text);
WriteDocumentation(sw, f);
}
WriteMethod(sw, f, enums);
sw.WriteLine();
return current;
}
示例2: WriteEnums
public void WriteEnums(BindStreamWriter sw, EnumCollection enums)
{
foreach (Enum @enum in enums.Values)
{
sw.WriteLine("public enum {0}", @enum.Name);
sw.WriteLine("{");
sw.Indent();
int count = @enum.ConstantCollection.Values.Count;
if (count == 0)
{
// Java enums must have at least one value.
sw.WriteLine("None;");
}
else
{
foreach (var c in @enum.ConstantCollection.Values)
{
sw.WriteLine(String.Format("{0}({1}{2}){3}",
c.Name,
!String.IsNullOrEmpty(c.Reference) ? (c.Reference + Settings.NamespaceSeparator) : "",
!String.IsNullOrEmpty(c.Reference) ? c.Value : c.Value.ToLower(),
--count == 0 ? ";" : ","));
}
sw.WriteLine();
sw.WriteLine("{0} mValue;", @enum.Type);
sw.WriteLine("{0}({1} value) {{ mValue = value; }}", @enum.Name, @enum.Type);
}
sw.Unindent();
sw.WriteLine("}");
sw.WriteLine();
}
}
示例3: WriteDocumentation
void WriteDocumentation(BindStreamWriter sw, Function f)
{
if (docfiles == null)
{
docfiles = new Dictionary<string, string>();
foreach (string file in Directory.GetFiles(Settings.DocPath))
{
docfiles.Add(Path.GetFileName(file), file);
}
}
string docfile = null;
try
{
docfile = Settings.FunctionPrefix + f.WrappedDelegate.Name + ".xml";
if (!docfiles.ContainsKey(docfile))
docfile = Settings.FunctionPrefix + f.TrimmedName + ".xml";
if (!docfiles.ContainsKey(docfile))
docfile = Settings.FunctionPrefix + f.TrimmedName.TrimEnd(numbers) + ".xml";
string doc = null;
if (docfiles.ContainsKey(docfile))
{
doc = processor.ProcessFile(docfiles[docfile]);
}
if (doc == null)
{
doc = "/// <summary></summary>";
}
int summary_start = doc.IndexOf("<summary>") + "<summary>".Length;
string warning = "[deprecated: v{0}]";
string category = "[requires: {0}]";
if (f.Deprecated)
{
warning = String.Format(warning, f.DeprecatedVersion);
doc = doc.Insert(summary_start, warning);
}
if (f.Extension != "Core" && !String.IsNullOrEmpty(f.Category))
{
category = String.Format(category, f.Category);
doc = doc.Insert(summary_start, category);
}
else if (!String.IsNullOrEmpty(f.Version))
{
if (f.Category.StartsWith("VERSION"))
category = String.Format(category, "v" + f.Version);
else
category = String.Format(category, "v" + f.Version + " and " + f.Category);
doc = doc.Insert(summary_start, category);
}
sw.WriteLine(doc);
}
catch (Exception e)
{
Console.WriteLine("[Warning] Error processing file {0}: {1}", docfile, e.ToString());
}
}
示例4: WriteConstants
void WriteConstants(BindStreamWriter sw, IEnumerable<Constant> constants)
{
// Make sure everything is sorted. This will avoid random changes between
// consecutive runs of the program.
constants = constants.OrderBy(c => c);
foreach (var c in constants)
{
if (!Settings.IsEnabled(Settings.Legacy.NoDocumentation))
{
sw.WriteLine("/// <summary>");
sw.WriteLine("/// Original was " + Settings.ConstantPrefix + c.OriginalName + " = " + c.Value);
sw.WriteLine("/// </summary>");
}
var str = String.Format("{0} = {1}((int){2}{3})", c.Name, c.Unchecked ? "unchecked" : "",
!String.IsNullOrEmpty(c.Reference) ? c.Reference + Settings.NamespaceSeparator : "", c.Value);
sw.Write(str);
if (!String.IsNullOrEmpty(str))
sw.WriteLine(",");
}
}
示例5: WriteBindings
void WriteBindings(DelegateCollection delegates, FunctionCollection wrappers, EnumCollection enums)
{
Console.WriteLine("Writing bindings to {0}", Settings.OutputPath);
if (!Directory.Exists(Settings.OutputPath))
Directory.CreateDirectory(Settings.OutputPath);
string temp_enums_file = Path.GetTempFileName();
string temp_wrappers_file = Path.GetTempFileName();
// Enums
using (BindStreamWriter sw = new BindStreamWriter(temp_enums_file))
{
WriteLicense(sw);
sw.WriteLine("using System;");
sw.WriteLine();
if ((Settings.Compatibility & Settings.Legacy.NestedEnums) != Settings.Legacy.None)
{
sw.WriteLine("namespace {0}", Settings.OutputNamespace);
sw.WriteLine("{");
sw.Indent();
sw.WriteLine("static partial class {0}", Settings.OutputClass);
}
else
sw.WriteLine("namespace {0}", Settings.EnumsOutput);
sw.WriteLine("{");
sw.Indent();
WriteEnums(sw, enums, wrappers);
sw.Unindent();
if ((Settings.Compatibility & Settings.Legacy.NestedEnums) != Settings.Legacy.None)
{
sw.WriteLine("}");
sw.Unindent();
}
sw.WriteLine("}");
}
// Wrappers
using (BindStreamWriter sw = new BindStreamWriter(temp_wrappers_file))
{
WriteLicense(sw);
sw.WriteLine("namespace {0}", Settings.OutputNamespace);
sw.WriteLine("{");
sw.Indent();
sw.WriteLine("using System;");
sw.WriteLine("using System.Text;");
sw.WriteLine("using System.Runtime.InteropServices;");
WriteWrappers(sw, wrappers, delegates, enums, Generator.CSTypes);
sw.Unindent();
sw.WriteLine("}");
}
string output_enums = Path.Combine(Settings.OutputPath, Settings.EnumsFile);
string output_delegates = Path.Combine(Settings.OutputPath, Settings.DelegatesFile);
string output_core = Path.Combine(Settings.OutputPath, Settings.ImportsFile);
string output_wrappers = Path.Combine(Settings.OutputPath, Settings.WrappersFile);
if (File.Exists(output_enums)) File.Delete(output_enums);
if (File.Exists(output_delegates)) File.Delete(output_delegates);
if (File.Exists(output_core)) File.Delete(output_core);
if (File.Exists(output_wrappers)) File.Delete(output_wrappers);
File.Move(temp_enums_file, output_enums);
File.Move(temp_wrappers_file, output_wrappers);
}
示例6: WriteWrapper
void WriteWrapper(BindStreamWriter sw, Function f, EnumCollection enums)
{
if ((Settings.Compatibility & Settings.Legacy.NoDocumentation) == 0)
{
WriteDocumentation(sw, f);
}
WriteMethod(sw, f, enums);
sw.WriteLine();
}
示例7: WriteDocumentation
void WriteDocumentation(BindStreamWriter sw, Function f)
{
var docs = f.Documentation;
try
{
string warning = String.Empty;
string category = String.Empty;
if (f.Deprecated)
{
warning = String.Format("[deprecated: v{0}]", f.DeprecatedVersion);
}
if (f.Extension != "Core" && !String.IsNullOrEmpty(f.Category))
{
category = String.Format("[requires: {0}]", f.Category);
}
else if (!String.IsNullOrEmpty(f.Version))
{
if (f.Category.StartsWith("VERSION"))
category = String.Format("[requires: {0}]", "v" + f.Version);
else
category = String.Format("[requires: {0}]", "v" + f.Version + " or " + f.Category);
}
// Write function summary
sw.Write("/// <summary>");
if (!String.IsNullOrEmpty(category) || !String.IsNullOrEmpty(warning))
{
sw.Write(WriteOptions.NoIndent, "{0}{1}", category, warning);
}
if (!String.IsNullOrEmpty(docs.Summary))
{
sw.WriteLine();
sw.WriteLine("/// {0}", docs.Summary);
sw.WriteLine("/// </summary>");
}
else
{
sw.WriteLine(WriteOptions.NoIndent, "</summary>");
}
// Write function parameters
for (int i = 0; i < f.Parameters.Count; i++)
{
var param = f.Parameters[i];
string length = String.Empty;
if (!String.IsNullOrEmpty(param.ComputeSize))
{
length = String.Format("[length: {0}]", param.ComputeSize);
}
// Try to match the correct parameter from documentation:
// - first by name
// - then by index
var docparam =
(docs.Parameters
.Where(p => p.Name == param.RawName)
.FirstOrDefault()) ??
(docs.Parameters.Count > i ?
docs.Parameters[i] : null);
if (docparam != null)
{
if (docparam.Name != param.RawName &&
docparam.Name != param.RawName.Substring(1)) // '@ref' -> 'ref' etc
{
Console.Error.WriteLine(
"[Warning] Parameter '{0}' in function '{1}' has incorrect doc name '{2}'",
param.RawName, f.Name, docparam.Name);
}
// Note: we use param.Name, because the documentation sometimes
// uses different names than the specification.
sw.Write("/// <param name=\"{0}\">", param.Name);
if (!String.IsNullOrEmpty(length))
{
sw.Write(WriteOptions.NoIndent, "{0}", length);
}
if (!String.IsNullOrEmpty(docparam.Documentation))
{
sw.WriteLine(WriteOptions.NoIndent, " ");
sw.WriteLine("/// {0}", docparam.Documentation);
sw.WriteLine("/// </param>");
}
else
{
sw.WriteLine(WriteOptions.NoIndent, "</param>");
}
}
else
{
Console.Error.WriteLine(
"[Warning] Parameter '{0}' in function '{1}' not found in documentation '{{{2}}}'",
param.Name, f.Name,
String.Join(",", docs.Parameters.Select(p => p.Name).ToArray()));
sw.WriteLine("/// <param name=\"{0}\">{1}</param>",
param.Name, length);
}
//.........这里部分代码省略.........
示例8: WriteEnums
void WriteEnums(BindStreamWriter sw, EnumCollection enums, FunctionCollection wrappers)
{
//sw.WriteLine("#pragma warning disable 3019"); // CLSCompliant attribute
//sw.WriteLine("#pragma warning disable 1591"); // Missing doc comments
//sw.WriteLine();
if ((Settings.Compatibility & Settings.Legacy.NestedEnums) != Settings.Legacy.None)
Trace.WriteLine(String.Format("Writing enums to:\t{0}.{1}.{2}", Settings.OutputNamespace, Settings.OutputClass, Settings.NestedEnumsClass));
else
Trace.WriteLine(String.Format("Writing enums to:\t{0}", Settings.EnumsOutput));
if ((Settings.Compatibility & Settings.Legacy.ConstIntEnums) == Settings.Legacy.None)
{
if ((Settings.Compatibility & Settings.Legacy.NestedEnums) != Settings.Legacy.None &&
!String.IsNullOrEmpty(Settings.NestedEnumsClass))
{
sw.WriteLine("public class Enums");
sw.WriteLine("{");
sw.Indent();
}
foreach (Enum @enum in enums.Values)
{
if (!Settings.IsEnabled(Settings.Legacy.NoDocumentation))
{
// Document which functions use this enum.
var functions =
(from wrapper in wrappers
from function in wrapper.Value
from param in function.Parameters
where param.CurrentType == @enum.Name
select Settings.GLClass + (function.Extension != "Core" ? ("." + function.Extension) : "") + "." + function.TrimmedName)
.Distinct();
sw.WriteLine("/// <summary>");
sw.WriteLine(String.Format("/// {0}", functions.Count() > 0 ?
("Used in " + String.Join(", ", functions.ToArray())) : "Not used directly."));
sw.WriteLine("/// </summary>");
}
if (!string.IsNullOrEmpty (@enum.Obsolete))
sw.WriteLine("[Obsolete(\"{0}\")]", @enum.Obsolete);
if (@enum.IsFlagCollection)
sw.WriteLine("[Flags]");
sw.WriteLine("public enum " + @enum.Name + " : " + @enum.Type);
sw.WriteLine("{");
sw.Indent();
WriteConstants(sw, @enum.ConstantCollection.Values);
sw.Unindent();
sw.WriteLine("}");
sw.WriteLine();
}
if ((Settings.Compatibility & Settings.Legacy.NestedEnums) != Settings.Legacy.None &&
!String.IsNullOrEmpty(Settings.NestedEnumsClass))
{
sw.Unindent();
sw.WriteLine("}");
}
}
else
{
// Tao legacy mode: dump all enums as constants in GLClass.
foreach (Constant c in enums[Settings.CompleteEnumName].ConstantCollection.Values)
{
// Print constants avoiding circular definitions
if (c.Name != c.Value)
{
sw.WriteLine(String.Format(
"public const int {0} = {2}((int){1});",
c.Name.StartsWith(Settings.ConstantPrefix) ? c.Name : Settings.ConstantPrefix + c.Name,
Char.IsDigit(c.Value[0]) ? c.Value : c.Value.StartsWith(Settings.ConstantPrefix) ? c.Value : Settings.ConstantPrefix + c.Value,
c.Unchecked ? "unchecked" : ""));
}
else
{
}
}
}
}
示例9: WriteWrapper
static Delegate WriteWrapper(Delegate last_delegate, Function f, BindStreamWriter sw)
{
//if (last_delegate == f.WrappedDelegate)
// return last_delegate; // Multiple wrappers for the same delegate are not necessary in C++
var valid = true;
var parameters = GenerateParameterString(f, true, out valid);
if (!valid)
return last_delegate;
last_delegate = f.WrappedDelegate;
sw.WriteLine("inline {0} {1}({2})", f.WrappedDelegate.ReturnType,
f.TrimmedName, parameters);
sw.WriteLine("{");
sw.Indent();
WriteMethodBody(sw, f);
sw.Unindent();
sw.WriteLine("}");
return last_delegate;
}
示例10: WriteWrappers
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])
{
current = WriteWrapper(sw, current, f);
}
if (((Settings.Compatibility & Settings.Legacy.NoSeparateFunctionNamespaces) == Settings.Legacy.None) && key != "Core")
{
sw.Unindent();
sw.WriteLine("}");
sw.WriteLine();
}
}
sw.Unindent();
sw.WriteLine("}");
}
示例11: WriteMethod
private static void WriteMethod(BindStreamWriter sw, Function f)
{
if (f.Deprecated && Settings.IsEnabled(Settings.Legacy.AddDeprecationWarnings))
{
sw.WriteLine("[Obsolete(\"Deprecated in OpenGL {0}\")]", f.DeprecatedVersion);
}
if (!string.IsNullOrEmpty (f.Obsolete))
sw.WriteLine("[Obsolete(\"{0}\")]", f.Obsolete);
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();
}
示例12: WriteImports
public void WriteImports(BindStreamWriter sw, DelegateCollection delegates)
{
Trace.WriteLine(String.Format("Writing imports to:\t{0}.{1}.{2}", Settings.OutputNamespace, Settings.OutputClass, Settings.ImportsClass));
sw.WriteLine("#pragma warning disable 3019"); // CLSCompliant attribute
sw.WriteLine("#pragma warning disable 1591"); // Missing doc comments
sw.WriteLine();
sw.WriteLine("partial class {0}", Settings.OutputClass);
sw.WriteLine("{");
sw.Indent();
sw.WriteLine();
sw.WriteLine("internal static partial class {0}", Settings.ImportsClass);
sw.WriteLine("{");
sw.Indent();
//sw.WriteLine("static {0}() {1} {2}", Settings.ImportsClass, "{", "}"); // Disable BeforeFieldInit
sw.WriteLine();
foreach (Delegate d in delegates.Values)
{
sw.WriteLine("[System.Security.SuppressUnmanagedCodeSecurity()]");
sw.WriteLine(
"[System.Runtime.InteropServices.DllImport({0}.Library, EntryPoint = \"{1}{2}\"{3})]",
Settings.OutputClass,
Settings.FunctionPrefix,
d.Name,
d.Name.EndsWith("W") || d.Name.EndsWith("A") ? ", CharSet = CharSet.Auto" : ", ExactSpelling = true"
);
sw.WriteLine("internal extern static {0};", d.DeclarationString());
}
sw.Unindent();
sw.WriteLine("}");
sw.Unindent();
sw.WriteLine("}");
}
示例13: WriteDelegates
void WriteDelegates(BindStreamWriter sw, DelegateCollection delegates)
{
Trace.WriteLine(String.Format("Writing delegates to:\t{0}.{1}.{2}", Settings.OutputNamespace, Settings.OutputClass, Settings.DelegatesClass));
sw.WriteLine("#pragma warning disable 3019"); // CLSCompliant attribute
sw.WriteLine("#pragma warning disable 1591"); // Missing doc comments
#if !MOBILE
sw.WriteLine();
sw.WriteLine("partial class {0}", Settings.OutputClass);
sw.WriteLine("{");
sw.Indent();
sw.WriteLine("internal static partial class {0}", Settings.DelegatesClass);
sw.WriteLine("{");
sw.Indent();
foreach (Delegate d in delegates.Values)
{
sw.WriteLine("[System.Security.SuppressUnmanagedCodeSecurity()]");
if (!string.IsNullOrEmpty (d.Obsolete))
sw.WriteLine("[Obsolete(\"{0}\")]", d.Obsolete);
sw.WriteLine("internal {0};", d.ToString());
sw.WriteLine("internal {0}static {1} {2}{1};", // = null
d.Unsafe ? "unsafe " : "",
d.Name,
Settings.FunctionPrefix);
}
sw.Unindent();
sw.WriteLine("}");
sw.Unindent();
sw.WriteLine("}");
#endif
}
示例14: WriteMethod
private void WriteMethod(BindStreamWriter sw, Function f, EnumCollection enums)
{
CreateBody(f, enums);
if (f.Deprecated && Settings.IsEnabled(Settings.Legacy.AddDeprecationWarnings))
{
sw.WriteLine("[Obsolete(\"Deprecated in OpenGL {0}\")]", f.DeprecatedVersion);
}
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.EntryPoint);
sw.WriteLine("public static ");
sw.Write(GetDeclarationString(f));
sw.WriteLine();
}
示例15: WriteDocumentation
void WriteDocumentation(BindStreamWriter sw, Function f)
{
var docs = f.Documentation;
try
{
string warning = "[deprecated: v{0}]";
string category = "[requires: {0}]";
if (f.Deprecated)
{
warning = String.Format(warning, f.DeprecatedVersion);
docs.Summary = docs.Summary.Insert(0, warning);
}
if (f.Extension != "Core" && !String.IsNullOrEmpty(f.Category))
{
category = String.Format(category, f.Category);
docs.Summary = docs.Summary.Insert(0, category);
}
else if (!String.IsNullOrEmpty(f.Version))
{
if (f.Category.StartsWith("VERSION"))
category = String.Format(category, "v" + f.Version);
else
category = String.Format(category, "v" + f.Version + " and " + f.Category);
docs.Summary = docs.Summary.Insert(0, category);
}
for (int i = 0; i < f.WrappedDelegate.Parameters.Count; i++)
{
var param = f.WrappedDelegate.Parameters[i];
if (param.ComputeSize != String.Empty)
{
docs.Parameters[i].Documentation.Insert(0,
String.Format("[length: {0}]", param.ComputeSize));
}
}
sw.Write("/// \brief ");
sw.WriteLine(docs.Summary);
foreach (var p in docs.Parameters)
{
sw.Write(@"/// \param ");
sw.Write(p.Name);
sw.WriteLine(p.Documentation);
}
}
catch (Exception e)
{
Console.WriteLine("[Warning] Error documenting function {0}: {1}", f.WrappedDelegate.Name, e.ToString());
}
}