Show docs of constants under Ruby
This commit is contained in:
parent
b923a59b8e
commit
8f11d6cbe2
Notes:
git
2024-12-25 10:12:52 +00:00
36
version.c
36
version.c
@ -88,17 +88,18 @@ const char ruby_engine[] = "ruby";
|
||||
const char *rb_dynamic_description = ruby_description;
|
||||
|
||||
static inline void
|
||||
define_ruby_const(const char *name, VALUE value, VALUE mRuby)
|
||||
define_ruby_const(VALUE mod, const char *name, VALUE value, bool toplevel)
|
||||
{
|
||||
rb_define_global_const(name, value);
|
||||
if (strncmp(name, "RUBY_", rb_strlen_lit("RUBY_")) == 0) {
|
||||
rb_define_const(mRuby, name + rb_strlen_lit("RUBY_"), value);
|
||||
if (toplevel) {
|
||||
rb_define_global_const(name, value);
|
||||
name += rb_strlen_lit("RUBY_");
|
||||
}
|
||||
rb_define_const(mod, name, value);
|
||||
}
|
||||
|
||||
/* RDoc needs rb_define_global_const */
|
||||
#define rb_define_global_const(name, value) \
|
||||
define_ruby_const(name, value, mRuby)
|
||||
/* RDoc needs rb_define_const */
|
||||
#define rb_define_const(mod, name, value) \
|
||||
define_ruby_const(mod, (mod == mRuby ? "RUBY_" name : name), value, (mod == mRuby))
|
||||
|
||||
/*! Defines platform-depended Ruby-level constants */
|
||||
void
|
||||
@ -107,6 +108,9 @@ Init_version(void)
|
||||
/*
|
||||
* The Ruby module that contains portable information among
|
||||
* implementations.
|
||||
*
|
||||
* The constants defined here are aliased in the toplevel with
|
||||
* +RUBY_+ prefix.
|
||||
*/
|
||||
VALUE mRuby = rb_define_module("Ruby");
|
||||
|
||||
@ -118,37 +122,37 @@ Init_version(void)
|
||||
/*
|
||||
* The running version of ruby
|
||||
*/
|
||||
rb_define_global_const("RUBY_VERSION", /* MKSTR(version) */ version);
|
||||
rb_define_const(mRuby, "VERSION", /* MKSTR(version) */ version);
|
||||
/*
|
||||
* The date this ruby was released
|
||||
*/
|
||||
rb_define_global_const("RUBY_RELEASE_DATE", MKSTR(release_date));
|
||||
rb_define_const(mRuby, "RELEASE_DATE", MKSTR(release_date));
|
||||
/*
|
||||
* The platform for this ruby
|
||||
*/
|
||||
rb_define_global_const("RUBY_PLATFORM", MKSTR(platform));
|
||||
rb_define_const(mRuby, "PLATFORM", MKSTR(platform));
|
||||
/*
|
||||
* The patchlevel for this ruby. If this is a development build of ruby
|
||||
* the patchlevel will be -1
|
||||
*/
|
||||
rb_define_global_const("RUBY_PATCHLEVEL", MKINT(patchlevel));
|
||||
rb_define_const(mRuby, "PATCHLEVEL", MKINT(patchlevel));
|
||||
/*
|
||||
* The GIT commit hash for this ruby.
|
||||
*/
|
||||
rb_define_global_const("RUBY_REVISION", MKSTR(revision));
|
||||
rb_define_const(mRuby, "REVISION", MKSTR(revision));
|
||||
/*
|
||||
* The copyright string for ruby
|
||||
*/
|
||||
rb_define_global_const("RUBY_COPYRIGHT", MKSTR(copyright));
|
||||
rb_define_const(mRuby, "COPYRIGHT", MKSTR(copyright));
|
||||
/*
|
||||
* The engine or interpreter this ruby uses.
|
||||
*/
|
||||
rb_define_global_const("RUBY_ENGINE", /* MKSTR(engine) */ ruby_engine_name);
|
||||
rb_define_const(mRuby, "ENGINE", /* MKSTR(engine) */ ruby_engine_name);
|
||||
ruby_set_script_name(ruby_engine_name);
|
||||
/*
|
||||
* The version of the engine or interpreter this ruby uses.
|
||||
*/
|
||||
rb_define_global_const("RUBY_ENGINE_VERSION", /* MKSTR(version) */ version);
|
||||
rb_define_const(mRuby, "ENGINE_VERSION", /* MKSTR(version) */ version);
|
||||
|
||||
rb_provide("ruby2_keywords.rb");
|
||||
}
|
||||
@ -227,7 +231,7 @@ define_ruby_description(const char *const jit_opt)
|
||||
/*
|
||||
* The full ruby version string, like <tt>ruby -v</tt> prints
|
||||
*/
|
||||
rb_define_global_const("RUBY_DESCRIPTION", /* MKSTR(description) */ description);
|
||||
rb_define_const(mRuby, "DESCRIPTION", /* MKSTR(description) */ description);
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
x
Reference in New Issue
Block a user