Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Commit

Permalink
Add support for slices of other uint and int types (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikewalker125 authored and captncraig committed May 23, 2019
1 parent e0a55b9 commit cbe6696
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion wmi.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func (c *Client) loadEntity(dst interface{}, src *ole.IDispatch) (errFieldMismat
}
f.Set(fArr)
}
case reflect.Uint8:
case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
safeArray := prop.ToArray()
if safeArray != nil {
arr := safeArray.ToValueArray()
Expand All @@ -398,6 +398,17 @@ func (c *Client) loadEntity(dst interface{}, src *ole.IDispatch) (errFieldMismat
}
f.Set(fArr)
}
case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
safeArray := prop.ToArray()
if safeArray != nil {
arr := safeArray.ToValueArray()
fArr := reflect.MakeSlice(f.Type(), len(arr), len(arr))
for i, v := range arr {
s := fArr.Index(i)
s.SetInt(reflect.ValueOf(v).Int())
}
f.Set(fArr)
}
default:
return &ErrFieldMismatch{
StructType: of.Type(),
Expand Down

0 comments on commit cbe6696

Please sign in to comment.