Go to the documentation of this file.00001 #ifdef RUBY_IS_19
00002 #include "ruby_internals-1.9.h"
00003 #else
00004 #include "ruby_internals-1.8.h"
00005 #endif
00006
00007
00008
00009
00010
00011
00012
00013
00014 static VALUE kernel_swap_bang(VALUE self, VALUE obj1, VALUE obj2)
00015 {
00016
00017 RVALUE old_obj;
00018 memcpy(&old_obj, reinterpret_cast<void*>(obj1), SLOT_SIZE);
00019
00020 memcpy(reinterpret_cast<void*>(obj1), reinterpret_cast<void*>(obj2), SLOT_SIZE);
00021
00022 memcpy(reinterpret_cast<void*>(obj2), &old_obj, SLOT_SIZE);
00023
00024 return Qnil;
00025 }
00026
00027 extern "C" void Init_swap()
00028 {
00029 rb_define_singleton_method(rb_mKernel, "swap!", RUBY_METHOD_FUNC(kernel_swap_bang), 2);
00030 }
00031