rev 716 - in trunk: . include/prothon src

SVN User <[email protected]> Thu, 08 Jul 2004 01:05:17 -0400
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: mark
Date: 2004-07-08 01:05:13 -0400 (Thu, 08 Jul 2004)
New Revision: 716

Modified:
   trunk/STATUS.txt
   trunk/include/prothon/prothon.h
   trunk/src/builtins-core.c
   trunk/src/builtins-string.c
   trunk/src/init.pth
Log:
added Object.dbgPrt()

Modified: trunk/STATUS.txt
===================================================================
--- trunk/STATUS.txt	2004-07-07 07:13:35 UTC (rev 715)
+++ trunk/STATUS.txt	2004-07-08 05:05:13 UTC (rev 716)
@@ -1,6 +1,12 @@
 
 ----------------------- TO-DO (highest priority first) ------------------------
 
+--- dbgPrt
+
+--- File & Dir properites?
+
+--- Make Dir.size() recursive
+
 --- "import as" broken
 
 --- camelcase errors: execpath, fparams, bufsize
@@ -10,27 +16,6 @@
 
 --- getAttr(name), setAttr(name, value), delAttr(name)
 
---- thread keyword for param improvement?
---- OSThread, Thread, and Gate
-		http://www.prothon.org/pipermail/prothon-user/2004-June/002124.html
---- lock keyword?
-
---- call_ str_ fix?
-		http://www.prothon.org/pipermail/prothon-user/2004-June/002442.html
-		http://www.prothon.org/pipermail/prothon-user/2004-June/002444.html
---- class keyword
-		http://www.prothon.org/pipermail/prothon-user/2004-June/002445.html
---- type keyword?  interfaces?
-		http://www.prothon.org/pipermail/prothon-user/2004-June/002508.html
-	
---- assignment as expression ???
-		http://www.prothon.org/pipermail/prothon-user/2004-June/002160.html
-		
---- implement from Module import * ???
-
---- implement 1xc3fe ?
---- implement taint attribute on strings, unTaint() method, respect in .fmt, eval, exec
-
 --- Module doc strings & Object doc strings
 
 --- unicode module - codecs
@@ -45,14 +30,9 @@
 --- add Object.data_ (builtins-databytes.c)
 --- Bytes methods?  copy struct module?
 
---- raise exception_object, doc_object
 --- allow tracebacks in the constructors to exception objects or raise command
 --- Traceback objects (stack trace of an exception), exceptions should show function names
 --- hide fake file names
-
---- metaclasses not supported ???
-		http://www.prothon.org/pipermail/prothon-user/2004-June/002409.html
-		http://www.prothon.org/pipermail/prothon-user/2004-June/002480.html
 		
 --- put in skeleton code for + _"abc"
 --- GNU message catalog _"abc" strings
@@ -72,47 +52,23 @@
 
 --- support long ints & Bytes in dbm & prosist
 
---- Swig, Boost, Pyrex and/or other (what GTK port used?) backend
-
 --- concatenate adjacent strings  "abc" "def" -> "abcdef"
 
 --- allow strings to compare with symbols
 
 --- Auto-documenter app
---- add static checking like interfaces to doc tool
 
---- networking code -- web access demonstration of security
 --- security flaw - modules can access each other by name
 
 --- name_ and file_ (always absolute paths)
 
 --- nesting  /* .. */ comments 
 
---- -m -l cmd-line options missing
---- memory bounds -> mem-mgr priorities
+----------------------- TUTORIAL TO-DO ------------------------
 
---- plug memory leaks -- add del_unlocks
-
---- switch mro method to C3
-
---- C API for profiling
-
 --- credit Ruby
 
---- Does simple 1+2 expr evaluation create objects?  If so, need shortcuts to speed it up
-
---- clean up prt_code_line mess with some cleaner coding technique
-
---- reduce array of act params passed to function to only odd entries
-
---- thread monitor function
-
---- improve torture with list and dict tortures, random walk against new end
-
------------------------ TUTORIAL TO-DO ------------------------
-
 	everything in changes.txt
-	super
 	Inheriting from binary objects, uninitialized objects
 	security system
 	console line editing
@@ -132,33 +88,15 @@
 --- apt-get
 		http://www.prothon.org/pipermail/prothon-user/2004-June/002450.html
 
---- wiki
-		http://www.prothon.org/pipermail/prothon-user/2004-June/002431.html
-		http://www.prothon.org/pipermail/prothon-user/2004-June/002443.html
-
------------------------- OPTIMIZATION TO_DO -----------------------------------
-
---- Lazy string concatenation
---- Improve garbage collector cache behavior
---- combine pr_malloc/garbage collector, remove obj_t linked list
-		http://www.cs.kent.ac.uk/people/staff/rej/gc.html#Book
-		http://www.prothon.org/pipermail/prothon-user/2004-June/002534.html
-
 ---------------- Ideas to consider for inclusion ------------------------------
 
-Psyco in std interpreter?
 
 multiple modules per file?
 
-add function version of print (write)
-
 sets and other zephyr email items 
 
 remove \ continuation ?
 
-Python add-on C module adapter for Prothon
-auto python -> prothon source converter
-
 add/replace int and float single decimal type with bounded precision and floating point. 
 				http://www.python.org/peps/pep-0327.html
 
@@ -189,16 +127,53 @@
 	need differentiate to __int__ which
 		truncates and __int__ which doesn't
 
+------------------------------ next phase ?---------------------------------------
 
+Psyco in std interpreter?
 
------------------------------- speedups ---------------------------------------
+--- networking code -- web access demonstration of security
 
+--- add static checking like interfaces to doc tool
+
+--- Swig, Boost, Pyrex and/or other (what GTK port used?) backend
+
+--- NEW GARBAGE COLLECTOR
+--- -m -l cmd-line options missing
+--- memory bounds -> mem-mgr priorities
+--- plug memory leaks -- add del_unlocks
+--- improve torture with list and dict tortures, random walk against new end
+
+--- switch mro method to C3
+
+--- C API for profiling
+
+--- Does simple 1+2 expr evaluation create objects?  If so, need shortcuts to speed it up
+
+--- clean up prt_code_line mess with some cleaner coding technique
+
+--- reduce array of act params passed to function to only odd entries
+
+--- thread monitor function
+
+Python add-on C module adapter for Prothon
+auto python -> prothon source converter
+
+
+--- Lazy string concatenation
+--- Improve garbage collector cache behavior
+--- combine pr_malloc/garbage collector, remove obj_t linked list
+		http://www.cs.kent.ac.uk/people/staff/rej/gc.html#Book
+		http://www.prothon.org/pipermail/prothon-user/2004-June/002534.html
+
+
 Inline asm for lock code up to wrlock acquire and access check
 
 Global prototype lookup cache
 
 Copy garbage collection good for small objects
 
+Make Prothon embeddable?
+
 ------------------------------ bugs -------------------------------------------
 parser
 	bison warnings

Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h	2004-07-07 07:13:35 UTC (rev 715)
+++ trunk/include/prothon/prothon.h	2004-07-08 05:05:13 UTC (rev 716)
@@ -718,7 +718,7 @@
 
 // SET_STRING_DATA: Change an existing object's data to string data
 // clobbers any esisting data pointer
-void c2pr_strcpy(isp ist, obj_p obj, char* p, data_size_t len);
+void c2pr_strcpy(isp ist, obj_p obj, char* p, size_t len);
 
 // PR_STRPTR: retreive string object as a C string
 char* pr2c_strptr(isp ist, obj_p str_obj);

Modified: trunk/src/builtins-core.c
===================================================================
--- trunk/src/builtins-core.c	2004-07-07 07:13:35 UTC (rev 715)
+++ trunk/src/builtins-core.c	2004-07-08 05:05:13 UTC (rev 716)
@@ -88,6 +88,50 @@
 
 // ***************************** Object *********************************
 
+obj_p print_method(isp ist, obj_p* parms, int return_flag) {
+	obj_p arg_list = parms[1];
+	obj_p arg_dict = parms[3];
+	int i, llen = (int) list_len(ist, arg_list);
+	char *sep, *eol, *str;
+	obj_p res, sep_obj, eol_obj;
+	sep_obj = dict_item(ist, arg_dict, sym(ist, "sep")); if_exc_return NULL;
+	if (sep_obj) {
+		CHECK_TYPE_EXC(sep_obj, OBJ(STRING_PROTO), String);
+		sep = pr2c_strptr(ist, sep_obj); 
+	} else 
+		sep = " ";
+	eol_obj = dict_item(ist, arg_dict, sym(ist, "eol")); if_exc_return NULL;
+	if (eol_obj) {
+		CHECK_TYPE_EXC(eol_obj, OBJ(STRING_PROTO), String);
+		eol = pr2c_strptr(ist, eol_obj); 
+	} else 
+		eol = "\n";
+	str = pr_malloc(strlen(eol)+1);
+	str[0] = 0;
+	for (i=0; i < llen; i++)  {
+		obj_p str_obj, item = list_item(ist, arg_list, i);
+		char* item_str;
+		if (!item) item = OBJ(NONE);
+		str_obj = call_func0(ist, item, SYM(STR_));
+		if_exc_return NULL;
+		item_str = pr2c_strptr(ist, str_obj);
+		str = pr_realloc(str, strlen(str)+strlen(item_str)+strlen(sep)+strlen(eol)+1);
+		strcat(str, item_str);
+		if (i < llen-1) strcat(str, sep);
+		else            strcat(str, eol);
+	}
+	if (llen == 0) strcpy(str, eol);
+	printf("%s", str);
+	if (return_flag) {
+        res = NEW_STRING(str);
+		pr_free(str);
+		return res;
+	} else {
+		pr_free(str);
+		return OBJ(NONE);
+	}
+}
+
 MODULE_START(Object)
 {
 	Object_OBJ = OBJ(OBJECT);
@@ -390,48 +434,12 @@
 	return self;
 }
 
+DEF(Object, dbgPrt, FORM_STAR3_PARAM) {
+	return print_method(ist, parms, TRUE);
+}
+
 DEF(Object, print, FORM_STAR3_PARAM) {
-	obj_p arg_list = parms[1];
-	obj_p arg_dict = parms[3];
-	int i, llen = (int) list_len(ist, arg_list);
-	char *sep, *eol, *str;
-	obj_p sep_obj, eol_obj;
-	sep_obj = dict_item(ist, arg_dict, sym(ist, "sep")); if_exc_return NULL;
-	if (sep_obj) {
-		CHECK_TYPE_EXC(sep_obj, OBJ(STRING_PROTO), String);
-		sep = pr2c_strptr(ist, sep_obj); 
-	} else 
-		sep = " ";
-	eol_obj = dict_item(ist, arg_dict, sym(ist, "eol")); if_exc_return NULL;
-	if (eol_obj) {
-		CHECK_TYPE_EXC(eol_obj, OBJ(STRING_PROTO), String);
-		eol = pr2c_strptr(ist, eol_obj); 
-	} else 
-		eol = "\n";
-	str = pr_malloc(strlen(eol)+1);
-	str[0] = 0;
-	for (i=0; i < llen; i++)  {
-		obj_p str_obj, item = list_item(ist, arg_list, i);
-		char* item_str;
-		if (!item) item = OBJ(NONE);
-		str_obj = call_func0(ist, item, SYM(STR_));
-		if_exc_return NULL;
-		item_str = pr2c_strptr(ist, str_obj);
-		str = pr_realloc(str, strlen(str)+strlen(item_str)+strlen(sep)+strlen(eol)+1);
-		strcat(str, item_str);
-		if (i < llen-1) strcat(str, sep);
-		else            strcat(str, eol);
-	}
-	if (llen == 0) strcpy(str, eol);
-	printf("%s", str);
-	//if (ist->in_console) {
-		pr_free(str);
-		return OBJ(NONE);
-	//} else {
-	//	res = NEW_STRING(str);
-	//	pr_free(str);
-	//	return res;
-	//}
+	return print_method(ist, parms, FALSE);
 }
 
 
@@ -1290,6 +1298,7 @@
 	MODULE_ADD_SYM(Object, range);
 	MODULE_ADD_SYM(Object, toStorProxy_);
 	MODULE_ADD_SYM(Object, fromStorProxy_);
+	MODULE_ADD_SYM(Object, dbgPrt);
 	MODULE_ADD_SYM(Object, print);  MARK_AS_COMMAND;
 
 

Modified: trunk/src/builtins-string.c
===================================================================
--- trunk/src/builtins-string.c	2004-07-07 07:13:35 UTC (rev 715)
+++ trunk/src/builtins-string.c	2004-07-08 05:05:13 UTC (rev 716)
@@ -123,10 +123,10 @@
 }
 
 //********************************* c2pr_strcpy *******************************
-void c2pr_strcpy(isp ist, obj_p obj, char* str, data_size_t len) {
+void c2pr_strcpy(isp ist, obj_p obj, char* str, size_t len) {
 	str_p obj_str;
 	ch3_p ch3p;
-	data_size_t i, size = len*3;
+	data_size_t i, size = (data_size_t) len*3;
 
 	if (size <= IMM_DATA_LEN) {
 		SET_TYPE_IF_EXC(OBJ(STRING_PROTO), obj, DATA_TYPE_IMMDATA) return;

Modified: trunk/src/init.pth
===================================================================
--- trunk/src/init.pth	2004-07-07 07:13:35 UTC (rev 715)
+++ trunk/src/init.pth	2004-07-08 05:05:13 UTC (rev 716)
@@ -11,6 +11,8 @@
 c:\prothon\modules\OS\debug
 c:\prothon\modules\DBM\debug
 
+c:\prothon\pr
+
 # this is executed before Main as module PthMod1
 
 #import re