summaryrefslogtreecommitdiff
path: root/include/ruby/backward
diff options
context:
space:
mode:
author卜部昌平 <[email protected]>2020-01-31 12:01:39 +0900
committer卜部昌平 <[email protected]>2020-01-31 13:01:52 +0900
commitcdd75d4e7f0402a0537c516b7331a036347b0fa9 ()
tree84e64cd8924489dc07fcc33cfd9b8e471e6bb666 /include/ruby/backward
parent4942adf68cd2d8ab0a3ca64a787bdf55e119b337 (diff)
support C++ std::nullptr_t
C++ keyword `nullptr` represents a null pointer (note also that NULL is an integer in C++ due to its design flaw). Its type is `std::nullptr_t`, defined in <cstddef> standard header. Why not support it when the backend implementation can take a null pointer as an argument.
-rw-r--r--include/ruby/backward/cxxanyargs.hpp166
1 files changed, 165 insertions, 1 deletions
@@ -13,6 +13,10 @@
extern "C++" {
/// @brief The main namespace.
/// @note The name "ruby" might already be taken, but that must not be a
/// problem because namespaces are allowed to reopen.
@@ -46,6 +50,9 @@ typedef void void_type(ANYARGS);
/// @brief ANYARGS-ed function type, int variant.
typedef int int_type(ANYARGS);
/// @name Hooking global variables
/// @{
@@ -95,6 +102,58 @@ rb_define_virtual_variable(const char *q, type *w, rb_gvar_setter_t *e)
::rb_define_virtual_variable(q, r, e);
}
RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
/// @brief Define a function-backended global variable.
/// @param[in] q Name of the variable.
@@ -144,6 +203,62 @@ rb_define_hooked_variable(const char *q, VALUE *w, type *e, rb_gvar_setter_t *r)
::rb_define_hooked_variable(q, w, t, r);
}
/// @}
/// @name Exceptions and tag jumps
/// @{
@@ -159,12 +274,28 @@ RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
/// @deprecated This function is obsolated since long before 2.x era. Do not
/// use it any longer. rb_block_call() is provided instead.
inline VALUE
-rb_iterate(VALUE(*q)(VALUE), VALUE w, type *e, VALUE r)
{
rb_block_call_func_t t = reinterpret_cast<rb_block_call_func_t>(e);
return ::rb_iterate(q, w, t, r);
}
RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
/// @brief Call a method with a block.
/// @param[in] q The self.
@@ -183,6 +314,22 @@ rb_block_call(VALUE q, ID w, int e, const VALUE *r, type *t, VALUE y)
return ::rb_block_call(q, w, e, r, u, y);
}
RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
/// @brief An equivalent of `rescue` clause.
/// @param[in] q A function that can raise.
@@ -274,6 +421,23 @@ rb_catch(const char *q, type *w, VALUE e)
return ::rb_catch(q, r, e);
}
RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
/// @brief An equivalent of `Kernel#catch`.
/// @param[in] q The "tag" object.