return *((ucl_object_t **) luaL_checkudata(L, index, OBJECT_META));
}
-static void
-lua_ucl_push_opaque(lua_State *L, const ucl_object_t *obj)
+void ucl_object_push_lua_unwrapped(lua_State *L, const ucl_object_t *obj)
{
ucl_object_t **pobj;
obj = ucl_parser_get_object(parser);
if (obj != NULL) {
- lua_ucl_push_opaque(L, obj);
+ ucl_object_push_lua_unwrapped(L, obj);
ucl_object_unref(obj);
}
else {
lua_pushnil(L);
if (ext_refs) {
- lua_ucl_push_opaque(L, ext_refs);
+ ucl_object_push_lua_unwrapped(L, ext_refs);
ucl_object_unref(ext_refs);
}
}
lua_pushfstring(L, "validation error: %s", err.msg);
if (ext_refs) {
- lua_ucl_push_opaque(L, ext_refs);
+ ucl_object_push_lua_unwrapped(L, ext_refs);
ucl_object_unref(ext_refs);
}
}
lua_pushfstring(L, "cannot find the requested path: %s", path);
if (ext_refs) {
- lua_ucl_push_opaque(L, ext_refs);
+ ucl_object_push_lua_unwrapped(L, ext_refs);
ucl_object_unref(ext_refs);
}
}
elt = ucl_object_lookup_len(obj, key, strlen(key));
if (elt) {
- lua_ucl_push_opaque(L, elt);
+ ucl_object_push_lua_unwrapped(L, elt);
}
else {
lua_pushnil(L);
elt = ucl_array_find_index(obj, idx);
if (elt) {
- lua_ucl_push_opaque(L, elt);
+ ucl_object_push_lua_unwrapped(L, elt);
}
else {
lua_pushnil(L);
lua_pushnumber(L, -1);
}
}
- lua_ucl_push_opaque(L, cur);
+ ucl_object_push_lua_unwrapped(L, cur);
return 2;
}
/*
- * Copyright 2023 Vsevolod Stakhov
+ * Copyright 2024 Vsevolod Stakhov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
UCL_EXTERN int ucl_object_push_lua(lua_State *L,
const ucl_object_t *obj, bool allow_array);
+
+/**
+ * Push an object to lua as userdata object (handling one refcount)
+ * @param L
+ * @param obj
+ */
+UCL_EXTERN void ucl_object_push_lua_unwrapped(lua_State *L, const ucl_object_t *obj);
/**
* Push an object to lua replacing all ucl.null with `false`
* @param L lua state