aboutsummaryrefslogtreecommitdiffhomepage
path: root/backends/lua.h
blob: 5587bf936e4578b74f3bfd95e16f5e8584256d38 (plain)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "midimonster.h"

#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>

//OSX and Windows don't have the cool new toys...
#ifdef __linux__
	#define MMBACKEND_LUA_TIMERFD
#endif

MM_PLUGIN_API int init();
static int lua_configure(char* option, char* value);
static int lua_configure_instance(instance* inst, char* option, char* value);
static int lua_instance(instance* inst);
static channel* lua_channel(instance* inst, char* spec, uint8_t flags);
static int lua_set(instance* inst, size_t num, channel** c, channel_value* v);
static int lua_handle(size_t num, managed_fd* fds);
static int lua_start(size_t n, instance** inst);
static int lua_shutdown(size_t n, instance** inst);
#ifndef MMBACKEND_LUA_TIMERFD
static uint32_t lua_interval();
#endif

typedef struct /*_lua_channel*/ {
	char* name;
	int reference;
	double in;
	double out;
	uint8_t mark;
} lua_channel_data;

typedef struct /*_lua_instance_data*/ {
	size_t channels;
	lua_channel_data* channel;

	lua_State* interpreter;
	int cleanup_handler;
	char* default_handler;
} lua_instance_data;

typedef struct /*_lua_interval_callback*/ {
	uint64_t interval;
	uint64_t delta;
	lua_State* interpreter;
	int reference;
} lua_timer;

typedef struct /*_lua_coroutine*/ {
	instance* instance;
	lua_State* thread;
	int reference;
	uint64_t timeout;
} lua_thread;