Ruby: include/ruby/internal/intern/hash.h File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Macros | Typedefs | Functions
hash.h File Reference

Public APIs related to rb_cHash. More...

`#include "ruby/internal/dllexport.h"`
`#include "ruby/internal/value.h"`
`#include "ruby/st.h"`

Go to the source code of this file.

## Macros
#define | st_foreach_safe rb_st_foreach_safe

## Typedefs
typedef VALUE | rb_hash_update_func(VALUE newkey, VALUE oldkey, VALUE value)

## Functions
void | rb_st_foreach_safe (struct st_table *, int(*)(st_data_t, st_data_t, st_data_t), st_data_t)
VALUE | rb_check_hash_type (VALUE)
void | rb_hash_foreach (VALUE, int(*)(VALUE, VALUE, VALUE), VALUE)
VALUE | rb_hash (VALUE)
VALUE | rb_hash_new (void)
VALUE | rb_hash_dup (VALUE)
VALUE | rb_hash_freeze (VALUE)
VALUE | rb_hash_aref (VALUE, VALUE)
VALUE | rb_hash_lookup (VALUE, VALUE)
VALUE | rb_hash_lookup2 (VALUE, VALUE, VALUE)
VALUE | rb_hash_fetch (VALUE, VALUE)
VALUE | rb_hash_aset (VALUE, VALUE, VALUE)
VALUE | rb_hash_clear (VALUE)
VALUE | rb_hash_delete_if (VALUE)
VALUE | rb_hash_delete (VALUE, VALUE)
VALUE | rb_hash_set_ifnone (VALUE hash, VALUE ifnone)
void | rb_hash_bulk_insert (long, const VALUE *, VALUE)
VALUE | rb_hash_update_by (VALUE hash1, VALUE hash2, rb_hash_update_func *func)
struct st_table * | rb_hash_tbl (VALUE, const char *file, int line)
int | rb_path_check (const char *)
int | rb_env_path_tainted (void)
VALUE | rb_env_clear (void)
VALUE | rb_hash_size (VALUE)
void | rb_hash_free (VALUE)

## Detailed Description

Public APIs related to rb_cHash.

Author
  Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org

Copyright
  This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.

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.

Definition in file hash.h.

## Macro Definition Documentation

## ◆ st_foreach_safe

#define st_foreach_safe rb_st_foreach_safe

Definition at line 31 of file hash.h.

## Typedef Documentation

## ◆ rb_hash_update_func

typedef VALUE rb_hash_update_func(VALUE newkey, VALUE oldkey, VALUE value)

Definition at line 48 of file hash.h.

## Function Documentation

## ◆ rb_check_hash_type()

VALUE rb_check_hash_type | ( | VALUE | hash | ) |

Definition at line 1860 of file hash.c.

References update_arg::hash, rb_check_convert_type_with_id(), and T_HASH.

Referenced by rb_econv_prepare_options(), and rb_Hash().

## ◆ rb_env_clear()

VALUE rb_env_clear | ( | void |  | ) |

Definition at line 5839 of file hash.c.

References key, RARRAY_AREF, RARRAY_LEN, RB_GC_GUARD, RSTRING_PTR, ruby_setenv(), and TRUE.

Referenced by rb_execarg_run_options().

## ◆ rb_env_path_tainted()

int rb_env_path_tainted | ( | void |  | ) |

Definition at line 5051 of file hash.c.

References rb_warn_deprecated_to_remove().

## ◆ rb_hash()

VALUE rb_hash | ( | VALUE | obj | ) |

Definition at line 143 of file hash.c.

References FIXNUM_MAX, FIXNUM_MIN, FIXNUM_P, id_hash, INTEGER_PACK_NATIVE_BYTE_ORDER, LONG2FIX, Qundef, rb_check_funcall_basic_kw(), rb_exec_recursive_outer(), rb_integer_pack(), rb_mKernel, rb_to_int(), and T_BIGNUM.

Referenced by rb_complex_hash(), and rb_rational_hash().

## ◆ rb_hash_aref()

VALUE rb_hash_aref | ( | VALUE | hash,
|  | VALUE | key
| ) |  |

Definition at line 2046 of file hash.c.

References key, and rb_hash_default_value().

Referenced by Init_Hash(), rb_autoload_str(), rb_econv_open_opts(), rb_econv_prepare_options(), rb_hash_values_at(), rb_io_extract_modeenc(), rb_iseq_build_from_ary(), rb_obj_dig(), and rb_warning_category_from_name().

## ◆ rb_hash_aset()

VALUE rb_hash_aset | ( | VALUE | hash,
|  | VALUE | key,
|  | VALUE | val
| ) |  |

Definition at line 2901 of file hash.c.

References identhash, key, rb_cString, rb_obj_class(), RHASH_ITER_LEV, RHASH_TYPE, RHASH_UPDATE_ITER, and shift_var::val.

Referenced by Init_Exception(), Init_GC(), Init_Hash(), Init_ossl_asn1(), Init_ossl_x509name(), InitVM_Enumerator(), olerecord_set_ivar(), rb_ast_add_mark_object(), rb_autoload_str(), rb_econv_prepare_options(), rb_hash_set_pair(), rb_iseq_new_top(), and rb_uninterruptible().

## ◆ rb_hash_bulk_insert()

void rb_hash_bulk_insert | ( | long | argc,
|  | const VALUE * | argv,
|  | VALUE | hash
| ) |  |

Definition at line 4777 of file hash.c.

References argc, argv, st_hash_type::hash, HASH_ASSERT, rb_hash_bulk_insert_into_st_table(), RHASH_AR_TABLE_MAX_SIZE, RHASH_AR_TABLE_SIZE, and RHASH_TBL_RAW.

## ◆ rb_hash_clear()

VALUE rb_hash_clear | ( | VALUE | hash | ) |

Definition at line 2819 of file hash.c.

References rb_hash_foreach(), RHASH_ITER_LEV, and st_clear.

Referenced by Init_Hash(), and yyparse().

## ◆ rb_hash_delete()

VALUE rb_hash_delete | ( | VALUE | hash,
|  | VALUE | key
| ) |  |

Definition at line 2327 of file hash.c.

References key, Qnil, Qundef, and rb_hash_delete_entry().

## ◆ rb_hash_delete_if()

VALUE rb_hash_delete_if | ( | VALUE | hash | ) |

Definition at line 2490 of file hash.c.

References rb_hash_foreach(), and RETURN_SIZED_ENUMERATOR.

Referenced by Init_Hash().

## ◆ rb_hash_dup()

VALUE rb_hash_dup | ( | VALUE | hash | ) |

Definition at line 1579 of file hash.c.

References FL_EXIVAR, hash_foreach_arg::hash, rb_copy_generic_ivar(), rb_obj_class(), RBASIC, and RHASH_PROC_DEFAULT.

## ◆ rb_hash_fetch()

VALUE rb_hash_fetch | ( | VALUE | hash,
|  | VALUE | key
| ) |  |

Definition at line 2138 of file hash.c.

References key.

Referenced by rb_category_compile_warn(), rb_category_warn(), and rb_category_warning().

## ◆ rb_hash_foreach()

void rb_hash_foreach | ( | VALUE | ,
|  | int(*)(VALUE, VALUE, VALUE) | ,
|  | VALUE |
| ) |  |

## ◆ rb_hash_free()

void rb_hash_free | ( | VALUE |  | ) |

## ◆ rb_hash_freeze()

VALUE rb_hash_freeze | ( | VALUE | hash | ) |

Definition at line 101 of file hash.c.

References rb_obj_freeze().

Referenced by rb_econv_prepare_options().

## ◆ rb_hash_lookup()

VALUE rb_hash_lookup | ( | VALUE | hash,
|  | VALUE | key
| ) |  |

Definition at line 2072 of file hash.c.

References key, Qnil, and rb_hash_lookup2().

## ◆ rb_hash_lookup2()

VALUE rb_hash_lookup2 | ( | VALUE | hash,
|  | VALUE | key,
|  | VALUE | def
| ) |  |

Definition at line 2059 of file hash.c.

References def(), and key.

Referenced by rb_hash_lookup(), rb_io_extract_encoding_option(), and rb_str_format().

## ◆ rb_hash_new()

VALUE rb_hash_new | ( | void |  | ) |

Definition at line 1538 of file hash.c.

References rb_cHash.

Referenced by date__httpdate(), date__iso8601(), date__jisx0301(), date__parse(), date__rfc2822(), date__rfc3339(), date__xmlschema(), Init_GC(), Init_limits(), Init_ossl_asn1(), Init_ossl_x509name(), Init_sizeof(), olerecord_set_ivar(), rb_default_coverage(), rb_econv_prepare_options(), rb_Hash(), rb_hash_new_with_size(), rb_hash_reject(), rb_ident_hash_new(), and yyparse().

## ◆ rb_hash_set_ifnone()

VALUE rb_hash_set_ifnone | ( | VALUE | hash,
|  | VALUE | ifnone
| ) |  |

Definition at line 113 of file hash.c.

References RB_OBJ_WRITE, and RHASH.

## ◆ rb_hash_size()

VALUE rb_hash_size | ( | VALUE | hash | ) |

Definition at line 2981 of file hash.c.

References INT2FIX, and RHASH_SIZE.

Referenced by Init_Hash().

## ◆ rb_hash_tbl()

struct st_table * rb_hash_tbl | ( | VALUE | hash,
|  | const char * | file,
|  | int | line
| ) |  |

Definition at line 1609 of file hash.c.

References OBJ_WB_UNPROTECT, and rb_hash_tbl_raw().

## ◆ rb_hash_update_by()

VALUE rb_hash_update_by | ( | VALUE | hash1,
|  | VALUE | hash2,
|  | rb_hash_update_func * | func
| ) |  |

Definition at line 4036 of file hash.c.

References update_func_arg::func, update_func_arg::hash, rb_hash_foreach(), and to_hash.

## ◆ rb_path_check()

int rb_path_check | ( | const char * | path | ) |

Definition at line 6250 of file file.c.

References PATH_SEP_CHAR, rb_str_new, strchr(), and strlen().

## ◆ rb_st_foreach_safe()

void rb_st_foreach_safe | ( | struct st_table * | ,
|  | int(*)(st_data_t, st_data_t, st_data_t) | ,
|  | st_data_t |
| ) |  |