Sha256: 5cf36dab034609eb224f13415db73f6dc51f72364c45bea6e1a6eb26e676fb86
Contents?: true
Size: 902 Bytes
Versions: 19
Compression:
Stored size: 902 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 RUCY_DEF_ALLOC(alloc, klass) { return new_type<Struct>(klass); } RUCY_END /* get num. */ static RUCY_DEF0(get_num) { Struct* obj = to<Struct*>(self); if (obj) return value(obj->num); } RUCY_END /* set num. */ static RUCY_DEF1(set_num, num) { Struct* obj = to<Struct*>(self); if (obj) obj->num = to<int>(num); } RUCY_END void Init_struct () { Module mRucy = define_module("Rucy"); Module mTester = mRucy.define_module("Tester"); cStruct = mTester.define_class("Struct"); cStruct.define_alloc_func(alloc); cStruct.define_method("num", get_num); cStruct.define_method("num=", set_num); }
Version data entries
19 entries across 19 versions & 1 rubygems