Tcl Source Code

Artifact [69becf860a]
Login

Artifact 69becf860a21c45b2968ac73698cc1e2e5d3d9bd:

Attachment "dict.patch" to ticket [654893ffff] added by dkf 2003-02-17 21:00:26.
Index: generic/tcl.decls
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tcl.decls,v
retrieving revision 1.94
diff -u -r1.94 tcl.decls
--- generic/tcl.decls	31 Aug 2002 06:09:45 -0000	1.94
+++ generic/tcl.decls	17 Feb 2003 13:40:55 -0000
@@ -1754,6 +1754,49 @@
 	    Tcl_ChannelType *chanTypePtr)
 }
 
+# DICTIONARIES
+declare 494 generic {
+    int Tcl_DictObjPut(Tcl_Interp *interp, Tcl_Obj *dictPtr,
+	    Tcl_Obj *keyPtr, Tcl_Obj *valuePtr)
+}
+declare 495 generic {
+    int Tcl_DictObjGet(Tcl_Interp *interp, Tcl_Obj *dictPtr, Tcl_Obj *keyPtr,
+	    Tcl_Obj **valuePtrPtr)
+}
+declare 496 generic {
+    int Tcl_DictObjRemove(Tcl_Interp *interp, Tcl_Obj *dictPtr,
+	    Tcl_Obj *keyPtr)
+}
+declare 497 generic {
+    int Tcl_DictObjSize(Tcl_Interp *interp, Tcl_Obj *dictPtr, int *sizePtr)
+}
+declare 498 generic {
+    int Tcl_DictObjFirst(Tcl_Interp *interp, Tcl_Obj *dictPtr,
+	    Tcl_DictSearch *searchPtr,
+	    Tcl_Obj **keyPtrPtr, Tcl_Obj **valuePtrPtr, int *donePtr)
+}
+declare 499 generic {
+    void Tcl_DictObjNext(Tcl_DictSearch *searchPtr,
+	    Tcl_Obj **keyPtrPtr, Tcl_Obj **valuePtrPtr, int *donePtr)
+}
+declare 500 generic {
+    void Tcl_DictObjDone(Tcl_DictSearch *searchPtr)
+}
+declare 501 generic {
+    int Tcl_DictObjPutKeyList(Tcl_Interp *interp, Tcl_Obj *dictPtr,
+	    int keyc, Tcl_Obj *CONST *keyv, Tcl_Obj *valuePtr)
+}
+declare 502 generic {
+    int Tcl_DictObjRemoveKeyList(Tcl_Interp *interp, Tcl_Obj *dictPtr,
+	    int keyc, Tcl_Obj *CONST *keyv)
+}
+declare 503 generic {
+    Tcl_Obj *Tcl_NewDictObj(void)
+}
+declare 504 generic {
+    Tcl_Obj *Tcl_DbNewDictObj(CONST char *file, int line)
+}
+
 ##############################################################################
 
 # Define the platform specific public Tcl interface.  These functions are
Index: generic/tcl.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tcl.h,v
retrieving revision 1.153
diff -u -r1.153 tcl.h
--- generic/tcl.h	15 Feb 2003 02:16:29 -0000	1.153
+++ generic/tcl.h	17 Feb 2003 13:40:56 -0000
@@ -490,6 +490,7 @@
 typedef struct Tcl_Var_ *Tcl_Var;
 typedef struct Tcl_ChannelTypeVersion_ *Tcl_ChannelTypeVersion;
 typedef struct Tcl_LoadHandle_ *Tcl_LoadHandle;
+typedef struct Tcl_Dict_ *Tcl_Dict;
 
 /*
  * Definition of the interface to procedures implementing threads.
@@ -1335,6 +1336,17 @@
 #   define Tcl_InitHashTable(tablePtr, keyType) \
 	Tcl_InitHashTableEx(tablePtr, keyType, NULL)
 #endif /* TCL_PRESERVE_BINARY_COMPATABILITY */
+
+/*
+ * Structure definition for information used to keep track of searches
+ * through dictionaries:
+ */
+typedef struct {
+    Tcl_HashSearch search;
+    int epoch;
+    Tcl_Obj *objPtr;
+    Tcl_Dict dictionaryPtr;
+} Tcl_DictSearch;
 
 
 /*
Index: generic/tclBasic.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclBasic.c,v
retrieving revision 1.73
diff -u -r1.73 tclBasic.c
--- generic/tclBasic.c	16 Feb 2003 01:36:32 -0000	1.73
+++ generic/tclBasic.c	17 Feb 2003 13:40:59 -0000
@@ -88,6 +88,8 @@
         (CompileProc *) NULL,		1},
     {"continue",	(Tcl_CmdProc *) NULL,	Tcl_ContinueObjCmd,
         TclCompileContinueCmd,		1},
+    {"dict",		(Tcl_CmdProc *) NULL,	Tcl_DictObjCmd,
+        (CompileProc *) NULL,		0},
     {"encoding",	(Tcl_CmdProc *) NULL,	Tcl_EncodingObjCmd,
         (CompileProc *) NULL,		0},
     {"error",		(Tcl_CmdProc *) NULL,	Tcl_ErrorObjCmd,
Index: generic/tclDecls.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclDecls.h,v
retrieving revision 1.93
diff -u -r1.93 tclDecls.h
--- generic/tclDecls.h	5 Aug 2002 15:01:04 -0000	1.93
+++ generic/tclDecls.h	17 Feb 2003 13:41:03 -0000
@@ -1564,6 +1564,48 @@
 /* 493 */
 EXTERN Tcl_DriverWideSeekProc * Tcl_ChannelWideSeekProc _ANSI_ARGS_((
 				Tcl_ChannelType * chanTypePtr));
+/* 494 */
+EXTERN int		Tcl_DictObjPut _ANSI_ARGS_((Tcl_Interp * interp, 
+				Tcl_Obj * dictPtr, Tcl_Obj * keyPtr, 
+				Tcl_Obj * valuePtr));
+/* 495 */
+EXTERN int		Tcl_DictObjGet _ANSI_ARGS_((Tcl_Interp * interp, 
+				Tcl_Obj * dictPtr, Tcl_Obj * keyPtr, 
+				Tcl_Obj ** valuePtrPtr));
+/* 496 */
+EXTERN int		Tcl_DictObjRemove _ANSI_ARGS_((Tcl_Interp * interp, 
+				Tcl_Obj * dictPtr, Tcl_Obj * keyPtr));
+/* 497 */
+EXTERN int		Tcl_DictObjSize _ANSI_ARGS_((Tcl_Interp * interp, 
+				Tcl_Obj * dictPtr, int * sizePtr));
+/* 498 */
+EXTERN int		Tcl_DictObjFirst _ANSI_ARGS_((Tcl_Interp * interp, 
+				Tcl_Obj * dictPtr, 
+				Tcl_DictSearch * searchPtr, 
+				Tcl_Obj ** keyPtrPtr, Tcl_Obj ** valuePtrPtr, 
+				int * donePtr));
+/* 499 */
+EXTERN void		Tcl_DictObjNext _ANSI_ARGS_((
+				Tcl_DictSearch * searchPtr, 
+				Tcl_Obj ** keyPtrPtr, Tcl_Obj ** valuePtrPtr, 
+				int * donePtr));
+/* 500 */
+EXTERN void		Tcl_DictObjDone _ANSI_ARGS_((
+				Tcl_DictSearch * searchPtr));
+/* 501 */
+EXTERN int		Tcl_DictObjPutKeyList _ANSI_ARGS_((
+				Tcl_Interp * interp, Tcl_Obj * dictPtr, 
+				int keyc, Tcl_Obj *CONST * keyv, 
+				Tcl_Obj * valuePtr));
+/* 502 */
+EXTERN int		Tcl_DictObjRemoveKeyList _ANSI_ARGS_((
+				Tcl_Interp * interp, Tcl_Obj * dictPtr, 
+				int keyc, Tcl_Obj *CONST * keyv));
+/* 503 */
+EXTERN Tcl_Obj *	Tcl_NewDictObj _ANSI_ARGS_((void));
+/* 504 */
+EXTERN Tcl_Obj *	Tcl_DbNewDictObj _ANSI_ARGS_((CONST char * file, 
+				int line));
 
 typedef struct TclStubHooks {
     struct TclPlatStubs *tclPlatStubs;
@@ -2117,6 +2159,17 @@
     Tcl_WideInt (*tcl_Seek) _ANSI_ARGS_((Tcl_Channel chan, Tcl_WideInt offset, int mode)); /* 491 */
     Tcl_WideInt (*tcl_Tell) _ANSI_ARGS_((Tcl_Channel chan)); /* 492 */
     Tcl_DriverWideSeekProc * (*tcl_ChannelWideSeekProc) _ANSI_ARGS_((Tcl_ChannelType * chanTypePtr)); /* 493 */
+    int (*tcl_DictObjPut) _ANSI_ARGS_((Tcl_Interp * interp, Tcl_Obj * dictPtr, Tcl_Obj * keyPtr, Tcl_Obj * valuePtr)); /* 494 */
+    int (*tcl_DictObjGet) _ANSI_ARGS_((Tcl_Interp * interp, Tcl_Obj * dictPtr, Tcl_Obj * keyPtr, Tcl_Obj ** valuePtrPtr)); /* 495 */
+    int (*tcl_DictObjRemove) _ANSI_ARGS_((Tcl_Interp * interp, Tcl_Obj * dictPtr, Tcl_Obj * keyPtr)); /* 496 */
+    int (*tcl_DictObjSize) _ANSI_ARGS_((Tcl_Interp * interp, Tcl_Obj * dictPtr, int * sizePtr)); /* 497 */
+    int (*tcl_DictObjFirst) _ANSI_ARGS_((Tcl_Interp * interp, Tcl_Obj * dictPtr, Tcl_DictSearch * searchPtr, Tcl_Obj ** keyPtrPtr, Tcl_Obj ** valuePtrPtr, int * donePtr)); /* 498 */
+    void (*tcl_DictObjNext) _ANSI_ARGS_((Tcl_DictSearch * searchPtr, Tcl_Obj ** keyPtrPtr, Tcl_Obj ** valuePtrPtr, int * donePtr)); /* 499 */
+    void (*tcl_DictObjDone) _ANSI_ARGS_((Tcl_DictSearch * searchPtr)); /* 500 */
+    int (*tcl_DictObjPutKeyList) _ANSI_ARGS_((Tcl_Interp * interp, Tcl_Obj * dictPtr, int keyc, Tcl_Obj *CONST * keyv, Tcl_Obj * valuePtr)); /* 501 */
+    int (*tcl_DictObjRemoveKeyList) _ANSI_ARGS_((Tcl_Interp * interp, Tcl_Obj * dictPtr, int keyc, Tcl_Obj *CONST * keyv)); /* 502 */
+    Tcl_Obj * (*tcl_NewDictObj) _ANSI_ARGS_((void)); /* 503 */
+    Tcl_Obj * (*tcl_DbNewDictObj) _ANSI_ARGS_((CONST char * file, int line)); /* 504 */
 } TclStubs;
 
 #ifdef __cplusplus
@@ -4132,6 +4185,50 @@
 #ifndef Tcl_ChannelWideSeekProc
 #define Tcl_ChannelWideSeekProc \
 	(tclStubsPtr->tcl_ChannelWideSeekProc) /* 493 */
+#endif
+#ifndef Tcl_DictObjPut
+#define Tcl_DictObjPut \
+	(tclStubsPtr->tcl_DictObjPut) /* 494 */
+#endif
+#ifndef Tcl_DictObjGet
+#define Tcl_DictObjGet \
+	(tclStubsPtr->tcl_DictObjGet) /* 495 */
+#endif
+#ifndef Tcl_DictObjRemove
+#define Tcl_DictObjRemove \
+	(tclStubsPtr->tcl_DictObjRemove) /* 496 */
+#endif
+#ifndef Tcl_DictObjSize
+#define Tcl_DictObjSize \
+	(tclStubsPtr->tcl_DictObjSize) /* 497 */
+#endif
+#ifndef Tcl_DictObjFirst
+#define Tcl_DictObjFirst \
+	(tclStubsPtr->tcl_DictObjFirst) /* 498 */
+#endif
+#ifndef Tcl_DictObjNext
+#define Tcl_DictObjNext \
+	(tclStubsPtr->tcl_DictObjNext) /* 499 */
+#endif
+#ifndef Tcl_DictObjDone
+#define Tcl_DictObjDone \
+	(tclStubsPtr->tcl_DictObjDone) /* 500 */
+#endif
+#ifndef Tcl_DictObjPutKeyList
+#define Tcl_DictObjPutKeyList \
+	(tclStubsPtr->tcl_DictObjPutKeyList) /* 501 */
+#endif
+#ifndef Tcl_DictObjRemoveKeyList
+#define Tcl_DictObjRemoveKeyList \
+	(tclStubsPtr->tcl_DictObjRemoveKeyList) /* 502 */
+#endif
+#ifndef Tcl_NewDictObj
+#define Tcl_NewDictObj \
+	(tclStubsPtr->tcl_NewDictObj) /* 503 */
+#endif
+#ifndef Tcl_DbNewDictObj
+#define Tcl_DbNewDictObj \
+	(tclStubsPtr->tcl_DbNewDictObj) /* 504 */
 #endif
 
 #endif /* defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) */
Index: generic/tclInt.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclInt.h,v
retrieving revision 1.118
diff -u -r1.118 tclInt.h
--- generic/tclInt.h	10 Feb 2003 10:26:25 -0000	1.118
+++ generic/tclInt.h	17 Feb 2003 13:41:04 -0000
@@ -1597,6 +1597,7 @@
 #ifndef TCL_WIDE_INT_IS_LONG
 extern Tcl_ObjType	tclWideIntType;
 #endif
+extern Tcl_ObjType	tclDictType;
 
 /*
  * Variables denoting the hash key types defined in the core.
@@ -1848,6 +1849,8 @@
 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
 EXTERN int	Tcl_ContinueObjCmd _ANSI_ARGS_((ClientData clientData,
 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
+EXTERN int	Tcl_DictObjCmd _ANSI_ARGS_((ClientData clientData,
+		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
 EXTERN int	Tcl_EncodingObjCmd _ANSI_ARGS_((ClientData clientData,
 		    Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
 EXTERN int	Tcl_EofObjCmd _ANSI_ARGS_((ClientData clientData,
Index: generic/tclObj.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclObj.c,v
retrieving revision 1.42
diff -u -r1.42 tclObj.c
--- generic/tclObj.c	17 Jan 2003 22:11:02 -0000	1.42
+++ generic/tclObj.c	17 Feb 2003 13:41:05 -0000
@@ -238,11 +238,12 @@
 #endif
     Tcl_RegisterObjType(&tclStringType);
     Tcl_RegisterObjType(&tclListType);
+    Tcl_RegisterObjType(&tclDictType);
     Tcl_RegisterObjType(&tclByteCodeType);
     Tcl_RegisterObjType(&tclProcBodyType);
     Tcl_RegisterObjType(&tclArraySearchType);
     Tcl_RegisterObjType(&tclIndexType);
     Tcl_RegisterObjType(&tclNsNameType);
     Tcl_RegisterObjType(&tclCmdNameType);
 
 #ifdef TCL_COMPILE_STATS
Index: generic/tclStubInit.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclStubInit.c,v
retrieving revision 1.78
diff -u -r1.78 tclStubInit.c
--- generic/tclStubInit.c	6 Dec 2002 23:22:59 -0000	1.78
+++ generic/tclStubInit.c	17 Feb 2003 13:41:05 -0000
@@ -901,6 +901,17 @@
     Tcl_Seek, /* 491 */
     Tcl_Tell, /* 492 */
     Tcl_ChannelWideSeekProc, /* 493 */
+    Tcl_DictObjPut, /* 494 */
+    Tcl_DictObjGet, /* 495 */
+    Tcl_DictObjRemove, /* 496 */
+    Tcl_DictObjSize, /* 497 */
+    Tcl_DictObjFirst, /* 498 */
+    Tcl_DictObjNext, /* 499 */
+    Tcl_DictObjDone, /* 500 */
+    Tcl_DictObjPutKeyList, /* 501 */
+    Tcl_DictObjRemoveKeyList, /* 502 */
+    Tcl_NewDictObj, /* 503 */
+    Tcl_DbNewDictObj, /* 504 */
 };
 
 /* !END!: Do not edit above this line. */
Index: unix/Makefile.in
===================================================================
RCS file: /cvsroot/tcl/tcl/unix/Makefile.in,v
retrieving revision 1.121
diff -u -r1.121 Makefile.in
--- unix/Makefile.in	28 Jan 2003 11:03:52 -0000	1.121
+++ unix/Makefile.in	17 Feb 2003 13:41:06 -0000
@@ -306,7 +306,7 @@
 GENERIC_OBJS = regcomp.o regexec.o regfree.o regerror.o tclAlloc.o \
 	tclAsync.o tclBasic.o tclBinary.o \
 	tclCkalloc.o tclClock.o tclCmdAH.o tclCmdIL.o tclCmdMZ.o \
-	tclCompCmds.o tclCompExpr.o tclCompile.o tclDate.o tclEncoding.o \
+	tclCompCmds.o tclCompExpr.o tclCompile.o tclDate.o tclDictObj.o tclEncoding.o \
 	tclEnv.o tclEvent.o tclExecute.o tclFCmd.o tclFileName.o tclGet.o \
 	tclHash.o tclHistory.o tclIndexObj.o tclInterp.o tclIO.o tclIOCmd.o \
 	tclIOGT.o tclIOSock.o tclIOUtil.o tclLink.o tclListObj.o \
@@ -355,6 +355,7 @@
 	$(GENERIC_DIR)/tclCompExpr.c \
 	$(GENERIC_DIR)/tclCompile.c \
 	$(GENERIC_DIR)/tclDate.c \
+	$(GENERIC_DIR)/tclDictObj.c \
 	$(GENERIC_DIR)/tclEncoding.c \
 	$(GENERIC_DIR)/tclEnv.c \
 	$(GENERIC_DIR)/tclEvent.c \
@@ -834,6 +835,9 @@
 
 tclCompile.o: $(GENERIC_DIR)/tclCompile.c
 	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclCompile.c
+
+tclDictObj.o: $(GENERIC_DIR)/tclDictObj.c
+	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclDictObj.c
 
 tclEncoding.o: $(GENERIC_DIR)/tclEncoding.c
 	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclEncoding.c