[][src]Module binjs_io::binjs_json

A format for generating invalid file, to test decoder implementation.

The expected usage is the following:

  1. Convert .js file to this JSON format (write module)
  2. Modify the JSON file, for instance:
    • Remove a field from an interface
    • Add a field to an interface
    • Replace a field value
  3. Convert JSON file to other BinAST format (read module)
  4. Feed the possibly-invalid BinAST to decoder

The JSON format is in the following structure:

tagged tuple

This example is not tested
{
  "@TYPE": "tagged tuple",
  "@INTERFACE": "<interface name>",
  "@FIELDS": [
    {
      "@FIELD_NAME": "<field name>"
      "@FIELD_VALUE": <field value>
    },
    ...
  ]
}

<interface name> and <field name> are the names of the interface and the field in WebIDL, and <field value> the field's value.

list

This example is not tested
{
  "@TYPE": "list",
  "@VALUE": [
    <item>,
    ...
  ]
}

<item> is the list's item.

string

This example is not tested
{
  "@TYPE": "string",
  "@VALUE": <value>
}

<value> is the value of the string. if the value is null, it's null. enum, identifier name, property key, float, unsigned long, bool also use the same format, with corresponding "@TYPE" value

Modules

read

A JSON reader with extra support for JSON->BinAST converter. The input JSON file is supposed to be the output of the JSON writer, filtered with some command to generate an invalid content. See mod.rs for the detail of the filter. Some methods implemented on Decoder are for binjs_convert_from_json command.

write

A JSON writer for BinAST file structure. The written file is supposed to be filtered with some command to generate an invalid content, and then fed to binjs_convert_from_json command to generate BinAST file with the invalid content. See mod.rs for the detail of the filter.

Structs

FormatProvider

Command-line management.