MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / aux_upvalue

Function aux_upvalue

3rd/lua-5.4.3/src/lapi.c:1349–1373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1347
1348
1349static const char *aux_upvalue (TValue *fi, int n, TValue **val,
1350 GCObject **owner) {
1351 switch (ttypetag(fi)) {
1352 case LUA_VCCL: { /* C closure */
1353 CClosure *f = clCvalue(fi);
1354 if (!(cast_uint(n) - 1u < cast_uint(f->nupvalues)))
1355 return NULL; /* 'n' not in [1, f->nupvalues] */
1356 *val = &f->upvalue[n-1];
1357 if (owner) *owner = obj2gco(f);
1358 return "";
1359 }
1360 case LUA_VLCL: { /* Lua closure */
1361 LClosure *f = clLvalue(fi);
1362 TString *name;
1363 Proto *p = f->p;
1364 if (!(cast_uint(n) - 1u < cast_uint(p->sizeupvalues)))
1365 return NULL; /* 'n' not in [1, p->sizeupvalues] */
1366 *val = f->upvals[n-1]->v;
1367 if (owner) *owner = obj2gco(f->upvals[n - 1]);
1368 name = p->upvalues[n-1].name;
1369 return (name == NULL) ? "(no name)" : getstr(name);
1370 }
1371 default: return NULL; /* not a closure */
1372 }
1373}
1374
1375
1376LUA_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