Skip to content

Commit

Permalink
Extend structure syntax to allow objects to be used as structures
Browse files Browse the repository at this point in the history
  • Loading branch information
totalspectrum committed Jul 10, 2024
1 parent b9151b0 commit 4357350
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions doc/spin.md
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,19 @@ PUB doprint22
print(@aFullDuplexSerialObj, 22)
```

### Object structures

The Spin2 syntax for declaring structures in the `CON` section is accepted
by flexspin, even for Spin1 files. For example:
```
CON sLine( long x, long y )
```
Flexspin also extends this to allow objects to be used as structures:
```
CON sLine("foo.spin2")
```
creates an abstract object named `sLine` which has the same methods and members as the object `foo.spin2`.

### PUB FILE and PRI FILE

A `pub` or `pri` function declaration may include a `file` directive which gives the file which contains the actual definition of the function. This looks like:
Expand Down
2 changes: 1 addition & 1 deletion frontends/spin/spin.y
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ conline:
SpinDeclareStruct(name, defs);
$$ = NULL;
}
| SP_IDENTIFIER ':' string optobjparams SP_EOLN
| SP_IDENTIFIER '(' string optobjparams ')' SP_EOLN
{
/* basically an inline object definition */
AST *paramlist = $4;
Expand Down

0 comments on commit 4357350

Please sign in to comment.