2 * strut.c - strut management
4 * Copyright © 2009 Julien Danjou <julien@danjou.info>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 /** Push a strut type to a table on stack.
26 * \param L The Lua VM state.
27 * \param strut The strut to push.
28 * \return The number of elements pushed on stack.
31 luaA_pushstrut(lua_State
*L
, strut_t strut
)
33 lua_createtable(L
, 4, 0);
34 lua_pushnumber(L
, strut
.left
);
35 lua_setfield(L
, -2, "left");
36 lua_pushnumber(L
, strut
.right
);
37 lua_setfield(L
, -2, "right");
38 lua_pushnumber(L
, strut
.top
);
39 lua_setfield(L
, -2, "top");
40 lua_pushnumber(L
, strut
.bottom
);
41 lua_setfield(L
, -2, "bottom");
45 /** Convert a table to a strut_t structure.
46 * \param L The Lua VM state.
47 * \param idx The index of the table on the stack.
48 * \param strut The strut to fill. Current values will be used as default.
51 luaA_tostrut(lua_State
*L
, int idx
, strut_t
*strut
)
53 luaA_checktable(L
, idx
);
54 strut
->left
= luaA_getopt_number(L
, idx
, "left", strut
->left
);
55 strut
->right
= luaA_getopt_number(L
, idx
, "right", strut
->right
);
56 strut
->top
= luaA_getopt_number(L
, idx
, "top", strut
->top
);
57 strut
->bottom
= luaA_getopt_number(L
, idx
, "bottom", strut
->bottom
);
60 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80