Ruby 1.9.2p136(2010-12-25revision30365)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Functions | Variables

# ext/json/parser/parser.c File Reference

`#include "parser.h"`
Include dependency graph for parser.c:

Go to the source code of this file.

## Functions
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_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_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 ()
static void | JSON_mark (JSON_Parser *json)
static void | JSON_free (JSON_Parser *json)
static VALUE | cJSON_parser_s_allocate (VALUE klass)
static VALUE | cParser_source (VALUE self)
void | Init_parser ()
## Variables
static const char | digit_values [256]
static ID | i_iconv
static VALUE | mJSON
static VALUE | mExt
static VALUE | cParser
static VALUE | eParserError
static VALUE | eNestingError
static VALUE | CNaN
static VALUE | CInfinity
static VALUE | CMinusInfinity
static ID | i_json_creatable_p
static ID | i_json_create
static ID | i_create_id
static ID | i_create_additions
static ID | i_chr
static ID | i_max_nesting
static ID | i_allow_nan
static ID | i_symbolize_names
static ID | i_object_class
static ID | i_array_class
static ID | i_key_p
static ID | i_deep_const_get
static const int | JSON_object_start = 1
static const int | JSON_object_first_final = 27
static const int | JSON_object_error = 0
static const int | JSON_object_en_main = 1
static const int | JSON_value_start = 1
static const int | JSON_value_first_final = 21
static const int | JSON_value_error = 0
static const int | JSON_value_en_main = 1
static const int | JSON_integer_start = 1
static const int | JSON_integer_first_final = 5
static const int | JSON_integer_error = 0
static const int | JSON_integer_en_main = 1
static const int | JSON_float_start = 1
static const int | JSON_float_first_final = 10
static const int | JSON_float_error = 0
static const int | JSON_float_en_main = 1
static const int | JSON_array_start = 1
static const int | JSON_array_first_final = 17
static const int | JSON_array_error = 0
static const int | JSON_array_en_main = 1
static const int | JSON_string_start = 1
static const int | JSON_string_first_final = 8
static const int | JSON_string_error = 0
static const int | JSON_string_en_main = 1
static const int | JSON_start = 1
static const int | JSON_first_final = 10
static const int | JSON_error = 0
static const int | JSON_en_main = 1

## Function Documentation

static VALUE cJSON_parser_s_allocate | ( | VALUE | klass | ) | `[static]`

Definition at line 1874 of file parser.c.

References Data_Wrap_Struct, JSON_allocate(), JSON_free(), and JSON_mark().

Referenced by Init_parser().

static VALUE convert_encoding | ( | VALUE | source | ) | `[static]`

Definition at line 1534 of file parser.c.

References eParserError, FORCE_UTF8, i_iconv, len, mJSON, rb_funcall(), rb_raise(), rb_str_dup(), rb_str_new2(), RSTRING_LEN, and RSTRING_PTR.

Referenced by cParser_initialize().

static int convert_UTF32_to_UTF8 | ( | char * | buf,
|  | UTF32 | ch
| ) |  | `[static]`

Definition at line 43 of file parser.c.

References len.

Referenced by json_string_unescape().

static VALUE cParser_initialize | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  | `[static]`

Definition at line 1608 of file parser.c.

References Check_Type, convert_encoding(), FIX2INT, GET_PARSER, i_allow_nan, i_array_class, i_create_additions, i_create_id, i_max_nesting, i_object_class, i_symbolize_names, ID2SYM, len, mJSON, NIL_P, option_given_p, Qnil, rb_convert_type(), rb_eArgError, rb_funcall(), rb_hash_aref(), rb_raise(), rb_scan_args(), RSTRING_LEN, RSTRING_PTR, RTEST, StringValue, T_FIXNUM, and T_HASH.

Referenced by Init_parser().

static VALUE cParser_parse | ( | VALUE | self | ) | `[static]`

Definition at line 1693 of file parser.c.

References eParserError, EVIL, GET_PARSER, JSON_first_final, JSON_parse_array(), JSON_parse_object(), JSON_start, NULL, Qnil, rb_raise(), and result.

Referenced by Init_parser().

static VALUE cParser_source | ( | VALUE | self | ) | `[static]`

Definition at line 1886 of file parser.c.

References GET_PARSER, and rb_str_dup().

Referenced by Init_parser().

void Init_parser | ( |  | ) |

Definition at line 1892 of file parser.c.

References CInfinity, cJSON_parser_s_allocate(), CMinusInfinity, CNaN, cParser, cParser_initialize(), cParser_parse(), cParser_source(), eNestingError, eParserError, i_allow_nan, i_array_class, i_chr, i_create_additions, i_create_id, i_deep_const_get, i_iconv, i_json_creatable_p, i_json_create, i_key_p, i_max_nesting, i_object_class, i_symbolize_names, mExt, mJSON, rb_cObject, rb_const_get(), rb_define_alloc_func(), rb_define_class_under(), rb_define_method(), rb_define_module(), rb_define_module_under(), rb_funcall(), rb_intern, rb_path2class(), rb_require(), and rb_str_new2().

static JSON_Parser* JSON_allocate | ( |  | ) | `[static]`

Definition at line 1854 of file parser.c.

References ALLOC, and MEMZERO.

Referenced by cJSON_parser_s_allocate().

static void JSON_free | ( | JSON_Parser * | json | ) | `[static]`

Definition at line 1869 of file parser.c.

References ruby_xfree().

Referenced by cJSON_parser_s_allocate().

static void JSON_mark | ( | JSON_Parser * | json | ) | `[static]`

Definition at line 1861 of file parser.c.

References JSON_ParserStruct::array_class, JSON_ParserStruct::create_id, JSON_ParserStruct::object_class, rb_gc_mark_maybe(), and JSON_ParserStruct::Vsource.

Referenced by cJSON_parser_s_allocate().

static char* JSON_parse_array | ( | JSON_Parser * | json,
|  | char * | p,
|  | char * | pe,
|  | VALUE * | result
| ) |  | `[static]`

Definition at line 1036 of file parser.c.

References JSON_ParserStruct::array_class, JSON_ParserStruct::current_nesting, eNestingError, eParserError, EVIL, JSON_array_first_final, JSON_array_start, JSON_parse_value(), JSON_ParserStruct::max_nesting, NIL_P, NULL, Qnil, rb_ary_new(), rb_ary_push(), rb_class_new_instance(), and rb_raise().

Referenced by cParser_parse(), and JSON_parse_value().

static char* JSON_parse_float | ( | JSON_Parser * | json,
|  | char * | p,
|  | char * | pe,
|  | VALUE * | result
| ) |  | `[static]`

Definition at line 873 of file parser.c.

References EVIL, JSON_float_first_final, JSON_float_start, len, JSON_ParserStruct::memo, NULL, rb_Float(), and rb_str_new().

Referenced by JSON_parse_value().

static char* JSON_parse_integer | ( | JSON_Parser * | json,
|  | char * | p,
|  | char * | pe,
|  | VALUE * | result
| ) |  | `[static]`

Definition at line 777 of file parser.c.

References EVIL, JSON_integer_first_final, JSON_integer_start, len, JSON_ParserStruct::memo, NULL, rb_Integer(), and rb_str_new().

Referenced by JSON_parse_value().

static char* JSON_parse_object | ( | JSON_Parser * | json,
|  | char * | p,
|  | char * | pe,
|  | VALUE * | result
| ) |  | `[static]`

Definition at line 100 of file parser.c.

References JSON_ParserStruct::create_id, JSON_ParserStruct::current_nesting, eNestingError, EVIL, i_deep_const_get, i_json_creatable_p, i_json_create, JSON_object_first_final, JSON_object_start, JSON_parse_string(), JSON_parse_value(), JSON_ParserStruct::max_nesting, mJSON, NIL_P, NULL, JSON_ParserStruct::object_class, JSON_ParserStruct::parsing_name, Qnil, rb_class_new_instance(), rb_funcall(), rb_hash_aref(), rb_hash_aset(), rb_hash_new(), rb_raise(), and RTEST.

Referenced by cParser_parse(), and JSON_parse_value().

static char* JSON_parse_string | ( | JSON_Parser * | json,
|  | char * | p,
|  | char * | pe,
|  | VALUE * | result
| ) |  | `[static]`

Definition at line 1364 of file parser.c.

References EVIL, FORCE_UTF8, JSON_string_first_final, JSON_string_start, json_string_unescape(), JSON_ParserStruct::memo, NIL_P, NULL, JSON_ParserStruct::parsing_name, rb_str_buf_new(), rb_str_intern(), and JSON_ParserStruct::symbolize_names.

Referenced by JSON_parse_object(), and JSON_parse_value().

static char* JSON_parse_value | ( | JSON_Parser * | json,
|  | char * | p,
|  | char * | pe,
|  | VALUE * | result
| ) |  | `[static]`

Definition at line 468 of file parser.c.

References JSON_ParserStruct::allow_nan, CInfinity, CMinusInfinity, CNaN, JSON_ParserStruct::current_nesting, eParserError, EVIL, JSON_parse_array(), JSON_parse_float(), JSON_parse_integer(), JSON_parse_object(), JSON_parse_string(), JSON_value_first_final, JSON_value_start, MinusInfinity, NULL, Qfalse, Qnil, Qtrue, and rb_raise().

Referenced by JSON_parse_array(), and JSON_parse_object().

static VALUE json_string_unescape | ( | VALUE | result,
|  | char * | string,
|  | char * | stringEnd
| ) |  | `[static]`

Definition at line 1282 of file parser.c.

References buf, convert_UTF32_to_UTF8(), Qnil, rb_str_buf_cat(), result, unescape_unicode(), and UNI_SUR_HIGH_START.

Referenced by JSON_parse_string().

static UTF32 unescape_unicode | ( | const unsigned char * | p | ) | `[static]`

Definition at line 24 of file parser.c.

References digit_values, result, and UNI_REPLACEMENT_CHAR.

Referenced by json_string_unescape().

## Variable Documentation

VALUE CInfinity

Definition at line 78 of file parser.c.

Referenced by Init_parser(), and JSON_parse_value().

VALUE CMinusInfinity

Definition at line 78 of file parser.c.

Referenced by Init_parser(), and JSON_parse_value().

VALUE CNaN`[static]`

Definition at line 78 of file parser.c.

Referenced by Init_parser(), and JSON_parse_value().

VALUE cParser

Definition at line 77 of file parser.c.

Referenced by Init_parser(), and Init_syck().

const char digit_values[256]`[static]`

Initial value:

     {
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1,
        -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1,
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
        10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
        -1, -1, -1, -1, -1, -1, -1
    }

Definition at line 7 of file parser.c.

Referenced by unescape_unicode().

VALUE eNestingError

Definition at line 77 of file parser.c.

VALUE eParserError

Definition at line 77 of file parser.c.

Referenced by convert_encoding(), cParser_parse(), Init_parser(), JSON_parse_array(), and JSON_parse_value().

ID i_allow_nan

Definition at line 80 of file parser.c.

ID i_array_class

Definition at line 80 of file parser.c.

Referenced by cParser_initialize(), and Init_parser().

ID i_chr

Definition at line 80 of file parser.c.

Referenced by Init_parser().

ID i_create_additions

Definition at line 80 of file parser.c.

Referenced by cParser_initialize(), and Init_parser().

ID i_create_id

Definition at line 80 of file parser.c.

ID i_deep_const_get

Definition at line 80 of file parser.c.

Referenced by Init_parser(), and JSON_parse_object().

ID i_iconv`[static]`

Definition at line 74 of file parser.c.

Referenced by convert_encoding(), and Init_parser().

ID i_json_creatable_p`[static]`

Definition at line 80 of file parser.c.

Referenced by Init_parser(), and JSON_parse_object().

ID i_json_create

Definition at line 80 of file parser.c.

Referenced by Init_parser(), and JSON_parse_object().

ID i_key_p

Definition at line 80 of file parser.c.

ID i_max_nesting

Definition at line 80 of file parser.c.

ID i_object_class

Definition at line 80 of file parser.c.

Referenced by cParser_initialize(), and Init_parser().

ID i_symbolize_names

Definition at line 80 of file parser.c.

Referenced by cParser_initialize(), and Init_parser().

const int JSON_array_en_main = 1`[static]`

Definition at line 1030 of file parser.c.

const int JSON_array_error = 0`[static]`

Definition at line 1028 of file parser.c.

const int JSON_array_first_final = 17`[static]`

Definition at line 1027 of file parser.c.

Referenced by JSON_parse_array().

const int JSON_array_start = 1`[static]`

Definition at line 1026 of file parser.c.

Referenced by JSON_parse_array().

const int JSON_en_main = 1`[static]`

Definition at line 1516 of file parser.c.

const int JSON_error = 0`[static]`

Definition at line 1514 of file parser.c.

const int JSON_first_final = 10`[static]`

Definition at line 1513 of file parser.c.

Referenced by cParser_parse().

const int JSON_float_en_main = 1`[static]`

Definition at line 867 of file parser.c.

const int JSON_float_error = 0`[static]`

Definition at line 865 of file parser.c.

const int JSON_float_first_final = 10`[static]`

Definition at line 864 of file parser.c.

Referenced by JSON_parse_float().

const int JSON_float_start = 1`[static]`

Definition at line 863 of file parser.c.

Referenced by JSON_parse_float().

const int JSON_integer_en_main = 1`[static]`

Definition at line 771 of file parser.c.

const int JSON_integer_error = 0`[static]`

Definition at line 769 of file parser.c.

const int JSON_integer_first_final = 5`[static]`

Definition at line 768 of file parser.c.

Referenced by JSON_parse_integer().

const int JSON_integer_start = 1`[static]`

Definition at line 767 of file parser.c.

Referenced by JSON_parse_integer().

const int JSON_object_en_main = 1`[static]`

Definition at line 94 of file parser.c.

const int JSON_object_error = 0`[static]`

Definition at line 92 of file parser.c.

const int JSON_object_first_final = 27`[static]`

Definition at line 91 of file parser.c.

Referenced by JSON_parse_object().

const int JSON_object_start = 1`[static]`

Definition at line 90 of file parser.c.

Referenced by JSON_parse_object().

const int JSON_start = 1`[static]`

Definition at line 1512 of file parser.c.

Referenced by cParser_parse().

const int JSON_string_en_main = 1`[static]`

Definition at line 1358 of file parser.c.

const int JSON_string_error = 0`[static]`

Definition at line 1356 of file parser.c.

const int JSON_string_first_final = 8`[static]`

Definition at line 1355 of file parser.c.

Referenced by JSON_parse_string().

const int JSON_string_start = 1`[static]`

Definition at line 1354 of file parser.c.

Referenced by JSON_parse_string().

const int JSON_value_en_main = 1`[static]`

Definition at line 462 of file parser.c.

const int JSON_value_error = 0`[static]`

Definition at line 460 of file parser.c.

const int JSON_value_first_final = 21`[static]`

Definition at line 459 of file parser.c.

Referenced by JSON_parse_value().

const int JSON_value_start = 1`[static]`

Definition at line 458 of file parser.c.

Referenced by JSON_parse_value().

VALUE mExt

Definition at line 77 of file parser.c.

VALUE mJSON`[static]`

Definition at line 77 of file parser.c.

Referenced by convert_encoding(), cParser_initialize(), Init_parser(), and JSON_parse_object().