summaryrefslogtreecommitdiffstats
path: root/generic/tclObj.c
diff options
context:
space:
mode:
authorpooryorick <com.digitalsmarties@pooryorick.com>2016-07-28 21:49:35 (GMT)
committerpooryorick <com.digitalsmarties@pooryorick.com>2016-07-28 21:49:35 (GMT)
commit3a49ad6c4bdee4485eb5fd692e7ba8d1a5d0f637 (patch)
tree7f0dfdde40a71ae52f7e38e3031a8b0066ea0f31 /generic/tclObj.c
parentd01a6c61924702ec32f0345567fead78978e1c54 (diff)
parentf1810dae6c5de7512c2d388b7631b7dc4a888928 (diff)
downloadtcl-pyk_trunk.zip
tcl-pyk_trunk.tar.gz
tcl-pyk_trunk.tar.bz2
merge pyk-listdictstringreppyk_trunk
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