58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
for i=0,sz do dest[i] = [uint8](rnd()) end
return sz
end
end
m.random = macro(function(typ, from, to)
local ty = typ:astype()
return quote
var v: ty
m.spray([&uint8](&v), sizeof(ty))
v = v % (to - from) + from -- only works with unsigned!!
in v end
end)
|
|
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
for i=0,sz do dest[i] = [uint8](rnd()) end
return sz
end
end
m.random = macro(function(typ, from, to)
local ty = typ:astype()
from = from or 0
to = to or ty:max()
return quote
var v: ty
m.spray([&uint8](&v), sizeof(ty))
v = v % (to - from) + from -- only works with unsigned!!
in v end
end)
|