Move from Jansson to JV - everything but the interpreter loop

Passes valgrind --leak-check=full.
This commit is contained in:
Stephen Dolan committed 2012-09-02 16:31:59 +01:00
1 parent 22f8aed31e
commit 2cb9a6e61d
12 files changed
+170 -123

No files matched your search

+13 -17
View File
@@ -1,28 +1,24 @@
#include "builtin.h"
#include <jansson.h>
static void f_false(json_t* input[], json_t* output[]) {
output[0] = json_false();
static void f_false(jv input[], jv output[]) {
output[0] = jv_false();
}
static void f_true(json_t* input[], json_t* output[]) {
output[0] = json_true();
static void f_true(jv input[], jv output[]) {
output[0] = jv_true();
}
static void f_plus(json_t* input[], json_t* output[]) {
json_t* a = input[2];
json_t* b = input[1];
if (json_is_number(a) && json_is_number(b)) {
output[0] = json_real(json_number_value(a) +
json_number_value(b));
} else if (json_is_array(a) && json_is_array(b)) {
output[0] = json_copy(a);
json_array_extend(output[0], b);
static void f_plus(jv input[], jv output[]) {
jv a = input[2];
jv b = input[1];
if (jv_get_kind(a) == JV_KIND_NUMBER && jv_get_kind(b) == JV_KIND_NUMBER) {
output[0] = jv_number(jv_number_value(a) +
jv_number_value(b));
} else if (jv_get_kind(a) == JV_KIND_ARRAY && jv_get_kind(b) == JV_KIND_ARRAY) {
output[0] = jv_array_concat(a, b);
} else {
output[0] = json_string("wtf gaize");
output[0] = jv_string("wtf gaize");
}
}