From 17a13663998a98ff75fcc838d1cea95c879fbb88 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 18 Sep 2019 22:52:41 +0900 Subject: Overload variable definition functions Define overloading functions of rb_define_virtual_variable and rb_define_hooked_variable, for combinations with and without ANYARGS casts. --- include/ruby/backward/cxxanyargs.hpp | 62 ++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/include/ruby/backward/cxxanyargs.hpp b/include/ruby/backward/cxxanyargs.hpp index 604d50bd4d..55b841b24e 100644 --- a/include/ruby/backward/cxxanyargs.hpp +++ b/include/ruby/backward/cxxanyargs.hpp @@ -63,6 +63,36 @@ rb_define_virtual_variable(const char *q, type *w, void_type *e) ::rb_define_virtual_variable(q, r, t); } +RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprected") +/// @brief Define a function-backended global variable. +/// @param[in] q Name of the variable. +/// @param[in] w Getter function. +/// @param[in] e Setter function. +/// @note Both functions can be nullptr. +/// @see rb_define_hooked_variable() +/// @deprecated Use glanular typed overload instead. +inline void +rb_define_virtual_variable(const char *q, rb_gvar_getter_t *w, void_type *e) +{ + rb_gvar_setter_t *t = reinterpret_cast(e); + ::rb_define_virtual_variable(q, w, t); +} + +RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprected") +/// @brief Define a function-backended global variable. +/// @param[in] q Name of the variable. +/// @param[in] w Getter function. +/// @param[in] e Setter function. +/// @note Both functions can be nullptr. +/// @see rb_define_hooked_variable() +/// @deprecated Use glanular typed overload instead. +inline void +rb_define_virtual_variable(const char *q, type *w, rb_gvar_setter_t *e) +{ + rb_gvar_getter_t *r = reinterpret_cast(w); + ::rb_define_virtual_variable(q, r, e); +} + RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprected") /// @brief Define a function-backended global variable. /// @param[in] q Name of the variable. @@ -80,6 +110,38 @@ rb_define_hooked_variable(const char *q, VALUE *w, type *e, void_type *r) ::rb_define_hooked_variable(q, w, t, y); } +RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprected") +/// @brief Define a function-backended global variable. +/// @param[in] q Name of the variable. +/// @param[in] w Variable storage. +/// @param[in] e Getter function. +/// @param[in] r Setter function. +/// @note Both functions can be nullptr. +/// @see rb_define_virtual_variable() +/// @deprecated Use glanular typed overload instead. +inline void +rb_define_hooked_variable(const char *q, VALUE *w, rb_gvar_getter_t *e, void_type *r) +{ + rb_gvar_setter_t *y = reinterpret_cast(r); + ::rb_define_hooked_variable(q, w, e, y); +} + +RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprected") +/// @brief Define a function-backended global variable. +/// @param[in] q Name of the variable. +/// @param[in] w Variable storage. +/// @param[in] e Getter function. +/// @param[in] r Setter function. +/// @note Both functions can be nullptr. +/// @see rb_define_virtual_variable() +/// @deprecated Use glanular typed overload instead. +inline void +rb_define_hooked_variable(const char *q, VALUE *w, type *e, rb_gvar_setter_t *r) +{ + rb_gvar_getter_t *t = reinterpret_cast(e); + ::rb_define_hooked_variable(q, w, t, r); +} + /// @} /// @name Exceptions and tag jumps /// @{ -- cgit v1.2.3