Sha256: 4237a27130f1e333720974e3e7016a5b8a3962c031134f94b7c952c575b7e6ef

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

// -*- c++ -*-
#pragma once
#ifndef __RUCY_H__
#define __RUCY_H__


#include <ruby.h>
#include <rucy/value.h>


namespace Rucy
{


	bool init ();


	Value require (const char* name);

	void define_const (const char* name, Value val);


	bool check_class (Value obj, Value class_);


	template <typename T> inline void mark_type (void* p)
	{
		((T*) p)->mark();
	}

	template <typename T> inline void delete_type (void* p)
	{
		delete (T*) p;
	}

	template <typename T> inline Value new_type (
		Value klass, T* ptr,
		RUBY_DATA_FUNC mark = NULL,
		RUBY_DATA_FUNC free = delete_type<T>)
	{
		return Data_Wrap_Struct(klass, mark, free, ptr);
	}

	template <typename T> inline Value new_type (
		Value klass,
		RUBY_DATA_FUNC mark = NULL,
		RUBY_DATA_FUNC free = delete_type<T>)
	{
		return new_type(klass, new T, mark, free);
	}

	template <typename T> inline T* get_type (Value obj, Value klass = Qnil)
	{
		if (klass && !check_class(obj, klass)) return NULL;
		T* p = NULL;
		Data_Get_Struct(obj.value(), T, p);
		return p;
	}


}// Rucy


#endif//EOH

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rucy-0.1.2 include/rucy/rucy.h
rucy-0.1.1 include/rucy/rucy.h
rucy-0.1.0 include/rucy/rucy.h