Ruby  3.4.0dev (2024-12-06 revision 892c46283a5ea4179500d951c9d4866c0051f27b)
Macros | Functions
scan_args.h File Reference

(892c46283a5ea4179500d951c9d4866c0051f27b)

Compile-time static implementation of rb_scan_args(). More...

#include "ruby/assert.h"
#include "ruby/internal/attr/diagnose_if.h"
#include "ruby/internal/attr/error.h"
#include "ruby/internal/attr/forceinline.h"
#include "ruby/internal/attr/nonnull.h"
#include "ruby/internal/attr/noreturn.h"
#include "ruby/internal/config.h"
#include "ruby/internal/dllexport.h"
#include "ruby/internal/has/attribute.h"
#include "ruby/internal/intern/array.h"
#include "ruby/internal/intern/error.h"
#include "ruby/internal/intern/hash.h"
#include "ruby/internal/intern/proc.h"
#include "ruby/internal/iterator.h"
#include "ruby/internal/static_assert.h"
#include "ruby/internal/stdbool.h"
#include "ruby/internal/value.h"
Include dependency graph for scan_args.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define HAVE_RB_SCAN_ARGS_OPTIONAL_HASH   1
 
Possible values that you should pass to rb_scan_args_kw().
#define RB_SCAN_ARGS_PASS_CALLED_KEYWORDS   0
 Same behaviour as rb_scan_args(). More...
 
#define RB_SCAN_ARGS_KEYWORDS   1
 The final argument should be a hash treated as keywords. More...
 
#define RB_SCAN_ARGS_LAST_HASH_KEYWORDS   3
 Treat a final argument as keywords if it is a hash, and not as keywords otherwise. More...
 
Possible values that you should pass to rb_funcallv_kw().
#define RB_NO_KEYWORDS   0
 Do not pass keywords. More...
 
#define RB_PASS_KEYWORDS   1
 Pass keywords, final argument should be a hash of keywords. More...
 
#define RB_PASS_CALLED_KEYWORDS   !!rb_keyword_given_p()
 Pass keywords if current method is called with keywords, useful for argument delegation. More...
 

Functions

int rb_scan_args (int argc, const VALUE *argv, const char *fmt,...)
 Retrieves argument from argc and argv to given VALUE references according to the format string. More...
 
int rb_scan_args_kw (int kw_splat, int argc, const VALUE *argv, const char *fmt,...)
 Identical to rb_scan_args(), except it also accepts kw_splat. More...
 

Detailed Description

Compile-time static implementation of rb_scan_args().

Author
Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org
Warning
Symbols prefixed with either RBIMPL or rbimpl are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will.
Note
To ruby-core: remember that this header can be possibly recursively included from extension libraries written in C++. Do not expect for instance __VA_ARGS__ is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98.

This is a beast. It statically analyses the argument spec string, and expands the assignment of variables into dedicated codes.

Definition in file scan_args.h.

Macro Definition Documentation

◆ HAVE_RB_SCAN_ARGS_OPTIONAL_HASH

#define HAVE_RB_SCAN_ARGS_OPTIONAL_HASH   1
Deprecated:
This macro once was a thing in the old days, but makes no sense any longer today.

Exists here for backwards compatibility only. You can safely forget about it.

Definition at line 89 of file scan_args.h.

◆ RB_NO_KEYWORDS

#define RB_NO_KEYWORDS   0

Do not pass keywords.

Definition at line 69 of file scan_args.h.

◆ RB_PASS_CALLED_KEYWORDS

#define RB_PASS_CALLED_KEYWORDS   !!rb_keyword_given_p()

Pass keywords if current method is called with keywords, useful for argument delegation.

Definition at line 78 of file scan_args.h.

◆ RB_PASS_KEYWORDS

#define RB_PASS_KEYWORDS   1

Pass keywords, final argument should be a hash of keywords.

Definition at line 72 of file scan_args.h.

◆ RB_SCAN_ARGS_KEYWORDS

#define RB_SCAN_ARGS_KEYWORDS   1

The final argument should be a hash treated as keywords.

Definition at line 53 of file scan_args.h.

◆ RB_SCAN_ARGS_LAST_HASH_KEYWORDS

#define RB_SCAN_ARGS_LAST_HASH_KEYWORDS   3

Treat a final argument as keywords if it is a hash, and not as keywords otherwise.

Definition at line 59 of file scan_args.h.

◆ RB_SCAN_ARGS_PASS_CALLED_KEYWORDS

#define RB_SCAN_ARGS_PASS_CALLED_KEYWORDS   0

Same behaviour as rb_scan_args().

Definition at line 50 of file scan_args.h.