Skip to content

Instantly share code, notes, and snippets.

@loic-sharma
Last active February 26, 2024 17:58
Show Gist options
  • Save loic-sharma/d3d75d54e0f3973aedb5fae3c6bbbe3d to your computer and use it in GitHub Desktop.
Save loic-sharma/d3d75d54e0f3973aedb5fae3c6bbbe3d to your computer and use it in GitHub Desktop.
RFW JSON format strawman

Given the following RFW text:

import core.widgets;

widget root = Row(
  children: [
    ...for city in args.cities:
      switch args.showCities {
        true: City(),
        false: SizedBoxShrink(),
      }
  ]
);

RFW converts this to its internal model, which can be serialized to JSON:

{
  "arguments": [],
  "widgets": [
    "name": "root",
    "root": {
      "kind": "constructorCall",
      "name": "Row",
      "arguments": {
        "children": [
          {
            "kind": "loop",
            "input": {
              "kind": "argsReference",
              "parts": ["cities"]
            },
            "output": {
              "kind": "switch",
              "input": {
                "kind": "argsReference",
                "parts": ["showCities"]
              },
              "outputs": {
                "true": {
                  "kind": "constructorCall",
                  "name": "City"
                },
                "false": {
                  "kind": "constructorCall",
                  "name": "SizedBoxShrink"
                }
              }
            }
          }
        ]
      }
    }
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment