summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Frank <flori@ping.de>2011-01-05 00:12:51 +0100
committerFlorian Frank <flori@ping.de>2011-01-05 00:12:51 +0100
commit0b15820e245f4048d1bcd29cd60693e4e211ab43 (patch)
treeabffda1af3d23b47739d88fd089609cffa378ed7
parentc87f6f3022f9b7c1b1317e958976e2ed6d4f4ae4 (diff)
downloadjson-0b15820e245f4048d1bcd29cd60693e4e211ab43.tar.gz
renamed :match argument to :match_stringv1.5.0
-rw-r--r--ext/json/ext/parser/parser.c19
-rw-r--r--ext/json/ext/parser/parser.h2
-rw-r--r--ext/json/ext/parser/parser.rl19
-rw-r--r--java/src/json/ext/Parser.java10
-rw-r--r--java/src/json/ext/Parser.rl10
-rw-r--r--lib/json/pure/parser.rb6
-rw-r--r--tests/test_json_string_matching.rb6
7 files changed, 37 insertions, 35 deletions
diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c
index a16d068..c125f82 100644
--- a/ext/json/ext/parser/parser.c
+++ b/ext/json/ext/parser/parser.c
@@ -79,7 +79,7 @@ static VALUE CNaN, CInfinity, CMinusInfinity;
static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
i_chr, i_max_nesting, i_allow_nan, i_symbolize_names, i_object_class,
- i_array_class, i_key_p, i_deep_const_get, i_match;
+ i_array_class, i_key_p, i_deep_const_get, i_match, i_match_string;
#line 108 "parser.rl"
@@ -1376,7 +1376,7 @@ match_i(VALUE regexp, VALUE klass, VALUE memo)
static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result)
{
int cs = EVIL;
- VALUE match;
+ VALUE match_string;
*result = rb_str_buf_new(0);
@@ -1509,11 +1509,11 @@ case 7:
#line 494 "parser.rl"
- if (json->create_additions && RTEST(match = json->match)) {
+ if (json->create_additions && RTEST(match_string = json->match_string)) {
VALUE klass;
VALUE memo = rb_ary_new2(2);
rb_ary_push(memo, *result);
- rb_hash_foreach(match, match_i, memo);
+ rb_hash_foreach(match_string, match_i, memo);
klass = rb_ary_entry(memo, 1);
if (RTEST(klass)) {
*result = rb_funcall(klass, i_json_create, 1, *result);
@@ -1692,12 +1692,12 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
} else {
json->array_class = Qnil;
}
- tmp = ID2SYM(i_match);
+ tmp = ID2SYM(i_match_string);
if (option_given_p(opts, tmp)) {
- VALUE match = rb_hash_aref(opts, tmp);
- json->match = RTEST(match) ? match : Qnil;
+ VALUE match_string = rb_hash_aref(opts, tmp);
+ json->match_string = RTEST(match_string) ? match_string : Qnil;
} else {
- json->match = Qnil;
+ json->match_string = Qnil;
}
}
} else {
@@ -1895,7 +1895,7 @@ static void JSON_mark(JSON_Parser *json)
rb_gc_mark_maybe(json->create_id);
rb_gc_mark_maybe(json->object_class);
rb_gc_mark_maybe(json->array_class);
- rb_gc_mark_maybe(json->match);
+ rb_gc_mark_maybe(json->match_string);
}
static void JSON_free(JSON_Parser *json)
@@ -1949,6 +1949,7 @@ void Init_parser()
i_object_class = rb_intern("object_class");
i_array_class = rb_intern("array_class");
i_match = rb_intern("match");
+ i_match_string = rb_intern("match_string");
i_key_p = rb_intern("key?");
i_deep_const_get = rb_intern("deep_const_get");
#ifdef HAVE_RUBY_ENCODING_H
diff --git a/ext/json/ext/parser/parser.h b/ext/json/ext/parser/parser.h
index 877ef67..ed48035 100644
--- a/ext/json/ext/parser/parser.h
+++ b/ext/json/ext/parser/parser.h
@@ -47,7 +47,7 @@ typedef struct JSON_ParserStruct {
VALUE object_class;
VALUE array_class;
int create_additions;
- VALUE match;
+ VALUE match_string;
} JSON_Parser;
#define GET_PARSER \
diff --git a/ext/json/ext/parser/parser.rl b/ext/json/ext/parser/parser.rl
index 53f1dbe..5862698 100644
--- a/ext/json/ext/parser/parser.rl
+++ b/ext/json/ext/parser/parser.rl
@@ -77,7 +77,7 @@ static VALUE CNaN, CInfinity, CMinusInfinity;
static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
i_chr, i_max_nesting, i_allow_nan, i_symbolize_names, i_object_class,
- i_array_class, i_key_p, i_deep_const_get, i_match;
+ i_array_class, i_key_p, i_deep_const_get, i_match, i_match_string;
%%{
machine JSON_common;
@@ -485,18 +485,18 @@ match_i(VALUE regexp, VALUE klass, VALUE memo)
static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result)
{
int cs = EVIL;
- VALUE match;
+ VALUE match_string;
*result = rb_str_buf_new(0);
%% write init;
json->memo = p;
%% write exec;
- if (json->create_additions && RTEST(match = json->match)) {
+ if (json->create_additions && RTEST(match_string = json->match_string)) {
VALUE klass;
VALUE memo = rb_ary_new2(2);
rb_ary_push(memo, *result);
- rb_hash_foreach(match, match_i, memo);
+ rb_hash_foreach(match_string, match_i, memo);
klass = rb_ary_entry(memo, 1);
if (RTEST(klass)) {
*result = rb_funcall(klass, i_json_create, 1, *result);
@@ -690,12 +690,12 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
} else {
json->array_class = Qnil;
}
- tmp = ID2SYM(i_match);
+ tmp = ID2SYM(i_match_string);
if (option_given_p(opts, tmp)) {
- VALUE match = rb_hash_aref(opts, tmp);
- json->match = RTEST(match) ? match : Qnil;
+ VALUE match_string = rb_hash_aref(opts, tmp);
+ json->match_string = RTEST(match_string) ? match_string : Qnil;
} else {
- json->match = Qnil;
+ json->match_string = Qnil;
}
}
} else {
@@ -752,7 +752,7 @@ static void JSON_mark(JSON_Parser *json)
rb_gc_mark_maybe(json->create_id);
rb_gc_mark_maybe(json->object_class);
rb_gc_mark_maybe(json->array_class);
- rb_gc_mark_maybe(json->match);
+ rb_gc_mark_maybe(json->match_string);
}
static void JSON_free(JSON_Parser *json)
@@ -806,6 +806,7 @@ void Init_parser()
i_object_class = rb_intern("object_class");
i_array_class = rb_intern("array_class");
i_match = rb_intern("match");
+ i_match_string = rb_intern("match_string");
i_key_p = rb_intern("key?");
i_deep_const_get = rb_intern("deep_const_get");
#ifdef HAVE_RUBY_ENCODING_H
diff --git a/java/src/json/ext/Parser.java b/java/src/json/ext/Parser.java
index f6e9c4e..c92600e 100644
--- a/java/src/json/ext/Parser.java
+++ b/java/src/json/ext/Parser.java
@@ -53,7 +53,7 @@ public class Parser extends RubyObject {
private boolean symbolizeNames;
private RubyClass objectClass;
private RubyClass arrayClass;
- private RubyHash match;
+ private RubyHash match_string;
private static final int DEFAULT_MAX_NESTING = 19;
@@ -155,7 +155,7 @@ public class Parser extends RubyObject {
this.createAdditions = opts.getBool("create_additions", true);
this.objectClass = opts.getClass("object_class", runtime.getHash());
this.arrayClass = opts.getClass("array_class", runtime.getArray());
- this.match = opts.getHash("match");
+ this.match_string = opts.getHash("match_string");
this.vSource = source;
return this;
@@ -1383,11 +1383,11 @@ case 5:
// line 554 "Parser.rl"
if (parser.createAdditions) {
- RubyHash match = parser.match;
- if (match != null) {
+ RubyHash match_string = parser.match_string;
+ if (match_string != null) {
final IRubyObject[] memoArray = { result, null };
try {
- match.visitAll(new RubyHash.Visitor() {
+ match_string.visitAll(new RubyHash.Visitor() {
@Override
public void visit(IRubyObject pattern, IRubyObject klass) {
if (pattern.callMethod(context, "===", memoArray[0]).isTrue()) {
diff --git a/java/src/json/ext/Parser.rl b/java/src/json/ext/Parser.rl
index a79ead5..e576b97 100644
--- a/java/src/json/ext/Parser.rl
+++ b/java/src/json/ext/Parser.rl
@@ -51,7 +51,7 @@ public class Parser extends RubyObject {
private boolean symbolizeNames;
private RubyClass objectClass;
private RubyClass arrayClass;
- private RubyHash match;
+ private RubyHash match_string;
private static final int DEFAULT_MAX_NESTING = 19;
@@ -153,7 +153,7 @@ public class Parser extends RubyObject {
this.createAdditions = opts.getBool("create_additions", true);
this.objectClass = opts.getClass("object_class", runtime.getHash());
this.arrayClass = opts.getClass("array_class", runtime.getArray());
- this.match = opts.getHash("match");
+ this.match_string = opts.getHash("match_string");
this.vSource = source;
return this;
@@ -553,11 +553,11 @@ public class Parser extends RubyObject {
%% write exec;
if (parser.createAdditions) {
- RubyHash match = parser.match;
- if (match != null) {
+ RubyHash match_string = parser.match_string;
+ if (match_string != null) {
final IRubyObject[] memoArray = { result, null };
try {
- match.visitAll(new RubyHash.Visitor() {
+ match_string.visitAll(new RubyHash.Visitor() {
@Override
public void visit(IRubyObject pattern, IRubyObject klass) {
if (pattern.callMethod(context, "===", memoArray[0]).isTrue()) {
diff --git a/lib/json/pure/parser.rb b/lib/json/pure/parser.rb
index 6a0192c..8043e67 100644
--- a/lib/json/pure/parser.rb
+++ b/lib/json/pure/parser.rb
@@ -119,7 +119,7 @@ module JSON
@create_id = opts[:create_id] || JSON.create_id
@object_class = opts[:object_class] || Hash
@array_class = opts[:array_class] || Array
- @json_match = opts[:match] # @match is an ivar in rbx's strscan
+ @match_string = opts[:match_string]
end
alias source string
@@ -189,8 +189,8 @@ module JSON
if string.respond_to?(:force_encoding)
string.force_encoding(::Encoding::UTF_8)
end
- if @create_additions and @json_match
- for (regexp, klass) in @json_match
+ if @create_additions and @match_string
+ for (regexp, klass) in @match_string
klass.json_creatable? or next
string =~ regexp and return klass.json_create(string)
end
diff --git a/tests/test_json_string_matching.rb b/tests/test_json_string_matching.rb
index 6bd74e3..df26a68 100644
--- a/tests/test_json_string_matching.rb
+++ b/tests/test_json_string_matching.rb
@@ -28,13 +28,13 @@ class TestJsonStringMatching < Test::Unit::TestCase
t_json = [ t ].to_json
assert_equal [ t ],
JSON.parse(t_json,
- :match => { /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\Z/ => TestTime })
+ :match_string => { /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\Z/ => TestTime })
assert_equal [ t.strftime('%FT%T%z') ],
JSON.parse(t_json,
- :match => { /\A\d{3}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\Z/ => TestTime })
+ :match_string => { /\A\d{3}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\Z/ => TestTime })
assert_equal [ t.strftime('%FT%T%z') ],
JSON.parse(t_json,
- :match => { /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\Z/ => TestTime },
+ :match_string => { /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\Z/ => TestTime },
:create_additions => false)
end
end