mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-12-26 04:28:20 +01:00
auxiliar: pragma visibility
This commit is contained in:
parent
2af4872a40
commit
98800e9129
@ -7,13 +7,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
/*=========================================================================*\
|
|
||||||
* Exported functions
|
|
||||||
\*=========================================================================*/
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Initializes the module
|
* Initializes the module
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
LUASOCKET_PRIVATE int auxiliar_open(lua_State *L) {
|
int auxiliar_open(lua_State *L) {
|
||||||
(void) L;
|
(void) L;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -22,7 +19,7 @@ LUASOCKET_PRIVATE int auxiliar_open(lua_State *L) {
|
|||||||
* Creates a new class with given methods
|
* Creates a new class with given methods
|
||||||
* Methods whose names start with __ are passed directly to the metatable.
|
* 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 */
|
luaL_newmetatable(L, classname); /* mt */
|
||||||
/* create __index table to place methods */
|
/* create __index table to place methods */
|
||||||
lua_pushstring(L, "__index"); /* mt,"__index" */
|
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
|
* 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];
|
char buf[32];
|
||||||
if (!lua_getmetatable(L, 1)) goto error;
|
if (!lua_getmetatable(L, 1)) goto error;
|
||||||
lua_pushstring(L, "__index");
|
lua_pushstring(L, "__index");
|
||||||
@ -66,7 +63,7 @@ error:
|
|||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Insert class into group
|
* 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);
|
luaL_getmetatable(L, classname);
|
||||||
lua_pushstring(L, groupname);
|
lua_pushstring(L, groupname);
|
||||||
lua_pushboolean(L, 1);
|
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
|
* 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))
|
if (!lua_isboolean(L, objidx))
|
||||||
auxiliar_typeerror(L, objidx, lua_typename(L, LUA_TBOOLEAN));
|
auxiliar_typeerror(L, objidx, lua_typename(L, LUA_TBOOLEAN));
|
||||||
return lua_toboolean(L, objidx);
|
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
|
* Return userdata pointer if object belongs to a given class, abort with
|
||||||
* error otherwise
|
* 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);
|
void *data = auxiliar_getclassudata(L, classname, objidx);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
char msg[45];
|
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
|
* Return userdata pointer if object belongs to a given group, abort with
|
||||||
* error otherwise
|
* 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);
|
void *data = auxiliar_getgroupudata(L, groupname, objidx);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
char msg[45];
|
char msg[45];
|
||||||
@ -114,7 +111,7 @@ LUASOCKET_PRIVATE void *auxiliar_checkgroup(lua_State *L, const char *groupname,
|
|||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Set object class
|
* 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);
|
luaL_getmetatable(L, classname);
|
||||||
if (objidx < 0) objidx--;
|
if (objidx < 0) objidx--;
|
||||||
lua_setmetatable(L, 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
|
* Get a userdata pointer if object belongs to a given group. Return NULL
|
||||||
* otherwise
|
* 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))
|
if (!lua_getmetatable(L, objidx))
|
||||||
return NULL;
|
return NULL;
|
||||||
lua_pushstring(L, groupname);
|
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
|
* Get a userdata pointer if object belongs to a given class. Return NULL
|
||||||
* otherwise
|
* 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);
|
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.
|
* Throws error when argument does not have correct type.
|
||||||
* Used to be part of lauxlib in Lua 5.1, was dropped from 5.2.
|
* 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,
|
const char *msg = lua_pushfstring(L, "%s expected, got %s", tname,
|
||||||
luaL_typename(L, narg));
|
luaL_typename(L, narg));
|
||||||
return luaL_argerror(L, narg, msg);
|
return luaL_argerror(L, narg, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,20 +29,22 @@
|
|||||||
* reverse mapping are done using lauxlib.
|
* reverse mapping are done using lauxlib.
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
|
|
||||||
#include "lua.h"
|
#include "luasocket.h"
|
||||||
#include "lauxlib.h"
|
|
||||||
#include "compat.h"
|
#pragma GCC visibility push(hidden)
|
||||||
|
|
||||||
int auxiliar_open(lua_State *L);
|
int auxiliar_open(lua_State *L);
|
||||||
void auxiliar_newclass(lua_State *L, const char *classname, luaL_Reg *func);
|
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_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_checkclass(lua_State *L, const char *classname, int objidx);
|
||||||
void *auxiliar_checkgroup(lua_State *L, const char *groupname, 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);
|
void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx);
|
||||||
int auxiliar_checkboolean(lua_State *L, int objidx);
|
void *auxiliar_getclassudata(lua_State *L, const char *groupname, int objidx);
|
||||||
int auxiliar_tostring(lua_State *L);
|
|
||||||
int auxiliar_typeerror(lua_State *L, int narg, const char *tname);
|
int auxiliar_typeerror(lua_State *L, int narg, const char *tname);
|
||||||
|
|
||||||
|
#pragma GCC visibility pop
|
||||||
|
|
||||||
#endif /* AUXILIAR_H */
|
#endif /* AUXILIAR_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user