• 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     GET_PARSER_INIT;                        \
00048     if (!json->Vsource) rb_raise(rb_eTypeError, "uninitialized instance")
00049 #define GET_PARSER_INIT                     \
00050     JSON_Parser *json;                      \
00051     Data_Get_Struct(self, JSON_Parser, json)
00052 
00053 #define MinusInfinity "-Infinity"
00054 #define EVIL 0x666
00055 
00056 static UTF32 unescape_unicode(const unsigned char *p);
00057 static int convert_UTF32_to_UTF8(char *buf, UTF32 ch);
00058 static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result);
00059 static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result);
00060 static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result);
00061 static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result);
00062 static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result);
00063 static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd);
00064 static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result);
00065 static VALUE convert_encoding(VALUE source);
00066 static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self);
00067 static VALUE cParser_parse(VALUE self);
00068 static JSON_Parser *JSON_allocate();
00069 static void JSON_mark(JSON_Parser *json);
00070 static void JSON_free(JSON_Parser *json);
00071 static VALUE cJSON_parser_s_allocate(VALUE klass);
00072 static VALUE cParser_source(VALUE self);
00073 
00074 #endif
00075 

Generated on Sat Jul 7 2012 15:29:09 for Ruby by  doxygen 1.7.1