-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjswrap_stream.h
29 lines (25 loc) · 1.11 KB
/
jswrap_stream.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
* This file is part of Espruino, a JavaScript interpreter for Microcontrollers
*
* Copyright (C) 2013 Gordon Williams <[email protected]>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* ----------------------------------------------------------------------------
* JavaScript Stream Functions
* ----------------------------------------------------------------------------
*/
#include "jsvar.h"
#define STREAM_BUFFER_NAME JS_HIDDEN_CHAR_STR"buf" // the buffer to store data in when no listener is defined
#define STREAM_CALLBACK_NAME "#ondata"
#define STREAM_MAX_BUFFER_SIZE 512
JsVarInt jswrap_stream_available(JsVar *parent);
JsVar *jswrap_stream_read(JsVar *parent, JsVarInt chars);
/** Push data into a stream. To be used by Espruino (not a user).
* This either calls the on('data') handler if it exists, or it
* puts the data in a buffer. This MAY CLAIM the string that is
* passed in.
*/
void jswrap_stream_pushData(JsVar *parent, JsVar *dataString);