Ruby 4.1.0dev (2026-09-30 revision 5c128f545b7d16f3fc8405b811fc5a04dcd73d8f)
rhash.h
Go to the documentation of this file.
1#ifndef RBIMPL_RHASH_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_RHASH_H
24#include "ruby/internal/config.h"
25
26#ifdef STDC_HEADERS
27# include <stddef.h>
28#endif
29
31#include "ruby/internal/value.h"
32#if !defined RUBY_EXPORT && !defined RUBY_NO_OLD_COMPATIBILITY
33# include "ruby/backward.h"
34#endif
35
47#define RHASH_IFNONE(h) rb_hash_ifnone(h)
48
57#define RHASH_SIZE(h) rb_hash_size_num(h)
58
67#define RHASH_EMPTY_P(h) (RHASH_SIZE(h) == 0)
68
80#define RHASH_SET_IFNONE(h, ifnone) rb_hash_set_ifnone((VALUE)h, ifnone)
81
82struct st_table; /* in ruby/st.h */
83
85
86
94size_t rb_hash_size_num(VALUE hash);
95
106struct st_table *rb_hash_tbl(VALUE hash);
107
108RBIMPL_ATTR_DEPRECATED(("other `rb_hash_*` APIs"))
121static inline st_table *
123{
124 return rb_hash_tbl(h);
125}
126
135VALUE rb_hash_set_ifnone(VALUE hash, VALUE ifnone);
137
138#endif /* RBIMPL_RHASH_H */
#define RBIMPL_ATTR_DEPRECATED(msg)
Wraps (or simulates) [[deprecated]]
Definition deprecated.h:64
Tweaking visibility of C variables/functions.
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:74
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:65
static st_table * RHASH_TBL(VALUE h)
Retrieves the internal table.
Definition rhash.h:122
VALUE rb_hash_set_ifnone(VALUE hash, VALUE ifnone)
This is the implementation detail of RHASH_SET_IFNONE.
Definition hash.c:133
struct st_table * rb_hash_tbl(VALUE hash)
This is the implementation detail of RHASH_TBL.
Definition hash.c:1804
size_t rb_hash_size_num(VALUE hash)
This is the implementation detail of RHASH_SIZE.
Definition hash.c:3265
Definition st.h:79
Defines VALUE and ID.
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40