Skip to content

Commit de9704b

Browse files
committed
Work on docs for MarkNativeNames
1 parent 27f6d5b commit de9704b

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,30 @@ intercepting these native functions is so that function pointers can be automati
341341

342342
Mod categories: Metadata, Naming
343343

344+
This mod naively adds `[NativeName]` attributes to most identifiers in the generated bindings and is designed to be
345+
placed immediately after `ClangScraper`. Syntax nodes that are not output by `ClangScraper` are intentionally not
346+
processed.
347+
348+
The name stored by the `[NativeName]` attribute matches the C# identifier at the time the mod runs. This assumes that
349+
the name used by the C# source code matches the name used by the native source code, which is *usually* the case when
350+
this mod is placed immediately after `ClangScraper`. However, there are cases where the names output by `ClangScraper`
351+
do not correspond to native names. These cases are usually because there is no native name available, such as for
352+
inline array types (named in the format `_name_e__FixedBuffer`) or backing fields used by bitfield structs (named
353+
`_bitfield`).
354+
344355
Usage recommendations:
345356

357+
As mentioned, this mod is best used immediately after `ClangScraper` runs. This should mark all identifiers output
358+
by `ClangScraper` itself.
359+
360+
However, do not assume that this mod is sufficient to mark all identifiers present in the final set of generated
361+
bindings. When other mods introduce new identifiers, those mods will need to add `[NativeName]` attributes themselves,
362+
or have another mod do it for them, in the case those identifiers represent a native API.
363+
364+
Because the name stored as the value for `[NativeName]` comes from the native API, it can be used as a stable identifier
365+
for an API. This is in contrast to the current C# identifier being used, as that identifier is often transformed by mods
366+
such as `[PrettifyNames]`.
367+
346368
### MixKhronosData
347369

348370
Mod categories: Creation, Metadata, Naming, Transformation

sources/SilkTouch/SilkTouch/Mods/MarkNativeNames.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Silk.NET.SilkTouch.Mods;
1111
/// </summary>
1212
/// <remarks>
1313
/// This mod is currently kept pretty dumb and just applies [NativeName] attributes to almost everything.
14-
/// Syntax nodes not output by ClangSharp are intentionally not processed.
14+
/// Syntax nodes not output by ClangScraper are intentionally not processed.
1515
/// This mod is best placed directly after ClangScraper.
1616
/// </remarks>
1717
public class MarkNativeNames : IMod

0 commit comments

Comments
 (0)