mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
resolve conflict
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,9 @@
|
||||
# Language
|
||||
|
||||
mruby is an implementation of the Ruby programming language.
|
||||
These documents are describing the language features and libraries
|
||||
which are provided together with mruby.
|
||||
|
||||
## Built-In Class and Modules
|
||||
|
||||
see *doc/lang/Core.md*
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
c_dir = File.dirname(__FILE__)
|
||||
MRUBY_ROOT = File.expand_path("#{c_dir}/../..")
|
||||
DOC_DIR = File.expand_path(c_dir)
|
||||
|
||||
puts `#{DOC_DIR}/mrbdoc/mrbdoc.rb #{MRUBY_ROOT} #{DOC_DIR}`
|
||||
@@ -0,0 +1,231 @@
|
||||
class MRBDoc
|
||||
SRC_DIR = 'src'
|
||||
MRBLIB_DIR = 'mrblib'
|
||||
|
||||
def analyze_code dir, &block
|
||||
@mrb_files = {}
|
||||
@dir = File.expand_path(dir)
|
||||
|
||||
block.call "MRBDOC\tanalyze #{@dir}"
|
||||
|
||||
analyze(dir) do |progress|
|
||||
block.call progress
|
||||
end
|
||||
end
|
||||
|
||||
def each_file(&block); @mrb_files.each {|k,v| block.call k,v}; end
|
||||
|
||||
def find_c_func(c_func_name)
|
||||
each_file do |file_name, file|
|
||||
c_func = file.c_funcs(c_func_name)
|
||||
return c_func unless c_func.nil?
|
||||
end
|
||||
{}
|
||||
end
|
||||
|
||||
def find_c_file(rb_obj_name, c_func_name)
|
||||
last_file_name_match = ''
|
||||
each_file do |file_name, file|
|
||||
c_func = file.c_funcs(c_func_name)
|
||||
if c_func and file.rb_class(rb_obj_name) or file.rb_module(rb_obj_name)
|
||||
return file_name
|
||||
elsif c_func
|
||||
last_file_name_match = file_name
|
||||
end
|
||||
end
|
||||
last_file_name_match
|
||||
end
|
||||
|
||||
def find_c_file_by_class(name)
|
||||
each_file do |file_name, file|
|
||||
rb_class = file.rb_class(name)
|
||||
return file_name unless rb_class.nil?
|
||||
end
|
||||
'nil'
|
||||
end
|
||||
|
||||
def find_c_file_by_module(name)
|
||||
each_file do |file_name, file|
|
||||
rb_module = file.rb_module(name)
|
||||
return file_name unless rb_module.nil?
|
||||
end
|
||||
'nil'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def analyze dir, &block
|
||||
collect_all_files dir, &block
|
||||
end
|
||||
|
||||
def collect_all_files dir, &block
|
||||
l = lambda {|f| block.call " - #{f.name}"}
|
||||
collect_files(src_code_dir(dir), /\.c$/, &l)
|
||||
collect_files(mrb_code_dir(dir), /\.rb$/, &l)
|
||||
end
|
||||
|
||||
def collect_files dir, rxp, &block
|
||||
Dir.foreach(dir) do |file|
|
||||
next unless file =~ rxp
|
||||
|
||||
file_path = "#{dir}/#{file}"
|
||||
mrb_file = MRBFile.new "#{file_path}"
|
||||
@mrb_files["#{file_path}"] = mrb_file
|
||||
|
||||
block.call mrb_file
|
||||
end
|
||||
end
|
||||
|
||||
def src_code_dir dir; File.expand_path SRC_DIR, dir; end
|
||||
def mrb_code_dir dir; File.expand_path MRBLIB_DIR, dir; end
|
||||
end
|
||||
|
||||
class MRBFile
|
||||
attr_reader :name
|
||||
attr_reader :file
|
||||
|
||||
def initialize mrb_file
|
||||
@file = mrb_file
|
||||
@name = File.basename file
|
||||
@c_funcs = {}
|
||||
@rb_class_c_def = {}
|
||||
@rb_method_c_def = {}
|
||||
@rb_class_method_c_def = {}
|
||||
@rb_module_c_def = {}
|
||||
@last_line = nil
|
||||
@assignments = {}
|
||||
|
||||
@assignments['mrb->object_class'] = 'Object'
|
||||
@assignments['mrb->kernel_module'] = 'Kernel'
|
||||
@assignments['mrb->module_class'] = 'Module'
|
||||
@assignments['mrb->nil_class'] = 'NilClass'
|
||||
@assignments['mrb->true_class'] = 'TrueClass'
|
||||
@assignments['mrb->class_class'] = 'Class'
|
||||
|
||||
analyze
|
||||
end
|
||||
|
||||
def each_class &block
|
||||
@rb_class_c_def.each do |class_name, class_hsh|
|
||||
block.call class_name, class_hsh
|
||||
end
|
||||
end
|
||||
|
||||
def each_method name, &block
|
||||
@rb_method_c_def.each do |met_name, met_hsh|
|
||||
met_name_tmp = met_name.sub /^#{name}_/, ''
|
||||
block.call met_name_tmp, met_hsh if met_hsh[:rb_class] == name
|
||||
end
|
||||
end
|
||||
|
||||
def each_class_method name, &block
|
||||
@rb_class_method_c_def.each do |met_name, met_hsh|
|
||||
met_name_tmp = met_name.sub /^#{name}_/, ''
|
||||
block.call met_name_tmp, met_hsh if met_hsh[:rb_class] == name
|
||||
end
|
||||
end
|
||||
|
||||
def each_module &block
|
||||
@rb_module_c_def.each do |module_name, module_hsh|
|
||||
block.call module_name, module_hsh
|
||||
end
|
||||
end
|
||||
|
||||
def each_core_object &block
|
||||
each_class {|n| block.call n}
|
||||
each_module {|n| block.call n}
|
||||
end
|
||||
|
||||
def c_funcs c_func_name; @c_funcs[c_func_name]; end
|
||||
def rb_class rb_class_name; @rb_class_c_def[rb_class_name]; end
|
||||
def rb_module rb_module_name; @rb_module_c_def[rb_module_name]; end
|
||||
|
||||
private
|
||||
|
||||
def analyze
|
||||
File.open(file).each_line.each_with_index do |line, idx|
|
||||
line_no = idx.succ
|
||||
if c_file?
|
||||
analyze_c_line line, line_no
|
||||
elsif rb_file?
|
||||
analyze_rb_line line, line_no
|
||||
else
|
||||
raise ArgumentError.new "#{file} is a not supported file type"
|
||||
end
|
||||
@last_line = line.strip
|
||||
end
|
||||
end
|
||||
|
||||
def c_file?; (name =~ /\.c$/); end
|
||||
def rb_file?; (name =~ /\.rb$/); end
|
||||
|
||||
RXP_C_VAR = /\s*([^\s]*?)\s*?/
|
||||
RXP_C_STR = /\s*?\"(.*?)\"\s*?/
|
||||
#RXP_C_ISO = /\s*\;\s*[\/\*]*\s*.*?([15\.]{0,3}[0-9\.]*)\s*[\\\\\*]*/
|
||||
RXP_C_ISO = /\s*;\s*[\/\*]*[\sa-zA-Z]*([\d\.]*)[\sa-zA-Z]*[\*\/]*/
|
||||
|
||||
def analyze_c_line line, line_no
|
||||
case line.strip
|
||||
when /^([a-zA-Z\_][a-zA-Z\_0-9]*?)\((.*?)\)\s*?$/
|
||||
# assuming c method definition
|
||||
@c_funcs[$1] = {:line_no => line_no, :args => $2, :return => @last_line}
|
||||
when /mrb_define_class\(.*?\,#{RXP_C_STR}\,#{RXP_C_VAR}\)#{RXP_C_ISO}/
|
||||
# assuming ruby class definition in c
|
||||
class_name = $1.clone
|
||||
iso = $3.clone
|
||||
iso.strip!
|
||||
@rb_class_c_def[class_name] = {:c_object => $2, :iso => iso}
|
||||
assigns = line.split '='
|
||||
if assigns.size > 1
|
||||
assigns[0..-2].each do |v|
|
||||
@assignments[v.strip] = class_name
|
||||
end
|
||||
end
|
||||
when /mrb_define_module\(.*?\,#{RXP_C_STR}\)#{RXP_C_ISO}/
|
||||
# assuming ruby class definition in c
|
||||
module_name = $1.clone
|
||||
iso = $2.clone
|
||||
iso.strip!
|
||||
@rb_module_c_def[module_name] = {:iso => iso}
|
||||
assigns = line.split '='
|
||||
if assigns.size > 1
|
||||
assigns[0..-2].each do |v|
|
||||
@assignments[v.strip] = module_name
|
||||
end
|
||||
end
|
||||
when /mrb_define_method\(.*?\,#{RXP_C_VAR}\,#{RXP_C_STR}\,#{RXP_C_VAR}\,#{RXP_C_VAR}\)#{RXP_C_ISO}/
|
||||
# assuming ruby method definition in c
|
||||
name = $1.clone
|
||||
name = resolve_obj(name)
|
||||
iso = $5.clone
|
||||
iso.strip!
|
||||
@rb_method_c_def["#{name}_#{$2}"] = {:c_func => $3, :args => $4, :rb_class => name, :iso => iso}
|
||||
when /mrb_define_class_method\(.*?\,#{RXP_C_VAR}\,#{RXP_C_STR}\,#{RXP_C_VAR}\,#{RXP_C_VAR}\)#{RXP_C_ISO}/
|
||||
# assuming ruby class method definition in c
|
||||
class_name = $1.clone
|
||||
class_name = resolve_obj(class_name)
|
||||
iso = $5.clone
|
||||
iso.strip!
|
||||
@rb_class_method_c_def["#{class_name}_#{$2}"] = {:c_func => $3, :args => $4, :rb_class => class_name, :iso => iso}
|
||||
when /mrb_name_class\(.*?\,#{RXP_C_VAR}\,\s*mrb_intern\(.*?,#{RXP_C_STR}\)\)#{RXP_C_ISO}/
|
||||
class_name = $2.clone
|
||||
iso = $3.clone
|
||||
iso.strip!
|
||||
@rb_class_c_def[class_name] = {:c_object => $1, :iso => iso}
|
||||
@assignments[$1] = class_name
|
||||
when /mrb_include_module\(.*?\,#{RXP_C_VAR}\,\s*mrb_class_get\(.*?\,#{RXP_C_STR}\)\)/
|
||||
class_name = resolve_obj($1)
|
||||
mod = $2.clone
|
||||
@rb_class_c_def[class_name][:include] = [] unless @rb_class_c_def[class_name].has_key? :include
|
||||
@rb_class_c_def[class_name][:include] << mod
|
||||
end
|
||||
end
|
||||
|
||||
def analyze_rb_line line, line_no
|
||||
|
||||
end
|
||||
|
||||
def resolve_obj c_var
|
||||
@assignments[c_var]
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,113 @@
|
||||
class MRBDoc
|
||||
def write_documentation dir, &block
|
||||
block.call "MRBDOC\twrite to #{File.expand_path(dir)}"
|
||||
|
||||
write(dir) do |progress|
|
||||
block.call progress
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def write dir
|
||||
File.open(File.expand_path('Core.md', dir), 'w+') do |io|
|
||||
print_core_classes(io)
|
||||
print_core_modules(io)
|
||||
end
|
||||
end
|
||||
|
||||
def get_core_list id
|
||||
core_list = {}
|
||||
each_file do |file_path, mrb_file|
|
||||
mrb_file.send(id) do |name, cls_hsh|
|
||||
core_list[name] = {:data => cls_hsh, :methods => {}, :class_methods => {}}
|
||||
mrb_file.each_method name do |met_name, met_hsh|
|
||||
core_list[name][:methods][met_name] = met_hsh
|
||||
end
|
||||
mrb_file.each_class_method name do |met_name, met_hsh|
|
||||
core_list[name][:class_methods][met_name] = met_hsh
|
||||
end
|
||||
end
|
||||
end
|
||||
core_list
|
||||
end
|
||||
|
||||
def print_core_classes(io)
|
||||
core_list = get_core_list :each_class
|
||||
io.puts "# Core Classes\n\n"
|
||||
core_list.sort.each do |name, hsh|
|
||||
file = find_c_file_by_class(name)
|
||||
file = file.split("#{@dir}/")[1]
|
||||
iso = hsh[:data][:iso]
|
||||
iso = 'n/a' if iso.nil? or iso == ''
|
||||
mixins = hsh[:data][:include].join(', ') unless hsh[:data][:include].nil?
|
||||
mixins = 'n/a' if mixins.nil? or mixins == ''
|
||||
|
||||
io.puts <<CLASS
|
||||
## #{name}
|
||||
|
||||
ISO Code | Mixins | Source File
|
||||
--- | --- | ---
|
||||
#{iso} | #{mixins} | #{file}
|
||||
|
||||
CLASS
|
||||
print_class_methods(io, hsh)
|
||||
print_methods(io, hsh)
|
||||
end
|
||||
end
|
||||
|
||||
def print_core_modules(io)
|
||||
core_list = get_core_list :each_module
|
||||
io.puts "# Core Modules\n\n"
|
||||
core_list.sort.each do |name, hsh|
|
||||
file = find_c_file_by_module(name)
|
||||
file = file.split("#{@dir}/")[1]
|
||||
iso = hsh[:data][:iso]
|
||||
iso = 'n/a' if iso.nil? or iso == ''
|
||||
|
||||
io.puts <<CLASS
|
||||
## #{name}
|
||||
|
||||
ISO Code | Source File
|
||||
--- | ---
|
||||
#{iso} | #{file}
|
||||
|
||||
CLASS
|
||||
print_class_methods(io, hsh)
|
||||
print_methods(io, hsh)
|
||||
end
|
||||
end
|
||||
|
||||
def print_methods(io, hsh)
|
||||
return unless hsh[:methods].size > 0
|
||||
io.puts "### Methods\n\n"
|
||||
hsh[:methods].sort.each do |met_name, met_hsh|
|
||||
print_method(io, met_name, met_hsh)
|
||||
end
|
||||
end
|
||||
|
||||
def print_class_methods(io, hsh)
|
||||
return unless hsh[:class_methods].size > 0
|
||||
io.puts "### Class Methods\n\n"
|
||||
hsh[:class_methods].sort.each do |met_name, met_hsh|
|
||||
print_method(io, met_name, met_hsh)
|
||||
end
|
||||
end
|
||||
|
||||
def print_method(io, met_name, met_hsh)
|
||||
line_no = find_c_func(met_hsh[:c_func])[:line_no]
|
||||
file = find_c_file(met_hsh[:rb_class], met_hsh[:c_func])
|
||||
file = file.split("#{@dir}/")[1]
|
||||
iso = met_hsh[:iso]
|
||||
iso = 'n/a' if iso.nil? or iso == ''
|
||||
|
||||
io.puts <<METHOD
|
||||
#### #{met_name}
|
||||
|
||||
ISO Code | Source File | C Function | Line
|
||||
--- | --- | ---
|
||||
#{iso} | #{file} | #{met_hsh[:c_func]} | #{line_no}
|
||||
|
||||
METHOD
|
||||
end
|
||||
end
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
$: << File.dirname(__FILE__) + '/lib'
|
||||
|
||||
require 'mrbdoc_analyze'
|
||||
require 'mrbdoc_docu'
|
||||
|
||||
MRUBY_ROOT = ARGV[0]
|
||||
DOC_ROOT = ARGV[1]
|
||||
|
||||
raise ArgumentError.new 'mruby root missing!' if MRUBY_ROOT.nil?
|
||||
raise ArgumentError.new 'doc root missing!' if DOC_ROOT.nil?
|
||||
|
||||
mrbdoc = MRBDoc.new
|
||||
|
||||
mrbdoc.analyze_code MRUBY_ROOT do |progress|
|
||||
puts progress
|
||||
end
|
||||
|
||||
mrbdoc.write_documentation DOC_ROOT do |progress|
|
||||
puts progress
|
||||
end
|
||||
+1
-1
@@ -1054,7 +1054,7 @@ mrb_init_array(mrb_state *mrb)
|
||||
{
|
||||
struct RClass *a;
|
||||
|
||||
a = mrb->array_class = mrb_define_class(mrb, "Array", mrb->object_class);
|
||||
a = mrb->array_class = mrb_define_class(mrb, "Array", mrb->object_class); /* 15.2.12 */
|
||||
MRB_SET_INSTANCE_TT(a, MRB_TT_ARRAY);
|
||||
|
||||
mrb_define_class_method(mrb, a, "[]", mrb_ary_s_create, MRB_ARGS_ANY()); /* 15.2.12.4.1 */
|
||||
|
||||
+3
-3
@@ -1944,9 +1944,9 @@ mrb_init_class(mrb_state *mrb)
|
||||
|
||||
/* name each classes */
|
||||
name_class(mrb, bob, mrb_intern_lit(mrb, "BasicObject"));
|
||||
name_class(mrb, obj, mrb_intern_lit(mrb, "Object"));
|
||||
name_class(mrb, mod, mrb_intern_lit(mrb, "Module"));
|
||||
name_class(mrb, cls, mrb_intern_lit(mrb, "Class"));
|
||||
name_class(mrb, obj, mrb_intern_lit(mrb, "Object")); /* 15.2.1 */
|
||||
name_class(mrb, mod, mrb_intern_lit(mrb, "Module")); /* 15.2.2 */
|
||||
name_class(mrb, cls, mrb_intern_lit(mrb, "Class")); /* 15.2.3 */
|
||||
|
||||
MRB_SET_INSTANCE_TT(cls, MRB_TT_CLASS);
|
||||
mrb_define_method(mrb, bob, "initialize", mrb_bob_init, MRB_ARGS_NONE());
|
||||
|
||||
+1
-1
@@ -9,5 +9,5 @@
|
||||
void
|
||||
mrb_init_comparable(mrb_state *mrb)
|
||||
{
|
||||
mrb_define_module(mrb, "Comparable");
|
||||
mrb_define_module(mrb, "Comparable"); /* 15.3.3 */
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,6 +9,6 @@
|
||||
void
|
||||
mrb_init_enumerable(mrb_state *mrb)
|
||||
{
|
||||
mrb_define_module(mrb, "Enumerable");
|
||||
mrb_define_module(mrb, "Enumerable"); /* 15.3.2 */
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -826,7 +826,7 @@ mrb_init_hash(mrb_state *mrb)
|
||||
{
|
||||
struct RClass *h;
|
||||
|
||||
h = mrb->hash_class = mrb_define_class(mrb, "Hash", mrb->object_class);
|
||||
h = mrb->hash_class = mrb_define_class(mrb, "Hash", mrb->object_class); /* 15.2.13 */
|
||||
MRB_SET_INSTANCE_TT(h, MRB_TT_HASH);
|
||||
|
||||
mrb_define_method(mrb, h, "[]", mrb_hash_aget, MRB_ARGS_REQ(1)); /* 15.2.13.4.2 */
|
||||
|
||||
+1
-1
@@ -1139,7 +1139,7 @@ mrb_init_kernel(mrb_state *mrb)
|
||||
{
|
||||
struct RClass *krn;
|
||||
|
||||
krn = mrb->kernel_module = mrb_define_module(mrb, "Kernel");
|
||||
krn = mrb->kernel_module = mrb_define_module(mrb, "Kernel"); /* 15.3.1 */
|
||||
mrb_define_class_method(mrb, krn, "block_given?", mrb_f_block_given_p_m, MRB_ARGS_NONE()); /* 15.3.1.2.2 */
|
||||
mrb_define_class_method(mrb, krn, "global_variables", mrb_f_global_variables, MRB_ARGS_NONE()); /* 15.3.1.2.4 */
|
||||
mrb_define_class_method(mrb, krn, "iterator?", mrb_f_block_given_p_m, MRB_ARGS_NONE()); /* 15.3.1.2.5 */
|
||||
|
||||
+4
-4
@@ -1315,7 +1315,7 @@ mrb_init_numeric(mrb_state *mrb)
|
||||
struct RClass *numeric, *integer, *fixnum, *fl;
|
||||
|
||||
/* Numeric Class */
|
||||
numeric = mrb_define_class(mrb, "Numeric", mrb->object_class);
|
||||
numeric = mrb_define_class(mrb, "Numeric", mrb->object_class); /* 15.2.7 */
|
||||
|
||||
mrb_define_method(mrb, numeric, "**", num_pow, MRB_ARGS_REQ(1));
|
||||
mrb_define_method(mrb, numeric, "/", num_div, MRB_ARGS_REQ(1)); /* 15.2.8.3.4 */
|
||||
@@ -1323,9 +1323,9 @@ mrb_init_numeric(mrb_state *mrb)
|
||||
mrb_define_method(mrb, numeric, "<=>", num_cmp, MRB_ARGS_REQ(1)); /* 15.2.9.3.6 */
|
||||
|
||||
/* Integer Class */
|
||||
integer = mrb_define_class(mrb, "Integer", numeric);
|
||||
integer = mrb_define_class(mrb, "Integer", numeric); /* 15.2.8 */
|
||||
mrb_undef_class_method(mrb, integer, "new");
|
||||
mrb_define_method(mrb, integer, "to_i", int_to_i, MRB_ARGS_NONE()); /* 15.2.8.3.24 */
|
||||
mrb_define_method(mrb, integer, "to_i", int_to_i, MRB_ARGS_NONE()); /* 15.2.8.3.24 */
|
||||
mrb_define_method(mrb, integer, "to_int", int_to_i, MRB_ARGS_NONE());
|
||||
|
||||
fixnum = mrb->fixnum_class = mrb_define_class(mrb, "Fixnum", integer);
|
||||
@@ -1348,7 +1348,7 @@ mrb_init_numeric(mrb_state *mrb)
|
||||
mrb_define_method(mrb, fixnum, "divmod", fix_divmod, MRB_ARGS_REQ(1)); /* 15.2.8.3.30 (x) */
|
||||
|
||||
/* Float Class */
|
||||
fl = mrb->float_class = mrb_define_class(mrb, "Float", numeric);
|
||||
fl = mrb->float_class = mrb_define_class(mrb, "Float", numeric); /* 15.2.9 */
|
||||
mrb_undef_class_method(mrb, fl, "new");
|
||||
mrb_define_method(mrb, fl, "+", flo_plus, MRB_ARGS_REQ(1)); /* 15.2.9.3.1 */
|
||||
mrb_define_method(mrb, fl, "-", flo_minus, MRB_ARGS_REQ(1)); /* 15.2.9.3.2 */
|
||||
|
||||
+1
-1
@@ -201,7 +201,7 @@ mrb_init_proc(mrb_state *mrb)
|
||||
call_irep->iseq = call_iseq;
|
||||
call_irep->ilen = 1;
|
||||
|
||||
mrb->proc_class = mrb_define_class(mrb, "Proc", mrb->object_class);
|
||||
mrb->proc_class = mrb_define_class(mrb, "Proc", mrb->object_class); /* 15.2.17 */
|
||||
MRB_SET_INSTANCE_TT(mrb->proc_class, MRB_TT_PROC);
|
||||
|
||||
mrb_define_method(mrb, mrb->proc_class, "initialize", mrb_proc_initialize, MRB_ARGS_NONE());
|
||||
|
||||
+1
-1
@@ -400,7 +400,7 @@ mrb_init_range(mrb_state *mrb)
|
||||
{
|
||||
struct RClass *r;
|
||||
|
||||
r = mrb_define_class(mrb, "Range", mrb->object_class);
|
||||
r = mrb_define_class(mrb, "Range", mrb->object_class); /* 15.2.14 */
|
||||
MRB_SET_INSTANCE_TT(r, MRB_TT_RANGE);
|
||||
|
||||
mrb_define_method(mrb, r, "begin", mrb_range_beg, MRB_ARGS_NONE()); /* 15.2.14.4.3 */
|
||||
|
||||
+1
-1
@@ -2586,7 +2586,7 @@ mrb_init_string(mrb_state *mrb)
|
||||
{
|
||||
struct RClass *s;
|
||||
|
||||
s = mrb->string_class = mrb_define_class(mrb, "String", mrb->object_class);
|
||||
s = mrb->string_class = mrb_define_class(mrb, "String", mrb->object_class); /* 15.2.10 */
|
||||
MRB_SET_INSTANCE_TT(s, MRB_TT_STRING);
|
||||
|
||||
mrb_define_method(mrb, s, "bytesize", mrb_str_bytesize, MRB_ARGS_NONE());
|
||||
|
||||
+1
-1
@@ -473,7 +473,7 @@ mrb_init_symbol(mrb_state *mrb)
|
||||
{
|
||||
struct RClass *sym;
|
||||
|
||||
sym = mrb->symbol_class = mrb_define_class(mrb, "Symbol", mrb->object_class);
|
||||
sym = mrb->symbol_class = mrb_define_class(mrb, "Symbol", mrb->object_class); /* 15.2.11 */
|
||||
|
||||
mrb_define_method(mrb, sym, "===", sym_equal, MRB_ARGS_REQ(1)); /* 15.2.11.3.1 */
|
||||
mrb_define_method(mrb, sym, "id2name", mrb_sym_to_s, MRB_ARGS_NONE()); /* 15.2.11.3.2 */
|
||||
|
||||
Reference in New Issue
Block a user