summaryrefslogtreecommitdiffhomepage
path: root/src/class.c
AgeCommit message (Collapse)Author
2019-10-20Use `mrb_str_cat_str` instead of `mrb_str_concat` if possibleKOBAYASHI Shuji
2019-10-19Fix that `Module#to_s` may return frozen string; ref 08eafe2KOBAYASHI Shuji
2019-10-13Refactor `mrb_class_name_class`KOBAYASHI Shuji
- Use `mrb_sym_name_len` instead of `mrb_sym_name` (class name should not be escaped). - Avoid `mrb_str_dup` (it is unnecessary to be shared string because it is changed).
2019-10-08Implement Ruby2.7's frozen strings from `Module#name`KOBAYASHI Shuji
2019-10-06Get keyword arguments with `mrb_get_args()`dearblue
Keyword arguments can now be retrieved with the `:` specifier and `mrb_kwargs` data. For the interface, I referred to CRuby's `rb_get_kwargs()`. For implementation, I referred to `OP_KARG` or etc.
2019-10-04Implement Ruby2.7's frozen strings from `Symbol#to_s`.Yukihiro "Matz" Matsumoto
2019-09-26Use type predicate macros instead of `mrb_type` if possibleKOBAYASHI Shuji
For efficiency with `MRB_WORD_BOXING` (implement type predicate macros for all `enum mrb_vtype`).
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-18Fix `super` from aliased methods to work correctly; fix #4718Yukihiro "Matz" Matsumoto
We needed to preserve the original method name somewhere. We kept it in the `env` structure pointed from aliased methods. #1457 and #1531 tried to address this issue. But this patch is more memory efficient. Limitation: this fix does not support `super` from methods defined by `define_method`. This limitation may be addressed in the future, but it's low priority.
2019-09-16Shrink `mrb_get_args()`dearblue
As a side effect, all specifiers now accept the `!` modifier.
2019-09-16Cache argv first in each specifiers for `mrb_get_args()`; ref #3090dearblue
In terms of specifiers, argv is never referenced after a method call as shown in #3090. Reduction of object code can be expected. If you need to refer to argv after a method call in the same loop, update argv after the method call.
2019-09-16Raise `ArgumentError` by `aspec` check; ref #4688Yukihiro "Matz" Matsumoto
This is partial `aspec` check that only checks `MRB_ARGS_NONE()`.
2019-09-14Use `%C` to `mrb_name_error` in `mrb_method_search`; ref 5890c7d5KOBAYASHI Shuji
2019-09-14Remove `mrb_funcall` from `mrb_method_search`.Yukihiro "Matz" Matsumoto
2019-09-09Remove duplication of `BasicObject` constant; fix #4698Yukihiro "Matz" Matsumoto
2019-09-09Fix `Class.new` argument specsKOBAYASHI Shuji
2019-09-04Fix argument specs to `BasicObject`KOBAYASHI Shuji
2019-08-26fix lots of warnings and make logo not so bigDavid Siaw
2019-08-18Prohibit changes to iseq in principledearblue
2019-08-17Stop using `mrb_to_str` as a converter (it is not).Yukihiro "Matz" Matsumoto
2019-08-17Avoid `mrb_funcall` from `Class#new` when no overloading.Yukihiro "Matz" Matsumoto
2019-08-16Optimize bytecode for `Class#new`.Yukihiro "Matz" Matsumoto
2019-08-16Implement `Class#new` using inline mruby bytecode.Yukihiro "Matz" Matsumoto
2019-08-16Stop raising exceptions from `undef` C API.Yukihiro "Matz" Matsumoto
Some `undef' functions may be called before initialization, thus causes infinite error recursion.
2019-08-14Avoid array copying in `mrb_instance_new`.Yukihiro "Matz" Matsumoto
2019-08-14Integrate `kazuho/mruby-class-new-fiber-safe` in the master.Yukihiro "Matz" Matsumoto
Avoid calling `initialize` via `mrb_funcall`, which cause `cross C boundary` error from Fibers started in the method.
2019-08-14Remove `MRB_API` from functions only called from `vm.c`.Yukihiro "Matz" Matsumoto
* `mrb_vm_define_class` * `mrb_vm_define_module` Only functions called from user code requires `MRB_API`.
2019-08-07Update `mrb_to_str` and related functions.Yukihiro "Matz" Matsumoto
Contrary to the name, `mrb_to_str` just checks type, no conversion.
2019-08-07Reorganize `mrb_string_value_cstr` and related functions.Yukihiro "Matz" Matsumoto
`mrb_string_value_cstr` and `mrb_string_value_len`: obsolete `mrb_string_cstr`: new function to retrieve NULL terminated C string `RSTRING_CSTR`: wrapper macro of `mrb_string_cstr`
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-07-20Fix `Module#dup` to frozen moduleKOBAYASHI Shuji
Before this patch: $ bin/mruby -e 'p Module.new.freeze.dup.frozen?' #=> true After this patch (same as Ruby): $ bin/mruby -e 'p Module.new.freeze.dup.frozen?' #=> false
2019-07-13Use stack memory for small name of attr accessorsdearblue
Also integrated the common parts of `mrb_mod_attr_reader()` and `mrb_mod_attr_writer()` functions.
2019-07-03Refine document to mrb_get_args()` [ci skip]KOBAYASHI Shuji
2019-06-30Fix `include`, `prepend` and `extend` to frozen objectKOBAYASHI Shuji
2019-06-13Fix class name validation in `Struct.new`KOBAYASHI Shuji
Before this patch: $ bin/mruby -e 'p Struct.new("A-")' #=> Struct::"A-" After this patch: $ bin/mruby -e 'p Struct.new("A-")' #=> NameError: identifier A- needs to be constant
2019-05-18Move `Kernel#equal? to `BasicObject`KOBAYASHI Shuji
2019-05-18Add ISO section number to `Module#===`.Yukihiro "Matz" Matsumoto
2019-05-15Merge pull request #4400 from ↵Yukihiro "Matz" Matsumoto
shuujii/fix-name-assignment-to-frozen-anonymous-class-module Fix name assignment to frozen anonymous class/module
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-23Fix name assignment to frozen anonymous class/moduleKOBAYASHI Shuji
Fix the following issues: A = Class.new.freeze #=> FrozenError Module.new::B = Class.new.freeze #=> FrozenError String::B = Module.new.freeze #=> FrozenError
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