Sha256: d936a30bc64c4a1e14f120edf053dd3fe76cb3020334f75fb0cddb7004d9a6e0
Contents?: true
Size: 972 Bytes
Versions: 19
Compression:
Stored size: 972 Bytes
Contents
#include "rucy.h" using namespace Rucy; struct Struct { int num; Struct () : num(0) {} };// Struct static Class cStruct; namespace Rucy { template <> inline Class get_ruby_class<Struct> () {return cStruct;} }// Rucy RUCY_VALUE_FROM_TO(Struct) /* alloc function. */ static VALUE alloc(VALUE klass) { return new_type<Struct>(klass); } /* get num. */ static VALUE get_num(VALUE self) { Struct* obj = to<Struct*>(self); if (obj) return value(obj->num); } /* set num. */ static VALUE set_num(VALUE self, VALUE num) { Struct* obj = to<Struct*>(self); if (obj) obj->num = to<int>(num); } void Init_struct () { Module mRucy = rb_define_module("Rucy"); Module mTester = rb_define_module_under(mRucy, "Tester"); cStruct = rb_define_class_under(mTester, "Struct", rb_cObject); rb_define_alloc_func(cStruct, alloc); rb_define_method(cStruct, "num", RUBY_METHOD_FUNC(get_num), 0); rb_define_method(cStruct, "num=", RUBY_METHOD_FUNC(set_num), 1); }
Version data entries
19 entries across 19 versions & 1 rubygems