summaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
authorStephen Dolan <mu@netsoc.tcd.ie>2012-11-26 22:23:30 +0000
committerStephen Dolan <mu@netsoc.tcd.ie>2012-11-26 22:24:04 +0000
commit2dad2bdd974e6964e739f9bd09c7ad2c4025d00b (patch)
tree35f0269f8718a42eaf746d15fa8903f4ef3a7822 /builtin.c
parentd56370f734a2195fb473b8809f40358b024bb073 (diff)
parent0923c79fee215ee6c01c3d2f822b6267ad29090e (diff)
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/builtin.c b/builtin.c
index 657a7a1f..756b069d 100644
--- a/builtin.c
+++ b/builtin.c
@@ -161,6 +161,21 @@ static void f_greatereq(jv input[], jv output[]) {
order_cmp(input, output, CMP_OP_GREATEREQ);
}
+static void f_contains(jv input[], jv output[]) {
+ jv_free(input[0]);
+ jv a = input[2];
+ jv b = input[1];
+ jv_kind akind = jv_get_kind(a);
+
+ if (akind == jv_get_kind(b)) {
+ output[0] = jv_bool(jv_contains(a, b));
+ } else {
+ output[0] = jv_invalid_with_msg(jv_string_fmt("Can only check containment of values of the same type."));
+ jv_free(a);
+ jv_free(b);
+ }
+}
+
static void f_tonumber(jv input[], jv output[]) {
if (jv_get_kind(input[0]) == JV_KIND_NUMBER) {
output[0] = input[0];
@@ -265,6 +280,7 @@ static struct cfunction function_list[] = {
{f_greater, "_greater", CALL_BUILTIN_3_1},
{f_lesseq, "_lesseq", CALL_BUILTIN_3_1},
{f_greatereq, "_greatereq", CALL_BUILTIN_3_1},
+ {f_contains, "_contains", CALL_BUILTIN_3_1},
{f_length, "length", CALL_BUILTIN_1_1},
{f_type, "type", CALL_BUILTIN_1_1},
{f_add, "add", CALL_BUILTIN_1_1},