fix: ptr handling in int conv bindings for lua.h

This commit is contained in:
Erica Marigold 2024-07-20 13:17:29 +05:30
parent 0884e8d7c0
commit e468a36ec7
No known key found for this signature in database
GPG key ID: 2768CC0C23D245D1

View file

@ -203,31 +203,40 @@ func LessThan(L *LuaState, idx1, idx2 int32) bool {
return C.lua_lessthan(L, C.int(idx1), C.int(idx2)) != 0 return C.lua_lessthan(L, C.int(idx1), C.int(idx2)) != 0
} }
func ToNumberX(L *LuaState, idx int32, isnum bool) LuaNumber { func ToNumberX(L *LuaState, idx int32, isnum *bool) LuaNumber {
isnumInner := C.int(0) cisnumber := C.int(0)
if isnum { if *isnum {
isnumInner = C.int(1) cisnumber = C.int(1)
} }
return LuaNumber(C.lua_tonumberx(L, C.int(idx), &isnumInner)) num := LuaNumber(C.lua_tonumberx(L, C.int(idx), &cisnumber))
*isnum = cisnumber != C.int(0)
return num
} }
func ToIntegerX(L *LuaState, idx int32, isnum bool) LuaInteger { func ToIntegerX(L *LuaState, idx int32, isnum *bool) LuaInteger {
isnumInner := C.int(0) cisnumber := C.int(0)
if isnum { if *isnum {
isnumInner = C.int(1) cisnumber = C.int(1)
} }
return LuaInteger(C.lua_tointegerx(L, C.int(idx), &isnumInner)) integer := LuaInteger(C.lua_tointegerx(L, C.int(idx), &cisnumber))
*isnum = cisnumber != C.int(0)
return integer
} }
func ToUnsignedX(L *LuaState, idx int32, isnum bool) LuaUnsigned { func ToUnsignedX(L *LuaState, idx int32, isnum *bool) LuaUnsigned {
isnumInner := C.int(0) cisnumber := C.int(0)
if isnum { if *isnum {
isnumInner = C.int(1) cisnumber = C.int(1)
} }
return LuaUnsigned(C.lua_tounsignedx(L, C.int(idx), &isnumInner)) unsigned := LuaUnsigned(C.lua_tounsignedx(L, C.int(idx), &cisnumber))
*isnum = cisnumber != C.int(0)
return unsigned
} }
func ToVector(L *LuaState, idx int32) { func ToVector(L *LuaState, idx int32) {