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

Function getIntField

oslib.go:15–39  ·  view source on GitHub ↗
(L *LState, tb *LTable, key string, v int)

Source from the content-addressed store, hash-verified

13}
14
15func getIntField(L *LState, tb *LTable, key string, v int) int {
16 ret := tb.RawGetString(key)
17
18 switch lv := ret.(type) {
19 case LNumber:
20 return int(lv)
21 case LString:
22 slv := string(lv)
23 slv = strings.TrimLeft(slv, " ")
24 if strings.HasPrefix(slv, "0") && !strings.HasPrefix(slv, "0x") && !strings.HasPrefix(slv, "0X") {
25 // Standard lua interpreter only support decimal and hexadecimal
26 slv = strings.TrimLeft(slv, "0")
27 if slv == "" {
28 return 0
29 }
30 }
31 if num, err := parseNumber(slv); err == nil {
32 return int(num)
33 }
34 default:
35 return v
36 }
37
38 return v
39}
40
41func getBoolField(L *LState, tb *LTable, key string, v bool) bool {
42 ret := tb.RawGetString(key)

Callers 1

osTimeFunction · 0.85

Calls 2

parseNumberFunction · 0.85
RawGetStringMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…