MIRROR: javascript for 馃悳's, a tiny runtime with big ambitions
1#ifndef ANT_STREAM_MODULE_H
2#define ANT_STREAM_MODULE_H
3
4#include "types.h"
5
6typedef void (*stream_finalize_fn)(
7 ant_t *js,
8 ant_value_t stream_obj,
9 void *state
10);
11
12typedef struct {
13 bool writing;
14 bool pending_final;
15 bool final_started;
16 void *attached_state;
17 stream_finalize_fn attached_state_finalize;
18} stream_private_state_t;
19
20void stream_init_constructors(ant_t *js);
21
22ant_value_t stream_library(ant_t *js);
23ant_value_t stream_promises_library(ant_t *js);
24ant_value_t stream_web_library(ant_t *js);
25
26ant_value_t stream_readable_constructor(ant_t *js);
27ant_value_t stream_writable_constructor(ant_t *js);
28ant_value_t stream_readable_prototype(ant_t *js);
29ant_value_t stream_writable_prototype(ant_t *js);
30ant_value_t stream_duplex_prototype(ant_t *js);
31
32ant_value_t stream_construct_readable(ant_t *js, ant_value_t base_proto, ant_value_t options);
33ant_value_t stream_construct_writable(ant_t *js, ant_value_t base_proto, ant_value_t options);
34ant_value_t stream_readable_push(ant_t *js, ant_value_t stream_obj, ant_value_t chunk, ant_value_t encoding);
35ant_value_t stream_readable_maybe_read(ant_t *js, ant_value_t stream_obj);
36ant_value_t stream_readable_flush(ant_t *js, ant_value_t stream_obj);
37ant_value_t stream_readable_push_value(ant_t *js, ant_value_t stream_obj, ant_value_t chunk, ant_value_t encoding);
38ant_value_t stream_readable_continue_flowing(ant_t *js, ant_value_t *args, int nargs);
39ant_value_t stream_readable_begin_flowing(ant_t *js, ant_value_t stream_obj);
40ant_value_t stream_writable_begin_end(ant_t *js, ant_value_t stream_obj, ant_value_t callback);
41
42void stream_init_readable_object(ant_t *js, ant_value_t obj, ant_value_t options);
43void stream_init_writable_object(ant_t *js, ant_value_t obj, ant_value_t options);
44void stream_init_duplex_object(ant_t *js, ant_value_t obj, ant_value_t options);
45
46void *stream_get_attached_state(ant_value_t stream_obj);
47void stream_clear_attached_state(ant_value_t stream_obj);
48void stream_set_attached_state(ant_value_t stream_obj, void *state, stream_finalize_fn finalize);
49
50#endif