Skip to content

Commit

Permalink
修复空字符串被移除的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
wingcd committed May 22, 2024
1 parent d22ee54 commit ac0d873
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions generator/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,20 @@ func convertToLuaValue(L *lua.LState, obj interface{}) lua.LValue {
}

reflectValue := reflect.ValueOf(obj)

switch reflectValue.Kind() {
case reflect.String:
return lua.LString(reflectValue.String())
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return lua.LNumber(reflectValue.Int())
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
return lua.LNumber(reflectValue.Uint())
case reflect.Float32, reflect.Float64:
return lua.LNumber(reflectValue.Float())
case reflect.Bool:
return lua.LBool(reflectValue.Bool())
}

if reflectValue.IsZero() {
return lua.LNil
}
Expand Down

0 comments on commit ac0d873

Please sign in to comment.