From 42affd404a67ab2454eecee1ae2dd8804eed0d9f Mon Sep 17 00:00:00 2001 From: jaeger Date: Fri, 8 Jul 2011 19:48:44 +0000 Subject: [PATCH] tinypy: file reading support. git-svn-id: svn://kolibrios.org@2001 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/develop/tinypy/tinypy/Makefile | 2 +- programs/develop/tinypy/tinypy/kolibri_fs.c | 1 + programs/develop/tinypy/tinypy/kolibri_init.c | 1 + programs/develop/tinypy/tinypy/ops.c | 6 ++---- programs/develop/tinypy/tinypy/test.py | 5 +++++ programs/develop/tinypy/tinypy/tpmain.c | 1 + 6 files changed, 11 insertions(+), 5 deletions(-) create mode 120000 programs/develop/tinypy/tinypy/kolibri_fs.c create mode 120000 programs/develop/tinypy/tinypy/kolibri_init.c diff --git a/programs/develop/tinypy/tinypy/Makefile b/programs/develop/tinypy/tinypy/Makefile index 0cea5f1406..2ff0a58912 100644 --- a/programs/develop/tinypy/tinypy/Makefile +++ b/programs/develop/tinypy/tinypy/Makefile @@ -1,6 +1,6 @@ export MENUETDEV=../../libraries/menuetlibc OUTFILE = tpmain -OBJS = tpmain.o +OBJS = tpmain.o kolibri_init.o kolibri_fs.o include $(MENUETDEV)/makefiles/Makefile_for_program #testmod.o: fasm_modules/testmod.s # fasm fasm_modules/testmod.s diff --git a/programs/develop/tinypy/tinypy/kolibri_fs.c b/programs/develop/tinypy/tinypy/kolibri_fs.c new file mode 120000 index 0000000000..46df7b12e6 --- /dev/null +++ b/programs/develop/tinypy/tinypy/kolibri_fs.c @@ -0,0 +1 @@ +/home/john/Kolibri/kolibrios.org/programs/develop/tinypy/modules/kolibri/fs.c \ No newline at end of file diff --git a/programs/develop/tinypy/tinypy/kolibri_init.c b/programs/develop/tinypy/tinypy/kolibri_init.c new file mode 120000 index 0000000000..7950a9d303 --- /dev/null +++ b/programs/develop/tinypy/tinypy/kolibri_init.c @@ -0,0 +1 @@ +/home/john/Kolibri/kolibrios.org/programs/develop/tinypy/modules/kolibri/init.c \ No newline at end of file diff --git a/programs/develop/tinypy/tinypy/ops.c b/programs/develop/tinypy/tinypy/ops.c index 88df8a7995..d7d34059e0 100644 --- a/programs/develop/tinypy/tinypy/ops.c +++ b/programs/develop/tinypy/tinypy/ops.c @@ -69,7 +69,7 @@ tp_obj tp_iter(TP,tp_obj self, tp_obj k) { tp_obj tp_get(TP,tp_obj self, tp_obj k) { int type = self.type; tp_obj r; - /*con_printf("tp_get %s %s\n", TP_CSTR(self), TP_CSTR(k));*/ + if (type == TP_DICT) { return _tp_dict_get(tp,self.dict.val,k,"tp_get"); } else if (type == TP_LIST) { @@ -142,8 +142,6 @@ tp_obj tp_get(TP,tp_obj self, tp_obj k) { } } - - con_printf("Raising exception\n"); tp_raise(tp_None,"tp_get(%s,%s)",TP_CSTR(self),TP_CSTR(k)); } @@ -162,7 +160,7 @@ int tp_iget(TP,tp_obj *r, tp_obj self, tp_obj k) { void tp_set(TP,tp_obj self, tp_obj k, tp_obj v) { int type; - con_printf("vm is %x self is %x k is %x v is %x", tp, self, k, v); + type = self.type; if (type == TP_DICT) { _tp_dict_set(tp,self.dict.val,k,v); diff --git a/programs/develop/tinypy/tinypy/test.py b/programs/develop/tinypy/tinypy/test.py index 42409b84c8..b67491643b 100644 --- a/programs/develop/tinypy/tinypy/test.py +++ b/programs/develop/tinypy/tinypy/test.py @@ -1,2 +1,7 @@ +import kolibri if __name__=="__main__": print("ok!") + f = kolibri.open("/hd0/1/tinypy/test.txt") + print(f.size) + print(f.read()) + f.close() diff --git a/programs/develop/tinypy/tinypy/tpmain.c b/programs/develop/tinypy/tinypy/tpmain.c index b20c786e0d..f35015f39c 100644 --- a/programs/develop/tinypy/tinypy/tpmain.c +++ b/programs/develop/tinypy/tinypy/tpmain.c @@ -15,6 +15,7 @@ void main(void) { argv[1][strlen(argv[1]) - 1] = '\0'; con_printf("Running file %s\n", argv[1]); tp_vm *tp = tp_init(argc, argv); + kolibri_init(tp); /* INIT */ tp_call(tp,"py2bc","tinypy",tp_None); tp_deinit(tp);