提交 37cfc912 编写于 作者: S Stephen Dolan

Remove #includes from jv.h

上级 8c2e228c
#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);
......
#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*, ...);
......
#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) {
......
#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"
......
%{
#include <assert.h>
#include "jv_alloc.h"
#include "compile.h"
......
%{
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "compile.h"
#include "jv_alloc.h"
#define YYMALLOC jv_mem_alloc
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册