* ext/json/parser/parser.h (GET_PARSER): raise TypeError.
* ext/json/parser/parser.rl (cParser_initialize): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9cc62abc6b
commit
1069e5d665
@ -1,4 +1,8 @@
|
|||||||
Sat Feb 5 10:29:52 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sat Feb 5 11:29:10 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* ext/json/parser/parser.h (GET_PARSER): raise TypeError.
|
||||||
|
|
||||||
|
* ext/json/parser/parser.rl (cParser_initialize): ditto.
|
||||||
|
|
||||||
* ext/json/parser/parser.h (GET_PARSER): check if initialized.
|
* ext/json/parser/parser.h (GET_PARSER): check if initialized.
|
||||||
[ruby-core:35079]
|
[ruby-core:35079]
|
||||||
|
@ -1613,7 +1613,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
|
|||||||
GET_PARSER_INIT;
|
GET_PARSER_INIT;
|
||||||
|
|
||||||
if (json->Vsource) {
|
if (json->Vsource) {
|
||||||
rb_raise(rb_eArgError, "already initialized instance");
|
rb_raise(rb_eTypeError, "already initialized instance");
|
||||||
}
|
}
|
||||||
rb_scan_args(argc, argv, "11", &source, &opts);
|
rb_scan_args(argc, argv, "11", &source, &opts);
|
||||||
source = convert_encoding(StringValue(source));
|
source = convert_encoding(StringValue(source));
|
||||||
|
@ -45,7 +45,7 @@ typedef struct JSON_ParserStruct {
|
|||||||
|
|
||||||
#define GET_PARSER \
|
#define GET_PARSER \
|
||||||
GET_PARSER_INIT; \
|
GET_PARSER_INIT; \
|
||||||
if (!json->Vsource) rb_raise(rb_eArgError, "uninitialized instance")
|
if (!json->Vsource) rb_raise(rb_eTypeError, "uninitialized instance")
|
||||||
#define GET_PARSER_INIT \
|
#define GET_PARSER_INIT \
|
||||||
JSON_Parser *json; \
|
JSON_Parser *json; \
|
||||||
Data_Get_Struct(self, JSON_Parser, json)
|
Data_Get_Struct(self, JSON_Parser, json)
|
||||||
|
@ -611,7 +611,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
|
|||||||
GET_PARSER_INIT;
|
GET_PARSER_INIT;
|
||||||
|
|
||||||
if (json->Vsource) {
|
if (json->Vsource) {
|
||||||
rb_raise(rb_eArgError, "already initialized instance");
|
rb_raise(rb_eTypeError, "already initialized instance");
|
||||||
}
|
}
|
||||||
rb_scan_args(argc, argv, "11", &source, &opts);
|
rb_scan_args(argc, argv, "11", &source, &opts);
|
||||||
source = convert_encoding(StringValue(source));
|
source = convert_encoding(StringValue(source));
|
||||||
|
@ -394,8 +394,8 @@ EOT
|
|||||||
|
|
||||||
def test_allocate
|
def test_allocate
|
||||||
json = JSON::Parser.new("{}")
|
json = JSON::Parser.new("{}")
|
||||||
assert_raises(ArgumentError, '[ruby-core:35079]') {json.__send__(:initialize, "{}")}
|
assert_raises(TypeError, '[ruby-core:35079]') {json.__send__(:initialize, "{}")}
|
||||||
json = JSON::Parser.allocate
|
json = JSON::Parser.allocate
|
||||||
assert_raises(ArgumentError, '[ruby-core:35079]') {json.source}
|
assert_raises(TypeError, '[ruby-core:35079]') {json.source}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user