_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

luacallback.h
Go to the documentation of this file.
1 // _________ __ __
2 // / _____// |_____________ _/ |______ ____ __ __ ______
3 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
4 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
5 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
6 // \/ \/ \//_____/ \/
7 // ______________________ ______________________
8 // T H E W A R B E G I N S
9 // Stratagus - A free fantasy real time strategy game engine
10 //
12 //
13 // (c) Copyright 2008 by Francois Beerten
14 //
15 // This program is free software; you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation; only version 2 of the License.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 // 02111-1307, USA.
28 
29 #ifndef LUA_CALLBACK_HEADER_FILE
30 #define LUA_CALLBACK_HEADER_FILE
31 
32 #include <map>
33 #include <string>
34 #include <vector>
35 #include <utility>
36 #include <variant>
37 
38 typedef int lua_Object; // from tolua++.h
39 struct lua_State;
40 
42 {
43 public:
44  LuaCallback(lua_State *lua, lua_Object luaref);
45  ~LuaCallback();
46  void pushPreamble();
47  void pushInteger(int value);
48  void pushIntegers(const std::vector<int> &values);
49  void pushString(const std::string &eventId);
50  void pushTable(std::initializer_list<std::pair<std::string, std::variant<std::string, int>>> list);
51  void pushTable(std::map<std::string, std::variant<std::string, int>> map);
52  void run(int results = 0);
53  bool popBoolean();
54  int popInteger();
55 private:
56  lua_State *luastate;
57  int luaref;
58  int arguments;
59  int rescount;
60  int base;
61 };
62 
63 #endif
LuaCallback::popBoolean
bool popBoolean()
Definition: luacallback.cpp:141
LuaCallback::pushInteger
void pushInteger(int value)
Definition: luacallback.cpp:72
LuaCallback::pushString
void pushString(const std::string &eventId)
Definition: luacallback.cpp:99
LuaCallback::pushTable
void pushTable(std::initializer_list< std::pair< std::string, std::variant< std::string, int >>> list)
Definition: luacallback.cpp:108
LuaCallback::run
void run(int results=0)
Definition: luacallback.cpp:178
LuaCallback::~LuaCallback
~LuaCallback()
Definition: luacallback.cpp:187
LuaCallback::pushIntegers
void pushIntegers(const std::vector< int > &values)
Definition: luacallback.cpp:83
lua_Object
int lua_Object
Definition: luacallback.h:38
LuaCallback::LuaCallback
LuaCallback(lua_State *lua, lua_Object luaref)
Definition: luacallback.cpp:44
LuaCallback
Definition: luacallback.h:41
LuaCallback::pushPreamble
void pushPreamble()
Definition: luacallback.cpp:59
LuaCallback::popInteger
int popInteger()
Definition: luacallback.cpp:158
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.