aboutsummaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2023-06-21 16:49:51 +0900
committerGitHub <noreply@github.com>2023-06-21 16:49:51 +0900
commita87bce86bb2a7581943355b41abaf41a6ad18218 (patch)
tree34686e94b2f5fb9f10d6e17a06385d98e97b0014 /internal
parente25403d0d97b737901d137c54635df0413155ad4 (diff)
downloadruby-a87bce86bb2a7581943355b41abaf41a6ad18218.tar.gz
Allow setting the name of a class or module. (#7483)
Introduce `Module#set_temporary_name` for setting identifiers for otherwise anonymous modules/classes.
Diffstat (limited to 'internal')
-rw-r--r--internal/variable.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/variable.h b/internal/variable.h
index 4436cd789c..4fb7b23cf5 100644
--- a/internal/variable.h
+++ b/internal/variable.h
@@ -36,6 +36,22 @@ static inline bool ROBJ_TRANSIENT_P(VALUE obj);
static inline void ROBJ_TRANSIENT_SET(VALUE obj);
static inline void ROBJ_TRANSIENT_UNSET(VALUE obj);
+/**
+ * Sets the name of a module.
+ *
+ * Non-permanently named classes can have a temporary name assigned (or
+ * cleared). In that case the name will be used for `#inspect` and `#to_s`, and
+ * nested classes/modules will be named with the temporary name as a prefix.
+ *
+ * After the module is assigned to a constant, the temporary name will be
+ * discarded, and the name will be computed based on the nesting.
+ *
+ * @param[in] mod An instance of ::rb_cModule.
+ * @param[in] name An instance of ::rb_cString.
+ * @retval mod
+ */
+VALUE rb_mod_set_temporary_name(VALUE, VALUE);
+
struct gen_ivtbl;
int rb_gen_ivtbl_get(VALUE obj, ID id, struct gen_ivtbl **ivtbl);
int rb_obj_evacuate_ivs_to_hash_table(ID key, VALUE val, st_data_t arg);