Ruby 1.9.2p136(2010-12-25revision30365)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

# ext/json/parser/parser.h

Go to the documentation of this file.

    00001 #ifndef _PARSER_H_
    00002 #define _PARSER_H_
    00003
    00004 #include "ruby.h"
    00005
    00006 #if HAVE_RE_H
    00007 #include "re.h"
    00008 #endif
    00009
    00010 #ifdef HAVE_RUBY_ENCODING_H
    00011 #include "ruby/encoding.h"
    00012 #define FORCE_UTF8(obj) rb_enc_associate((obj), rb_utf8_encoding())
    00013 #else
    00014 #define FORCE_UTF8(obj)
    00015 #endif
    00016
    00017 #define option_given_p(opts, key) RTEST(rb_funcall(opts, i_key_p, 1, key))
    00018
    00019 /* unicode */
    00020
    00021 typedef unsigned long   UTF32;  /* at least 32 bits */
    00022 typedef unsigned short UTF16;   /* at least 16 bits */
    00023 typedef unsigned char   UTF8;     /* typically 8 bits */
    00024
    00025 #define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
    00026 #define UNI_SUR_HIGH_START  (UTF32)0xD800
    00027 #define UNI_SUR_HIGH_END    (UTF32)0xDBFF
    00028 #define UNI_SUR_LOW_START   (UTF32)0xDC00
    00029 #define UNI_SUR_LOW_END     (UTF32)0xDFFF
    00030
    00031 typedef struct JSON_ParserStruct {
    00032     VALUE Vsource;
    00033     char *source;
    00034     long len;
    00035     char *memo;
    00036     VALUE create_id;
    00037     int max_nesting;
    00038     int current_nesting;
    00039     int allow_nan;
    00040     int parsing_name;
    00041     int symbolize_names;
    00042     VALUE object_class;
    00043     VALUE array_class;
    00044 } JSON_Parser;
    00045
    00046 #define GET_PARSER                          \
    00047     JSON_Parser *json;                      \
    00048     Data_Get_Struct(self, JSON_Parser, json)
    00049
    00050 #define MinusInfinity "-Infinity"
    00051 #define EVIL 0x666
    00052
    00053 static UTF32 unescape_unicode(const unsigned char *p);
    00054 static int convert_UTF32_to_UTF8(char *buf, UTF32 ch);
    00055 static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result);
    00056 static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result);
    00057 static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result);
    00058 static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result);
    00059 static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result);
    00060 static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd);
    00061 static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result);
    00062 static VALUE convert_encoding(VALUE source);
    00063 static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self);
    00064 static VALUE cParser_parse(VALUE self);
    00065 static JSON_Parser *JSON_allocate();
    00066 static void JSON_mark(JSON_Parser *json);
    00067 static void JSON_free(JSON_Parser *json);
    00068 static VALUE cJSON_parser_s_allocate(VALUE klass);
    00069 static VALUE cParser_source(VALUE self);
    00070
    00071 #endif
    00072