aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/ansi_c
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+667e-11@users.noreply.github.com>2015-12-06 17:50:23 -0500
committerGravatar mitchell <70453897+667e-11@users.noreply.github.com>2015-12-06 17:50:23 -0500
commit6b37ee4f9681743735e2b9ae4d0b2d2976f9ca77 (patch)
tree7877e34216feb8d7806c36a4cf9284229855adda /modules/ansi_c
parent20bc8627e62384854f2dee8246604e0e26a98e58 (diff)
Updated to Lua 5.3.2.
Diffstat (limited to 'modules/ansi_c')
-rw-r--r--modules/ansi_c/lua_api12
1 files changed, 6 insertions, 6 deletions
diff --git a/modules/ansi_c/lua_api b/modules/ansi_c/lua_api
index 6d313c13..f8bc0be6 100644
--- a/modules/ansi_c/lua_api
+++ b/modules/ansi_c/lua_api
@@ -2,15 +2,15 @@ lua_absindex lua_absindex(lua_State *L, int idx) [int]\nConverts the acceptable
lua_Alloc (*lua_Alloc)(void *ud, void *ptr, size_t osize, size_t nsize) [void*]\nThe type of the memory-allocation function used by Lua states. The allocator\nfunction must provide a functionality similar to `realloc`, but not exactly\nthe same. Its arguments are `ud`, an opaque pointer passed to `lua_newstate`;\n`ptr`, a pointer to the block being allocated/reallocated/freed; `osize`,\nthe original size of the block or some code about what is being allocated;\nand `nsize`, the new size of the block.\n\nWhen `ptr` is not `NULL`, `osize` is the size of the block pointed by `ptr`,\nthat is, the size given when it was allocated or reallocated.\n\nWhen `ptr` is `NULL`, `osize` encodes the kind of object that Lua is allocating.\n`osize` is any of `LUA_TSTRING`, `LUA_TTABLE`, `LUA_TFUNCTION`, `LUA_TUSERDATA`,\nor `LUA_TTHREAD` when (and only when) Lua is creating a new object of that type.\nWhen `osize` is some other value, Lua is allocating memory for something else.\n\nLua assumes the following behavior from the allocator function:\n\nWhen `nsize` is zero, the allocator must behave like `free` and return `NULL`.\n\nWhen `nsize` is not zero, the allocator must behave like `realloc`. The\nallocator returns `NULL` if and only if it cannot fulfill the request. Lua\nassumes that the allocator never fails when `osize >= nsize`.\n\nHere is a simple implementation for the allocator function. It is used in\nthe auxiliary library by `luaL_newstate`.\n\n static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {\n (void)ud; (void)osize; /* not used */\n if (nsize == 0) {\n free(ptr);\n return NULL;\n }\n else\n return realloc(ptr, nsize);\n }\n\nNote that Standard C ensures that `free(NULL)` has no effect and that\n`realloc(NULL, size)` is equivalent to `malloc(size)`. This code assumes that\n`realloc` does not fail when shrinking a block. (Although Standard C does not\nensure this behavior, it seems to be a safe assumption.)\n
lua_arith lua_arith(lua_State *L, int op) [void]\nPerforms an arithmetic or bitwise operation over the two values (or one, in the\ncase of negations) at the top of the stack, with the value at the top being the\nsecond operand, pops these values, and pushes the result of the operation. The\nfunction follows the semantics of the corresponding Lua operator (that is, it\nmay call metamethods).\n\nThe value of `op` must be one of the following constants:\n * LUA_OPADD: performs addition (`+`)\n * LUA_OPSUB: performs subtraction (`-`)\n * LUA_OPMUL: performs multiplication (`*`)\n * LUA_OPDIV: performs float division (`/`)\n * LUA_OPIDIV: performs floor division (`//`)\n * LUA_OPMOD: performs modulo (`%`)\n * LUA_OPPOW: performs exponentiation (`^`)\n * LUA_OPUNM: performs mathematical negation (unary `-`)\n * LUA_OPBNOT: performs bitwise negation (`~`)\n * LUA_OPBAND: performs bitwise and (`&`)\n * LUA_OPBOR: performs bitwise or (`|`)\n * LUA_OPBXOR: performs bitwise exclusive or (`~`)\n * LUA_OPBSHL: performs left shift (`<<`)\n * LUA_OPBSHR: performs right shift (`>>`)\n
lua_atpanic lua_atpanic(lua_State *L, lua_CFunction panicf) [lua_CFunction]\nSets a new panic function and returns the old one (see §4.6).\n\nIf an error happens outside any protected environment, Lua calls a _panic\nfunction_ and then calls `abort`, thus exiting the host application. Your panic\nfunction can avoid this exit by never returning (e.g., doing a long jump).\n\nThe panic function runs as if it were a message handler (see §2.3); in\nparticular, the error message is at the top of the stack. However, there is no\nguarantees about stack space. To push anything on the stack, the panic function\nshould first check the available space (see §4.2).\n
-lua_call lua_call(lua_State *L, int nargs, int nresults) [void]\nCalls a function.\n\nTo call a function you must use the following protocol: first, the function\nto be called is pushed onto the stack; then, the arguments to the function\nare pushed in direct order; that is, the first argument is pushed first.\nFinally you call `lua_call`; `nargs` is the number of arguments that you\npushed onto the stack. All arguments and the function value are popped from\nthe stack when the function is called. The function results are pushed onto\nthe stack when the function returns. The number of results is adjusted to\n`nresults`, unless `nresults` is `LUA_MULTRET`. In this case, all results from\nthe function are pushed. Lua takes care that the returned values fit into the\nstack space. The function results are pushed onto the stack in direct order\n(the first result is pushed first), so that after the call the last result is on\nthe top of the stack.\n\nAny error inside the called function is propagated upwards (with a `longjmp`).\n\nThe following example shows how the host program can do the equivalent to\nthis Lua code:\n\n a = f("how", t.x, 14)\n\nHere it is in C:\n\n lua_getglobal(L, "f"); /* function to be called */\n lua_pushliteral(L, "how"); /* 1st argument */\n lua_getglobal(L, "t"); /* table to be indexed */\n lua_getfield(L, -1, "x"); /* push result of t.x (2nd arg) */\n lua_remove(L, -2); /* remove 't' from the stack */\n lua_pushinteger(L, 14); /* 3rd argument */\n lua_call(L, 3, 1); /* call 'f' with 3 arguments and 1 result */\n lua_setglobal(L, "a"); /* set global 'a' */\n\nNote that the code above is _balanced_: at its end, the stack is back to\nits original configuration. This is considered good programming practice.\n
+lua_call lua_call(lua_State *L, int nargs, int nresults) [void]\nCalls a function.\n\nTo call a function you must use the following protocol: first, the function\nto be called is pushed onto the stack; then, the arguments to the function\nare pushed in direct order; that is, the first argument is pushed first.\nFinally you call `lua_call`; `nargs` is the number of arguments that you\npushed onto the stack. All arguments and the function value are popped from\nthe stack when the function is called. The function results are pushed onto\nthe stack when the function returns. The number of results is adjusted to\n`nresults`, unless `nresults` is `LUA_MULTRET`. In this case, all results from\nthe function are pushed. Lua takes care that the returned values fit into the\nstack space, but it does not ensure any extra space on the stack. The function\nresults are pushed onto the stack in direct order (the first result is pushed\nfirst), so that after the call the last result is on the top of the stack.\n\nAny error inside the called function is propagated upwards (with a `longjmp`).\n\nThe following example shows how the host program can do the equivalent to\nthis Lua code:\n\n a = f("how", t.x, 14)\n\nHere it is in C:\n\n lua_getglobal(L, "f"); /* function to be called */\n lua_pushliteral(L, "how"); /* 1st argument */\n lua_getglobal(L, "t"); /* table to be indexed */\n lua_getfield(L, -1, "x"); /* push result of t.x (2nd arg) */\n lua_remove(L, -2); /* remove 't' from the stack */\n lua_pushinteger(L, 14); /* 3rd argument */\n lua_call(L, 3, 1); /* call 'f' with 3 arguments and 1 result */\n lua_setglobal(L, "a"); /* set global 'a' */\n\nNote that the code above is _balanced_: at its end, the stack is back to\nits original configuration. This is considered good programming practice.\n
lua_callk lua_callk(lua_State *L, int nargs, int nresults, lua_KContext ctx, lua_KFunction k) [void]\nThis function behaves exactly like `lua_call`, but allows the called function to\nyield (see §4.7).\n
lua_CFunction (*lua_CFunction)(lua_State *L) [int]\nType for C functions.\n\nIn order to communicate properly with Lua, a C function must use the\nfollowing protocol, which defines the way parameters and results are passed:\na C function receives its arguments from Lua in its stack in direct order\n(the first argument is pushed first). So, when the function starts,\n`lua_gettop(L)` returns the number of arguments received by the function.\nThe first argument (if any) is at index 1 and its last argument is at index\n`lua_gettop(L)`. To return values to Lua, a C function just pushes them onto\nthe stack, in direct order (the first result is pushed first), and returns\nthe number of results. Any other value in the stack below the results will\nbe properly discarded by Lua. Like a Lua function, a C function called by\nLua can also return many results.\n\nAs an example, the following function receives a variable number of numerical\narguments and returns their average and their sum:\n\n static int foo (lua_State *L) {\n int n = lua_gettop(L); /* number of arguments */\n lua_Number sum = 0.0;\n int i;\n for (i = 1; i <= n; i++) {\n if (!lua_isnumber(L, i)) {\n lua_pushliteral(L, "incorrect argument");\n lua_error(L);\n }\n sum += lua_tonumber(L, i);\n }\n lua_pushnumber(L, sum/n); /* first result */\n lua_pushnumber(L, sum); /* second result */\n return 2; /* number of results */\n }\n
-lua_checkstack lua_checkstack(lua_State *L, int n) [int]\nEnsures that the stack has space for at least `n` extra slots.\nIt returns false if it cannot fulfill the request, either because it would cause\nthe stack to be larger than a fixed maximum size (typically at least several\nthousand elements) or because it cannot allocate memory for the extra space.\nThis function never shrinks the stack; if the stack is already larger than the\nnew size, it is left unchanged.\n
+lua_checkstack lua_checkstack(lua_State *L, int n) [int]\nEnsures that the stack has space for at least `n` extra slots (that is, that you\ncan safely push up to `n` values onto it).\nIt returns false if it cannot fulfill the request, either because it would cause\nthe stack to be larger than a fixed maximum size (typically at least several\nthousand elements) or because it cannot allocate memory for the extra space.\nThis function never shrinks the stack; if the stack already has space for the\nextra slots, it is left unchanged.\n
lua_close lua_close(lua_State *L) [void]\nDestroys all objects in the given Lua state (calling the corresponding\ngarbage-collection metamethods, if any) and frees all dynamic memory used by\nthis state. On several platforms, you may not need to call this function,\nbecause all resources are naturally released when the host program ends.\nOn the other hand, long-running programs that create multiple states, such as\ndaemons or web servers, will probably need to close states as soon as they are\nnot needed.\n
lua_compare lua_compare(lua_State *L, int index1, int index2, int op) [int]\nCompares two Lua values.\nReturns 1 if the value at index `index1` satisfies `op` when compared with\nthe value at index `index2`, following the semantics of the corresponding Lua\noperator (that is, it may call metamethods). Otherwise returns 0. Also\nreturns 0 if any of the indices is not valid.\n\nThe value of `op` must be one of the following constants:\n * LUA_OPEQ: compares for equality (`==`)\n * LUA_OPLT: compares for less than (`<`)\n * LUA_OPLE: compares for less or equal (`<=`)\n
lua_concat lua_concat(lua_State *L, int n) [void]\nConcatenates the `n` values at the top of the stack, pops them, and leaves\nthe result at the top. If `n` is 1, the result is the single value on the\nstack (that is, the function does nothing); if `n` is 0, the result is the\nempty string. Concatenation is performed following the usual semantics of\nLua (see §3.4.6).\n
lua_copy lua_copy(lua_State *L, int fromidx, int toidx) [void]\nCopies the element at index `fromidx` into the valid index `toidx`, replacing\nthe value at that position. Values at other positions are not affected.\n
-lua_createtable lua_createtable(lua_State *L, int narr, int nrec) [void]\nCreates a new empty table and pushes it onto the stack. Parameter `narr` is a\nhint for how many elements the table will have as a sequence; parameter `nrec`\nis a hint for how many other elements the table will have. Lua may use these\nhints to preallocate memory for the new table. This pre-allocation is useful for\nperformance when you know in advance how many elements the table will have.\nOtherwise you can use the function `lua_newtable`.\n
+lua_createtable lua_createtable(lua_State *L, int narr, int nrec) [void]\nCreates a new empty table and pushes it onto the stack. Parameter `narr` is a\nhint for how many elements the table will have as a sequence; parameter `nrec`\nis a hint for how many other elements the table will have. Lua may use these\nhints to preallocate memory for the new table. This preallocation is useful for\nperformance when you know in advance how many elements the table will have.\nOtherwise you can use the function `lua_newtable`.\n
lua_dump lua_dump(lua_State *L, lua_Writer writer, void *data, int strip) [int]\nDumps a function as a binary chunk. Receives a Lua function on the top of\nthe stack and produces a binary chunk that, if loaded again, results in a\nfunction equivalent to the one dumped. As it produces parts of the chunk,\n`lua_dump` calls function `writer` (see `lua_Writer`) with the given `data`\nto write them.\n\nIf `strip` is true, the binary representation is created without debug\ninformation about the function.\n\nThe value returned is the error code returned by the last call to the writer;\n0 means no errors.\n\nThis function does not pop the Lua function from the stack.\n
lua_error lua_error(lua_State *L) [int]\nGenerates a Lua error, using the value at the top of the stack as the error\nobject. This function does a long jump, and therefore never returns\n(see `luaL_error`).\n
lua_gc lua_gc(lua_State *L, int what, int data) [int]\nControls the garbage collector.\n\nThis function performs several tasks, according to the value of the parameter\n`what`:\n * LUA_GCSTOP: stops the garbage collector.\n * LUA_GCRESTART: restarts the garbage collector.\n * LUA_GCCOLLECT: performs a full garbage-collection cycle.\n * LUA_GCCOUNT: returns the current amount of memory (in Kbytes) in use by Lua.\n * LUA_GCCOUNTB: returns the remainder of dividing the current amount of bytes\n of memory in use by Lua by 1024.\n * LUA_GCSTEP: performs an incremental step of garbage collection.\n * LUA_GCSETPAUSE: sets `data` as the new value for the _pause_ of the\n collector (see §2.5) and returns the previous value of the pause.\n * LUA_GCSETSTEPMUL: sets `data` as the new value for the _step multiplier_ of\n the collector (see §2.5) and returns the previous value of the step\n multiplier.\n * LUA_GCISRUNNING: returns a boolean that tells whether the collector is\n running (i.e., not stopped).\n\nFor more details about these options, see `collectgarbage`.\n
@@ -97,7 +97,7 @@ lua_toboolean lua_toboolean(lua_State *L, int index) [int]\nConverts the Lua val
lua_tocfunction lua_tocfunction(lua_State *L, int index) [lua_CFunction]\nConverts a value at the given index to a C function. That value must be a\nC function; otherwise, returns `NULL`.\n
lua_tointeger lua_tointeger(lua_State *L, int index) [lua_Integer]\nEquivalent to `lua_tointegerx` with `isnum` equal to `NULL`.\n
lua_tointegerx lua_tointegerx(lua_State *L, int index, int *isnum) [lua_Integer]\nConverts the Lua value at the given index to the signed integral type\n`lua_Integer`. The Lua value must be an integer, or a number or a string\nconvertible to an integer (see §3.4.3); otherwise, `lua_tointegerx` returns 0.\n\nIf `isnum` is not `NULL`, its referent is assigned a boolean value that\nindicates whether the operation succeeded.\n
-lua_tolstring lua_tolstring(lua_State *L, int index, size_t *len) [const char*]\nConverts the Lua value at the given index to a C string. If `len` is not\n`NULL`, it also sets `*len` with the string length. The Lua value must be a\nstring or a number; otherwise, the function returns `NULL`. If the value is a\nnumber, then `lua_tolstring` also _changes the actual value in the stack to a\nstring_. (This change confuses `lua_next` when `lua_tolstring` is applied to\nkeys during a table traversal.)\n\n`lua_tolstring` returns a fully aligned pointer to a string inside the\nLua state. This string always has a zero ('\0') after its last character\n(as in C), but can contain other zeros in its body.\n\nBecause Lua has garbage collection, there is no guarantee that the pointer\nreturned by `lua_tolstring` will be valid after the corresponding Lua value\nis removed from the stack.\n
+lua_tolstring lua_tolstring(lua_State *L, int index, size_t *len) [const char*]\nConverts the Lua value at the given index to a C string. If `len` is not\n`NULL`, it sets `*len` with the string length. The Lua value must be a string\nor a number; otherwise, the function returns `NULL`. If the value is a number,\nthen `lua_tolstring` also _changes the actual value in the stack to a string_.\n(This change confuses `lua_next` when `lua_tolstring` is applied to keys during\na table traversal.)\n\n`lua_tolstring` returns a pointer to a string inside the Lua state. This string\nalways has a zero ('\0') after its last character (as in C), but can contain\nother zeros in its body.\n\nBecause Lua has garbage collection, there is no guarantee that the pointer\nreturned by `lua_tolstring` will be valid after the corresponding Lua value\nis removed from the stack.\n
lua_tonumber lua_tonumber(lua_State *L, int index) [lua_Number]\nEquivalent to `lua_tonumberx` with `isnum` equal to `NULL`.\n
lua_tonumberx lua_tonumberx(lua_State *L, int index, int *isnum) [lua_Number]\nConverts the Lua value at the given index to the C type `lua_Number` (see\n`lua_Number`). The Lua value must be a number or a string convertible to a\nnumber (see §3.4.3); otherwise, `lua_tonumberx` returns 0.\n\nIf `isnum` is not `NULL`, its referent is assigned a boolean value that\nindicates whether the operation succeeded.\n
lua_topointer lua_topointer(lua_State *L, int index) [const void*]\nConverts the value at the given index to a generic C pointer (`void*`).\nThe value can be a userdata, a table, a thread, or a function; otherwise,\n`lua_topointer` returns `NULL`. Different objects will give different\npointers. There is no way to convert the pointer back to its original value.\n\nTypically this function is used only for debug information.\n
@@ -169,7 +169,7 @@ luaL_newmetatable luaL_newmetatable(lua_State *L, const char *tname) [int]\nIf t
luaL_newstate luaL_newstate(void) [lua_State*]\nCreates a new Lua state. It calls `lua_newstate` with an allocator based\non the standard C `realloc` function and then sets a panic function (see\n`lua_atpanic`) that prints an error message to the standard error output in\ncase of fatal errors.\n\nReturns the new state, or `NULL` if there is a memory allocation error.\n
luaL_openlibs luaL_openlibs(lua_State *L) [void]\nOpens all standard Lua libraries into the given state.\n
luaL_optinteger luaL_optinteger(lua_State *L, int arg, lua_Integer d) [lua_Integer]\nIf the function argument `arg` is an integer (or convertable to an integer),\nreturns this integer. If this argument is absent or is nil, returns `d`.\nOtherwise, raises an error.\n
-luaL_optlstring luaL_optlstring(lua_State *L, int arg, const char *d, size_t *l) [const char*]\nIf the function argument `arg` is a string, returns this string. If this\nargument is absent or is nil, returns `d`. Otherwise, raises an error.\n\nIf `l` is not `NULL`, fills the position `*l` with the result's length.\n
+luaL_optlstring luaL_optlstring(lua_State *L, int arg, const char *d, size_t *l) [const char*]\nIf the function argument `arg` is a string, returns this string. If this\nargument is absent or is nil, returns `d`. Otherwise, raises an error.\n\nIf `l` is not `NULL`, fills the position `*l` with the result's length. If the\nresult is `NULL` (only possible when returning `d` and `d == NULL`), its length\nis considered zero.\n
luaL_optnumber luaL_optnumber(lua_State *L, int arg, lua_Number d) [lua_Number]\nIf the function argument `arg` is a number, returns this number. If this\nargument is absent or is nil, returns `d`. Otherwise, raises an error.\n
luaL_optstring luaL_optstring(lua_State *L, int arg, const char *d) [const char*]\nIf the function argument `arg` is a string, returns this string. If this\nargument is absent or is nil, returns `d`. Otherwise, raises an error.\n
luaL_prepbuffer luaL_prepbuffer(luaL_Buffer *B) [char*]\nEquivalent to `luaL_prepbuffsize` with the predefined size `LUAL_BUFFERSIZE`.\n
@@ -181,7 +181,7 @@ luaL_Reg luaL_Reg [struct]\ntypedef struct luaL_Reg {\n const char *name;\n lu
luaL_requiref luaL_requiref(lua_State *L, const char *modname, lua_CFunction openf, int glb) [void]\nIf `modname` is not already present in `package.loaded`, calls function `openf`\nwith string `modname` as an argument and sets the call result in\n`package.loaded[modname]`, as if that function has been called through\n`require`.\n\nIf `glb` is true, also stores the module into global `modname`.\n\nLeaves a copy of the module on the stack.\n
luaL_setfuncs luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup) [void]\nRegisters all functions in the array `l` (see `luaL_Reg`) into the table on the\ntop of the stack (below optional upvalues, see next).\n\nWhen `nup` is not zero, all functions are created sharing `nup` upvalues, which\nmust be previously pushed on the stack on top of the library table. These\nvalues are popped from the stack after the registration.\n
luaL_setmetatable luaL_setmetatable(lua_State *L, const char *tname) [void]\nSets the metatable of the object at the top of the stack as the metatable\nassociated with name `tname` in the registry (see `luaL_newmetatable`).\n
-luaL_Stream luaL_Stream [typedef struct luaL_Stream {FILE *f; lua_CFunction closef;}]\nThe standard representation for file handles, which is used by the standard I/O\nlibrary.\n\nA file handle is implemented as a full userdata, with a metatable called\n`LUA_FILEHANDLE` (where `LUA_FILEHANDLE` is a macro with the actual metatable's\nname). The metatable is created by the I/O library (see `luaL_newmetatable`).\n\nThis userdata must start with the structure `luaL_Stream`; it can contain other\ndata after this initial structure. Field `f` points to the corresponding C\nstream (or it can be `NULL` to indicate an incompletely created handle). Field\n`closef` points to a Lua function that will be called to close the stream when\nthe handle is closed or collected; this function receives the file handle as its\nsole argument and must return either **true** (in case of success) or **nil**\nplus an error message (in case of error). Once Lua calls this field, the field\nvalue is changed to `NULL` to signal that the handle is closed.\n
+luaL_Stream luaL_Stream [typedef struct luaL_Stream {FILE *f; lua_CFunction closef;}]\nThe standard representation for file handles, which is used by the standard I/O\nlibrary.\n\nA file handle is implemented as a full userdata, with a metatable called\n`LUA_FILEHANDLE` (where `LUA_FILEHANDLE` is a macro with the actual metatable's\nname). The metatable is created by the I/O library (see `luaL_newmetatable`).\n\nThis userdata must start with the structure `luaL_Stream`; it can contain other\ndata after this initial structure. Field `f` points to the corresponding C\nstream (or it can be `NULL` to indicate an incompletely created handle). Field\n`closef` points to a Lua function that will be called to close the stream when\nthe handle is closed or collected; this function receives the file handle as its\nsole argument and must return either **true** (in case of success) or **nil**\nplus an error message (in case of error). Once Lua calls this field, it changes\nthe field value to `NULL` to signal that the handle is closed.\n
luaL_testudata luaL_testudata(lua_State *L, int arg, const char *tname) [void]\nThis function works like `luaL_checkudata`, except that, when the test fails,\nit returns `NULL` instead of raising an error.\n
luaL_tolstring luaL_tolstring(lua_State *L, int idx, size_t *len) [const char*]\nConverts any Lua value at the given index to a C string in a reasonable format.\nThe resulting string is pushed onto the stack and also returned by the function.\nIf `len` is not `NULL`, the function also sets `*len` with the string length.\n\nIf the value has a metatable with a `"__tostring"` field, then `luaL_tolstring`\ncalls the corresponding metamethod with the value as argument, and uses the\nresult of the call as its result.\n
luaL_traceback luaL_traceback(lua_State *L, lua_State *L1, const char *msg, int level) [void]\nCreates and pushes a traceback of the stack `L1`. If `msg` is not `NULL` it is\nappended at the beginning of the traceback. The `level` parameter tells at\nwhich level to start the traceback.\n