]> git.lizzy.rs Git - dragonfireclient.git/blob - src/script/common/c_converter.h
C++ modernize: Pragma once (#6264)
[dragonfireclient.git] / src / script / common / c_converter.h
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
21 /******************************************************************************/
22 /******************************************************************************/
23 /* WARNING!!!! do NOT add this header in any include file or any code file    */
24 /*             not being a script/modapi file!!!!!!!!                         */
25 /******************************************************************************/
26 /******************************************************************************/
27 #pragma once
28
29 #include <vector>
30 #include <unordered_map>
31
32 #include "irrlichttypes_bloated.h"
33 #include "common/c_types.h"
34
35 extern "C" {
36 #include <lua.h>
37 }
38
39 std::string        getstringfield_default(lua_State *L, int table,
40                              const char *fieldname, const std::string &default_);
41 bool               getboolfield_default(lua_State *L, int table,
42                              const char *fieldname, bool default_);
43 float              getfloatfield_default(lua_State *L, int table,
44                              const char *fieldname, float default_);
45 int                getintfield_default           (lua_State *L, int table,
46                              const char *fieldname, int default_);
47
48 bool               getstringfield(lua_State *L, int table,
49                              const char *fieldname, std::string &result);
50 size_t             getstringlistfield(lua_State *L, int table,
51                              const char *fieldname,
52                              std::vector<std::string> *result);
53 bool               getintfield(lua_State *L, int table,
54                              const char *fieldname, int &result);
55 bool               getintfield(lua_State *L, int table,
56                              const char *fieldname, u8 &result);
57 bool               getintfield(lua_State *L, int table,
58                              const char *fieldname, u16 &result);
59 bool               getintfield(lua_State *L, int table,
60                              const char *fieldname, u32 &result);
61 void               read_groups(lua_State *L, int index,
62                              std::unordered_map<std::string, int> &result);
63 bool               getboolfield(lua_State *L, int table,
64                              const char *fieldname, bool &result);
65 bool               getfloatfield(lua_State *L, int table,
66                              const char *fieldname, float &result);
67
68 std::string        checkstringfield(lua_State *L, int table,
69                              const char *fieldname);
70
71 void               setstringfield(lua_State *L, int table,
72                              const char *fieldname, const char *value);
73 void               setintfield(lua_State *L, int table,
74                              const char *fieldname, int value);
75 void               setfloatfield(lua_State *L, int table,
76                              const char *fieldname, float value);
77 void               setboolfield(lua_State *L, int table,
78                              const char *fieldname, bool value);
79 void               setstringfield(lua_State *L, int table,
80                              const char *fieldname, const char *value);
81
82 v3f                 checkFloatPos       (lua_State *L, int index);
83 v2f                 check_v2f           (lua_State *L, int index);
84 v2s16               check_v2s16         (lua_State *L, int index);
85 v3f                 check_v3f           (lua_State *L, int index);
86 v3s16               check_v3s16         (lua_State *L, int index);
87
88 v3f                 read_v3f            (lua_State *L, int index);
89 v2f                 read_v2f            (lua_State *L, int index);
90 v2s16               read_v2s16          (lua_State *L, int index);
91 v2s32               read_v2s32          (lua_State *L, int index);
92 video::SColor       read_ARGB8          (lua_State *L, int index);
93 bool                read_color          (lua_State *L, int index,
94                                          video::SColor *color);
95
96 aabb3f              read_aabb3f         (lua_State *L, int index, f32 scale);
97 v3s16               read_v3s16          (lua_State *L, int index);
98 std::vector<aabb3f> read_aabb3f_vector  (lua_State *L, int index, f32 scale);
99 size_t              read_stringlist     (lua_State *L, int index,
100                                          std::vector<std::string> *result);
101
102 void                push_v2s16          (lua_State *L, v2s16 p);
103 void                push_v2s32          (lua_State *L, v2s32 p);
104 void                push_v3s16          (lua_State *L, v3s16 p);
105 void                push_aabb3f         (lua_State *L, aabb3f box);
106 void                push_ARGB8          (lua_State *L, video::SColor color);
107 void                pushFloatPos        (lua_State *L, v3f p);
108 void                push_v3f            (lua_State *L, v3f p);
109 void                push_v2f            (lua_State *L, v2f p);
110
111 void                warn_if_field_exists(lua_State *L, int table,
112                                          const char *fieldname,
113                                          const std::string &message);
114
115 size_t write_array_slice_float(lua_State *L, int table_index, float *data,
116         v3u16 data_size, v3u16 slice_offset, v3u16 slice_size);
117 size_t write_array_slice_u16(lua_State *L, int table_index, u16 *data,
118         v3u16 data_size, v3u16 slice_offset, v3u16 slice_size);