3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
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.
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.
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.
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 #ifndef C_CONVERTER_H_
28 #define C_CONVERTER_H_
31 #include "util/cpp11_container.h"
33 #include "irrlichttypes_bloated.h"
34 #include "common/c_types.h"
40 std::string getstringfield_default(lua_State *L, int table,
41 const char *fieldname, const std::string &default_);
42 bool getboolfield_default(lua_State *L, int table,
43 const char *fieldname, bool default_);
44 float getfloatfield_default(lua_State *L, int table,
45 const char *fieldname, float default_);
46 int getintfield_default (lua_State *L, int table,
47 const char *fieldname, int default_);
49 bool getstringfield(lua_State *L, int table,
50 const char *fieldname, std::string &result);
51 size_t getstringlistfield(lua_State *L, int table,
52 const char *fieldname,
53 std::vector<std::string> *result);
54 bool getintfield(lua_State *L, int table,
55 const char *fieldname, int &result);
56 bool getintfield(lua_State *L, int table,
57 const char *fieldname, u8 &result);
58 bool getintfield(lua_State *L, int table,
59 const char *fieldname, u16 &result);
60 bool getintfield(lua_State *L, int table,
61 const char *fieldname, u32 &result);
62 void read_groups(lua_State *L, int index,
63 UNORDERED_MAP<std::string, int> &result);
64 bool getboolfield(lua_State *L, int table,
65 const char *fieldname, bool &result);
66 bool getfloatfield(lua_State *L, int table,
67 const char *fieldname, float &result);
69 std::string checkstringfield(lua_State *L, int table,
70 const char *fieldname);
72 void setstringfield(lua_State *L, int table,
73 const char *fieldname, const char *value);
74 void setintfield(lua_State *L, int table,
75 const char *fieldname, int value);
76 void setfloatfield(lua_State *L, int table,
77 const char *fieldname, float value);
78 void setboolfield(lua_State *L, int table,
79 const char *fieldname, bool value);
81 v3f checkFloatPos (lua_State *L, int index);
82 v2f check_v2f (lua_State *L, int index);
83 v2s16 check_v2s16 (lua_State *L, int index);
84 v3f check_v3f (lua_State *L, int index);
85 v3s16 check_v3s16 (lua_State *L, int index);
87 v3f read_v3f (lua_State *L, int index);
88 v2f read_v2f (lua_State *L, int index);
89 v2s16 read_v2s16 (lua_State *L, int index);
90 v2s32 read_v2s32 (lua_State *L, int index);
91 video::SColor read_ARGB8 (lua_State *L, int index);
92 bool read_color (lua_State *L, int index,
93 video::SColor *color);
95 aabb3f read_aabb3f (lua_State *L, int index, f32 scale);
96 v3s16 read_v3s16 (lua_State *L, int index);
97 std::vector<aabb3f> read_aabb3f_vector (lua_State *L, int index, f32 scale);
98 size_t read_stringlist (lua_State *L, int index,
99 std::vector<std::string> *result);
101 void push_v2s16 (lua_State *L, v2s16 p);
102 void push_v2s32 (lua_State *L, v2s32 p);
103 void push_v3s16 (lua_State *L, v3s16 p);
104 void push_aabb3f (lua_State *L, aabb3f box);
105 void push_ARGB8 (lua_State *L, video::SColor color);
106 void pushFloatPos (lua_State *L, v3f p);
107 void push_v3f (lua_State *L, v3f p);
108 void push_v2f (lua_State *L, v2f p);
110 void warn_if_field_exists(lua_State *L, int table,
111 const char *fieldname,
112 const std::string &message);
114 size_t write_array_slice_float(lua_State *L, int table_index, float *data,
115 v3u16 data_size, v3u16 slice_offset, v3u16 slice_size);
116 size_t write_array_slice_u16(lua_State *L, int table_index, u16 *data,
117 v3u16 data_size, v3u16 slice_offset, v3u16 slice_size);
119 #endif /* C_CONVERTER_H_ */