increase custamizability

This commit is contained in:
2026-05-28 15:47:49 +02:00
parent f56fad47af
commit 0bb0a4e4fc
2 changed files with 24 additions and 12 deletions

View File

@@ -157,8 +157,8 @@ static class Program
StreamWriter includeAll = scope .()..Create("clang-c.h");
for (let file in clangFiles)
{
//if (system(scope $"curl -o {clangHeaders}/{file}.h https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/main/clang/include/clang-c/{file}.h") != 0)
// Runtime.FatalError(scope $"Failed to download clang-c/{file}");
if (system(scope $"wget -O {clangHeaders}/{file}.h https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/main/clang/include/clang-c/{file}.h") != 0)
Runtime.FatalError(scope $"Failed to download clang-c/{file}");
includeAll.Write($"#include <clang-c/{file}.h>\n");
}
}

View File

@@ -169,6 +169,7 @@ abstract class Cpp2BeefGenerator
case .FieldDecl: BeginCursor(cursor); FieldDecl(cursor);
case .VarDecl: BeginCursor(cursor); VarDecl(cursor);
case .EnumConstantDecl: BeginCursor(cursor); EnumConstantDecl(cursor);
case .MacroDefinition:
if (Clang.Cursor_IsMacroFunctionLike(cursor) != 0) return;
@@ -444,7 +445,8 @@ abstract class Cpp2BeefGenerator
for (; i < file.Length && file[i].IsWhiteSpace; i++) outString.Append(file[i]);
}
protected virtual void AllWhiteSpaceUntil(CXSourceLocation from, enum { NoNewLines, YesNewLines } newlineMode)
protected enum WhiteSpaceNewLineMode { NoNewLines, YesNewLines }
protected virtual void AllWhiteSpaceUntil(CXSourceLocation from, WhiteSpaceNewLineMode newlineMode)
{
StringView file;
uint32 offset;
@@ -779,7 +781,7 @@ abstract class Cpp2BeefGenerator
str.Append(')');
}
protected void AccessSpecifier(CXCursor cursor)
protected virtual void AccessSpecifier(CXCursor cursor)
{
switch (Clang.GetCXXAccessSpecifier(cursor))
{
@@ -790,6 +792,11 @@ abstract class Cpp2BeefGenerator
}
}
protected virtual bool IsEmptyStructOpaque(CXCursor cursor)
{
return true;
}
protected mixin BeginBody(CXCursor cursor)
{
fileInfo.prevEnd = GetCursorAnchor(cursor);
@@ -817,6 +824,8 @@ abstract class Cpp2BeefGenerator
switch (cursor.kind)
{
case .StructDecl, .UnionDecl, .ClassDecl:
if (!IsEmptyStructOpaque(cursor))
fallthrough;
str.Append(';');
default:
str.Append(" {}");
@@ -1392,18 +1401,21 @@ abstract class Cpp2BeefGenerator
{
Self self = (.)Internal.UnsafeCastToObject(client_data);
Runtime.Assert(cursor.kind == .EnumConstantDecl);
self.BeginCursor(cursor);
self.WriteCustomAttributes(cursor);
self.GetNameInBindings(cursor, self.str);
self.WriteTokensAfterEquals(cursor);
//Clang.GetEnumConstantDeclValue(cursor).ToString(self.str);
self.str.Append(',');
self.HandleCursor(cursor);
return .Continue;
}, Internal.UnsafeCastToPtr(this));
}
protected virtual void EnumConstantDecl(CXCursor cursor)
{
BeginCursor(cursor);
WriteCustomAttributes(cursor);
GetNameInBindings(cursor, str);
WriteTokensAfterEquals(cursor);
//Clang.GetEnumConstantDeclValue(cursor).ToString(str);
str.Append(',');
}
protected virtual void TypeAlias(CXCursor cursor)
{
CXType type;