changeset 88:f38d8d39d617

add file interface
author tobaru
date Wed, 16 Oct 2019 19:40:37 +0900
parents add5e775339c
children df104b2de895
files src/interface/File.h src/sysfile.cbc
diffstat 2 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/interface/File.h	Wed Oct 16 19:40:37 2019 +0900
@@ -0,0 +1,8 @@
+typedef struct File<Type, Impl>{
+        union Data* file;
+        struct file *f;
+        int n;
+        char *p;
+        __code file_read(__code, next(...));
+        __code next(...);
+} File;
--- a/src/sysfile.cbc	Tue Oct 15 20:13:25 2019 +0900
+++ b/src/sysfile.cbc	Wed Oct 16 19:40:37 2019 +0900
@@ -87,6 +87,20 @@
     goto cbc_fileread(f, p, n, next);
 }
 
+__code file_read(struct file *f, int n, char *p, __code next(...)){
+   goto cbc_fileread(f, p, n, next);
+}
+
+__code file_read_stub(struct Context* cbc_context){
+    struct file *f;
+    int n;
+    char *p;
+    if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) {
+        goto next(-1);
+    }
+    goto cbc_fileread(f, p, n, next);
+}
+
 int sys_read(void)
 {
     struct file *f;