auxiliar: pragma visibility

This commit is contained in:
E. Westbrook 2019-02-27 20:55:43 -07:00
parent 2af4872a40
commit 98800e9129
2 changed files with 20 additions and 22 deletions

View File

@ -7,13 +7,10 @@
#include <string.h>
#include <stdio.h>
/*=========================================================================*\
* 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);
}

View File

@ -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 */