Sha256: 8862fdb5439a8608bde70096f0cf9d4e8460f8850c73af9daca6550c546f909f

Contents?: true

Size: 1.5 KB

Versions: 10

Compression:

Stored size: 1.5 KB

Contents

#ifndef Rice__Builtin_Object_defn__hpp_
#define Rice__Builtin_Object_defn__hpp_

#include "Object_defn.hpp"
#include "detail/ruby.hpp"

namespace Rice
{

//! A smartpointer-like wrapper for Ruby builtin objects.
/*! A builtin object is one of Ruby's internal types, e.g. RArray or
 *  RString.  Every builtin type structure has a corresponding integer
 *  type number (e.g T_ARRAY for RArray or T_STRING for RString).  This
 *  class is a wrapper for those types of objects, primarily useful as a
 *  base class for other wrapper classes like Array and Hash.
 */
template<int Builtin_Type>
class Builtin_Object
  : public Object
{
public:
  //! Wrap an already allocated Ruby object.
  /*! Checks to see if the object is an object of type Builtin_Type; a
   *  C++ exception is thrown if this is not the case.
   *  \param value the object to be wrapped.
   */
  Builtin_Object(Object value);

  //! Make a copy of a Builtin_Object
  /*! \param other the Builtin_Object to be copied.
   */
  Builtin_Object(Builtin_Object const & other);

  RObject & operator*() const { return *obj_; } //!< Return a reference to obj_
  RObject * operator->() const { return obj_; } //!< Return a pointer to obj_
  RObject * get() const { return obj_; }        //!< Return a pointer to obj_

  //! Swap with another builtin object of the same type
  /*! \param ref the object with which to swap.
   */
  void swap(Builtin_Object<Builtin_Type> & ref);

private:
  RObject * obj_;
};

} // namespace Rice

#endif // Rice__Builtin_Object_defn__hpp_

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
rice-3.0.0 rice/Builtin_Object_defn.hpp
rice2-2.2.1 rice/Builtin_Object_defn.hpp
rice2-2.2.0 rice/Builtin_Object_defn.hpp
rice-2.2.0 rice/Builtin_Object_defn.hpp
rice-2.1.3 rice/Builtin_Object_defn.hpp
rice-2.1.2 rice/Builtin_Object_defn.hpp
rice-2.1.1 rice/Builtin_Object_defn.hpp
rice-2.1.0 rice/Builtin_Object_defn.hpp
rice-2.0.0 rice/Builtin_Object_defn.hpp
rice-1.7.0 rice/Builtin_Object_defn.hpp