Fix to use mrb_data_check_get_ptr instead of DATA_PTR and set channel as MRB_TT_DATA
#include <mruby/error.h>
#include <mruby/hash.h>
#include <mruby/string.h>
+#include <mruby/class.h>
#include "h2o/mruby_.h"
#include "embedded.c.h"
@@ -90,7 +91,7 @@ static mrb_value channel_initialize_method(mrb_state *mrb, mrb_value self)
static mrb_value channel_notify_method(mrb_state *mrb, mrb_value self)
{
struct st_h2o_mruby_channel_context_t *ctx;
- ctx = DATA_PTR(self);
+ ctx = mrb_data_check_get_ptr(mrb, self, &channel_type);
if (!mrb_nil_p(ctx->receiver)) {
h2o_mruby_run_fiber(ctx->ctx, detach_receiver(ctx), mrb_nil_value(), NULL);
@@ -109,7 +110,7 @@ mrb_value h2o_mruby_channel_shift_callback(h2o_mruby_context_t *mctx, mrb_value
struct st_h2o_mruby_channel_context_t *ctx;
- if ((ctx = DATA_PTR(mrb_ary_entry(args, 0))) == NULL)
+ if ((ctx = mrb_data_check_get_ptr(mrb, mrb_ary_entry(args, 0), &channel_type)) == NULL)
return mrb_exc_new_str_lit(mrb, E_ARGUMENT_ERROR, "Channel#shift wrong self");
attach_receiver(ctx, receiver);
@@ -128,6 +129,7 @@ void h2o_mruby_channel_init_context(h2o_mruby_shared_context_t *shared_ctx)
module = mrb_define_module(mrb, "H2O");
klass = mrb_class_get_under(mrb, module, "Channel");
+ MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA);
mrb_ary_set(mrb, shared_ctx->constants, H2O_MRUBY_CHANNEL_CLASS, mrb_obj_value(klass));
mrb_define_method(mrb, klass, "initialize", channel_initialize_method, MRB_ARGS_NONE());
mrb_define_method(mrb, klass, "_notify", channel_notify_method, MRB_ARGS_NONE());
