Cleanup function pointer typedefs;

This commit is contained in:
bjorn 2019-08-21 14:37:22 -07:00
parent fb279057b8
commit 7c8a44cc57
4 changed files with 7 additions and 6 deletions

View File

@ -55,7 +55,7 @@ void luax_checkvariant(lua_State* L, int index, Variant* variant) {
lua_pushliteral(L, "__destructor");
lua_rawget(L, -2);
variant->value.object.destructor = (destructorFn*) lua_tocfunction(L, -1);
variant->value.object.destructor = (void (*)(void*)) lua_tocfunction(L, -1);
lua_pop(L, 1);
variant->value.object.pointer = proxy->object;

View File

@ -7,6 +7,9 @@
#include <stdarg.h>
#include <stdbool.h>
typedef void voidFn(void);
typedef void destructorFn(void*);
static int luax_meta__tostring(lua_State* L) {
lua_getfield(L, -1, "__name");
lua_pushstring(L, (const char*) lua_touserdata(L, -1));

View File

@ -1,7 +1,7 @@
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#include "util.h"
#include <stdint.h>
#pragma once
@ -27,7 +27,7 @@ typedef struct {
#define luax_seterror(L) lua_setfield(L, LUA_REGISTRYINDEX, "_lovrerror")
#define luax_clearerror(L) lua_pushnil(L), luax_seterror(L)
void _luax_registertype(lua_State* L, const char* name, const luaL_Reg* functions, destructorFn* destructor);
void _luax_registertype(lua_State* L, const char* name, const luaL_Reg* functions, void (*destructor)(void*));
void* _luax_totype(lua_State* L, int index, uint32_t hash);
void* _luax_checktype(lua_State* L, int index, uint32_t hash, const char* debug);
void _luax_pushtype(lua_State* L, const char* name, uint32_t hash, void* object);
@ -39,5 +39,5 @@ int luax_print(lua_State* L);
void luax_pushconf(lua_State* L);
int luax_setconf(lua_State* L);
void luax_setmainthread(lua_State* L);
void luax_atexit(lua_State* L, voidFn* destructor);
void luax_atexit(lua_State* L, void (*destructor)(void));
void luax_readcolor(lua_State* L, int index, struct Color* color);

View File

@ -35,8 +35,6 @@
typedef struct Color { float r, g, b, a; } Color;
typedef void voidFn(void);
typedef void destructorFn(void*);
typedef void errorFn(void*, const char*, va_list);
extern LOVR_THREAD_LOCAL errorFn* lovrErrorCallback;