Permalink
Browse files

Separate meta-programming features to `mruby-metaprog` gem.

We assume meta-programming is less used in embedded environments.
We have moved following methods:

 * Kernel module
   global_variables, local_variables, singleton_class,
   instance_variables, instance_variables_defined?, instance_variable_get,
   instance_variable_set, methods, private_methods, public_methods,
   protected_methods, singleton_methods, define_singleton_methods

 * Module class
   class_variables, class_variables_defined?, class_variable_get,
   class_variable_set, remove_class_variable, included_modules,
   instance_methods, remove_method, method_removed, constants

 * Module class methods
   constants, nesting

Note:
Following meta-programming methods are kept in the core:

 * Module class
   alias_method, undef_method, ancestors, const_defined?, const_get,
   const_set, remove_const, method_defined?, define_method

 * Toplevel object
   define_method

`mruby-metaprog` gem is linked by default (specified in default.gembox).
When it is removed, it will save 40KB (stripped:8KB) on x86-64
environment last time I measured.
  • Loading branch information...
matz committed Aug 30, 2018
1 parent 75a01af commit e471d37ca5f1422860a1eaa81d4c9f1b3c8b6aed
View
@@ -1,4 +1,7 @@
MRuby::GemBox.new do |conf|
# Meta-programming features
conf.gem :core => "mruby-metaprog"
# Use standard IO/File class
conf.gem :core => "mruby-io"
@@ -67,7 +67,7 @@
`#{cmd('mruby-strip')} -l #{without_lv.path}`
assert_true without_lv.size < with_lv.size
assert_equal '[:a, :b]', `#{cmd('mruby')} -b #{with_lv.path}`.chomp
assert_equal '[]', `#{cmd('mruby')} -b #{without_lv.path}`.chomp
#
# assert_equal '[:a, :b]', `#{cmd('mruby')} -b #{with_lv.path}`.chomp
# assert_equal '[]', `#{cmd('mruby')} -b #{without_lv.path}`.chomp
end
@@ -26,7 +26,7 @@ class Inner; end
assert 'Module#singleton_class?' do
mod = Module.new
cls = Class.new
scl = cls.singleton_class
scl = (class <<cls; self; end)
assert_false mod.singleton_class?
assert_false cls.singleton_class?
@@ -58,7 +58,7 @@
assert('String instance_eval') do
obj = Object.new
obj.instance_variable_set :@test, 'test'
obj.instance_eval{ @test = 'test' }
assert_raise(ArgumentError) { obj.instance_eval(0) { } }
assert_raise(ArgumentError) { obj.instance_eval('0', 'test', 0, 'test') }
assert_equal(['test.rb', 10]) { obj.instance_eval('[__FILE__, __LINE__]', 'test.rb', 10)}
@@ -35,7 +35,7 @@ def assert_nothing_raised(*exp)
end
assert('IO', '15.2.20.3') do
assert_include(IO.included_modules, Enumerable)
assert_include(IO.ancestors, Enumerable)
end
assert('IO.open', '15.2.20.4.1') do
@@ -0,0 +1,5 @@
MRuby::Gem::Specification.new('mruby-metaprog') do |spec|
spec.license = 'MIT'
spec.author = 'mruby developers'
spec.summary = 'Meta-programming features for mruby'
end
Oops, something went wrong.

0 comments on commit e471d37

Please sign in to comment.