MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / aux_upvalue

Function aux_upvalue

lib/lua/src/lapi.c:1357–1381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1355
1356
1357static const char *aux_upvalue (TValue *fi, int n, TValue **val,
1358 GCObject **owner) {
1359 switch (ttypetag(fi)) {
1360 case LUA_VCCL: { /* C closure */
1361 CClosure *f = clCvalue(fi);
1362 if (!(cast_uint(n) - 1u < cast_uint(f->nupvalues)))
1363 return NULL; /* 'n' not in [1, f->nupvalues] */
1364 *val = &f->upvalue[n-1];
1365 if (owner) *owner = obj2gco(f);
1366 return "";
1367 }
1368 case LUA_VLCL: { /* Lua closure */
1369 LClosure *f = clLvalue(fi);
1370 TString *name;
1371 Proto *p = f->p;
1372 if (!(cast_uint(n) - 1u < cast_uint(p->sizeupvalues)))
1373 return NULL; /* 'n' not in [1, p->sizeupvalues] */
1374 *val = f->upvals[n-1]->v.p;
1375 if (owner) *owner = obj2gco(f->upvals[n - 1]);
1376 name = p->upvalues[n-1].name;
1377 return (name == NULL) ? "(no name)" : getstr(name);
1378 }
1379 default: return NULL; /* not a closure */
1380 }
1381}
1382
1383
1384LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) {

Callers 2

lua_getupvalueFunction · 0.85
lua_setupvalueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected