~lattis/muon

ref: f9a8cbad39b665a9496cd3adb4756e85ee5ec97c muon/src/functions/feature_opt.c -rw-r--r-- 1.2 KiB
f9a8cbadStone Tickle print stdout/stderr of failing test 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
39
40
41
42
43
44
45
46
#include "posix.h"

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

static bool
feature_opt_common(struct workspace *wk, uint32_t rcvr, uint32_t args_node,
	uint32_t *obj, enum feature_opt_state state)
{
	if (!interp_args(wk, args_node, NULL, NULL, NULL)) {
		return false;
	}

	// TODO auto_features

	make_obj(wk, obj, obj_bool)->dat.boolean =
		get_obj(wk, rcvr)->dat.feature_opt.state == state;
	return true;
}

static bool
func_feature_opt_auto(struct workspace *wk, uint32_t rcvr, uint32_t args_node, uint32_t *obj)
{
	return feature_opt_common(wk, rcvr, args_node, obj, feature_opt_auto);
}

static bool
func_feature_opt_disabled(struct workspace *wk, uint32_t rcvr, uint32_t args_node, uint32_t *obj)
{
	return feature_opt_common(wk, rcvr, args_node, obj, feature_opt_disabled);
}

static bool
func_feature_opt_enabled(struct workspace *wk, uint32_t rcvr, uint32_t args_node, uint32_t *obj)
{
	return feature_opt_common(wk, rcvr, args_node, obj, feature_opt_enabled);
}

const struct func_impl_name impl_tbl_feature_opt[] = {
	{ "auto", func_feature_opt_auto },
	{ "disabled", func_feature_opt_disabled },
	{ "enabled", func_feature_opt_enabled },
	{ NULL, NULL },
};