You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/for-contributors/Generator/name-processing.md
+47-1Lines changed: 47 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -248,6 +248,8 @@ The use of a *lowercase* x in particular is a stylistic choice and matches names
248
248
249
249
## Name Affixes
250
250
251
+
(TODO: Explain how these actually look in metadata/attribute form)
252
+
251
253
Name prefixes and suffixes are used commonly in both native code and in identifiers created by the SilkTouch generator.
252
254
253
255
For example, in `VkPresentInfoKHR` from Vulkan, `Vk-` is a namespace prefix commonly used in C code, while `-KHR` is a
@@ -267,12 +269,56 @@ are handled by `IdentifySharedPrefixes`.
267
269
268
270
### Referenced Affixes
269
271
270
-
(TODO: Explain why referenced affixes exist (compound names and types that are the logical extensions of other types) and when these are used in the generator. Explain how these are processed.)
272
+
(TODO: Explain how these actually look in metadata/attribute form)
273
+
274
+
Referenced affixes were added to handle compound names where part of the name is actually the name of another
275
+
identifier. This ensures that the "referenced" part of the name always matches the name being referenced, in other
276
+
words, changes to the referenced name is "synchronized" to the name referencing it (more on this later).
277
+
278
+
This occurs primarily in types added to the bindings by Silk. For example:
279
+
280
+
-**Nested types** - Nested types are extracted by `ExtractNestedType` to be non-nested types. These types have the name
281
+
of their parent type plus their original name (for nested types that have proper names in the native code) or the name
282
+
of their parent type plus the name of the field that uses them (eg: for `InlineArray` types).
283
+
- Example: `GamepadBinding`, `GamepadBindingInput`, and `GamepadBindingInputAxis` in the SDL bindings. The latter are
284
+
nested structs.
285
+
- Example: `PerformanceCounterDescriptionARM` and `PerformanceCounterDescriptionARMName` in the Vulkan bindings. The
286
+
latter is an inline array used by the field, `PerformanceCounterDescriptionARM.Name`.
287
+
288
+
-**Derived types** - Derived types refer to types that are generated based on another type (not to be confused with
289
+
inheritance). At time of writing, this only refers to function pointer types for which Silk generates a function
290
+
pointer struct and a corresponding delegate type. The delegate type has the `-Delegate` suffix appended to it.
291
+
- Example: `DebugReportCallbackEXT` and `DebugReportCallbackEXTDelegate` in the Vulkan bindings.
292
+
293
+
In other words, referenced affixes are most helpful when dealing with types that are the logical extensions of other
294
+
types.
295
+
296
+
Most notably, handle type suffixes do not fall into the above categorization.
297
+
298
+
For example: `PipelineBinaryHandleKHR` in the Vulkan bindings is not an extension of `PipelineBinaryKHR`, it *is* the
299
+
type, just renamed to avoid naming collisions.
300
+
301
+
Going back to the idea of synchronizing changes, if `GamepadBinding` was to be renamed using an override, the referenced
302
+
affix system ensures that `GamepadBindingInput` and `GamepadBindingInputAxis` are renamed correspondingly.
303
+
304
+
Similarly, it ensures that if an affix is configured to be moved to the end of the referenced name, the affix only moves
305
+
to the end of the name it was originally declared on. This can be seen in `PerformanceCounterDescriptionARMName` and
306
+
`PipelineBinaryHandleKHR`. `ARM` is a Khronos vendor suffix for `PerformanceCounterDescriptionARM`, so it only moves to
307
+
the end of that name; however, `KHR` is a vendor suffix for `PipelineBinaryHandleKHR` as a whole.
308
+
309
+
Side note: Another benefit of referenced affixes is that it ensures that derived types show up when typing the base
310
+
type's name in the IDE. For example, if vendor suffixes always moved to the end of the name,
311
+
`PerformanceCounterDescriptionARMName` would become `PerformanceCounterDescriptionNameARM` and would not show up when
(TODO: Exhaustively list each category being used in the generator. Explain which mods add the affix category. Provide examples on what the affixes look like. Provide recommendations on how each affix should be configured (i.e., should match the configuration used by `generator.json`).)
275
317
318
+
(TODO: This overrides the previous todo. Don't list the affix categories. Just explain them. List them out in the generator-mods.md doc instead.)
319
+
320
+
(TODO: Edit. Just explain them as part of the syntax section for Name Affixes above.)
321
+
276
322
## Symbol-based Renamer
277
323
278
324
(TODO: Explain how the symbol-based renamer works and why `SymbolFinder.FindReferencesAsync` is not used.)
0 commit comments