Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remove encode_class and converter_class from mrb_state

  • Loading branch information...
commit affb5cb7c2e91ea38640ea0580af34a5f7cabf93 1 parent 4e40121
@matz matz authored
View
4 include/mruby.h
@@ -241,10 +241,6 @@ typedef struct mrb_state {
struct RClass *string_class;
struct RClass *array_class;
struct RClass *hash_class;
-#ifdef INCLUDE_ENCODING
- struct RClass *encode_class;
- struct RClass *converter_class;
-#endif
struct RClass *float_class;
struct RClass *fixnum_class;
View
12 src/encoding.c
@@ -103,7 +103,7 @@ static const struct mrb_data_type encoding_data_type = {
static mrb_value
enc_new(mrb_state *mrb, mrb_encoding *encoding)
{
- return mrb_obj_value(Data_Wrap_Struct(mrb, mrb->encode_class, &encoding_data_type, encoding));
+ return mrb_obj_value(Data_Wrap_Struct(mrb, ENCODE_CLASS, &encoding_data_type, encoding));
}
#define enc_autoload_p(enc) (!mrb_enc_mbmaxlen(enc))
@@ -1139,7 +1139,7 @@ mrb_usascii_encindex(void)
int
mrb_locale_encindex(mrb_state *mrb)
{
- mrb_value charmap = mrb_locale_charmap(mrb, mrb_obj_value(mrb->encode_class));
+ mrb_value charmap = mrb_locale_charmap(mrb, mrb_obj_value(ENCODE_CLASS));
int idx;
if (mrb_nil_p(charmap))
@@ -1493,7 +1493,7 @@ set_encoding_const(mrb_state *mrb, const char *name, mrb_encoding *enc)
if (s - name > ENCODING_NAMELEN_MAX) return;
valid = 1;
//mrb_define_const(mrb_cEncoding, name, encoding);
- mrb_define_const(mrb, mrb->encode_class, name, encoding);
+ mrb_define_const(mrb, ENCODE_CLASS, name, encoding);
}
if (!valid || haslower) {
size_t len = s - name;
@@ -1516,14 +1516,14 @@ set_encoding_const(mrb_state *mrb, const char *name, mrb_encoding *enc)
if (!ISALNUM(*s)) *s = '_';
}
if (hasupper) {
- mrb_define_const(mrb, mrb->encode_class, name, encoding);
+ mrb_define_const(mrb, ENCODE_CLASS, name, encoding);
}
}
if (haslower) {
for (s = (char *)name; *s; ++s) {
if (ISLOWER(*s)) *s = ONIGENC_ASCII_CODE_TO_UPPER_CASE((int)*s);
}
- mrb_define_const(mrb, mrb->encode_class, name, encoding);
+ mrb_define_const(mrb, ENCODE_CLASS, name, encoding);
}
}
}
@@ -1617,7 +1617,7 @@ mrb_init_encoding(mrb_state *mrb)
int i;
struct RClass *s;
- s = mrb->encode_class = mrb_define_class(mrb, "Encoding", mrb->object_class);
+ s = mrb_define_class(mrb, "Encoding", mrb->object_class);
//mrb_undef_alloc_func(mrb_cEncoding);
//mrb_undef_method(CLASS_OF(mrb_cEncoding), "new");
mrb_define_class_method(mrb, s, "aliases", mrb_enc_aliases, ARGS_NONE()); /* 15.2.40.2.1 */
View
3  src/encoding.h
@@ -348,6 +348,9 @@ void mrb_econv_binmode(mrb_econv_t *ec);
int mrb_isspace(int c);
+#define ENCODE_CLASS (mrb_class_obj_get(mrb, "Encoding"))
+#define CONVERTER_CLASS (mrb_class_obj_get(mrb, "Converter"))
+
#if defined(__cplusplus)
} /* extern "C" { */
#endif
View
5 src/transcode.c
@@ -4273,7 +4273,6 @@ extern void Init_newline(void);
void
mrb_init_transcode(mrb_state *mrb)
{
- struct RClass *e;
struct RClass *s;
struct RClass *c;
struct RClass *u;
@@ -4281,7 +4280,7 @@ mrb_init_transcode(mrb_state *mrb)
struct RClass *eConverterNotFoundError_class;
struct RClass *eInvalidByteSequenceError_class;
struct RClass *eUndefinedConversionError_class;
- e = mrb->encode_class;
+
eUndefinedConversionError_class = mrb_define_class(mrb, "UndefinedConversionError", E_ENCODING_ERROR);
eInvalidByteSequenceError_class = mrb_define_class(mrb, "InvalidByteSequenceError", E_ENCODING_ERROR);
eConverterNotFoundError_class = mrb_define_class(mrb, "ConverterNotFoundError", E_ENCODING_ERROR);
@@ -4312,7 +4311,7 @@ mrb_init_transcode(mrb_state *mrb)
mrb_define_method(mrb, s, "encode", str_encode, ARGS_ANY());
mrb_define_method(mrb, s, "encode!", str_encode_bang, ARGS_ANY());
- c = mrb->converter_class = mrb_define_class(mrb, "Converter", mrb->encode_class);
+ c = mrb_define_class(mrb, "Converter", ENCODE_CLASS);
//mrb_cEncodingConverter = rb_define_class_under(mrb_cEncoding, "Converter", rb_cData);
//mrb_define_alloc_func(mrb_cEncodingConverter, econv_s_allocate);
mrb_define_class_method(mrb, c, "asciicompat_encoding", econv_s_asciicompat_encoding, ARGS_REQ(1)); /* 1 */
Please sign in to comment.
Something went wrong with that request. Please try again.