rev 701 - in trunk: bin include/prothon src

SVN User <[email protected]> Sun, 04 Jul 2004 19:40:30 -0400
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: mark
Date: 2004-07-04 19:40:27 -0400 (Sun, 04 Jul 2004)
New Revision: 701

Modified:
   trunk/bin/rel.bat
   trunk/include/prothon/prothon.h
   trunk/src/builtins-bytes.c
   trunk/src/builtins-core.c
   trunk/src/builtins-file.c
   trunk/src/builtins-int.c
   trunk/src/symbol.c
Log:
fixed Bytes constructor bug that chopped four bytes off end, added ability to compare Int to String of length 1, added Bytes.pr, made ord() and chr() global built-ins

Modified: trunk/bin/rel.bat
===================================================================
--- trunk/bin/rel.bat	2004-07-04 20:31:33 UTC (rev 700)
+++ trunk/bin/rel.bat	2004-07-04 23:40:27 UTC (rev 701)
@@ -1,9 +1,13 @@
 cd \prothon
 
 del /F /S /Q win32\Prothon\pr\test\*.*
+del /F /S /Q win32\Prothon\pr\pretest\*.*
 rmdir win32\Prothon\pr\test
-del /F /S /Q win32\Prothon\pr\tutorial\*.*
-rmdir win32\Prothon\pr\tutorial
+rmdir win32\Prothon\pr\pretest
+
+rem del /F /S /Q win32\Prothon\pr\tutorial\*.*
+rem rmdir win32\Prothon\pr\tutorial
+
 del /F /S /Q win32\Prothon\pr\*.*
 rmdir win32\Prothon\pr
 del /F /S /Q win32\Prothon\*.*
@@ -11,8 +15,10 @@
 del /F /S /Q win32\*.*
 rmdir win32
 mkdir win32\Prothon\pr\test
-mkdir win32\Prothon\pr\tutorial
+mkdir win32\Prothon\pr\pretest
 
+rem mkdir win32\Prothon\pr\tutorial
+
 copy src\release\prothon.exe 					win32\Prothon
 
 copy modules\DBM\release\DBM.dll 				win32\Prothon
@@ -30,5 +36,7 @@
 copy LICENSE	 								win32\Prothon\LICENSE.txt
 
 copy pr\test\*.pr 								win32\Prothon\pr\test
-copy pr\tutorial\*.pr 							win32\Prothon\pr\tutorial
+copy pr\pretest\*.pr 							win32\Prothon\pr\pretest
 
+rem copy pr\tutorial\*.pr 						win32\Prothon\pr\tutorial
+
Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h	2004-07-04 20:31:33 UTC (rev 700)
+++ trunk/include/prothon/prothon.h	2004-07-04 23:40:27 UTC (rev 701)
@@ -246,7 +246,7 @@
 } obj_t;
 
 typedef struct {
-	data_size_t	len;
+	data_size_t	size;
 	u8_t		byt[];
 } byt_t;
 
@@ -473,6 +473,8 @@
 	LEN_,
 	MAX,
 	MIN,
+	ORD_,
+	CHR_,
 	COPY,
 	TOSTORPROXY_,
 	FROMSTORPROXY_,

Modified: trunk/src/builtins-bytes.c
===================================================================
--- trunk/src/builtins-bytes.c	2004-07-04 20:31:33 UTC (rev 700)
+++ trunk/src/builtins-bytes.c	2004-07-04 23:40:27 UTC (rev 701)
@@ -77,7 +77,7 @@
 			memcpy(obj->data.bytes, byt, len);
 	} else {
 		obj_byt = obj_malloc(ist, OBJ(BYTES_PROTO), obj, sizeof(byt_t)+len); if_exc_return NULL;
-		obj_byt->len = (data_size_t) len;
+		obj_byt->size = (data_size_t) (sizeof(byt_t)+len);
 		memcpy(&(obj_byt->byt[0]), byt, len);
 	}
 	obj->immutable = TRUE;
@@ -93,7 +93,7 @@
 		memcpy(obj->data.bytes, byt, len);
 	} else {
 		obj_byt = obj_malloc(ist, OBJ(BYTES_PROTO), obj, sizeof(byt_t)+len); if_exc_return;
-		obj_byt->len = (data_size_t) len;
+		obj_byt->size = (data_size_t) sizeof(byt_t)+len;
 		memcpy(&(obj_byt->byt[0]), byt, len);
 	}
 	obj->immutable = TRUE;
@@ -151,7 +151,7 @@
 			buf = self->data.bytes;
 		} else {
 			obj_byt = obj_malloc(ist, OBJ(BYTES_PROTO), self, sizeof(byt_t)+len); if_exc_return NULL;
-			obj_byt->len = (data_size_t) len;
+			obj_byt->size = (data_size_t) (sizeof(byt_t)+len);
 			buf = &(obj_byt->byt[0]);
 		}
 		pr_str2bytes(ist, buf, parms[1], latin);
@@ -167,7 +167,7 @@
 			bufp = self->data.bytes;
 		} else {
 			obj_byt = obj_malloc(ist, OBJ(BYTES_PROTO), self, sizeof(byt_t)+len); if_exc_return NULL;
-			obj_byt->len = (data_size_t) len;
+			obj_byt->size = (data_size_t) (sizeof(byt_t)+len);
 			bufp = &(obj_byt->byt[0]);
 		}
 		for(i=0; i < len; i++) {
Modified: trunk/src/builtins-core.c
===================================================================
--- trunk/src/builtins-core.c	2004-07-04 20:31:33 UTC (rev 700)
+++ trunk/src/builtins-core.c	2004-07-04 23:40:27 UTC (rev 701)
@@ -213,6 +213,14 @@
 	return call_func0(ist, parms[1], SYM(MIN));
 }
 
+DEF(Object, ord, FORM_RPARAM) {
+	return call_func0(ist, parms[1], SYM(ORD_));
+}
+
+DEF(Object, chr, FORM_RPARAM) {
+	return call_func0(ist, parms[1], SYM(CHR_));
+}
+
 DEF(Object, setReadAccess, FORM_RPARAM) {
 	CHECK_TYPE_EXC(parms[1], OBJ(INT_PROTO), "integer");
 	if (ist->access < get_obj_wracc(self)) {
@@ -1259,6 +1267,8 @@
 	MODULE_ADD_SYM(Object, len);
 	MODULE_ADD_SYM(Object, Max);
 	MODULE_ADD_SYM(Object, Min);
+	MODULE_ADD_SYM(Object, ord);
+	MODULE_ADD_SYM(Object, chr);
 	MODULE_ADD_SYM(Object, getItem_);
 	MODULE_ADD_SYM(Object, setItem_);
 	MODULE_ADD_SYM(Object, delItem_);

Modified: trunk/src/builtins-file.c
===================================================================
--- trunk/src/builtins-file.c	2004-07-04 20:31:33 UTC (rev 700)
+++ trunk/src/builtins-file.c	2004-07-04 23:40:27 UTC (rev 701)
@@ -1060,7 +1060,7 @@
 		byt_obj->imm_data_len = (int) total_read;
 	else {
 		obj_str = obj_realloc(ist, byt_obj, sizeof(str_t)+total_read+1);
-		obj_str->len = (data_size_t) total_read;
+		obj_str->size = (data_size_t) (sizeof(str_t)+total_read);
 		buf = obj_str->byt;
 	}
 	buf[total_read] = 0;
Modified: trunk/src/builtins-int.c
===================================================================
--- trunk/src/builtins-int.c	2004-07-04 20:31:33 UTC (rev 700)
+++ trunk/src/builtins-int.c	2004-07-04 23:40:27 UTC (rev 701)
@@ -2529,6 +2529,11 @@
 DEF(Int, eq__QUES, FORM_RPARAM){
 	obj_p other = parms[1];
 	BIN_CONTENT_CHK(Int);
+	if (has_proto(ist, other, OBJ(STRING_PROTO)) && pr_strlen(other) == 1) {
+		char* s = pr2c_strptr(ist, parms[1]); if_exc_return NULL;
+		other = NEW_INT(s[0]);
+		pr_free(s);
+	}
 	if (!is_Int(other)) {
 		int c = covers(other, self);
 		if (catch_exception(ist, OBJ(FUNCNOTFOUND_EXC), NULL)) 

Modified: trunk/src/symbol.c
===================================================================
--- trunk/src/symbol.c	2004-07-04 20:31:33 UTC (rev 700)
+++ trunk/src/symbol.c	2004-07-04 23:40:27 UTC (rev 701)
@@ -145,6 +145,8 @@
 	{ "len_",			0 },
 	{ "max",			0 },
 	{ "min",			0 },
+	{ "ord_",			0 },
+	{ "chr_",			0 },
 	{ "copy",			0 },
 	{ "toStorProxy_",	0 },
 	{ "fromStorProxy_", 0},