rev 243 - trunk/src

SVN User <[email protected]>
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: bcollins
Date: 2004-03-31 20:00:43 -0500 (Wed, 31 Mar 2004)
New Revision: 243

Modified:
   trunk/src/builtins.c
Log:
Redo DictGen so that it iterates keys, like python.


Modified: trunk/src/builtins.c
===================================================================
--- trunk/src/builtins.c	2004-03-31 23:20:12 UTC (rev 242)
+++ trunk/src/builtins.c	2004-04-01 01:00:43 UTC (rev 243)
@@ -1295,7 +1295,7 @@
 	obj_p list_obj, gen_obj = new_object(DictGen_OBJ);
 
 	gen_obj->data_type = OBJ_TYPE_DATAPTR;
-	gen_obj->data.ptr = list_obj = dict_keys_values(ist, self, 2);
+	gen_obj->data.ptr = list_obj = dict_keys(ist, self);
 
 	listlen(list_obj) = 0;
 	return gen_obj;
@@ -1310,23 +1310,17 @@
 
 DEF(DictGen, next, NULL) {
 	obj_p res, list_obj = self->data.ptr;
-	size_t lsiz, llen;
 
 	CHECK_TYPE_EXC(self, DictGen_OBJ, "DictGen");
 	CHECK_TYPE_EXC(list_obj, OBJ(SEQ_PROTO), "list");
 
-	lsiz = listsize(list_obj);
-	llen = listlen(list_obj);
-
-	if (llen == lsiz) {
+	if (listsize(list_obj) == listlen(list_obj)) {
 		raise_exception(ist, OBJ(STOP_ITERATION_EXC), NULL);
 		return NULL;
 	}
 
-	res = new_list_obj(2);
-	list_append(ist, res, list_item(ist, list_obj, llen));
-	list_append(ist, res, list_item(ist, list_obj, llen + 1));
-	listlen(list_obj) += 2;
+	res = listitem(list_obj, listlen(list_obj));
+	listlen(list_obj)++;
 
 	return res;
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.