Ruby  3.4.0dev (2024-12-06 revision 892c46283a5ea4179500d951c9d4866c0051f27b)
Namespaces | Typedefs
ruby::backward::cxxanyargs Namespace Reference

Provides ANYARGS deprecation warnings. More...

Namespaces

 define_method
 Driver for *_define_method.
 

Typedefs

typedef VALUE type(ANYARGS)
 ANYARGS-ed function type. More...
 
typedef void void_type(ANYARGS)
 ANYARGS-ed function type, void variant. More...
 
typedef int int_type(ANYARGS)
 ANYARGS-ed function type, int variant. More...
 
typedef VALUE onearg_type(VALUE)
 Single-argumented function type. More...
 

Functions

Hooking global variables
void rb_define_virtual_variable (const char *q, type *w, void_type *e)
 Define a function-backended global variable. More...
 
void rb_define_hooked_variable (const char *q, VALUE *w, type *e, void_type *r)
 Define a function-backended global variable. More...
 
Exceptions and tag jumps
VALUE rb_iterate (onearg_type *q, VALUE w, type *e, VALUE r)
 Old way to implement iterators. More...
 
VALUE rb_block_call (VALUE q, ID w, int e, const VALUE *r, type *t, VALUE y)
 Call a method with a block. More...
 
VALUE rb_rescue (type *q, VALUE w, type *e, VALUE r)
 An equivalent of rescue clause. More...
 
VALUE rb_rescue2 (type *q, VALUE w, type *e, VALUE r,...)
 An equivalent of rescue clause. More...
 
VALUE rb_ensure (type *q, VALUE w, type *e, VALUE r)
 An equivalent of ensure clause. More...
 
VALUE rb_catch (const char *q, type *w, VALUE e)
 An equivalent of Kernel#catch. More...
 
VALUE rb_catch_obj (VALUE q, type *w, VALUE e)
 An equivalent of Kernel#catch. More...
 
Procs, Fibers and Threads
VALUE rb_fiber_new (type *q, VALUE w)
 Creates a rb_cFiber instance. More...
 
VALUE rb_proc_new (type *q, VALUE w)
 Creates a rb_cProc instance. More...
 
VALUE rb_thread_create (type *q, void *w)
 Creates a rb_cThread instance. More...
 
Hash and st_table
int st_foreach (st_table *q, int_type *w, st_data_t e)
 Iteration over the given table. More...
 
int st_foreach_check (st_table *q, int_type *w, st_data_t e, st_data_t)
 Iteration over the given table. More...
 
void st_foreach_safe (st_table *q, int_type *w, st_data_t e)
 Iteration over the given table. More...
 
void rb_hash_foreach (VALUE q, int_type *w, VALUE e)
 Iteration over the given hash. More...
 
void rb_ivar_foreach (VALUE q, int_type *w, VALUE e)
 Iteration over each instance variable of the object. More...
 

Detailed Description

Provides ANYARGS deprecation warnings.

In C, ANYARGS means there is no function prototype. Literally anything, even including nothing, can be a valid ANYARGS. So passing a correctly prototyped function pointer to an ANYARGS-ed function parameter is valid, at the same time passing an ANYARGS-ed function pointer to a granular typed function parameter is also valid. However on the other hand in C++, ANYARGS doesn't actually mean any number of arguments. C++'s ANYARGS means variadic number of arguments. This is incompatible with ordinal, correct function prototypes.

Luckily, function prototypes being distinct each other means they can be overloaded. We can provide a compatibility layer for older Ruby APIs which used to have ANYARGS. This namespace includes such attempts.

Typedef Documentation

◆ int_type

typedef int ruby::backward::cxxanyargs::int_type(ANYARGS)

ANYARGS-ed function type, int variant.

Definition at line 58 of file cxxanyargs.hpp.

◆ onearg_type

typedef VALUE ruby::backward::cxxanyargs::onearg_type(VALUE)

Single-argumented function type.

Definition at line 59 of file cxxanyargs.hpp.

◆ type

typedef VALUE ruby::backward::cxxanyargs::type(ANYARGS)

ANYARGS-ed function type.

Definition at line 56 of file cxxanyargs.hpp.

◆ void_type

typedef void ruby::backward::cxxanyargs::void_type(ANYARGS)

ANYARGS-ed function type, void variant.

Definition at line 57 of file cxxanyargs.hpp.

Function Documentation

◆ rb_block_call()

VALUE ruby::backward::cxxanyargs::rb_block_call ( VALUE  q,
ID  w,
int  e,
const VALUE r,
type t,
VALUE  y 
)
inline

Call a method with a block.

Parameters
[in]qThe self.
[in]wThe method.
[in]eThe # of elems of r
[in]rThe arguments.
[in]tWhat is to be yielded.
[in]yPassed to t
Returns
Return value of q#w(*r,&t)
Note
't' can be nullptr.
Deprecated:
Use granular typed overload instead.

Definition at line 232 of file cxxanyargs.hpp.

◆ rb_catch()

VALUE ruby::backward::cxxanyargs::rb_catch ( const char *  q,
type w,
VALUE  e 
)
inline

An equivalent of Kernel#catch.

Parameters
[in]qThe "tag" string.
[in]wA function that can throw.
[in]ePassed to w.
Returns
What was thrown.
Note
q can be a nullptr but makes no sense to pass nullptr tow.
See also
rb_block_call()
rb_protect()
rb_rb_catch_obj()
rb_rescue()
Deprecated:
Use granular typed overload instead.

Definition at line 331 of file cxxanyargs.hpp.

◆ rb_catch_obj()

VALUE ruby::backward::cxxanyargs::rb_catch_obj ( VALUE  q,
type w,
VALUE  e 
)
inline

An equivalent of Kernel#catch.

Parameters
[in]qThe "tag" object.
[in]wA function that can throw.
[in]ePassed to w.
Returns
What was thrown.
Note
It makes no sense to pass nullptr tow.
See also
rb_block_call()
rb_protect()
rb_rb_catch_obj()
rb_rescue()
Deprecated:
Use granular typed overload instead.

Definition at line 358 of file cxxanyargs.hpp.

◆ rb_define_hooked_variable()

void ruby::backward::cxxanyargs::rb_define_hooked_variable ( const char *  q,
VALUE w,
type e,
void_type r 
)
inline

Define a function-backended global variable.

Parameters
[in]qName of the variable.
[in]wVariable storage.
[in]eGetter function.
[in]rSetter function.
Note
Both functions can be nullptr.
See also
rb_define_virtual_variable()
Deprecated:
Use granular typed overload instead.

Definition at line 136 of file cxxanyargs.hpp.

◆ rb_define_virtual_variable()

void ruby::backward::cxxanyargs::rb_define_virtual_variable ( const char *  q,
type w,
void_type e 
)
inline

Define a function-backended global variable.

Parameters
[in]qName of the variable.
[in]wGetter function.
[in]eSetter function.
Note
Both functions can be nullptr.
See also
rb_define_hooked_variable()
Deprecated:
Use granular typed overload instead.

Definition at line 73 of file cxxanyargs.hpp.

◆ rb_ensure()

VALUE ruby::backward::cxxanyargs::rb_ensure ( type q,
VALUE  w,
type e,
VALUE  r 
)
inline

An equivalent of ensure clause.

Parameters
[in]qA function that can raise.
[in]wPassed to q.
[in]eA function that ensures.
[in]rPassed to e.
Returns
The return value of q.
Note
It makes no sense to pass nullptr to e.
See also
rb_rescue()
rb_rescue2()
rb_protect()
Deprecated:
Use granular typed overload instead.

Definition at line 310 of file cxxanyargs.hpp.

◆ rb_fiber_new()

VALUE ruby::backward::cxxanyargs::rb_fiber_new ( type q,
VALUE  w 
)
inline

Creates a rb_cFiber instance.

Parameters
[in]qThe fiber body.
[in]wPassed to q.
Returns
What was allocated.
Note
It makes no sense to pass nullptr toq.
See also
rb_proc_new()
rb_thread_create()
Deprecated:
Use granular typed overload instead.

Definition at line 378 of file cxxanyargs.hpp.

◆ rb_hash_foreach()

void ruby::backward::cxxanyargs::rb_hash_foreach ( VALUE  q,
int_type w,
VALUE  e 
)
inline

Iteration over the given hash.

Parameters
[in]qA hash to scan.
[in]wA function to iterate.
[in]ePassed to w.
Note
It makes no sense to pass nullptr tow.
See also
st_foreach()
Deprecated:
Use granular typed overload instead.

Definition at line 482 of file cxxanyargs.hpp.

◆ rb_iterate()

VALUE ruby::backward::cxxanyargs::rb_iterate ( onearg_type q,
VALUE  w,
type e,
VALUE  r 
)
inline

Old way to implement iterators.

Parameters
[in]qA function that can yield.
[in]wPassed to q.
[in]eWhat is to be yielded.
[in]rPassed to e.
Returns
The return value of q.
Note
e can be nullptr.
Deprecated:
This function is obsoleted since long before 2.x era. Do not use it any longer. rb_block_call() is provided instead.

Definition at line 205 of file cxxanyargs.hpp.

◆ rb_ivar_foreach()

void ruby::backward::cxxanyargs::rb_ivar_foreach ( VALUE  q,
int_type w,
VALUE  e 
)
inline

Iteration over each instance variable of the object.

Parameters
[in]qAn object.
[in]wA function to iterate.
[in]ePassed to w.
Note
It makes no sense to pass nullptr tow.
See also
st_foreach()
Deprecated:
Use granular typed overload instead.

Definition at line 498 of file cxxanyargs.hpp.

◆ rb_proc_new()

VALUE ruby::backward::cxxanyargs::rb_proc_new ( type q,
VALUE  w 
)
inline

Creates a rb_cProc instance.

Parameters
[in]qThe proc body.
[in]wPassed to q.
Returns
What was allocated.
Note
It makes no sense to pass nullptr toq.
See also
rb_fiber_new()
rb_thread_create()
Deprecated:
Use granular typed overload instead.

Definition at line 394 of file cxxanyargs.hpp.

◆ rb_rescue()

VALUE ruby::backward::cxxanyargs::rb_rescue ( type q,
VALUE  w,
type e,
VALUE  r 
)
inline

An equivalent of rescue clause.

Parameters
[in]qA function that can raise.
[in]wPassed to q.
[in]eA function that cleans-up.
[in]rPassed to e.
Returns
The return value of q if no exception occurs, or the return value of e if otherwise.
Note
e can be nullptr.
See also
rb_ensure()
rb_rescue2()
rb_protect()
Deprecated:
Use granular typed overload instead.

Definition at line 260 of file cxxanyargs.hpp.

◆ rb_rescue2()

VALUE ruby::backward::cxxanyargs::rb_rescue2 ( type q,
VALUE  w,
type e,
VALUE  r,
  ... 
)
inline

An equivalent of rescue clause.

Parameters
[in]qA function that can raise.
[in]wPassed to q.
[in]eA function that cleans-up.
[in]rPassed to e.
[in]...0-terminated list of subclass of rb_eException.
Returns
The return value of q if no exception occurs, or the return value of e if otherwise.
Note
e can be nullptr.
See also
rb_ensure()
rb_rescue()
rb_protect()
Deprecated:
Use granular typed overload instead.

Definition at line 284 of file cxxanyargs.hpp.

◆ rb_thread_create()

VALUE ruby::backward::cxxanyargs::rb_thread_create ( type q,
void *  w 
)
inline

Creates a rb_cThread instance.

Parameters
[in]qThe thread body.
[in]wPassed to q.
Returns
What was allocated.
Note
It makes no sense to pass nullptr toq.
See also
rb_proc_new()
rb_fiber_new()
Deprecated:
Use granular typed overload instead.

Definition at line 410 of file cxxanyargs.hpp.

◆ st_foreach()

int ruby::backward::cxxanyargs::st_foreach ( st_table q,
int_type w,
st_data_t  e 
)
inline

Iteration over the given table.

Parameters
[in]qA table to scan.
[in]wA function to iterate.
[in]ePassed to w.
Return values
0Always returns 0.
Note
It makes no sense to pass nullptr tow.
See also
st_foreach_check()
rb_hash_foreach()
Deprecated:
Use granular typed overload instead.

Definition at line 432 of file cxxanyargs.hpp.

Referenced by rb_clear_constant_cache_for_id(), rb_econv_asciicompat_encoding(), rb_mark_hash(), rb_mark_set(), rb_mark_tbl(), and rb_sym_all_symbols().

◆ st_foreach_check()

int ruby::backward::cxxanyargs::st_foreach_check ( st_table q,
int_type w,
st_data_t  e,
st_data_t   
)
inline

Iteration over the given table.

Parameters
[in]qA table to scan.
[in]wA function to iterate.
[in]ePassed to w.
Return values
0Successful end of iteration.
1Element removed during traversing.
Note
It makes no sense to pass nullptr tow.
See also
st_foreach()
Deprecated:
Use granular typed overload instead.

Definition at line 450 of file cxxanyargs.hpp.

◆ st_foreach_safe()

void ruby::backward::cxxanyargs::st_foreach_safe ( st_table q,
int_type w,
st_data_t  e 
)
inline

Iteration over the given table.

Parameters
[in]qA table to scan.
[in]wA function to iterate.
[in]ePassed to w.
Note
It makes no sense to pass nullptr tow.
See also
st_foreach_check()
Deprecated:
Use granular typed overload instead.

Definition at line 466 of file cxxanyargs.hpp.