本人自行删除

lanjingyu · November 23, 2015 · Last by luikore replied at November 24, 2015 · 7253 hits

本人自行删除

你还得写属性 wrapper method

static VALUE get_connected(VALUE self) {
  struct rb_connect_information* info;
  Data_Get_Struct(self, struct rb_connect_information, info);
  return INT2NUM(info->connected);
}

static VALUE get_servername(VALUE self) {
  struct rb_connect_information* info;
  Data_Get_Struct(self, struct rb_connect_information, info);
  return info->servername;
}

然后声明方法才能在 ruby 中调用

rb_define_method(rb_cConnectInfo, "connected", get_connected, 0);
rb_define_method(rb_cConnectInfo, "servername", get_servername, 0);

文档看一遍 http://www.rubydoc.info/stdlib/core/file/README.EXT

另外一个包装的方法是用 FFI, 不用写那么多 wrapper...

2 Floor has deleted
You need to Sign in before reply, if you don't have an account, please Sign up first.