Added cont argument to blocking I/O functions

This commit is contained in:
Justin Ethier 2015-12-22 21:57:00 -05:00
parent f0b992335e
commit 309e35c69b
3 changed files with 10 additions and 6 deletions

View file

@ -150,8 +150,8 @@ object Cyc_io_close_output_port(void *data, object port);
object Cyc_io_flush_output_port(void *data, object port);
object Cyc_io_delete_file(void *data, object filename);
object Cyc_io_file_exists(void *data, object filename);
object Cyc_io_read_char(void *data, object port);
object Cyc_io_peek_char(void *data, object port);
object Cyc_io_read_char(void *data, object cont, object port);
object Cyc_io_peek_char(void *data, object cont, object port);
object Cyc_io_read_line(void *data, object cont, object port);
object Cyc_is_boolean(object o);

View file

@ -1486,7 +1486,7 @@ object Cyc_io_file_exists(void *data, object filename) {
}
// TODO: port arg is optional! (maybe handle that in expansion section??)
object Cyc_io_read_char(void *data, object port) {
object Cyc_io_read_char(void *data, object cont, object port) {
int c;
Cyc_check_port(data, port);
{
@ -1526,7 +1526,7 @@ object Cyc_io_read_line(void *data, object cont, object port) {
return nil;
}
object Cyc_io_peek_char(void *data, object port) {
object Cyc_io_peek_char(void *data, object cont, object port) {
FILE *stream;
int c;
@ -1952,10 +1952,10 @@ void _delete_91file(void *data, object cont, object args) {
return_closcall1(data, cont, Cyc_io_delete_file(data, car(args)));}
void _read_91char(void *data, object cont, object args) {
Cyc_check_num_args(data, "read-char", 1, args);
return_closcall1(data, cont, Cyc_io_read_char(data, car(args)));}
return_closcall1(data, cont, Cyc_io_read_char(data, cont, car(args)));}
void _peek_91char(void *data, object cont, object args) {
Cyc_check_num_args(data, "peek-char", 1, args);
return_closcall1(data, cont, Cyc_io_peek_char(data, car(args)));}
return_closcall1(data, cont, Cyc_io_peek_char(data, cont, car(args)));}
void _Cyc_91read_91line(void *data, object cont, object args) {
Cyc_check_num_args(data, "Cyc-read-line", 1, args);
Cyc_io_read_line(data, cont, car(args));}

View file

@ -651,6 +651,8 @@
((eq? p 'string-length) "integer_type")
((eq? p 'apply) "object")
((eq? p 'Cyc-read-line) "object")
((eq? p 'read-char) "object")
((eq? p 'peek-char) "object")
((eq? p 'command-line-arguments) "object")
((eq? p 'number->string) "object")
((eq? p 'symbol->string) "object")
@ -681,12 +683,14 @@
+ - * / apply
command-line-arguments
Cyc-read-line
read-char peek-char
cons length vector-length cell))))
;; Pass continuation as the function's first parameter?
(define (prim:cont? exp)
(and (prim? exp)
(member exp '(Cyc-read-line apply command-line-arguments number->string
read-char peek-char
symbol->string list->string substring string-append
make-vector list->vector Cyc-installation-dir))))