From 98800e9129a63e8d0f751108d79efdffe58e98f7 Mon Sep 17 00:00:00 2001 From: "E. Westbrook" Date: Wed, 27 Feb 2019 20:55:43 -0700 Subject: [PATCH] auxiliar: pragma visibility --- src/auxiliar.c | 26 +++++++++++--------------- src/auxiliar.h | 16 +++++++++------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/auxiliar.c b/src/auxiliar.c index 0bd7927..93a66a0 100644 --- a/src/auxiliar.c +++ b/src/auxiliar.c @@ -7,13 +7,10 @@ #include #include -/*=========================================================================*\ -* Exported functions -\*=========================================================================*/ /*-------------------------------------------------------------------------*\ * Initializes the module \*-------------------------------------------------------------------------*/ -LUASOCKET_PRIVATE int auxiliar_open(lua_State *L) { +int auxiliar_open(lua_State *L) { (void) L; return 0; } @@ -22,7 +19,7 @@ LUASOCKET_PRIVATE int auxiliar_open(lua_State *L) { * Creates a new class with given methods * Methods whose names start with __ are passed directly to the metatable. \*-------------------------------------------------------------------------*/ -LUASOCKET_PRIVATE void auxiliar_newclass(lua_State *L, const char *classname, luaL_Reg *func) { +void auxiliar_newclass(lua_State *L, const char *classname, luaL_Reg *func) { luaL_newmetatable(L, classname); /* mt */ /* create __index table to place methods */ lua_pushstring(L, "__index"); /* mt,"__index" */ @@ -45,7 +42,7 @@ LUASOCKET_PRIVATE void auxiliar_newclass(lua_State *L, const char *classname, lu /*-------------------------------------------------------------------------*\ * Prints the value of a class in a nice way \*-------------------------------------------------------------------------*/ -LUASOCKET_PRIVATE int auxiliar_tostring(lua_State *L) { +int auxiliar_tostring(lua_State *L) { char buf[32]; if (!lua_getmetatable(L, 1)) goto error; lua_pushstring(L, "__index"); @@ -66,7 +63,7 @@ error: /*-------------------------------------------------------------------------*\ * Insert class into group \*-------------------------------------------------------------------------*/ -LUASOCKET_PRIVATE void auxiliar_add2group(lua_State *L, const char *classname, const char *groupname) { +void auxiliar_add2group(lua_State *L, const char *classname, const char *groupname) { luaL_getmetatable(L, classname); lua_pushstring(L, groupname); lua_pushboolean(L, 1); @@ -77,7 +74,7 @@ LUASOCKET_PRIVATE void auxiliar_add2group(lua_State *L, const char *classname, c /*-------------------------------------------------------------------------*\ * Make sure argument is a boolean \*-------------------------------------------------------------------------*/ -LUASOCKET_PRIVATE int auxiliar_checkboolean(lua_State *L, int objidx) { +int auxiliar_checkboolean(lua_State *L, int objidx) { if (!lua_isboolean(L, objidx)) auxiliar_typeerror(L, objidx, lua_typename(L, LUA_TBOOLEAN)); return lua_toboolean(L, objidx); @@ -87,7 +84,7 @@ LUASOCKET_PRIVATE int auxiliar_checkboolean(lua_State *L, int objidx) { * Return userdata pointer if object belongs to a given class, abort with * error otherwise \*-------------------------------------------------------------------------*/ -LUASOCKET_PRIVATE void *auxiliar_checkclass(lua_State *L, const char *classname, int objidx) { +void *auxiliar_checkclass(lua_State *L, const char *classname, int objidx) { void *data = auxiliar_getclassudata(L, classname, objidx); if (!data) { char msg[45]; @@ -101,7 +98,7 @@ LUASOCKET_PRIVATE void *auxiliar_checkclass(lua_State *L, const char *classname, * Return userdata pointer if object belongs to a given group, abort with * error otherwise \*-------------------------------------------------------------------------*/ -LUASOCKET_PRIVATE void *auxiliar_checkgroup(lua_State *L, const char *groupname, int objidx) { +void *auxiliar_checkgroup(lua_State *L, const char *groupname, int objidx) { void *data = auxiliar_getgroupudata(L, groupname, objidx); if (!data) { char msg[45]; @@ -114,7 +111,7 @@ LUASOCKET_PRIVATE void *auxiliar_checkgroup(lua_State *L, const char *groupname, /*-------------------------------------------------------------------------*\ * Set object class \*-------------------------------------------------------------------------*/ -LUASOCKET_PRIVATE void auxiliar_setclass(lua_State *L, const char *classname, int objidx) { +void auxiliar_setclass(lua_State *L, const char *classname, int objidx) { luaL_getmetatable(L, classname); if (objidx < 0) objidx--; lua_setmetatable(L, objidx); @@ -124,7 +121,7 @@ LUASOCKET_PRIVATE void auxiliar_setclass(lua_State *L, const char *classname, in * Get a userdata pointer if object belongs to a given group. Return NULL * otherwise \*-------------------------------------------------------------------------*/ -LUASOCKET_PRIVATE void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx) { +void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx) { if (!lua_getmetatable(L, objidx)) return NULL; lua_pushstring(L, groupname); @@ -142,7 +139,7 @@ LUASOCKET_PRIVATE void *auxiliar_getgroupudata(lua_State *L, const char *groupna * Get a userdata pointer if object belongs to a given class. Return NULL * otherwise \*-------------------------------------------------------------------------*/ -LUASOCKET_PRIVATE void *auxiliar_getclassudata(lua_State *L, const char *classname, int objidx) { +void *auxiliar_getclassudata(lua_State *L, const char *classname, int objidx) { return luaL_testudata(L, objidx, classname); } @@ -150,9 +147,8 @@ LUASOCKET_PRIVATE void *auxiliar_getclassudata(lua_State *L, const char *classna * Throws error when argument does not have correct type. * Used to be part of lauxlib in Lua 5.1, was dropped from 5.2. \*-------------------------------------------------------------------------*/ -LUASOCKET_PRIVATE int auxiliar_typeerror (lua_State *L, int narg, const char *tname) { +int auxiliar_typeerror (lua_State *L, int narg, const char *tname) { const char *msg = lua_pushfstring(L, "%s expected, got %s", tname, luaL_typename(L, narg)); return luaL_argerror(L, narg, msg); } - diff --git a/src/auxiliar.h b/src/auxiliar.h index 65511d4..234b00a 100644 --- a/src/auxiliar.h +++ b/src/auxiliar.h @@ -29,20 +29,22 @@ * reverse mapping are done using lauxlib. \*=========================================================================*/ -#include "lua.h" -#include "lauxlib.h" -#include "compat.h" +#include "luasocket.h" + +#pragma GCC visibility push(hidden) int auxiliar_open(lua_State *L); void auxiliar_newclass(lua_State *L, const char *classname, luaL_Reg *func); +int auxiliar_tostring(lua_State *L); void auxiliar_add2group(lua_State *L, const char *classname, const char *group); -void auxiliar_setclass(lua_State *L, const char *classname, int objidx); +int auxiliar_checkboolean(lua_State *L, int objidx); void *auxiliar_checkclass(lua_State *L, const char *classname, int objidx); void *auxiliar_checkgroup(lua_State *L, const char *groupname, int objidx); -void *auxiliar_getclassudata(lua_State *L, const char *groupname, int objidx); +void auxiliar_setclass(lua_State *L, const char *classname, int objidx); void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx); -int auxiliar_checkboolean(lua_State *L, int objidx); -int auxiliar_tostring(lua_State *L); +void *auxiliar_getclassudata(lua_State *L, const char *groupname, int objidx); int auxiliar_typeerror(lua_State *L, int narg, const char *tname); +#pragma GCC visibility pop + #endif /* AUXILIAR_H */