Optimize empty comments parsing in Scripting API
This commit is contained in:
@@ -538,10 +538,14 @@ namespace Flax.Build.Bindings
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void GenerateCSharpComment(StringBuilder contents, string indent, string[] comment)
|
private static void GenerateCSharpComment(StringBuilder contents, string indent, string[] comment, bool skipMeta = false)
|
||||||
{
|
{
|
||||||
|
if (comment == null)
|
||||||
|
return;
|
||||||
foreach (var c in comment)
|
foreach (var c in comment)
|
||||||
{
|
{
|
||||||
|
if (skipMeta && (c.Contains("/// <returns>") || c.Contains("<param name=")))
|
||||||
|
continue;
|
||||||
contents.Append(indent).Append(c.Replace("::", ".")).AppendLine();
|
contents.Append(indent).Append(c.Replace("::", ".")).AppendLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -744,13 +748,7 @@ namespace Flax.Build.Bindings
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var comment in eventInfo.Comment)
|
GenerateCSharpComment(contents, indent, eventInfo.Comment, true);
|
||||||
{
|
|
||||||
if (comment.Contains("/// <returns>"))
|
|
||||||
continue;
|
|
||||||
contents.Append(indent).Append(comment.Replace("::", ".")).AppendLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
GenerateCSharpAttributes(buildData, contents, indent, classInfo, eventInfo, useUnmanaged);
|
GenerateCSharpAttributes(buildData, contents, indent, classInfo, eventInfo, useUnmanaged);
|
||||||
contents.Append(indent);
|
contents.Append(indent);
|
||||||
if (eventInfo.Access == AccessLevel.Public)
|
if (eventInfo.Access == AccessLevel.Public)
|
||||||
@@ -835,14 +833,7 @@ namespace Flax.Build.Bindings
|
|||||||
if (fieldInfo.Getter == null || fieldInfo.IsHidden)
|
if (fieldInfo.Getter == null || fieldInfo.IsHidden)
|
||||||
continue;
|
continue;
|
||||||
contents.AppendLine();
|
contents.AppendLine();
|
||||||
|
GenerateCSharpComment(contents, indent, fieldInfo.Comment, true);
|
||||||
foreach (var comment in fieldInfo.Comment)
|
|
||||||
{
|
|
||||||
if (comment.Contains("/// <returns>"))
|
|
||||||
continue;
|
|
||||||
contents.Append(indent).Append(comment.Replace("::", ".")).AppendLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
GenerateCSharpAttributes(buildData, contents, indent, classInfo, fieldInfo, useUnmanaged, fieldInfo.DefaultValue, fieldInfo.Type);
|
GenerateCSharpAttributes(buildData, contents, indent, classInfo, fieldInfo, useUnmanaged, fieldInfo.DefaultValue, fieldInfo.Type);
|
||||||
contents.Append(indent);
|
contents.Append(indent);
|
||||||
if (fieldInfo.Access == AccessLevel.Public)
|
if (fieldInfo.Access == AccessLevel.Public)
|
||||||
@@ -894,14 +885,7 @@ namespace Flax.Build.Bindings
|
|||||||
throw new NotImplementedException("TODO: support properties inside non-static and non-scripting API class types.");
|
throw new NotImplementedException("TODO: support properties inside non-static and non-scripting API class types.");
|
||||||
|
|
||||||
contents.AppendLine();
|
contents.AppendLine();
|
||||||
|
GenerateCSharpComment(contents, indent, propertyInfo.Comment, true);
|
||||||
foreach (var comment in propertyInfo.Comment)
|
|
||||||
{
|
|
||||||
if (comment.Contains("/// <returns>") || comment.Contains("<param name="))
|
|
||||||
continue;
|
|
||||||
contents.Append(indent).Append(comment.Replace("::", ".")).AppendLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
GenerateCSharpAttributes(buildData, contents, indent, classInfo, propertyInfo, useUnmanaged);
|
GenerateCSharpAttributes(buildData, contents, indent, classInfo, propertyInfo, useUnmanaged);
|
||||||
contents.Append(indent);
|
contents.Append(indent);
|
||||||
if (propertyInfo.Access == AccessLevel.Public)
|
if (propertyInfo.Access == AccessLevel.Public)
|
||||||
@@ -1127,10 +1111,7 @@ namespace Flax.Build.Bindings
|
|||||||
foreach (var fieldInfo in structureInfo.Fields)
|
foreach (var fieldInfo in structureInfo.Fields)
|
||||||
{
|
{
|
||||||
contents.AppendLine();
|
contents.AppendLine();
|
||||||
|
GenerateCSharpComment(contents, indent, fieldInfo.Comment);
|
||||||
foreach (var comment in fieldInfo.Comment)
|
|
||||||
contents.Append(indent).Append(comment).AppendLine();
|
|
||||||
|
|
||||||
GenerateCSharpAttributes(buildData, contents, indent, structureInfo, fieldInfo, fieldInfo.IsStatic, fieldInfo.DefaultValue, fieldInfo.Type);
|
GenerateCSharpAttributes(buildData, contents, indent, structureInfo, fieldInfo, fieldInfo.IsStatic, fieldInfo.DefaultValue, fieldInfo.Type);
|
||||||
contents.Append(indent);
|
contents.Append(indent);
|
||||||
if (fieldInfo.Access == AccessLevel.Public)
|
if (fieldInfo.Access == AccessLevel.Public)
|
||||||
@@ -1153,8 +1134,7 @@ namespace Flax.Build.Bindings
|
|||||||
for (int i = 1; i < fieldInfo.Type.ArraySize; i++)
|
for (int i = 1; i < fieldInfo.Type.ArraySize; i++)
|
||||||
{
|
{
|
||||||
contents.AppendLine();
|
contents.AppendLine();
|
||||||
foreach (var comment in fieldInfo.Comment)
|
GenerateCSharpComment(contents, indent, fieldInfo.Comment);
|
||||||
contents.Append(indent).Append(comment).AppendLine();
|
|
||||||
GenerateCSharpAttributes(buildData, contents, indent, structureInfo, fieldInfo, fieldInfo.IsStatic);
|
GenerateCSharpAttributes(buildData, contents, indent, structureInfo, fieldInfo, fieldInfo.IsStatic);
|
||||||
contents.Append(indent);
|
contents.Append(indent);
|
||||||
if (fieldInfo.Access == AccessLevel.Public)
|
if (fieldInfo.Access == AccessLevel.Public)
|
||||||
@@ -1257,10 +1237,7 @@ namespace Flax.Build.Bindings
|
|||||||
foreach (var entryInfo in enumInfo.Entries)
|
foreach (var entryInfo in enumInfo.Entries)
|
||||||
{
|
{
|
||||||
contents.AppendLine();
|
contents.AppendLine();
|
||||||
|
GenerateCSharpComment(contents, indent, entryInfo.Comment);
|
||||||
foreach (var comment in entryInfo.Comment)
|
|
||||||
contents.Append(indent).Append(comment).AppendLine();
|
|
||||||
|
|
||||||
GenerateCSharpAttributes(buildData, contents, indent, enumInfo, entryInfo.Attributes, entryInfo.Comment, true, false);
|
GenerateCSharpAttributes(buildData, contents, indent, enumInfo, entryInfo.Attributes, entryInfo.Comment, true, false);
|
||||||
contents.Append(indent).Append(entryInfo.Name);
|
contents.Append(indent).Append(entryInfo.Name);
|
||||||
if (!string.IsNullOrEmpty(entryInfo.Value))
|
if (!string.IsNullOrEmpty(entryInfo.Value))
|
||||||
|
|||||||
@@ -118,6 +118,8 @@ namespace Flax.Build.Bindings
|
|||||||
for (var i = 0; i < tokensCount; i++)
|
for (var i = 0; i < tokensCount; i++)
|
||||||
context.Tokenizer.NextToken(true, true);
|
context.Tokenizer.NextToken(true, true);
|
||||||
|
|
||||||
|
if (context.StringCache.Count == 0)
|
||||||
|
return null;
|
||||||
if (context.StringCache.Count == 1)
|
if (context.StringCache.Count == 1)
|
||||||
{
|
{
|
||||||
// Ensure to have summary begin/end pair
|
// Ensure to have summary begin/end pair
|
||||||
@@ -880,11 +882,14 @@ namespace Flax.Build.Bindings
|
|||||||
throw new Exception($"Property {propertyName} in class {classInfo.Name} (line {context.Tokenizer.CurrentLine}) has mismatching getter return type ({getterType}) and setter parameter type ({setterType}). Both getter and setter methods must use the same value type used for property.");
|
throw new Exception($"Property {propertyName} in class {classInfo.Name} (line {context.Tokenizer.CurrentLine}) has mismatching getter return type ({getterType}) and setter parameter type ({setterType}). Both getter and setter methods must use the same value type used for property.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix documentation comment to reflect both getter and setters available
|
if (propertyInfo.Comment != null)
|
||||||
for (var i = 0; i < propertyInfo.Comment.Length; i++)
|
|
||||||
{
|
{
|
||||||
ref var comment = ref propertyInfo.Comment[i];
|
// Fix documentation comment to reflect both getter and setters available
|
||||||
comment = comment.Replace("/// Gets ", "/// Gets or sets ");
|
for (var i = 0; i < propertyInfo.Comment.Length; i++)
|
||||||
|
{
|
||||||
|
ref var comment = ref propertyInfo.Comment[i];
|
||||||
|
comment = comment.Replace("/// Gets ", "/// Gets or sets ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user