Ruby 2.0.0p353(2013-11-22revision43784)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

parser.h
Go to the documentation of this file.
1 #ifndef _PARSER_H_
2 #define _PARSER_H_
3
4 #include "ruby.h"
5
6 #ifndef HAVE_RUBY_RE_H
7 #include "re.h"
8 #endif
9
10 #ifdef HAVE_RUBY_ST_H
11 #include "ruby/st.h"
12 #else
13 #include "st.h"
14 #endif
15
16 #define option_given_p(opts, key) RTEST(rb_funcall(opts, i_key_p, 1, key))
17
18 /* unicode */
19
20 typedef unsigned long UTF32; /* at least 32 bits */
21 typedef unsigned short UTF16; /* at least 16 bits */
22 typedef unsigned char UTF8; /* typically 8 bits */
23
24 #define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
25 #define UNI_SUR_HIGH_START (UTF32)0xD800
26 #define UNI_SUR_HIGH_END (UTF32)0xDBFF
27 #define UNI_SUR_LOW_START (UTF32)0xDC00
28 #define UNI_SUR_LOW_END (UTF32)0xDFFF
29
30 typedef struct JSON_ParserStruct {
31 VALUE Vsource;
32 char *source;
33 long len;
34 char *memo;
35 VALUE create_id;
36 int max_nesting;
37 int current_nesting;
38 int allow_nan;
39 int parsing_name;
40 int symbolize_names;
41 int quirks_mode;
42 VALUE object_class;
43 VALUE array_class;
44 int create_additions;
45 VALUE match_string;
46 FBuffer *fbuffer;
47 } JSON_Parser;
48
49 #define GET_PARSER \
50 GET_PARSER_INIT; \
51 if (!json->Vsource) rb_raise(rb_eTypeError, "uninitialized instance")
52 #define GET_PARSER_INIT \
53 JSON_Parser *json; \
54 Data_Get_Struct(self, JSON_Parser, json)
55
56 #define MinusInfinity "-Infinity"
57 #define EVIL 0x666
58
59 static UTF32 unescape_unicode(const unsigned char *p);
60 static int convert_UTF32_to_UTF8(char *buf, UTF32 ch);
61 static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result);
62 static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result);
63 static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result);
64 static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result);
65 static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result);
66 static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd);
67 static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result);
68 static VALUE convert_encoding(VALUE source);
69 static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self);
70 static VALUE cParser_parse(VALUE self);
71 static JSON_Parser *JSON_allocate();
72 static void JSON_mark(JSON_Parser *json);
73 static void JSON_free(JSON_Parser *json);
74 static VALUE cJSON_parser_s_allocate(VALUE klass);
75 static VALUE cParser_source(VALUE self);
76
77 #endif
cParser_source
static VALUE cParser_source(VALUE self)
JSON_ParserStruct::create_additions
int create_additions
Definition: parser.h:44
unescape_unicode
static UTF32 unescape_unicode(const unsigned char *p)
JSON_ParserStruct::memo
char * memo
Definition: parser.h:34
p
Win32OLEIDispatch * p
Definition: win32ole.c:786
JSON_ParserStruct::len
long len
Definition: parser.h:33
ruby.h
UTF8
unsigned char UTF8
Definition: generator.h:32
JSON_ParserStruct::allow_nan
int allow_nan
Definition: parser.h:38
JSON_ParserStruct::parsing_name
int parsing_name
Definition: parser.h:39
JSON_ParserStruct::current_nesting
int current_nesting
Definition: parser.h:37
JSON_free
static void JSON_free(JSON_Parser *json)
UTF16
unsigned short UTF16
Definition: generator.h:31
cParser_initialize
static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
cJSON_parser_s_allocate
static VALUE cJSON_parser_s_allocate(VALUE klass)
json_string_unescape
static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd)
UTF32
unsigned long UTF32
Definition: generator.h:30
JSON_ParserStruct::object_class
VALUE object_class
Definition: parser.h:42
buf
unsigned char buf[MIME_BUF_SIZE]
Definition: nkf.c:4308
JSON_ParserStruct::symbolize_names
int symbolize_names
Definition: parser.h:40
JSON_ParserStruct::max_nesting
int max_nesting
Definition: parser.h:36
JSON_allocate
static JSON_Parser * JSON_allocate()
argv
VALUE * argv
Definition: tcltklib.c:1971
result
q result
Definition: tcltklib.c:7070
JSON_parse_value
static char * JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result)
argc
int argc
Definition: tcltklib.c:1970
convert_UTF32_to_UTF8
static int convert_UTF32_to_UTF8(char *buf, UTF32 ch)
JSON_ParserStruct::quirks_mode
int quirks_mode
Definition: parser.h:41
re.h
JSON_parse_integer
static char * JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result)
klass
klass
Definition: tcltklib.c:3504
JSON_parse_float
static char * JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result)
JSON_parse_array
static char * JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result)
JSON_ParserStruct::source
char * source
Definition: parser.h:32
st.h
FBufferStruct
Definition: fbuffer.h:40
JSON_ParserStruct::fbuffer
FBuffer * fbuffer
Definition: parser.h:46
JSON_ParserStruct::array_class
VALUE array_class
Definition: parser.h:43
JSON_parse_string
static char * JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result)
VALUE
unsigned long VALUE
Definition: ripper.y:104
JSON_ParserStruct::Vsource
VALUE Vsource
Definition: parser.h:31
JSON_ParserStruct::match_string
VALUE match_string
Definition: parser.h:45
JSON_mark
static void JSON_mark(JSON_Parser *json)
cParser_parse
static VALUE cParser_parse(VALUE self)
JSON_parse_object
static char * JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result)
JSON_ParserStruct::create_id
VALUE create_id
Definition: parser.h:35
convert_encoding
static VALUE convert_encoding(VALUE source)
JSON_ParserStruct
Definition: parser.h:30
JSON_Parser
struct JSON_ParserStruct JSON_Parser