Skip to content

Commit 77f4ff0

Browse files
committed
Experiment: ResumableParser
Fix: #983 Numerous known issues TODO: - `object_start_cursor` recorded in frame becomes invalid if the buffer string is reallocated or spilled. - The buffer need to be shrunk sometimes. - Lot more testing needed. - Unclear what to do with top level numbers (and perhaps true/false/null) - API is all but final - I'd like to be able to "pop" the value, so we don't uselessly keep a reference on it. - Then methods need to be documented. - It would worth trying to make `json_parse_any` exception free. - Right now EOF errors have been eliminated in favor of returning `false`. - We could try to do the same with syntax errors. - But then we need to `rb_protect` when calling back into Ruby or other unsafe APIs, so perhaps it's best to just accept it.
1 parent ad6b9cf commit 77f4ff0

3 files changed

Lines changed: 416 additions & 48 deletions

File tree

ext/json/ext/json.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
#if defined(RUBY_DEBUG) && RUBY_DEBUG
1313
# define JSON_ASSERT RUBY_ASSERT
14+
# ifndef JSON_DEBUG
15+
# define JSON_DEBUG 1
16+
# endif
1417
#else
1518
# ifdef JSON_DEBUG
1619
# include <assert.h>
@@ -20,8 +23,18 @@
2023
# endif
2124
#endif
2225

26+
#ifdef JSON_DEBUG
27+
# define JSON_UNREACHABLE_RETURN(val) rb_bug("Unreachable")
28+
#else
29+
# define JSON_UNREACHABLE_RETURN UNREACHABLE_RETURN
30+
#endif
31+
2332
/* shims */
2433

34+
#ifndef UNDEF_P
35+
#define UNDEF_P(val) (val == Qundef)
36+
#endif
37+
2538
#if SIZEOF_UINT64_T == SIZEOF_LONG_LONG
2639
# define INT64T2NUM(x) LL2NUM(x)
2740
# define UINT64T2NUM(x) ULL2NUM(x)

0 commit comments

Comments
 (0)