Yukihiro "Matz" Matsumoto
a574034cb2
hash.c (hash_set_default_proc): mrb_proc_arity() returns mrb_int
2025-03-25 08:09:21 +09:00
Yukihiro "Matz" Matsumoto
226acdc540
hash.c (mrb_hash_set_default_proc): avoid repeated calls for mrb_nil_p()
2025-03-19 14:57:02 +09:00
Yukihiro "Matz" Matsumoto
a55e3685a9
string.c: rename local variable indx to idx
...
`indx` seems not to be a common abbreviation.
2025-03-18 10:40:30 +09:00
Mark Delk
6396aac434
fix a typo, update specs
2025-03-17 10:47:33 -05:00
Yukihiro "Matz" Matsumoto
1e6442f54e
Revert "class.c (include_module_at): narrow local variable scope"
...
C++ does not compile `goto` cross local variable declaration.
This reverts commit c618b44fee .
2025-03-10 19:33:49 +09:00
Yukihiro "Matz" Matsumoto
1e36d7662c
object.h: rename gccolor to clearer gc_color
2025-03-10 14:23:51 +09:00
Yukihiro "Matz" Matsumoto
92b18d6a44
gc.c: fix re-using to reusing
2025-03-10 14:23:21 +09:00
Yukihiro "Matz" Matsumoto
f4de205960
range.c (range_num_to_a): reduce integer to float conversion
...
For big numbers (especially integers close to MRB_INT_MAX), float
conversion may be lose precisions. So we try not to convert numbers, but
just compare.
2025-03-10 13:13:10 +09:00
Yukihiro "Matz" Matsumoto
c618b44fee
class.c (include_module_at): narrow local variable scope
2025-03-10 11:26:13 +09:00
Yukihiro "Matz" Matsumoto
48f93adcdc
class.c (boot_defclass): unify variable declaration and initialization
2025-03-10 11:25:34 +09:00
Yukihiro "Matz" Matsumoto
4ba0cac481
numeric.c (coerce_step_counter): move local variable definition
...
To avoid unused local variable warning.
2025-03-09 16:42:28 +09:00
Yukihiro "Matz" Matsumoto
9a226c28bc
hash.c: add arity check for Hash#default_proc (and Hash.new); fix #6484
2025-03-08 16:14:26 +09:00
Yukihiro "Matz" Matsumoto
a7f3cfb711
hash.c: allow 'default_proc=nil' to clear default_proc; ref #6483
2025-03-08 15:49:26 +09:00
Yukihiro "Matz" Matsumoto
837f62f18a
hash.c: should check type before setting default_proc; fix #6483
2025-03-08 12:34:25 +09:00
Yukihiro "Matz" Matsumoto
87680d3ab2
hash.c (mrb_hash_rehash): call hash_modify before actual modify; fix #6485
2025-03-08 11:21:27 +09:00
Yukihiro "Matz" Matsumoto
213a262b20
hash.c (mrb_hash_compact): call hash_modify instead of mrb_check_frozen
...
Currently, hash_modify() only calls mrb_check_frozen, but we may add new
checks in the future; ref #6485
2025-03-08 11:15:37 +09:00
Yukihiro "Matz" Matsumoto
436269f62c
class.c: remove duplicated CI_TARGET_CLASS definition from class.c
2025-03-08 11:09:57 +09:00
Yukihiro "Matz" Matsumoto
3c4f6501b0
class.c (find_visibility_ci): inline find_ci_from_proc()
2025-03-08 07:54:51 +09:00
Yukihiro "Matz" Matsumoto
07b986f710
symbol.c (sym_inline_unpack): should not mix signedness
2025-03-07 17:55:20 +09:00
Yukihiro "Matz" Matsumoto
ec7477fe0d
class.c: take visibility from outer scope
...
It is possible to update the visibility from within a block, so that
`find_visibility_ci()` should look up outer scopes.
2025-03-07 17:49:08 +09:00
Yukihiro "Matz" Matsumoto
67e85ed296
vm.c (mrb_object_exec): update ci's target class by update function
...
To avoid breaking a Proc with env set.
2025-03-07 17:17:50 +09:00
Yukihiro "Matz" Matsumoto
889f09f8b7
class.c: move visibility flags from classes/modules to callinfo
2025-03-07 17:17:50 +09:00
Yukihiro "Matz" Matsumoto
02bf7fe08e
symbol.c (sym_inline_pack): max inline symbol length is now 4
2025-03-07 17:17:50 +09:00
Yukihiro "Matz" Matsumoto
6e1ab49ed3
class.c: allow changing visibility of methods defined in superclasses
2025-03-07 17:17:49 +09:00
Yukihiro "Matz" Matsumoto
37fb59bdac
class.h: rename macros for clarity
...
- MRB_SET_VISIBILITY -> MRB_CLASS_SET_VISIBILITY
- MRB_VISIBILITY -> MRB_CLASS_VISIBILITY
2025-03-07 17:17:49 +09:00
Yukihiro "Matz" Matsumoto
5e6ea6c5f9
vm.c: restore visibility when reopen class/module definition
...
Ideally, the default visibility should be stored in the scope. But for
the time being mruby stores the visibility in the class/module. As a
result, nesting class/module reopening or class_eval/module_eval could
cause incompatibility. We will try to fix them in the future.
2025-03-07 17:17:49 +09:00
Yukihiro "Matz" Matsumoto
2a876d2047
class.c: implement top-level public/private/protected in the core in C
2025-03-07 17:17:49 +09:00
Yukihiro "Matz" Matsumoto
43da490a1e
class.c: alias should keep the visibility of the original
2025-03-07 17:17:48 +09:00
Yukihiro "Matz" Matsumoto
921d632615
class.c (mrb_mod_visibility): clear method cache
2025-03-07 17:17:48 +09:00
Yukihiro "Matz" Matsumoto
20d5330417
class.c: use MT_VMASK to mask the flag values
2025-03-07 17:17:48 +09:00
Yukihiro "Matz" Matsumoto
b0db0bdd3a
vm.c: add checks for visibility (private, protected); close #1835
2025-03-07 17:17:47 +09:00
Yukihiro "Matz" Matsumoto
aba9a7d053
class.c: #initialize should be private by default
...
Fixed wrong condition.
2025-03-07 17:17:46 +09:00
Yukihiro "Matz" Matsumoto
c22f527bac
symbol.c (SYMBOL_INLINE_P): fix the check condition
...
Symbol `:_` would break the assertion.
2025-03-07 17:17:46 +09:00
Yukihiro "Matz" Matsumoto
6a61cd9373
kernel.c: make #respond_to_missing? private
2025-03-07 17:17:46 +09:00
Yukihiro "Matz" Matsumoto
ff6149dea7
kernel.c: removed some Kernel singleton methods
...
Since virtually no one calls `Kernel.block_given?` but just
`block_given?`. For the cases `raise` is redefined (like Ruby/Tk),
`Kernel.raise` is kept.
2025-03-07 17:17:44 +09:00
Yukihiro "Matz" Matsumoto
efc03f60af
proc.c: make #lambda private
2025-03-07 17:17:43 +09:00
Yukihiro "Matz" Matsumoto
cfc104e66c
class.c (mrb_define_module_function): make instance method private
2025-03-07 17:17:42 +09:00
Yukihiro "Matz" Matsumoto
4122cee9e4
class.c: implement attr_accessor in C
2025-03-07 17:17:39 +09:00
Yukihiro "Matz" Matsumoto
27828de749
kernel.c: make some methods private
...
- block_given?
- initialize_copy
- iterator?
- p
- print
- raise
- respond_to_missing?
2025-03-07 17:17:38 +09:00
Yukihiro "Matz" Matsumoto
7d2beb9fef
class.c (mrb_remove_method): should call hook method from the origin
...
MRB_CLASS_ORIGIN moves the pointer for prepended class/module, but the
hook method should be searched from the original class/module.
2025-03-07 17:17:38 +09:00
Yukihiro "Matz" Matsumoto
6168b15e0e
class.c (undef_method): call hook method when undef'ing a method
2025-03-07 17:17:38 +09:00
Yukihiro "Matz" Matsumoto
bcd0e0e439
class.c (mrb_remove_method): call hook method
...
Depending the context, hook method should be either method_removed or
singleton_method_removed.
2025-03-07 17:17:38 +09:00
Yukihiro "Matz" Matsumoto
0863c08841
class.c: implement singleton method hook methods
...
- singleton_method_removed
- singleton_method_undefined
2025-03-07 17:17:37 +09:00
Yukihiro "Matz" Matsumoto
9c74f6e908
class.c: implement method hook methods
...
- method_removed
- method_undefined
2025-03-07 17:17:37 +09:00
Yukihiro "Matz" Matsumoto
eb8b4120d7
class.c: initialize method needs to be private by default
2025-03-07 17:17:37 +09:00
Yukihiro "Matz" Matsumoto
e660e28a39
class.c: make some Module methods private
...
- append_features
- extend_object
- extended
- included
- initialize
- method_added
- module_function
- prepend_features
- prepended
- private
- protected
- public
- remove_const
2025-03-07 17:17:36 +09:00
Yukihiro "Matz" Matsumoto
f5150ab98a
class.c: make some Class methods private
...
- initialize
- inherited
2025-03-07 17:17:36 +09:00
Yukihiro "Matz" Matsumoto
c5e270e8f3
class.c: make some BasicObject methods private
...
- initialize
- singleton_method_added
- method_missing
2025-03-07 17:17:36 +09:00
Yukihiro "Matz" Matsumoto
ca20017ac9
class.c: implement mrb_define_private_method()
2025-03-07 17:17:36 +09:00
Yukihiro "Matz" Matsumoto
71c0de7f08
class.c (mrb_define_method_raw): take visibility from the class
...
If not explicitly specified in the method struct.
2025-03-07 17:17:36 +09:00