luausb / compat.c

#include <lua.h>
#include "compat.h"



int typeerror(lua_State* L, int narg, const char* tname)
	const char* msg = lua_pushfstring(L, "%s expected, got %s", tname, luaL_typename(L, narg));
	return luaL_argerror(L, narg, msg);




void setfuncs(lua_State* L, const luaL_Reg* l, int nup)
	luaL_checkstack(L, nup, "too many upvalues");
	for (; l->name; ++l) /* fill the table with given functions */
		int i;
		for (i = 0; i < nup; ++i) /* copy upvalues to the top */
			lua_pushvalue(L, -nup);
		lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */
		lua_setfield(L, -(nup + 2), l->name);
	lua_pop(L, nup); /* remove upvalues */

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.