Skip to content

Commit 298d017

Browse files
authored
Define a set of schemas for ISO/IEC 9899:2024 (C23) (#34)
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent ed15317 commit 298d017

23 files changed

+1088
-0
lines changed

README.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ expressed as JSON Schema definitions.
6666
| ISO | [ISO 8601-1:2019](https://www.iso.org/standard/70907.html) | Date and time — Representations for information interchange — Part 1: Basic rules |
6767
| ISO | [ISO 80000-1:2022](https://www.iso.org/standard/76921.html) | Quantities and units — Part 1: General |
6868
| ISO/IEC | [ISO/IEC 2382:2015](https://www.iso.org/standard/63598.html) | Information technology — Vocabulary |
69+
| ISO/IEC | [ISO/IEC 9899:2024](https://www.iso.org/standard/82075.html) | Programming languages — C |
6970
| JSON-RPC | [JSON-RPC 2.0](https://www.jsonrpc.org/specification) | JSON-RPC 2.0 Specification |
7071
| JSON Schema | [Draft 2020-12](https://json-schema.org/draft/2020-12/json-schema-core) | JSON Schema: A Media Type for Describing JSON Documents |
7172

schemas/iso/c/2024/bool.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "ISO/IEC 9899:2024 Boolean Type (bool)",
4+
"description": "A boolean type that can hold the values 0 (false) or 1 (true)",
5+
"$comment": "In C, bool is represented as an integer type that can only hold 0 or 1. Defined in `<stdbool.h>` as `_Bool`",
6+
"examples": [ 0, 1 ],
7+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
8+
"x-links": [ "https://www.iso.org/standard/82075.html" ],
9+
"enum": [ 0, 1 ]
10+
}

schemas/iso/c/2024/double.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "ISO/IEC 9899:2024 Double Precision Floating Point (double)",
4+
"description": "A double precision (64-bit) floating point type conforming to IEC 60559 (IEEE 754)",
5+
"$comment": "The minimum and maximum represent `DBL_MAX` and `-DBL_MAX`. Special floating-point values are defined in a separate schema",
6+
"examples": [
7+
0.0,
8+
1.5,
9+
-3.14159,
10+
299800000.0,
11+
179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0,
12+
-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0,
13+
"NAN",
14+
"INFINITY",
15+
"-INFINITY"
16+
],
17+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
18+
"x-links": [ "https://www.iso.org/standard/82075.html" ],
19+
"anyOf": [
20+
{
21+
"type": "number",
22+
"maximum": 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0,
23+
"minimum": -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0
24+
},
25+
{
26+
"$ref": "./float-special.json"
27+
}
28+
]
29+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "ISO/IEC 9899:2024 Special Floating-Point Values",
4+
"description": "Special floating-point values as defined in `<math.h>`. These are represented as strings since JSON numbers cannot express these values",
5+
"examples": [ "NAN", "INFINITY", "-INFINITY" ],
6+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
7+
"x-links": [ "https://www.iso.org/standard/82075.html" ],
8+
"enum": [ "NAN", "INFINITY", "-INFINITY" ]
9+
}

schemas/iso/c/2024/float.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "ISO/IEC 9899:2024 Single Precision Floating Point (float)",
4+
"description": "A single precision (32-bit) floating point type conforming to IEC 60559 (IEEE 754)",
5+
"$comment": "The minimum and maximum represent `FLT_MAX` and `-FLT_MAX`. Special floating-point values are defined in a separate schema",
6+
"examples": [
7+
0.0,
8+
1.5,
9+
-3.14,
10+
340282346600000016151267322115014000640.0,
11+
-340282346600000016151267322115014000640.0,
12+
"NAN",
13+
"INFINITY",
14+
"-INFINITY"
15+
],
16+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
17+
"x-links": [ "https://www.iso.org/standard/82075.html" ],
18+
"anyOf": [
19+
{
20+
"type": "number",
21+
"maximum": 340282346600000016151267322115014000640.0,
22+
"minimum": -340282346600000016151267322115014000640.0
23+
},
24+
{
25+
"$ref": "./float-special.json"
26+
}
27+
]
28+
}

schemas/iso/c/2024/int16_t.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "ISO/IEC 9899:2024 Signed 16-bit Integer (int16_t)",
4+
"description": "A signed integer type with width of exactly 16 bits",
5+
"examples": [ 0, 1, -1, 32767, -32768, 1000, -1000 ],
6+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
7+
"x-links": [ "https://www.iso.org/standard/82075.html" ],
8+
"type": "integer",
9+
"maximum": 32767,
10+
"minimum": -32768
11+
}

schemas/iso/c/2024/int32_t.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "ISO/IEC 9899:2024 Signed 32-bit Integer (int32_t)",
4+
"description": "A signed integer type with width of exactly 32 bits",
5+
"examples": [ 0, 1, -1, 2147483647, -2147483648, 42, -999 ],
6+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
7+
"x-links": [ "https://www.iso.org/standard/82075.html" ],
8+
"type": "integer",
9+
"maximum": 2147483647,
10+
"minimum": -2147483648
11+
}

schemas/iso/c/2024/int64_t.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "ISO/IEC 9899:2024 Signed 64-bit Integer (int64_t)",
4+
"description": "A signed integer type with width of exactly 64 bits",
5+
"examples": [
6+
0,
7+
1,
8+
-1,
9+
9223372036854775807,
10+
-9223372036854775808,
11+
1000000000,
12+
-1000000000
13+
],
14+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
15+
"x-links": [ "https://www.iso.org/standard/82075.html" ],
16+
"type": "integer",
17+
"maximum": 9223372036854775807,
18+
"minimum": -9223372036854775808
19+
}

schemas/iso/c/2024/int8_t.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "ISO/IEC 9899:2024 Signed 8-bit Integer (int8_t)",
4+
"description": "A signed integer type with width of exactly 8 bits",
5+
"examples": [ 0, 1, -1, 127, -128, 42, -99 ],
6+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
7+
"x-links": [ "https://www.iso.org/standard/82075.html" ],
8+
"type": "integer",
9+
"maximum": 127,
10+
"minimum": -128
11+
}

schemas/iso/c/2024/uint16_t.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "ISO/IEC 9899:2024 Unsigned 16-bit Integer (uint16_t)",
4+
"description": "An unsigned integer type with width of exactly 16 bits",
5+
"examples": [ 0, 1, 65535, 32768, 1000 ],
6+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
7+
"x-links": [ "https://www.iso.org/standard/82075.html" ],
8+
"type": "integer",
9+
"maximum": 65535,
10+
"minimum": 0
11+
}

0 commit comments

Comments
 (0)