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

ruby_type.hpp

00001 #ifndef Exc_Ruby__ruby_value__hpp_
00002 #define Exc_Ruby__ruby_value__hpp_
00003 
00004 #include "ruby_reference.hpp"
00005 #include "value_holder.hpp"
00006 #include <ruby.h>
00007 #undef TYPE
00008 
00009 namespace Exc_Ruby
00010 {
00011 
00012 struct Ruby_Type_Wrapper
00013 {
00014   typedef void (*Ruby_Data_Func)(RClass * obj);
00015 
00018   static VALUE wrap(
00019       VALUE klass,
00020       Ruby_Data_Func mark,
00021       Ruby_Data_Func free,
00022       RClass * obj);
00023 
00027   static RClass * unwrap(VALUE value);
00028 
00029 private:
00030   Ruby_Type_Wrapper();
00031 };
00032 
00033 class Module;
00034 
00035 // ---------------------------------------------------------------------
00038 template<typename T>
00039 class Ruby_Type
00040   : public Ruby_Reference<RClass, Ruby_Type_Wrapper>
00041 {
00042 public:
00045   Ruby_Type();
00046  
00048   explicit Ruby_Type(VALUE type);
00049  
00051   // explicit Ruby_Type(Module & module);
00052 
00056   operator VALUE() const { return value_; }
00057 
00061   operator Value_Holder() const { return value_; }
00062 
00064   VALUE type() const { return value_; }
00065 
00067   bool is_bound() const { return is_bound_; }
00068 
00072   virtual Ruby_Type & bind(VALUE type);
00073 
00075   virtual Ruby_Type & operator=(VALUE type);
00076 
00077   typedef T CPP_Type;
00078 
00079 private:
00080   bool is_bound_;
00081 };
00082 
00083 } // namespace Exc_Ruby
00084 
00085 #include "ruby_type.ipp"
00086 
00087 #endif // Exc_Ruby__ruby_value__hpp_
00088 

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