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

ruby_module.hpp

00001 #ifndef Exc_Ruby__builtin__ruby_module__hpp_
00002 #define Exc_Ruby__builtin__ruby_module__hpp_
00003 
00004 #include "../detail/Auto_Function_Wrapper.hpp"
00005 #include "../detail/Auto_Member_Function_Wrapper.hpp"
00006 #include "../detail/define_method_and_auto_wrap.hpp"
00007 #include "../detail/Iterator_Definer.hpp"
00008 #include <memory>
00009 
00010 namespace Exc_Ruby
00011 {
00012 
00013 class Module
00014   : public detail::Iterator_Definer<Module>
00015 {
00016 public:
00017   explicit Module(VALUE v);
00018 
00019   // add an exception handler to be used with every method in this
00020   // class defined hereafter
00021   template<typename Exception_T, typename Functor_T>
00022   Module & add_handler(
00023       Functor_T functor);
00024 
00025   // define an instance method called name and implemented by function
00026   // func
00027   template<typename Func_T>
00028   Module & define_method(
00029       char const * name,
00030       Func_T func);
00031 
00032   // define an singleton method called name and implemented by function
00033   // func
00034   template<typename Func_T>
00035   Module & define_singleton_method(
00036       char const * name,
00037       Func_T func);
00038 
00039   // define a module function called name and implemented by function
00040   // func
00041   template<typename Func_T>
00042   Module & define_module_function(
00043       char const * name,
00044       Func_T func);
00045 
00046   // Allows this object to be assigned to a VALUE or a Ruby_Type
00047   operator VALUE()
00048   {
00049     return v_;
00050   }
00051 
00052 protected:
00053   VALUE v_;
00054 
00055   // TODO: For now, we always leak the handler, but in the future, we
00056   // should register it with the garbage collector.
00057   detail::Exception_Handler const * handler_;
00058 };
00059 
00060 Module define_module_under(
00061     Value_Holder module,
00062     char const * name);
00063 
00064 Module define_module(
00065     char const * name);
00066 
00067 } // namespace Exc_Ruby
00068 
00069 #include "ruby_module.ipp"
00070 
00071 #endif // Exc_Ruby__builtin__ruby_module__hpp_
00072 

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