Sha256: 79f805ac885661387834940abdf8b55bca03689a3aec191fa77d989f978318b9

Contents?: true

Size: 721 Bytes

Versions: 4

Compression:

Stored size: 721 Bytes

Contents

// -*- c++ -*-
#include "rucy/gc.h"


namespace Rucy
{


	static void
	register_value (VALUE* v)
	{
		if (!v) return;
		rb_gc_register_address(v);
	}

	static void
	unregister_value (VALUE* v)
	{
		if (!v) return;
		rb_gc_unregister_address(v);
	}

	GCGuard::GCGuard (VALUE* v)
	:	pval(v)
	{
		register_value(pval);
	}

	GCGuard::GCGuard (Value* v)
	:	pval(v ? &v->v : NULL)
	{
		register_value(pval);
	}

	GCGuard::~GCGuard ()
	{
		unregister_value(pval);
	}


	GlobalValue::GlobalValue (Value v)
	:	val(v), guard(&val)
	{
	}

	Value
	GlobalValue::value () const
	{
		return val;
	}

	GlobalValue::operator VALUE () const
	{
		return value();
	}

	GlobalValue::operator Value () const
	{
		return value();
	}


}// Rucy

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rucy-0.1.3 src/gc.cpp
rucy-0.1.2 src/gc.cpp
rucy-0.1.1 src/gc.cpp
rucy-0.1.0 src/gc.cpp