我将mruby 1.3.0 (2017-7-4)与build_config.rb结合使用
MRuby::Build.new do |conf|
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
enable_debug
conf.gembox 'default'
conf.gem :git => 'https://github.com/mattn/mruby-uv'
conf.gem :git => 'https://github.com/mattn/mruby-http'
conf.gem :git => 'https://github.com/iij/mruby-socket'
conf.gem :git => 'https://github.com/luisbebop/mruby-polarssl.git'
conf.gem :git => 'https://github.com/iij/mruby-digest'
conf.gem :git => 'https://github.com/iij/mruby-pack'
conf.gem :git => 'https://github.com/matsumoto-r/mruby-simplehttp.git'
conf.gem :git => 'https://github.com/matsumotory/mruby-httprequest'
conf.gem :git => 'https://github.com/iij/mruby-aws-s3.git'
end
MRuby::Build.new('host-debug') do |conf|
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
enable_debug
conf.gembox 'default'
conf.cc.defines = %w(MRB_ENABLE_DEBUG_HOOK)
conf.gem :core => "mruby-bin-debugger"
end
MRuby::Build.new('test') do |conf|
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
enable_debug
conf.enable_bintest
conf.enable_test
conf.gembox 'default'
end我发现const_get方法在红宝石和红宝石中不同。在ruby (2.4.0p0)中,Class.const_get('Fixnum')返回常量Fixnum,而在mruby Class.const_get('Fixnum')中,返回错误uninitialized constant Class::Fixnum (NameError)。
然后,我尝试了另一个例子:class Hoge; end; class Hoge::Fuga; end。在红宝石中,Class.const_get('Hoge::Fuga')和Hoge.const_get('Fuga')都给出了常数Hoge::Fuga。在mruby中,只有Hoge.const_get('Fuga')才返回Hoge::Fuga。
发布于 2017-12-18 10:10:27
mruby的Module#const_get类似于CRuby中的第二个参数(命名为inherit,用于搜索超类)。如果您使用Object.const_get(:Integer),那么它的行为应该与您在mruby和CRuby中所期望的相同。
https://stackoverflow.com/questions/47810173
复制相似问题