rev 418 - in trunk: modules/Prosist pr src

SVN User <[email protected]> Mon, 26 Apr 2004 01:54:10 -0400
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: mark
Date: 2004-04-26 01:54:07 -0400 (Mon, 26 Apr 2004)
New Revision: 418

Modified:
   trunk/modules/Prosist/Prosist.c
   trunk/pr/prosist.pr
   trunk/src/builtins-string.c
   trunk/src/object.c
Log:
all of prosist almost working, but strange intermittent bugs happen, like int ends up with string as proto, 
ans string ends up with itself as proto

Modified: trunk/modules/Prosist/Prosist.c
===================================================================
--- trunk/modules/Prosist/Prosist.c	2004-04-26 04:23:13 UTC (rev 417)
+++ trunk/modules/Prosist/Prosist.c	2004-04-26 05:54:07 UTC (rev 418)
@@ -482,12 +482,13 @@
 			return;
 		}
 		if (obj != proxy_obj) {
+			if (obj->has_attrs && obj->attr_proto.attrs)
+				pr_free(obj->attr_proto.attrs);
 			if (obj->data_type == DATA_TYPE_DATAPTR && obj->data.ptr) {
 				pr_free(obj->data.ptr);
 			}
-			copy_object_data(ist, obj, proxy_obj);
+			memcpy(obj, res, sizeof(*obj)-sizeof(obj->next_obj));
 		}
-		proxy_obj = obj;
 	}
 	if (!proxy_obj) {
 		proxy_obj = call_func0(ist, obj, SYM(__TOSTORPROXY__));

Modified: trunk/pr/prosist.pr
===================================================================
--- trunk/pr/prosist.pr	2004-04-26 04:23:13 UTC (rev 417)
+++ trunk/pr/prosist.pr	2004-04-26 05:54:07 UTC (rev 418)
@@ -6,7 +6,7 @@
 
 b = 7.3
 
-c = "hello"
+c = "hello, my name is imalongstring"
 
 d = ('i', 'am', 'a', 'tuple')
 
@@ -22,16 +22,31 @@
 a = {1:b, 2:c, 3:[d,e], (4,5): f, 6:g}
 
 db = Prosist('test.pdb', root=a, mode=Prosist.RWTRUNCATE)
+/*
+a[1] = 999
+a[1] = b
+g.b = [11,22]
 
+a[(4,5)] = {'i':'am', 'a':'different', 'dict':'!'}
+a[2] = "yoohoo, I'm a long string"
+
+db.rollBack()
+
+print
+print a, a[6].a , a[6].b , a[6].c 
+
 a[1] = 999
 a[1] = b
-g.b = []
+g.b = [11,22]
 
 a[(4,5)] = {'i':'am', 'a':'different', 'dict':'!'}
 a[2] = 'yoohoo'
 
 db.commit()
 
+print
+print a, a[6].a , a[6].b , a[6].c 
+*/
 db.close()
 db = Prosist('test.pdb')
 x = db.root

Modified: trunk/src/builtins-string.c
===================================================================
--- trunk/src/builtins-string.c	2004-04-26 04:23:13 UTC (rev 417)
+++ trunk/src/builtins-string.c	2004-04-26 05:54:07 UTC (rev 418)
@@ -436,6 +436,8 @@
 
 	MODULE_SUB_INIT(StringGen);
 	MODULE_ADD_SYM(StringGen, next);
+	
+	set_immutable(String_OBJ);
 
 	check_exceptions(ist);
 }

Modified: trunk/src/object.c
===================================================================
--- trunk/src/object.c	2004-04-26 04:23:13 UTC (rev 417)
+++ trunk/src/object.c	2004-04-26 05:54:07 UTC (rev 418)
@@ -265,15 +265,13 @@
 //********************************* copy_object_data **************************
 // clobbers data section of dest (copy) object
 void copy_object_data(isp ist, obj_p copy, obj_p obj) {
+	int wrlock_req_cnt;
 	attr_p new_attrp, attrp;
-	rdlock_rtrn(obj);
-	if_wrlock(copy) { read_unlock(ist, obj); return; }
+	wrlock_rtrn(obj);
+	if_wrlock(copy) { write_unlock(ist, obj); return; }
+	wrlock_req_cnt = copy->wrlock_req_cnt;
 	memcpy(copy, obj, sizeof(*obj)-sizeof(obj->next_obj));
-	copy->archived       = FALSE;
-	copy->del_locked     = TRUE;
-	copy->rdlock_cnt     = 0;
-	copy->wrlock_req_cnt = 0;
-	copy->wrlock		  = 0;
+	copy->wrlock_req_cnt = wrlock_req_cnt;
 	if (obj->has_attrs) {
 		size_t size;
 		attrp = obj->attr_proto.attrs;
@@ -282,7 +280,7 @@
 		memcpy(new_attrp, attrp, size);
 	}
 	write_unlock(ist, copy);
-	read_unlock(ist, obj);
+	write_unlock(ist, obj);
 }
 
 //********************************* copy_object ******************************
@@ -821,6 +819,10 @@
 		if ((len = proto_len(ist, obj)) == 1) {
 			proto = proto_item(ist, obj, 0);
 			read_unlock(ist, obj);
+			if (obj == proto) {
+				raise_exception(ist, OBJ(INTERNAL_EXC), "only prototype is self");
+				return NULL;
+			}
 			obj = proto;
 			continue;
 		}