Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
da9898d
Fix "pstring" docs subsection header to include mention of "encoding"
emnpiex Apr 30, 2026
5a39091
Fix "utils" markdown document to specify JSON as language of example …
emnpiex Apr 30, 2026
85b611b
Fix spacing on "pstring"'s "encoding" argument to conform to existing…
emnpiex Apr 30, 2026
432d3cb
Fix 'langauge' typo
emnpiex Apr 30, 2026
c050dcb
Fix optionality qualifier at beginning of word in subsection header
emnpiex Apr 30, 2026
50e58ee
Fix primitives doc "cstring" subsection header to include its arguments
emnpiex Apr 30, 2026
ec8d840
Fix consistency on docs' subsection headers for types with no arguments
emnpiex Apr 30, 2026
e6eb764
Fix consistency on how types are printed in subsection headers
emnpiex Apr 30, 2026
920e4cf
Fix "cstring" example correctly describes what it is
emnpiex Apr 30, 2026
995c625
Fix null-termination grammar
emnpiex Apr 30, 2026
7958660
Fix "cstring" subsection "Arguments" list conforms to how other argum…
emnpiex Apr 30, 2026
a8a138d
Fix "Example" subsubsection header appends newline consistently
emnpiex Apr 30, 2026
e5a5646
Fix "big" argument of "bitflags" type documentation to specify what t…
emnpiex Apr 30, 2026
7328f94
Fix unnecessary array encapsulation is removed
emnpiex Apr 30, 2026
57a9ff4
Fix unnecessary array encapsulation is removed
emnpiex Apr 30, 2026
6751260
Merge branch 'fix/int-schema-size-not-in-array' into feat/minimum-and…
emnpiex Apr 30, 2026
23f2fce
Fix schemas are consistently titled
emnpiex Apr 30, 2026
9ecf054
Merge branch 'fix/title-schemas' into feat/minimum-and-maximum-on-int…
emnpiex Apr 30, 2026
71bd309
Add `minimum` and `maximum` arguments to integer types' documentation
emnpiex Apr 30, 2026
9440e28
Add example for `minimum` and `maximum` arguments to "int" type's sub…
emnpiex Apr 30, 2026
d8b379e
Add more JSON examples to "varint" doc
emnpiex Apr 30, 2026
2981751
Update schemas for optionally settable integer arguments
emnpiex Apr 30, 2026
6a88164
Fix missing maximum and minimum schemas on sized integers
emnpiex May 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/datatypes/conditional.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ For `compareTo` variables, to go up one level when referencing a field, use "../
Switch statement field names starting with "/" will reference a root variable. Root variables are primitives that can be used for comparisons and changed dynamically.

Example:

A switch which can encode a byte, a varint, a float or a string depending on "someField".
If the value of someField is different, then the value encoded is of type void.
```json
Expand Down Expand Up @@ -43,7 +42,8 @@ Represents a simple optional type.
It's encoded as a boolean indicating whether the value is there or not.
It's similar to the `Optional` type in java or `Maybe` in haskell.

Example: An option of value string
Example:
An option of value string
```json
[
"option",
Expand Down
68 changes: 57 additions & 11 deletions doc/datatypes/numeric.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,44 +21,90 @@ They default to big-endian encoding. To use little-endian, prefix its name with
| zigzag32 | 1-4 | -100 | signed int var |
| zigzag64 | 1-8 | -680n | signed long |

### **int** ({ size: Integer })
### **int** ({ size: Integer, ?minimum: Integer, ?maximum: Integer })
Arguments:
* size : fixed size in bytes
* minimum : optional, the minimum integer value
* maximum : optional, the maximum integer value

Represents a unsigned integer using `size` bytes.

Example:
```json
[
"int",
{ "size": "3" }
{ "size": "3", "minimum": 14, "maximum": 15 }
]
```
Example of value: `65535` (size = 2) / `16777215` (size = 3)

### **varint** ( )
Example:
```json
[
"int",
{ "size": "1", "minimum": 1, "maximum": 100 }
]
```
Example of value: `1`, `100` (does not match `0` or `101`)

### **varint** ({ ?minimum: Integer, ?maximum: Integer })
Arguments: None

[Protobuf](https://developers.google.com/protocol-buffers/docs/encoding#varints)-compatible representation for variable-length integers using one or more bytes. Intended for 32-bit unsigned integers, or signed 32-bit integers that have been directly cast to an integer (where the MSB is the sign bit) before encoding.

Example:
```json
"varint"
```

or
```json
[
"varint"
]
```

or
```json
[
"varint",
{}
]
```

or
```json
[
"varint",
{ "minimum": 1, "maximum": 100 }
]
```
Example of value: `300` (size is 2 bytes)

### **varint64** ()
Arguments: None
### **varint64** ({ ?minimum: Integer, ?maximum: Integer })
Arguments:
* minimum : optional, the minimum integer value
* maximum : optional, the maximum integer value

Same as **varint**, but for 64-bit unsigned integers, or signed 64-bit integers that have been directly cast to an integer (where the MSB is the sign bit) before encoding.

### **varint128** ()
Arguments: None
### **varint128** ({ ?minimum: Integer, ?maximum: Integer })
Arguments:
* minimum : optional, the minimum integer value
* maximum : optional, the maximum integer value

Same as **varint**, but for 128-bit unsigned integers, or signed 128-bit integers that have been directly cast to an integer (where the MSB is the sign bit) before encoding.

### **zigzag32** ()
Arguments: None
### **zigzag32** ({ ?minimum: Integer, ?maximum: Integer })
Arguments:
* minimum : optional, the minimum integer value
* maximum : optional, the maximum integer value

Similar to **varint**, except using [ZigZag encoding](https://protobuf.dev/programming-guides/encoding/#signed-ints) for signed integers. Intended for 32-bit signed numbers.

### **zigzag64** ()
Arguments: None
### **zigzag64** ({ ?minimum: Integer, ?maximum: Integer })
Arguments:
* minimum : optional, the minimum integer value
* maximum : optional, the maximum integer value

Same as **zigzag32**, but for 64-bit signed integers in ZigZag encoding.
14 changes: 7 additions & 7 deletions doc/datatypes/primitives.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
## Primitives

### **bool** ( )
### **bool** ()
Arguments: None

Represents a boolean, encoded in one byte.

Example of value: `true` / `false`

### **cstring** ( )
Arguments: encoding
### **cstring** ({ ?encoding: String })
Arguments:
* encoding : the encoding of the string, UTF-8 by default

Represents a null terminated string. Similar to strings in C.
Assumes UTF-8 encoding by default
Represents a null-terminated string. Similar to strings in C.

Example:
Example: A string length prefixed by a varint.
A UTF-16 string of unknown size that is expected to end with the zero character (null-terminal).
```json
[
"cstring", { "encoding": "utf-16" }
Expand All @@ -23,7 +23,7 @@ Example: A string length prefixed by a varint.

Example of value: `"my string"`

### **void** ( )
### **void** ()
Arguments: None

Represents an empty value.
Expand Down
11 changes: 7 additions & 4 deletions doc/datatypes/structures.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Arguments:

Represents a list of values with same type.

Example: An array of int prefixed by a short length.
Example:
An array of int prefixed by a short length.
```json
[
"array",
Expand All @@ -20,7 +21,7 @@ Example: An array of int prefixed by a short length.
```
Example of value: `[1, 2, 3, 4]` (type = [i8](./numeric.md)) / `["ac", "dc"]` (type = [cstring](./utils.md))

### **container** ([ { name: String, type: Type, ?anon: Bool }, ... ])
### **container** ([ { name: String, type: Type, ?anon: Boolean }, ... ])
Arguments:
* [array] : a field
* * name : the name of field
Expand All @@ -29,7 +30,8 @@ Arguments:

Represents a list of named values.

Example: A container with fields of type int, int, ushort and ushort.
Example:
A container with fields of type int, int, ushort and ushort.
```json
[
"container",
Expand Down Expand Up @@ -57,7 +59,8 @@ Arguments:

Represents a count field for an array or a buffer.

Example: A count for a field name records, of type short.
Example:
A count for a field name records, of type short.
```json
[
"count",
Expand Down
25 changes: 13 additions & 12 deletions doc/datatypes/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Arguments:

Represents a raw bytes with count prefix/field or without it.

Example: An buffer prefixed by a varint length.
Example:
An buffer prefixed by a varint length.
```json
[
"buffer",
Expand All @@ -29,7 +30,6 @@ Represents a list of value with sizes that are not a multiple of 8bits.
The sum of the sizes must be a multiple of 8.

Example:

3 values, x, y and z with sizes in bits : 26, 12, 26. Notice that 26+12+26=64.
```json
[
Expand All @@ -52,7 +52,6 @@ Arguments:
Maps string to a values.

Example:

Maps a byte to a string, 1 to "byte", 2 to "short", 3 to "int", 4 to "long".
```json
[
Expand All @@ -70,17 +69,16 @@ Maps a byte to a string, 1 to "byte", 2 to "short", 3 to "int", 4 to "long".
```
Example of value: `"int"`

### **bitflags** ([ { type: string, flags: object | array, big?: boolean, shift?: number } ])
### **bitflags** ([ { type: String, flags: Object | Array, ?big: Boolean, ?shift: Number } ])
Arguments:
* type : The underlying integer type (eg varint, lu32).
* flags : Either an array of flag values from LSB to MSB, or an object containing a mappng of valueName => bitMask.
* big : 64+ bits. In langauges like javascript (where all numbers are 64-bit floating points), special data types may have to be used for integers greater than 32 bits, so this must be set to true if the `type` is using the special data type.
* big : If the type is 64+ bits. In languages like javascript (where all numbers are 64-bit floating points), special data types may have to be used for integers greater than 32 bits, so this must be set to true if the `type` is using the special data type.
* shift : Specify if flags is an object and holds bit positions as values opposed to a bitmask.

Represents boolean flags packed into an integer. Similar to bitfields, but only intended for enumerated boolean flags (each flag occupies 1 bit), and supports arbitrary underlying integer types.

Example:

```json
[
"bitflags",
Expand All @@ -92,32 +90,35 @@ Example:
```

or
```yaml
```json
[
"bitflags",
{
"type": "lu32",
"big": true,
"flags": {
"onGround": 0b1,
"inAir": 0b10
"onGround": 1,
"inAir": 2
}
}
]
```

where `1` and `2` respectively are the JSON-compatible, decimal representations of the bitmasks `0b01` and `0b10`.

Example of value to pass when writing: `{"flags": { "onGround": true, "inAir": false } }`. Likewise when reading you will get a similar object back, with a extra `_value` field holding the raw integer.


### **pstring** ({ countType: Type, ?count: Countable })
### **pstring** ({ countType: Type, ?count: Countable, ?encoding: String })
Arguments:
* countType : the type of the length prefix
* count : optional (either count or countType), a reference to the field counting the elements, or a fixed size (an integer)
* encoding: the encoding of the string, UTF-8 by default
* encoding : the encoding of the string, UTF-8 by default

Represents a string.

Example: A string length prefixed by a varint.
Example:
A string length prefixed by a varint.
```json
[
"pstring", { "countType": "varint", "encoding": "utf-8" }
Expand Down
Loading