fix static block appearing before rsquirly

This commit is contained in:
Rune
2026-03-06 17:22:57 +01:00
parent fa90624c84
commit 09748b9eeb

View File

@@ -154,6 +154,9 @@ abstract class Cpp2BeefGenerator
case .Namespace: BeginCursor(cursor); Namespace(cursor);
case .FunctionDecl: BeginCursor(cursor); FunctionDecl(cursor);
case .FunctionTemplate, .ClassTemplate, .TypeAliasTemplateDecl:
Runtime.FatalError("Templates are currently unsupported but Coming Soon tm");
case .CXXMethod,
.Constructor,
.Destructor,
@@ -408,7 +411,6 @@ abstract class Cpp2BeefGenerator
switch (cursor.kind)
{
case .FunctionTemplate, .ClassTemplate, .TypeAliasTemplateDecl:
Runtime.FatalError("Templates are currently unsupported but Coming Soon tm");
templateParams.Append('<');
let len = wrapperTemplateChain.Length;
Clang.VisitChildren(cursor, (cursor, parent, client_data) =>
@@ -542,6 +544,9 @@ abstract class Cpp2BeefGenerator
}
protected virtual void WriteComments(CXSourceLocation writeUntil, Block? block = null)
{
var block;
if (fileInfo.queuedTokens != .None) block = null;
Clang.GetFileLocation(writeUntil, let curFile, let curLine, let curColumn, let curOffset);
Clang.GetFileLocation(fileInfo.prevEnd, let prevFile, let prevLine, let prevColumn, let prevOffset);
@@ -587,6 +592,7 @@ abstract class Cpp2BeefGenerator
void Block()
{
if (fileInfo.queuedTokens != .None) return;
findMacros: do
{
for (uint32 ln = line; ln < curLine; ln++)
@@ -620,6 +626,7 @@ abstract class Cpp2BeefGenerator
QueuedToken!(decltype(fileInfo.queuedTokens).RSquirly, "}");
if (!isWritingQueuedToken) continue;
if (fileInfo.queuedTokens == .None) block = @block;
default: continue;
}
let location = Clang.GetTokenLocation(unit, token);
@@ -637,7 +644,7 @@ abstract class Cpp2BeefGenerator
Flush();
}
WriteLinesUntil!(curLine, writeUntil);
if (block.HasValue) WriteBlock(block.Value);
if (@block.HasValue) WriteBlock(@block.Value);
}
protected enum TypeParamMode { None, InParam, OutParam }
@@ -940,7 +947,7 @@ abstract class Cpp2BeefGenerator
String whitespace;
if (preserveColumns)
{
whitespace = scope .(str);
whitespace = scope:: .(str);
str.Clear();
Type(type);
whitespace.Length -= Math.Min(str.Length, whitespace.Length);