poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: JSON Representation


From: Jose E. Marchesi
Subject: Re: JSON Representation
Date: Thu, 07 May 2020 23:11:55 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hi kostasch.

Thanks for the update.

    +  "$schema": "http://json-schema.org/draft-06/schema#";,
    +  "$id": "",
    +  "title": "Poke values",
    +  "description": "JSON Representation for Poke values",
    +  "definitions": {
    +    "UnsignedInteger": {
    +      "type": "object",
    +      "properties": {
    +        "unsignedValue": {

Why having "unsignedValue" and "signedValue" instead of just "value" in
both "UnsignedInteger" and "SignedInteger"?

    +          "type": "integer",
    +          "minimum": 0,
    +          "maximum": 18446744073709551615
             },
    +        "size": {
    +          "type": "integer",
    +          "minimum": 1,
    +          "maximum": 64
    +        }
    +      },
    +      "required": [
    +        "size",
    +        "unsignedValue"
    +      ],
    +      "title": "UnsignedInteger"
    +    },
    +    "Integer": {
    +      "type": "object",
    +      "properties": {
    +        "signedValue": {
    +          "type": "integer",
    +          "minimum": -9223372036854775808,
    +          "maximum": 9223372036854775807
             },
    +        "size": {
    +          "type": "integer",
    +          "minimum": 1,
    +          "maximum": 64
    +        }
    +      },
    +      "required": [
    +        "size",
    +        "signedValue"
    +      ],
    +      "title": "Integer"
    +    },
    +    "Null": {
    +      "type": "object",
    +      "properties": {
    +        "nullValue": {
    +          "type": "null"
    +        }

I don't think we need a nullValue property.  The "Null" object can have
either an empty "properties" (if such a thing is allowed in the JSON
thingie) or no properties at all.

    +      },
    +      "required": [
    +        "nullValue"
    +      ],
    +      "title": "Null"
    +    },
    +    "Offset": {
    +      "type": "object",
    +      "properties": {
    +        "magnitude": {
    +          "type": "object",
    +          "anyOf": [
    +            {
    +              "$ref": "#/definitions/UnsignedInteger"
                 },
    +            {
    +              "$ref": "#/definitions/Integer"
    +            }
    +          ]
             },
    +        "base": {
    +          "type": "object",
    +          "oneOf": [
    +            {
    +              "$ref": "#/definitions/UnsignedInteger"
    +            }
    +          ],
    +          "size": 64

s/"base"/"unit"/.

Do we need an "oneOf" if there is just one alternative?

Also, with this definition, is `"size": 64' really referring to the size
of the size of the $ref-erred object above?

Yeah I have no clue about JSON schemas 8-)

    +        }
    +      },
    +      "required": [
    +        "magnitude",
    +        "base"
    +      ],
    +      "title": "Offset"
    +    },
    +    "String": {
    +      "type": "object",
    +      "properties": {
    +        "stringValue": {
    +          "type": "string"
    +        }

Why not just "value"?

    +      },
    +      "required": [
    +        "stringValue"
    +      ],
    +      "title": "String"
    +    },
    +    /*(Not sure about this one)
    +     Represent poke struct as an object a number of fields plus a Mapping
    +    */
    +    "Struct": {
    +      "type":"object",
    +      "properties":{
    +        "structFields": {

Why not just "fields"?

    +          "type" : "array",
    +          "items" : {
    +            "type" : "object",
    +            "anyOf" : [
    +              {"$ref": "#/definitions/String"},
    +              {"$ref": "#/definitions/Struct"},
    +              {"$ref": "#/definitions/Array"},
    +              {"$ref": "#/definitions/UnsignedInteger"},
    +              {"$ref": "#/definitions/Integer"},
    +              {"$ref": "#/definitions/Offset"}
    +            ]

Using an array for the struct elements seems appropriate: the order
matters!

However, each struct field should be a JSON object by itself, containing
the several properties you can see in pvm_struct_field in pvm-val.h:
offset, name, value and modified.  See the comment before the definition
of the struct in order to determine what kind of values these properties
can hold (they are all pvm_vals, which should map to your JSON objects.)

Struct values also should have an array of methods.  Each method is a
closure, you can look at their properties in the pvm_cls boxed value in
pvm-val.h.

    +          },
    +          "default" : {
    +           "type" : "object",
    +            "$ref" : "#/definitions/Null"
    +          }
    +        }
    +      },
    +      /*Optionally, add a mapping after defining the struct*/
    +      "additionalProperties": {
    +            "type" : "object",
    +            "$ref" : "#/definitions/Mapping"
    +      },

Does the order in the definition of the properties matter?  I'm a bit
confused about the "after defining the struct" comment.

    +      "required": [
    +        "structFields"
    +      ],
    +      "title": "Struct"
    +    },
    +    "Mapping": {
    +      "type": "object",
    +      "properties": {
    +        "IOS": {
    +          "type": "integer"

The IOS should be a 32-bit signed integer.  Don't you need to define
minimum and maximum?

    +        },
    +        "offset": {
    +          "type": "object",
    +          "$ref": "#/definitions/Offset"
    +        }
    +      },
    +      "required": [
    +        "IOS",
    +        "offset"
    +      ],
    +      "title": "Mapping"
    +    },
    +    "Array": {
    +      "type" : "object",
    +      "properties" : {
    +           /*arrayItems is an array of all defined objects above, except
    Mapping which is added at the end*/
    +        "arrayItems" : {

Call them elements please, not items.

    +            "type": "array",
    +            "items": {
    +              "type": "object",
    +              "anyOf" : [
    +                {"$ref": "#/definitions/String"},
    +                {"$ref": "#/definitions/Struct"},
    +                {"$ref": "#/definitions/Array"},
    +                {"$ref": "#/definitions/UnsignedInteger"},
    +                {"$ref": "#/definitions/Integer"},
    +                {"$ref": "#/definitions/Offset"}
    +              ]
                 },
    +            "default" : {
    +               "type" : "object",
    +               "$ref": "#/definitions/Null"
    +            }
             }
    +      },
    +      /*Optionally, add a mapping after defining the array*/
    +      "additionalProperties": {
    +        "type": "object",
    +        "$ref": "#/definitions/Mapping"
    +      },
    +      "required" : [
    +           "arrayItems"
    +      ]
    +    }
    +  },

I got lost: what are the definitions below for? :)

    +  "type": "object",
    +  "properties": {
    +    "UnsignedInteger": {
    +      "$ref": "#/definitions/UnsignedInteger"
    +    },
    +    "Integer": {
    +      "$ref": "#/definitions/Integer"
    +    },
    +    "Offset": {
    +      "$ref": "#/definitions/Offset"
    +    },
    +    "String": {
    +      "$ref": "#/definitions/String"
    +    },
    +    "Mapping": {
    +      "$ref": "#/definitions/Mapping"
    +    },
    +    "Null": {
    +      "$ref": "#/definitions/Null"
    +    },
    +    "Struct": {
    +      "$ref": "#/definitions/Struct"
    +    },
    +    "Array": {
    +      "$ref": "#/definitions/Array"
    +    }
    +  },
    +  "additionalProperties": false

Thanks!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]