mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-04 06:06:17 +00:00
ipc: Add a json schema for the IPC description
This commit is contained in:
parent
0980cda87a
commit
323d794df3
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"$schema": "./proto.schema.json",
|
||||
|
||||
"instance_get_shm_fd": {
|
||||
"out_fds": true
|
||||
},
|
||||
|
|
|
@ -151,7 +151,9 @@ class Proto:
|
|||
|
||||
def __init__(self, data):
|
||||
"""Construct a protocol from a dictionary of calls."""
|
||||
self.calls = [Call(name, call) for name, call in data.items()]
|
||||
self.calls = [Call(name, call) for name, call
|
||||
in data.items()
|
||||
if not name.startswith("$")]
|
||||
|
||||
|
||||
header = '''// Copyright 2020, Collabora, Ltd.
|
||||
|
|
97
src/xrt/ipc/proto.schema.json
Normal file
97
src/xrt/ipc/proto.schema.json
Normal file
|
@ -0,0 +1,97 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"$id": "http://gitlab.freedesktop.org/monado/monado/src/xrt/ipc/proto.schema.json",
|
||||
"type": "object",
|
||||
"title": "Protocol schema",
|
||||
"description": "The root schema for an entire protocol.",
|
||||
"definitions": {
|
||||
"scalar": {
|
||||
"title": "Known scalar type",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"uint32_t",
|
||||
"int64_t",
|
||||
"uint64_t"
|
||||
]
|
||||
},
|
||||
"aggregate": {
|
||||
"title": "Struct or union type",
|
||||
"type": "string",
|
||||
"pattern": "(struct|union) xrt_[a-z_]+"
|
||||
},
|
||||
"scalar_enum": {
|
||||
"title": "Custom enum (scalar)",
|
||||
"type": "string",
|
||||
"pattern": "enum xrt_[a-z_]+"
|
||||
},
|
||||
"param": {
|
||||
"type": "object",
|
||||
"title": "Parameter",
|
||||
"required": [
|
||||
"name",
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"title": "Parameter name",
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"title": "Parameter type",
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/scalar"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/aggregate"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/scalar_enum"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"param_list": {
|
||||
"title": "Parameter list",
|
||||
"type": "array",
|
||||
"additionalItems": {
|
||||
"$ref": "#/definitions/param"
|
||||
}
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"$schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": {
|
||||
"$id": "#/call",
|
||||
"type": "object",
|
||||
"title": "IPC Call",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"title": "Call ID",
|
||||
"description": "If left unspecified or empty, the ID will be constructed by prepending IPC_ to the call name in all upper-case."
|
||||
},
|
||||
"out_fds": {
|
||||
"$id": "#/call/properties/out_fds",
|
||||
"type": "boolean",
|
||||
"title": "Call returns fds?",
|
||||
"default": false,
|
||||
"examples": [
|
||||
true
|
||||
]
|
||||
},
|
||||
"in": {
|
||||
"title": "Input parameters",
|
||||
"$ref": "#/definitions/param_list"
|
||||
},
|
||||
"out": {
|
||||
"title": "Output parameters",
|
||||
"$ref": "#/definitions/param_list"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue