path: root/ext/json/parser/parser.h
diff options
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-26 06:27:27 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-26 06:27:27 +0000
commit3642494ce5a44938285677669b3e001a1af1ce47 (patch)
tree73fae9b5eb43a636cf3b928ef1630a9d831a613f /ext/json/parser/parser.h
parent27be3056dc0e9c313f25b430ca90b240a5e44160 (diff)
Recommit of JSON; fix mixed declarations.
git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/json/parser/parser.h')
1 files changed, 71 insertions, 0 deletions
diff --git a/ext/json/parser/parser.h b/ext/json/parser/parser.h
new file mode 100644
index 0000000000..688ffdaeba
--- /dev/null
+++ b/ext/json/parser/parser.h
@@ -0,0 +1,71 @@
+#ifndef _PARSER_H_
+#define _PARSER_H_
+#include "ruby.h"
+#if HAVE_RE_H
+#include "re.h"
+#include "ruby/encoding.h"
+#define FORCE_UTF8(obj) rb_enc_associate((obj), rb_utf8_encoding())
+#define FORCE_UTF8(obj)
+#define option_given_p(opts, key) RTEST(rb_funcall(opts, i_key_p, 1, key))
+/* unicode */
+typedef unsigned long UTF32; /* at least 32 bits */
+typedef unsigned short UTF16; /* at least 16 bits */
+typedef unsigned char UTF8; /* typically 8 bits */
+#define UNI_SUR_HIGH_START (UTF32)0xD800
+#define UNI_SUR_LOW_START (UTF32)0xDC00
+#define UNI_SUR_LOW_END (UTF32)0xDFFF
+typedef struct JSON_ParserStruct {
+ VALUE Vsource;
+ char *source;
+ long len;
+ char *memo;
+ VALUE create_id;
+ int max_nesting;
+ int current_nesting;
+ int allow_nan;
+ int parsing_name;
+ int symbolize_names;
+ VALUE object_class;
+ VALUE array_class;
+} JSON_Parser;
+#define GET_PARSER \
+ JSON_Parser *json; \
+ Data_Get_Struct(self, JSON_Parser, json)
+#define MinusInfinity "-Infinity"
+#define EVIL 0x666
+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);