rev 345 - in trunk: . include/prothon modules/SQLite pr src
SVN User <[email protected]>
| Newsgroups | gmane.comp.lang.prothon.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: mark
Date: 2004-04-14 02:33:28 -0400 (Wed, 14 Apr 2004)
New Revision: 345
Added:
trunk/pr/sqlite.pr
Modified:
trunk/STATUS.txt
trunk/include/prothon/prothon.h
trunk/modules/SQLite/SQLite.c
trunk/src/interp.c
trunk/src/memory_mgr.c
trunk/src/parser_routines.c
trunk/src/src.vcproj
Log:
added sqlite.pr test
Modified: trunk/STATUS.txt
===================================================================
--- trunk/STATUS.txt 2004-04-14 04:18:21 UTC (rev 344)
+++ trunk/STATUS.txt 2004-04-14 06:33:28 UTC (rev 345)
@@ -3,10 +3,8 @@
--- change all varnames to var_names
---- add list comprehension
+--- add list comprehension, list.sort!(), string %
---- flesh out dlls, list.sort!(), dict stuff, string %
-
--- add support for APR_BINARY in File.c ('b' flag)
--- support any object that supports file methods in stdxxx (duck std)
@@ -79,9 +77,6 @@
Syntax extension modifier -- language spec?
-make := work like = but usable as an expr
- looks like a no-go
-
Point = proto(base1, base2):
func = def(arg1, arg2):
@@ -94,12 +89,10 @@
sets and other zephyr email items -- use <> ?
-
remove \ continuation ?
--- make print a function ?
-
------------------------------ speedups ---------------------------------------
Inline asm for lock code up to wrlock acquire and access check
Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h 2004-04-14 04:18:21 UTC (rev 344)
+++ trunk/include/prothon/prothon.h 2004-04-14 06:33:28 UTC (rev 345)
@@ -60,8 +60,8 @@
//#define DEBUG_THREADS
//#define DEBUG_MEM_MGR
//#define TRACE_PARSER
-//#define DUMP_MODULE_CODE
-//#define TRACE_INTERPRETER
+#define DUMP_MODULE_CODE
+#define TRACE_INTERPRETER
//#define DUMP_OBJECTS_AT_END
//*****************************************************************************
Modified: trunk/modules/SQLite/SQLite.c
===================================================================
--- trunk/modules/SQLite/SQLite.c 2004-04-14 04:18:21 UTC (rev 344)
+++ trunk/modules/SQLite/SQLite.c 2004-04-14 06:33:28 UTC (rev 345)
@@ -128,7 +128,8 @@
cursorp = curs_obj->data.ptr = pr_malloc(sizeof(cursor_t));
cursorp->ist = ist;
cursorp->conn_obj = self;
- cursorp->row_list = NULL;
+ cursorp->row_list = new_list_obj(ist, INITIAL_ROW_LIST_SIZE);
+ del_unlock(cursorp->row_list);
return curs_obj;
} else {
raise_exception(ist, Error_OBJ, "connection closed");
@@ -181,7 +182,7 @@
return 0;
}
-DEF(Cursor, execute, list4(ist, sym(ist, "statement"), NULL,
+DEF(Cursor, execute_BANG, list4(ist, sym(ist, "statement"), NULL,
sym(ist, "parameters"), OBJ(NONE) ) ) {
cursor_p cursorp;
sqlite_p db;
@@ -194,8 +195,8 @@
return NULL;
}
cursorp = (cursor_p)(self->data.ptr);
- if (cursorp->row_list) del_unlock(cursorp->row_list);
- cursorp->row_list = new_list_obj(ist, INITIAL_ROW_LIST_SIZE);
+ clr_immutable(cursorp->row_list);
+ list_clear(ist, cursorp->row_list);
db = (sqlite_p)(cursorp->conn_obj->data.ptr);
sqlite_exec(db, sql, xCallback, cursorp, &errmsg);
if (errmsg) {
@@ -267,10 +268,12 @@
}
DEF(Cursor, __objlist__, FORM_RPARAM) {
- return self;
+ cursor_p cursorp = (cursor_p)(self->data.ptr);
+ if (cursorp->row_list)
+ return cursorp->row_list;
+ return parms[1];
}
-
MAIN_MODULE_INIT(SQLite)
{
MODULE_SUB_INIT(SQLite);
@@ -282,7 +285,7 @@
MODULE_ADD_SYM(Connection, close);
MODULE_ADD_SYM(Connection, __objlist__);
- MODULE_ADD_SYM(Cursor, execute);
+ MODULE_ADD_SYM(Cursor, execute_BANG);
MODULE_ADD_SYM(Cursor, fetchone);
MODULE_ADD_SYM(Cursor, fetchmany);
MODULE_ADD_SYM(Cursor, fetchall);
Added: trunk/pr/sqlite.pr
===================================================================
--- trunk/pr/sqlite.pr 2004-04-14 04:18:21 UTC (rev 344)
+++ trunk/pr/sqlite.pr 2004-04-14 06:33:28 UTC (rev 345)
@@ -0,0 +1,72 @@
+#!/usr/bin/env prothon
+
+# sqlite.pr
+
+import SQLite
+
+conn = SQLite.connect('test.db')
+curs = conn.cursor()
+
+try: curs.execute!("drop table tbl1")
+except: print 3
+try: curs.execute!("drop table tbl2")
+except: pass
+
+curs.execute!("create table tbl1 (a INTEGER PRIMARY KEY, b INTEGER, c INTEGER)")
+curs.execute!("create table tbl2 (d INTEGER PRIMARY KEY, a INTEGER, e INTEGER)")
+
+curs.execute!("insert into tbl1 values (1, 10, 100)")
+
+curs.execute!("insert into tbl2 values (1, 1, 101)")
+curs.execute!("insert into tbl2 values (2, 1, 102)")
+curs.execute!("insert into tbl2 values (3, 1, 103)")
+curs.execute!("insert into tbl2 values (4, 1, 104)")
+curs.execute!("insert into tbl2 values (5, 1, 105)")
+curs.execute!("insert into tbl2 values (6, 1, 106)")
+curs.execute!("insert into tbl2 values (7, 1, 107)")
+curs.execute!("insert into tbl2 values (8, 1, 108)")
+curs.execute!("insert into tbl2 values (9, 1, 109)")
+
+curs.execute!("insert into tbl1 values (2, 20, 200)")
+
+curs.execute!("insert into tbl2 values (10, 2, 201)")
+curs.execute!("insert into tbl2 values (11, 2, 202)")
+curs.execute!("insert into tbl2 values (12, 2, 203)")
+curs.execute!("insert into tbl2 values (13, 2, 204)")
+curs.execute!("insert into tbl2 values (14, 2, 205)")
+curs.execute!("insert into tbl2 values (15, 2, 206)")
+curs.execute!("insert into tbl2 values (16, 2, 207)")
+curs.execute!("insert into tbl2 values (17, 2, 208)")
+curs.execute!("insert into tbl2 values (18, 2, 209)")
+
+curs1 = conn.cursor()
+curs2 = conn.cursor()
+
+curs1.execute!("select * from tbl1")
+
+if curs1.rowcount() != 2:
+ print 'curs1.rowcount() error'
+ Sys.exit(1)
+
+rows1 = curs1.fetchall()
+for row in rows1:
+ curs2.execute!('select * from tbl2 where a='+row[0])
+ if curs2.rowcount() != 9:
+ print 'curs2.rowcount() error, rows1:', rows1, 'rowcount:',curs2.rowcount()
+ Sys.exit(1)
+ for i in 4:
+ row2 = curs2.fetchone()
+ if row2[2] != ''+(101+i) and row2[2] != ''+(201+i):
+ print 'row2[2] error'
+ Sys.exit(1)
+ rows2 = curs2.fetchmany(3)
+ if Len(rows2) != 3:
+ print 'Len(rows2) error1, rows2:', rows2
+ Sys.exit(1)
+ rows2 = curs2.fetchmany(3)
+ if Len(rows2) != 2:
+ print 'Len(rows2) error2'
+ Sys.exit(1)
+conn.close()
+
+print '\nall tests passed\n'
Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c 2004-04-14 04:18:21 UTC (rev 344)
+++ trunk/src/interp.c 2004-04-14 06:33:28 UTC (rev 345)
@@ -835,7 +835,7 @@
continue;
}
if (intrp_exobj) break;
- if (exc_obj_label)
+ if (exc_obj_label && exc_obj_label != OBJ(NONE))
set_attr(ist, frame->locals, exc_obj_label, exc_waiting);
exc_waiting = 0;
} break;
@@ -1118,8 +1118,6 @@
fprintf(tfout, "---exception---\n");
fflush(tfout);
#endif
-
- fr_sp = 0;
add_frame_to_exception(ist, frame);
while (!have_exstk && frame->prev_frame && !last_called_from_c) {
frame_p tmp_frame = frame;
Modified: trunk/src/memory_mgr.c
===================================================================
--- trunk/src/memory_mgr.c 2004-04-14 04:18:21 UTC (rev 344)
+++ trunk/src/memory_mgr.c 2004-04-14 06:33:28 UTC (rev 345)
@@ -110,7 +110,7 @@
isp ist = get_ist(ACC_SYSTEM);
obj_p mm_obj_list = new_list_obj(ist, 100);
obj_p mm_obj_act_param[2];
- int last_obj_del_count = 0, last_obj_count = 0;
+ int last_obj_del_count = 0, last_obj_count = 0;
register_thread(ist, handle);
@@ -203,14 +203,12 @@
write_unlock(ist, mm_obj_list);
obj_list = call_func(ist, obj, SYM(__OBJLIST__), 2, mm_obj_act_param, NULL);
if (ist->exception_obj) {
- printf("Warning: memory manager unable to scan object: %lx\n",
+ printf("\nWarning: memory manager unable to scan object: %lx\n",
(unsigned long)(uintptr_t)obj);
-
- printf("Dumping object details to mem-mgr-obj-dump.txt\n");
+ printf("Dumping object details to mm-obj-dump.txt\n");
printf("Aborting Prothon\n");
- dump(ist, "mem-mgr-obj-dump.txt", obj);
+ dump(ist, "mm-obj-dump.txt", obj);
pr_exit(1);
-
printf(" exception: %s\n",
strch(get_attr(ist, ist->exception_obj, SYM(__DOC__))));
ist->exception_obj = 0;
Modified: trunk/src/parser_routines.c
===================================================================
--- trunk/src/parser_routines.c 2004-04-14 04:18:21 UTC (rev 344)
+++ trunk/src/parser_routines.c 2004-04-14 06:33:28 UTC (rev 345)
@@ -1232,7 +1232,10 @@
add_code_to(expr, res, &k);
res->code_data[k ].bytecode.opcode = OP_PUSH;
res->code_data[k++].bytecode.param = 2;
- res->code_data[k++].data = sym(INTRP, label);
+ if (label)
+ res->code_data[k++].data = sym(INTRP, label);
+ else
+ res->code_data[k++].data = OBJ(NONE);
res->code_data[k ].bytecode.opcode = OP_EXCEPT;
res->code_data[k++].bytecode.param = body->len+1;
assert(res->len == k);
Modified: trunk/src/src.vcproj
===================================================================
--- trunk/src/src.vcproj 2004-04-14 04:18:21 UTC (rev 344)
+++ trunk/src/src.vcproj 2004-04-14 06:33:28 UTC (rev 345)
@@ -280,6 +280,9 @@
RelativePath="..\pr\speed.pr">
</File>
<File
+ RelativePath="..\pr\sqlite.pr">
+ </File>
+ <File
RelativePath="..\status.txt">
</File>
<File