Comparing version 1.12.0 to 1.12.1
# History | ||
## 1.12.1 | ||
* update to protodef 1.0.0 | ||
## 1.12.0 | ||
@@ -4,0 +8,0 @@ |
{ | ||
"name": "protodef", | ||
"version": "1.12.0", | ||
"version": "1.12.1", | ||
"description": "A simple yet powerful way to define binary protocols", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,292 +0,20 @@ | ||
# Datatypes | ||
Protodef has a number of useful default datatypes. | ||
## Conditional | ||
### switch | ||
switch make it possible to choose a datatype depending on the value of an other field. | ||
It is similar to the switch/case syntax. | ||
It takes 3 arguments: | ||
* compareTo : the value is the other field | ||
* compareToValue : an optional property (it's either compareTo or compareToValue) that allows the comparison to be made with a value instead of an other field | ||
* fields : an object mapping the values to the types | ||
* default : an optional property saying the type taken if the value doesn't fit into the cases | ||
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 | ||
[ | ||
"switch", | ||
{ | ||
"compareTo": "someField", | ||
"fields": { | ||
"0": "i8", | ||
"1": "varint", | ||
"2": "f32", | ||
"3": "string" | ||
}, | ||
"default": "void" | ||
} | ||
] | ||
``` | ||
Example of value: `4.5` | ||
### option | ||
option 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. | ||
It takes only one argument : the type of the value. | ||
Example: | ||
An option of value string | ||
```json | ||
[ | ||
"option", | ||
"cstring" | ||
] | ||
``` | ||
Example of value: `"my string"` | ||
## Numeric | ||
These datatypes don't take any arguments. They represent numbers. | ||
| Name | Size in bytes | Example of value | Also called | | ||
| --- | --- | --- | --- | | ||
| i8 | 1 | -125 | byte | | ||
| u8 | 1 | 255 | unsigned byte | | ||
| i16 | 2 | -32000 | short | | ||
| u16 | 2 | 60000 | unsigned short | | ||
| i32 | 4 | -2000000000 | int | | ||
| u32 | 4 | 3000000000 | unsigned int | | ||
| f32 | 4 | 4.5 | float | | ||
| f64 | 8 | 4.5 | double | | ||
| i64 | 8 | 1 | long | | ||
| u64 | 8 | 1 | unsigned long | | ||
| li8 | 1 | -125 | little endian byte | | ||
| lu8 | 1 | 255 | little endian unsigned byte | | ||
| li16 | 2 | -32000 | little endian short | | ||
| lu16 | 2 | 60000 | little endian unsigned short | | ||
| li32 | 4 | -2000000000 | little endian int | | ||
| lu32 | 4 | 3000000000 | little endian unsigned int | | ||
| lf32 | 4 | 4.5 | little endian float | | ||
| lf64 | 8 | 4.5 | little endian double | | ||
| li64 | 8 | 1 | little endian long | | ||
| lu64 | 8 | 1 | little endian unsigned long | | ||
## Structures | ||
### array | ||
array represents a list of values. | ||
It takes for arguments: | ||
* type : the type of the element | ||
* 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) | ||
See [Counting](#counting) | ||
Example: | ||
An array of int prefixed by a short length. | ||
```json | ||
[ | ||
"array", | ||
{ | ||
"countType": "i16", | ||
"type": "i32" | ||
} | ||
] | ||
``` | ||
Example of value: `[1,2,3,4]` | ||
### count | ||
It represents a count field for an array or a buffer. | ||
Example: | ||
A count for a field name records, of type short. | ||
```json | ||
[ | ||
"count", | ||
{ | ||
"type": "i16", | ||
"countFor": "records" | ||
} | ||
] | ||
``` | ||
Example of value: `5` | ||
### container | ||
It represents a list of named values. It takes for argument these values with their types and names. | ||
Example: | ||
A container with fields of type int, int, ushort and ushort. | ||
```json | ||
[ | ||
"container", | ||
[ | ||
{ | ||
"name": "x", | ||
"type": "i32" | ||
}, | ||
{ | ||
"name": "z", | ||
"type": "i32" | ||
}, | ||
{ | ||
"name": "bitMap", | ||
"type": "u16" | ||
}, | ||
{ | ||
"name": "addBitMap", | ||
"type": "u16" | ||
} | ||
] | ||
] | ||
``` | ||
Example of value: `{"x":10,"z":10,"bitMap":10,"addBitMap":10}` | ||
## Utils | ||
### varint | ||
A variable-length number representation. | ||
Size: between 1 and 5 | ||
Example of value : `5` | ||
### bool | ||
A boolean, encoded in one byte. | ||
Example of value : `true` | ||
### pstring | ||
A length prefixed string. It takes one argument : the type of the length prefix. | ||
It is usually used to define a "string" type that can be used without argument. | ||
The count can also be defined in different ways, see [Counting](#counting). | ||
Example: | ||
A string length prefixed by a varint. | ||
```json | ||
[ | ||
"pstring",{ | ||
"countType":"varint" | ||
} | ||
] | ||
``` | ||
Example of value: `"my string"` | ||
### buffer | ||
buffer represents a Buffer | ||
It takes for 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) | ||
See [Counting](#counting) | ||
Example: | ||
An buffer prefixed by a varint length. | ||
```json | ||
[ | ||
"buffer", | ||
{ | ||
"countType": "varint" | ||
} | ||
] | ||
``` | ||
Example of value: `new Buffer([0x01,0x02,0x03])` | ||
### void | ||
void represents an empty value. It has a size of 0. | ||
Example of value: `undefined` | ||
### bitfield | ||
bitfield represents a list of value with sizes that are not a multiple of 8bits. | ||
It takes for argument a list of values with: | ||
* a size | ||
* a name | ||
* signed | ||
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 | ||
["bitfield", [ | ||
{ "name": "x", "size": 26, "signed": true }, | ||
{ "name": "y", "size": 12, "signed": true }, | ||
{ "name": "z", "size": 26, "signed": true } | ||
]] | ||
``` | ||
Example of value: `{"x":10,"y":10,"z":10}` | ||
### cstring | ||
cstring represents a null terminated string. Similar to strings in C. | ||
Example of value: "my string" | ||
### mapper | ||
mappers maps values. It takes as argument the type of the input, and a mappings object with the values to map. | ||
Example: | ||
Maps a byte to a string, 1 to "byte", 2 to "short", 3 to "int", 4 to "long". | ||
```json | ||
[ | ||
"mapper", | ||
{ | ||
"type": "i8", | ||
"mappings": { | ||
"1": "byte", | ||
"2": "short", | ||
"3": "int", | ||
"4": "long" | ||
} | ||
} | ||
] | ||
``` | ||
Example of value: `3` | ||
# Common datatypes arguments | ||
## Counting | ||
* 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) | ||
# Datatypes reference | ||
* [Conditional](./datatypes/conditional.md) | ||
* * [switch](./datatypes/conditional.md#) | ||
* * [option](./datatypes/conditional.md#) | ||
* [Numeric](./datatypes/numeric.md) | ||
* * [i8 / u8 / i16 / u16 / i32 / u32 / i64 / u64 / f32 / f64](./datatypes/numeric.md) | ||
* * [varint](./datatypes/numeric.md) | ||
* [Structures](./datatypes/structures.md) | ||
* * [array](./datatypes/structures.md) | ||
* * [container](./datatypes/structures.md) | ||
* * [count](./datatypes/structures.md) | ||
* [Primitives](./datatypes/primitives.md) | ||
* * [bool](./datatypes/primitives.md) | ||
* * [cstring](./datatypes/primitives.md) | ||
* * [void](./datatypes/primitives.md) | ||
* [Utils](./datatypes/utils.md) | ||
* * [buffer](./datatypes/utils.md) | ||
* * [bitfield](./datatypes/utils.md) | ||
* * [mapper](./datatypes/utils.md) | ||
* * [pstring](./datatypes/utils.md) |
@@ -5,7 +5,38 @@ # Protocol | ||
The protocol object is an object with keys `types` and namespace keys. | ||
Example: | ||
```json | ||
{ | ||
"types": { | ||
"pstring": "native", | ||
"varint": "native" | ||
}, | ||
"namespace1": { | ||
"types": { | ||
"mytype": [ | ||
"pstring", | ||
"varint" | ||
] | ||
}, | ||
"namespace2": { | ||
"packet": "mytype" | ||
} | ||
} | ||
} | ||
``` | ||
* The value of the `types` key is an object of type name to type definition. | ||
* The value of the namespace key is a protocol object. | ||
> Don't define types with same name (or override types in child namespaces) because this will lead to implementation-defined behavior. | ||
> Same with override of built-in types such as `u8`. | ||
See [protocol_schema.json](../schemas/protocol_schema.json) for a json schema definition of this format. | ||
## **types** : { [String]: Type | "native", ... } | ||
Arguments: | ||
* [object] : a type definition | ||
* * [key] : the name | ||
* * [value] : the type (or `"native"` if implemented) | ||
* * * 0 : name of used type | ||
* * * 1 : options of used type | ||
## **[String]** : { [namespace], ... } | ||
Arguments: | ||
* [object] : A namespace object | ||
* * [key] : type name | ||
* * [value] : namespace or type (see above) definition |
@@ -9,4 +9,8 @@ # ProtoDef | ||
| --- | --- | --- | | ||
| [node-protodef](https://github.com/ProtoDef-io/node-protodef) | Node.js | interpretation | | ||
| [node-protodef](https://github.com/ProtoDef-io/node-protodef) | Node.js | interpretation and compilation | | ||
| [elixir-protodef](https://github.com/ProtoDef-io/elixir-protodef) | Elixir | compilation | | ||
| [protodefc](https://github.com/ProtoDef-io/protodefc) | Rust | compilation | | ||
| [node-protodef-neo](https://github.com/Saiv46/node-protodef-neo) | Node.js | mixed | | ||
| [mcd2c](https://github.com/SpockBotMC/mcd2c) | C | compilation | | ||
| [mcd2cpp](https://github.com/SpockBotMC/RikerBot/blob/master/mcd2cpp/__init__.py#L495) | C++ | compilation | | ||
@@ -22,3 +26,3 @@ ## Documentation | ||
* [minecraft-protocol](https://github.com/PrismarineJS/node-minecraft-protocol) defines a protocol.json by minecraft version and use ProtoDef to serialize and parse packets | ||
* the protocol.json files are stored in [minecraft-data](https://github.com/PrismarineJS/minecraft-data/blob/master/data/1.8/protocol.json) | ||
* the protocol.json files are stored in [minecraft-data](https://github.com/PrismarineJS/minecraft-data/blob/master/data/pc/1.8/protocol.json) | ||
* and they can be visualized automatically in this [doc](http://prismarinejs.github.io/minecraft-data/?d=protocol) | ||
@@ -31,1 +35,3 @@ * [prismarine-nbt](https://github.com/PrismarineJS/prismarine-nbt) defined a nbt.json to parse and serialize the NBT format | ||
* [pocket-minecraft-protocol](https://github.com/mhsjlw/pocket-minecraft-protocol) defines the minecraft pocket edition protocol | ||
* [diablo2-protocol](https://github.com/MephisTools/diablo2-protocol) Diablo 2 network protocol | ||
* [dofus-protocol](https://github.com/AstrubTools/dofus-protocol) Network protocol for dofus : create client and servers for dofus 1.30 |
{ | ||
"switch":{ | ||
"switch": { | ||
"title": "switch", | ||
"type": "array", | ||
"items":[ | ||
{"enum":["switch"]}, | ||
"items": [ | ||
{ | ||
"type":"object", | ||
"enum": ["switch"] | ||
}, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"compareTo":{"$ref": "definitions#/definitions/contextualizedFieldName"}, | ||
"compareToValue":{"type":"string"}, | ||
"fields":{ | ||
"type":"object", | ||
"patternProperties" : { | ||
"^[-a-zA-Z0-9 _:]+$":{"$ref": "dataType"} | ||
"compareTo": { | ||
"$ref": "definitions#/definitions/contextualizedFieldName" | ||
}, | ||
"compareToValue": { | ||
"type": "string" | ||
}, | ||
"fields": { | ||
"type": "object", | ||
"patternProperties": { | ||
"^[-a-zA-Z0-9 _:]+$": { | ||
"$ref": "dataType" | ||
} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
"default":{"$ref": "dataType"} | ||
"default": { | ||
"$ref": "dataType" | ||
} | ||
}, | ||
"oneOf":[ | ||
"oneOf": [ | ||
{ | ||
"required":["compareTo","fields"] | ||
"required": ["compareTo", "fields"] | ||
}, | ||
{ | ||
"required":["compareToValue","fields"] | ||
"required": ["compareToValue", "fields"] | ||
} | ||
@@ -34,11 +44,15 @@ ], | ||
}, | ||
"option":{ | ||
"option": { | ||
"title": "option", | ||
"type": "array", | ||
"items":[ | ||
{"enum":["option"]}, | ||
{"$ref": "dataType"} | ||
"items": [ | ||
{ | ||
"enum": ["option"] | ||
}, | ||
{ | ||
"$ref": "dataType" | ||
} | ||
], | ||
"additionalItems": false | ||
} | ||
} | ||
} |
{ | ||
"title": "datatype", | ||
"description":"default dataTypes", | ||
"oneOf":[ | ||
{"$ref": "switch"}, | ||
{"$ref": "option"}, | ||
"description": "default dataTypes", | ||
"oneOf": [ | ||
{ "$ref": "switch" }, | ||
{ "$ref": "option" }, | ||
{"$ref": "i8"}, | ||
{"$ref": "u8"}, | ||
{"$ref": "i16"}, | ||
{"$ref": "u16"}, | ||
{"$ref": "i32"}, | ||
{"$ref": "u32"}, | ||
{"$ref": "f32"}, | ||
{"$ref": "f64"}, | ||
{"$ref": "li8"}, | ||
{"$ref": "lu8"}, | ||
{"$ref": "li16"}, | ||
{"$ref": "lu16"}, | ||
{"$ref": "li32"}, | ||
{"$ref": "lu32"}, | ||
{"$ref": "lf32"}, | ||
{"$ref": "lf64"}, | ||
{"$ref": "i64"}, | ||
{"$ref": "li64"}, | ||
{"$ref": "u64"}, | ||
{"$ref": "lu64"}, | ||
{ "$ref": "i8" }, | ||
{ "$ref": "u8" }, | ||
{ "$ref": "i16" }, | ||
{ "$ref": "u16" }, | ||
{ "$ref": "i32" }, | ||
{ "$ref": "u32" }, | ||
{ "$ref": "f32" }, | ||
{ "$ref": "f64" }, | ||
{ "$ref": "li8" }, | ||
{ "$ref": "lu8" }, | ||
{ "$ref": "li16" }, | ||
{ "$ref": "lu16" }, | ||
{ "$ref": "li32" }, | ||
{ "$ref": "lu32" }, | ||
{ "$ref": "lf32" }, | ||
{ "$ref": "lf64" }, | ||
{ "$ref": "i64" }, | ||
{ "$ref": "li64" }, | ||
{ "$ref": "u64" }, | ||
{ "$ref": "lu64" }, | ||
{ "$ref": "int" }, | ||
{ "$ref": "varint" }, | ||
{ "$ref": "lint" }, | ||
{"$ref": "array"}, | ||
{"$ref": "count"}, | ||
{"$ref": "container"}, | ||
{ "$ref": "array" }, | ||
{ "$ref": "container" }, | ||
{ "$ref": "count" }, | ||
{"$ref": "varint"}, | ||
{"$ref": "bool"}, | ||
{"$ref": "pstring"}, | ||
{"$ref": "buffer"}, | ||
{"$ref": "void"}, | ||
{"$ref": "bitfield"}, | ||
{"$ref": "cstring"}, | ||
{"$ref": "mapper"} | ||
{ "$ref": "bool" }, | ||
{ "$ref": "cstring" }, | ||
{ "$ref": "void" }, | ||
{ "$ref": "pstring" }, | ||
{ "$ref": "buffer" }, | ||
{ "$ref": "bitfield" }, | ||
{ "$ref": "mapper" } | ||
] | ||
} | ||
} |
@@ -23,3 +23,3 @@ { | ||
}, | ||
"type":"object" | ||
} | ||
"type": "object" | ||
} |
{ | ||
"i8":{"enum":["i8"]}, | ||
"u8":{"enum":["u8"]}, | ||
"i16":{"enum":["i16"]}, | ||
"u16":{"enum":["u16"]}, | ||
"i32":{"enum":["i32"]}, | ||
"u32":{"enum":["u32"]}, | ||
"f32":{"enum":["f32"]}, | ||
"f64":{"enum":["f64"]}, | ||
"li8":{"enum":["li8"]}, | ||
"lu8":{"enum":["lu8"]}, | ||
"li16":{"enum":["li16"]}, | ||
"lu16":{"enum":["lu16"]}, | ||
"li32":{"enum":["li32"]}, | ||
"lu32":{"enum":["lu32"]}, | ||
"lf32":{"enum":["lf32"]}, | ||
"lf64":{"enum":["lf64"]}, | ||
"i64":{"enum":["i64"]}, | ||
"li64":{"enum":["li64"]}, | ||
"u64":{"enum":["u64"]}, | ||
"lu64":{"enum":["lu64"]} | ||
} | ||
"i8": { | ||
"enum": ["i8"] | ||
}, | ||
"u8": { | ||
"enum": ["u8"] | ||
}, | ||
"i16": { | ||
"enum": ["i16"] | ||
}, | ||
"u16": { | ||
"enum": ["u16"] | ||
}, | ||
"i32": { | ||
"enum": ["i32"] | ||
}, | ||
"u32": { | ||
"enum": ["u32"] | ||
}, | ||
"f32": { | ||
"enum": ["f32"] | ||
}, | ||
"f64": { | ||
"enum": ["f64"] | ||
}, | ||
"li8": { | ||
"enum": ["li8"] | ||
}, | ||
"lu8": { | ||
"enum": ["lu8"] | ||
}, | ||
"li16": { | ||
"enum": ["li16"] | ||
}, | ||
"lu16": { | ||
"enum": ["lu16"] | ||
}, | ||
"li32": { | ||
"enum": ["li32"] | ||
}, | ||
"lu32": { | ||
"enum": ["lu32"] | ||
}, | ||
"lf32": { | ||
"enum": ["lf32"] | ||
}, | ||
"lf64": { | ||
"enum": ["lf64"] | ||
}, | ||
"i64": { | ||
"enum": ["i64"] | ||
}, | ||
"li64": { | ||
"enum": ["li64"] | ||
}, | ||
"u64": { | ||
"enum": ["u64"] | ||
}, | ||
"lu64": { | ||
"enum": ["lu64"] | ||
}, | ||
"varint": { | ||
"enum": ["varint"] | ||
}, | ||
"int": { | ||
"title": "int", | ||
"type": "array", | ||
"items": [ | ||
{ | ||
"enum": ["int"] | ||
}, | ||
{ | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"size": { | ||
"type": "number" | ||
} | ||
}, | ||
"required": ["size"], | ||
"additionalProperties": false | ||
}, | ||
"additionalItems": false | ||
} | ||
], | ||
"additionalItems": false | ||
}, | ||
"lint": { | ||
"title": "lint", | ||
"type": "array", | ||
"items": [ | ||
{ | ||
"enum": ["lint"] | ||
}, | ||
{ | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"size": { | ||
"type": "number" | ||
} | ||
}, | ||
"required": ["size"], | ||
"additionalProperties": false | ||
}, | ||
"additionalItems": false | ||
} | ||
], | ||
"additionalItems": false | ||
} | ||
} |
{ | ||
"title": "protocol", | ||
"type": "object", | ||
"properties":{ | ||
"types":{ | ||
"properties": { | ||
"types": { | ||
"type": "object", | ||
"patternProperties": { | ||
"^[0-9a-zA-Z_]+$": { | ||
"oneOf":[ | ||
{"type":"string"}, | ||
"oneOf": [ | ||
{ | ||
"type": "string" | ||
}, | ||
{ | ||
"type": "array", | ||
"items": [ | ||
{"type":"string"}, | ||
{"oneOf":[{"type": "object"},{"type": "array"}]} | ||
{ | ||
"type": "string" | ||
}, | ||
{ | ||
"oneOf": [ | ||
{ | ||
"type": "object" | ||
}, | ||
{ | ||
"type": "array" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
]} | ||
] | ||
} | ||
}, | ||
@@ -24,5 +38,7 @@ "additionalProperties": false | ||
"patternProperties": { | ||
"^(?!types)[a-zA-Z_]+$": {"$ref": "#"} | ||
"^(?!types)[a-zA-Z_]+$": { | ||
"$ref": "#" | ||
} | ||
}, | ||
"additionalProperties": false | ||
} |
{ | ||
"array":{ | ||
"array": { | ||
"title": "array", | ||
"type":"array", | ||
"items":[ | ||
{"enum":["array"]}, | ||
"type": "array", | ||
"items": [ | ||
{ | ||
"oneOf":[ | ||
"enum": ["array"] | ||
}, | ||
{ | ||
"oneOf": [ | ||
{ | ||
"type":"object", | ||
"properties":{ | ||
"type": {"$ref": "dataType"}, | ||
"countType": {"$ref": "dataType"} | ||
"type": "object", | ||
"properties": { | ||
"type": { | ||
"$ref": "dataType" | ||
}, | ||
"countType": { | ||
"$ref": "dataType" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"required":["type","countType"] | ||
"required": ["type", "countType"] | ||
}, | ||
{ | ||
"type":"object", | ||
"properties":{ | ||
"type": {"$ref": "dataType"}, | ||
"count": {"$ref": "definitions#/definitions/dataTypeArgsCount"} | ||
"type": "object", | ||
"properties": { | ||
"type": { | ||
"$ref": "dataType" | ||
}, | ||
"count": { | ||
"$ref": "definitions#/definitions/dataTypeArgsCount" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"required":["type","count"] | ||
"required": ["type", "count"] | ||
} | ||
@@ -32,12 +42,18 @@ ] | ||
}, | ||
"count":{ | ||
"count": { | ||
"title": "count", | ||
"type": "array", | ||
"items":[ | ||
{"enum":["count"]}, | ||
"items": [ | ||
{ | ||
"enum": ["count"] | ||
}, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"countFor": {"$ref":"definitions#/definitions/contextualizedFieldName"}, | ||
"type": {"$ref": "dataType"} | ||
"countFor": { | ||
"$ref": "definitions#/definitions/contextualizedFieldName" | ||
}, | ||
"type": { | ||
"$ref": "dataType" | ||
} | ||
}, | ||
@@ -50,3 +66,3 @@ "required": ["countFor", "type"], | ||
}, | ||
"container":{ | ||
"container": { | ||
"title": "container", | ||
@@ -56,5 +72,3 @@ "type": "array", | ||
{ | ||
"enum": [ | ||
"container" | ||
] | ||
"enum": ["container"] | ||
}, | ||
@@ -78,15 +92,9 @@ { | ||
{ | ||
"required": [ | ||
"anon" | ||
] | ||
"required": ["anon"] | ||
}, | ||
{ | ||
"required": [ | ||
"name" | ||
] | ||
"required": ["name"] | ||
} | ||
], | ||
"required": [ | ||
"type" | ||
], | ||
"required": ["type"], | ||
"additionalProperties": false | ||
@@ -99,2 +107,2 @@ }, | ||
} | ||
} | ||
} |
{ | ||
"varint":{"enum":["varint"]}, | ||
"bool":{"enum":["bool"]}, | ||
"pstring":{ | ||
"pstring": { | ||
"title": "pstring", | ||
"type": "array", | ||
"items":[ | ||
{"enum":["pstring"]}, | ||
"items": [ | ||
{ | ||
"oneOf":[ | ||
"enum": ["pstring"] | ||
}, | ||
{ | ||
"oneOf": [ | ||
{ | ||
"type":"object", | ||
"properties":{ | ||
"countType": {"$ref": "dataType"} | ||
"type": "object", | ||
"properties": { | ||
"countType": { | ||
"$ref": "dataType" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"required":["countType"] | ||
"required": ["countType"] | ||
}, | ||
{ | ||
"type":"object", | ||
"properties":{ | ||
"count": {"$ref": "definitions#/definitions/dataTypeArgsCount"} | ||
"type": "object", | ||
"properties": { | ||
"count": { | ||
"$ref": "definitions#/definitions/dataTypeArgsCount" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"required":["count"] | ||
"required": ["count"] | ||
} | ||
@@ -32,18 +36,20 @@ ] | ||
}, | ||
"buffer":{ | ||
"buffer": { | ||
"title": "buffer", | ||
"type":"array", | ||
"items":[ | ||
{"enum":["buffer"]}, | ||
"type": "array", | ||
"items": [ | ||
{ | ||
"oneOf":[ | ||
"enum": ["buffer"] | ||
}, | ||
{ | ||
"oneOf": [ | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"countType": {"$ref": "dataType"} | ||
"countType": { | ||
"$ref": "dataType" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"required": [ | ||
"countType" | ||
] | ||
"required": ["countType"] | ||
}, | ||
@@ -53,8 +59,8 @@ { | ||
"properties": { | ||
"count": {"$ref": "definitions#/definitions/dataTypeArgsCount"} | ||
"count": { | ||
"$ref": "definitions#/definitions/dataTypeArgsCount" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"required": [ | ||
"count" | ||
] | ||
"required": ["count"] | ||
} | ||
@@ -65,9 +71,10 @@ ] | ||
}, | ||
"void":{"enum":["void"]}, | ||
"bitfield":{ | ||
"bitfield": { | ||
"title": "bitfield", | ||
"type": "array", | ||
"items": [ | ||
{ "enum": ["bitfield"] }, | ||
{ | ||
"enum": ["bitfield"] | ||
}, | ||
{ | ||
"type": "array", | ||
@@ -77,11 +84,13 @@ "items": { | ||
"properties": { | ||
"name": {"$ref": "definitions#/definitions/fieldName"}, | ||
"size": {"type": "number"}, | ||
"signed": {"type": "boolean"} | ||
"name": { | ||
"$ref": "definitions#/definitions/fieldName" | ||
}, | ||
"size": { | ||
"type": "number" | ||
}, | ||
"signed": { | ||
"type": "boolean" | ||
} | ||
}, | ||
"required": [ | ||
"name", | ||
"size", | ||
"signed" | ||
], | ||
"required": ["name", "size", "signed"], | ||
"additionalProperties": false | ||
@@ -94,16 +103,21 @@ }, | ||
}, | ||
"cstring":{"enum":["cstring"]}, | ||
"mapper":{ | ||
"mapper": { | ||
"title": "mapper", | ||
"type": "array", | ||
"items":[ | ||
{"enum":["mapper"]}, | ||
"items": [ | ||
{ | ||
"type":"object", | ||
"enum": ["mapper"] | ||
}, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"type":{"$ref": "dataType"}, | ||
"mappings":{ | ||
"type":"object", | ||
"patternProperties" : { | ||
"^[-a-zA-Z0-9 _]+$":{"type":"string"} | ||
"type": { | ||
"$ref": "dataType" | ||
}, | ||
"mappings": { | ||
"type": "object", | ||
"patternProperties": { | ||
"^[-a-zA-Z0-9 _]+$": { | ||
"type": "string" | ||
} | ||
}, | ||
@@ -113,3 +127,3 @@ "additionalProperties": false | ||
}, | ||
"required":["type","mappings"], | ||
"required": ["type", "mappings"], | ||
"additionalProperties": false | ||
@@ -120,2 +134,2 @@ } | ||
} | ||
} | ||
} |
@@ -71,2 +71,167 @@ [ | ||
] | ||
}, | ||
{ | ||
"description":"container with 2 bitfields", | ||
"type":[ | ||
"container", | ||
[ | ||
{ | ||
"anon": true, | ||
"type": [ | ||
"bitfield", | ||
[ | ||
{ | ||
"name": "metadata", | ||
"size": 4, | ||
"signed": false | ||
}, | ||
{ | ||
"name": "blockId", | ||
"size": 12, | ||
"signed": false | ||
} | ||
] | ||
] | ||
}, | ||
{ | ||
"name": "y", | ||
"type": "u8" | ||
}, | ||
{ | ||
"anon": true, | ||
"type": [ | ||
"bitfield", | ||
[ | ||
{ | ||
"name": "z", | ||
"size": 4, | ||
"signed": false | ||
}, | ||
{ | ||
"name": "x", | ||
"size": 4, | ||
"signed": false | ||
} | ||
] | ||
] | ||
} | ||
] | ||
], | ||
"values":[ | ||
{ | ||
"value":{ "metadata": 14, "blockId": 806, "y": 4, "z": 6, "x": 1 }, | ||
"buffer":["0xe3","0x26","0x04","0x61"] | ||
} | ||
] | ||
}, | ||
{ | ||
"description":"container with 2 bitfields in an array in a container", | ||
"type":[ | ||
"container", | ||
[ | ||
{ | ||
"name": "chunkX", | ||
"type": "i32" | ||
}, | ||
{ | ||
"name": "chunkZ", | ||
"type": "i32" | ||
}, | ||
{ | ||
"name": "recordCount", | ||
"type": [ | ||
"count", | ||
{ | ||
"type": "i16", | ||
"countFor": "records" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "dataLength", | ||
"type": "i32" | ||
}, | ||
{ | ||
"name": "records", | ||
"type": [ | ||
"array", | ||
{ | ||
"count": "recordCount", | ||
"type": [ | ||
"container", | ||
[ | ||
{ | ||
"anon": true, | ||
"type": [ | ||
"bitfield", | ||
[ | ||
{ | ||
"name": "metadata", | ||
"size": 4, | ||
"signed": false | ||
}, | ||
{ | ||
"name": "blockId", | ||
"size": 12, | ||
"signed": false | ||
} | ||
] | ||
] | ||
}, | ||
{ | ||
"name": "y", | ||
"type": "u8" | ||
}, | ||
{ | ||
"anon": true, | ||
"type": [ | ||
"bitfield", | ||
[ | ||
{ | ||
"name": "z", | ||
"size": 4, | ||
"signed": false | ||
}, | ||
{ | ||
"name": "x", | ||
"size": 4, | ||
"signed": false | ||
} | ||
] | ||
] | ||
} | ||
] | ||
] | ||
} | ||
] | ||
} | ||
] | ||
], | ||
"values":[ | ||
{ | ||
"value":{ | ||
"chunkX": 25, | ||
"chunkZ": 66, | ||
"recordCount": 2, | ||
"dataLength": 8, | ||
"records": [ | ||
{ | ||
"metadata": 14, | ||
"blockId": 806, | ||
"y": 4, | ||
"z": 6, | ||
"x": 1 | ||
}, | ||
{ | ||
"metadata": 13, | ||
"blockId": 806, | ||
"y": 4, | ||
"z": 0, | ||
"x": 6 | ||
} | ||
] | ||
}, | ||
"buffer":["0x00","0x00","0x00","0x19","0x00","0x00","0x00","0x42","0x00","0x02","0x00","0x00","0x00","0x08","0xe3","0x26","0x04","0x61","0xd3","0x26","0x04","0x06"] | ||
} | ||
] | ||
} | ||
@@ -73,0 +238,0 @@ ] |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
161645
60
4510