Skip to content
Tcl Source Code Artifact [8a81e0eba7]
Login

Artifact [8a81e0eba7]

Artifact 8a81e0eba7e9446268b9b50aff9ced0a3d831e2a:

Ticket change [8a81e0eba7] - Ticket [520304ffffffffff|520304ffff] <i>Tcl_GetIndexFromObjStruct signature</i> status still Open with 4 other changes by jenglish on 2002-02-21 03:02:46.
D 2002-02-21T03:02:46
J icomment Logged\sIn:\sYES\s\nuser_id=68433\n\nHm,\sI'm\shaving\sa\shard\stime\slocating\sinstances\sof\nTcl_GetIndexFromObjStruct\sin\sthe\swild.\s\sAs\san\sexample,\nhere's\sa\smodified\sversion\sof\sthe\soption-parsing\spart\sof\nTcl_SubstObjCommand;\sswitching\sto\nTcl_GetIndexFromObjStruct()\ssimplifies\sthe\scode\ssince\swe\scan\nget\srid\sof\san\senum\sdeclaration\sand\sa\sswitch\sstatement:\n\n\s\s\s\sstatic\sstruct\ssubstOption\s{\n\s\s\s\s\s\s\s\sconst\schar\s\s\s\s\s\s*option;\n\s\s\s\s\s\s\s\sunsigned\sint\s\s\s\smask;\n\s\s\s\s}\ssubstOptions[]\s=\s{\n\s\s\s\s\s\s\s\s{\s"-nobackslashes",\sTCL_SUBST_BACKSLASHES\s},\n\s\s\s\s\s\s\s\s{\s"-nocommands",\s\sTCL_SUBST_COMMANDS\s},\n\s\s\s\s\s\s\s\s{\s"-novariables",\sTCL_SUBST_VARIABLES\s},\n\s\s\s\s\s\s\s\s{\sNULL,\s0\s}\n\s\s\s\s};\n\s\s\s\sflags\s=\sTCL_SUBST_ALL;\n\s\s\s\sfor\s(i\s=\s1;\si\s<\s(objc-1);\si++)\s{\n\s\s\s\s\s\s\s\sif\s(Tcl_GetIndexFromObjStruct(interp,\sobjv[i],\n(SOME_CAST)substOptions,\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\ssizeof(substOptions[0]),\s"switch",\s0,\n&optionIndex)\s!=\sTCL_OK)\s{\n\s\s\s\s\s\s\s\s\s\s\s\sreturn\sTCL_ERROR;\n\s\s\s\s\s\s\s\s}\n\s\s\s\s\s\s\s\sflags\s&=\s~substOptions[optionIndex].mask;\n\s\s\s\s}\n\n\s\s\s/*\s...\s*/\n\nWith\sthe\sold\ssignature,\s"SOME_CAST"\sis\s'char\s**';\swith\sthe\ncurrent\ssignature\s'SOME_CAST'\sis\s'CONST84\schar\s**'.\s\sWith\nthe\sproposed\ssignature,\sa\scast\sisn't\snecessary.\n\nFor\scross-version\scompatibility,\sSOME_CAST\scan\sbe\s'void\s*',\nwhich\swill\swork\swith\sall\sthree\ssignatures\s(except\sin\sC++\ncode,\sin\swhich\scase\sit\swill\sonly\swork\sif\nTcl_GetIndexFromObjStruct\stakes\sa\s'void\s*').\n\nBut\sthe\smain\sissue\sis\sthat\sthe\s"tablePtr"\sargument\snormally\npoints\sto\sa\san\sarray\sof\sstructures\sof\sunknown\stype,\sso\s'void\n*'\sis\sthe\smost\sappropriate\stype.\n\n[later]\s\n>\sPayoff\sis\sreally\sin\scalls\sto\sTcl_GetIndexFromObj(),\swhere\s\nyou\scan\slet\sthe\scompiler\s\sauto-cast\sto\s(void\s*)\n\nI\sdon't\sthink\sTcl_GetIndexFromObj()\sshould\sbe\schanged,\sonly\nTcl_GetIndexFromObjStruct().\s\s\sThe\s'tablePtr'\sargument\sto\nthe\sformer\sreally\s_is_\sa\s'const\schar\s**';\sdeclaring\sit\sas\sa\n'void\s*'\swould\sonly\sweaken\sthe\stype-safety\sthat\sTIP27\swas\nintended\sto\senhance.\s\n\n
J login jenglish
J mimetype text/plain
J username jenglish
K 520304ffffffffffffffffffffffffffffffffff
U jenglish
Z cd069a42894b02ae797d0a3b1aaed13e