csonpath 0.12.1__tar.gz → 0.13.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {csonpath-0.12.1 → csonpath-0.13.1}/Makefile +11 -3
- {csonpath-0.12.1/csonpath.egg-info → csonpath-0.13.1}/PKG-INFO +1 -1
- {csonpath-0.12.1 → csonpath-0.13.1/csonpath.egg-info}/PKG-INFO +1 -1
- {csonpath-0.12.1 → csonpath-0.13.1}/csonpath.h +14 -12
- {csonpath-0.12.1 → csonpath-0.13.1}/csonpath_do.h +9 -6
- {csonpath-0.12.1 → csonpath-0.13.1}/csonpath_python.c +15 -3
- {csonpath-0.12.1 → csonpath-0.13.1}/pyproject.toml +2 -2
- {csonpath-0.12.1 → csonpath-0.13.1}/LICENSE +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/MANIFEST.in +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/README.md +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/configure +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/csonpath.egg-info/SOURCES.txt +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/csonpath.egg-info/dependency_links.txt +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/csonpath.egg-info/requires.txt +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/csonpath.egg-info/top_level.txt +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/csonpath_json-c.h +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/csonpath_yyjson.h +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/setup.cfg +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/setup.py +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/tiny-regex-c/.git +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/tiny-regex-c/.github/workflows/c-cpp.yml +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/tiny-regex-c/.gitignore +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/tiny-regex-c/LICENSE +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/tiny-regex-c/Makefile +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/tiny-regex-c/README.md +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/tiny-regex-c/clib.json +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/tiny-regex-c/formal_verification.md +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/tiny-regex-c/re.c +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/tiny-regex-c/re.h +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/tiny-regex-c/scripts/exrex.py +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/tiny-regex-c/scripts/regex_test.py +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/tiny-regex-c/scripts/regex_test_neg.py +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/tiny-regex-c/tests/test1.c +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/tiny-regex-c/tests/test2.c +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/tiny-regex-c/tests/test3.c +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/tiny-regex-c/tests/test_compile.c +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/tiny-regex-c/tests/test_print.c +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/tiny-regex-c/tests/test_rand.c +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/tiny-regex-c/tests/test_rand_neg.c +0 -0
- {csonpath-0.12.1 → csonpath-0.13.1}/tiny-regex-c/tests/test_thread.c +0 -0
|
@@ -3,7 +3,7 @@ JSON_C_LDFLAGS=$(shell pkg-config --libs json-c)
|
|
|
3
3
|
|
|
4
4
|
include config.mk
|
|
5
5
|
|
|
6
|
-
all: test-json-c-get-a test-json-update test-json-filter test-json-subpath test-json-c-array-root
|
|
6
|
+
all: test-json-c-get-a test-json-update test-json-filter test-json-subpath test-json-c-array-root test-json-filter-and-missing-key test-json-get-array-big-index
|
|
7
7
|
|
|
8
8
|
bench:
|
|
9
9
|
make -C bench
|
|
@@ -30,12 +30,20 @@ test-json-filter: tests/json-c/filter.c csonpath_json-c.h csonpath.h csonpath_do
|
|
|
30
30
|
test-json-subpath: tests/json-c/subpath.c csonpath_json-c.h csonpath.h csonpath_do.h
|
|
31
31
|
$(CC) tests/json-c/subpath.c $(EXTRA_FILES) $(JSON_C_CFLAGS) $(CFLAGS) -Wno-format -I./ -o test-json-subpath $(JSON_C_LDFLAGS) $(LDFLAGS)
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
test-json-filter-and-missing-key: tests/json-c/filter-and-missing-key.c csonpath_json-c.h csonpath.h csonpath_do.h
|
|
34
|
+
$(CC) tests/json-c/filter-and-missing-key.c $(EXTRA_FILES) $(JSON_C_CFLAGS) $(CFLAGS) -Wno-format -I./ -o test-json-filter-and-missing-key $(JSON_C_LDFLAGS) $(LDFLAGS)
|
|
35
|
+
|
|
36
|
+
test-json-get-array-big-index: tests/json-c/get-array-big-index.c csonpath_json-c.h csonpath.h csonpath_do.h
|
|
37
|
+
$(CC) tests/json-c/get-array-big-index.c $(EXTRA_FILES) $(JSON_C_CFLAGS) $(CFLAGS) -Wno-format -I./ -o test-json-get-array-big-index $(JSON_C_LDFLAGS) $(LDFLAGS)
|
|
38
|
+
|
|
39
|
+
tests-c: test-json-c-get-a test-json-update test-json-filter test-json-subpath test-json-c-array-root test-json-filter-and-missing-key test-json-get-array-big-index
|
|
34
40
|
./test-json-c-get-a
|
|
35
41
|
./test-json-update
|
|
36
42
|
./test-json-filter
|
|
37
43
|
./test-json-subpath
|
|
38
44
|
./test-json-c-array-root
|
|
45
|
+
./test-json-filter-and-missing-key
|
|
46
|
+
./test-json-get-array-big-index
|
|
39
47
|
|
|
40
48
|
pip-dev:
|
|
41
49
|
pip install -e .[dev] --force-reinstall
|
|
@@ -46,5 +54,5 @@ tests-py: pip-dev
|
|
|
46
54
|
tests: tests-py tests-c
|
|
47
55
|
|
|
48
56
|
clean:
|
|
49
|
-
rm -rvf test-json-c-get-a test-json-update test-json-filter test-json-subpath
|
|
57
|
+
rm -rvf test-json-c-get-a test-json-update test-json-filter test-json-subpath test-json-c-array-root test-json-filter-and-missing-key test-json-get-array-big-index
|
|
50
58
|
|
|
@@ -918,9 +918,9 @@ need_reloop_in = 0;
|
|
|
918
918
|
#define CSONPATH_NONE_FOUND_RET CSONPATH_NULL
|
|
919
919
|
|
|
920
920
|
#define CSONPATH_GETTER_ERR(args...) do { \
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
921
|
+
CSONPATH_FORMAT_EXCEPTION(args); \
|
|
922
|
+
return CSONPATH_NULL; \
|
|
923
|
+
} while (0)
|
|
924
924
|
|
|
925
925
|
/* Find First */
|
|
926
926
|
|
|
@@ -980,10 +980,10 @@ need_reloop_in = 0;
|
|
|
980
980
|
|
|
981
981
|
#define CSONPATH_NONE_FOUND_RET 0
|
|
982
982
|
|
|
983
|
-
#define CSONPATH_GETTER_ERR(args...) do {
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
983
|
+
#define CSONPATH_GETTER_ERR(args...) do { \
|
|
984
|
+
CSONPATH_FORMAT_EXCEPTION(args); \
|
|
985
|
+
return -1; \
|
|
986
|
+
} while (0)
|
|
987
987
|
|
|
988
988
|
#define CSONPATH_DO_ON_FOUND
|
|
989
989
|
|
|
@@ -1104,7 +1104,8 @@ static int csonpath_sync_root_array(CSONPATH_JSON parent, CSONPATH_JSON to_updat
|
|
|
1104
1104
|
|
|
1105
1105
|
CSONPATH_ARRAY_CLEAR(parent);
|
|
1106
1106
|
CSONPATH_FOREACH_ARRAY(to_update, child, idx) {
|
|
1107
|
-
CSONPATH_APPEND_AT(parent, idx, child)
|
|
1107
|
+
if (CSONPATH_APPEND_AT(parent, idx, child) < 0)
|
|
1108
|
+
return -1;
|
|
1108
1109
|
}
|
|
1109
1110
|
return 1;
|
|
1110
1111
|
}
|
|
@@ -1116,7 +1117,8 @@ static int csonpath_sync_root_obj(CSONPATH_JSON parent, CSONPATH_JSON to_update)
|
|
|
1116
1117
|
|
|
1117
1118
|
CSONPATH_OBJ_CLEAR(parent);
|
|
1118
1119
|
CSONPATH_FOREACH_OBJ(to_update, child, key) {
|
|
1119
|
-
CSONPATH_APPEND_AT(parent, key, child)
|
|
1120
|
+
if (CSONPATH_APPEND_AT(parent, key, child) < 0)
|
|
1121
|
+
return -1;
|
|
1120
1122
|
}
|
|
1121
1123
|
return 1;
|
|
1122
1124
|
}
|
|
@@ -1129,7 +1131,7 @@ static int csonpath_sync_root_obj(CSONPATH_JSON parent, CSONPATH_JSON to_update)
|
|
|
1129
1131
|
} else if (CSONPATH_IS_ARRAY(origin) && CSONPATH_IS_ARRAY(to_update)) { \
|
|
1130
1132
|
return csonpath_sync_root_array(origin, to_update); \
|
|
1131
1133
|
} else { \
|
|
1132
|
-
CSONPATH_EXCEPTION("can't
|
|
1134
|
+
CSONPATH_EXCEPTION("can't update root ($)\n"); \
|
|
1133
1135
|
} \
|
|
1134
1136
|
}
|
|
1135
1137
|
|
|
@@ -1141,7 +1143,7 @@ static int csonpath_sync_root_obj(CSONPATH_JSON parent, CSONPATH_JSON to_update)
|
|
|
1141
1143
|
to_check = *check_at; \
|
|
1142
1144
|
} while (to_check == CSONPATH_INST_GET_ALL || to_check == CSONPATH_INST_FIND_ALL); \
|
|
1143
1145
|
if (to_check == CSONPATH_INST_END || to_check == CSONPATH_INST_OR) { \
|
|
1144
|
-
CSONPATH_APPEND_AT(ctx, this_idx, to_update);
|
|
1146
|
+
if (CSONPATH_APPEND_AT(ctx, this_idx, to_update) < 0) return -1; \
|
|
1145
1147
|
return 1; \
|
|
1146
1148
|
}
|
|
1147
1149
|
|
|
@@ -1215,7 +1217,7 @@ static int csonpath_sync_root_obj(CSONPATH_JSON parent, CSONPATH_JSON to_update)
|
|
|
1215
1217
|
#define CSONPATH_PRE_GET_ROOT \
|
|
1216
1218
|
int to_check = *walker; \
|
|
1217
1219
|
if (to_check == CSONPATH_INST_END || to_check == CSONPATH_INST_OR) { \
|
|
1218
|
-
CSONPATH_GETTER_ERR("can't
|
|
1220
|
+
CSONPATH_GETTER_ERR("can't update root ($)\n"); \
|
|
1219
1221
|
return CSONPATH_NONE_FOUND_RET; \
|
|
1220
1222
|
}
|
|
1221
1223
|
|
|
@@ -161,7 +161,7 @@ static CSONPATH_DO_RET_TYPE csonpath_do_dotdot(const struct csonpath cjp[const s
|
|
|
161
161
|
CSONPATH_DO_FIND_ALL;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
} else {
|
|
164
|
+
} else if (CSONPATH_IS_ARRAY(tmp)) {
|
|
165
165
|
CSONPATH_FOREACH_ARRAY(tmp, el, key_idx) {
|
|
166
166
|
CSONPATH_DO_FOREACH_PRE_SET;
|
|
167
167
|
if (CSONPATH_IS_OBJ(el) || CSONPATH_IS_ARRAY(el)) {
|
|
@@ -212,9 +212,15 @@ static CSONPATH_DO_RET_TYPE csonpath_do_internal(const struct csonpath cjp[const
|
|
|
212
212
|
|
|
213
213
|
(void) foreach_idx;
|
|
214
214
|
CSONPATH_DO_FILTER_PRE_LOOP;
|
|
215
|
+
if (!CSONPATH_IS_ARRAY(tmp)) {
|
|
216
|
+
CSONPATH_DO_FILTER_OUT;
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
215
219
|
CSONPATH_FOREACH_ARRAY(tmp, el, foreach_idx)
|
|
216
220
|
{
|
|
217
221
|
intptr_t key_idx = foreach_idx;
|
|
222
|
+
filter_next = filter_next_in;
|
|
223
|
+
operation = operation_in;
|
|
218
224
|
(void)key_idx;
|
|
219
225
|
owalker = next;
|
|
220
226
|
match_and_or_or:
|
|
@@ -226,7 +232,7 @@ static CSONPATH_DO_RET_TYPE csonpath_do_internal(const struct csonpath cjp[const
|
|
|
226
232
|
|
|
227
233
|
if (csonpath_make_match(cjp, origin, el2, &owalker, operation)) {
|
|
228
234
|
if (*owalker == CSONPATH_INST_FILTER_AND) {
|
|
229
|
-
++owalker; /* skip
|
|
235
|
+
++owalker; /* skip and */
|
|
230
236
|
operation = *owalker;
|
|
231
237
|
++owalker;
|
|
232
238
|
filter_next = *owalker;
|
|
@@ -237,9 +243,6 @@ static CSONPATH_DO_RET_TYPE csonpath_do_internal(const struct csonpath cjp[const
|
|
|
237
243
|
csonpath_do_internal(cjp, origin, el, tmp, owalker
|
|
238
244
|
CSONPATH_DO_EXTRA_ARGS_NEESTED);
|
|
239
245
|
CSONPATH_DO_FILTER_FIND;
|
|
240
|
-
} else {
|
|
241
|
-
operation = operation_in;
|
|
242
|
-
filter_next = filter_next_in;
|
|
243
246
|
}
|
|
244
247
|
}
|
|
245
248
|
}
|
|
@@ -385,7 +388,7 @@ static CSONPATH_DO_RET_TYPE csonpath_do_internal(const struct csonpath cjp[const
|
|
|
385
388
|
this_idx = to_num.n;
|
|
386
389
|
CSONPATH_PRE_GET(this_idx);
|
|
387
390
|
tmp = CSONPATH_AT(tmp, to_num.n);
|
|
388
|
-
walker +=
|
|
391
|
+
walker += 4;
|
|
389
392
|
if (tmp == CSONPATH_NULL) {
|
|
390
393
|
CSONPATH_DO_GET_NOTFOUND(this_idx);
|
|
391
394
|
}
|
|
@@ -264,6 +264,8 @@ static PyObject *find_all(PyCsonPathObject *self, PyObject* args)
|
|
|
264
264
|
BAD_ARG();
|
|
265
265
|
|
|
266
266
|
PyObject *ret = csonpath_find_all(self->cp, json);
|
|
267
|
+
if (PyErr_Occurred())
|
|
268
|
+
return NULL;
|
|
267
269
|
|
|
268
270
|
return ret;
|
|
269
271
|
}
|
|
@@ -276,6 +278,8 @@ static PyObject *find_first(PyCsonPathObject *self, PyObject* args)
|
|
|
276
278
|
BAD_ARG();
|
|
277
279
|
|
|
278
280
|
PyObject *ret = csonpath_find_first(self->cp, json);
|
|
281
|
+
if (PyErr_Occurred())
|
|
282
|
+
return NULL;
|
|
279
283
|
|
|
280
284
|
Py_INCREF(ret);
|
|
281
285
|
return ret;
|
|
@@ -284,7 +288,7 @@ static PyObject *find_first(PyCsonPathObject *self, PyObject* args)
|
|
|
284
288
|
static PyObject *print_instructions(PyCsonPathObject *self, PyObject *args, PyObject *kwds)
|
|
285
289
|
{
|
|
286
290
|
csonpath_print_instruction(self->cp);
|
|
287
|
-
|
|
291
|
+
Py_RETURN_NONE;
|
|
288
292
|
}
|
|
289
293
|
|
|
290
294
|
static PyObject *callback(PyCsonPathObject *self, PyObject* args)
|
|
@@ -294,6 +298,8 @@ static PyObject *callback(PyCsonPathObject *self, PyObject* args)
|
|
|
294
298
|
if (!PyArg_ParseTuple(args, "OO|O", &json, &callback, &udata))
|
|
295
299
|
BAD_ARG();
|
|
296
300
|
int ret = csonpath_callback(self->cp, json, callback, udata);
|
|
301
|
+
if (PyErr_Occurred())
|
|
302
|
+
return NULL;
|
|
297
303
|
return PyLong_FromLong(ret);
|
|
298
304
|
}
|
|
299
305
|
|
|
@@ -304,6 +310,8 @@ static PyObject *do_remove(PyCsonPathObject *self, PyObject* args)
|
|
|
304
310
|
if (!PyArg_ParseTuple(args, "O", &json))
|
|
305
311
|
BAD_ARG();
|
|
306
312
|
int ret = csonpath_remove(self->cp, json);
|
|
313
|
+
if (PyErr_Occurred())
|
|
314
|
+
return NULL;
|
|
307
315
|
return PyLong_FromLong(ret);
|
|
308
316
|
}
|
|
309
317
|
|
|
@@ -313,10 +321,11 @@ static PyObject *update_or_create(PyCsonPathObject *self, PyObject* args)
|
|
|
313
321
|
PyObject *value;
|
|
314
322
|
|
|
315
323
|
if (!PyArg_ParseTuple(args, "OO", &json, &value))
|
|
316
|
-
|
|
324
|
+
BAD_ARG();
|
|
317
325
|
int ret = csonpath_update_or_create(self->cp, json, value);
|
|
318
|
-
if (ret < 0)
|
|
326
|
+
if (PyErr_Occurred() || ret < 0) {
|
|
319
327
|
return NULL;
|
|
328
|
+
}
|
|
320
329
|
return PyLong_FromLong(ret);
|
|
321
330
|
}
|
|
322
331
|
|
|
@@ -327,6 +336,9 @@ static PyObject *update_or_create_callback(PyCsonPathObject *self, PyObject* arg
|
|
|
327
336
|
if (!PyArg_ParseTuple(args, "OO|O", &json, &callback, &udata))
|
|
328
337
|
BAD_ARG();
|
|
329
338
|
int ret = csonpath_update_or_create_callback(self->cp, json, callback, udata);
|
|
339
|
+
if (PyErr_Occurred() || ret < 0) {
|
|
340
|
+
return NULL;
|
|
341
|
+
}
|
|
330
342
|
return PyLong_FromLong(ret);
|
|
331
343
|
}
|
|
332
344
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "csonpath"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.13.1"
|
|
8
8
|
readme = "README.md"
|
|
9
9
|
|
|
10
10
|
[tool.setuptools]
|
|
@@ -27,7 +27,7 @@ test-command = "pytest {project}/tests/python"
|
|
|
27
27
|
before-build = "choco install mingw -y"
|
|
28
28
|
|
|
29
29
|
[tool.bumpversion]
|
|
30
|
-
current_version = "0.
|
|
30
|
+
current_version = "0.13.1"
|
|
31
31
|
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
|
|
32
32
|
serialize = ["{major}.{minor}.{patch}"]
|
|
33
33
|
search = "{current_version}"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|