Index: generic/gentclAPI.decls =================================================================== diff -u -r8eb8f0692e858ee3b4a7f90d0e16bae6f835330f -r5f856ff709f400d155ff730f532f646db5feef04 --- generic/gentclAPI.decls (.../gentclAPI.decls) (revision 8eb8f0692e858ee3b4a7f90d0e16bae6f835330f) +++ generic/gentclAPI.decls (.../gentclAPI.decls) (revision 5f856ff709f400d155ff730f532f646db5feef04) @@ -401,6 +401,10 @@ {-argName "-scope" -required 0 -nrargs 1 -type "all|class|object"} {-argName "pattern" -type objpattern} } +classInfoMethod objectparameter NsfClassInfoObjectparameterMethod { + {-argName "infoobjectparametersubcmd" -type "list|name|parameter|parametersyntax" -required 1} + {-argName "pattern" -required 0} +} classInfoMethod slots NsfClassInfoSlotsMethod { {-argName "-closure"} {-argName "-source" -nrargs 1 -type "all|application|baseclasses" -default all} Index: generic/nsf.c =================================================================== diff -u -r1f7ecfcf5b0643ce05b96405c77d5da7fe10268e -r5f856ff709f400d155ff730f532f646db5feef04 --- generic/nsf.c (.../nsf.c) (revision 1f7ecfcf5b0643ce05b96405c77d5da7fe10268e) +++ generic/nsf.c (.../nsf.c) (revision 5f856ff709f400d155ff730f532f646db5feef04) @@ -7433,7 +7433,7 @@ *---------------------------------------------------------------------- * ParamDefsList -- * - * Produce a Tcl_ListObj containing the names ot the parameters + * Produce a Tcl_ListObj containing the list of the parameters * based on a parameter structure. * * Results: @@ -7450,6 +7450,33 @@ Nsf_Param CONST *pPtr; for (pPtr = paramsPtr; pPtr->name; pPtr++) { + Tcl_ListObjAppendElement(interp, listObj, Tcl_NewStringObj(pPtr->name, -1)); + } + return listObj; +} + + +/* + *---------------------------------------------------------------------- + * ParamDefsNames -- + * + * Produce a Tcl_ListObj containing the names of the parameters + * based on a parameter structure. + * + * Results: + * Tcl_Obj + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ +static Tcl_Obj * +ParamDefsNames(Tcl_Interp *interp, Nsf_Param CONST *paramsPtr) { + Tcl_Obj *listObj = Tcl_NewListObj(0, NULL); + Nsf_Param CONST *pPtr; + + for (pPtr = paramsPtr; pPtr->name; pPtr++) { Tcl_ListObjAppendElement(interp, listObj, pPtr->nameObj); } return listObj; @@ -13825,29 +13852,28 @@ } static Tcl_Obj * -ListParamDefs(Tcl_Interp *interp, Nsf_Param CONST *paramsPtr, int style) { +ListParamDefs(Tcl_Interp *interp, Nsf_Param CONST *paramsPtr, NsfParamsPrintStyle style) { Tcl_Obj *listObj; switch (style) { - case 0: listObj = ParamDefsFormat(interp, paramsPtr); break; - case 1: listObj = ParamDefsList(interp, paramsPtr); break; - case 2: listObj = NsfParamDefsSyntax(paramsPtr); break; + case NSF_PARAMS_PARAMETER: listObj = ParamDefsFormat(interp, paramsPtr); break; + case NSF_PARAMS_LIST: listObj = ParamDefsList(interp, paramsPtr); break; + case NSF_PARAMS_NAMES: listObj = ParamDefsNames(interp, paramsPtr); break; + case NSF_PARAMS_SYNTAX: listObj = NsfParamDefsSyntax(paramsPtr); break; default: listObj = NULL; } return listObj; } -// TODO enum style - /* *---------------------------------------------------------------------- * ListCmdParams -- * - * Obtains a cmd and a method name and sets as side effect the Tcl - * result to either the list of the parameters (withVarnames == 0), - * to the args (withVarnames == 1) or to the parametersyntax - * (withVarnames == 2). + * Obtains a cmd and a method name and sets as side effect the Tcl result + * to either the list. The printstyle NSF_PARAMS_NAMES, NSF_PARAMS_LIST, + * NSF_PARAMS_PARAMETER, NSF_PARAMS_SYNTAX controls the elements of the + * list. * * Results: * Tcl result code. @@ -13859,7 +13885,8 @@ */ static int -ListCmdParams(Tcl_Interp *interp, Tcl_Command cmd, CONST char *methodName, int withVarnames) { +ListCmdParams(Tcl_Interp *interp, Tcl_Command cmd, CONST char *methodName, + NsfParamsPrintStyle printStyle) { NsfParamDefs *paramDefs; Tcl_Obj *list; Proc *procPtr; @@ -13873,7 +13900,7 @@ /* * Obtain parameter info from paramDefs */ - list = ListParamDefs(interp, paramDefs->paramsPtr, withVarnames); + list = ListParamDefs(interp, paramDefs->paramsPtr, printStyle); Tcl_SetObjResult(interp, list); return TCL_OK; } @@ -13893,15 +13920,15 @@ continue; } - if (withVarnames == 2 && strcmp(args->name, "args") == 0) { + if (printStyle == NSF_PARAMS_SYNTAX && strcmp(args->name, "args") == 0) { if (args != procPtr->firstLocalPtr) { Tcl_AppendToObj(list, " ", 1); } Tcl_AppendToObj(list, "?arg ...?", 9); } else { innerlist = Tcl_NewListObj(0, NULL); Tcl_ListObjAppendElement(interp, innerlist, Tcl_NewStringObj(args->name, -1)); - if (!withVarnames && args->defValuePtr) { + if (printStyle == NSF_PARAMS_PARAMETER && args->defValuePtr) { Tcl_ListObjAppendElement(interp, innerlist, args->defValuePtr); } Tcl_ListObjAppendElement(interp, list, innerlist); @@ -13926,7 +13953,7 @@ if (((Command *)cmd)->objProc == mdPtr->proc) { NsfParamDefs paramDefs = {mdPtr->paramDefs, mdPtr->nrParameters, NULL, NULL}; - Tcl_Obj *list = ListParamDefs(interp, paramDefs.paramsPtr, withVarnames); + Tcl_Obj *list = ListParamDefs(interp, paramDefs.paramsPtr, printStyle); Tcl_SetObjResult(interp, list); return TCL_OK; @@ -13942,7 +13969,7 @@ paramDefs.paramsPtr = cd->paramsPtr; paramDefs.nrParams = 1; paramDefs.slotObj = NULL; - list = ListParamDefs(interp, paramDefs.paramsPtr, withVarnames); + list = ListParamDefs(interp, paramDefs.paramsPtr, printStyle); Tcl_SetObjResult(interp, list); return TCL_OK; } else { @@ -13957,7 +13984,7 @@ * ::nsf::parametersyntax. Note that we can only obtain the * parametersyntax this way. */ - if (withVarnames == 2) { + if (printStyle == NSF_PARAMS_SYNTAX) { Tcl_DString ds, *dsPtr = &ds; Tcl_Obj *parameterSyntaxObj; @@ -14092,17 +14119,17 @@ case InfomethodsubcmdArgsIdx: { Tcl_Command importedCmd = GetOriginalCommand(cmd); - return ListCmdParams(interp, importedCmd, methodName, 1); + return ListCmdParams(interp, importedCmd, methodName, NSF_PARAMS_NAMES); } case InfomethodsubcmdParameterIdx: { Tcl_Command importedCmd = GetOriginalCommand(cmd); - return ListCmdParams(interp, importedCmd, methodName, 0); + return ListCmdParams(interp, importedCmd, methodName, NSF_PARAMS_PARAMETER); } case InfomethodsubcmdParametersyntaxIdx: { Tcl_Command importedCmd = GetOriginalCommand(cmd); - return ListCmdParams(interp, importedCmd, methodName, 2); + return ListCmdParams(interp, importedCmd, methodName, NSF_PARAMS_SYNTAX); } case InfomethodsubcmdPreconditionIdx: { @@ -14173,7 +14200,7 @@ /* todo: don't hard-code registering command name "method" / NSF_METHOD */ AppendMethodRegistration(interp, resultObj, NsfGlobalStrings[NSF_METHOD], regObject, methodName, cmd, 0, outputPerObject, 1); - ListCmdParams(interp, cmd, methodName, 0); + ListCmdParams(interp, cmd, methodName, NSF_PARAMS_PARAMETER); Tcl_ListObjAppendElement(interp, resultObj, Tcl_GetObjResult(interp)); ListProcBody(interp, GetTclProcFromCommand(cmd), methodName); Tcl_ListObjAppendElement(interp, resultObj, Tcl_GetObjResult(interp)); @@ -14273,7 +14300,7 @@ Tcl_ListObjAppendElement(interp, resultObj, Tcl_NewStringObj(Tcl_DStringValue(dsPtr), Tcl_DStringLength(dsPtr))); - ListCmdParams(interp, cmd, Tcl_DStringValue(dsPtr), 0); + ListCmdParams(interp, cmd, Tcl_DStringValue(dsPtr), NSF_PARAMS_PARAMETER); Tcl_ListObjAppendElement(interp, resultObj, Tcl_GetObjResult(interp)); ListProcBody(interp, GetTclProcFromCommand(procCmd), methodName); Tcl_ListObjAppendElement(interp, resultObj, Tcl_GetObjResult(interp)); @@ -16219,7 +16246,7 @@ /* * Build a list containing the arguments of the proc */ - result = ListCmdParams(interp, cmd, oldName, 0); + result = ListCmdParams(interp, cmd, oldName, NSF_PARAMS_PARAMETER); if (result != TCL_OK) { return result; } @@ -19299,7 +19326,67 @@ return TCL_OK; } + /* +classInfoMethod objectparameter NsfClassInfoObjectparameterMethod { + {-argName "infoobjectparametersubcmd" -type "name|parameter|parametersyntax" -required 1} + {-argName "name" -required 0} +} +*/ + +static int +NsfClassInfoObjectparameterMethod(Tcl_Interp *interp, NsfClass *class, + int subcmd, CONST char *name) { + NsfParsedParam parsedParam; + Tcl_Obj *listObj = NULL; + Nsf_Param CONST *paramsPtr; + Nsf_Param paramList[2]; + int result; + + result = GetObjectParameterDefinition(interp, NsfGlobalObjs[NSF_EMPTY], + class, &parsedParam); + if (result != TCL_OK) { + return result; + } + paramsPtr = parsedParam.paramDefs->paramsPtr; + + /* + * If a single paramter name is given, we construct a filtered parameter + * list on the fly and provide it to the output functions. + */ + if (name) { + Nsf_Param CONST *pPtr; + + for (pPtr = paramsPtr; pPtr->name; pPtr++) { + if (Tcl_StringMatch( ObjStr(pPtr->nameObj), name)) { + paramsPtr = (Nsf_Param CONST *)¶mList; + paramList[0] = *pPtr; + paramList[1].name = NULL; + break; + } + } + } + + switch (subcmd) { + case InfoobjectparametersubcmdListIdx: + listObj = ParamDefsList(interp, paramsPtr); + break; + case InfoobjectparametersubcmdNameIdx: + listObj = ParamDefsNames(interp, paramsPtr); + break; + case InfoobjectparametersubcmdParameterIdx: + listObj = ParamDefsFormat(interp, paramsPtr); + break; + case InfoobjectparametersubcmdParametersyntaxIdx: + listObj = NsfParamDefsSyntax(paramsPtr); + break; + } + Tcl_SetObjResult(interp, listObj); + + return TCL_OK; +} + +/* classInfoMethod slots NsfClassInfoSlotsMethod { {-argName "-closure"} {-argName "-source" -nrargs 1 -type "all|application|baseclasses"} Index: generic/nsfInt.h =================================================================== diff -u -r1f7ecfcf5b0643ce05b96405c77d5da7fe10268e -r5f856ff709f400d155ff730f532f646db5feef04 --- generic/nsfInt.h (.../nsfInt.h) (revision 1f7ecfcf5b0643ce05b96405c77d5da7fe10268e) +++ generic/nsfInt.h (.../nsfInt.h) (revision 5f856ff709f400d155ff730f532f646db5feef04) @@ -635,6 +635,10 @@ } NsfShadowTclCommandInfo; typedef enum {SHADOW_LOAD=1, SHADOW_UNLOAD=0, SHADOW_REFETCH=2} NsfShadowOperations; + +typedef enum {NSF_PARAMS_NAMES, NSF_PARAMS_LIST, + NSF_PARAMS_PARAMETER, NSF_PARAMS_SYNTAX} NsfParamsPrintStyle; + int NsfCallCommand(Tcl_Interp *interp, NsfGlobalNames name, int objc, Tcl_Obj *CONST objv[]); int NsfShadowTclCommands(Tcl_Interp *interp, NsfShadowOperations load); Index: generic/tclAPI.h =================================================================== diff -u -r8eb8f0692e858ee3b4a7f90d0e16bae6f835330f -r5f856ff709f400d155ff730f532f646db5feef04 --- generic/tclAPI.h (.../tclAPI.h) (revision 8eb8f0692e858ee3b4a7f90d0e16bae6f835330f) +++ generic/tclAPI.h (.../tclAPI.h) (revision 5f856ff709f400d155ff730f532f646db5feef04) @@ -51,6 +51,19 @@ return result; } +enum InfoobjectparametersubcmdIdx {InfoobjectparametersubcmdNULL, InfoobjectparametersubcmdListIdx, InfoobjectparametersubcmdNameIdx, InfoobjectparametersubcmdParameterIdx, InfoobjectparametersubcmdParametersyntaxIdx}; + +static int ConvertToInfoobjectparametersubcmd(Tcl_Interp *interp, Tcl_Obj *objPtr, Nsf_Param CONST *pPtr, + ClientData *clientData, Tcl_Obj **outObjPtr) { + int index, result; + static CONST char *opts[] = {"list", "name", "parameter", "parametersyntax", NULL}; + (void)pPtr; + result = Tcl_GetIndexFromObj(interp, objPtr, opts, "infoobjectparametersubcmd", 0, &index); + *clientData = (ClientData) INT2PTR(index + 1); + *outObjPtr = objPtr; + return result; +} + enum SourceIdx {SourceNULL, SourceAllIdx, SourceApplicationIdx, SourceBaseclassesIdx}; static int ConvertToSource(Tcl_Interp *interp, Tcl_Obj *objPtr, Nsf_Param CONST *pPtr, @@ -158,6 +171,7 @@ static enumeratorConverterEntry enumeratorConverterEntries[] = { {ConvertToScope, "all|class|object"}, + {ConvertToInfoobjectparametersubcmd, "list|name|parameter|parametersyntax"}, {ConvertToInfomethodsubcmd, "args|body|definition|exists|handle|parameter|parametersyntax|type|precondition|postcondition|submethods"}, {ConvertToCallprotection, "all|protected|public"}, {ConvertToMethodtype, "all|scripted|builtin|alias|forwarder|object|setter|nsfproc"}, @@ -200,6 +214,7 @@ static int NsfClassInfoMixinOfMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfClassInfoMixinclassesMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfClassInfoMixinguardMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int NsfClassInfoObjectparameterMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfClassInfoSlotsMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfClassInfoSubclassMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfClassInfoSuperclassMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); @@ -290,6 +305,7 @@ static int NsfClassInfoMixinOfMethod(Tcl_Interp *interp, NsfClass *cl, int withClosure, int withScope, CONST char *patternString, NsfObject *patternObj); static int NsfClassInfoMixinclassesMethod(Tcl_Interp *interp, NsfClass *cl, int withClosure, int withGuards, int withHeritage, CONST char *patternString, NsfObject *patternObj); static int NsfClassInfoMixinguardMethod(Tcl_Interp *interp, NsfClass *cl, CONST char *mixin); +static int NsfClassInfoObjectparameterMethod(Tcl_Interp *interp, NsfClass *cl, int infoobjectparametersubcmd, CONST char *pattern); static int NsfClassInfoSlotsMethod(Tcl_Interp *interp, NsfClass *cl, int withClosure, int withSource, NsfClass *withType, CONST char *pattern); static int NsfClassInfoSubclassMethod(Tcl_Interp *interp, NsfClass *cl, int withClosure, CONST char *patternString, NsfObject *patternObj); static int NsfClassInfoSuperclassMethod(Tcl_Interp *interp, NsfClass *cl, int withClosure, Tcl_Obj *pattern); @@ -381,6 +397,7 @@ NsfClassInfoMixinOfMethodIdx, NsfClassInfoMixinclassesMethodIdx, NsfClassInfoMixinguardMethodIdx, + NsfClassInfoObjectparameterMethodIdx, NsfClassInfoSlotsMethodIdx, NsfClassInfoSubclassMethodIdx, NsfClassInfoSuperclassMethodIdx, @@ -847,6 +864,26 @@ } static int +NsfClassInfoObjectparameterMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + ParseContext pc; + NsfClass *cl = NsfObjectToClass(clientData); + if (!cl) return NsfDispatchClientDataError(interp, clientData, "class", "objectparameter"); + if (ArgumentParse(interp, objc, objv, (NsfObject *) cl, objv[0], + method_definitions[NsfClassInfoObjectparameterMethodIdx].paramDefs, + method_definitions[NsfClassInfoObjectparameterMethodIdx].nrParameters, 1, + &pc) != TCL_OK) { + return TCL_ERROR; + } else { + int infoobjectparametersubcmd = (int )PTR2INT(pc.clientData[0]); + CONST char *pattern = (CONST char *)pc.clientData[1]; + + assert(pc.status == 0); + return NsfClassInfoObjectparameterMethod(interp, cl, infoobjectparametersubcmd, pattern); + + } +} + +static int NsfClassInfoSlotsMethodStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; NsfClass *cl = NsfObjectToClass(clientData); @@ -2265,6 +2302,10 @@ {"::nsf::methods::class::info::mixinguard", NsfClassInfoMixinguardMethodStub, 1, { {"mixin", NSF_ARG_REQUIRED, 0, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL}} }, +{"::nsf::methods::class::info::objectparameter", NsfClassInfoObjectparameterMethodStub, 2, { + {"infoobjectparametersubcmd", NSF_ARG_REQUIRED|NSF_ARG_IS_ENUMERATION, 0, ConvertToInfoobjectparametersubcmd, NULL,NULL,NULL,NULL,NULL,NULL,NULL}, + {"pattern", 0, 0, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL}} +}, {"::nsf::methods::class::info::slots", NsfClassInfoSlotsMethodStub, 4, { {"-closure", 0, 0, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"-source", 0|NSF_ARG_IS_ENUMERATION, 1, ConvertToSource, NULL,NULL,NULL,NULL,NULL,NULL,NULL},