Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

ruby_hacks.hpp

Go to the documentation of this file.
00001 #ifndef Exc_Ruby__ruby_hacks__hpp_
00002 #define Exc_Ruby__ruby_hacks__hpp_
00003 
00009 // TODO: Is there a way to ensure that this is Ruby's version.h?
00010 #include <version.h>
00011 #include <ruby.h>
00012 
00013 // This causes problems with certain C++ libraries
00014 #undef TYPE
00015 
00017 // TODO: Casting from a C++ function to an extern "C" function won't
00018 // work on all platforms.  I'm not sure what to do about this.
00019 extern "C" typedef VALUE (*RUBY_VALUE_FUNC)(VALUE);
00020 
00021 // Fix Ruby RUBY_METHOD_FUNC from macro to typedef
00022 // TODO: Casting from a C++ function to an extern "C" function won't
00023 // result in correct behavior on all platforms.  I'm not sure what to do
00024 // about this.
00025 #if defined(RUBY_METHOD_FUNC)
00026 # undef RUBY_METHOD_FUNC
00027 # if RUBY_VERSION_CODE <= 166
00028     extern "C" typedef VALUE (*RUBY_METHOD_FUNC)();
00029 # else
00030     extern "C" typedef VALUE (*RUBY_METHOD_FUNC)(ANYARGS);
00031 # endif
00032 #endif
00033 
00034 // Some functions have the wrong prototype on Ruby 1.6
00035 #if RUBY_VERSION_CODE < 170
00036   namespace Exc_Ruby
00037   {
00038     extern "C" typedef VALUE
00039       (*Rb_Protect_Signature)(RUBY_VALUE_FUNC, VALUE, int *);
00040     extern "C" typedef void
00041       (*Rb_Gc_Mark_Signature)(VALUE);
00042     extern "C" typedef void
00043       (*Rb_Set_End_Proc_Signature)(void (*)(VALUE), VALUE);
00044   }
00046 # define rb_protect(f, arg, state) \
00047      ((::Exc_Ruby::Rb_Protect_Signature)(rb_protect))(f, arg, state)
00048 
00049 # define rb_gc_mark(value) \
00050     ((::Exc_Ruby::Rb_Gc_Mark_Signature)(rb_gc_mark))(value)
00051 
00052 # define rb_set_end_proc(f,v) \
00053     ((::Exc_Ruby::Rb_Set_End_Proc_Signature)(rb_set_end_proc))(f, v)
00054 #endif
00055 
00056 #endif // Exc_Ruby__ruby_hacks__hpp_
00057 

Generated on Sat Jan 1 12:02:19 2005 for Exceptional Ruby by doxygen 1.3.6