Skip to content

Commit 17a1366

Browse files
committed
Overload variable definition functions
Define overloading functions of rb_define_virtual_variable and rb_define_hooked_variable, for combinations with and without ANYARGS casts.
1 parent 9c0d5e5 commit 17a1366

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

include/ruby/backward/cxxanyargs.hpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,36 @@ rb_define_virtual_variable(const char *q, type *w, void_type *e)
6363
::rb_define_virtual_variable(q, r, t);
6464
}
6565

66+
RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprected")
67+
/// @brief Define a function-backended global variable.
68+
/// @param[in] q Name of the variable.
69+
/// @param[in] w Getter function.
70+
/// @param[in] e Setter function.
71+
/// @note Both functions can be nullptr.
72+
/// @see rb_define_hooked_variable()
73+
/// @deprecated Use glanular typed overload instead.
74+
inline void
75+
rb_define_virtual_variable(const char *q, rb_gvar_getter_t *w, void_type *e)
76+
{
77+
rb_gvar_setter_t *t = reinterpret_cast<rb_gvar_setter_t*>(e);
78+
::rb_define_virtual_variable(q, w, t);
79+
}
80+
81+
RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprected")
82+
/// @brief Define a function-backended global variable.
83+
/// @param[in] q Name of the variable.
84+
/// @param[in] w Getter function.
85+
/// @param[in] e Setter function.
86+
/// @note Both functions can be nullptr.
87+
/// @see rb_define_hooked_variable()
88+
/// @deprecated Use glanular typed overload instead.
89+
inline void
90+
rb_define_virtual_variable(const char *q, type *w, rb_gvar_setter_t *e)
91+
{
92+
rb_gvar_getter_t *r = reinterpret_cast<rb_gvar_getter_t*>(w);
93+
::rb_define_virtual_variable(q, r, e);
94+
}
95+
6696
RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprected")
6797
/// @brief Define a function-backended global variable.
6898
/// @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)
80110
::rb_define_hooked_variable(q, w, t, y);
81111
}
82112

113+
RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprected")
114+
/// @brief Define a function-backended global variable.
115+
/// @param[in] q Name of the variable.
116+
/// @param[in] w Variable storage.
117+
/// @param[in] e Getter function.
118+
/// @param[in] r Setter function.
119+
/// @note Both functions can be nullptr.
120+
/// @see rb_define_virtual_variable()
121+
/// @deprecated Use glanular typed overload instead.
122+
inline void
123+
rb_define_hooked_variable(const char *q, VALUE *w, rb_gvar_getter_t *e, void_type *r)
124+
{
125+
rb_gvar_setter_t *y = reinterpret_cast<rb_gvar_setter_t*>(r);
126+
::rb_define_hooked_variable(q, w, e, y);
127+
}
128+
129+
RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprected")
130+
/// @brief Define a function-backended global variable.
131+
/// @param[in] q Name of the variable.
132+
/// @param[in] w Variable storage.
133+
/// @param[in] e Getter function.
134+
/// @param[in] r Setter function.
135+
/// @note Both functions can be nullptr.
136+
/// @see rb_define_virtual_variable()
137+
/// @deprecated Use glanular typed overload instead.
138+
inline void
139+
rb_define_hooked_variable(const char *q, VALUE *w, type *e, rb_gvar_setter_t *r)
140+
{
141+
rb_gvar_getter_t *t = reinterpret_cast<rb_gvar_getter_t*>(e);
142+
::rb_define_hooked_variable(q, w, t, r);
143+
}
144+
83145
/// @}
84146
/// @name Exceptions and tag jumps
85147
/// @{

0 commit comments

Comments
 (0)