35
35
#include "scanner/list-scanner/list-scanner.h"
36
36
#include "str-repr/encode.h"
37
37
38
- static gboolean
38
+ #define json_object_get_type (jso ) (*((int *) jso))
39
+
40
+ static inline gboolean
39
41
_is_json_cacheable (struct json_object * jso )
40
42
{
41
43
if (json_object_get_type (jso ) == json_type_double && JSON_C_MAJOR_VERSION == 0 && JSON_C_MINOR_VERSION < 14 )
@@ -53,6 +55,30 @@ _is_json_cacheable(struct json_object *jso)
53
55
return TRUE;
54
56
}
55
57
58
+ static inline FilterXObject *
59
+ filterx_json_get_cached_object (struct json_object * jso )
60
+ {
61
+ if (!_is_json_cacheable (jso ))
62
+ return NULL ;
63
+
64
+ if (json_object_get_type (jso ) == json_type_double )
65
+ {
66
+ /*
67
+ * This is a workaround to ditch builtin serializer for double objects
68
+ * that are set when parsing from a string representation.
69
+ * json_object_double_new_ds() will set userdata to the string
70
+ * representation of the number, as extracted from the JSON source.
71
+ *
72
+ * Changing the value of the double to the same value, ditches this,
73
+ * but only if necessary.
74
+ */
75
+ json_object_set_double (jso , json_object_get_double (jso ));
76
+ }
77
+
78
+ return (FilterXObject * ) json_object_get_userdata (jso );
79
+ }
80
+
81
+
56
82
static int
57
83
_deep_copy_filterx_object_ref (json_object * src , json_object * parent , const char * key , size_t index , json_object * * dst )
58
84
{
@@ -154,28 +180,6 @@ filterx_json_associate_cached_object(struct json_object *jso, FilterXObject *fil
154
180
json_object_set_userdata (jso , filterx_obj , NULL );
155
181
}
156
182
157
- FilterXObject *
158
- filterx_json_get_cached_object (struct json_object * jso )
159
- {
160
- if (!_is_json_cacheable (jso ))
161
- return NULL ;
162
-
163
- if (json_object_get_type (jso ) == json_type_double )
164
- {
165
- /*
166
- * This is a workaround to ditch builtin serializer for double objects
167
- * that are set when parsing from a string representation.
168
- * json_object_double_new_ds() will set userdata to the string
169
- * representation of the number, as extracted from the JSON source.
170
- *
171
- * Changing the value of the double to the same value, ditches this,
172
- * but only if necessary.
173
- */
174
- json_object_set_double (jso , json_object_get_double (jso ));
175
- }
176
-
177
- return (FilterXObject * ) json_object_get_userdata (jso );
178
- }
179
183
180
184
FilterXObject *
181
185
filterx_json_new_from_repr (const gchar * repr , gssize repr_len )
0 commit comments