Sha256: 82995e55f9ec6cbaf6b8d04cf7021e38971c7d47cdefa12d0513a4a8e70d7a1b
Contents?: true
Size: 972 Bytes
Versions: 18
Compression:
Stored size: 972 Bytes
Contents
#include "defs.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
18 entries across 18 versions & 1 rubygems