summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-metaprog
AgeCommit message (Collapse)Author
2021-06-03add a few regressions test from #2313Yukihiro "Matz" Matsumoto
The code was contributed from Carson McDonald (@carsonmcdonald)
2021-02-22Added other methods for `Binding`dearblue
- Added to `mruby-binding-core` - `Binding#local_variable_defined?` - `Binding#local_variable_get` - `Binding#local_variable_set` - `Binding#local_variables` - `Binding#receiver` - `Binding#source_location` - `Binding#inspect` - Added to `mruby-proc-binding` - `Proc#binding` The reason for separating `Proc#binding` is that core-mrbgems has a method that returns a closure object to minimize possible problems with being able to manipulate internal variables. By separating it as different mrbgem, each user can judge this problem and incorporate it arbitrarily.
2021-02-22Adjustment of the current HEAD and bindings, and separationdearblue
Make changes to make `Binding` work. At the same time, it separates `Binding#eval`, which depends on `mruby-eval`, from `mruby-binding-core`.
2021-02-20metaprog.c: fix a `methods()` bug with `false` argument; fix #5351Yukihiro "Matz" Matsumoto
2021-02-20metaprog.c: remove unused argument from a private function.Yukihiro "Matz" Matsumoto
2021-01-26Revert "Minimize the changes in #5277"Yukihiro "Matz" Matsumoto
This reverts commit dc51d89ac22acc60b9bfeed87115863565b74085.
2021-01-22Minimize the changes in #5277Yukihiro "Matz" Matsumoto
Instead of including `mruby/presym.h` everywhere, we provided the fallback `mruby/presym.inc` under `include/mruby` directory, and specify `-I<build-dir>/include` before `-I<top-dir>/include` in `presym.rake`. So even when someone drops `-I<build-dir>/include` in compiler options, it just compiles without failure.
2021-01-11Avoid including `presym.inc` in existing header filesKOBAYASHI Shuji
Addressed an issue where existing programs linking `libmruby.a` could only be built by adding `<build-dir>/include` to compiler's include path.
2020-11-21Improved `Object#define_singleton_method`dearblue
Integrate the implementation with `Module#define_method`. - Introduce the internal function `mrb_mod_define_method_m()` (no static) - The `Object#define_singleton_method` method can now accept a second argument
2020-11-14Don't use private structs with `mrb_mt_foreach()`dearblue
The `MRB_API` function `mrb_mt_foreach()` previously used the private structure `struct mt_elem`. Therefore, use `mrb_method_t` instead.
2020-11-02ISO C does not allow extra ';' outside of a function; #5107Yukihiro "Matz" Matsumoto
2020-10-22Prohibit array changes by "a"/"*" specifier of `mrb_get_args()`dearblue
The "a"/"*" specifier of the `mrb_get_args()` function will now return `const mrb_value *`. This is because it is difficult for the caller to check if it is an array object and write-barrier if necessary. And it requires calling `mrb_ary_modify()` on the unmodified array object, which is also difficult (this is similar to #5087).
2020-10-12Replace the implementation of method tables in classes/modules.Yukihiro "Matz" Matsumoto
They are basically the copy of instance variable tables. On my Linux box, memory consumption of `mrbtest` measured by `valgrind` is: - old: 17,683,830 bytes - new: 14,283,749 bytes
2020-10-12Integrate `Fixnum` class into `Integer` classdearblue
* The `Fixnum` constant is now an alias for the `Integer` class. * Remove `struct mrb_state::fixnum_class` member. If necessary, use `struct mrb_state::integer_class` instead.
2020-10-12You don't need to keep index in local variables info in `irep`.Yukihiro "Matz" Matsumoto
2020-10-12Generate C struct from `irep` instead of binary dump.Yukihiro "Matz" Matsumoto
2020-10-12Constify `irep` members.Yukihiro "Matz" Matsumoto
- `pool` - `syms` - `reps`
2020-10-12Use `mrb_funcall_id()` extensively.Yukihiro "Matz" Matsumoto
Except for support files e.g. `mruby-test/driver.c`, which are not target of symbol collection via `rake gensym`.
2020-06-09Remove `mrb_assert()` in `Module.nesting`dearblue
The following code was causing SIGSEGV: ```ruby Module.method(:nesting).call ```
2020-05-31Get local variable names from orphan block; ref #3710dearblue
2020-03-30Fix NULL pointer dereferences in mrb_local_variables; fix #4955dearblue
However, the behavior of `#call` on the method object of `local_variables` is not corrected.
2019-12-14Fix for `#methods` to include methods that were `undef`dearblue
If `#methods` traverse the super class, it includes the methods that were does `undef` in the subclass. Before patched: ```terminal % bin/mruby -e 'p Module.instance_methods - Class.instance_methods' [] ``` After patched: ```terminal % bin/mruby -e 'p Module.instance_methods - Class.instance_methods' [:append_features, :extend_object] ```
2019-11-15Fix argument specs to `Kernel`KOBAYASHI Shuji
2019-09-25Rename symbol-to-string functions; close #4684Yukihiro "Matz" Matsumoto
* mrb_sym2name -> mrb_sym_name * mrb_sym2name_len -> mrb_sym_name_len * mrb_sym2str -> mrb_sym_str
2019-09-20Add optional argument to `Module#class_variables`.Yukihiro "Matz" Matsumoto
2019-09-18Remove `mrb_get_args(mrb, "")`; ref 30f37872KOBAYASHI Shuji
2019-09-16Entrust "no block given" error to `mrb_get_args()`dearblue
Some error messages will be changed.
2019-08-05Use new specifiers/modifiers of `mrb_vfromat()`KOBAYASHI Shuji
The binary sizes (gems are only `mruby-bin-mruby`) are reduced slightly in my environment than before the introduction of new specifiers/modifiers (5116789a) with this change. ------------+-------------------+-------------------+-------- BINARY | BEFORE (5116789a) | AFTER (This PR) | RATIO ------------+-------------------+-------------------+-------- mruby | 593416 bytes | 593208 bytes | -0.04% libmruby.a | 769048 bytes | 767264 bytes | -0.23% ------------+-------------------+-------------------+-------- BTW, I accidentally changed `tasks/toolchains/visualcpp.rake` at #4613, so I put it back.
2019-06-27Add modification tests for immediate valueKOBAYASHI Shuji
2019-06-22Merge pull request #4518 from ↵Yukihiro "Matz" Matsumoto
shuujii/add-ISO-section-number-to-Kernel-local_variables Add ISO section number to `Kernel.#local_variables` [ci skip]
2019-06-21Move `Kernel#__send__` test to core from `mruby-metaprog`KOBAYASHI Shuji
2019-06-20Add ISO section number to `Kernel.#local_variables` [ci skip]KOBAYASHI Shuji
2019-06-16Fix cvar, ivar, const and method can be removed to frozen objectKOBAYASHI Shuji
2019-06-10`Kernel#global_variables` should not include undefined `$1`-`$9`KOBAYASHI Shuji
- They are not include in Ruby. - Appear in duplicate when `$1`-`$9` are defined.
2019-06-07Remove `Kernel#global_variables` from coreKOBAYASHI Shuji
This method is defined in `mruby-metaprog` gem.
2019-05-27Make some functions static in `mrbgems/mruby-metaprog/src/metaprog.c`KOBAYASHI Shuji
2019-05-26Move `mrb_mod_s_nesting()` to `mruby-metaprog` gem from the coreKOBAYASHI Shuji
2019-04-25Singleton class of frozen object should be frozenKOBAYASHI Shuji
Before this patch: p (class << Object.new.freeze; self end).frozen? #=> false sc = class << (o=Object.new); self end; o.freeze; p sc.frozen? #=> false After this patch / Ruby: p (class << Object.new.freeze; self end).frozen? #=> true sc = class << (o=Object.new); self end; o.freeze; p sc.frozen? #=> true
2019-04-24Fix modiying class variable to frozen class/moduleKOBAYASHI Shuji
2019-03-17Fix class/instance variable name validationKOBAYASHI Shuji
- `@@?` etc are invalid class variable name. - `@1` etc are invalid instance variable name.
2019-03-11Reduce `String` creation in `check_(cv|const)_name_sym`KOBAYASHI Shuji
2019-02-19Use more appropriate assertion methodsKOBAYASHI Shuji
2018-09-01Move `Kernel#send` to `mruby-metaprog` gem.Yukihiro "Matz" Matsumoto
But `BasicObject#__send__` is still available from the core.
2018-08-30Separate meta-programming features to `mruby-metaprog` gem.Yukihiro "Matz" Matsumoto
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.