Melang

Logo

A script language of preemptive scheduling coroutine in single thread

View the Project on GitHub Water-Melon/Melang

Pipe

Pipe provides an approach to send a data set from C layer to script layer.

Functions

In C
int mln_lang_ctx_pipe_send(mln_lang_ctx_t *ctx, char *fmt, ...);

This function will send a data set given by ... to a specified script task by ctx.

fmt is used for the interpretation of variable parameters, fmt supports three characters:

Return value:

In Melang

Pipe(op);

This function is used to subscribe, unsubscribe and receive data from C layer.

op has three values:

Return value:

Example

In C

mln_lang_ctx_pipe_send(ctx, "ir", 1, 3.14);

In Melang

sys = Import('sys');
Pipe('subscribe');
sys.print(Pipe('recv'));
Pipe('unsubscribe');

The output is:

[[1, 3.14], ]