cf29e39e9e7dac42a7f4f78da07a078c777bdc8f
[deliverable/barectf.git] / barectf / schemas / config / 3 / field-type.yaml
1 # The MIT License (MIT)
2 #
3 # Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be
14 # included in all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24 $schema: http://json-schema.org/draft-07/schema#
25 $id: https://barectf.org/schemas/config/3/field-type.json
26 title: Effective field type object
27 definitions:
28 ft-base:
29 type: object
30 required:
31 - class
32 bit-array-ft:
33 allOf:
34 - $ref: '#/definitions/ft-base'
35 - properties:
36 size:
37 $ref: https://barectf.org/schemas/config/common/common.json#/definitions/int-ft-size-prop
38 alignment:
39 $ref: https://barectf.org/schemas/config/common/common.json#/definitions/opt-int-min-1
40 byte-order:
41 $ref: https://barectf.org/schemas/config/common/common.json#/definitions/opt-byte-order-prop
42 required:
43 - size
44 int-ft-props:
45 properties:
46 class: true
47 size: true
48 alignment: true
49 byte-order: true
50 preferred-display-base: true
51 additionalProperties: false
52 int-ft:
53 allOf:
54 - $ref: '#/definitions/bit-array-ft'
55 - properties:
56 preferred-display-base:
57 $ref: https://barectf.org/schemas/config/common/common.json#/definitions/opt-int-ft-preferred-display-base-prop
58 uint-ft-class-prop:
59 type: string
60 enum:
61 - uint
62 - unsigned-int
63 - unsigned-integer
64 uint-ft:
65 title: Unsigned integer field type object
66 allOf:
67 - $ref: '#/definitions/int-ft'
68 - $ref: '#/definitions/int-ft-props'
69 - properties:
70 class:
71 $ref: '#/definitions/uint-ft-class-prop'
72 sint-ft-class-prop:
73 type: string
74 enum:
75 - sint
76 - signed-int
77 - signed-integer
78 sint-ft:
79 title: Signed integer field type object
80 allOf:
81 - $ref: '#/definitions/int-ft'
82 - $ref: '#/definitions/int-ft-props'
83 - properties:
84 class:
85 $ref: '#/definitions/sint-ft-class-prop'
86 enum-ft-props:
87 properties:
88 class: true
89 size: true
90 alignment: true
91 byte-order: true
92 preferred-display-base: true
93 mappings: true
94 additionalProperties: false
95 enum-ft:
96 properties:
97 mappings:
98 if:
99 type: object
100 then:
101 patternProperties:
102 '.*':
103 type: array
104 items:
105 if:
106 type: array
107 then:
108 items:
109 type: integer
110 minItems: 2
111 maxItems: 2
112 else:
113 type: integer
114 else:
115 type: 'null'
116 properties:
117 class: true
118 size: true
119 alignment: true
120 byte-order: true
121 preferred-display-base: true
122 mappings: true
123 additionalProperties: false
124 uenum-ft-class-prop:
125 type: string
126 enum:
127 - uenum
128 - unsigned-enum
129 - unsigned-enumeration
130 uenum-ft:
131 title: Unsigned enumeration field type object
132 allOf:
133 - $ref: '#/definitions/int-ft'
134 - $ref: '#/definitions/enum-ft'
135 - $ref: '#/definitions/enum-ft-props'
136 - properties:
137 class:
138 $ref: '#/definitions/uenum-ft-class-prop'
139 senum-ft-class-prop:
140 type: string
141 enum:
142 - senum
143 - signed-enum
144 - signed-enumeration
145 senum-ft:
146 title: Signed enumeration field type object
147 allOf:
148 - $ref: '#/definitions/int-ft'
149 - $ref: '#/definitions/enum-ft'
150 - $ref: '#/definitions/enum-ft-props'
151 - properties:
152 class:
153 $ref: '#/definitions/senum-ft-class-prop'
154 real-ft-class-prop:
155 type: string
156 const: real
157 real-ft:
158 title: Real field type object
159 allOf:
160 - $ref: '#/definitions/bit-array-ft'
161 - properties:
162 class:
163 $ref: '#/definitions/real-ft-class-prop'
164 size:
165 enum:
166 - 32
167 - 64
168 properties:
169 class: true
170 size: true
171 alignment: true
172 byte-order: true
173 additionalProperties: false
174 string-ft-class-prop:
175 type: string
176 enum:
177 - str
178 - string
179 string-ft:
180 title: String field type object
181 allOf:
182 - $ref: '#/definitions/ft-base'
183 - properties:
184 class:
185 $ref: '#/definitions/string-ft-class-prop'
186 properties:
187 class: true
188 additionalProperties: false
189 static-array-ft-class-prop:
190 type: string
191 const: static-array
192 static-array-ft:
193 title: Static array field type object
194 allOf:
195 - $ref: '#/definitions/ft-base'
196 - properties:
197 class:
198 $ref: '#/definitions/static-array-ft-class-prop'
199 element-field-type:
200 $ref: '#/definitions/ft'
201 length:
202 type: integer
203 minimum: 0
204 required:
205 - element-field-type
206 - length
207 properties:
208 class: true
209 element-field-type: true
210 length: true
211 additionalProperties: false
212 struct-ft-class-prop:
213 type: string
214 enum:
215 - struct
216 - structure
217 struct-ft-member:
218 type: object
219 properties:
220 field-type:
221 $ref: '#/definitions/ft'
222 required:
223 - field-type
224 additionalProperties: false
225 struct-ft-members:
226 type: array
227 items:
228 type: object
229 patternProperties:
230 '^[A-Za-z_][A-Za-z0-9_]*$':
231 $ref: '#/definitions/struct-ft-member'
232 minProperties: 1
233 maxProperties: 1
234 struct-ft:
235 title: Structure field type object
236 allOf:
237 - $ref: '#/definitions/ft-base'
238 - properties:
239 class:
240 $ref: '#/definitions/struct-ft-class-prop'
241 minimum-alignment:
242 $ref: https://barectf.org/schemas/config/common/common.json#/definitions/opt-int-min-1
243 members:
244 if:
245 type: array
246 then:
247 $ref: '#/definitions/struct-ft-members'
248 else:
249 type: 'null'
250 properties:
251 class: true
252 minimum-alignment: true
253 members: true
254 additionalProperties: false
255 ft:
256 allOf:
257 - $ref: '#/definitions/ft-base'
258 - properties:
259 # This is used to make sure that the field type's class name
260 # is valid as any of the conditionals below can fail.
261 #
262 # Although we could use `oneOf` instead of this enumeration
263 # here and refer to each of the `*-ft-class-prop` definitions,
264 # it would be hard for the validator to show something useful
265 # for the user as all cases would fail.
266 #
267 # Using `enum` below makes the validator show a very clear
268 # validation failure message.
269 class:
270 enum:
271 - uint
272 - unsigned-int
273 - unsigned-integer
274 - sint
275 - signed-int
276 - signed-integer
277 - uenum
278 - unsigned-enum
279 - unsigned-enumeration
280 - senum
281 - signed-enum
282 - signed-enumeration
283 - real
284 - str
285 - string
286 - static-array
287 - struct
288 - structure
289 - if:
290 properties:
291 class:
292 $ref: '#/definitions/uint-ft-class-prop'
293 then:
294 $ref: '#/definitions/uint-ft'
295 - if:
296 properties:
297 class:
298 $ref: '#/definitions/sint-ft-class-prop'
299 then:
300 $ref: '#/definitions/sint-ft'
301 - if:
302 properties:
303 class:
304 $ref: '#/definitions/uenum-ft-class-prop'
305 then:
306 $ref: '#/definitions/uenum-ft'
307 - if:
308 properties:
309 class:
310 $ref: '#/definitions/senum-ft-class-prop'
311 then:
312 $ref: '#/definitions/senum-ft'
313 - if:
314 properties:
315 class:
316 $ref: '#/definitions/real-ft-class-prop'
317 then:
318 $ref: '#/definitions/real-ft'
319 - if:
320 properties:
321 class:
322 $ref: '#/definitions/string-ft-class-prop'
323 then:
324 $ref: '#/definitions/string-ft'
325 - if:
326 properties:
327 class:
328 $ref: '#/definitions/static-array-ft-class-prop'
329 then:
330 $ref: '#/definitions/static-array-ft'
331 - if:
332 properties:
333 class:
334 $ref: '#/definitions/struct-ft-class-prop'
335 then:
336 $ref: '#/definitions/struct-ft'
337 required:
338 - class
339 $ref: '#/definitions/ft'
This page took 0.034739 seconds and 3 git commands to generate.