Change the underlying type of JSON integer from long to json_int_t
[jansson.git] / src / jansson_private.h
1 /*
2  * Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
3  *
4  * Jansson is free software; you can redistribute it and/or modify
5  * it under the terms of the MIT license. See LICENSE for details.
6  */
7
8 #ifndef JANSSON_PRIVATE_H
9 #define JANSSON_PRIVATE_H
10
11 #include "jansson.h"
12 #include "hashtable.h"
13
14 #define container_of(ptr_, type_, member_)  \
15     ((type_ *)((char *)ptr_ - (size_t)&((type_ *)0)->member_))
16
17 typedef struct {
18     json_t json;
19     hashtable_t hashtable;
20     size_t serial;
21     int visited;
22 } json_object_t;
23
24 typedef struct {
25     json_t json;
26     size_t size;
27     size_t entries;
28     json_t **table;
29     int visited;
30 } json_array_t;
31
32 typedef struct {
33     json_t json;
34     char *value;
35 } json_string_t;
36
37 typedef struct {
38     json_t json;
39     double value;
40 } json_real_t;
41
42 typedef struct {
43     json_t json;
44     json_int_t value;
45 } json_integer_t;
46
47 #define json_to_object(json_)  container_of(json_, json_object_t, json)
48 #define json_to_array(json_)   container_of(json_, json_array_t, json)
49 #define json_to_string(json_)  container_of(json_, json_string_t, json)
50 #define json_to_real(json_)   container_of(json_, json_real_t, json)
51 #define json_to_integer(json_) container_of(json_, json_integer_t, json)
52
53 typedef struct {
54     size_t serial;
55     char key[];
56 } object_key_t;
57
58 const object_key_t *jsonp_object_iter_fullkey(void *iter);
59
60 #endif