diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-05-23 18:14:15 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-05-23 18:14:15 +0100 |
commit | 714eb56e1760fdfb26afccde92664d3a2f1e8435 (patch) | |
tree | 84d1399acbb92f852b4bd64f9ea5412680b0c6ab /contrib/lua-torch/torch7/random.lua | |
parent | 220a51ff68013dd668a45b78c60a7b8bfc10f074 (diff) | |
download | rspamd-714eb56e1760fdfb26afccde92664d3a2f1e8435.tar.gz rspamd-714eb56e1760fdfb26afccde92664d3a2f1e8435.zip |
[Minor] Move lua contrib libraries to lua- prefix
Diffstat (limited to 'contrib/lua-torch/torch7/random.lua')
-rw-r--r-- | contrib/lua-torch/torch7/random.lua | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/contrib/lua-torch/torch7/random.lua b/contrib/lua-torch/torch7/random.lua new file mode 100644 index 000000000..59bbd7b1a --- /dev/null +++ b/contrib/lua-torch/torch7/random.lua @@ -0,0 +1,53 @@ +local wrap = require 'cwrap' + +require 'torchcwrap' + +local interface = wrap.CInterface.new() + +interface:print( + [[ +#include "luaT.h" +#include "TH.h" + +extern void torch_Generator_init(lua_State *L); +extern void torch_Generator_new(lua_State *L); + ]]) + +for _,name in ipairs({"seed", "initialSeed"}) do + interface:wrap(name, + string.format("THRandom_%s",name), + {{name='Generator', default=true}, + {name="long", creturned=true}}) +end + +interface:wrap('manualSeed', + 'THRandom_manualSeed', + {{name='Generator', default=true}, + {name="long"}}) + +interface:wrap('getRNGState', + 'THByteTensor_getRNGState', + {{name='Generator', default=true}, + {name='ByteTensor',default=true,returned=true,method={default='nil'}} + }) + +interface:wrap('setRNGState', + 'THByteTensor_setRNGState', + {{name='Generator', default=true}, + {name='ByteTensor',default=true,returned=true,method={default='nil'}} + }) + +interface:register("random__") + +interface:print( + [[ +void torch_random_init(lua_State *L) +{ + torch_Generator_init(L); + torch_Generator_new(L); + lua_setfield(L, -2, "_gen"); + luaT_setfuncs(L, random__, 0); +} +]]) + +interface:tofile(arg[1]) |