1 /* 2 __ 3 / _| 4 __ _ _ _ _ __ ___ _ __ __ _ | |_ ___ ___ ___ 5 / _` | | | | '__/ _ \| '__/ _` | | _/ _ \/ __/ __| 6 | (_| | |_| | | | (_) | | | (_| | | || (_) \__ \__ \ 7 \__,_|\__,_|_| \___/|_| \__,_| |_| \___/|___/___/ 8 9 Copyright (C) 1994-2020 Lua.org, PUC-Rio. 10 Copyright (C) 2018-2020 Aurora Free Open Source Software. 11 Copyright (C) 2018-2020 Luís Ferreira <luis@aurorafoss.org> 12 13 This file is part of the Aurora Free Open Source Software. This 14 organization promote free and open source software that you can 15 redistribute and/or modify under the terms of the GNU Lesser General 16 Public License Version 3 as published by the Free Software Foundation or 17 (at your option) any later version approved by the Aurora Free Open Source 18 Software Organization. The license is available in the package root path 19 as 'LICENSE' file. Please review the following information to ensure the 20 GNU Lesser General Public License version 3 requirements will be met: 21 https://www.gnu.org/licenses/lgpl.html . 22 23 Alternatively, this file may be used under the terms of the GNU General 24 Public License version 3 or later as published by the Free Software 25 Foundation. Please review the following information to ensure the GNU 26 General Public License requirements will be met: 27 http://www.gnu.org/licenses/gpl-3.0.html. 28 29 NOTE: All products, services or anything associated to trademarks and 30 service marks used or referenced on this file are the property of their 31 respective companies/owners or its subsidiaries. Other names and brands 32 may be claimed as the property of others. 33 34 For more info about intellectual property visit: aurorafoss.org or 35 directly send an email to: contact (at) aurorafoss.org . 36 */ 37 38 /++ 39 Static function declarations for Lua bindings 40 41 This file defines all static function declarations for Lua library bindings. 42 43 Authors: Luís Ferreira <luis@aurorafoss.org> 44 Copyright: All rights reserved, Aurora Free Open Source Software 45 License: GNU Lesser General Public License (Version 3, 29 June 2007) 46 Date: 2018-2019 47 +/ 48 module riverd.lua.statfun; 49 50 import core.stdc.stdarg; 51 import riverd.lua.types; 52 53 54 extern(C) @nogc nothrow { 55 56 /** Creates a new thread running in a new, independent state. 57 * 58 * Params: 59 * f = The allocator function. Lua does all memory allocation for this 60 * state through this function. 61 * ud = an opaque pointer that Lua passes to the allocator in every call. 62 * 63 * Returns: `null` if it cannot create the thread or the state 64 * (due to lack of memory). 65 * 66 * See_Also: $(REF lua_Alloc, riverd,lua,types) 67 */ 68 lua_State* lua_newstate(lua_Alloc f, void* ud); 69 70 71 /** Destroys all objects in the given Lua state. 72 * 73 * Destroys all objects in the given Lua state (calling the corresponding 74 * garbage-collection metamethods, if any) and frees all dynamic memory 75 * used by this state. 76 * In several platforms, you may not need to call this function, 77 * because all resources are naturally released when the host 78 * program ends. On the other hand, long-running programs that create 79 * multiple states, such as daemons or web servers, will probably need 80 * to close states as soon as they are not needed. 81 * 82 * Params: 83 * s = Lua state 84 * 85 * See_Also: $(REF lua_State, riverd,lua,types) 86 */ 87 void lua_close(lua_State* s); 88 89 90 /** Creates a new thread. 91 * 92 * Creates a new thread and pushes it on the stack. The new thread returned 93 * by this function shares with the original thread its global environment, 94 * but has an independent execution stack. 95 * 96 * Params: 97 * s = Lua state 98 * 99 * Returns: a pointer to a lua_State that represents this new thread. 100 * 101 * Note: There is no explicit function to close or to destroy a thread. 102 * Threads are subject to garbage collection, like any Lua object. 103 * 104 * See_Also: $(REF lua_State, riverd,lua,types) 105 */ 106 lua_State* lua_newthread(lua_State* s); 107 108 /** Resets a thread 109 * 110 * Cleaning its call stack and closing all pending to-be-closed variables. 111 * 112 * Params: 113 * s = Lua state 114 * 115 * Returns: LUA_OK for no errors in closing methods, or an error status 116 * otherwise. 117 * 118 * Note: In case of error, leaves the error object on the top of the stack. 119 * 120 * See_Also: $(REF lua_State, riverd,lua,types) 121 */ 122 123 int lua_resetthread(lua_State *s); 124 125 126 /** Sets a new panic function 127 * 128 * Params: 129 * s = Lua state 130 * func = C lua_State registered function 131 * 132 * Returns: the old panic functio 133 * 134 * Note: The panic function can access the error message at the top of the stack. 135 * If an error happens outside any protected environment, Lua calls a panic 136 * function and then calls exit(EXIT_FAILURE), thus exiting the host application. 137 * Your panic function can avoid this exit by never returning (e.g., doing a long 138 * jump). 139 * 140 * See_Also: $(REF lua_State, riverd,lua,types) 141 * $(REF lua_CFunction, riverd,lua,types) 142 */ 143 lua_CFunction lua_atpanic(lua_State* s, lua_CFunction func); 144 145 lua_Number lua_version(lua_State*); 146 int lua_absindex(lua_State*, int); 147 int lua_gettop(lua_State*); 148 void lua_settop(lua_State*, int); 149 void lua_pushvalue(lua_State*, int); 150 void lua_rotate(lua_State*, int, int); 151 void lua_copy(lua_State*, int, int); 152 int lua_checkstack(lua_State*, int); 153 void lua_xmove(lua_State*, lua_State*, int); 154 int lua_isnumber(lua_State*, int); 155 int lua_isstring(lua_State*, int); 156 int lua_iscfunction(lua_State*, int); 157 int lua_isinteger(lua_State*, int); 158 int lua_isuserdata(lua_State*, int); 159 int lua_type(lua_State*, int); 160 const(char)* lua_typename(lua_State*, int); 161 lua_Number lua_tonumberx(lua_State*, int, int*); 162 lua_Integer lua_tointegerx(lua_State*, int, int*); 163 int lua_toboolean(lua_State*, int); 164 const(char)* lua_tolstring(lua_State*, int, size_t*); 165 lua_Unsigned lua_rawlen(lua_State*, int); 166 lua_CFunction lua_tocfunction(lua_State*, int); 167 void* lua_touserdata(lua_State*, int); 168 lua_State* lua_tothread(lua_State*, int); 169 const(void)* lua_topointer(lua_State*, int); 170 void lua_arith(lua_State*, int); 171 int lua_rawequal(lua_State*, int, int); 172 int lua_compare(lua_State*, int, int, int); 173 void lua_pushnil(lua_State*); 174 void lua_pushnumber(lua_State*, lua_Number); 175 void lua_pushinteger(lua_State*, lua_Integer); 176 const(char)* lua_pushlstring(lua_State*, const(char)*, size_t); 177 const(char)* lua_pushstring(lua_State*, const(char)*); 178 const(char)* lua_pushvfstring(lua_State*, const(char)*, va_list); 179 const(char)* lua_pushfstring(lua_State*, const(char)*, ...); 180 void lua_pushcclosure(lua_State*, lua_CFunction, int); 181 void lua_pushboolean(lua_State*, int); 182 void lua_pushlightuserdata(lua_State*, void*); 183 int lua_pushthread(lua_State*); 184 int lua_getglobal(lua_State*, const(char)*); 185 int lua_gettable(lua_State*, int); 186 int lua_getfield(lua_State*, int, const(char)*); 187 int lua_geti(lua_State*, int, lua_Integer); 188 int lua_rawget(lua_State*, int); 189 int lua_rawgeti(lua_State*, int, int); 190 int lua_rawgetp(lua_State*, int, const(void)*); 191 void lua_createtable(lua_State*, int, int); 192 void* lua_newuserdatauv(lua_State*, size_t, int); 193 int lua_getmetatable(lua_State*, int); 194 int lua_getiuservalue(lua_State*, int, int); 195 void lua_setglobal(lua_State*, const(char)*); 196 void lua_settable(lua_State*, int); 197 void lua_setfield(lua_State*, int, const(char)*); 198 void lua_rawset(lua_State*, int); 199 void lua_rawseti(lua_State*, int, lua_Integer); 200 void lua_rawsetp(lua_State*, int, const(void)*); 201 int lua_setmetatable(lua_State*, int); 202 void lua_setiuservalue(lua_State*, int, int); 203 void lua_callk(lua_State*, int, int, lua_KContext, lua_KFunction); 204 int lua_pcallk(lua_State*, int, int, int, lua_KContext, lua_KFunction); 205 int lua_load(lua_State*, lua_Reader, void*, const(char)*, const(char)*); 206 int lua_dump(lua_State*, lua_Writer, void*, int); 207 int lua_yieldk(lua_State*, int, lua_KContext, lua_KFunction); 208 int lua_resume(lua_State*, lua_State*, int, int*); 209 int lua_status(lua_State*); 210 int lua_isyieldable(lua_State*); 211 void lua_setwarnf(lua_State*, lua_WarnFunction, void *); 212 void lua_warning(lua_State*, const char*, int); 213 int lua_gc(lua_State*, int, ...); 214 int lua_error(lua_State*); 215 int lua_next(lua_State*, int); 216 void lua_concat(lua_State*, int); 217 void lua_len(lua_State*, int); 218 size_t lua_stringtonumber(lua_State*, const(char)*); 219 lua_Alloc lua_getallocf(lua_State*, void**); 220 void lua_setallocf(lua_State*, lua_Alloc, void*); 221 void lua_toclose(lua_State*, int); 222 int lua_getstack(lua_State*, int, lua_Debug*); 223 int lua_getinfo(lua_State*, const(char)*, lua_Debug*); 224 const(char)* lua_getlocal(lua_State*, const(lua_Debug)*, int); 225 const(char)* lua_setlocal(lua_State*, const(lua_Debug)*, int); 226 const(char)* lua_getupvalue(lua_State*, int, int); 227 const(char)* lua_setupvalue(lua_State*, int, int); 228 void* lua_upvalueid(lua_State*, int, int); 229 void lua_upvaluejoin(lua_State*, int, int, int, int); 230 void lua_sethook(lua_State*, lua_Hook, int, int); 231 lua_Hook lua_gethook(lua_State*); 232 int lua_gethookmask(lua_State*); 233 int lua_gethookcount(lua_State*); 234 int lua_setcstacklimit(lua_State*, uint); 235 236 void luaL_checkversion_(lua_State*, lua_Number, size_t); 237 int luaL_getmetafield(lua_State*, int, const(char)*); 238 int luaL_callmeta(lua_State*, int, const(char)*); 239 const(char)* luaL_tolstring(lua_State*, int, size_t*); 240 int luaL_argerror(lua_State*, int, const(char)*); 241 const(char)* luaL_checklstring(lua_State*, int, size_t*); 242 const(char)* luaL_optlstring(lua_State*, int, const(char)*, size_t*); 243 lua_Number luaL_checknumber(lua_State*, int); 244 lua_Number luaL_optnumber(lua_State*, int, lua_Number); 245 lua_Integer luaL_checkinteger(lua_State*, int); 246 lua_Integer luaL_optinteger(lua_State*, int, lua_Integer); 247 void luaL_checkstack(lua_State*, int, const(char)*); 248 void luaL_checktype(lua_State*, int, int); 249 void luaL_checkany(lua_State*, int); 250 int luaL_newmetatable(lua_State*, const(char)*); 251 void luaL_setmetatable(lua_State*, const(char)*); 252 void* luaL_testudata(lua_State*, int, const(char)*); 253 void* luaL_checkudata(lua_State*, int, const(char)*); 254 void luaL_where(lua_State*, int); 255 int luaL_error(lua_State*, const(char)*, ...); 256 int luaL_checkoption(lua_State*, int, const(char)*); 257 int luaL_fileresult(lua_State*, int, const(char)*); 258 int luaL_execresult(lua_State*, int); 259 int luaL_ref(lua_State*, int); 260 void luaL_unref(lua_State*, int, int); 261 int luaL_loadfilex(lua_State*, const(char)*, const(char)*); 262 int luaL_loadbufferx(lua_State*, const(char)*, size_t, const(char)*, const(char)*); 263 int luaL_loadstring(lua_State*, const(char)*); 264 lua_State* luaL_newstate(); 265 lua_Integer luaL_len(lua_State*, int); 266 const(char)* luaL_gsub(lua_State*, const(char)*, const(char)*, const(char)*); 267 void luaL_setfuncs(lua_State*, const luaL_Reg*, int); 268 int luaL_getsubtable(lua_State*, int, const(char)*); 269 void luaL_traceback(lua_State*, lua_State*, const(char)*, int); 270 void luaL_requiref(lua_State*, const(char)*, lua_CFunction, int); 271 void luaL_buffinit(lua_State*, luaL_Buffer*); 272 char* luaL_prepbuffsize(luaL_Buffer*, size_t); 273 void luaL_addlstring(luaL_Buffer*, const(char)*, size_t); 274 void luaL_addstring(luaL_Buffer*, const(char)*); 275 void luaL_addvalue(luaL_Buffer*); 276 void luaL_pushresult(luaL_Buffer*); 277 void luaL_pushresultsize(luaL_Buffer*, size_t); 278 char* luaL_buffinitsize(lua_State*, luaL_Buffer*, size_t); 279 void luaL_pushmodule(lua_State*, const(char)*, int); 280 void luaL_openlib(lua_State*, const(char)*, const(luaL_Reg)*, int); 281 int luaopen_base(lua_State*); 282 int luaopen_coroutine(lua_State*); 283 int luaopen_table(lua_State*); 284 int luaopen_io(lua_State*); 285 int luaopen_os(lua_State*); 286 int luaopen_string(lua_State*); 287 int luaopen_utf8(lua_State*); 288 int luaopen_bit32(lua_State*); 289 int luaopen_math(lua_State*); 290 int luaopen_debug(lua_State*); 291 int luaopen_package(lua_State*); 292 void luaL_openlibs(lua_State*); 293 }