From: Jos v.d.V. <jo...@us...> - 2005-05-28 08:35:48
|
Update of /cvsroot/win32forth/win32forth/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15388/win32forth/src/lib Modified Files: ExtStruct.f STRUCT.F Log Message: Jos: Made #struct-size obsolete and minimized struct.f Index: ExtStruct.f =================================================================== RCS file: /cvsroot/win32forth/win32forth/src/lib/ExtStruct.f,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ExtStruct.f 26 May 2005 08:22:37 -0000 1.1 --- ExtStruct.f 28 May 2005 08:35:39 -0000 1.2 *************** *** 1,14 **** - \ $Id$ - \ C like structures. \ Written by Jos v.d. Ven and Dirk Busch. ! \ Based on Jos's Struct.f cr .( Loading Extended C like structures... ) - [defined] -struct.f [if] - cr .( Error: You can't use ExtStruct.f and Struct.f in one application. ) abort - [then] - anew -ExtStruct.f --- 1,8 ---- \ C like structures. \ Written by Jos v.d. Ven and Dirk Busch. ! \ Based on a previous Struct.f by Jos. cr .( Loading Extended C like structures... ) anew -ExtStruct.f *************** *** 26,29 **** --- 20,26 ---- 0 value _struct + : _add-struct ( sizeof.struct -- ) \ compile current offset and increment + _struct , +to _struct ; + : add-struct ( sizeof.struct "name" -- ) \ compiling: store current offset and increment _struct offset +to _struct ; \ run-time: ( addr -- addr+offset ) *************** *** 91,117 **** \ Close a struct definiton. - \ A #STRUCT-SIZE constant is compiled into the vocabulary of the struct. - \ This constant holds the size of the struct in bytes. - \ So don't use #STRUCT-SIZE as the name for a struct member !!! - : ;struct ( -- ) - previous - - s" #struct-size" "HEADER - DOCON COMPILE, - _struct , \ store the size of the struct previous current-voc set-current ; - \ Return the size of a struct - \ The vocabulary for the struct must be in the current search order. - - : struct-size ( -- n ) - c" #struct-size" find - if execute - else abort" struct-size error" - then ; - : struct-voc[ ( -<name-struct>- -- wid ) also structs get-current also ' execute ; --- 88,99 ---- \ Close a struct definiton. + : ;struct ( ptr-size -- ) + previous _struct swap ! \ Store the size previous current-voc set-current + -1 +to olddepth ; : struct-voc[ ( -<name-struct>- -- wid ) also structs get-current also ' execute ; *************** *** 120,134 **** previous previous set-current ; external \ return the size of <name-struct> in bytes - : sizeof ( -<name-struct>- -- size ) - struct-voc[ - struct-size swap - ]struct-voc ! state @ if postpone literal ! then ; immediate \ compiles the adress and offset as one adress inside a definition --- 102,118 ---- previous previous set-current ; + : getsize-struct ( adr-struct - n ) + 2 cells+ @ ; + external + \ return the size of <name-struct> in bytes ! : sizeof ( -<name-struct>- -- size ) ! ' getsize-struct state @ if postpone literal ! then ! ; immediate \ compiles the adress and offset as one adress inside a definition *************** *** 146,149 **** --- 130,134 ---- internal + : create-struct-voc ( addr len -- wid ) get-current >r also Structs definitions *************** *** 151,157 **** previous r> set-current ; ! : create-struct ( addr len wid -- ) -rot ( create ) "HEADER DOVAR COMPILE, , immediate ! does> @ +order state @ if interpret \ Compile the offset+ part inside a definition --- 136,142 ---- previous r> set-current ; ! : create-struct ( addr len wid -- ptr-size ) \ Map: WID size -rot ( create ) "HEADER DOVAR COMPILE, , immediate ! here .s -2 , does> @ +order state @ if interpret \ Compile the offset+ part inside a definition *************** *** 165,169 **** \ A vocabulary <name-struct> is created. \ All words for the struct members will be compiled into this vocabulary. ! : :struct ( -<name-struct>- -- ) /parse-word count ( addr len ) --- 150,154 ---- \ A vocabulary <name-struct> is created. \ All words for the struct members will be compiled into this vocabulary. ! : :struct ( -<name-struct>- -- ptr-size ) /parse-word count ( addr len ) *************** *** 180,183 **** --- 165,169 ---- 0 to _struct + 1 +to olddepth ; *************** *** 317,319 **** decimal ! |