MCPcopy Index your code
hub / github.com/yuin/gopher-lua / FindTable

Method FindTable

auxlib.go:264–283  ·  view source on GitHub ↗

* }}} */ * table operations {{{ */

(obj *LTable, n string, size int)

Source from the content-addressed store, hash-verified

262/* table operations {{{ */
263
264func (ls *LState) FindTable(obj *LTable, n string, size int) LValue {
265 names := strings.Split(n, ".")
266 curobj := obj
267 for _, name := range names {
268 if curobj.Type() != LTTable {
269 return LNil
270 }
271 nextobj := ls.RawGet(curobj, LString(name))
272 if nextobj == LNil {
273 tb := ls.CreateTable(0, size)
274 ls.RawSet(curobj, LString(name), tb)
275 curobj = tb
276 } else if nextobj.Type() != LTTable {
277 return LNil
278 } else {
279 curobj = nextobj.(*LTable)
280 }
281 }
282 return curobj
283}
284
285/* }}} */
286

Callers 2

RegisterModuleMethod · 0.95
loModuleFunction · 0.80

Calls 5

RawGetMethod · 0.95
CreateTableMethod · 0.95
RawSetMethod · 0.95
LStringTypeAlias · 0.85
TypeMethod · 0.65

Tested by

no test coverage detected