summaryrefslogtreecommitdiffhomepage
path: root/lib
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
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')
-rw-r--r--lib/fs.c102
-rw-r--r--lib/math.c28
-rw-r--r--lib/ubus.c28
-rw-r--r--lib/uci.c108
4 files changed, 133 insertions, 133 deletions
diff --git a/lib/fs.c b/lib/fs.c
index a6a5227..485dfb1 100644
--- a/lib/fs.c
+++ b/lib/fs.c
@@ -52,14 +52,14 @@ uc_fs_error(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_fs_read_common(uc_vm_t *vm, size_t nargs, const char *type)
{
- uc_value_t *limit = uc_get_arg(0);
+ uc_value_t *limit = uc_fn_arg(0);
uc_value_t *rv = NULL;
char buf[128], *p = NULL, *tmp;
size_t rlen, len = 0;
const char *lstr;
int64_t lsize;
- FILE **fp = uc_get_self(type);
+ FILE **fp = uc_fn_this(type);
if (!fp || !*fp)
err_return(EBADF);
@@ -144,11 +144,11 @@ uc_fs_read_common(uc_vm_t *vm, size_t nargs, const char *type)
static uc_value_t *
uc_fs_write_common(uc_vm_t *vm, size_t nargs, const char *type)
{
- uc_value_t *data = uc_get_arg(0);
+ uc_value_t *data = uc_fn_arg(0);
size_t len, wsize;
char *str;
- FILE **fp = uc_get_self(type);
+ FILE **fp = uc_fn_this(type);
if (!fp || !*fp)
err_return(EBADF);
@@ -174,7 +174,7 @@ uc_fs_write_common(uc_vm_t *vm, size_t nargs, const char *type)
static uc_value_t *
uc_fs_pclose(uc_vm_t *vm, size_t nargs)
{
- FILE **fp = uc_get_self("fs.proc");
+ FILE **fp = uc_fn_this("fs.proc");
int rc;
if (!fp || !*fp)
@@ -210,8 +210,8 @@ uc_fs_pwrite(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_fs_popen(uc_vm_t *vm, size_t nargs)
{
- uc_value_t *comm = uc_get_arg(0);
- uc_value_t *mode = uc_get_arg(1);
+ uc_value_t *comm = uc_fn_arg(0);
+ uc_value_t *mode = uc_fn_arg(1);
FILE *fp;
if (ucv_type(comm) != UC_STRING)
@@ -223,14 +223,14 @@ uc_fs_popen(uc_vm_t *vm, size_t nargs)
if (!fp)
err_return(errno);
- return uc_alloc_ressource(proc_type, fp);
+ return uc_ressource_new(proc_type, fp);
}
static uc_value_t *
uc_fs_close(uc_vm_t *vm, size_t nargs)
{
- FILE **fp = uc_get_self("fs.file");
+ FILE **fp = uc_fn_this("fs.file");
if (!fp || !*fp)
err_return(EBADF);
@@ -256,12 +256,12 @@ uc_fs_write(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_fs_seek(uc_vm_t *vm, size_t nargs)
{
- uc_value_t *ofs = uc_get_arg(0);
- uc_value_t *how = uc_get_arg(1);
+ uc_value_t *ofs = uc_fn_arg(0);
+ uc_value_t *how = uc_fn_arg(1);
int whence, res;
long offset;
- FILE **fp = uc_get_self("fs.file");
+ FILE **fp = uc_fn_this("fs.file");
if (!fp || !*fp)
err_return(EBADF);
@@ -293,7 +293,7 @@ uc_fs_tell(uc_vm_t *vm, size_t nargs)
{
long offset;
- FILE **fp = uc_get_self("fs.file");
+ FILE **fp = uc_fn_this("fs.file");
if (!fp || !*fp)
err_return(EBADF);
@@ -309,8 +309,8 @@ uc_fs_tell(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_fs_open(uc_vm_t *vm, size_t nargs)
{
- uc_value_t *path = uc_get_arg(0);
- uc_value_t *mode = uc_get_arg(1);
+ uc_value_t *path = uc_fn_arg(0);
+ uc_value_t *mode = uc_fn_arg(1);
FILE *fp;
if (ucv_type(path) != UC_STRING)
@@ -322,14 +322,14 @@ uc_fs_open(uc_vm_t *vm, size_t nargs)
if (!fp)
err_return(errno);
- return uc_alloc_ressource(file_type, fp);
+ return uc_ressource_new(file_type, fp);
}
static uc_value_t *
uc_fs_readdir(uc_vm_t *vm, size_t nargs)
{
- DIR **dp = uc_get_self("fs.dir");
+ DIR **dp = uc_fn_this("fs.dir");
struct dirent *e;
if (!dp || !*dp)
@@ -347,7 +347,7 @@ uc_fs_readdir(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_fs_telldir(uc_vm_t *vm, size_t nargs)
{
- DIR **dp = uc_get_self("fs.dir");
+ DIR **dp = uc_fn_this("fs.dir");
long position;
if (!dp || !*dp)
@@ -364,8 +364,8 @@ uc_fs_telldir(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_fs_seekdir(uc_vm_t *vm, size_t nargs)
{
- uc_value_t *ofs = uc_get_arg(0);
- DIR **dp = uc_get_self("fs.dir");
+ uc_value_t *ofs = uc_fn_arg(0);
+ DIR **dp = uc_fn_this("fs.dir");
long position;
if (ucv_type(ofs) != UC_INTEGER)
@@ -384,7 +384,7 @@ uc_fs_seekdir(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_fs_closedir(uc_vm_t *vm, size_t nargs)
{
- DIR **dp = uc_get_self("fs.dir");
+ DIR **dp = uc_fn_this("fs.dir");
if (!dp || !*dp)
err_return(EBADF);
@@ -398,7 +398,7 @@ uc_fs_closedir(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_fs_opendir(uc_vm_t *vm, size_t nargs)
{
- uc_value_t *path = uc_get_arg(0);
+ uc_value_t *path = uc_fn_arg(0);
DIR *dp;
if (ucv_type(path) != UC_STRING)
@@ -409,13 +409,13 @@ uc_fs_opendir(uc_vm_t *vm, size_t nargs)
if (!dp)
err_return(errno);
- return uc_alloc_ressource(dir_type, dp);
+ return uc_ressource_new(dir_type, dp);
}
static uc_value_t *
uc_fs_readlink(uc_vm_t *vm, size_t nargs)
{
- uc_value_t *path = uc_get_arg(0);
+ uc_value_t *path = uc_fn_arg(0);
uc_value_t *res;
ssize_t buflen = 0, rv;
char *buf = NULL, *tmp;
@@ -455,7 +455,7 @@ uc_fs_readlink(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_fs_stat_common(uc_vm_t *vm, size_t nargs, bool use_lstat)
{
- uc_value_t *path = uc_get_arg(0);
+ uc_value_t *path = uc_fn_arg(0);
uc_value_t *res, *o;
struct stat st;
int rv;
@@ -551,8 +551,8 @@ uc_fs_lstat(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_fs_mkdir(uc_vm_t *vm, size_t nargs)
{
- uc_value_t *path = uc_get_arg(0);
- uc_value_t *mode = uc_get_arg(1);
+ uc_value_t *path = uc_fn_arg(0);
+ uc_value_t *mode = uc_fn_arg(1);
if (ucv_type(path) != UC_STRING ||
(mode && ucv_type(mode) != UC_INTEGER))
@@ -567,7 +567,7 @@ uc_fs_mkdir(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_fs_rmdir(uc_vm_t *vm, size_t nargs)
{
- uc_value_t *path = uc_get_arg(0);
+ uc_value_t *path = uc_fn_arg(0);
if (ucv_type(path) != UC_STRING)
err_return(EINVAL);
@@ -581,8 +581,8 @@ uc_fs_rmdir(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_fs_symlink(uc_vm_t *vm, size_t nargs)
{
- uc_value_t *dest = uc_get_arg(0);
- uc_value_t *path = uc_get_arg(1);
+ uc_value_t *dest = uc_fn_arg(0);
+ uc_value_t *path = uc_fn_arg(1);
if (ucv_type(dest) != UC_STRING ||
ucv_type(path) != UC_STRING)
@@ -597,7 +597,7 @@ uc_fs_symlink(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_fs_unlink(uc_vm_t *vm, size_t nargs)
{
- uc_value_t *path = uc_get_arg(0);
+ uc_value_t *path = uc_fn_arg(0);
if (ucv_type(path) != UC_STRING)
err_return(EINVAL);
@@ -647,7 +647,7 @@ uc_fs_getcwd(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_fs_chdir(uc_vm_t *vm, size_t nargs)
{
- uc_value_t *path = uc_get_arg(0);
+ uc_value_t *path = uc_fn_arg(0);
if (ucv_type(path) != UC_STRING)
err_return(EINVAL);
@@ -661,8 +661,8 @@ uc_fs_chdir(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_fs_chmod(uc_vm_t *vm, size_t nargs)
{
- uc_value_t *path = uc_get_arg(0);
- uc_value_t *mode = uc_get_arg(1);
+ uc_value_t *path = uc_fn_arg(0);
+ uc_value_t *mode = uc_fn_arg(1);
if (ucv_type(path) != UC_STRING ||
ucv_type(mode) != UC_INTEGER)
@@ -771,9 +771,9 @@ uc_fs_resolve_group(uc_value_t *v, gid_t *gid)
static uc_value_t *
uc_fs_chown(uc_vm_t *vm, size_t nargs)
{
- uc_value_t *path = uc_get_arg(0);
- uc_value_t *user = uc_get_arg(1);
- uc_value_t *group = uc_get_arg(2);
+ uc_value_t *path = uc_fn_arg(0);
+ uc_value_t *user = uc_fn_arg(1);
+ uc_value_t *group = uc_fn_arg(2);
uid_t uid;
gid_t gid;
@@ -793,8 +793,8 @@ uc_fs_chown(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_fs_rename(uc_vm_t *vm, size_t nargs)
{
- uc_value_t *oldpath = uc_get_arg(0);
- uc_value_t *newpath = uc_get_arg(1);
+ uc_value_t *oldpath = uc_fn_arg(0);
+ uc_value_t *newpath = uc_fn_arg(1);
if (ucv_type(oldpath) != UC_STRING ||
ucv_type(newpath) != UC_STRING)
@@ -814,7 +814,7 @@ uc_fs_glob(uc_vm_t *vm, size_t nargs)
size_t i;
for (i = 0; i < nargs; i++) {
- pat = uc_get_arg(i);
+ pat = uc_fn_arg(i);
if (ucv_type(pat) != UC_STRING) {
globfree(&gl);
@@ -835,14 +835,14 @@ uc_fs_glob(uc_vm_t *vm, size_t nargs)
}
-static const uc_cfunction_list_t proc_fns[] = {
+static const uc_function_list_t proc_fns[] = {
{ "read", uc_fs_pread },
{ "write", uc_fs_pwrite },
{ "close", uc_fs_pclose },
{ "error", uc_fs_error },
};
-static const uc_cfunction_list_t file_fns[] = {
+static const uc_function_list_t file_fns[] = {
{ "read", uc_fs_read },
{ "write", uc_fs_write },
{ "seek", uc_fs_seek },
@@ -851,7 +851,7 @@ static const uc_cfunction_list_t file_fns[] = {
{ "error", uc_fs_error },
};
-static const uc_cfunction_list_t dir_fns[] = {
+static const uc_function_list_t dir_fns[] = {
{ "read", uc_fs_readdir },
{ "seek", uc_fs_seekdir },
{ "tell", uc_fs_telldir },
@@ -859,7 +859,7 @@ static const uc_cfunction_list_t dir_fns[] = {
{ "error", uc_fs_error },
};
-static const uc_cfunction_list_t global_fns[] = {
+static const uc_function_list_t global_fns[] = {
{ "error", uc_fs_error },
{ "open", uc_fs_open },
{ "opendir", uc_fs_opendir },
@@ -906,13 +906,13 @@ static void close_dir(void *ud)
void uc_module_init(uc_vm_t *vm, uc_value_t *scope)
{
- uc_add_functions(scope, global_fns);
+ uc_function_list_register(scope, global_fns);
- proc_type = uc_declare_type(vm, "fs.proc", proc_fns, close_proc);
- file_type = uc_declare_type(vm, "fs.file", file_fns, close_file);
- dir_type = uc_declare_type(vm, "fs.dir", dir_fns, close_dir);
+ proc_type = uc_type_declare(vm, "fs.proc", proc_fns, close_proc);
+ file_type = uc_type_declare(vm, "fs.file", file_fns, close_file);
+ dir_type = uc_type_declare(vm, "fs.dir", dir_fns, close_dir);
- ucv_object_add(scope, "stdin", uc_alloc_ressource(file_type, stdin));
- ucv_object_add(scope, "stdout", uc_alloc_ressource(file_type, stdout));
- ucv_object_add(scope, "stderr", uc_alloc_ressource(file_type, stderr));
+ ucv_object_add(scope, "stdin", uc_ressource_new(file_type, stdin));
+ ucv_object_add(scope, "stdout", uc_ressource_new(file_type, stdout));
+ ucv_object_add(scope, "stderr", uc_ressource_new(file_type, stderr));
}
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);
}
diff --git a/lib/ubus.c b/lib/ubus.c
index 79b615c..14e62de 100644
--- a/lib/ubus.c
+++ b/lib/ubus.c
@@ -133,8 +133,8 @@ uc_blob_to_json(uc_vm_t *vm, struct blob_attr *attr, bool table, const char **na
static uc_value_t *
uc_ubus_connect(uc_vm_t *vm, size_t nargs)
{
- uc_value_t *socket = uc_get_arg(0);
- uc_value_t *timeout = uc_get_arg(1);
+ uc_value_t *socket = uc_fn_arg(0);
+ uc_value_t *timeout = uc_fn_arg(1);
uc_value_t *co;
ubus_connection *c;
@@ -168,7 +168,7 @@ uc_ubus_connect(uc_vm_t *vm, size_t nargs)
ubus_add_uloop(c->ctx);
- return uc_alloc_ressource(conn_type, c);
+ return uc_ressource_new(conn_type, c);
}
static void
@@ -201,8 +201,8 @@ uc_ubus_objects_cb(struct ubus_context *c, struct ubus_object_data *o, void *p)
static uc_value_t *
uc_ubus_list(uc_vm_t *vm, size_t nargs)
{
- ubus_connection **c = uc_get_self("ubus.connection");
- uc_value_t *objname = uc_get_arg(0);
+ ubus_connection **c = uc_fn_this("ubus.connection");
+ uc_value_t *objname = uc_fn_arg(0);
uc_value_t *res = NULL;
enum ubus_msg_status rv;
@@ -239,10 +239,10 @@ uc_ubus_call_cb(struct ubus_request *req, int type, struct blob_attr *msg)
static uc_value_t *
uc_ubus_call(uc_vm_t *vm, size_t nargs)
{
- ubus_connection **c = uc_get_self("ubus.connection");
- uc_value_t *objname = uc_get_arg(0);
- uc_value_t *funname = uc_get_arg(1);
- uc_value_t *funargs = uc_get_arg(2);
+ ubus_connection **c = uc_fn_this("ubus.connection");
+ uc_value_t *objname = uc_fn_arg(0);
+ uc_value_t *funname = uc_fn_arg(1);
+ uc_value_t *funargs = uc_fn_arg(2);
uc_value_t *res = NULL;
json_object *o;
enum ubus_msg_status rv;
@@ -284,7 +284,7 @@ uc_ubus_call(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_ubus_disconnect(uc_vm_t *vm, size_t nargs)
{
- ubus_connection **c = uc_get_self("ubus.connection");
+ ubus_connection **c = uc_fn_this("ubus.connection");
if (!c || !*c || !(*c)->ctx)
err_return(UBUS_STATUS_CONNECTION_FAILED);
@@ -296,12 +296,12 @@ uc_ubus_disconnect(uc_vm_t *vm, size_t nargs)
}
-static const uc_cfunction_list_t global_fns[] = {
+static const uc_function_list_t global_fns[] = {
{ "error", uc_ubus_error },
{ "connect", uc_ubus_connect },
};
-static const uc_cfunction_list_t conn_fns[] = {
+static const uc_function_list_t conn_fns[] = {
{ "list", uc_ubus_list },
{ "call", uc_ubus_call },
{ "error", uc_ubus_error },
@@ -322,7 +322,7 @@ static void close_connection(void *ud) {
void uc_module_init(uc_vm_t *vm, uc_value_t *scope)
{
- uc_add_functions(scope, global_fns);
+ uc_function_list_register(scope, global_fns);
- conn_type = uc_declare_type(vm, "ubus.connection", conn_fns, close_connection);
+ conn_type = uc_type_declare(vm, "ubus.connection", conn_fns, close_connection);
}
diff --git a/lib/uci.c b/lib/uci.c
index 116fad6..f582ddb 100644
--- a/lib/uci.c
+++ b/lib/uci.c
@@ -66,8 +66,8 @@ uc_uci_error(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_uci_cursor(uc_vm_t *vm, size_t nargs)
{
- uc_value_t *cdir = uc_get_arg(0);
- uc_value_t *sdir = uc_get_arg(1);
+ uc_value_t *cdir = uc_fn_arg(0);
+ uc_value_t *sdir = uc_fn_arg(1);
struct uci_context *c;
int rv;
@@ -94,15 +94,15 @@ uc_uci_cursor(uc_vm_t *vm, size_t nargs)
err_return(rv);
}
- return uc_alloc_ressource(cursor_type, c);
+ return uc_ressource_new(cursor_type, c);
}
static uc_value_t *
uc_uci_load(uc_vm_t *vm, size_t nargs)
{
- struct uci_context **c = uc_get_self("uci.cursor");
- uc_value_t *conf = uc_get_arg(0);
+ struct uci_context **c = uc_fn_this("uci.cursor");
+ uc_value_t *conf = uc_fn_arg(0);
struct uci_element *e;
char *s;
@@ -130,8 +130,8 @@ uc_uci_load(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_uci_unload(uc_vm_t *vm, size_t nargs)
{
- struct uci_context **c = uc_get_self("uci.cursor");
- uc_value_t *conf = uc_get_arg(0);
+ struct uci_context **c = uc_fn_this("uci.cursor");
+ uc_value_t *conf = uc_fn_arg(0);
struct uci_element *e;
if (!c || !*c)
@@ -251,10 +251,10 @@ package_to_uval(uc_vm_t *vm, struct uci_package *p)
static uc_value_t *
uc_uci_get_any(uc_vm_t *vm, size_t nargs, bool all)
{
- struct uci_context **c = uc_get_self("uci.cursor");
- uc_value_t *conf = uc_get_arg(0);
- uc_value_t *sect = uc_get_arg(1);
- uc_value_t *opt = uc_get_arg(2);
+ struct uci_context **c = uc_fn_this("uci.cursor");
+ uc_value_t *conf = uc_fn_arg(0);
+ uc_value_t *sect = uc_fn_arg(1);
+ uc_value_t *opt = uc_fn_arg(2);
struct uci_ptr ptr = { 0 };
int rv;
@@ -323,10 +323,10 @@ uc_uci_get_all(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_uci_get_first(uc_vm_t *vm, size_t nargs)
{
- struct uci_context **c = uc_get_self("uci.cursor");
- uc_value_t *conf = uc_get_arg(0);
- uc_value_t *type = uc_get_arg(1);
- uc_value_t *opt = uc_get_arg(2);
+ struct uci_context **c = uc_fn_this("uci.cursor");
+ uc_value_t *conf = uc_fn_arg(0);
+ uc_value_t *type = uc_fn_arg(1);
+ uc_value_t *opt = uc_fn_arg(2);
struct uci_package *p = NULL;
struct uci_section *sc;
struct uci_element *e;
@@ -381,9 +381,9 @@ uc_uci_get_first(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_uci_add(uc_vm_t *vm, size_t nargs)
{
- struct uci_context **c = uc_get_self("uci.cursor");
- uc_value_t *conf = uc_get_arg(0);
- uc_value_t *type = uc_get_arg(1);
+ struct uci_context **c = uc_fn_this("uci.cursor");
+ uc_value_t *conf = uc_fn_arg(0);
+ uc_value_t *type = uc_fn_arg(1);
struct uci_element *e = NULL;
struct uci_package *p = NULL;
struct uci_section *sc = NULL;
@@ -461,9 +461,9 @@ uval_to_uci(uc_vm_t *vm, uc_value_t *val, const char **p, bool *is_list)
static uc_value_t *
uc_uci_set(uc_vm_t *vm, size_t nargs)
{
- struct uci_context **c = uc_get_self("uci.cursor");
- uc_value_t *conf = uc_get_arg(0);
- uc_value_t *sect = uc_get_arg(1);
+ struct uci_context **c = uc_fn_this("uci.cursor");
+ uc_value_t *conf = uc_fn_arg(0);
+ uc_value_t *sect = uc_fn_arg(1);
uc_value_t *opt = NULL, *val = NULL;
struct uci_ptr ptr = { 0 };
bool is_list = false;
@@ -477,8 +477,8 @@ uc_uci_set(uc_vm_t *vm, size_t nargs)
switch (nargs) {
/* conf, sect, opt, val */
case 4:
- opt = uc_get_arg(2);
- val = uc_get_arg(3);
+ opt = uc_fn_arg(2);
+ val = uc_fn_arg(3);
if (ucv_type(opt) != UC_STRING)
err_return(UCI_ERR_INVAL);
@@ -487,7 +487,7 @@ uc_uci_set(uc_vm_t *vm, size_t nargs)
/* conf, sect, type */
case 3:
- val = uc_get_arg(2);
+ val = uc_fn_arg(2);
if (ucv_type(val) != UC_STRING)
err_return(UCI_ERR_INVAL);
@@ -566,10 +566,10 @@ uc_uci_set(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_uci_delete(uc_vm_t *vm, size_t nargs)
{
- struct uci_context **c = uc_get_self("uci.cursor");
- uc_value_t *conf = uc_get_arg(0);
- uc_value_t *sect = uc_get_arg(1);
- uc_value_t *opt = uc_get_arg(2);
+ struct uci_context **c = uc_fn_this("uci.cursor");
+ uc_value_t *conf = uc_fn_arg(0);
+ uc_value_t *sect = uc_fn_arg(1);
+ uc_value_t *opt = uc_fn_arg(2);
struct uci_ptr ptr = { 0 };
int rv;
@@ -601,9 +601,9 @@ uc_uci_delete(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_uci_rename(uc_vm_t *vm, size_t nargs)
{
- struct uci_context **c = uc_get_self("uci.cursor");
- uc_value_t *conf = uc_get_arg(0);
- uc_value_t *sect = uc_get_arg(1);
+ struct uci_context **c = uc_fn_this("uci.cursor");
+ uc_value_t *conf = uc_fn_arg(0);
+ uc_value_t *sect = uc_fn_arg(1);
uc_value_t *opt = NULL, *val = NULL;
struct uci_ptr ptr = { 0 };
int rv;
@@ -615,8 +615,8 @@ uc_uci_rename(uc_vm_t *vm, size_t nargs)
switch (nargs) {
/* conf, sect, opt, val */
case 4:
- opt = uc_get_arg(2);
- val = uc_get_arg(3);
+ opt = uc_fn_arg(2);
+ val = uc_fn_arg(3);
if (ucv_type(opt) != UC_STRING ||
ucv_type(val) != UC_STRING)
@@ -626,7 +626,7 @@ uc_uci_rename(uc_vm_t *vm, size_t nargs)
/* conf, sect, type */
case 3:
- val = uc_get_arg(2);
+ val = uc_fn_arg(2);
if (ucv_type(val) != UC_STRING)
err_return(UCI_ERR_INVAL);
@@ -661,10 +661,10 @@ uc_uci_rename(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_uci_reorder(uc_vm_t *vm, size_t nargs)
{
- struct uci_context **c = uc_get_self("uci.cursor");
- uc_value_t *conf = uc_get_arg(0);
- uc_value_t *sect = uc_get_arg(1);
- uc_value_t *val = uc_get_arg(2);
+ struct uci_context **c = uc_fn_this("uci.cursor");
+ uc_value_t *conf = uc_fn_arg(0);
+ uc_value_t *sect = uc_fn_arg(1);
+ uc_value_t *val = uc_fn_arg(2);
struct uci_ptr ptr = { 0 };
int64_t n;
int rv;
@@ -701,8 +701,8 @@ uc_uci_reorder(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_uci_pkg_command(uc_vm_t *vm, size_t nargs, enum pkg_cmd cmd)
{
- struct uci_context **c = uc_get_self("uci.cursor");
- uc_value_t *conf = uc_get_arg(0);
+ struct uci_context **c = uc_fn_this("uci.cursor");
+ uc_value_t *conf = uc_fn_arg(0);
struct uci_element *e, *tmp;
struct uci_package *p;
struct uci_ptr ptr = { 0 };
@@ -858,8 +858,8 @@ changes_to_uval(uc_vm_t *vm, struct uci_context *ctx, const char *package)
static uc_value_t *
uc_uci_changes(uc_vm_t *vm, size_t nargs)
{
- struct uci_context **c = uc_get_self("uci.cursor");
- uc_value_t *conf = uc_get_arg(0);
+ struct uci_context **c = uc_fn_this("uci.cursor");
+ uc_value_t *conf = uc_fn_arg(0);
uc_value_t *res, *chg;
char **configs;
int rv, i;
@@ -892,10 +892,10 @@ uc_uci_changes(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_uci_foreach(uc_vm_t *vm, size_t nargs)
{
- struct uci_context **c = uc_get_self("uci.cursor");
- uc_value_t *conf = uc_get_arg(0);
- uc_value_t *type = uc_get_arg(1);
- uc_value_t *func = uc_get_arg(2);
+ struct uci_context **c = uc_fn_this("uci.cursor");
+ uc_value_t *conf = uc_fn_arg(0);
+ uc_value_t *type = uc_fn_arg(1);
+ uc_value_t *func = uc_fn_arg(2);
uc_value_t *rv = NULL;
struct uci_package *p = NULL;
struct uci_element *e, *tmp;
@@ -927,8 +927,8 @@ uc_uci_foreach(uc_vm_t *vm, size_t nargs)
if (type && strcmp(sc->type, ucv_string_get(type)))
continue;
- uc_push_val(ucv_get(func));
- uc_push_val(section_to_uval(vm, sc, i - 1));
+ uc_value_push(ucv_get(func));
+ uc_value_push(section_to_uval(vm, sc, i - 1));
ex = uc_call(1);
@@ -937,7 +937,7 @@ uc_uci_foreach(uc_vm_t *vm, size_t nargs)
break;
ret = true;
- rv = uc_pop_val();
+ rv = uc_value_pop();
stop = (ucv_type(rv) == UC_BOOLEAN && !ucv_boolean_get(rv));
ucv_put(rv);
@@ -954,7 +954,7 @@ uc_uci_foreach(uc_vm_t *vm, size_t nargs)
static uc_value_t *
uc_uci_configs(uc_vm_t *vm, size_t nargs)
{
- struct uci_context **c = uc_get_self("uci.cursor");
+ struct uci_context **c = uc_fn_this("uci.cursor");
uc_value_t *a;
char **configs;
int i, rv;
@@ -975,7 +975,7 @@ uc_uci_configs(uc_vm_t *vm, size_t nargs)
}
-static const uc_cfunction_list_t cursor_fns[] = {
+static const uc_function_list_t cursor_fns[] = {
{ "load", uc_uci_load },
{ "unload", uc_uci_unload },
{ "get", uc_uci_get },
@@ -995,7 +995,7 @@ static const uc_cfunction_list_t cursor_fns[] = {
{ "error", uc_uci_error },
};
-static const uc_cfunction_list_t global_fns[] = {
+static const uc_function_list_t global_fns[] = {
{ "error", uc_uci_error },
{ "cursor", uc_uci_cursor },
};
@@ -1007,7 +1007,7 @@ static void close_uci(void *ud) {
void uc_module_init(uc_vm_t *vm, uc_value_t *scope)
{
- uc_add_functions(scope, global_fns);
+ uc_function_list_register(scope, global_fns);
- cursor_type = uc_declare_type(vm, "uci.cursor", cursor_fns, close_uci);
+ cursor_type = uc_type_declare(vm, "uci.cursor", cursor_fns, close_uci);
}