2019-10-18 21:32:29 +00:00
|
|
|
/* Copyright (c), Charlotte Meyer <dev@buffet.sh>
|
|
|
|
*
|
|
|
|
* 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 https://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
2020-01-02 00:11:46 +00:00
|
|
|
#ifndef KIWMI_LUAK_LUAK_H
|
|
|
|
#define KIWMI_LUAK_LUAK_H
|
2019-10-18 21:32:29 +00:00
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#include <lua.h>
|
|
|
|
|
|
|
|
#include "server.h"
|
|
|
|
|
2019-12-30 23:33:07 +00:00
|
|
|
struct kiwmi_lua {
|
|
|
|
lua_State *L;
|
2020-02-06 17:55:05 +00:00
|
|
|
int objects;
|
2020-01-03 18:40:11 +00:00
|
|
|
struct wl_global *global;
|
2019-12-30 23:33:07 +00:00
|
|
|
};
|
|
|
|
|
2020-02-06 17:55:05 +00:00
|
|
|
struct kiwmi_object {
|
|
|
|
struct kiwmi_lua *lua;
|
|
|
|
|
|
|
|
void *object;
|
|
|
|
size_t refcount;
|
|
|
|
bool valid;
|
|
|
|
|
|
|
|
struct wl_listener destroy;
|
|
|
|
struct wl_list callbacks; // struct kiwmi_lua_callback::link
|
|
|
|
|
|
|
|
struct {
|
|
|
|
struct wl_signal destroy;
|
|
|
|
} events;
|
|
|
|
};
|
|
|
|
|
|
|
|
int luaK_kiwmi_object_gc(lua_State *L);
|
|
|
|
struct kiwmi_object *luaK_get_kiwmi_object(
|
|
|
|
struct kiwmi_lua *lua,
|
|
|
|
void *ptr,
|
|
|
|
struct wl_signal *destroy);
|
2020-01-02 22:15:00 +00:00
|
|
|
int luaK_callback_register_dispatch(lua_State *L);
|
2020-01-08 17:33:01 +00:00
|
|
|
int luaK_usertype_ref_equal(lua_State *L);
|
2020-01-02 00:11:46 +00:00
|
|
|
struct kiwmi_lua *luaK_create(struct kiwmi_server *server);
|
2019-12-30 23:33:07 +00:00
|
|
|
bool luaK_dofile(struct kiwmi_lua *lua, const char *config_path);
|
2020-01-02 00:11:46 +00:00
|
|
|
void luaK_destroy(struct kiwmi_lua *lua);
|
2019-10-18 21:32:29 +00:00
|
|
|
|
2020-01-02 00:11:46 +00:00
|
|
|
#endif /* KIWMI_LUAK_LUAK_H */
|