pfe-struct-ext
Prev? | pfe Forth Wordset List | ?Next

## Name

pfe-struct-ext ? STRUCT - simple struct implementation

## Synopsis

`STRUCT ( "name" -- here zero-offset ) ?=>? (` | `)`; | ?

`"EXTENSIONS"`;
?

`END-STRUCT ( here some-offset -- ) ?=>? (` | `)`; | ?

`"EXTENSIONS"`;
?

`SUBRECORD ( outer-offset "name" -- outer-offset here zero-offset ) ?=>? (` | `)`; | ?

`"EXTENSIONS"`;
?

`END-SUBRECORD ( outer-offset here some-offset -- outer-offset+some ) ?=>? (` | `)`; | ?

`"EXTENSIONS"`;
?

`ARRAY-OF ( some-offset n len "name" -- some-offset ) ?=>? (` | `)`; | ?

`"EXTENSIONS"`;
?

`VARIANT ( outer-offset "name" -- outer-offset here zero-offset ) ?=>? (` | `)`; | ?

`"EXTENSIONS"`;
?

`END-VARIANT ( outer-offset here some-offset -- outer-offset ) ?=>? (` | `)`; | ?

`"EXTENSIONS"`;
?

`INSTANCE ( len "name" -- ) ?=>? (` | `)`; | ?

`"EXTENSIONS"`;
?

`INSTANCE-ADDR ( len -- addr ) ?=>? (` | `)`; | ?

`"EXTENSIONS"`;
?

`ENDSTRUCTURE ( here some-offset -- ) ?=>? (` | `)`; | ?

`"EXTENSIONS"`;
?

`SIZEOF ( "name" -- size ) ?=>? (` | `)`; | ?

`"EXTENSIONS"`;
?

`CHAR% ?=>? (` | `)`; | ?

`"EXTENSIONS"`;
?

`CELL% ?=>? (` | `)`; | ?

`"EXTENSIONS"`;
?

`WCHAR% ?=>? (` | `)`; | ?

`"EXTENSIONS"`;
?

`DOUBLE% ?=>? (` | `)`; | ?

`"EXTENSIONS"`;
?

`FLOAT% ?=>? (` | `)`; | ?

`"EXTENSIONS"`;
?

`SFLOAT% ?=>? (` | `)`; | ?

`"EXTENSIONS"`;
?

`DFLOAT% ?=>? (` | `)`; | ?

`"EXTENSIONS"`;
?

## Description

STRUCT ( "name" -- here zero-offset ) => "EXTENSIONS"

begin definition of a new structure (mpe.000)

      : STRUCT CREATE  !CSP
        HERE
        0 DUP ,
      DOES&gt;
        @
      ;

END-STRUCT ( here some-offset -- ) => "EXTENSIONS"

terminate definition of a new structure (mpe.000)

      : END-STRUCT  SWAP !  ?CSP ;

SUBRECORD ( outer-offset "name" -- outer-offset here zero-offset ) => "EXTENSIONS"

begin definition of a subrecord (mpe.000)

      : STRUCT CREATE
        HERE
        0 DUP ,
      DOES&gt;
        @
      ;

END-SUBRECORD ( outer-offset here some-offset -- outer-offset+some ) => "EXTENSIONS"

end definition of a subrecord (mpe.000)

      : END-SUBRECORD  TUCK SWAP !  + ;

ARRAY-OF ( some-offset n len "name" -- some-offset ) => "EXTENSIONS"

a `FIELD`-array

      : ARRAY-OF * FIELD ;

VARIANT ( outer-offset "name" -- outer-offset here zero-offset ) => "EXTENSIONS"

Variant records describe an alternative view of the current record or subrecord from the start to the current point. The variant need not be of the same length, but the larger is taken

      : VARIANT SUBRECORD ;

END-VARIANT ( outer-offset here some-offset -- outer-offset ) => "EXTENSIONS"

terminate definition of a new variant (mpe.000)

      : END-STRUCT  TUCK SWAP !  2DUP &lt; IF NIP ELSE DROP THEN ;

INSTANCE ( len "name" -- ) => "EXTENSIONS"

Create a named instance of a named structure.

      : INSTANCE  CREATE ALLOT ;

INSTANCE-ADDR ( len -- addr ) => "EXTENSIONS"

Create nameless instance of a structure and return base address.

      : INSTANCE-ADDR  HERE SWAP ALLOT ;

ENDSTRUCTURE ( here some-offset -- ) => "EXTENSIONS"

finalize a previously started `STRUCTURE` definition

      : ENDSTRUCTURE  SWAP !  ?CSP ;

SIZEOF ( "name" -- size ) => "EXTENSIONS"

get the size-value from a previous structure definition

      : SIZEOF   ' &gt;BODY @  STATE @ IF [COMPILE] LITERAL THEN ; IMMEDIATE

CHAR% - no description, sorry

CELL% - no description, sorry

WCHAR% - no description, sorry

DOUBLE% - no description, sorry

FLOAT% - no description, sorry

SFLOAT% - no description, sorry

DFLOAT% - no description, sorry

Prev? | Up | ?Next
pfe-string-ext? | Home | ?pfe-structs-ext