~lattis/muon

ref: 1c1ab113103e1a2ebcb7edf3a47f826428f8e124 muon/src/functions/subproject.c -rw-r--r-- 958 bytes
1c1ab113Stone Tickle extract string.split() 8 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "posix.h"

#include "functions/common.h"
#include "functions/subproject.h"
#include "lang/interpreter.h"
#include "log.h"

bool
subproject_get_variable(struct workspace *wk, uint32_t node, uint32_t name_id,
	uint32_t subproj, uint32_t *obj)
{
	const char *name = get_cstr(wk, name_id);
	uint32_t subproject_id = get_obj(wk, subproj)->dat.subproj;

	if (!get_obj_id(wk, name, obj, subproject_id)) {
		interp_error(wk, node, "subproject does not define '%s'", name);
		return false;
	}

	return true;
}

static bool
func_subproject_get_variable(struct workspace *wk, uint32_t rcvr, uint32_t args_node, uint32_t *obj)
{
	struct args_norm an[] = { { obj_string }, ARG_TYPE_NULL };

	if (!interp_args(wk, args_node, an, NULL, NULL)) {
		return false;
	}

	return subproject_get_variable(wk, an[0].node, an[0].val, rcvr, obj);
}

const struct func_impl_name impl_tbl_subproject[] = {
	{ "get_variable", func_subproject_get_variable },
	{ NULL, NULL },
};