change a_float to a_real
[liba.git] / lua / src / a.h
blobae18447d09becf5215d7af4ed77bc7fc34e11dab
1 #ifndef LUA_LIBA_A_H
2 #define LUA_LIBA_A_H
4 #if defined(_MSC_VER)
5 #if !defined _CRT_SECURE_NO_WARNINGS
6 #define _CRT_SECURE_NO_WARNINGS /* NOLINT */
7 #endif /* _CRT_SECURE_NO_WARNINGS */
8 #pragma warning(disable : 4820)
9 #endif /* _MSC_VER */
10 #include "a/hash.h"
11 #if __has_warning("-Wcomma")
12 #pragma clang diagnostic ignored "-Wcomma"
13 #endif /* -Wcomma */
14 #if __has_warning("-Wdocumentation")
15 #pragma clang diagnostic ignored "-Wdocumentation"
16 #endif /* -Wdocumentation */
17 #if __has_warning("-Wdocumentation-unknown-command")
18 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
19 #endif /* -Wdocumentation-unknown-command */
20 #if defined(__GNUC__) || defined(__clang__)
21 #pragma GCC diagnostic ignored "-Wpadded"
22 #endif /* -Wpadded */
23 #include <lua.h>
25 #if !defined LUA_INT
26 #define LUA_INT lua_Integer
27 #endif /* LUA_INT */
28 #if !defined LUA_NUM
29 #define LUA_NUM a_real
30 #endif /* LUA_NUM */
32 typedef struct
34 char const *name;
35 lua_CFunction func;
36 } lua_fun;
38 typedef struct
40 char const *name;
41 char const *data;
42 } lua_str;
44 typedef struct
46 char const *name;
47 LUA_INT data;
48 } lua_int;
50 typedef struct
52 char const *name;
53 LUA_NUM data;
54 } lua_num;
56 #if defined(__cplusplus)
57 extern "C" {
58 #endif /* __cplusplus */
60 #if defined(LUA_VERSION_NUM) && (LUA_VERSION_NUM > 503)
61 #define lua_newclass(L, T) (T *)lua_newuserdatauv(L, sizeof(T), 0)
62 #else /* !LUA_VERSION_NUM */
63 #define lua_newclass(L, T) (T *)lua_newuserdata(L, sizeof(T))
64 #endif /* LUA_VERSION_NUM */
66 #if !defined LUA_VERSION_NUM || (LUA_VERSION_NUM < 503)
67 #define lua_geti(L, idx, i) (lua_pushinteger(L, i), lua_gettable(L, (idx) - 1))
68 #endif /* LUA_VERSION_NUM */
70 #if defined(LUA_VERSION_NUM) && (LUA_VERSION_NUM > 501)
71 LUALIB_API void luaL_checkversion_(lua_State *L, lua_Number ver, size_t sz);
72 #define luaL_checkversion(L) luaL_checkversion_(L, LUA_VERSION_NUM, sizeof(lua_Number) + sizeof(lua_Integer) * 16)
73 #else /* !LUA_VERSION_NUM */
74 #define luaL_checkversion(L) (void)0
75 #endif /* LUA_VERSION_NUM */
77 #if !defined LUA_VERSION_NUM || (LUA_VERSION_NUM <= 501)
78 LUALIB_API void luaL_register(lua_State *L, char const *libname, lua_fun const *l);
79 #define lua_rawsetp(L, idx, p) (lua_pushlightuserdata(L, p), lua_insert(L, -2), lua_rawset(L, idx))
80 #define lua_rawgetp(L, idx, p) (lua_pushlightuserdata(L, p), lua_rawget(L, idx))
81 #define lua_rawlen lua_objlen
82 #endif /* LUA_VERSION_NUM */
84 LUALIB_API int luaL_callmeta(lua_State *L, int obj, const char *e);
85 LUALIB_API int luaL_getmetafield(lua_State *L, int obj, const char *e);
87 LUALIB_API char const *luaL_checklstring(lua_State *L, int numArg, size_t *l);
88 LUALIB_API char const *luaL_optlstring(lua_State *L, int numArg, char const *def, size_t *l);
90 LUALIB_API lua_Integer luaL_checkinteger(lua_State *L, int numArg);
91 LUALIB_API lua_Integer luaL_optinteger(lua_State *L, int nArg, lua_Integer def);
93 LUALIB_API lua_Number luaL_checknumber(lua_State *L, int numArg);
94 LUALIB_API lua_Number luaL_optnumber(lua_State *L, int nArg, lua_Number def);
96 LUALIB_API void luaL_checkstack(lua_State *L, int sz, char const *msg);
97 LUALIB_API void luaL_checktype(lua_State *L, int narg, int t);
98 LUALIB_API void luaL_checkany(lua_State *L, int narg);
100 LUALIB_API int luaL_error(lua_State *L, char const *fmt, ...);
101 LUALIB_API void luaL_where(lua_State *L, int lvl);
103 void lua_u8_new(lua_State *L, a_u8 value);
104 a_u8 lua_u8_get(lua_State *L, int idx);
105 void lua_u16_new(lua_State *L, a_u16 value);
106 a_u16 lua_u16_get(lua_State *L, int idx);
107 void lua_u32_new(lua_State *L, a_u32 value);
108 a_u32 lua_u32_get(lua_State *L, int idx);
109 void lua_u64_new(lua_State *L, a_u64 value);
110 a_u64 lua_u64_get(lua_State *L, int idx);
112 void *lua_alloc(lua_State *L, void const *ptr, size_t siz);
114 void lua_registry_get(lua_State *L, int (*fn)(lua_State *));
115 void lua_registry_set(lua_State *L, int (*fn)(lua_State *));
117 void lua_fun_reg(lua_State *L, int idx, lua_fun const *tab, size_t len);
118 void lua_fun_set(lua_State *L, int idx, char const *name, lua_CFunction func);
120 void lua_str_reg(lua_State *L, int idx, lua_str const *tab, size_t len);
121 void lua_str_set(lua_State *L, int idx, char const *name, char const *data);
122 char const *lua_str_get(lua_State *L, int idx, char const *name);
124 void lua_int_reg(lua_State *L, int idx, lua_int const *tab, size_t len);
125 void lua_int_set(lua_State *L, int idx, char const *name, LUA_INT data);
126 LUA_INT lua_int_get(lua_State *L, int idx, char const *name);
128 void lua_num_reg(lua_State *L, int idx, lua_num const *tab, size_t len);
129 void lua_num_set(lua_State *L, int idx, char const *name, LUA_NUM data);
130 LUA_NUM lua_num_get(lua_State *L, int idx, char const *name);
132 unsigned int lua_array_len(lua_State *L, int idx);
134 void lua_array_u8_new(lua_State *L, a_u8 const *ptr, unsigned int num);
135 void lua_array_u16_new(lua_State *L, a_u16 const *ptr, unsigned int num);
136 void lua_array_u32_new(lua_State *L, a_u32 const *ptr, unsigned int num);
137 void lua_array_u64_new(lua_State *L, a_u64 const *ptr, unsigned int num);
139 void lua_array_str_new(lua_State *L, char const *const *ptr, unsigned int num);
140 void lua_array_str_get(lua_State *L, int idx, char const **ptr, unsigned int num);
141 void lua_array_str_set(lua_State *L, int idx, char const *const *ptr, unsigned int num);
143 void lua_array_int_new(lua_State *L, LUA_INT const *ptr, unsigned int num);
144 void lua_array_int_get(lua_State *L, int idx, LUA_INT *ptr, unsigned int num);
145 void lua_array_int_set(lua_State *L, int idx, LUA_INT const *ptr, unsigned int num);
147 void lua_array_num_new(lua_State *L, LUA_NUM const *ptr, unsigned int num);
148 unsigned int lua_array_num_len(lua_State *L, int idx, int dim);
149 LUA_NUM *lua_array_num_ptr(lua_State *L, int idx, LUA_NUM *ptr, int dim);
150 LUA_NUM *lua_array_num_get(lua_State *L, int idx, LUA_NUM const *ptr, unsigned int *num, int dim);
151 void lua_array_num_set(lua_State *L, int idx, LUA_NUM const *ptr, unsigned int num);
153 void lua_stack_view(lua_State *L, unsigned int line);
154 /* #define LUA_STACK(L) lua_stack_view(L, __LINE__) */
156 A_PUBLIC int luaopen_liba(lua_State *L);
157 A_PUBLIC int luaopen_liba_complex(lua_State *L);
158 A_PUBLIC int luaopen_liba_crc16(lua_State *L);
159 A_PUBLIC int luaopen_liba_crc32(lua_State *L);
160 A_PUBLIC int luaopen_liba_crc64(lua_State *L);
161 A_PUBLIC int luaopen_liba_crc8(lua_State *L);
162 A_PUBLIC int luaopen_liba_hpf(lua_State *L);
163 A_PUBLIC int luaopen_liba_lpf(lua_State *L);
164 A_PUBLIC int luaopen_liba_mf(lua_State *L);
165 A_PUBLIC int luaopen_liba_pid(lua_State *L);
166 A_PUBLIC int luaopen_liba_pid_fuzzy(lua_State *L);
167 A_PUBLIC int luaopen_liba_pid_neuro(lua_State *L);
168 A_PUBLIC int luaopen_liba_regress_linear(lua_State *L);
169 A_PUBLIC int luaopen_liba_regress_simple(lua_State *L);
170 A_PUBLIC int luaopen_liba_tf(lua_State *L);
171 A_PUBLIC int luaopen_liba_trajbell(lua_State *L);
172 A_PUBLIC int luaopen_liba_trajpoly3(lua_State *L);
173 A_PUBLIC int luaopen_liba_trajpoly5(lua_State *L);
174 A_PUBLIC int luaopen_liba_trajpoly7(lua_State *L);
175 A_PUBLIC int luaopen_liba_trajtrap(lua_State *L);
176 A_PUBLIC int luaopen_liba_version(lua_State *L);
178 #if defined(__cplusplus)
179 } /* extern "C" */
180 #endif /* __cplusplus */
182 #endif /* a.h */