summaryrefslogtreecommitdiffhomepage
path: root/lib/math.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2021-07-11 07:18:37 +0200
committerJo-Philipp Wich <jo@mein.io>2021-07-11 15:49:14 +0200
commitd5b25f942147b09511d77d5470cd38a1e1643fb9 (patch)
tree40542b06a966366e2e8a3a0118e756874a838ce6 /lib/math.c
parentcc4ce8dfd13e833702c949e56049443cd01c0dfb (diff)
treewide: harmonize function naming
- Ensure that most functions follow the subject_verb naming schema - Move type related function from value.c to types.c - Rename value.c to vallist.c Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'lib/math.c')
-rw-r--r--lib/math.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/math.c b/lib/math.c
index e2c2fd8..c4a08e3 100644
--- a/lib/math.c
+++ b/lib/math.c
@@ -24,7 +24,7 @@ static bool srand_called = false;
static uc_value_t *
uc_abs(uc_vm_t *vm, size_t nargs)
{
- uc_value_t *v = uc_get_arg(0);
+ uc_value_t *v = uc_fn_arg(0);
uc_type_t t;
int64_t n;
double d;
@@ -32,7 +32,7 @@ uc_abs(uc_vm_t *vm, size_t nargs)
if (ucv_type(v) == UC_NULL)
return ucv_double_new(NAN);
- t = uc_to_number(v, &n, &d);
+ t = ucv_cast_number(v, &n, &d);
if (t == UC_DOUBLE)
return (isnan(d) || d < 0) ? ucv_double_new(-d) : ucv_get(v);
@@ -43,8 +43,8 @@ uc_abs(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_atan2(uc_vm_t *vm, size_t nargs)
{
- double d1 = uc_to_double(uc_get_arg(0));
- double d2 = uc_to_double(uc_get_arg(1));
+ double d1 = ucv_to_double(uc_fn_arg(0));
+ double d2 = ucv_to_double(uc_fn_arg(1));
if (isnan(d1) || isnan(d2))
return ucv_double_new(NAN);
@@ -55,7 +55,7 @@ uc_atan2(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_cos(uc_vm_t *vm, size_t nargs)
{
- double d = uc_to_double(uc_get_arg(0));
+ double d = ucv_to_double(uc_fn_arg(0));
if (isnan(d))
return ucv_double_new(NAN);
@@ -66,7 +66,7 @@ uc_cos(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_exp(uc_vm_t *vm, size_t nargs)
{
- double d = uc_to_double(uc_get_arg(0));
+ double d = ucv_to_double(uc_fn_arg(0));
if (isnan(d))
return ucv_double_new(NAN);
@@ -77,7 +77,7 @@ uc_exp(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_log(uc_vm_t *vm, size_t nargs)
{
- double d = uc_to_double(uc_get_arg(0));
+ double d = ucv_to_double(uc_fn_arg(0));
if (isnan(d))
return ucv_double_new(NAN);
@@ -88,7 +88,7 @@ uc_log(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_sin(uc_vm_t *vm, size_t nargs)
{
- double d = uc_to_double(uc_get_arg(0));
+ double d = ucv_to_double(uc_fn_arg(0));
if (isnan(d))
return ucv_double_new(NAN);
@@ -99,7 +99,7 @@ uc_sin(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_sqrt(uc_vm_t *vm, size_t nargs)
{
- double d = uc_to_double(uc_get_arg(0));
+ double d = ucv_to_double(uc_fn_arg(0));
if (isnan(d))
return ucv_double_new(NAN);
@@ -110,8 +110,8 @@ uc_sqrt(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_pow(uc_vm_t *vm, size_t nargs)
{
- double x = uc_to_double(uc_get_arg(0));
- double y = uc_to_double(uc_get_arg(1));
+ double x = ucv_to_double(uc_fn_arg(0));
+ double y = ucv_to_double(uc_fn_arg(1));
if (isnan(x) || isnan(y))
return ucv_double_new(NAN);
@@ -137,7 +137,7 @@ uc_rand(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_srand(uc_vm_t *vm, size_t nargs)
{
- int64_t n = uc_to_int64(uc_get_arg(0));
+ int64_t n = ucv_to_integer(uc_fn_arg(0));
srand((unsigned int)n);
srand_called = true;
@@ -145,7 +145,7 @@ uc_srand(uc_vm_t *vm, size_t nargs)
return NULL;
}
-static const uc_cfunction_list_t math_fns[] = {
+static const uc_function_list_t math_fns[] = {
{ "abs", uc_abs },
{ "atan2", uc_atan2 },
{ "cos", uc_cos },
@@ -160,5 +160,5 @@ static const uc_cfunction_list_t math_fns[] = {
void uc_module_init(uc_vm_t *vm, uc_value_t *scope)
{
- uc_add_functions(scope, math_fns);
+ uc_function_list_register(scope, math_fns);
}