Freeciv-3.2
Loading...
Searching...
No Matches
api_specenum.c
Go to the documentation of this file.
1/*****************************************************************************
2 Freeciv - Copyright (C) 2010 - The Freeciv Project
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12*****************************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* dependencies/lua */
19#include "lua.h"
20
21/* utilit */
22#include "log.h"
23
24#include "api_specenum.h"
25
26/**********************************************************************/
31{
32 /* Insert a module table in the global environment,
33 * or reuse any preexisting table */
35 if (lua_isnil(L, -1)) {
37 lua_pushvalue(L, -1);
39 }
41 /* Create a metatable */
42 lua_newtable(L); /* stack: module mt */
43 lua_pushliteral(L, "__index");
44 lua_pushcfunction(L, findex); /* stack: module mt '__index' index */
45 lua_rawset(L, -3); /* stack: module mt */
46 lua_setmetatable(L, -2); /* stack: module */
47 lua_pop(L, 1);
48}
void api_specenum_create_table(lua_State *L, const char *name, lua_CFunction findex)
char * incite_cost
Definition comments.c:75
const char * name
Definition inputfile.c:127
#define fc_assert_ret(condition)
Definition log.h:191