2008-10-21 01:40:54 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2012-10-26 02:01:52 -07:00
|
|
|
#include <Eina.h>
|
|
|
|
|
2008-10-21 01:40:54 -07:00
|
|
|
#include "Embryo.h"
|
2004-03-29 03:58:57 -08:00
|
|
|
#include "embryo_private.h"
|
|
|
|
|
|
|
|
/* exported random number api */
|
|
|
|
|
|
|
|
static Embryo_Cell
|
2012-10-26 02:01:52 -07:00
|
|
|
_embryo_rand_rand(Embryo_Program *ep EINA_UNUSED, Embryo_Cell *params EINA_UNUSED)
|
2004-03-29 03:58:57 -08:00
|
|
|
{
|
|
|
|
return (Embryo_Cell)(rand() & 0xffff);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Embryo_Cell
|
2012-10-26 02:01:52 -07:00
|
|
|
_embryo_rand_randf(Embryo_Program *ep EINA_UNUSED, Embryo_Cell *params EINA_UNUSED)
|
2004-03-29 03:58:57 -08:00
|
|
|
{
|
|
|
|
double r;
|
|
|
|
float f;
|
2008-04-11 12:06:18 -07:00
|
|
|
|
2004-03-29 03:58:57 -08:00
|
|
|
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);
|
|
|
|
}
|