Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

References for existing structures #207

Closed
wants to merge 3 commits into from

Conversation

tomaskender
Copy link
Contributor

This new feature allows users to define attributes that reference an existing structure.

Use case:

Person - name <string>
       - partner <Person>
       - children <Person[]>
 
 person.parents[0].parents[0].name

Changes had to be made to _addStruct and other parts of modules.cpp. The most serious one was the predeclaration of a struct symbol in it's parent object. It's assigned as an attribute of it's parent before attributes of the struct itself are loaded.

Sample declaration of references in modules:

module: my_module
{
   "kind": "array",
  "name": "people",
  "structure":
  {
    "kind": "struct",
    "name": "people",
    "attributes": [
      {
        "kind": "value",
        "name": "name",
        "type": "s"
      },
      {
        "kind": "reference",
        "name": "partner",
        "type": "my_module.people",
      },
      {
        "kind": "array",
        "name": "children",
        "structure":
        {
          "kind": "reference",
          "name": "children",
          "type": "my_module.people"
        }
      }
    ]
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant