2009-01-04 21:45:21 -05:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include "llt.h"
|
|
|
|
#include "flisp.h"
|
|
|
|
|
|
|
|
static value_t streamsym;
|
|
|
|
static fltype_t *streamtype;
|
|
|
|
|
|
|
|
void print_stream(value_t v, ios_t *f, int princ)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void free_stream(value_t self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void relocate_stream(value_t oldv, value_t newv)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
cvtable_t stream_vtable = { print_stream, relocate_stream, free_stream, NULL };
|
|
|
|
|
|
|
|
int isstream(value_t v)
|
|
|
|
{
|
|
|
|
return iscvalue(v) && cv_class((cvalue_t*)ptr(v)) == streamtype;
|
|
|
|
}
|
|
|
|
|
|
|
|
value_t fl_streamp(value_t *args, uint32_t nargs)
|
|
|
|
{
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
argcount("stream?", nargs, 1);
|
|
|
|
return isstream(args[0]) ? FL_T : FL_F;
|
2009-01-04 21:45:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static ios_t *tostream(value_t v, char *fname)
|
|
|
|
{
|
|
|
|
if (!isstream(v))
|
|
|
|
type_error(fname, "stream", v);
|
|
|
|
return (ios_t*)cv_data((cvalue_t*)ptr(v));
|
|
|
|
}
|
|
|
|
|
|
|
|
static builtinspec_t streamfunc_info[] = {
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
{ "stream?", fl_streamp },
|
2009-01-04 21:45:21 -05:00
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
void stream_init()
|
|
|
|
{
|
|
|
|
streamsym = symbol("stream");
|
|
|
|
streamtype = define_opaque_type(streamsym, sizeof(ios_t),
|
|
|
|
&stream_vtable, NULL);
|
|
|
|
assign_global_builtins(streamfunc_info);
|
|
|
|
}
|