aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorE. Westbrook <github@westbrook.io>2019-02-25 15:57:01 -0700
committerE. Westbrook <github@westbrook.io>2019-02-25 15:57:01 -0700
commitc0374dd46ff7b3a8c1913ade4a3746873d6060c1 (patch)
tree2a5b36b70b5569ecd2f64d01005cfb1292e007a1
parent16b0026e27d4c77fc5e723d52b811ebc23dddc0c (diff)
downloadluasocket-c0374dd46ff7b3a8c1913ade4a3746873d6060c1.tar.gz
luasocket-c0374dd46ff7b3a8c1913ade4a3746873d6060c1.tar.bz2
luasocket-c0374dd46ff7b3a8c1913ade4a3746873d6060c1.zip
auxiliar.c: use LUASOCKET_PRIVATE
-rw-r--r--src/auxiliar.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/auxiliar.c b/src/auxiliar.c
index 5251549..0bd7927 100644
--- a/src/auxiliar.c
+++ b/src/auxiliar.c
@@ -2,18 +2,18 @@
2* Auxiliar routines for class hierarchy manipulation 2* Auxiliar routines for class hierarchy manipulation
3* LuaSocket toolkit 3* LuaSocket toolkit
4\*=========================================================================*/ 4\*=========================================================================*/
5#include "luasocket.h"
6#include "auxiliar.h"
5#include <string.h> 7#include <string.h>
6#include <stdio.h> 8#include <stdio.h>
7 9
8#include "auxiliar.h"
9
10/*=========================================================================*\ 10/*=========================================================================*\
11* Exported functions 11* Exported functions
12\*=========================================================================*/ 12\*=========================================================================*/
13/*-------------------------------------------------------------------------*\ 13/*-------------------------------------------------------------------------*\
14* Initializes the module 14* Initializes the module
15\*-------------------------------------------------------------------------*/ 15\*-------------------------------------------------------------------------*/
16int auxiliar_open(lua_State *L) { 16LUASOCKET_PRIVATE int auxiliar_open(lua_State *L) {
17 (void) L; 17 (void) L;
18 return 0; 18 return 0;
19} 19}
@@ -22,7 +22,7 @@ int auxiliar_open(lua_State *L) {
22* Creates a new class with given methods 22* Creates a new class with given methods
23* Methods whose names start with __ are passed directly to the metatable. 23* Methods whose names start with __ are passed directly to the metatable.
24\*-------------------------------------------------------------------------*/ 24\*-------------------------------------------------------------------------*/
25void auxiliar_newclass(lua_State *L, const char *classname, luaL_Reg *func) { 25LUASOCKET_PRIVATE void auxiliar_newclass(lua_State *L, const char *classname, luaL_Reg *func) {
26 luaL_newmetatable(L, classname); /* mt */ 26 luaL_newmetatable(L, classname); /* mt */
27 /* create __index table to place methods */ 27 /* create __index table to place methods */
28 lua_pushstring(L, "__index"); /* mt,"__index" */ 28 lua_pushstring(L, "__index"); /* mt,"__index" */
@@ -45,7 +45,7 @@ void auxiliar_newclass(lua_State *L, const char *classname, luaL_Reg *func) {
45/*-------------------------------------------------------------------------*\ 45/*-------------------------------------------------------------------------*\
46* Prints the value of a class in a nice way 46* Prints the value of a class in a nice way
47\*-------------------------------------------------------------------------*/ 47\*-------------------------------------------------------------------------*/
48int auxiliar_tostring(lua_State *L) { 48LUASOCKET_PRIVATE int auxiliar_tostring(lua_State *L) {
49 char buf[32]; 49 char buf[32];
50 if (!lua_getmetatable(L, 1)) goto error; 50 if (!lua_getmetatable(L, 1)) goto error;
51 lua_pushstring(L, "__index"); 51 lua_pushstring(L, "__index");
@@ -66,7 +66,7 @@ error:
66/*-------------------------------------------------------------------------*\ 66/*-------------------------------------------------------------------------*\
67* Insert class into group 67* Insert class into group
68\*-------------------------------------------------------------------------*/ 68\*-------------------------------------------------------------------------*/
69void auxiliar_add2group(lua_State *L, const char *classname, const char *groupname) { 69LUASOCKET_PRIVATE void auxiliar_add2group(lua_State *L, const char *classname, const char *groupname) {
70 luaL_getmetatable(L, classname); 70 luaL_getmetatable(L, classname);
71 lua_pushstring(L, groupname); 71 lua_pushstring(L, groupname);
72 lua_pushboolean(L, 1); 72 lua_pushboolean(L, 1);
@@ -77,7 +77,7 @@ void auxiliar_add2group(lua_State *L, const char *classname, const char *groupna
77/*-------------------------------------------------------------------------*\ 77/*-------------------------------------------------------------------------*\
78* Make sure argument is a boolean 78* Make sure argument is a boolean
79\*-------------------------------------------------------------------------*/ 79\*-------------------------------------------------------------------------*/
80int auxiliar_checkboolean(lua_State *L, int objidx) { 80LUASOCKET_PRIVATE int auxiliar_checkboolean(lua_State *L, int objidx) {
81 if (!lua_isboolean(L, objidx)) 81 if (!lua_isboolean(L, objidx))
82 auxiliar_typeerror(L, objidx, lua_typename(L, LUA_TBOOLEAN)); 82 auxiliar_typeerror(L, objidx, lua_typename(L, LUA_TBOOLEAN));
83 return lua_toboolean(L, objidx); 83 return lua_toboolean(L, objidx);
@@ -87,7 +87,7 @@ int auxiliar_checkboolean(lua_State *L, int objidx) {
87* Return userdata pointer if object belongs to a given class, abort with 87* Return userdata pointer if object belongs to a given class, abort with
88* error otherwise 88* error otherwise
89\*-------------------------------------------------------------------------*/ 89\*-------------------------------------------------------------------------*/
90void *auxiliar_checkclass(lua_State *L, const char *classname, int objidx) { 90LUASOCKET_PRIVATE void *auxiliar_checkclass(lua_State *L, const char *classname, int objidx) {
91 void *data = auxiliar_getclassudata(L, classname, objidx); 91 void *data = auxiliar_getclassudata(L, classname, objidx);
92 if (!data) { 92 if (!data) {
93 char msg[45]; 93 char msg[45];
@@ -101,7 +101,7 @@ void *auxiliar_checkclass(lua_State *L, const char *classname, int objidx) {
101* Return userdata pointer if object belongs to a given group, abort with 101* Return userdata pointer if object belongs to a given group, abort with
102* error otherwise 102* error otherwise
103\*-------------------------------------------------------------------------*/ 103\*-------------------------------------------------------------------------*/
104void *auxiliar_checkgroup(lua_State *L, const char *groupname, int objidx) { 104LUASOCKET_PRIVATE void *auxiliar_checkgroup(lua_State *L, const char *groupname, int objidx) {
105 void *data = auxiliar_getgroupudata(L, groupname, objidx); 105 void *data = auxiliar_getgroupudata(L, groupname, objidx);
106 if (!data) { 106 if (!data) {
107 char msg[45]; 107 char msg[45];
@@ -114,7 +114,7 @@ void *auxiliar_checkgroup(lua_State *L, const char *groupname, int objidx) {
114/*-------------------------------------------------------------------------*\ 114/*-------------------------------------------------------------------------*\
115* Set object class 115* Set object class
116\*-------------------------------------------------------------------------*/ 116\*-------------------------------------------------------------------------*/
117void auxiliar_setclass(lua_State *L, const char *classname, int objidx) { 117LUASOCKET_PRIVATE void auxiliar_setclass(lua_State *L, const char *classname, int objidx) {
118 luaL_getmetatable(L, classname); 118 luaL_getmetatable(L, classname);
119 if (objidx < 0) objidx--; 119 if (objidx < 0) objidx--;
120 lua_setmetatable(L, objidx); 120 lua_setmetatable(L, objidx);
@@ -124,7 +124,7 @@ void auxiliar_setclass(lua_State *L, const char *classname, int objidx) {
124* Get a userdata pointer if object belongs to a given group. Return NULL 124* Get a userdata pointer if object belongs to a given group. Return NULL
125* otherwise 125* otherwise
126\*-------------------------------------------------------------------------*/ 126\*-------------------------------------------------------------------------*/
127void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx) { 127LUASOCKET_PRIVATE void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx) {
128 if (!lua_getmetatable(L, objidx)) 128 if (!lua_getmetatable(L, objidx))
129 return NULL; 129 return NULL;
130 lua_pushstring(L, groupname); 130 lua_pushstring(L, groupname);
@@ -142,7 +142,7 @@ void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx) {
142* Get a userdata pointer if object belongs to a given class. Return NULL 142* Get a userdata pointer if object belongs to a given class. Return NULL
143* otherwise 143* otherwise
144\*-------------------------------------------------------------------------*/ 144\*-------------------------------------------------------------------------*/
145void *auxiliar_getclassudata(lua_State *L, const char *classname, int objidx) { 145LUASOCKET_PRIVATE void *auxiliar_getclassudata(lua_State *L, const char *classname, int objidx) {
146 return luaL_testudata(L, objidx, classname); 146 return luaL_testudata(L, objidx, classname);
147} 147}
148 148
@@ -150,7 +150,7 @@ void *auxiliar_getclassudata(lua_State *L, const char *classname, int objidx) {
150* Throws error when argument does not have correct type. 150* Throws error when argument does not have correct type.
151* Used to be part of lauxlib in Lua 5.1, was dropped from 5.2. 151* Used to be part of lauxlib in Lua 5.1, was dropped from 5.2.
152\*-------------------------------------------------------------------------*/ 152\*-------------------------------------------------------------------------*/
153int auxiliar_typeerror (lua_State *L, int narg, const char *tname) { 153LUASOCKET_PRIVATE int auxiliar_typeerror (lua_State *L, int narg, const char *tname) {
154 const char *msg = lua_pushfstring(L, "%s expected, got %s", tname, 154 const char *msg = lua_pushfstring(L, "%s expected, got %s", tname,
155 luaL_typename(L, narg)); 155 luaL_typename(L, narg));
156 return luaL_argerror(L, narg, msg); 156 return luaL_argerror(L, narg, msg);