MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / lookforfunc

Function lookforfunc

third-party/lua-5.5.0/src/loadlib.c:384–402  ·  view source on GitHub ↗

** Look for a C function named 'sym' in a dynamically loaded library ** 'path'. ** First, check whether the library is already loaded; if not, try ** to load it. ** Then, if 'sym' is '*', return true (as library has been loaded). ** Otherwise, look for symbol 'sym' in the library and push a ** C function with that symbol. ** Return 0 with 'true' or a function in the stack; in case of ** errors, re

Source from the content-addressed store, hash-verified

382** errors, return an error code with an error message in the stack.
383*/
384static int lookforfunc (lua_State *L, const char *path, const char *sym) {
385 void *reg = checkclib(L, path); /* check loaded C libraries */
386 if (reg == NULL) { /* must load library? */
387 reg = lsys_load(L, path, *sym == '*'); /* global symbols if 'sym'=='*' */
388 if (reg == NULL) return ERRLIB; /* unable to load library */
389 addtoclib(L, path, reg);
390 }
391 if (*sym == '*') { /* loading only library (no function)? */
392 lua_pushboolean(L, 1); /* return 'true' */
393 return 0; /* no errors */
394 }
395 else {
396 lua_CFunction f = lsys_sym(L, reg, sym);
397 if (f == NULL)
398 return ERRFUNC; /* unable to find function */
399 lua_pushcfunction(L, f); /* else create new function */
400 return 0; /* no errors */
401 }
402}
403
404
405static int ll_loadlib (lua_State *L) {

Callers 2

ll_loadlibFunction · 0.70
loadfuncFunction · 0.70

Calls 5

checkclibFunction · 0.70
lsys_loadFunction · 0.70
addtoclibFunction · 0.70
lua_pushbooleanFunction · 0.70
lsys_symFunction · 0.70

Tested by

no test coverage detected