Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

lua_ucl.h 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* Copyright (c) 2014, Vsevolod Stakhov
  2. * All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. * * Redistributions of source code must retain the above copyright
  7. * notice, this list of conditions and the following disclaimer.
  8. * * Redistributions in binary form must reproduce the above copyright
  9. * notice, this list of conditions and the following disclaimer in the
  10. * documentation and/or other materials provided with the distribution.
  11. *
  12. * THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY
  13. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  14. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  15. * DISCLAIMED. IN NO EVENT SHALL AUTHOR BE LIABLE FOR ANY
  16. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  17. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  18. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  20. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  21. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. */
  23. #ifndef LUA_UCL_H_
  24. #define LUA_UCL_H_
  25. #ifdef HAVE_CONFIG_H
  26. #include "config.h"
  27. #endif
  28. #include <lua.h>
  29. #include <lauxlib.h>
  30. #include <lualib.h>
  31. #include "ucl.h"
  32. /**
  33. * Closure structure for lua function storing inside UCL
  34. */
  35. struct ucl_lua_funcdata {
  36. lua_State *L;
  37. int idx;
  38. char *ret;
  39. };
  40. /**
  41. * Initialize lua UCL API
  42. */
  43. UCL_EXTERN int luaopen_ucl (lua_State *L);
  44. /**
  45. * Import UCL object from lua state
  46. * @param L lua state
  47. * @param idx index of object at the lua stack to convert to UCL
  48. * @return new UCL object or NULL, the caller should unref object after using
  49. */
  50. UCL_EXTERN ucl_object_t* ucl_object_lua_import (lua_State *L, int idx);
  51. /**
  52. * Push an object to lua
  53. * @param L lua state
  54. * @param obj object to push
  55. * @param allow_array traverse over implicit arrays
  56. */
  57. UCL_EXTERN int ucl_object_push_lua (lua_State *L,
  58. const ucl_object_t *obj, bool allow_array);
  59. UCL_EXTERN struct ucl_lua_funcdata* ucl_object_toclosure (
  60. const ucl_object_t *obj);
  61. #endif /* LUA_UCL_H_ */