|
From: Andre R. <and...@us...> - 2004-11-04 21:13:02
|
Update of /cvsroot/frontierkernel/Frontier/Common/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11877/Common/source Modified Files: fileloop.c langlist.c oplist.c shellbuttons.c Log Message: Moved definition of tylistrecord from oplist.h to oplist.c to make it opaque to all users. Added opgetisrecord, opsetisrecord, opsetreleaseitemcallback, and oplistvisit functions. Adapted users to use new accessor functions instead of accessing a list record directly. All this is in preparation for eventually replacing the implementations of the list and record data types. (Still to be discussed.) Index: oplist.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/oplist.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** oplist.c 1 Nov 2004 11:50:16 -0000 1.4 --- oplist.c 4 Nov 2004 21:12:51 -0000 1.5 *************** *** 68,71 **** --- 68,83 ---- + typedef struct tylistrecord { + + struct tyoutlinerecord ** houtline; /*the list is stored in an outline*/ + + long ctitems; /*number of items in the list, can be gotten without traversal*/ + + boolean isrecord; /*do items have names?*/ + + oplistreleaseitemcallback releaseitemcallback; /*routine that releases one of **your** handles*/ + } tylistrecord; + + typedef struct tydisklistrecord { *************** *** 490,493 **** --- 502,539 ---- + boolean opgetisrecord (hdllistrecord hlist) { + + /* + 2004-11-04 aradke: accessor function. + */ + + return ((**hlist).isrecord); + } /*oplistisrecord*/ + + + void opsetisrecord (hdllistrecord hlist, boolean flisrecord) { + + /* + 2004-11-04 aradke: accessor function. + */ + + (**hlist).isrecord = flisrecord; + } /*oplistisrecord*/ + + + oplistreleaseitemcallback opsetreleaseitemcallback (hdllistrecord hlist, oplistreleaseitemcallback cb) { + + /* + 2004-11-04 aradke: accessor function. set the callback and return previous callback. + */ + + oplistreleaseitemcallback oldcb = (**hlist).releaseitemcallback; + + (**hlist).releaseitemcallback = cb; + + return (oldcb); + } /*opsetreleaseitemcallback*/ + + static boolean opdeletelistnode (hdloutlinerecord ho, hdlheadrecord hdelete) { *************** *** 795,797 **** --- 841,875 ---- + boolean opvisitlist (hdllistrecord hlist, opvisitlistcallback visit, ptrvoid refcon) { + + /* + 2004-11-04 aradke: Visit all items in a list without recursion. + The callback should return false to break out of the loop. + */ + + hdloutlinerecord ho; + register hdlheadrecord nomad, nextnomad; + bigstring bskey; + + ho = (hdloutlinerecord) (**hlist).houtline; + + nomad = (**ho).hsummit; + + while (true) { + + nextnomad = (**nomad).headlinkdown; + + opgetheadstring (nomad, bskey); + + if (!(*visit) ((**nomad).hrefcon, bskey, refcon)) + return (false); + + if (nextnomad == nomad) + break; + + nomad = nextnomad; + } /*while*/ + + return (true); + } /*opvisitlist*/ Index: shellbuttons.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/shellbuttons.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** shellbuttons.c 1 Nov 2004 11:50:16 -0000 1.4 --- shellbuttons.c 4 Nov 2004 21:12:51 -0000 1.5 *************** *** 89,93 **** return (0L); ! return ((**buttonlist).ctitems); } /*shellgetbuttonlistcount*/ --- 89,93 ---- return (0L); ! return (opcountlistitems (buttonlist)); } /*shellgetbuttonlistcount*/ *************** *** 513,516 **** --- 513,517 ---- Rect r; short i; + short ctbuttons; //buttonlist = (hdllistrecord) shellglobals.buttonlist; *************** *** 549,553 **** #endif ! for (i = 1; i <= (**buttonlist).ctitems; i++) shelldrawbutton (i, false); --- 550,556 ---- #endif ! ctbuttons = opcountlistitems (buttonlist); ! ! for (i = 1; i <= ctbuttons; i++) shelldrawbutton (i, false); Index: fileloop.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/fileloop.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** fileloop.c 23 Oct 2004 22:18:13 -0000 1.2 --- fileloop.c 4 Nov 2004 21:12:51 -0000 1.3 *************** *** 98,102 **** (**h).hfilelist = hlist; ! (**hlist).releaseitemcallback = &fileloopreleaseitem; ix = 1; /*start with file index 1*/ --- 98,102 ---- (**h).hfilelist = hlist; ! opsetreleaseitemcallback (hlist, &fileloopreleaseitem); ix = 1; /*start with file index 1*/ *************** *** 243,247 **** (**h).hfilelist = hlist; ! (**hlist).releaseitemcallback = &fileloopreleaseitem; ix = 1; /*start with file index 1*/ --- 243,247 ---- (**h).hfilelist = hlist; ! opsetreleaseitemcallback (hlist, &fileloopreleaseitem); ix = 1; /*start with file index 1*/ Index: langlist.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/langlist.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** langlist.c 1 Nov 2004 11:50:17 -0000 1.5 --- langlist.c 4 Nov 2004 21:12:51 -0000 1.6 *************** *** 297,300 **** --- 297,301 ---- bigstring bs; Handle hstring; + boolean flisrecord = opgetisrecord (hlist); n = opcountlistitems (hlist); *************** *** 308,312 **** goto error; ! if ((**hlist).isrecord) { langdeparsestring (key, chdoublequote); /*add needed escape sequences*/ --- 309,313 ---- goto error; ! if (flisrecord) { langdeparsestring (key, chdoublequote); /*add needed escape sequences*/ *************** *** 737,741 **** case listvaluetype: ! (**hlist).isrecord = false; return (true); --- 738,742 ---- case listvaluetype: ! opsetisrecord (hlist, false); return (true); *************** *** 907,911 **** n = opcountlistitems ((*v2).data.listvalue); ! if ( (m > n) || (**(*v2).data.listvalue).isrecord ) { /* Either the first list is longer than the second: append to the first, or we are adding records so we want to --- 908,912 ---- n = opcountlistitems ((*v2).data.listvalue); ! if ( (m > n) || opgetisrecord ((*v2).data.listvalue) ) { /* Either the first list is longer than the second: append to the first, or we are adding records so we want to *************** *** 926,930 **** return (false); ! if ((**list3).isrecord) { /* discard duplicate keys */ if (opgetlisthandle (list3, -1, key, &hignore)) --- 927,931 ---- return (false); ! if (opgetisrecord (list3)) { /* discard duplicate keys */ if (opgetlisthandle (list3, -1, key, &hignore)) *************** *** 991,995 **** n2 = opcountlistitems (list2); ! if ((**list3).isrecord) { for (ix1 = 1; ix1 <= n2; ++ix1) { /*delete values that appear in second record*/ --- 992,996 ---- n2 = opcountlistitems (list2); ! if (opgetisrecord (list3)) { for (ix1 = 1; ix1 <= n2; ++ix1) { /*delete values that appear in second record*/ *************** *** 1052,1056 **** goto exit; ! flbykey = (**list1).isrecord; switch (comparisonop) { --- 1053,1057 ---- goto exit; ! flbykey = opgetisrecord (list1); switch (comparisonop) { *************** *** 1237,1277 **** ! boolean langvisitlistvalues (tyvaluerecord *vlist, langvisitlistvaluescallback visit, ptrvoid refcon) { /* ! 2003-04-28 AR: Visit all items in a list without recursion. */ - - hdllistrecord hlist = (hdllistrecord) (*vlist).data.binaryvalue; - hdloutlinerecord ho; - register hdlheadrecord nomad, nextnomad; - tyvaluerecord v; - boolean fl; ! ho = (hdloutlinerecord) (**hlist).houtline; ! ! nomad = (**ho).hsummit; ! while (true) { ! nextnomad = (**nomad).headlinkdown; ! if (!langunpackvalue ((**nomad).hrefcon, &v)) ! return (false); ! ! fl = visit (&v, refcon); ! ! disposevaluerecord (v, true); ! ! if (!fl) ! return (false); ! ! if (nextnomad == nomad) ! break; ! ! nomad = nextnomad; ! } /*while*/ ! return (true); } /*langvisitlistvalues*/ --- 1238,1281 ---- ! typedef struct tylangvisitlistinfo { ! ptrvoid refcon; ! langvisitlistvaluescallback visit; ! } tylangvisitlistinfo; ! ! ! static boolean langvisitlistvaluesvisit (Handle hdata, ptrstring bskey, ptrvoid refcon) { /* ! 2004-11-04 aradke: helper for langvisitlistvalues, called from opvisitlist. */ ! tylangvisitlistinfo *info = (tylangvisitlistinfo *) refcon; ! tyvaluerecord val; ! boolean fl; ! if (!langunpackvalue (hdata, &val)) ! return (false); ! fl = (*info).visit (&val, (*info).refcon); ! disposevaluerecord (val, true); ! return (fl); ! } /*langvisitlistvaluesvisit*/ ! ! ! boolean langvisitlistvalues (tyvaluerecord *vlist, langvisitlistvaluescallback visit, ptrvoid refcon) { ! ! /* ! 2004-11-04 aradke: rewritten to use opvisitlist, called from langregexp.c. ! */ ! ! hdllistrecord hlist = (hdllistrecord) (*vlist).data.binaryvalue; ! tylangvisitlistinfo info; ! ! info.refcon = refcon; ! info.visit = visit; ! ! return (opvisitlist (hlist, &langvisitlistvaluesvisit, &info)); } /*langvisitlistvalues*/ |