diff --git a/include/rice.hpp b/include/rice.hpp new file mode 100644 index 00000000..0925fde8 --- /dev/null +++ b/include/rice.hpp @@ -0,0 +1,6940 @@ + +// ========= ruby_version_code.hpp ========= + +#define RICE__RUBY_VERSION_CODE 272 + + +// ========= ruby.hpp ========= + +/*! \file + * \brief Hacks for addressing incompatibilities between various Ruby + * versions. + */ + +#include + +// missing.h that comes with the one-click installer doesn't properly +// check for double-definition of isinf +#ifdef isinf +#define HAVE_ISINF +#endif + + +#include + +//! A function that takes a VALUE as a parameter and returns a VALUE. +// TODO: Casting from a C++ function to an extern "C" function won't +// work on all platforms. I'm not sure what to do about this. +extern "C" typedef VALUE (*RUBY_VALUE_FUNC)(VALUE); + +// Fix Ruby RUBY_METHOD_FUNC from macro to typedef +#if defined(RUBY_METHOD_FUNC) +# undef RUBY_METHOD_FUNC + extern "C" typedef VALUE (*RUBY_METHOD_FUNC)(ANYARGS); +#endif + +#ifndef RSTRING_LEN +#define RSTRING_LEN(str) RSTRING(str)->len +#endif + +#ifndef RSTRING_PTR +#define RSTRING_PTR(str) RSTRING(str)->ptr +#endif + +#ifndef RARRAY_LEN +#define RARRAY_LEN(arr) RARRAY(arr)->len +#endif + +#ifndef RARRAY_PTR +#define RARRAY_PTR(arr) RARRAY(arr)->ptr +#endif + +#ifndef RHASH_TBL +#define RHASH_TBL(hsh) RHASH(hsh)->tbl +#endif + +#ifndef RCLASS_M_TBL +#define RCLASS_M_TBL(c) RCLASS(c)->m_tbl +#endif + +// ruby.h has a few defines that conflict with Visual Studio's STL +#if defined(_MSC_VER) + #undef write + #undef read + #undef bind +#endif + +// And some c library conflicts +#if defined(_MSC_VER) +#undef snprintf +#undef vsnprintf +#endif + +#define std_unique_ptr std::unique_ptr + + + +// ========= rice_traits.hpp ========= + +#include +#include + +namespace Rice +{ + namespace detail + { + // Get the base_type of T - without pointer, reference, const or volatile + template + using base_type = typename std::remove_cv_t>>; + + // Helper to determine if we have to keep a local copy of a value converted from Ruby. + // This is needed for primitive types (numeric, char, bool and we include strings) + template + struct is_primitive : public std::false_type {}; + + template + struct is_primitive> || + std::is_same_v>>> : public std::true_type {}; + + template + constexpr bool is_primitive_v = is_primitive::value; + + // Helper to find out if a template has been specialized for provided type + template class, typename, typename = void> + struct is_specialized : std::false_type {}; + + template class Template, typename T> + struct is_specialized{})>> : std::true_type {}; + + /*template class Template> + struct is_specialization : std::false_type {}; + + template