MCPcopy Create free account
hub / github.com/Shopify/goluago / pullArrayRec

Function pullArrayRec

util/deep_pull.go:109–131  ·  view source on GitHub ↗
(l *lua.State, idx int)

Source from the content-addressed store, hash-verified

107}
108
109func pullArrayRec(l *lua.State, idx int) (interface{}, error) {
110 table := make([]interface{}, lua.LengthEx(l, idx))
111
112 l.PushNil()
113 for l.Next(idx) {
114 k, ok := l.ToInteger(-2)
115 if !ok {
116 l.Pop(2)
117 return nil, fmt.Errorf("pull array: expected numeric index, got '%s'", l.TypeOf(-2))
118 }
119
120 v, err := toGoValue(l, -1)
121 if err != nil {
122 l.Pop(2)
123 return nil, err
124 }
125
126 table[k-1] = v
127 l.Pop(1)
128 }
129
130 return table, nil
131}
132
133func toGoValue(l *lua.State, idx int) (interface{}, error) {
134 t := l.TypeOf(idx)

Callers 1

pullTableRecFunction · 0.85

Calls 1

toGoValueFunction · 0.85

Tested by

no test coverage detected