Remove #includes from jv.h
diff --git a/builtin.c b/builtin.c
index 826d8c9..7ef64d5 100644
--- a/builtin.c
+++ b/builtin.c
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <string.h>
+#include <assert.h>
#include "builtin.h"
#include "compile.h"
#include "jq_parser.h"
diff --git a/jq_test.c b/jq_test.c
index 9e39594..f10a258 100644
--- a/jq_test.c
+++ b/jq_test.c
@@ -125,9 +125,9 @@
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);
diff --git a/jv.c b/jv.c
index 9316aec..46f7dbf 100644
--- a/jv.c
+++ b/jv.c
@@ -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 @@
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);
diff --git a/jv.h b/jv.h
index 420b9bd..a901021 100644
--- a/jv.h
+++ b/jv.h
@@ -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 @@
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 @@
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_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*, ...);
diff --git a/jv_aux.c b/jv_aux.c
index eb4ded0..b73c905 100644
--- a/jv_aux.c
+++ b/jv_aux.c
@@ -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) {
diff --git a/jv_parse.c b/jv_parse.c
index 4418cb0..cc1e7b9 100644
--- a/jv_parse.c
+++ b/jv_parse.c
@@ -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"
diff --git a/jv_print.c b/jv_print.c
index 890de04..da90abf 100644
--- a/jv_print.c
+++ b/jv_print.c
@@ -2,6 +2,7 @@
#include <stdio.h>
#include <float.h>
#include <string.h>
+#include <assert.h>
#include "jv_dtoa.h"
#include "jv_unicode.h"
diff --git a/lexer.l b/lexer.l
index 96c0efc..e8d73d6 100644
--- a/lexer.l
+++ b/lexer.l
@@ -1,4 +1,5 @@
%{
+#include <assert.h>
#include "jv_alloc.h"
#include "compile.h"
diff --git a/parser.y b/parser.y
index 4ec1038..c8713de 100644
--- a/parser.y
+++ b/parser.y
@@ -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