Sha256: 2ec7ddcf57deaa2ae018136c7cc63b02c76e21b78da6af5a67255e104e7a9e4e

Contents?: true

Size: 1.17 KB

Versions: 19

Compression:

Stored size: 1.17 KB

Contents

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


#include <xot/string.h>
#include "rucy/symbol.h"
#include "rucy/extension.h"


#define RUCY_END RUCY_DEF_END


namespace Rucy
{


	Class::Class (RubyValue v)
	:	Super(v)
	{
	}

	void
	Class::define_alloc_func (RubyFunction0 fun)
	{
		rb_define_alloc_func(value(), (RubyValue(*)(RubyValue)) fun);
	}

	void
	Class::define_alloc_func (const char*, RubyFunction0 fun)
	{
		define_alloc_func(fun);
	}

	template <bool singleton>
	static
	RUCY_DEF1(method_added_or_removed, method_name)
	{
		RUCY_SYMBOL(klass, "class");
		RUCY_SYM(name);
		Xot::String code =
			Xot::stringf(
				"ObjectSpace.each_object(%s) {|o| o.clear_override_flags}",
				(singleton ? self(klass) : self)(name).c_str());
		eval(code);
	}
	RUCY_END

	void
	Class::define_clear_override_flags (RubyFunction0 fun)
	{
		define_method("clear_override_flags",     fun);
		define_method("singleton_method_added",   method_added_or_removed<true>);
		define_method("singleton_method_removed", method_added_or_removed<true>);
		define_singleton_method("method_added",   method_added_or_removed<false>);
		define_singleton_method("method_removed", method_added_or_removed<false>);
	}


}// Rucy

Version data entries

19 entries across 19 versions & 1 rubygems

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