summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-06-28 17:12:39 +0100
committerMichael Williamson <mike@zwobble.org>2013-06-28 17:12:39 +0100
commitcbfbd9be6b47a5822a3b3cd5ec9f19a82496630e (patch)
tree3980f6b090f2ab92774d1629f8c3bbb568453b16
parentbf0f12612e0d867801ef6ba34b78d6f1c14bbf05 (diff)
Update to work with libjq branch on github.com/stedolan/jq
-rw-r--r--jq.pyx27
-rw-r--r--setup.py9
2 files changed, 17 insertions, 19 deletions
diff --git a/jq.pyx b/jq.pyx
index f94aab2..b61e5f6 100644
--- a/jq.pyx
+++ b/jq.pyx
@@ -8,6 +8,14 @@ cdef extern from "jv.h":
char* jv_string_value(jv)
jv jv_dump_string(jv, int flags)
void jv_free(jv)
+
+ cdef struct jv_parser:
+ pass
+
+ jv_parser* jv_parser_new()
+ void jv_parser_free(jv_parser*)
+ void jv_parser_set_buf(jv_parser*, const char*, int, int)
+ jv jv_parser_next(jv_parser*)
cdef extern from "jq.h":
@@ -20,16 +28,6 @@ cdef extern from "jq.h":
void jq_start(jq_state *, jv value, int flags)
jv jq_next(jq_state *)
-
-cdef extern from "jv_parse.h":
- cdef struct jv_parser:
- pass
-
- void jv_parser_init(jv_parser*)
- void jv_parser_free(jv_parser*)
- void jv_parser_set_buf(jv_parser*, const char*, int, int)
- jv jv_parser_next(jv_parser*)
-
def jq(char* program):
cdef jq_state *jq = jq_init()
@@ -60,19 +58,18 @@ cdef class _Program(object):
cdef object _string_to_strings(self, char* input):
- cdef jv_parser parser
- jv_parser_init(&parser)
- jv_parser_set_buf(&parser, input, len(input), 0)
+ cdef jv_parser* parser = jv_parser_new()
+ jv_parser_set_buf(parser, input, len(input), 0)
cdef jv value
results = []
while True:
- value = jv_parser_next(&parser)
+ value = jv_parser_next(parser)
if jv_is_valid(value):
self._process(value, results)
else:
break
- jv_parser_free(&parser)
+ jv_parser_free(parser)
return results
diff --git a/setup.py b/setup.py
index 130090a..8b5e695 100644
--- a/setup.py
+++ b/setup.py
@@ -28,11 +28,11 @@ class jq_build_ext(build_ext):
else:
subprocess.check_call([
"git", "clone",
- "https://github.com/nicowilliams/jq.git",
+ "https://github.com/stedolan/jq.git",
jq_lib_dir
])
- # Tested with commit e8643787cf
+ # Tested with commit 37cfc912c1
command(["git", "checkout", "libjq"])
command(["mkdir", "-p", "m4"])
command(["autoreconf", "-i"])
@@ -47,8 +47,9 @@ jq_extension = Extension(
"jq",
sources=["jq.c"],
include_dirs=[jq_lib_dir],
- libraries=["jq"],
- library_dirs=[jq_lib_dir],
+ #libraries=["jq"],
+ extra_objects=[os.path.join(jq_lib_dir, ".libs/libjq.a")],
+ #library_dirs=[os.path.join(jq_lib_dir, ".libs")],
)
setup(