Sha256: a4554eb1ec0e9081f19544cd8e44bac098bb06cb9a7fb46c04f4275fb73026c6

Contents?: true

Size: 1012 Bytes

Versions: 7

Compression:

Stored size: 1012 Bytes

Contents

#ifndef Rice__detail__ruby_function__hpp_
#define Rice__detail__ruby_function__hpp_

#include "ruby.hpp"

namespace Rice::detail
{
  /* This is functor class that wraps calls to a Ruby C API method. It is needed because
     rb_protect only supports calling methods that take one argument. Thus 
     we invoke rb_protect telling it to invoke Ruby_Function::call with an 
     instance of a Ruby_Function. That instance then in turn calls the original
     Ruby method passing along its required arguments. */

  template<typename Function_T, typename...Arg_Ts>
  class RubyFunction
  {
  public:
    using Return_T = typename function_traits<Function_T>::return_type;

  public:
    RubyFunction(Function_T func, const Arg_Ts&... args);
    Return_T operator()();

  private:
    Function_T func_;
    std::tuple<Arg_Ts...> args_;
  };

  template<typename Function_T, typename ...Arg_Ts>
  auto protect(Function_T func, Arg_Ts...args);
}
#include "RubyFunction.ipp"

#endif // Rice__detail__ruby_function__hpp_

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rice-4.3.3 rice/detail/RubyFunction.hpp
rice-4.3.2 rice/detail/RubyFunction.hpp
rice-4.3.1 rice/detail/RubyFunction.hpp
rice-4.3.0 rice/detail/RubyFunction.hpp
rice-4.2.1 rice/detail/RubyFunction.hpp
rice-4.2.0 rice/detail/RubyFunction.hpp
rice-4.1.0 rice/detail/RubyFunction.hpp