inline a bunch of super smol lua things

This commit is contained in:
Alug committed 2025-01-28 18:31:54 +01:00
1 parent ba38b69782
commit aa5b480a44
9 files changed
+74 -74

No files matched your search

+7 -7
View File
@@ -369,7 +369,7 @@ static int lib_pRandomChance(lua_State *L)
// P_MAPUTIL
///////////////
static int lib_pAproxDistance(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_pAproxDistance(lua_State *L)
{
fixed_t dx = luaL_checkfixed(L, 1);
fixed_t dy = luaL_checkfixed(L, 2);
@@ -1776,7 +1776,7 @@ static int lib_evCrumbleChain(lua_State *L)
// P_SLOPES
////////////
static int lib_pGetZAt(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_pGetZAt(lua_State *L)
{
pslope_t *slope = *((pslope_t **)luaL_checkudata(L, 1, META_SLOPE));
fixed_t x = luaL_checkfixed(L, 2);
@@ -1792,7 +1792,7 @@ static int lib_pGetZAt(lua_State *L)
// R_DEFS
////////////
static int lib_rPointToAngle(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_rPointToAngle(lua_State *L)
{
fixed_t x = luaL_checkfixed(L, 1);
fixed_t y = luaL_checkfixed(L, 2);
@@ -1801,7 +1801,7 @@ static int lib_rPointToAngle(lua_State *L)
return 1;
}
static int lib_rPointToAngle2(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_rPointToAngle2(lua_State *L)
{
fixed_t px2 = luaL_checkfixed(L, 1);
fixed_t py2 = luaL_checkfixed(L, 2);
@@ -1812,7 +1812,7 @@ static int lib_rPointToAngle2(lua_State *L)
return 1;
}
static int lib_rPointToDist(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_rPointToDist(lua_State *L)
{
fixed_t x = luaL_checkfixed(L, 1);
fixed_t y = luaL_checkfixed(L, 2);
@@ -1821,7 +1821,7 @@ static int lib_rPointToDist(lua_State *L)
return 1;
}
static int lib_rPointToDist2(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_rPointToDist2(lua_State *L)
{
fixed_t px2 = luaL_checkfixed(L, 1);
fixed_t py2 = luaL_checkfixed(L, 2);
@@ -1832,7 +1832,7 @@ static int lib_rPointToDist2(lua_State *L)
return 1;
}
static int lib_rPointInSubsector(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_rPointInSubsector(lua_State *L)
{
fixed_t x = luaL_checkfixed(L, 1);
fixed_t y = luaL_checkfixed(L, 2);
+1 -1
View File
@@ -8,7 +8,7 @@
#define GLIB_DATABASE_MTABLE "metatable" /* Metatable.*/
#define GLIB_DATABASE_PROXY "proxy" /* Proxy table for the library that isn't the global table. */
static inline void lua_glib_push_db(lua_State *L)
FUNCINLINE static ATTRINLINE void lua_glib_push_db(lua_State *L)
{
lua_pushliteral(L, GLIB_DATABASE_GUID);
lua_gettable(L, LUA_REGISTRYINDEX);
+17 -17
View File
@@ -231,7 +231,7 @@ static int lib_getHudInfo(lua_State *L)
return 1;
}
static int lib_hudinfolen(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_hudinfolen(lua_State *L)
{
lua_pushinteger(L, NUMHUDITEMS);
return 1;
@@ -273,14 +273,14 @@ static int hudinfo_set(lua_State *L)
return 0;
}
static int hudinfo_num(lua_State *L)
FUNCINLINE static ATTRINLINE int hudinfo_num(lua_State *L)
{
hudinfo_t *info = *((hudinfo_t **)luaL_checkudata(L, 1, META_HUDINFO));
lua_pushinteger(L, info-hudinfo);
return 1;
}
static int colormap_get(lua_State *L)
FUNCINLINE static ATTRINLINE int colormap_get(lua_State *L)
{
return luaL_error(L, "colormap is not a struct.");
}
@@ -315,7 +315,7 @@ static int patch_get(lua_State *L)
return 1;
}
static int patch_set(lua_State *L)
FUNCINLINE static ATTRINLINE int patch_set(lua_State *L)
{
return luaL_error(L, LUA_QL("patch_t") " struct cannot be edited by Lua.");
}
@@ -383,14 +383,14 @@ static int camera_get(lua_State *L)
// lib_draw
//
static int libd_patchExists(lua_State *L)
FUNCINLINE static ATTRINLINE int libd_patchExists(lua_State *L)
{
HUDONLY
lua_pushboolean(L, W_LumpExists(luaL_checkstring(L, 1)));
return 1;
}
static int libd_cachePatch(lua_State *L)
FUNCINLINE static ATTRINLINE int libd_cachePatch(lua_State *L)
{
HUDONLY
LUA_PushUserdata(L, W_CachePatchName(luaL_checkstring(L, 1), PU_STATIC), META_PATCH);
@@ -1049,14 +1049,14 @@ static int libd_getColorHudPatch(lua_State *L)
return 2;
}
static int libd_getHudColor(lua_State *L)
FUNCINLINE static ATTRINLINE int libd_getHudColor(lua_State *L)
{
HUDONLY
lua_pushinteger(L, K_GetHudColor());
return 1;
}
static int libd_useColorHud(lua_State *L)
FUNCINLINE static ATTRINLINE int libd_useColorHud(lua_State *L)
{
HUDONLY
lua_pushboolean(L, K_UseColorHud());
@@ -1064,21 +1064,21 @@ static int libd_useColorHud(lua_State *L)
}
static int libd_width(lua_State *L)
FUNCINLINE static ATTRINLINE int libd_width(lua_State *L)
{
HUDONLY
lua_pushinteger(L, vid.width); // push screen width
return 1;
}
static int libd_height(lua_State *L)
FUNCINLINE static ATTRINLINE int libd_height(lua_State *L)
{
HUDONLY
lua_pushinteger(L, vid.height); // push screen height
return 1;
}
static int libd_dupx(lua_State *L)
FUNCINLINE static ATTRINLINE int libd_dupx(lua_State *L)
{
HUDONLY
lua_pushinteger(L, vid.dupx); // push integral scale (patch scale)
@@ -1086,7 +1086,7 @@ static int libd_dupx(lua_State *L)
return 2;
}
static int libd_dupy(lua_State *L)
FUNCINLINE static ATTRINLINE int libd_dupy(lua_State *L)
{
HUDONLY
lua_pushinteger(L, vid.dupy); // push integral scale (patch scale)
@@ -1094,7 +1094,7 @@ static int libd_dupy(lua_State *L)
return 2;
}
static int libd_renderer(lua_State *L)
FUNCINLINE static ATTRINLINE int libd_renderer(lua_State *L)
{
HUDONLY
switch (rendermode) {
@@ -1107,7 +1107,7 @@ static int libd_renderer(lua_State *L)
// 30/10/18 Lat': Get cv_translucenthud's value for HUD rendering as a normal V_xxTRANS int
// Could as well be thrown in global vars for ease of access but I guess it makes sense for it to be a HUD fn
static int libd_getlocaltransflag(lua_State *L)
FUNCINLINE static ATTRINLINE int libd_getlocaltransflag(lua_State *L)
{
HUDONLY
lua_pushinteger(L, (10-cv_translucenthud.value)*V_10TRANS); // A bit weird that it's called "translucenthud" yet 10 is fully opaque :V
@@ -1208,7 +1208,7 @@ static int lib_draw_ref;
//
// enable vanilla HUD element
static int lib_hudenable(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_hudenable(lua_State *L)
{
enum hud option = luaL_checkoption(L, 1, NULL, hud_disable_options);
hud_enabled[option/8] |= 1<<(option%8);
@@ -1216,7 +1216,7 @@ static int lib_hudenable(lua_State *L)
}
// disable vanilla HUD element
static int lib_huddisable(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_huddisable(lua_State *L)
{
enum hud option = luaL_checkoption(L, 1, NULL, hud_disable_options);
hud_enabled[option/8] &= ~(1<<(option%8));
@@ -1224,7 +1224,7 @@ static int lib_huddisable(lua_State *L)
}
// 30/10/18: Lat': How come this wasn't here before?
static int lib_hudenabled(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_hudenabled(lua_State *L)
{
enum hud option = luaL_checkoption(L, 1, NULL, hud_disable_options);
if (hud_enabled[option/8] & (1<<(option%8)))
+9 -9
View File
@@ -61,7 +61,7 @@ static int lib_getSprname(lua_State *L)
}
/// \todo Maybe make it tally up the used_spr from dehacked?
static int lib_sprnamelen(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_sprnamelen(lua_State *L)
{
lua_pushinteger(L, NUMSPRITES);
return 1;
@@ -121,7 +121,7 @@ static void A_Lua(mobj_t *actor)
}
// Arbitrary states[] table index -> state_t *
static int lib_getState(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_getState(lua_State *L)
{
UINT32 i;
lua_remove(L, 1);
@@ -213,7 +213,7 @@ static int lib_setState(lua_State *L)
}
// #states -> NUMSTATES
static int lib_statelen(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_statelen(lua_State *L)
{
lua_pushinteger(L, NUMSTATES);
return 1;
@@ -481,7 +481,7 @@ static int state_num(lua_State *L)
///////////////
// Arbitrary mobjinfo[] table index -> mobjinfo_t *
static int lib_getMobjInfo(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_getMobjInfo(lua_State *L)
{
UINT32 i;
lua_remove(L, 1);
@@ -592,7 +592,7 @@ static int lib_setMobjInfo(lua_State *L)
}
// #mobjinfo -> NUMMOBJTYPES
static int lib_mobjinfolen(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_mobjinfolen(lua_State *L)
{
lua_pushinteger(L, NUMMOBJTYPES);
return 1;
@@ -868,7 +868,7 @@ static int mobjinfo_set(lua_State *L)
}
// mobjinfo_t * -> MT_*
static int mobjinfo_num(lua_State *L)
FUNCINLINE static ATTRINLINE int mobjinfo_num(lua_State *L)
{
mobjinfo_t *info = *((mobjinfo_t **)luaL_checkudata(L, 1, META_MOBJINFO));
@@ -884,7 +884,7 @@ static int mobjinfo_num(lua_State *L)
//////////////
// Arbitrary S_sfx[] table index -> sfxinfo_t *
static int lib_getSfxInfo(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_getSfxInfo(lua_State *L)
{
UINT32 i;
lua_remove(L, 1);
@@ -987,7 +987,7 @@ static int lib_setSfxInfo(lua_State *L)
return 0;
}
static int lib_sfxlen(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_sfxlen(lua_State *L)
{
lua_pushinteger(L, NUMSFX);
return 1;
@@ -1061,7 +1061,7 @@ static int sfxinfo_set(lua_State *L)
return 0;
}
static int sfxinfo_num(lua_State *L)
FUNCINLINE static ATTRINLINE int sfxinfo_num(lua_State *L)
{
sfxinfo_t *sfx = *((sfxinfo_t **)luaL_checkudata(L, 1, META_SFXINFO));
+11 -11
View File
@@ -555,7 +555,7 @@ static int sector_set(lua_State *L)
return 0;
}
static int sector_num(lua_State *L)
FUNCINLINE static ATTRINLINE int sector_num(lua_State *L)
{
sector_t *sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR));
lua_pushinteger(L, sector-sectors);
@@ -594,7 +594,7 @@ static int subsector_get(lua_State *L)
return 0;
}
static int subsector_num(lua_State *L)
FUNCINLINE static ATTRINLINE int subsector_num(lua_State *L)
{
subsector_t *subsector = *((subsector_t **)luaL_checkudata(L, 1, META_SUBSECTOR));
lua_pushinteger(L, subsector-subsectors);
@@ -691,7 +691,7 @@ static int line_get(lua_State *L)
return 0;
}
static int line_num(lua_State *L)
FUNCINLINE static ATTRINLINE int line_num(lua_State *L)
{
line_t *line = *((line_t **)luaL_checkudata(L, 1, META_LINE));
lua_pushinteger(L, line-lines);
@@ -820,7 +820,7 @@ static int side_set(lua_State *L)
return 0;
}
static int side_num(lua_State *L)
FUNCINLINE static ATTRINLINE int side_num(lua_State *L)
{
side_t *side = *((side_t **)luaL_checkudata(L, 1, META_SIDE));
lua_pushinteger(L, side-sides);
@@ -859,7 +859,7 @@ static int vertex_get(lua_State *L)
return 0;
}
static int vertex_num(lua_State *L)
FUNCINLINE static ATTRINLINE int vertex_num(lua_State *L)
{
vertex_t *vertex = *((vertex_t **)luaL_checkudata(L, 1, META_VERTEX));
lua_pushinteger(L, vertex-vertexes);
@@ -906,7 +906,7 @@ static int lib_getSector(lua_State *L)
return 0;
}
static int lib_numsectors(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_numsectors(lua_State *L)
{
lua_pushinteger(L, numsectors);
return 1;
@@ -952,7 +952,7 @@ static int lib_getSubsector(lua_State *L)
return 0;
}
static int lib_numsubsectors(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_numsubsectors(lua_State *L)
{
lua_pushinteger(L, numsubsectors);
return 1;
@@ -998,7 +998,7 @@ static int lib_getLine(lua_State *L)
return 0;
}
static int lib_numlines(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_numlines(lua_State *L)
{
lua_pushinteger(L, numlines);
return 1;
@@ -1044,7 +1044,7 @@ static int lib_getSide(lua_State *L)
return 0;
}
static int lib_numsides(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_numsides(lua_State *L)
{
lua_pushinteger(L, numsides);
return 1;
@@ -1090,7 +1090,7 @@ static int lib_getVertex(lua_State *L)
return 0;
}
static int lib_numvertexes(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_numvertexes(lua_State *L)
{
lua_pushinteger(L, numvertexes);
return 1;
@@ -1454,7 +1454,7 @@ static int lib_getMapheaderinfo(lua_State *L)
return 0;
}
static int lib_nummapheaders(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_nummapheaders(lua_State *L)
{
lua_pushinteger(L, NUMMAPS);
return 1;
+21 -21
View File
@@ -23,14 +23,14 @@
// General math
//////////////////
static int lib_abs(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_abs(lua_State *L)
{
int a = (int)luaL_checkinteger(L, 1);
lua_pushinteger(L, abs(a));
return 1;
}
static int lib_min(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_min(lua_State *L)
{
int a = luaL_checkinteger(L, 1);
int b = luaL_checkinteger(L, 2);
@@ -38,7 +38,7 @@ static int lib_min(lua_State *L)
return 1;
}
static int lib_max(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_max(lua_State *L)
{
int a = luaL_checkinteger(L, 1);
int b = luaL_checkinteger(L, 2);
@@ -49,31 +49,31 @@ static int lib_max(lua_State *L)
// Angle math
////////////////
static int lib_fixedangle(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_fixedangle(lua_State *L)
{
lua_pushangle(L, FixedAngle(luaL_checkfixed(L, 1)));
return 1;
}
static int lib_anglefixed(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_anglefixed(lua_State *L)
{
lua_pushfixed(L, AngleFixed(luaL_checkangle(L, 1)));
return 1;
}
static int lib_invangle(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_invangle(lua_State *L)
{
lua_pushangle(L, InvAngle(luaL_checkangle(L, 1)));
return 1;
}
static int lib_finesine(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_finesine(lua_State *L)
{
lua_pushfixed(L, FINESINE((luaL_checkangle(L, 1)>>ANGLETOFINESHIFT) & FINEMASK));
return 1;
}
static int lib_finecosine(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_finecosine(lua_State *L)
{
lua_pushfixed(L, FINECOSINE((luaL_checkangle(L, 1)>>ANGLETOFINESHIFT) & FINEMASK));
return 1;
@@ -101,19 +101,19 @@ static int lib_finetangent(lua_State *L)
// Fixed math
////////////////
static int lib_fixedmul(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_fixedmul(lua_State *L)
{
lua_pushfixed(L, FixedMul(luaL_checkfixed(L, 1), luaL_checkfixed(L, 2)));
return 1;
}
static int lib_fixedint(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_fixedint(lua_State *L)
{
lua_pushinteger(L, FixedInt(luaL_checkfixed(L, 1)));
return 1;
}
static int lib_fixeddiv(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_fixeddiv(lua_State *L)
{
fixed_t i = luaL_checkfixed(L, 1);
fixed_t j = luaL_checkfixed(L, 2);
@@ -123,13 +123,13 @@ static int lib_fixeddiv(lua_State *L)
return 1;
}
static int lib_fixedrem(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_fixedrem(lua_State *L)
{
lua_pushfixed(L, FixedRem(luaL_checkfixed(L, 1), luaL_checkfixed(L, 2)));
return 1;
}
static int lib_fixedsqrt(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_fixedsqrt(lua_State *L)
{
fixed_t i = luaL_checkfixed(L, 1);
if (i < 0)
@@ -138,31 +138,31 @@ static int lib_fixedsqrt(lua_State *L)
return 1;
}
static int lib_fixedhypot(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_fixedhypot(lua_State *L)
{
lua_pushfixed(L, FixedHypot(luaL_checkfixed(L, 1), luaL_checkfixed(L, 2)));
return 1;
}
static int lib_fixedfloor(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_fixedfloor(lua_State *L)
{
lua_pushfixed(L, FixedFloor(luaL_checkfixed(L, 1)));
return 1;
}
static int lib_fixedtrunc(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_fixedtrunc(lua_State *L)
{
lua_pushfixed(L, FixedTrunc(luaL_checkfixed(L, 1)));
return 1;
}
static int lib_fixedceil(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_fixedceil(lua_State *L)
{
lua_pushfixed(L, FixedCeil(luaL_checkfixed(L, 1)));
return 1;
}
static int lib_fixedround(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_fixedround(lua_State *L)
{
lua_pushfixed(L, FixedRound(luaL_checkfixed(L, 1)));
return 1;
@@ -172,13 +172,13 @@ static int lib_fixedround(lua_State *L)
// (aka extra little funcs that don't quite fit in baselib)
//////////////////////////////////////////////////////////////////
static int lib_getsecspecial(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_getsecspecial(lua_State *L)
{
lua_pushinteger(L, GETSECSPECIAL(luaL_checkinteger(L, 1), luaL_checkinteger(L, 2)));
return 1;
}
static int lib_all7emeralds(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_all7emeralds(lua_State *L)
{
lua_pushboolean(L, ALL7EMERALDS(luaL_checkinteger(L, 1)));
return 1;
@@ -227,4 +227,4 @@ int LUA_MathLib(lua_State *L)
lua_pushvalue(L, LUA_GLOBALSINDEX);
luaL_register(L, NULL, lib);
return 0;
}
}
+1 -1
View File
@@ -964,7 +964,7 @@ static int lib_getMapthing(lua_State *L)
return 0;
}
static int lib_nummapthings(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_nummapthings(lua_State *L)
{
lua_pushinteger(L, nummapthings);
return 1;
+5 -5
View File
@@ -437,7 +437,7 @@ static int lib_getPlayer(lua_State *L)
}
// #players -> MAXPLAYERS
static int lib_lenPlayer(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_lenPlayer(lua_State *L)
{
lua_pushinteger(L, MAXPLAYERS);
return 1;
@@ -521,7 +521,7 @@ static int lib_getDisplayplayers(lua_State *L)
}
// #displayplayers -> MAXSPLITSCREENPLAYERS
static int lib_lenDisplayplayers(lua_State *L)
FUNCINLINE static ATTRINLINE int lib_lenDisplayplayers(lua_State *L)
{
lua_pushinteger(L, MAXSPLITSCREENPLAYERS);
return 1;
@@ -629,7 +629,7 @@ static int player_set(lua_State *L)
#undef NOSET
static int player_num(lua_State *L)
FUNCINLINE static ATTRINLINE int player_num(lua_State *L)
{
player_t *plr = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
if (!plr)
@@ -666,7 +666,7 @@ static int power_set(lua_State *L)
}
// #powers -> NUMPOWERS
static int power_len(lua_State *L)
FUNCINLINE static ATTRINLINE int power_len(lua_State *L)
{
lua_pushinteger(L, NUMPOWERS);
return 1;
@@ -700,7 +700,7 @@ static int kartstuff_set(lua_State *L)
}
// #kartstuff -> NUMKARTSTUFF
static int kartstuff_len(lua_State *L)
FUNCINLINE static ATTRINLINE int kartstuff_len(lua_State *L)
{
lua_pushinteger(L, NUMKARTSTUFF);
return 1;
+2 -2
View File
@@ -32,7 +32,7 @@ struct iterationState {
int next;
};
static int iterationState_gc(lua_State *L)
FUNCINLINE static ATTRINLINE int iterationState_gc(lua_State *L)
{
struct iterationState *it = luaL_checkudata(L, -1, META_ITERATIONSTATE);
if (it->next != LUA_REFNIL)
@@ -130,4 +130,4 @@ int LUA_ThinkerLib(lua_State *L)
lua_setfield(L, -2, "iterate");
lua_setglobal(L, "thinkers");
return 0;
}
}