Index: generic/nsf.c =================================================================== diff -u -rf2ba4d0c4da21ca0fda3cdd13c7558ebc339b48a -r8ac4f64a1364f7a40221a96378f7167322909abc --- generic/nsf.c (.../nsf.c) (revision f2ba4d0c4da21ca0fda3cdd13c7558ebc339b48a) +++ generic/nsf.c (.../nsf.c) (revision 8ac4f64a1364f7a40221a96378f7167322909abc) @@ -195,7 +195,9 @@ *Nsf_OT_listType = NULL, *Nsf_OT_doubleType = NULL, *Nsf_OT_intType = NULL, - *Nsf_OT_parsedVarNameType = NULL; + *Nsf_OT_parsedVarNameType = NULL, + *Nsf_OT_byteArrayType = NULL, + *Nsf_OT_properByteArrayType = NULL; /* * Function prototypes @@ -13299,15 +13301,15 @@ #if 1 if (subMethodCmd != NULL) { unsigned int cmdFlags = (unsigned int)Tcl_Command_flags(subMethodCmd); - + if ((cscPtr->flags & (NSF_CM_LOCAL_METHOD|NSF_CM_IGNORE_PERMISSIONS)) == 0u && (cmdFlags & NSF_CMD_CALL_PRIVATE_METHOD) != 0u) { subMethodCmd = NULL; } else if (unlikely((cmdFlags & NSF_CMD_CALL_PROTECTED_METHOD) != 0u)) { NsfObject *lastSelf; Tcl_CallFrame *framePtr0; int withinEnsemble = ((cscPtr->frameType & NSF_CSC_TYPE_ENSEMBLE) != 0u); - + if (withinEnsemble) { Tcl_CallFrame *framePtr1; /* Alternatively: (void)NsfCallStackFindLastInvocation(interp, 0, &framePtr1); */ @@ -13323,14 +13325,14 @@ } else { lastSelf = GetSelfObj(interp); } - - - /* fprintf(stderr, "'%s (%s) == %s == %s? for %s\n", lastSelf != NULL ? ObjectName(lastSelf): "n/a", + + + /* fprintf(stderr, "'%s (%s) == %s == %s? for %s\n", lastSelf != NULL ? ObjectName(lastSelf): "n/a", ObjectName(GetSelfObj(interp)), ObjectName(actualSelf), ObjectName(invokedObject), subMethodName); */ - + if (actualSelf != lastSelf) { const char *path = withinEnsemble ? ObjStr(NsfMethodNamePath(interp, framePtr0, methodName)) : methodName; - + NsfLog(interp, NSF_LOG_WARN, "'%s %s %s' fails since method %s.%s %s is protected", ObjectName(actualSelf), path, subMethodName, (actualClass != NULL) ? ClassName(actualClass) : ObjectName(actualSelf), path, subMethodName); @@ -22629,6 +22631,25 @@ pPtr = flagPtr->paramPtr; valueObj = flagPtr->payload; + } else if ((argumentObj->typePtr == Nsf_OT_byteArrayType) + || (argumentObj->typePtr == Nsf_OT_properByteArrayType) + //|| (argumentObj->typePtr == Nsf_OT_intType) + //|| (argumentObj->typePtr == Nsf_OT_doubleType) + ) { + /* + * The actual argument belongs to the types, for which we assume that + * these can't belong to a nonpos flag. The argument might be e.g. a + * pure Tcl bytearray, for which we do not want to add a string rep + * via ObjStr() such it looses its purity (Tcl 8.6). For these + * argument types. proceed in the parameter vector to the next block + * (positional parameter) + */ + SkipNonposParamDefs(currentParamPtr); + pPtr = currentParamPtr; + /* + * currentParamPtr is either NULL or points to a positional parameter + */ + assert(currentParamPtr == NULL || currentParamPtr->name == NULL || *currentParamPtr->name != '-'); } else { const char *argumentString = ObjStr(argumentObj); /* @@ -25129,6 +25150,19 @@ fprintf(stderr, "... cmd %p flags %.6x name '%s' ns '%s'", (void *)cmd, Tcl_Command_flags(cmd), tail, procPtr->nsPtr->name); } + } else if ((objPtr->typePtr == Nsf_OT_byteArrayType) + || (objPtr->typePtr == Nsf_OT_properByteArrayType)) { + char *bytes; + int i, length; + + bytes = (char *)Tcl_GetByteArrayFromObj(objPtr, &length); + + fprintf(stderr, "bytearray proper %d length %d string rep %p: ", + (objPtr->typePtr == Nsf_OT_properByteArrayType), + length, (void*)objPtr->bytes); + for (i = 0; i < length; i++) { + fprintf(stderr, "%.2x", (unsigned)(*(bytes+i)) & 0xff); + } } fprintf(stderr, "\n"); @@ -32816,6 +32850,31 @@ Nsf_OT_doubleType = Tcl_GetObjType("double"); assert(Nsf_OT_doubleType != NULL); + + Nsf_OT_byteArrayType = Tcl_GetObjType("bytearray"); + assert(Nsf_OT_byteArrayType != NULL); + + /* + * Get bytearray and proper bytearray from Tcl (latter if available, + * introduced in Tcl 8.7a+) + */ + { + Tcl_Obj *newByteObj = Tcl_NewByteArrayObj(NULL, 0); + + Nsf_OT_properByteArrayType = newByteObj->typePtr; + if (Nsf_OT_properByteArrayType == Nsf_OT_byteArrayType) { + /* + * When both values are the same, we are in a Tcl version before 8.7, + * where we have no properByteArrayTypePtr. So set it to an invalid + * value to avoid potential confusions. Without this stunt, we would + * need several ifdefs. + */ + Nsf_OT_properByteArrayType = (Tcl_ObjType *)0xffffff; + } + Tcl_DecrRefCount(newByteObj); + } + assert(Nsf_OT_properByteArrayType != NULL); + NsfMutexUnlock(&initMutex); /* Index: tests/method-parameter.test =================================================================== diff -u -re0da9e0032a357fe5c6bfdd37a2d234e00780460 -r8ac4f64a1364f7a40221a96378f7167322909abc --- tests/method-parameter.test (.../method-parameter.test) (revision e0da9e0032a357fe5c6bfdd37a2d234e00780460) +++ tests/method-parameter.test (.../method-parameter.test) (revision 8ac4f64a1364f7a40221a96378f7167322909abc) @@ -359,7 +359,7 @@ # Test abbreviations # -nx::test case abbrevs { +nx::test case abbrevs1 { nsf::proc x {-super -super11 -superclass -super12} { return [info exists super]-[info exists super11]-[info exists superclass]-[info exists super12] @@ -382,7 +382,7 @@ # leading dash and and numbers # -nx::test case abbrevs { +nx::test case abbrevs2 { nsf::proc x {-x y:integer} { return [info exists x]-$y