rev 203 - in trunk: modules/Dict src

SVN User <[email protected]>
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: mark
Date: 2004-03-29 23:53:09 -0500 (Mon, 29 Mar 2004)
New Revision: 203

Modified:
   trunk/modules/Dict/Dict.c
   trunk/src/builtins.c
   trunk/src/object.c
   trunk/src/object.h
Log:
added Object.attrs()

Modified: trunk/modules/Dict/Dict.c
===================================================================
--- trunk/modules/Dict/Dict.c	2004-03-30 04:06:07 UTC (rev 202)
+++ trunk/modules/Dict/Dict.c	2004-03-30 04:53:09 UTC (rev 203)
@@ -58,5 +58,6 @@
 
 #define DICT_PROTO_OBJ   OBJ(DICT_PROTO)
 
+
 install_module(Dict){
 }

Modified: trunk/src/builtins.c
===================================================================
--- trunk/src/builtins.c	2004-03-30 04:06:07 UTC (rev 202)
+++ trunk/src/builtins.c	2004-03-30 04:53:09 UTC (rev 203)
@@ -200,6 +200,25 @@
 	return call_func1(ist, parms[1], SYM(__RNOTIN__), self);
 }
 
+DEF(OBJECT_OBJ, attrs, NULL) { 
+	int i;
+	size_t alen, asize;
+	attr_p attrp;
+	obj_p dict_obj;
+	if (!self->has_attrs) return new_dict_obj(0);
+	attrp = self->attr_proto.attrs;
+	asize = attr_asize(attrp);
+	alen  = attr_alen(attrp);
+	dict_obj = new_dict_obj((int)alen);
+	for (i=0; i < (int) asize; i++) {
+		if (attr_ap(attrp,i)->attr.key > 0)
+			dict_add( ist, dict_obj, 
+					  new_string_obj(keych(ist, attr_ap(attrp,i)->attr.key)), 
+			          attr_ap(attrp,i)->attr.value );
+	}
+	return dict_obj;
+}
+
 // ***************************** PR_FALSE *****************************************
 #define PR_FALSE_OBJ    OBJ(PR_FALSE)
 DEF(PR_FALSE_OBJ, __str__,  NULL) { return new_string_obj("False"); }
@@ -1052,6 +1071,7 @@
 	CALL_INIT(OBJECT_OBJ, __ge__);
 	CALL_INIT(OBJECT_OBJ, __in__);
 	CALL_INIT(OBJECT_OBJ, __notin__);
+	CALL_INIT(OBJECT_OBJ, attrs);
 
 	CALL_INIT(PR_FALSE_OBJ, __str__);
 	CALL_INIT(PR_FALSE_OBJ, __bool__);

Modified: trunk/src/object.c
===================================================================
--- trunk/src/object.c	2004-03-30 04:06:07 UTC (rev 202)
+++ trunk/src/object.c	2004-03-30 04:53:09 UTC (rev 203)
@@ -1232,7 +1232,9 @@
 	dump_obj(ist, obj, 0);
 	fclose(fout);
 }
-char* keych(isp ist, attr_key_t key){
+
+//********************************* keych *************************************
+char* keych(isp ist, attr_key_t key) {
 	int i, len;
 	char* res;
 	read_lock(ist, OBJ(SYMBOLS));

Modified: trunk/src/object.h
===================================================================
--- trunk/src/object.h	2004-03-30 04:06:07 UTC (rev 202)
+++ trunk/src/object.h	2004-03-30 04:53:09 UTC (rev 203)
@@ -167,6 +167,8 @@
 
 char* numonly(char* s, char* buf);
 
+char* keych(isp ist, attr_key_t key);
+
 void dump(isp ist, char* dumpfilename, obj_p obj);
 void dump_obj(isp ist, obj_p obj, int dep);
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.