#ifndef LYAML_H
#define LYAML_H 1
#include <yaml.h>
#include <lua.h>
#include <lauxlib.h>
#include "lyaml.h"
#if LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503 || LUA_VERSION_NUM == 504
# define lua_objlen lua_rawlen
# define lua_strlen lua_rawlen
# define luaL_openlib(L,n,l,nup) luaL_setfuncs((L),(l),(nup))
# define luaL_register(L,n,l) (luaL_newlib(L,l))
#endif
#ifndef STREQ
#define STREQ !strcmp
#endif
#ifndef STRNEQ
#define STRNEQ strcmp
#endif
#define lua_pushyamlstr(_s) lua_pushstring (L, (char *)(_s))
#define RAWSET_BOOLEAN(_k, _v) \
lua_pushyamlstr (_k); \
lua_pushboolean (L, (_v) != 0); \
lua_rawset (L, -3)
#define RAWSET_INTEGER(_k, _v) \
lua_pushyamlstr (_k); \
lua_pushinteger (L, (_v)); \
lua_rawset (L, -3)
#define RAWSET_STRING(_k, _v) \
lua_pushyamlstr (_k); \
lua_pushyamlstr (_v); \
lua_rawset (L, -3)
#define RAWSET_EVENTF(_k) \
lua_pushstring (L, #_k); \
lua_pushyamlstr (EVENTF(_k)); \
lua_rawset (L, -3)
#define RAWGET_BOOLEAN(_k) \
lua_pushstring (L, #_k); \
lua_rawget (L, -2); \
if (!lua_isnil (L, -1)) { \
_k = lua_toboolean (L, -1); \
} \
lua_pop (L, 1)
#define RAWGET_INTEGER(_k) \
lua_pushstring (L, #_k); \
lua_rawget (L, -2); \
if (!lua_isnil (L, -1)) { \
_k = lua_tointeger (L, -1); \
} \
lua_pop (L, 1)
#define RAWGET_STRING(_k) \
lua_pushstring (L, #_k); \
lua_rawget (L, -2); \
if (!lua_isnil (L, -1)) { \
_k = lua_tostring (L, -1); \
} else { _k = NULL; }
#define RAWGET_STRDUP(_k) \
lua_pushstring (L, #_k); \
lua_rawget (L, -2); \
if (!lua_isnil (L, -1)) { \
_k = strdup (lua_tostring (L, -1)); \
} else { _k = NULL; }
#define RAWGET_YAML_CHARP(_k) \
lua_pushstring (L, #_k); \
lua_rawget (L, -2); \
if (!lua_isnil (L, -1)) { \
_k = (yaml_char_t *) lua_tostring (L, -1); \
} else { _k = NULL; }
#define RAWGETS_INTEGER(_v, _s) \
lua_pushstring (L, _s); \
lua_rawget (L, -2); \
if (!lua_isnil (L, -1)) { \
_v = lua_tointeger (L, -1); \
} \
lua_pop (L, 1)
#define RAWGETS_STRDUP( _v, _s) \
lua_pushstring (L, _s); \
lua_rawget (L, -2); \
if (!lua_isnil (L, -1)) { \
_v = (yaml_char_t *) strdup (lua_tostring (L, -1)); \
} else { _v = NULL; }
#define RAWGET_PUSHTABLE(_k) \
lua_pushstring (L, _k); \
lua_rawget (L, -2); \
if ((lua_type (L, -1) != LUA_TTABLE) && !lua_isnil (L, -1)) { \
lua_pop (L, 1); \
return luaL_error (L, "%s must be a table", _k); \
}
#define ERROR_IFNIL(_err) \
if (lua_isnil (L, -1)) { \
emitter->error++; \
luaL_addstring (&emitter->errbuff, _err); \
}
extern int Pemitter (lua_State *L);
extern void parser_init (lua_State *L);
extern int Pparser (lua_State *L);
extern void scanner_init (lua_State *L);
extern int Pscanner (lua_State *L);
#endif