/* Copyright (c) 2014, Vsevolod Stakhov1* All rights reserved.2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions are met:5* * Redistributions of source code must retain the above copyright6* notice, this list of conditions and the following disclaimer.7* * Redistributions in binary form must reproduce the above copyright8* notice, this list of conditions and the following disclaimer in the9* documentation and/or other materials provided with the distribution.10*11* THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY12* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED13* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE14* DISCLAIMED. IN NO EVENT SHALL AUTHOR BE LIABLE FOR ANY15* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES16* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;17* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND18* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT19* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS20* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.21*/22#ifndef LUA_UCL_H_23#define LUA_UCL_H_2425#ifdef HAVE_CONFIG_H26#include "config.h"27#endif2829#include <lua.h>30#include <lauxlib.h>31#include <lualib.h>32#include "ucl.h"3334/**35* Closure structure for lua function storing inside UCL36*/37struct ucl_lua_funcdata {38lua_State *L;39int idx;40char *ret;41};4243/**44* Initialize lua UCL API45*/46UCL_EXTERN int luaopen_ucl (lua_State *L);4748/**49* Import UCL object from lua state50* @param L lua state51* @param idx index of object at the lua stack to convert to UCL52* @return new UCL object or NULL, the caller should unref object after using53*/54UCL_EXTERN ucl_object_t* ucl_object_lua_import (lua_State *L, int idx);5556/**57* Import UCL object from lua state, escaping JSON strings58* @param L lua state59* @param idx index of object at the lua stack to convert to UCL60* @return new UCL object or NULL, the caller should unref object after using61*/62UCL_EXTERN ucl_object_t* ucl_object_lua_import_escape (lua_State *L, int idx);6364/**65* Push an object to lua66* @param L lua state67* @param obj object to push68* @param allow_array traverse over implicit arrays69*/70UCL_EXTERN int ucl_object_push_lua (lua_State *L,71const ucl_object_t *obj, bool allow_array);72/**73* Push an object to lua replacing all ucl.null with `false`74* @param L lua state75* @param obj object to push76* @param allow_array traverse over implicit arrays77*/78UCL_EXTERN int ucl_object_push_lua_filter_nil (lua_State *L,79const ucl_object_t *obj,80bool allow_array);8182UCL_EXTERN struct ucl_lua_funcdata* ucl_object_toclosure (const ucl_object_t *obj);8384#endif /* LUA_UCL_H_ */858687