add yaml serialization library
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
/// int l_function_name(lua::State* L);
|
||||
|
||||
// Libraries
|
||||
extern const luaL_Reg applib[];
|
||||
extern const luaL_Reg audiolib[];
|
||||
extern const luaL_Reg base64lib[];
|
||||
extern const luaL_Reg bjsonlib[];
|
||||
@@ -38,7 +39,6 @@ extern const luaL_Reg packlib[];
|
||||
extern const luaL_Reg particleslib[]; // gfx.particles
|
||||
extern const luaL_Reg playerlib[];
|
||||
extern const luaL_Reg quatlib[];
|
||||
extern const luaL_Reg applib[];
|
||||
extern const luaL_Reg text3dlib[]; // gfx.text3d
|
||||
extern const luaL_Reg timelib[];
|
||||
extern const luaL_Reg tomllib[];
|
||||
@@ -48,6 +48,7 @@ extern const luaL_Reg vec3lib[]; // vecn.cpp
|
||||
extern const luaL_Reg vec4lib[]; // vecn.cpp
|
||||
extern const luaL_Reg weatherlib[];
|
||||
extern const luaL_Reg worldlib[];
|
||||
extern const luaL_Reg yamllib[];
|
||||
|
||||
// Components
|
||||
extern const luaL_Reg skeletonlib[];
|
||||
|
||||
@@ -19,4 +19,5 @@ static int l_json_parse(lua::State* L) {
|
||||
const luaL_Reg jsonlib[] = {
|
||||
{"tostring", lua::wrap<l_json_stringify>},
|
||||
{"parse", lua::wrap<l_json_parse>},
|
||||
{NULL, NULL}};
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#include "coders/yaml.hpp"
|
||||
#include "api_lua.hpp"
|
||||
|
||||
static int l_stringify(lua::State* L) {
|
||||
auto value = lua::tovalue(L, 1);
|
||||
auto string = yaml::stringify(value);
|
||||
return lua::pushstring(L, string);
|
||||
}
|
||||
|
||||
static int l_parse(lua::State* L) {
|
||||
auto string = lua::require_string(L, 1);
|
||||
auto element = yaml::parse("[string]", string);
|
||||
return lua::pushvalue(L, element);
|
||||
}
|
||||
|
||||
const luaL_Reg yamllib[] = {
|
||||
{"tostring", lua::wrap<l_stringify>},
|
||||
{"parse", lua::wrap<l_parse>},
|
||||
{NULL, NULL}
|
||||
};
|
||||
Reference in New Issue
Block a user