2020-11-05 06:39:54 -05:00
|
|
|
# Test uctypes array, load and store, with array size > 1
|
|
|
|
|
|
|
|
try:
|
|
|
|
import uctypes
|
|
|
|
except ImportError:
|
|
|
|
print("SKIP")
|
|
|
|
raise SystemExit
|
|
|
|
|
2020-11-05 06:42:28 -05:00
|
|
|
N = 5
|
2020-11-05 06:39:54 -05:00
|
|
|
|
|
|
|
for endian in ("NATIVE", "LITTLE_ENDIAN", "BIG_ENDIAN"):
|
|
|
|
for type_ in ("INT8", "UINT8", "INT16", "UINT16", "INT32", "UINT32", "INT64", "UINT64"):
|
|
|
|
desc = {"arr": (uctypes.ARRAY | 0, getattr(uctypes, type_) | N)}
|
|
|
|
sz = uctypes.sizeof(desc)
|
|
|
|
data = bytearray(sz)
|
|
|
|
s = uctypes.struct(uctypes.addressof(data), desc, getattr(uctypes, endian))
|
|
|
|
for i in range(N):
|
2020-11-05 06:42:28 -05:00
|
|
|
s.arr[i] = i - 2
|
2020-11-05 06:39:54 -05:00
|
|
|
print(endian, type_, sz, *(s.arr[i] for i in range(N)))
|