summaryrefslogtreecommitdiffhomepage
path: root/src/class.c
AgeCommit message (Collapse)Author
2019-05-03Simplify conversion process for `i` in `mrb_get_args()`KOBAYASHI 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-10Remove too aggressive `initialize` call in `mrb_instance_new`.Yukihiro "Matz" Matsumoto
2019-04-10Remove `MRB_API` from `mrb_instance_new`.Yukihiro "Matz" Matsumoto
2019-04-09Extract frozen checking to functionKOBAYASHI Shuji
2019-04-05`Module#alias_method` should return `self` in ISO standardKOBAYASHI Shuji
2019-04-01Avoid keeping pointers from `mrb_sym2name_len()`; fix #4342Yukihiro "Matz" Matsumoto
The addresses for packed inline symbols reference `mrb->symbuf` that could be overridden by the later call of `mrb_sym2name_len`. Since file names in call stack information are kept as symbols, keeping the address in the C structures could cause problems like #4342. This changes small incompatible changes in function prototypes: * `mrb_parser_get_filename`: return value changed to `mrb_sym`. * `mrb_debug_get_filename`: add `mrb_state*` as a first argument. * `mrb_debug_get_line`: ditto. I believe above functions are almost internal, and no third-party mrbgem use them.
2019-03-26Fix missing `MRB_API` prefix for functions below; clse #4267Yukihiro "Matz" Matsumoto
Functions to add prototypes to headers: * mrb_ary_splice() * mrb_notimplement() * mrb_vformat() * mrb_cstr_to_dbl() * mrb_cstr_to_inum() Functions to be made `static` (`MRB_API` was not needed): * mrb_mod_module_function() * mrb_obj_hash() * mrb_str_len_to_inum() Functions to remove `MRB_API` from definitions (referenced from within `libmruby`): * mrb_mod_cv_defined() * mrb_mod_cv_get() * mrb_f_send()
2019-03-14Fix constant name validationKOBAYASHI Shuji
`X!` etc are invalid constant name.
2019-03-11Reduce `String` creation in `check_(cv|const)_name_sym`KOBAYASHI Shuji
2019-03-03Extract similar code fragment to method in `src/class.c`KOBAYASHI Shuji
2019-02-06Reduce invocation of `mrb_convert_type()` from `mrb_str_to_str()`.Yukihiro "Matz" Matsumoto
2018-11-19Removed `to_hash` conversion method.Yukihiro "Matz" Matsumoto
2018-11-19Removed `to_ary` conversion method.Yukihiro "Matz" Matsumoto
2018-11-19Remove implicit conversion using `to_str` method; fix #3854Yukihiro "Matz" Matsumoto
We have added internal convenience method `__to_str` which does string type check. The issue #3854 was fixed but fundamental flaw of lack of stack depth check along with fibers still remains. Use `MRB_GC_FIXED_ARENA` for workaround.
2018-09-20Merge branch 'assign-anon-class-name' of https://github.com/dearblue/mruby ↵Yukihiro "Matz" Matsumoto
into dearblue-assign-anon-class-name
2018-09-20Merge pull request #4112 from dearblue/fix-outer-module-nameYukihiro "Matz" Matsumoto
Fix outer module name
2018-09-08Fix outer module namedearblue
example: a = Module.new a::B = Module.new p [a, a::B] # => [#<Module:0x801825890>, #<Class:0x801825890>::B] # => [#<Module:0x801825890>, #<Module:0x801825890>::B] (Fixed)
2018-09-07Fix to not define outer when outer is itself.dearblue
example: a = Class.new a::A = a
2018-09-07Undesirable line splitdearblue
2018-09-04Need more precise constant name check.Yukihiro "Matz" Matsumoto
This change was inspired by [ruby-bugs#7573]
2018-09-01Fix ISO/JIS section numbers.Yukihiro "Matz" Matsumoto
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.
2018-08-25Rename ambiguous function names.Yukihiro "Matz" Matsumoto
`mrb_iv_p` -> `mrb_iv_name_sym_p` `mrb_iv_check` -> `mrb_iv_name_sym_check`
2018-08-25Reorganize flags values for classes; fix #3975Yukihiro "Matz" Matsumoto
Renamed flag macro names as well: `MRB_FLAG_IS_FROZEN` -> `MRB_FL_OBJ_FROZEN` `MRB_FLAG_IS_PREPENDED` -> `MRB_FL_CLASS_IS_PREPENDED` `MRB_FLAG_IS_ORIGIN` -> `MRB_FL_CLASS_IS_ORIGIN` `MRB_FLAG_IS_INHERITED` -> `MRB_FL_CLASS_IS_INHERITED`
2018-07-30New bytecode implementation of mruby VM.Yukihiro "Matz" Matsumoto
2018-06-08`mrb_class_real()` did not work for `BasicObject`; fix #4037Yukihiro "Matz" Matsumoto
2018-03-16Update `mrb_get_args` reference comment; ref #3963Yukihiro "Matz" Matsumoto
2018-03-04fix && to &! in mrb_get_args()dearblue
2018-03-04add forced block arguments feature to mrb_get_argsdearblue
2018-01-17Typo fixed.Yukihiro "Matz" Matsumoto
2017-12-20Should not overwrite `MRB_PROC_TARGET_CLASS(p)` if `p` has env; fix #3905Yukihiro "Matz" Matsumoto
2017-12-13Fixed wrong `MRB_WITHOUT_FLOAT` condition; ref #3827Yukihiro "Matz" Matsumoto
2017-12-12Modifying frozen objects will raise `FrozenError`.Yukihiro "Matz" Matsumoto
`FrozenError` is a subclass of `RuntimeError` which used to be raised. [Ruby2.5]
2017-12-06`mrb_method_search_vm()` should gives the defined class.Yukihiro "Matz" Matsumoto
Otherwise `super` may call a wrong method.
2017-11-20Add `MRB_METHOD_TABLE_INLINE` option.Yukihiro "Matz" Matsumoto
Now the method tables (in classes/modules and caches) keeps C function pointers without wrapping in `struct RProc` objects. For the sake of portability, `mrb_method_t` is represented by the struct and union, but if the most significant bit of the pointer is not used by the platform, `mrb_method_t` should be packed in `uintptr_t` to reduce memory usage. `MRB_METHOD_TABLE_INLINE` is turned on by default for linux.
2017-11-04Merge branch 'mrb_without_float' of https://github.com/pandax381/mruby into ↵Yukihiro "Matz" Matsumoto
pandax381-mrb_without_float
2017-11-04Reimplement `block_given?`; ref #3841Yukihiro "Matz" Matsumoto
Make `block_given?` to search for the top of the scope first. The top of the scope means either: * the top method body * the enclosing class body * the top-level The special case is the method defined by `define_method` with a block as in #3841. In cases like this, the method body (given by a block) is not considered as the top of the scope. You need to use `&block` in the block parameter if you want to know if a block is given to the method. This commit also changes the behavior of `MRB_PROC_SCOPE` flag. Now it is only set if the `proc` is either a class body or a method body defined in Ruby. It is no longer set for a block that given to `define_method`.
2017-11-04Merge branch 'master' of github.com:mruby/mrubyYAMAMOTO Masaya
2017-10-28Heavily refactored how lexical scope links are implemented; fix #3821Yukihiro "Matz" Matsumoto
Instead of `irep` links, we added a `upper` link to `struct RProc`. To make a space for the `upper` link, we moved `target_class` reference. If a `Proc` does not have `env`, `target_class` is saved in an `union` shared with `env` (if a `Proc` has env, you can tell it by `MRB_PROC_ENV_P()). Otherwise `target_class` is referenced from `env->c`. We removed links in `env` as well. This change removes 2 members from `mrb_irep` struct, thus saving 2 words per method/proc/block. This also fixes potential memory leaks due to the circular references caused by a link from `mrb_irep`.
2017-10-19Add `main.define_method`Yukihiro "Matz" Matsumoto
2017-10-17Remove `mrb_vm_get_argc`; ref #3826Yukihiro "Matz" Matsumoto
2017-10-11Add MRB_WITHOUT_FLOATYAMAMOTO Masaya
2017-10-10correctly handle *splat arguments in mrb_get_argc, also add mrb_vm_get_argc ↵Tomasz Dąbrowski
and mrb_get_argv Fixes #3825
2017-09-27fix: src\class.c(949): warning C4244: '=': conversion from 'mrb_int' to ↵Tomasz Dąbrowski
'int', possible loss of data
2017-09-27fix: src\class.c(949): warning C4244: '=': conversion from 'mrb_int' to ↵Tomasz Dąbrowski
'int', possible loss of data
2017-09-27fix: src\class.c(583): warning C4244: '=': conversion from 'mrb_int' to ↵Tomasz Dąbrowski
'int', possible loss of data
2017-09-06Avoid calling `mrb_funcall` to invoke `#initialize` from `Class.new`.Yukihiro "Matz" Matsumoto
If `#initialize` is implemented in C, we don't need stack consuming `mrb_funcall`.
2017-09-04Call `initialize` only when it's not empty.Yukihiro "Matz" Matsumoto
2017-09-01Update method cache clearing.Yukihiro "Matz" Matsumoto