<i>Tcl_ParseArgv as a useful non-Tk version of Tk_ParseArgv</i> status still Open with 4 other changes
by
.
D 2006-06-18T03:03:41
J icomment Logged\sIn:\sYES\s\nuser_id=87254\n\nHi\sSam.\s\sI\swrote\sthe\sanonymous\scomment\s(sure\sI\swas\slogged\sin\n--\ssilly\ssource\sforge)\sand\stclobjv.c\sin\snaviserver.\n\nYes,\stclobjv.c\sparses\sboth\soptions\sand\sarguments,\shandling\ntype\sconversion\sand\sdefaults\sfor\sboth,\sand\san\soptional\n'args'\sto\sgather\sremaining\sarguments\sin.\sIt\sdoes\sthis\swith\nthe\sNs_ObjvArgs\scallback.\s\sThere's\slots\sof\sexamples\sof\sit\nbeing\sused\shere:\n\nhttp://naviserver.cvs.sourceforge.net/naviserver/naviserver/nsd/tclsched.c?revision=1.5&view=markup\n\nYou\scan\sparse\sthe\sremaining\sarguments\showever\syou\slike.\n\n\n>\s(i)\sDoes\sthe\sorder\sof\soptions\smatter?\n\nNo,\swhich\sis\sthe\sexpected\sbehaviour,\sI\sthink.\n\n\n>\s(ii)\sCan\soptions\sbe\sinterspersed\swith\sarguments?\n\nNo.\sAll\soptions\smust\scome\sbefore\sarguments,\swhich\sagain\sI\nthink\sis\sthe\sexpected\sbehaviour.\n\n\n>\s(iii)\sWhat\shappens\sin\sthe\scase\sof\sunknown\sarguments?\n\nNot\ssure\swhat\syou\smean\shere.\s\sIf\sthe\sargs\ssupplied\sdon't\nmatch\sthe\ssignature,\san\serror\smessage\sis\sgenerated.\sIf\syou\nexpect\san\sargument\sof\san\sunusual\stype,\syou\scan\suse\nNs_ObjvObj\sand\sthe\sTcl\sobject\swill\sbe\sreturned,\swhich\syou\ncan\sinterpret\showever\syou\slike.\n\n\n>\s(iv)\sIs\sthere\san\sautomatically\sgenerated\shelp?\n\nError\smessages\sare\sautomatically\sgenerated\swhich\sdescibe\sthe\ncommand's\ssignature.\sPerhaps\sthe\ssignature\sshould\sbe\smade\navailable,\sso\sthat\scommands\scould\simplement\sa\s-help\sswitch\n(although\sthis\sfeels\swrong\sto\sme\sfor\scommands,\sfine\sfor\ncommand\slines).\n\n\n>\s(v)\sDo\sall\sarguments\shave\sto\sbe\sknown\sin\sadvance?\n\nThe\snumber\sof\sremaining,\sunparsed\sarguments\scan\sbe\scaptured\nand\sdealt\swith\showever\syou\slike\s(see\sabove).\n\n\n\ntclobjv.c\sis\sthe\sfastest\simplementation\sI\scould\scome\sup\swith\n(standalone,\snot\sincluding\sthe\sTcl\sbyte\scode\scompiler),\nwhich\sis\simportant\sfor\sTcl\scommands,\sthough\sprobably\snot\sfor\napplication\scommand\slines.\n\nSome\sthings\swhich\stclobjv.c\sdoes\sto\smake\sthings\sfast\sare:\sno\nmemory\sis\sallocated\sfor\sparsing;\suses\sGetIndexFromObj\sto\nshimmer\sswitches\sto\sspeed\sparsing\sin\sthe\sfuture;\ssplits\noption\sand\sarg\sparsing\sinto\stwo\sphases\sso\sthat\sun-passed\noptions\scan\sbe\sskipped\sefficiently;\sdirect\sjump\sto\stype\nconversion\scallbacks\srather\sthan\sgiant\sswitch\sstatement.\s\nThe\slast\sis\sobviously\smore\sfelxible,\stoo.\n\nThe\score\sNs_ParseObjv()\sis\sonly\s~45\slines.\sThe\stype\nconversion\scallbacks\sare\soften\strivial\swrappers.\n\n\nThere's\salso\sa\scomplete\sset\sof\stests\savailable:\n\nhttp://naviserver.cvs.sourceforge.net/naviserver/naviserver/tests/ns_parseargs.test?revision=1.3&view=markup\n\n\n\n
J login sdeasey
J mimetype text/plain
J username sdeasey
K 1446696fffffffffffffffffffffffffffffffff
U sdeasey
Z bab43723daa5fab0cc2a157492348412