From dd7595a3475407a7fa96a97393bae8c5220e8762 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Wed, 4 Jan 2012 18:41:13 +1000 Subject: Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje. Note that embryo wont be used, but I'm not sure yet if you can build edje without it. --- libraries/embryo/src/lib/embryo_rand.c | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 libraries/embryo/src/lib/embryo_rand.c (limited to 'libraries/embryo/src/lib/embryo_rand.c') diff --git a/libraries/embryo/src/lib/embryo_rand.c b/libraries/embryo/src/lib/embryo_rand.c new file mode 100644 index 0000000..627f7ed --- /dev/null +++ b/libraries/embryo/src/lib/embryo_rand.c @@ -0,0 +1,36 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include + +#include "Embryo.h" +#include "embryo_private.h" + +/* exported random number api */ + +static Embryo_Cell +_embryo_rand_rand(Embryo_Program *ep __UNUSED__, Embryo_Cell *params __UNUSED__) +{ + return (Embryo_Cell)(rand() & 0xffff); +} + +static Embryo_Cell +_embryo_rand_randf(Embryo_Program *ep __UNUSED__, Embryo_Cell *params __UNUSED__) +{ + double r; + float f; + + r = (double)(rand() & 0xffff) / 65535.0; + f = (float)r; + return EMBRYO_FLOAT_TO_CELL(f); +} + +/* functions used by the rest of embryo */ + +void +_embryo_rand_init(Embryo_Program *ep) +{ + embryo_program_native_call_add(ep, "rand", _embryo_rand_rand); + embryo_program_native_call_add(ep, "randf", _embryo_rand_randf); +} -- cgit v1.1