1#ifndef AUXILIAR_H
2#define AUXILIAR_H
3/*=========================================================================*\
4* Auxiliar routines for class hierarchy manipulation
5* LuaSocket toolkit (but completely independent of other LuaSocket modules)
6*
7* A LuaSocket class is a name associated with Lua metatables. A LuaSocket
8* group is a name associated with a class. A class can belong to any number
9* of groups. This module provides the functionality to:
10*
11* - create new classes
12* - add classes to groups
13* - set the class of objects
14* - check if an object belongs to a given class or group
15* - get the userdata associated to objects
16* - print objects in a pretty way
17*
18* LuaSocket class names follow the convention <module>{<class>}. Modules
19* can define any number of classes and groups. The module tcp.c, for
20* example, defines the classes tcp{master}, tcp{client} and tcp{server} and
21* the groups tcp{client,server} and tcp{any}. Module functions can then
22* perform type-checking on their arguments by either class or group.
23*
24* LuaSocket metatables define the __index metamethod as being a table. This
25* table has one field for each method supported by the class, and a field
26* "class" with the class name.
27*
28* The mapping from class name to the corresponding metatable and the
29* reverse mapping are done using lauxlib.
30\*=========================================================================*/
31
32#include "lua.h"
33#include "lauxlib.h"
34#include "compat.h"
35
36int auxiliar_open(lua_State *L);
37void auxiliar_newclass(lua_State *L, const char *classname, luaL_Reg *func);
38void auxiliar_add2group(lua_State *L, const char *classname, const char *group);
39void auxiliar_setclass(lua_State *L, const char *classname, int objidx);
40void *auxiliar_checkclass(lua_State *L, const char *classname, int objidx);
41void *auxiliar_checkgroup(lua_State *L, const char *groupname, int objidx);
42void *auxiliar_getclassudata(lua_State *L, const char *groupname, int objidx);
43void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx);
44int auxiliar_checkboolean(lua_State *L, int objidx);
45int auxiliar_tostring(lua_State *L);
46int auxiliar_typeerror(lua_State *L, int narg, const char *tname);
47
48#endif /* AUXILIAR_H */
49