Skip to content

Commit 4357350

Browse files
committed
Extend structure syntax to allow objects to be used as structures
1 parent b9151b0 commit 4357350

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

doc/spin.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,19 @@ PUB doprint22
524524
print(@aFullDuplexSerialObj, 22)
525525
```
526526
527+
### Object structures
528+
529+
The Spin2 syntax for declaring structures in the `CON` section is accepted
530+
by flexspin, even for Spin1 files. For example:
531+
```
532+
CON sLine( long x, long y )
533+
```
534+
Flexspin also extends this to allow objects to be used as structures:
535+
```
536+
CON sLine("foo.spin2")
537+
```
538+
creates an abstract object named `sLine` which has the same methods and members as the object `foo.spin2`.
539+
527540
### PUB FILE and PRI FILE
528541
529542
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:

frontends/spin/spin.y

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ conline:
10691069
SpinDeclareStruct(name, defs);
10701070
$$ = NULL;
10711071
}
1072-
| SP_IDENTIFIER ':' string optobjparams SP_EOLN
1072+
| SP_IDENTIFIER '(' string optobjparams ')' SP_EOLN
10731073
{
10741074
/* basically an inline object definition */
10751075
AST *paramlist = $4;

0 commit comments

Comments
 (0)