summaryrefslogtreecommitdiffstats
path: root/generic/tclObj.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclObj.c')
-rw-r--r--generic/tclObj.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/generic/tclObj.c b/generic/tclObj.c
index df17f13..ea1e5ae 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -4492,6 +4492,46 @@ Tcl_RepresentationCmd(
}
/*
+ *----------------------------------------------------------------------
+ *
+ * TclLookupObjTyped --
+ *
+ * Given a Tcl_Obj, find an corresponding object, if one exists, of a
+ * given type.
+ *
+ * Results:
+ * The found object, or, if no such corresponding object was found, NULL.
+ *
+ *
+ * Side effects:
+ * None
+ *
+ *----------------------------------------------------------------------
+ */
+
+Tcl_Obj *
+TclObjLookupTyped (Tcl_Obj * objPtr, Tcl_ObjType *typePtr) {
+ Tcl_Obj *foundPtr;
+ if (typePtr == objPtr->typePtr) {
+ return objPtr;
+ }
+ if (objPtr->typePtr == &tclStringType) {
+ foundPtr = TclStringGetPrev(objPtr);
+ if (foundPtr == NULL) {
+ return NULL;
+ }
+ return TclObjLookupTyped(foundPtr, typePtr);
+ }
+ if (typePtr == &tclListType) {
+ if (objPtr->typePtr == &tclDictType && objPtr->internalRep.twoPtrValue.ptr2 != NULL) {
+ /* A usable list representation exists. */
+ return objPtr->internalRep.twoPtrValue.ptr2;
+ }
+ }
+ return NULL;
+}
+
+/*
* Local Variables:
* mode: c
* c-basic-offset: 4