MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / aux_upvalue

Function aux_upvalue

extlibs/lua/src/lapi.c:1312–1336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1310
1311
1312static const char *aux_upvalue (TValue *fi, int n, TValue **val,
1313 GCObject **owner) {
1314 switch (ttypetag(fi)) {
1315 case LUA_VCCL: { /* C closure */
1316 CClosure *f = clCvalue(fi);
1317 if (!(cast_uint(n) - 1u < cast_uint(f->nupvalues)))
1318 return NULL; /* 'n' not in [1, f->nupvalues] */
1319 *val = &f->upvalue[n-1];
1320 if (owner) *owner = obj2gco(f);
1321 return "";
1322 }
1323 case LUA_VLCL: { /* Lua closure */
1324 LClosure *f = clLvalue(fi);
1325 TString *name;
1326 Proto *p = f->p;
1327 if (!(cast_uint(n) - 1u < cast_uint(p->sizeupvalues)))
1328 return NULL; /* 'n' not in [1, p->sizeupvalues] */
1329 *val = f->upvals[n-1]->v;
1330 if (owner) *owner = obj2gco(f->upvals[n - 1]);
1331 name = p->upvalues[n-1].name;
1332 return (name == NULL) ? "(no name)" : getstr(name);
1333 }
1334 default: return NULL; /* not a closure */
1335 }
1336}
1337
1338
1339LUA_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