Sha256: 422d1df5ebdb5267439a17222bcecb2e9993edd6a33d8819dc68f80fb67bd623

Contents?: true

Size: 1.98 KB

Versions: 36

Compression:

Stored size: 1.98 KB

Contents

#ifndef Rice__Module_defn__hpp_
#define Rice__Module_defn__hpp_

#include "Object_defn.hpp"
#include "Module_impl.hpp"
#include "to_from_ruby_defn.hpp"
#include <memory>

namespace Rice
{

class Array;
class Class;
class String;

//! A helper for defining a Module and its methods.
/*! This class provides a C++-style interface to ruby's Module class and
 *  for defining methods on that module.
 *
 *  Many of the methods are defined in Module_impl.hpp so that they can
 *  return a reference to the most derived type.
 */
class Module
  // TODO: we can't inherit from Builtin_Object, because Class needs
  // type T_CLASS and Module needs type T_MODULE
  : public Module_impl<Module_base, Module>
{
public:
  //! Default construct a Module and initialize it to rb_cObject.
  Module();

  //! Construct a Module from an existing Module object.
  Module(VALUE v);

  //! Return the name of the module.
  String name() const;

  //! Swap with another Module.
  void swap(Module & other);

  //! Return an array containing the Module's ancestors.
  /*! You will need to include Array.hpp to use this function.
   */
  Array ancestors() const;

  //! Return the module's singleton class.
  /*! You will need to include Class.hpp to use this function.
   */
  Class singleton_class() const;
};

//! Define a new module in the namespace given by module.
/*! \param module the module in which to define the new module.
 *  \param name the name of the new module.
 */
Module define_module_under(
    Object module,
    char const * name);

//! Define a new module in the default namespace.
/*! \param name the name of the new module.
 */
Module define_module(
    char const * name);

//! Create a new anonymous module.
/*! \return the new module.
 */
Module anonymous_module();

} // namespace Rice

template<>
inline
Rice::Module from_ruby<Rice::Module>(Rice::Object x)
{
  return Rice::Module(x);
}

template<>
inline
Rice::Object to_ruby<Rice::Module>(Rice::Module const & x)
{
  return x;
}

#endif // Rice__Module_defn__hpp_

Version data entries

36 entries across 36 versions & 6 rubygems

Version Path
rice-3.0.0 rice/Module_defn.hpp
rice2-2.2.1 rice/Module_defn.hpp
rice2-2.2.0 rice/Module_defn.hpp
rice-2.2.0 rice/Module_defn.hpp
rice-2.1.3 rice/Module_defn.hpp
rice-2.1.2 rice/Module_defn.hpp
rice-2.1.1 rice/Module_defn.hpp
rice-2.1.0 rice/Module_defn.hpp
rice-2.0.0 rice/Module_defn.hpp
rice-1.7.0 rice/Module_defn.hpp
rice-1.6.3 rice/Module_defn.hpp
jameskilton-rice-1.2.0 rice/Module_defn.hpp
rice-1.6.2 rice/Module_defn.hpp
rice-1.6.1 rice/Module_defn.hpp
rice-1.6.0 rice/Module_defn.hpp
rice-1.6.0.pre rice/Module_defn.hpp
rice-1.5.3 rice/Module_defn.hpp
rice-1.5.2 rice/Module_defn.hpp
keyme-rice-1.5.1.keyme1 rice/Module_defn.hpp
keyme-rice-1.5.1.keyme rice/Module_defn.hpp