Skip to content

Commit 0228a56

Browse files
committed
Implement referenced affixes and change how -Delegate types generated for function pointer types are named
1 parent 14d9d65 commit 0228a56

83 files changed

Lines changed: 124 additions & 122 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.silktouch/vulkan-clangsharp.stout

0 Bytes
Binary file not shown.

sources/SilkTouch/SilkTouch/Mods/MixKhronosData.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,9 +1915,8 @@ private SyntaxList<AttributeListSyntax> ProcessAndGetNewAttributes(
19151915
MethodDeclarationSyntax? methodDeclaration = null
19161916
)
19171917
{
1918-
// Get the name of the identifier, preferring the native one if available
19191918
// This name will be modified by the code below as different suffixes are identified
1920-
var trimmedName = attributeLists.GetNativeNameOrDefault(identifier);
1919+
var trimmedName = identifier.ToString();
19211920

19221921
if (trimHandleSuffix)
19231922
{

sources/SilkTouch/SilkTouch/Mods/PrettifyNames.cs

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ z.MethodKind is MethodKind.Constructor or MethodKind.Destructor
401401
ctx.SourceProject = proj;
402402
}
403403

404+
// TODO: Remove this method and unify the name processing code.
404405
/// <summary>
405406
/// Applies the prettify only pipeline.
406407
/// This currently consists of checking for name overrides first.
@@ -455,7 +456,7 @@ NamePrettifier namePrettifier
455456
var result = name;
456457
result = nameAffixer.RemoveAffixes(result, container, name, null);
457458
result = namePrettifier.Prettify(result, allowAllCaps);
458-
result = nameAffixer.ApplyAffixes(result, container, name, null);
459+
result = nameAffixer.ApplyAffixes(result, container, name, null, null);
459460
result = NameUtils.PrefixIfStartsWithNumber(result);
460461

461462
return result;
@@ -1240,12 +1241,14 @@ public string RemoveAffixes(
12401241
/// <param name="container">The container name. Either null or the containing type.</param>
12411242
/// <param name="originalName">The original name of the identifier. Either the type name or the member name.</param>
12421243
/// <param name="secondary">The list of secondary names. This should be null if used by <see cref="ApplyPrettifyOnlyPipeline"/>.</param>
1244+
/// <param name="context">The context containing the current names for the current container.</param>
12431245
/// <returns>The new primary name.</returns>
12441246
public string ApplyAffixes(
12451247
string primary,
12461248
string? container,
12471249
string originalName,
1248-
List<string>? secondary
1250+
List<string>? secondary,
1251+
NameProcessorContext? context // TODO: Handle this better. Exposing the entire context is excessive.
12491252
)
12501253
{
12511254
var affixes = GetAffixes(container, originalName);
@@ -1333,15 +1336,28 @@ void CreateName(string name, Span<NameAffix> currentAffixes)
13331336

13341337
foreach (var affix in currentAffixes)
13351338
{
1339+
var affixValue = affix.Affix;
1340+
if (
1341+
affix.IsReference
1342+
&& context.HasValue
1343+
&& context.Value.Names.TryGetValue(
1344+
affixValue,
1345+
out var referencedCandidateNames
1346+
)
1347+
)
1348+
{
1349+
affixValue = referencedCandidateNames.Primary;
1350+
}
1351+
13361352
if (!GetConfiguration(affix).Remove)
13371353
{
13381354
if (affix.Type == NameAffixType.Prefix)
13391355
{
1340-
name = affix.Affix + name;
1356+
name = affixValue + name;
13411357
}
13421358
else
13431359
{
1344-
name += affix.Affix;
1360+
name += affixValue;
13451361
}
13461362
}
13471363
}
@@ -1363,7 +1379,7 @@ void CreateName(string name, Span<NameAffix> currentAffixes)
13631379
/// <param name="container">The container name. Either null or the containing type.</param>
13641380
/// <param name="originalName">The original name of the identifier. Either the type name or the member name.</param>
13651381
/// <returns>The name affixes for the specified identifier.</returns>
1366-
private NameAffix[] GetAffixes(string? container, string originalName)
1382+
public NameAffix[] GetAffixes(string? container, string originalName)
13671383
{
13681384
TypeAffixData typeAffixData;
13691385
if (container == null)
@@ -1404,18 +1420,6 @@ private class StripAffixesProcessor(PrettifyNamesAffixer affixer) : INameProcess
14041420
{
14051421
public void ProcessNames(NameProcessorContext context)
14061422
{
1407-
if (context.Container == null)
1408-
{
1409-
foreach (var (original, (primary, secondary)) in context.Names)
1410-
{
1411-
var secondaries = secondary;
1412-
var newPrimary = affixer.RemoveAffixes(primary, null, original, secondaries);
1413-
context.Names[original] = new CandidateNames(newPrimary, secondaries);
1414-
}
1415-
1416-
return;
1417-
}
1418-
14191423
foreach (var (original, (primary, secondary)) in context.Names)
14201424
{
14211425
var secondaries = secondary;
@@ -1425,6 +1429,7 @@ public void ProcessNames(NameProcessorContext context)
14251429
original,
14261430
secondaries
14271431
);
1432+
14281433
context.Names[original] = new CandidateNames(newPrimary, secondaries);
14291434
}
14301435
}
@@ -1459,27 +1464,25 @@ private class ReapplyAffixesProcessor(PrettifyNamesAffixer affixer) : INameProce
14591464
{
14601465
public void ProcessNames(NameProcessorContext context)
14611466
{
1462-
if (context.Container == null)
1463-
{
1464-
foreach (var (original, (primary, secondary)) in context.Names)
1465-
{
1466-
var secondaries = secondary;
1467-
var newPrimary = affixer.ApplyAffixes(primary, null, original, secondaries);
1468-
context.Names[original] = new CandidateNames(newPrimary, secondaries);
1469-
}
1470-
1471-
return;
1472-
}
1467+
var processingOrder = context
1468+
.Names.Keys.OrderBy(original =>
1469+
affixer.GetAffixes(context.Container, original).Any(x => x.IsReference)
1470+
)
1471+
.ToArray();
14731472

1474-
foreach (var (original, (primary, secondary)) in context.Names)
1473+
foreach (var original in processingOrder)
14751474
{
1475+
var (primary, secondary) = context.Names[original];
1476+
14761477
var secondaries = secondary;
14771478
var newPrimary = affixer.ApplyAffixes(
14781479
primary,
14791480
context.Container,
14801481
original,
1481-
secondaries
1482+
secondaries,
1483+
context
14821484
);
1485+
14831486
context.Names[original] = new CandidateNames(newPrimary, secondaries);
14841487
}
14851488
}

sources/Vulkan/Vulkan/Vulkan/DebugMarkerMarkerInfoEXT.gen.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ public unsafe partial struct DebugMarkerMarkerInfoEXT
2626

2727
[NativeName("color")]
2828
[SupportedApiProfile("vulkan", ["VK_EXT_debug_marker"], ImpliesSets = ["VK_EXT_debug_report"])]
29-
public DebugMarkerMarkerInfoExtColor Color;
29+
public DebugMarkerMarkerInfoEXTColor Color;
3030
}

sources/Vulkan/Vulkan/Vulkan/DebugMarkerMarkerInfoExtColor.gen.cs renamed to sources/Vulkan/Vulkan/Vulkan/DebugMarkerMarkerInfoEXTColor.gen.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan;
1111
[NativeName("_color_e__FixedBuffer")]
1212
[InlineArray(4)]
1313
[SupportedApiProfile("vulkan")]
14-
public partial struct DebugMarkerMarkerInfoExtColor
14+
public partial struct DebugMarkerMarkerInfoEXTColor
1515
{
1616
[NativeName("e0")]
1717
[SupportedApiProfile("vulkan")]

sources/Vulkan/Vulkan/Vulkan/DebugReportCallbackEXT.gen.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public DebugReportCallbackEXT(
5252
) => Pointer = ptr;
5353

5454
[SupportedApiProfile("vulkan", ["VK_EXT_debug_report"])]
55-
public DebugReportCallbackEXT(DebugReportCallbackDelegateEXT proc) =>
55+
public DebugReportCallbackEXT(DebugReportCallbackEXTDelegate proc) =>
5656
Pointer = SilkMarshal.DelegateToPtr(proc);
5757

5858
[SupportedApiProfile("vulkan", ["VK_EXT_debug_report"])]

sources/Vulkan/Vulkan/Vulkan/DebugReportCallbackDelegateEXT.gen.cs renamed to sources/Vulkan/Vulkan/Vulkan/DebugReportCallbackEXTDelegate.gen.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Silk.NET.Vulkan;
1010

1111
[NativeName("PFN_vkDebugReportCallbackEXT")]
1212
[SupportedApiProfile("vulkan")]
13-
public unsafe delegate uint DebugReportCallbackDelegateEXT(
13+
public unsafe delegate uint DebugReportCallbackEXTDelegate(
1414
DebugReportFlagsEXT arg0,
1515
DebugReportObjectTypeEXT arg1,
1616
ulong arg2,

sources/Vulkan/Vulkan/Vulkan/DebugUtilsLabelEXT.gen.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ public unsafe partial struct DebugUtilsLabelEXT
2626

2727
[NativeName("color")]
2828
[SupportedApiProfile("vulkan", ["VK_EXT_debug_utils"])]
29-
public DebugUtilsLabelExtColor Color;
29+
public DebugUtilsLabelEXTColor Color;
3030
}

sources/Vulkan/Vulkan/Vulkan/DebugUtilsLabelExtColor.gen.cs renamed to sources/Vulkan/Vulkan/Vulkan/DebugUtilsLabelEXTColor.gen.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Silk.NET.Vulkan;
1111
[NativeName("_color_e__FixedBuffer")]
1212
[InlineArray(4)]
1313
[SupportedApiProfile("vulkan")]
14-
public partial struct DebugUtilsLabelExtColor
14+
public partial struct DebugUtilsLabelEXTColor
1515
{
1616
[NativeName("e0")]
1717
[SupportedApiProfile("vulkan")]

sources/Vulkan/Vulkan/Vulkan/DebugUtilsMessengerCallbackEXT.gen.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public DebugUtilsMessengerCallbackEXT(
4040
) => Pointer = ptr;
4141

4242
[SupportedApiProfile("vulkan", ["VK_EXT_debug_utils"])]
43-
public DebugUtilsMessengerCallbackEXT(DebugUtilsMessengerCallbackDelegateEXT proc) =>
43+
public DebugUtilsMessengerCallbackEXT(DebugUtilsMessengerCallbackEXTDelegate proc) =>
4444
Pointer = SilkMarshal.DelegateToPtr(proc);
4545

4646
[SupportedApiProfile("vulkan", ["VK_EXT_debug_utils"])]

0 commit comments

Comments
 (0)