summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Frank <flori@ping.de>2009-11-05 18:39:16 +0100
committerFlorian Frank <flori@ping.de>2009-11-05 18:39:16 +0100
commit16ec09d6af3e109400f5a64454b2dd38488e3ded (patch)
tree18a445607862295af26727a8b9b6b24ce5b4f6db
parent1e366a222abf3f7232b427ce968675d3a906b90c (diff)
downloadjson-16ec09d6af3e109400f5a64454b2dd38488e3ded.tar.gz
added docu, some methods renamed
-rw-r--r--ext/json/ext/generator/generator.c13
-rw-r--r--ext/json/ext/generator/unicode.c4
-rw-r--r--ext/json/ext/generator/unicode.h4
-rw-r--r--lib/json/pure/generator.rb4
4 files changed, 15 insertions, 10 deletions
diff --git a/ext/json/ext/generator/generator.c b/ext/json/ext/generator/generator.c
index 5e14827..d8be368 100644
--- a/ext/json/ext/generator/generator.c
+++ b/ext/json/ext/generator/generator.c
@@ -494,9 +494,9 @@ void generate_json(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, V
obj = rb_funcall(obj, i_encode, 1, CEncoding_UTF_8);
#endif
if (state->ascii_only) {
- JSON_convert_UTF8_to_JSON_ASCII(buffer, obj);
+ convert_UTF8_to_JSON_ASCII(buffer, obj);
} else {
- JSON_convert_UTF8_to_JSON(buffer, obj);
+ convert_UTF8_to_JSON(buffer, obj);
}
fbuffer_append_char(buffer, '"');
break;
@@ -543,9 +543,10 @@ void generate_json(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, V
}
/*
- * call-seq: generate(obj)
+ * call-seq: partial_generate(obj)
*
- * XXX
+ * Generates a part of a JSON document from object +obj+ and returns the
+ * result.
*/
inline static VALUE cState_partial_generate(VALUE self, VALUE obj, VALUE depth)
{
@@ -562,7 +563,9 @@ inline static VALUE cState_partial_generate(VALUE self, VALUE obj, VALUE depth)
/*
* call-seq: generate(obj)
*
- * XXX
+ * Generates a valid JSON document from object +obj+ and returns the
+ * result. If no valid JSON document can be created this method raises a
+ * GeneratorError exception.
*/
inline static VALUE cState_generate(VALUE self, VALUE obj)
{
diff --git a/ext/json/ext/generator/unicode.c b/ext/json/ext/generator/unicode.c
index e470eea..e838824 100644
--- a/ext/json/ext/generator/unicode.c
+++ b/ext/json/ext/generator/unicode.c
@@ -103,7 +103,7 @@ inline static void unicode_escape_to_buffer(FBuffer *buffer, char buf[7], UTF16
fbuffer_append(buffer, buf, 6);
}
-inline void JSON_convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string)
+inline void convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string)
{
const UTF8 *source = (UTF8 *) RSTRING_PTR(string);
const UTF8 *sourceEnd = source + RSTRING_LEN(string);
@@ -194,7 +194,7 @@ inline void JSON_convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string)
}
}
-inline void JSON_convert_UTF8_to_JSON(FBuffer *buffer, VALUE string)
+inline void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string)
{
const char *ptr = RSTRING_PTR(string), *p;
int len = RSTRING_LEN(string), start = 0, end = 0;
diff --git a/ext/json/ext/generator/unicode.h b/ext/json/ext/generator/unicode.h
index b827119..3837b32 100644
--- a/ext/json/ext/generator/unicode.h
+++ b/ext/json/ext/generator/unicode.h
@@ -26,8 +26,8 @@ static const int halfShift = 10; /* used for shifting by 10 bits */
static const UTF32 halfBase = 0x0010000UL;
static const UTF32 halfMask = 0x3FFUL;
-inline void JSON_convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string);
-inline void JSON_convert_UTF8_to_JSON(FBuffer *buffer, VALUE string);
+inline void convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string);
+inline void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string);
#ifndef RARRAY_PTR
#define RARRAY_PTR(ARRAY) RARRAY(ARRAY)->ptr
diff --git a/lib/json/pure/generator.rb b/lib/json/pure/generator.rb
index 8358988..256bdb5 100644
--- a/lib/json/pure/generator.rb
+++ b/lib/json/pure/generator.rb
@@ -216,7 +216,9 @@ module JSON
result
end
- # XXX
+ # Generates a valid JSON document from object +obj+ and returns the
+ # result. If no valid JSON document can be created this method raises a
+ # GeneratorError exception.
def generate(obj)
result = obj.to_json(self)
if result !~ /\A\s*(?:\[.*\]|\{.*\})\s*\Z/m