Minetest  5.4.0
c_types.h
Go to the documentation of this file.
1 /*
2 Minetest
3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14 
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 
20 #pragma once
21 
22 extern "C" {
23 #include "lua.h"
24 }
25 
26 #include <iostream>
27 
28 #include "exceptions.h"
29 
30 struct EnumString
31 {
32  int num;
33  const char *str;
34 };
35 
37 {
38 private:
39  lua_State *m_lua;
41 public:
42  StackUnroller(lua_State *L):
43  m_lua(L),
44  m_original_top(-1)
45  {
46  m_original_top = lua_gettop(m_lua); // store stack height
47  }
49  {
50  lua_settop(m_lua, m_original_top); // restore stack height
51  }
52 };
53 
54 class LuaError : public ModError
55 {
56 public:
57  LuaError(const std::string &s) : ModError(s) {}
58 };
59 
60 
61 extern EnumString es_ItemType[];
EnumString es_ItemType[]
Definition: c_types.cpp:27
Definition: c_types.h:55
LuaError(const std::string &s)
Definition: c_types.h:57
Definition: exceptions.h:95
Definition: c_types.h:37
lua_State * m_lua
Definition: c_types.h:39
int m_original_top
Definition: c_types.h:40
StackUnroller(lua_State *L)
Definition: c_types.h:42
~StackUnroller()
Definition: c_types.h:48
Definition: c_types.h:31
const char * str
Definition: c_types.h:33
int num
Definition: c_types.h:32