2010-07-25 23:45:09 -05:00
|
|
|
/**
|
|
|
|
* Bindings the runtime's random number generator (ISAAC).
|
|
|
|
*/
|
|
|
|
|
|
|
|
native "rust" mod rustrt {
|
2010-09-22 17:44:13 -05:00
|
|
|
type rctx;
|
|
|
|
fn rand_new() -> rctx;
|
|
|
|
fn rand_next(rctx c) -> u32;
|
|
|
|
fn rand_free(rctx c);
|
2010-07-25 23:45:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
type rng = obj { fn next() -> u32; };
|
|
|
|
|
|
|
|
fn mk_rng() -> rng {
|
2010-09-22 17:44:13 -05:00
|
|
|
obj rt_rng(rustrt.rctx c) {
|
|
|
|
fn next() -> u32 {
|
|
|
|
ret rustrt.rand_next(c);
|
|
|
|
}
|
|
|
|
drop {
|
|
|
|
rustrt.rand_free(c);
|
|
|
|
}
|
2010-07-25 23:45:09 -05:00
|
|
|
}
|
|
|
|
|
2010-09-22 17:44:13 -05:00
|
|
|
ret rt_rng(rustrt.rand_new());
|
2010-07-25 23:45:09 -05:00
|
|
|
}
|
2010-09-22 17:44:13 -05:00
|
|
|
|
|
|
|
// Local Variables:
|
|
|
|
// mode: rust;
|
|
|
|
// fill-column: 78;
|
|
|
|
// indent-tabs-mode: nil
|
|
|
|
// c-basic-offset: 4
|
|
|
|
// buffer-file-coding-system: utf-8-unix
|
|
|
|
// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
|
|
|
// End:
|