diff options
Diffstat (limited to 'ext/json/parser/parser.h')
| -rw-r--r-- | ext/json/parser/parser.h | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/ext/json/parser/parser.h b/ext/json/parser/parser.h index 45afbc2732..92ed3fdc5d 100644 --- a/ext/json/parser/parser.h +++ b/ext/json/parser/parser.h @@ -13,6 +13,10 @@ #include "st.h" #endif +#ifndef MAYBE_UNUSED +# define MAYBE_UNUSED(x) x +#endif + #define option_given_p(opts, key) RTEST(rb_funcall(opts, i_key_p, 1, key)) /* unicode */ @@ -34,13 +38,13 @@ typedef struct JSON_ParserStruct { char *memo; VALUE create_id; int max_nesting; - int current_nesting; int allow_nan; int parsing_name; int symbolize_names; - int quirks_mode; + int freeze; VALUE object_class; VALUE array_class; + VALUE decimal_class; int create_additions; VALUE match_string; FBuffer *fbuffer; @@ -58,21 +62,35 @@ typedef struct JSON_ParserStruct { static UTF32 unescape_unicode(const unsigned char *p); static int convert_UTF32_to_UTF8(char *buf, UTF32 ch); -static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result); -static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result); +static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting); +static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting); static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result); static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result); -static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result); -static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd); +static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting); +static VALUE json_string_unescape(char *string, char *stringEnd, int intern, int symbolize); static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result); static VALUE convert_encoding(VALUE source); static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self); static VALUE cParser_parse(VALUE self); -static JSON_Parser *JSON_allocate(void); static void JSON_mark(void *json); static void JSON_free(void *json); static VALUE cJSON_parser_s_allocate(VALUE klass); static VALUE cParser_source(VALUE self); +#ifndef ZALLOC +#define ZALLOC(type) ((type *)ruby_zalloc(sizeof(type))) +static inline void *ruby_zalloc(size_t n) +{ + void *p = ruby_xmalloc(n); + memset(p, 0, n); + return p; +} +#endif +#ifdef TypedData_Make_Struct static const rb_data_type_t JSON_Parser_type; +#define NEW_TYPEDDATA_WRAPPER 1 +#else +#define TypedData_Make_Struct(klass, type, ignore, json) Data_Make_Struct(klass, type, NULL, JSON_free, json) +#define TypedData_Get_Struct(self, JSON_Parser, ignore, json) Data_Get_Struct(self, JSON_Parser, json) +#endif #endif |
