! dynstruct.def [103] - definitions related to DYNSTRUCTs
!------------------------------------------------------------------------
!EDIT HISTORY
! [103] 14-Sep-21 / jdm / Add types.def
! [102] 26-Sep-18 / jdm / Move T_DYN_NAME, T_DEFTYP and T_FN_NAME to types.def
! [101] 31-Aug-18 / jdm / Change ST_VARDEF to _FLDDEF, expand, revise
! [100] 28-Aug-18 / jdm / created
!------------------------------------------------------------------------
!NOTES
!   DYNSTRUCTs require compiler 874, ashell 6.5.1645.1
!------------------------------------------------------------------------

++include'once types.def

! internal variable types (NOT THE SAME AS ARGTYP_xxx which are for params only !!!)
define VARTYP_X    = 0   
define VARTYP_S    = 1   
define VARTYP_F    = 2
define VARTYP_B    = 3
define VARTYP_I    = 4
define VARTYP_MASK = &h0F   ! mask out just the basic enumerated types

! these are all options which can combine with the above and each other
define VAR_COLL    = &h0020   ! Collection (assoc. array, map, deque, etc) [600] (without VAR_DYNARY = iterator) 
define VAR_ARRAY   = &h0040	  ! Subscripted variable bit (traditional or base of ass. array) 
define VAR_BRANCH  = &h0040   ! Branch of an associative array
define VAR_DIMX    = &h0080   ! DIMX variable 
define VAR_LOCAL   = &h0100   ! local variable 
define VAR_STATIC  = &h0200   ! static variable 
define VAR_INITED  = &h0400   ! static variable already initialized 
define VAR_BYREF   = &h0800   ! var is a pointer to another var (byref) 
define VAR_DYN     = &h4000   ! var is dynamically sized [455

! MX_DYNSTRUCT opcodes
define DYNOP_DEF   = 1      ! define (compile) dynstruct in dyndef
define DYNOP_BIND  = 2      ! bind dyndef to dynstruct variable
define DYNOP_INFO  = 3      ! retrieve array of field information
define DYNOP_COPY  = 4      ! make a copy of a dynstruct

define MAX_ARY_DIMS = 4     ! max # array dimensions (note: for BASIC it's really 16, but that seems ridiculous for structures)
define MAX_DYN_NAME = 64    ! max length of a dynstruct name or a field within a dynstruct

! attributes of each field in a dynstruct 
! typically used to create a dimx array to receive field info with DYNOP_INFO
! Note: first field is actually the overall structure and its name is the defined struture name
defstruct ST_FLDDEF                 ! [101] 
    map2 name,T_DYN_NAME            ! name of struct or field
    map2 vartyp,b,2                 ! see VARTYP_xxx
    map2 varsiz,b,4                 ! size of field (or element in array)
    map2 pos,b,4                    ! [101] position in struct (offset from base of structure, base 0)
    map2 subs,b,2                   ! # subscripts(0 for scalar)
    map2 subext(MAX_ARY_DIMS),b,4   ! # of elements in up to 4 dimensions
    map2 deftyp,T_DEFTYP            ! name of deftype (if applic)
endstruct

! see dds.def for ST_DSPFLDDEFS - higher level/display oriented version of ST_FLDDEF