Skip to content

Commit 8e65ee6

Browse files
committed
Work on TransformHandles docs
1 parent cfce994 commit 8e65ee6

2 files changed

Lines changed: 29 additions & 5 deletions

File tree

docs/for-contributors/Generator/generator-mods.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,13 +599,34 @@ The `BoolTypes` property in the configuration should match the configuration use
599599

600600
Mod categories: Transformation
601601

602+
This mod focuses on the transformation of opaque structs into more developer-friendly handle types.
603+
604+
This is done by finding references to empty structs. If all references to the empty struct are done through pointers,
605+
that struct will be treated as a handle type and transformed.
606+
607+
Empty structs identified as handle types will be transformed in two ways:
608+
609+
1. The struct itself will be transformed to wrap the underlying pointer and have methods/operators added for ease of
610+
use.
611+
612+
2. All references to that struct will have their pointer dimension reduced. For example, `VkBuffer**` becomes
613+
`VkBuffer*` This is because the mentioned struct transformation means that the innermost pointer dimension is now
614+
stored inside the struct.
615+
616+
This mod currently only processes handle types that wrap pointer types. Integer types are not yet supported.
617+
602618
Name affix categories:
603619

604-
- `HandleType` - TODO
620+
- `HandleType` - This is a suffix added to handle types transformed by `TransformedHandles`. Note that
621+
`TransformHandles` only adds the attribute and does not rename the actual handle type. This is so that the rename is
622+
deferred until `PrettifyNames` where all renames are done in bulk for performance reasons. This pattern is explained
623+
in the [Name Processing - Deferring Renames](name-processing.md#deferring-renames) documentation.
605624

606625
Usage recommendations:
607626

608-
(TODO: To be added)
627+
This mod should be placed after `ExtractHandles` and `AddOpaqueStructs`. This is because `TransformHandles` relies on
628+
the previously mentioned mods to add the empty struct types. `TransformHandles` itself does not add new structs, it only
629+
transforms existing ones that it identifies as a handle type.
609630

610631
### TransformProperties
611632

sources/SilkTouch/SilkTouch/Mods/TransformHandles.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,19 @@
1515
namespace Silk.NET.SilkTouch.Mods;
1616

1717
/// <summary>
18-
/// Identifies handle types by finding pointers to empty structs or missing types.
18+
/// Identifies handle types by finding pointers to empty structs.
1919
/// In general, a handle type is a struct that wraps an underlying opaque pointer (or some other underlying value).
2020
/// These handle types are then transformed by making the struct wrap the underlying pointer and
2121
/// reducing the dimension of pointers referencing that handle type by one.
2222
/// </summary>
2323
/// <example>
2424
/// Given an empty struct, <c>struct VkBuffer</c>, and all usages of that struct are through a pointer,
25-
/// <c>VkBuffer*</c>, usages of that pointer will be replaced by <c>VkBufferHandle</c>. For a 2-dimensional pointer,
26-
/// <c>VkBuffer**</c>, the resulting replacement is <c>VkBufferHandle*</c>.
25+
/// <c>VkBuffer*</c>, usages of that pointer will be replaced by <c>VkBuffer</c>. For a 2-dimensional pointer,
26+
/// <c>VkBuffer**</c>, the resulting replacement is <c>VkBuffer*</c>.
2727
/// </example>
28+
/// <remarks>
29+
/// The `Handle` suffix is not applied until <see cref="PrettifyNames"/> executes.
30+
/// </remarks>
2831
[ModConfiguration<Config>]
2932
public class TransformHandles(
3033
IOptionsSnapshot<TransformHandles.Config> config,

0 commit comments

Comments
 (0)