MCPcopy Index your code
hub / github.com/Shopify/go-lua / readLine

Function readLine

io.go:136–161  ·  view source on GitHub ↗
(l *State)

Source from the content-addressed store, hash-verified

134}
135
136func readLine(l *State) int {
137 s := l.ToUserData(UpValueIndex(1)).(*stream)
138 argCount, _ := l.ToInteger(UpValueIndex(2))
139 if s.close == nil {
140 Errorf(l, "file is already closed")
141 }
142 l.SetTop(1)
143 for i := 1; i <= argCount; i++ {
144 l.PushValue(UpValueIndex(3 + i))
145 }
146 resultCount := read(l, s.f, 2)
147 l.assert(resultCount > 0)
148 if !l.IsNil(-resultCount) {
149 return resultCount
150 }
151 if resultCount > 1 {
152 m, _ := l.ToString(-resultCount + 1)
153 Errorf(l, m)
154 }
155 if l.ToBoolean(UpValueIndex(3)) {
156 l.SetTop(0)
157 l.PushValue(UpValueIndex(1))
158 closeHelper(l)
159 }
160 return 0
161}
162
163func lines(l *State, shouldClose bool) {
164 argCount := l.Top() - 1

Callers

nothing calls this directly

Calls 12

UpValueIndexFunction · 0.85
ErrorfFunction · 0.85
readFunction · 0.85
closeHelperFunction · 0.85
ToUserDataMethod · 0.80
ToIntegerMethod · 0.80
SetTopMethod · 0.80
PushValueMethod · 0.80
IsNilMethod · 0.80
ToStringMethod · 0.80
ToBooleanMethod · 0.80
assertMethod · 0.45

Tested by

no test coverage detected