summaryrefslogtreecommitdiffhomepage
path: root/examples
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 /examples
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 'examples')
-rw-r--r--examples/exception-handler.c2
-rw-r--r--examples/execute-file.c2
-rw-r--r--examples/execute-string.c2
-rw-r--r--examples/native-function.c12
-rw-r--r--examples/state-reset.c2
-rw-r--r--examples/state-reuse.c2
6 files changed, 11 insertions, 11 deletions
diff --git a/examples/exception-handler.c b/examples/exception-handler.c
index e2b1058..1e722ec 100644
--- a/examples/exception-handler.c
+++ b/examples/exception-handler.c
@@ -79,7 +79,7 @@ int main(int argc, char **argv)
uc_vm_init(&vm, &config);
/* load standard library into global VM scope */
- uc_load_stdlib(uc_vm_scope_get(&vm));
+ uc_stdlib_load(uc_vm_scope_get(&vm));
/* register custom exception handler */
uc_vm_exception_handler_set(&vm, log_exception);
diff --git a/examples/execute-file.c b/examples/execute-file.c
index 2e86f7d..12910e3 100644
--- a/examples/execute-file.c
+++ b/examples/execute-file.c
@@ -66,7 +66,7 @@ int main(int argc, char **argv)
uc_vm_init(&vm, &config);
/* load standard library into global VM scope */
- uc_load_stdlib(uc_vm_scope_get(&vm));
+ uc_stdlib_load(uc_vm_scope_get(&vm));
/* add global variables x and y to VM scope */
ucv_object_add(uc_vm_scope_get(&vm), "x", ucv_int64_new(123));
diff --git a/examples/execute-string.c b/examples/execute-string.c
index c51a600..1fcc966 100644
--- a/examples/execute-string.c
+++ b/examples/execute-string.c
@@ -76,7 +76,7 @@ int main(int argc, char **argv)
uc_vm_init(&vm, &config);
/* load standard library into global VM scope */
- uc_load_stdlib(uc_vm_scope_get(&vm));
+ uc_stdlib_load(uc_vm_scope_get(&vm));
/* add global variables x and y to VM scope */
ucv_object_add(uc_vm_scope_get(&vm), "x", ucv_int64_new(123));
diff --git a/examples/native-function.c b/examples/native-function.c
index 89b3d15..9c643ec 100644
--- a/examples/native-function.c
+++ b/examples/native-function.c
@@ -39,8 +39,8 @@ static uc_parse_config_t config = {
static uc_value_t *
multiply_two_numbers(uc_vm_t *vm, size_t nargs)
{
- uc_value_t *x = uc_get_arg(0);
- uc_value_t *y = uc_get_arg(1);
+ uc_value_t *x = uc_fn_arg(0);
+ uc_value_t *y = uc_fn_arg(1);
return ucv_double_new(ucv_to_double(x) * ucv_to_double(y));
}
@@ -51,7 +51,7 @@ add_all_numbers(uc_vm_t *vm, size_t nargs)
double res = 0.0;
for (size_t n = 0; n < nargs; n++)
- res += ucv_to_double(uc_get_arg(n));
+ res += ucv_to_double(uc_fn_arg(n));
return ucv_double_new(res);
}
@@ -82,11 +82,11 @@ int main(int argc, char **argv)
uc_vm_init(&vm, &config);
/* load standard library into global VM scope */
- uc_load_stdlib(uc_vm_scope_get(&vm));
+ uc_stdlib_load(uc_vm_scope_get(&vm));
/* register our native functions as "add" and "multiply" */
- uc_add_function(uc_vm_scope_get(&vm), "add", add_all_numbers);
- uc_add_function(uc_vm_scope_get(&vm), "multiply", multiply_two_numbers);
+ uc_function_register(uc_vm_scope_get(&vm), "add", add_all_numbers);
+ uc_function_register(uc_vm_scope_get(&vm), "multiply", multiply_two_numbers);
/* execute program function */
int return_code = uc_vm_execute(&vm, progfunc, NULL);
diff --git a/examples/state-reset.c b/examples/state-reset.c
index 893ea26..692aa76 100644
--- a/examples/state-reset.c
+++ b/examples/state-reset.c
@@ -66,7 +66,7 @@ int main(int argc, char **argv)
uc_vm_init(&vm, &config);
/* load standard library into global VM scope */
- uc_load_stdlib(uc_vm_scope_get(&vm));
+ uc_stdlib_load(uc_vm_scope_get(&vm));
printf("Iteration %d: ", i + 1);
diff --git a/examples/state-reuse.c b/examples/state-reuse.c
index 4ebf556..7e2c44f 100644
--- a/examples/state-reuse.c
+++ b/examples/state-reuse.c
@@ -65,7 +65,7 @@ int main(int argc, char **argv)
uc_vm_init(&vm, &config);
/* load standard library into global VM scope */
- uc_load_stdlib(uc_vm_scope_get(&vm));
+ uc_stdlib_load(uc_vm_scope_get(&vm));
/* execute compiled program function five times */
for (int i = 0; i < 5; i++) {