diff options
author | Stephen Dolan <mu@netsoc.tcd.ie> | 2013-06-23 14:23:07 +0100 |
---|---|---|
committer | Stephen Dolan <mu@netsoc.tcd.ie> | 2013-06-23 14:23:07 +0100 |
commit | 37cfc912c1f384d177162f8aa706452754d2c6ab (patch) | |
tree | 04fedd3639f159f43aaf7ae499b987ab4b32d858 | |
parent | 8c2e228c74b99b800bb0169bb873e7d7db0f3f63 (diff) |
Remove #includes from jv.hlibjq
-rw-r--r-- | builtin.c | 1 | ||||
-rw-r--r-- | jq_test.c | 4 | ||||
-rw-r--r-- | jv.c | 7 | ||||
-rw-r--r-- | jv.h | 17 | ||||
-rw-r--r-- | jv_aux.c | 1 | ||||
-rw-r--r-- | jv_parse.c | 1 | ||||
-rw-r--r-- | jv_print.c | 1 | ||||
-rw-r--r-- | lexer.l | 1 | ||||
-rw-r--r-- | parser.y | 1 |
9 files changed, 19 insertions, 15 deletions
@@ -1,5 +1,6 @@ #include <stdlib.h> #include <string.h> +#include <assert.h> #include "builtin.h" #include "compile.h" #include "jq_parser.h" @@ -125,9 +125,9 @@ static void jv_test() { jv_free(a2); - assert(a.val.nontrivial.ptr->count == 1); + assert(jv_get_refcnt(a) == 1); a = jv_array_append(a, jv_copy(a)); - assert(a.val.nontrivial.ptr->count == 1); + assert(jv_get_refcnt(a) == 1); assert(jv_array_length(jv_copy(a)) == 2); assert(jv_number_value(jv_array_get(jv_copy(a), 0)) == 42); @@ -14,6 +14,11 @@ * Internal refcounting helpers */ +typedef struct jv_refcnt { + size_t count; +} jv_refcnt; + + static void jvp_refcnt_init(jv_nontrivial* c) { c->ptr->count = 1; } @@ -548,7 +553,7 @@ int jv_string_length_codepoints(jv j) { return len; } -uint32_t jv_string_hash(jv j) { +unsigned long jv_string_hash(jv j) { assert(jv_get_kind(j) == JV_KIND_STRING); uint32_t hash = jvp_string_hash(jvp_string_ptr(&j.val.nontrivial)); jv_free(j); @@ -1,12 +1,6 @@ #ifndef JV_H #define JV_H -#include <stdint.h> -#include <assert.h> -#include <stddef.h> - - - typedef enum { JV_KIND_INVALID, JV_KIND_NULL, @@ -18,12 +12,9 @@ typedef enum { JV_KIND_OBJECT } jv_kind; -typedef struct { - size_t count; -} jv_refcnt; - +struct jv_refcnt; typedef struct{ - jv_refcnt* ptr; + struct jv_refcnt* ptr; int i[2]; } jv_nontrivial; @@ -47,6 +38,8 @@ static int jv_is_valid(jv x) { return jv_get_kind(x) != JV_KIND_INVALID; } jv jv_copy(jv); void jv_free(jv); +int jv_get_refcnt(jv); + int jv_equal(jv, jv); int jv_contains(jv, jv); @@ -84,7 +77,7 @@ jv jv_string(const char*); jv jv_string_sized(const char*, int); int jv_string_length_bytes(jv); int jv_string_length_codepoints(jv); -uint32_t jv_string_hash(jv); +unsigned long jv_string_hash(jv); const char* jv_string_value(jv); jv jv_string_concat(jv, jv); jv jv_string_fmt(const char*, ...); @@ -1,5 +1,6 @@ #include <string.h> #include <stdlib.h> +#include <assert.h> #include "jv_alloc.h" static int parse_slice(jv array, jv slice, int* pstart, int* pend) { @@ -1,6 +1,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <assert.h> #include "jv.h" #include "jv_dtoa.h" #include "jv_unicode.h" @@ -2,6 +2,7 @@ #include <stdio.h> #include <float.h> #include <string.h> +#include <assert.h> #include "jv_dtoa.h" #include "jv_unicode.h" @@ -1,4 +1,5 @@ %{ +#include <assert.h> #include "jv_alloc.h" #include "compile.h" @@ -1,6 +1,7 @@ %{ #include <stdio.h> #include <string.h> +#include <assert.h> #include "compile.h" #include "jv_alloc.h" #define YYMALLOC jv_mem_alloc |