@@ -251,10 +251,9 @@ KS enforces specific identifier style in the language -
251251styles of identifier spelling, like `UpperCamelCase` or
252252`lowerCamelCase`, which some target languages use).
253253
254- KS allows omitting `id`. One MUST omit `id` to mark up attributes of
255- unknown/undetermined purpose, i.e. unfinished reverse engineering
256- work. One MUST NOT omit `id` to mark up reserved/unused attributes and
257- padding, i.e. placeholder that are known to be empty and unused.
254+ KS allows omitting `id`. One MUST NOT omit `id` to mark up reserved/unused
255+ attributes and padding, i.e. placeholder that are known to be empty
256+ and unused.
258257
259258One SHOULD use the following rules to maintain consistency across
260259various KSY files. Doing that would maintain the "principle of least
@@ -263,28 +262,37 @@ guesswork.
263262
264263* For simple non-repeated fields, use a simple singular form —
265264 e.g. `width`, `header`, `transaction_id`, `file`.
266- * For an array of objects (i.e. with `repeat: something`), use plural
265+ * For a sequence of objects (i.e. with `repeat: something`), use plural
267266 form — e.g. `files`, `transactions`.
268267* Don't be overly verbose: use commonly understood abbreviations
269268 liberally, if it will improve readability — e.g. `src_mac` or
270269 `src_mac_addr` instead of `source_media_access_control_address`
270+ * Repeated fields which cannot be packed into a sequence should
271+ have `id`s containing a number in the end. Numbers may have a
272+ visually-obvious structure, like "the first digit is major, the second
273+ one is minor".
271274* For fields that are designed to be used to detect file type (AKA
272- "magic values"), use `magic` name, or, if there are several of them,
273- `magic1` , `magic2 `, etc.
275+ "magic values"), use `signature` or ` magic` name, or, if there are
276+ several of them, like `signature` or `magic0` , `magic1 `, etc.
274277* For reserved fields which are *known* to be unused, use `reserved`
275- name (or `reserved1 `, `reserved2 `, etc, if there are many of them)
278+ name (or `reserved0 `, `reserved1 `, etc, if there are many of them)
276279* For fields that designate *number / count* of something (in
277- particular, number of repetitions of some other structure), use
278- `num_` prefix and plural form — i.e. `num_questions`, `num_blocks`,
279- `num_nodes`
280+ particular, number of repetitions of some other structure), use either
281+ `_count` suffix and a plural form, contrary to prescribed by English
282+ grammar, — i.e. `questions_count`, `blocks_count`, `nodes_count`
283+ (mentally replace `_count` by `.count` to understand the logic
284+ behind that).
280285* For fields that designate *offset* to some particular data structure,
281- use `ofs_` prefix and name of that data structure (as it would appear
282- in the file) — i.e. `ofs_block `, `ofs_queries `, `ofs_path `
286+ use `_offset` suffix and name of that data structure (as it would
287+ appear in the file) — i.e. `block_offset `, `queries_offset `, `path_offset `
283288* For fields that designate *size* of some particular data structure
284- (in bytes or some other fixed units), use `len_` prefix and name of
285- that data structure — i.e. `len_block ` (length of a single `block`
286- entry), `len_blocks ` (total length of whole `blocks` array, made of
289+ (in bytes or some other fixed units), use `_size` suffix and name of
290+ that data structure — i.e. `block_size ` (length of a single `block`
291+ entry), `blocks_size ` (total length of whole `blocks` array, made of
287292 `block` entries).
293+ * Fields of unknown/undetermined purpose, i.e. unfinished reverse
294+ engineering work SHOULD either NOT HAVE an `id` or HAVE an
295+ `id` matching the `/unkn(?:own)?(_\w+)?\d*/` regular expression.
288296
289297[NOTE]
290298See <<transcribing>> for more info on preserving / renaming
@@ -367,6 +375,13 @@ here as well. Keys MUST appear in this order:
367375. All other keys (except for `id` and `-orig-id`), in order specified
368376 in <<seq-attr>>
369377
378+ [[enum-attr]]
379+ == Enum attributes
380+
381+ * In the case of multiple enums with the same name it's usually
382+ better to append the integer value rather than a sequence
383+ number to its `id`.
384+
370385[[transcribing]]
371386== Transcribing existing specs
372387
0 commit comments