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

Version Path
rucy-0.2.1 .doc/ext/rucy/struct.cpp
rucy-0.2 .doc/ext/rucy/struct.cpp
rucy-0.1.44 .doc/ext/rucy/struct.cpp
rucy-0.1.43 .doc/ext/rucy/struct.cpp
rucy-0.1.42 .doc/ext/rucy/struct.cpp
rucy-0.1.41 .doc/ext/rucy/struct.cpp
rucy-0.1.40 .doc/ext/rucy/struct.cpp
rucy-0.1.39 .doc/ext/rucy/struct.cpp
rucy-0.1.38 .doc/ext/rucy/struct.cpp
rucy-0.1.37 .doc/ext/rucy/struct.cpp
rucy-0.1.36 .doc/ext/rucy/struct.cpp
rucy-0.1.35 .doc/ext/rucy/struct.cpp
rucy-0.1.34 .doc/ext/rucy/struct.cpp
rucy-0.1.33 .doc/ext/rucy/struct.cpp
rucy-0.1.32 .doc/ext/rucy/struct.cpp
rucy-0.1.31 .doc/ext/rucy/struct.cpp
rucy-0.1.30 .doc/ext/rucy/struct.cpp
rucy-0.1.29 .doc/ext/rucy/struct.cpp