mirror of
https://github.com/stedolan/jq.git
synced 2024-05-11 05:55:39 +00:00
Remove #includes from jv.h
This commit is contained in:
@ -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);
|
||||
|
7
jv.c
7
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 @@ 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);
|
||||
|
17
jv.h
17
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 @@ 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
jv_aux.c
1
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) {
|
||||
|
@ -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
lexer.l
1
lexer.l
@ -1,4 +1,5 @@
|
||||
%{
|
||||
#include <assert.h>
|
||||
#include "jv_alloc.h"
|
||||
#include "compile.h"
|
||||
|
||||
|
Reference in New Issue
Block a user