Tactical commit whilst converting to URL_FILE
This commit is contained in:
parent
f8c20ab3b1
commit
a355a28ffa
23 changed files with 700 additions and 88 deletions
8
src/ops/io.c
Normal file
8
src/ops/io.c
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* io.c
|
||||
*
|
||||
* Communication between PSSE and the outside world, via libcurl.
|
||||
*
|
||||
* (c) 2017 Simon Brooke <simon@journeyman.cc>
|
||||
* Licensed under GPL version 2.0, or, at your option, any later version.
|
||||
*/
|
||||
|
|
@ -839,7 +839,7 @@ lisp_read( struct stack_frame *frame, struct cons_pointer frame_pointer,
|
|||
#ifdef DEBUG
|
||||
debug_print( L"entering lisp_read\n", DEBUG_IO );
|
||||
#endif
|
||||
FILE *input = stdin;
|
||||
URL_FILE *input = stdin;
|
||||
struct cons_pointer in_stream = readp( frame->arg[0] ) ?
|
||||
frame->arg[0] : get_default_stream( true, env );
|
||||
|
||||
|
|
@ -922,7 +922,7 @@ lisp_print( struct stack_frame *frame, struct cons_pointer frame_pointer,
|
|||
struct cons_pointer env ) {
|
||||
debug_print( L"Entering print\n", DEBUG_IO );
|
||||
struct cons_pointer result = NIL;
|
||||
FILE *output = stdout;
|
||||
URL_FILE *output = stdout;
|
||||
struct cons_pointer out_stream = writep( frame->arg[1] ) ?
|
||||
frame->arg[1] : get_default_stream( false, env );
|
||||
|
||||
|
|
@ -1148,7 +1148,7 @@ struct cons_pointer lisp_repl( struct stack_frame *frame,
|
|||
|
||||
struct cons_pointer input = get_default_stream( true, env );
|
||||
struct cons_pointer output = get_default_stream( false, env );
|
||||
FILE *os = pointer2cell( output ).payload.stream.stream;
|
||||
URL_FILE *os = pointer2cell( output ).payload.stream.stream;
|
||||
struct cons_pointer prompt_name = c_string_to_lisp_symbol( L"*prompt*" );
|
||||
struct cons_pointer old_oblist = oblist;
|
||||
struct cons_pointer new_env = env;
|
||||
|
|
@ -1282,7 +1282,7 @@ struct cons_pointer lisp_inspect( struct stack_frame *frame,
|
|||
struct cons_pointer frame_pointer,
|
||||
struct cons_pointer env ) {
|
||||
debug_print( L"Entering print\n", DEBUG_IO );
|
||||
FILE *output = stdout;
|
||||
URL_FILE *output = stdout;
|
||||
struct cons_pointer out_stream = writep( frame->arg[1] ) ?
|
||||
frame->arg[1] : get_default_stream( false, env );
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ int print_use_colours = 0;
|
|||
* onto this `output`; if `pointer` does not indicate a string or symbol,
|
||||
* don't print anything but just return.
|
||||
*/
|
||||
void print_string_contents( FILE * output, struct cons_pointer pointer ) {
|
||||
void print_string_contents( URL_FILE * output, struct cons_pointer pointer ) {
|
||||
while ( stringp( pointer ) || symbolp( pointer ) ) {
|
||||
struct cons_space_object *cell = &pointer2cell( pointer );
|
||||
wchar_t c = cell->payload.string.character;
|
||||
|
|
@ -51,7 +51,7 @@ void print_string_contents( FILE * output, struct cons_pointer pointer ) {
|
|||
* the stream at this `output`, prepending and appending double quote
|
||||
* characters.
|
||||
*/
|
||||
void print_string( FILE * output, struct cons_pointer pointer ) {
|
||||
void print_string( URL_FILE * output, struct cons_pointer pointer ) {
|
||||
fputwc( btowc( '"' ), output );
|
||||
print_string_contents( output, pointer );
|
||||
fputwc( btowc( '"' ), output );
|
||||
|
|
@ -63,7 +63,7 @@ void print_string( FILE * output, struct cons_pointer pointer ) {
|
|||
* a space character.
|
||||
*/
|
||||
void
|
||||
print_list_contents( FILE * output, struct cons_pointer pointer,
|
||||
print_list_contents( URL_FILE * output, struct cons_pointer pointer,
|
||||
bool initial_space ) {
|
||||
struct cons_space_object *cell = &pointer2cell( pointer );
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ print_list_contents( FILE * output, struct cons_pointer pointer,
|
|||
}
|
||||
}
|
||||
|
||||
void print_list( FILE * output, struct cons_pointer pointer ) {
|
||||
void print_list( URL_FILE * output, struct cons_pointer pointer ) {
|
||||
if ( print_use_colours ) {
|
||||
fwprintf( output, L"%s(%s", "\x1B[31m", "\x1B[39m" );
|
||||
} else {
|
||||
|
|
@ -104,7 +104,7 @@ void print_list( FILE * output, struct cons_pointer pointer ) {
|
|||
* Print the cons-space object indicated by `pointer` to the stream indicated
|
||||
* by `output`.
|
||||
*/
|
||||
struct cons_pointer print( FILE * output, struct cons_pointer pointer ) {
|
||||
struct cons_pointer print( URL_FILE * output, struct cons_pointer pointer ) {
|
||||
struct cons_space_object cell = pointer2cell( pointer );
|
||||
char *buffer;
|
||||
|
||||
|
|
@ -225,6 +225,6 @@ struct cons_pointer print( FILE * output, struct cons_pointer pointer ) {
|
|||
return pointer;
|
||||
}
|
||||
|
||||
void println( FILE * output ) {
|
||||
void println( URL_FILE * output ) {
|
||||
fputws( L"\n", output );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@
|
|||
#ifndef __print_h
|
||||
#define __print_h
|
||||
|
||||
struct cons_pointer print( FILE * output, struct cons_pointer pointer );
|
||||
void println( FILE * output );
|
||||
struct cons_pointer print( URL_FILE * output, struct cons_pointer pointer );
|
||||
void println( URL_FILE * output );
|
||||
extern int print_use_colours;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -38,13 +38,13 @@
|
|||
|
||||
struct cons_pointer read_number( struct stack_frame *frame,
|
||||
struct cons_pointer frame_pointer,
|
||||
FILE * input, wint_t initial,
|
||||
URL_FILE * input, wint_t initial,
|
||||
bool seen_period );
|
||||
struct cons_pointer read_list( struct stack_frame *frame,
|
||||
struct cons_pointer frame_pointer, FILE * input,
|
||||
struct cons_pointer frame_pointer, URL_FILE * input,
|
||||
wint_t initial );
|
||||
struct cons_pointer read_string( FILE * input, wint_t initial );
|
||||
struct cons_pointer read_symbol( FILE * input, wint_t initial );
|
||||
struct cons_pointer read_string( URL_FILE * input, wint_t initial );
|
||||
struct cons_pointer read_symbol( URL_FILE * input, wint_t initial );
|
||||
|
||||
/**
|
||||
* quote reader macro in C (!)
|
||||
|
|
@ -61,7 +61,7 @@ struct cons_pointer c_quote( struct cons_pointer arg ) {
|
|||
*/
|
||||
struct cons_pointer read_continuation( struct stack_frame *frame,
|
||||
struct cons_pointer frame_pointer,
|
||||
FILE * input, wint_t initial ) {
|
||||
URL_FILE * input, wint_t initial ) {
|
||||
debug_print( L"entering read_continuation\n", DEBUG_IO );
|
||||
struct cons_pointer result = NIL;
|
||||
|
||||
|
|
@ -129,6 +129,7 @@ struct cons_pointer read_continuation( struct stack_frame *frame,
|
|||
}
|
||||
}
|
||||
break;
|
||||
//case ':': reserved for keywords and paths
|
||||
default:
|
||||
if ( iswdigit( c ) ) {
|
||||
result =
|
||||
|
|
@ -158,7 +159,7 @@ struct cons_pointer read_continuation( struct stack_frame *frame,
|
|||
*/
|
||||
struct cons_pointer read_number( struct stack_frame *frame,
|
||||
struct cons_pointer frame_pointer,
|
||||
FILE * input,
|
||||
URL_FILE * input,
|
||||
wint_t initial, bool seen_period ) {
|
||||
debug_print( L"entering read_number\n", DEBUG_IO );
|
||||
|
||||
|
|
@ -267,7 +268,7 @@ struct cons_pointer read_number( struct stack_frame *frame,
|
|||
*/
|
||||
struct cons_pointer read_list( struct stack_frame *frame,
|
||||
struct cons_pointer frame_pointer,
|
||||
FILE * input, wint_t initial ) {
|
||||
URL_FILE * input, wint_t initial ) {
|
||||
struct cons_pointer result = NIL;
|
||||
if ( initial != ')' ) {
|
||||
debug_printf( DEBUG_IO,
|
||||
|
|
@ -293,7 +294,7 @@ struct cons_pointer read_list( struct stack_frame *frame,
|
|||
* so delimited in which case it may not contain whitespace (unless escaped)
|
||||
* but may contain a double quote character (probably not a good idea!)
|
||||
*/
|
||||
struct cons_pointer read_string( FILE * input, wint_t initial ) {
|
||||
struct cons_pointer read_string( URL_FILE * input, wint_t initial ) {
|
||||
struct cons_pointer cdr = NIL;
|
||||
struct cons_pointer result;
|
||||
switch ( initial ) {
|
||||
|
|
@ -315,7 +316,7 @@ struct cons_pointer read_string( FILE * input, wint_t initial ) {
|
|||
return result;
|
||||
}
|
||||
|
||||
struct cons_pointer read_symbol( FILE * input, wint_t initial ) {
|
||||
struct cons_pointer read_symbol( URL_FILE * input, wint_t initial ) {
|
||||
struct cons_pointer cdr = NIL;
|
||||
struct cons_pointer result;
|
||||
switch ( initial ) {
|
||||
|
|
@ -331,7 +332,7 @@ struct cons_pointer read_symbol( FILE * input, wint_t initial ) {
|
|||
break;
|
||||
case ')':
|
||||
/*
|
||||
* symbols may not include right-parenthesis
|
||||
* symbols may not include right-parenthesis;
|
||||
*/
|
||||
result = NIL;
|
||||
/*
|
||||
|
|
@ -367,6 +368,6 @@ struct cons_pointer read_symbol( FILE * input, wint_t initial ) {
|
|||
struct cons_pointer read( struct
|
||||
stack_frame
|
||||
*frame, struct cons_pointer frame_pointer,
|
||||
FILE * input ) {
|
||||
URL_FILE * input ) {
|
||||
return read_continuation( frame, frame_pointer, input, fgetwc( input ) );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,6 @@
|
|||
* read the next object on this input stream and return a cons_pointer to it.
|
||||
*/
|
||||
struct cons_pointer read( struct stack_frame *frame,
|
||||
struct cons_pointer frame_pointer, FILE * input );
|
||||
struct cons_pointer frame_pointer, URL_FILE * input );
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue