Ruby: id_table.c File Reference

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

Data Structures | Macros | Typedefs | Functions
id_table.c File Reference
`#include "id_table.h"`
`#include "ruby_assert.h"`

Go to the source code of this file.

## Data Structures
struct | rb_id_item
struct | rb_id_table

## Macros
#define | ID_TABLE_DEBUG 0
#define | NDEBUG
#define | ITEM_GET_KEY(tbl, i) ((tbl)->items[i].key >> 1)
#define | ITEM_KEY_ISSET(tbl, i) ((tbl)->items[i].key > 1)
#define | ITEM_COLLIDED(tbl, i) ((tbl)->items[i].key & 1)
#define | ITEM_SET_COLLIDED(tbl, i) ((tbl)->items[i].key |= 1)

## Typedefs
typedef rb_id_serial_t | id_key_t
typedef struct rb_id_item | item_t

## Functions
struct rb_id_table * | rb_id_table_create (size_t capa)
void | rb_id_table_free (struct rb_id_table *tbl)
void | rb_id_table_clear (struct rb_id_table *tbl)
size_t | rb_id_table_size (const struct rb_id_table *tbl)
size_t | rb_id_table_memsize (const struct rb_id_table *tbl)
int | rb_id_table_lookup (struct rb_id_table *tbl, ID id, VALUE *valp)
int | rb_id_table_insert (struct rb_id_table *tbl, ID id, VALUE val)
int | rb_id_table_delete (struct rb_id_table *tbl, ID id)
void | rb_id_table_foreach_with_replace (struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, rb_id_table_update_callback_func_t *replace, void *data)
void | rb_id_table_foreach (struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, void *data)
void | rb_id_table_foreach_values (struct rb_id_table *tbl, rb_id_table_foreach_values_func_t *func, void *data)

## Macro Definition Documentation

## ◆ ID_TABLE_DEBUG

#define ID_TABLE_DEBUG 0

Definition at line 6 of file id_table.c.

## ◆ ITEM_COLLIDED

#define ITEM_COLLIDED | ( |  | tbl,
|  |  | i
| ) |  | ((tbl)->items[i].key & 1)

Definition at line 61 of file id_table.c.

## ◆ ITEM_GET_KEY

#define ITEM_GET_KEY | ( |  | tbl,
|  |  | i
| ) |  | ((tbl)->items[i].key >> 1)

Definition at line 59 of file id_table.c.

## ◆ ITEM_KEY_ISSET

#define ITEM_KEY_ISSET | ( |  | tbl,
|  |  | i
| ) |  | ((tbl)->items[i].key > 1)

Definition at line 60 of file id_table.c.

## ◆ ITEM_SET_COLLIDED

#define ITEM_SET_COLLIDED | ( |  | tbl,
|  |  | i
| ) |  | ((tbl)->items[i].key |= 1)

Definition at line 62 of file id_table.c.

## ◆ NDEBUG

#define NDEBUG

Definition at line 11 of file id_table.c.

## Typedef Documentation

## ◆ id_key_t

typedef rb_id_serial_t id_key_t

Definition at line 15 of file id_table.c.

## ◆ item_t

typedef struct rb_id_item item_t

## Function Documentation

## ◆ rb_id_table_clear()

void rb_id_table_clear | ( | struct rb_id_table * | tbl | ) |

Definition at line 110 of file id_table.c.

References rb_id_table::capa, rb_id_table::items, MEMZERO, rb_id_table::num, and rb_id_table::used.

## ◆ rb_id_table_create()

struct rb_id_table * rb_id_table_create | ( | size_t | capa | ) |

Definition at line 96 of file id_table.c.

References ALLOC, and rb_id_table::capa.

Referenced by Init_BareVM(), Init_var_tables(), rb_const_set(), rb_include_class_new(), and rb_singleton_class_clone_and_attach().

## ◆ rb_id_table_delete()

int rb_id_table_delete | ( | struct rb_id_table * | tbl,
|  | ID | id
| ) |  |

Definition at line 263 of file id_table.c.

References key.

Referenced by rb_const_remove().

## ◆ rb_id_table_foreach()

void rb_id_table_foreach | ( | struct rb_id_table * | tbl,
|  | rb_id_table_foreach_func_t * | func,
|  | void * | data
| ) |  |

Definition at line 292 of file id_table.c.

References assert, rb_id_table::capa, ID_TABLE_DELETE, ID_TABLE_STOP, ITEM_GET_KEY, ITEM_KEY_ISSET, rb_id_table::items, key, and rb_id_item::val.

Referenced by rb_f_global_variables(), rb_mod_const_at(), rb_mod_init_copy(), rb_obj_singleton_methods(), rb_prepend_module(), rb_proc_isolate_bang(), rb_proc_ractor_make_shareable(), rb_singleton_class_clone_and_attach(), rb_undef_methods_from(), and rb_vm_check_redefinition_by_prepend().

## ◆ rb_id_table_foreach_values()

void rb_id_table_foreach_values | ( | struct rb_id_table * | tbl,
|  | rb_id_table_foreach_values_func_t * | func,
|  | void * | data
| ) |  |

Definition at line 311 of file id_table.c.

References rb_id_table::capa, ID_TABLE_DELETE, ID_TABLE_STOP, ITEM_KEY_ISSET, rb_id_table::items, and rb_id_item::val.

Referenced by rb_execution_context_mark(), rb_free_const_table(), rb_gc_mark_global_tbl(), rb_gc_update_global_tbl(), and rb_vm_mark().

## ◆ rb_id_table_foreach_with_replace()

void rb_id_table_foreach_with_replace | ( | struct rb_id_table * | tbl,
|  | rb_id_table_foreach_func_t * | func,
|  | rb_id_table_update_callback_func_t * | replace,
|  | void * | data
| ) |  |

Definition at line 271 of file id_table.c.

References assert, rb_id_table::capa, ID_TABLE_REPLACE, ID_TABLE_STOP, ITEM_GET_KEY, ITEM_KEY_ISSET, rb_id_table::items, NULL, Qundef, TRUE, and rb_id_item::val.

## ◆ rb_id_table_free()

void rb_id_table_free | ( | struct rb_id_table * | tbl | ) |

Definition at line 103 of file id_table.c.

References rb_id_table::items, and xfree.

Referenced by rb_free_const_table(), and rb_iseq_free().

## ◆ rb_id_table_insert()

int rb_id_table_insert | ( | struct rb_id_table * | tbl,
|  | ID | id,
|  | VALUE | val
| ) |  |

Definition at line 257 of file id_table.c.

Referenced by rb_alias_variable(), rb_const_set(), and rb_method_table_insert().

## ◆ rb_id_table_lookup()

int rb_id_table_lookup | ( | struct rb_id_table * | tbl,
|  | ID | id,
|  | VALUE * | valp
| ) |  |

Definition at line 227 of file id_table.c.

References FALSE, rb_id_table::items, key, TRUE, and rb_id_item::val.

Referenced by rb_alias_variable(), and rb_const_lookup().

## ◆ rb_id_table_memsize()

size_t rb_id_table_memsize | ( | const struct rb_id_table * | tbl | ) |

Definition at line 124 of file id_table.c.

References rb_id_table::capa.

## ◆ rb_id_table_size()

size_t rb_id_table_size | ( | const struct rb_id_table * | tbl | ) |

Definition at line 118 of file id_table.c.

References rb_id_table::num.

Referenced by rb_class_has_methods().