auxiliar.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #include "lua.h"
  32. #include "lauxlib.h"
  33. int auxiliar_open(lua_State *L);
  34. void auxiliar_newclass(lua_State *L, const char *classname, luaL_Reg *func);
  35. void auxiliar_add2group(lua_State *L, const char *classname, const char *group);
  36. void auxiliar_setclass(lua_State *L, const char *classname, int objidx);
  37. void *auxiliar_checkclass(lua_State *L, const char *classname, int objidx);
  38. void *auxiliar_checkgroup(lua_State *L, const char *groupname, int objidx);
  39. void *auxiliar_getclassudata(lua_State *L, const char *groupname, int objidx);
  40. void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx);
  41. int auxiliar_checkboolean(lua_State *L, int objidx);
  42. int auxiliar_tostring(lua_State *L);
  43. int auxiliar_typeerror(lua_State *L, int narg, const char *tname);
  44. #endif /* AUXILIAR_H */