<commit_before>#include "lua_messaging.h"
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#include "lua_copy.h"
#include "globlua.h"
#include "global.h"

#include <string.h>

#define TYPE_NAME "messaging"
#define REGISTRY_KEY "geng.messaging"

void set_messaging_registry(lua_State* L, msgq_state* d);

msgq_state* luaG_checkmessage(lua_State* L, int index)
{
	luaL_checktype(L, index, LUA_TUSERDATA);
	msgq_state* s = NULL;
	s = luaL_checkudata(L, index, TYPE_NAME);
	if (s == NULL) luaL_typerror(L, index, TYPE_NAME);
	return s;
}

msgq_state* get_message_registry(lua_State* L)
{
	lua_pushstring(L, REGISTRY_KEY);
	lua_rawget(L, LUA_REGISTRYINDEX);
	msgq_state* ret = lua_touserdata(L, -1);
	lua_pop(L, 1);
	if(ret == NULL) {
		luaL_error(L, "Could not find messaging data");
	}
	return ret;
}

static int lua_broadcast_message(lua_State* l)
{
	msgq_state* s = get_message_registry(l);
	const char* message = luaL_checklstring(l, 1, 0);
	if (message == NULL)
		luaL_error(l, "Valid message needed");
	lua_pushvalue(l, 2);
	msgq_broadcast(s, l, message, luaL_ref(l, LUA_REGISTRYINDEX));
	return 0;
}

struct listen_data {
	lua_State* state;
	int listen_method;
};
<commit_msg>Warnings woo<commit_after>#include "lua_messaging.h"
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#include "lua_copy.h"
#include "globlua.h"
#include "global.h"

#include <string.h>

#define TYPE_NAME "messaging"
#define REGISTRY_KEY "geng.messaging"

void set_messaging_registry(lua_State* L, msgq_state* d);

msgq_state* luaG_checkmessage(lua_State* L, int index)
{
	luaL_checktype(L, index, LUA_TUSERDATA);
	msgq_state* s = NULL;
	s = luaL_checkudata(L, index, TYPE_NAME);
	if (s == NULL) luaL_typerror(L, index, TYPE_NAME);
	return s;
}

msgq_state* get_message_registry(lua_State* L)
{
	lua_pushstring(L, REGISTRY_KEY);
	lua_rawget(L, LUA_REGISTRYINDEX);
	msgq_state* ret = lua_touserdata(L, -1);
	lua_pop(L, 1);
	if(ret == NULL) {
		luaL_error(L, "Could not find messaging data");
	}
	return ret;
}

static int lua_broadcast_message(lua_State* l)
{
	msgq_state* s = get_message_registry(l);
	const char* message = luaL_checklstring(l, 1, 0);
	if (message == NULL)
		luaL_error(l, "Valid message needed");
	lua_pushvalue(l, 2);
	msgq_broadcast(s, l, message, (void*)luaL_ref(l, LUA_REGISTRYINDEX));
	return 0;
}

struct listen_data {
	lua_State* state;
	int listen_method;
};

{'fraction_non_alphanumeric': 0.13895885810243494, 'fraction_numerical': 0.005037783375314861, 'mean_word_length': 6.092261904761905, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2534500', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1014, 'n_words': 217}