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

Version Path
rucy-0.1.28 .doc/ext/rucy/struct.cpp
rucy-0.1.27 .doc/ext/rucy/struct.cpp
rucy-0.1.26 .doc/ext/rucy/struct.cpp
rucy-0.1.25 .doc/ext/rucy/struct.cpp
rucy-0.1.24 .doc/ext/rucy/struct.cpp
rucy-0.1.23 .doc/ext/rucy/struct.cpp
rucy-0.1.22 .doc/ext/rucy/struct.cpp
rucy-0.1.21 .doc/ext/rucy/struct.cpp
rucy-0.1.20 .doc/ext/rucy/struct.cpp
rucy-0.1.18 .doc/ext/rucy/struct.cpp
rucy-0.1.16 .doc/ext/rucy/struct.cpp
rucy-0.1.15 .doc/ext/rucy/struct.cpp
rucy-0.1.14 .doc/ext/rucy/struct.cpp
rucy-0.1.13 .doc/ext/rucy/struct.cpp
rucy-0.1.12 .doc/ext/rucy/struct.cpp
rucy-0.1.11 .doc/ext/rucy/struct.cpp
rucy-0.1.10 .doc/ext/rucy/struct.cpp
rucy-0.1.9 .doc/ext/rucy/struct.cpp
rucy-0.1.8 .doc/ext/rucy/struct.cpp