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

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