Define ::Ruby module earlier to define classes under it

This commit is contained in:
Satoshi Tagomori 2025-11-06 15:33:58 +09:00 committed by Satoshi Tagomori
parent d2a587c791
commit 95a110a9af
Notes: git 2025-11-07 04:15:46 +00:00
2 changed files with 9 additions and 1 deletions

View File

@ -52,6 +52,7 @@ rb_call_inits(void)
CALL(Time); CALL(Time);
CALL(Random); CALL(Random);
CALL(load); CALL(load);
CALL(Ruby_module);
CALL(Box); CALL(Box);
CALL(Proc); CALL(Proc);
CALL(Binding); CALL(Binding);

View File

@ -12,6 +12,7 @@
#include "internal/cmdlineopt.h" #include "internal/cmdlineopt.h"
#include "internal/parse.h" #include "internal/parse.h"
#include "internal/gc.h" #include "internal/gc.h"
#include "ruby/internal/globals.h"
#include "ruby/ruby.h" #include "ruby/ruby.h"
#include "version.h" #include "version.h"
#include "vm_core.h" #include "vm_core.h"
@ -112,6 +113,12 @@ define_ruby_const(VALUE mod, const char *name, VALUE value, bool toplevel)
#define rb_define_const(mod, name, value) \ #define rb_define_const(mod, name, value) \
define_ruby_const(mod, (mod == mRuby ? "RUBY_" name : name), value, (mod == mRuby)) define_ruby_const(mod, (mod == mRuby ? "RUBY_" name : name), value, (mod == mRuby))
void
Init_Ruby_module(void)
{
rb_define_module("Ruby");
}
/*! Defines platform-depended Ruby-level constants */ /*! Defines platform-depended Ruby-level constants */
void void
Init_version(void) Init_version(void)
@ -123,7 +130,7 @@ Init_version(void)
* The constants defined here are aliased in the toplevel with * The constants defined here are aliased in the toplevel with
* +RUBY_+ prefix. * +RUBY_+ prefix.
*/ */
VALUE mRuby = rb_define_module("Ruby"); VALUE mRuby = rb_path2class("Ruby");
enum {ruby_patchlevel = RUBY_PATCHLEVEL}; enum {ruby_patchlevel = RUBY_PATCHLEVEL};
VALUE version = MKSTR(version); VALUE version = MKSTR(version);