[前][次][番号順一覧][スレッド一覧]

ruby-changes:57820

From: Nobuyoshi <ko1@a...>
Date: Fri, 20 Sep 2019 01:30:06 +0900 (JST)
Subject: [ruby-changes:57820] 17a1366399 (master): Overload variable definition functions

https://git.ruby-lang.org/ruby.git/commit/?id=17a1366399

From 17a13663998a98ff75fcc838d1cea95c879fbb88 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
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.

diff --git a/include/ruby/backward/cxxanyargs.hpp b/include/ruby/backward/cxxanyargs.hpp
index 604d50b..55b841b 100644
--- a/include/ruby/backward/cxxanyargs.hpp
+++ b/include/ruby/backward/cxxanyargs.hpp
@@ -66,6 +66,36 @@ rb_define_virtual_variable(const char *q, type *w, void_type *e) https://github.com/ruby/ruby/blob/trunk/include/ruby/backward/cxxanyargs.hpp#L66
 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<rb_gvar_setter_t*>(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<rb_gvar_getter_t*>(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.
 /// @param[in]   w  Variable storage.
 /// @param[in]   e  Getter function.
 /// @param[in]   r  Setter function.
@@ -80,6 +110,38 @@ rb_define_hooked_variable(const char *q, VALUE *w, type *e, void_type *r) https://github.com/ruby/ruby/blob/trunk/include/ruby/backward/cxxanyargs.hpp#L110
     ::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<rb_gvar_setter_t*>(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<rb_gvar_getter_t*>(e);
+    ::rb_define_hooked_variable(q, w, t, r);
+}
+
 /// @}
 /// @name Exceptions and tag jumps
 /// @{
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]