rev 408 - in trunk: include/prothon pr src

SVN User <[email protected]> Sat, 24 Apr 2004 16:01:44 -0400
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: mark
Date: 2004-04-24 16:01:41 -0400 (Sat, 24 Apr 2004)
New Revision: 408

Modified:
   trunk/include/prothon/prothon.h
   trunk/pr/prosist.pr
   trunk/src/builtins-core.c
   trunk/src/object.c
Log:
Changed set_proto() to work on immuatable objects

Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h	2004-04-24 06:28:48 UTC (rev 407)
+++ trunk/include/prothon/prothon.h	2004-04-24 20:01:41 UTC (rev 408)
@@ -1059,6 +1059,7 @@
 // is set.  This bit is set for many common data types such as Int, String, Etc.
 void set_immutable(obj_p obj);		
 void clr_immutable(obj_p obj);
+int   is_immutable(obj_p obj);
 
 //************************** UNCLONABLE BIT ***********************************
 // Each object has a bit called unclonable.  This bit tells the interpreter

Modified: trunk/pr/prosist.pr
===================================================================
--- trunk/pr/prosist.pr	2004-04-24 06:28:48 UTC (rev 407)
+++ trunk/pr/prosist.pr	2004-04-24 20:01:41 UTC (rev 408)
@@ -4,22 +4,11 @@
 
 import Prosist
 
-/*
-print
+a = {1:2}
 
-a = {1:(2,)}
 db = Prosist('test.pdb', root=a, mode=Prosist.RWTRUNCATE)
-db.close()
 
-print
-
-db = Prosist('test.pdb')
-print db.root
-db.close()
-
-*/
-
-#/*
+/*
 b = 7.3
 
 c = "hello"
@@ -32,8 +21,8 @@
 
 g = Object()
 g.a = 1
-g.b = 2
-g.c = 3
+g.b = '2'
+g.c = {'3':{4:'5'}}
 
 a = {1:b, 2:c, 3:[d,e], (4,5): f, 6:g}
 
@@ -54,4 +43,4 @@
 print
 print x, x[6].a , x[6].b , x[6].c 
 
-#*/
\ No newline at end of file
+*/
\ No newline at end of file

Modified: trunk/src/builtins-core.c
===================================================================
--- trunk/src/builtins-core.c	2004-04-24 06:28:48 UTC (rev 407)
+++ trunk/src/builtins-core.c	2004-04-24 20:01:41 UTC (rev 408)
@@ -1,4 +1,4 @@
-/* ====================================================================
+/*====================================================================
  * The Prothon License Agreement, Version 1.1
  *
  * Copyright (c) 2004 Hahn Creative Applications, http://hahnca.com.
@@ -130,8 +130,12 @@
 }
 
 DEF(Object, setProto, FORM_RPARAM) {
+	int m;
 	read_unlock(ist, self);
+	if(m = is_immutable(self))
+		clr_immutable(self);
 	switch_proto(ist, self, parms[1]);
+	if (m) set_immutable(self);
 	read_lock(ist, self);
 	return NULL;
 }

Modified: trunk/src/object.c
===================================================================
--- trunk/src/object.c	2004-04-24 06:28:48 UTC (rev 407)
+++ trunk/src/object.c	2004-04-24 20:01:41 UTC (rev 408)
@@ -306,6 +306,15 @@
 	free_wrlock(obj);
 }
 
+//********************************* is_immutable ******************************
+int is_immutable(obj_p obj) {
+	int res;
+	get_wrlock(obj, NO_WAIT);
+	res = obj->immutable;
+	free_wrlock(obj);
+	return res;
+}
+
 //********************************* set_unclonable ****************************
 void set_unclonable(obj_p obj){
 	get_wrlock(obj, NO_WAIT);