summaryrefslogtreecommitdiff
path: root/object.c
AgeCommit message (Collapse)Author
2013-03-13* object.c (Init_Object): remove Module#used, which has beenshugo
introduced in Ruby 2.0 by mistake. [Bug #7916] [ruby-core:52719] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-24* object.c: Document methods receiving string and convert to symbolzzak
Patch by Stefan Rusterholz * vm_eval.c: ditto * vm_method.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-23* array.c: Document #<=> return values and formattingzzak
* bignum.c: ditto * file.c: ditto * object.c: ditto * numeric.c: ditto * rational.c: ditto * string.c: ditto * time.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-23* object.c (rb_obj_comp): Documenting Object#<=> return valueszzak
Patch by Stefan Rusterholz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-22* object.c: Add doc for Module.prependedmarcandre
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-20* object.c: Document Data class [Bug #7890] [ruby-core:52549]zzak
Patch by Matthew Mongeau git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-19* object.c: rdoc formatting for Kernel#Array()zzak
* array.c: Add rdoc for Array() method to Creating Arrays section git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-29* object.c: Improve error for failed implicit conversions [Bug #7539]marcandre
* error.c: Adapt rdoc * test/ruby/test_object.rb: Test for above git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-29* object.c: Fix rdoc typo, patch by Narsimham Chelluri [#7753].marcandre
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-17* object.c: Typo in Kernel#hash documentation.eregon
Patch by zed_0xff [Github Fixes #237] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-15object.c: CLASS_OR_MODULE_Pnobu
* object.c (rb_mod_to_s, rb_class_inherited_p, rb_mod_ge, rb_mod_cmp): use BUILTIN_TYPE() instead of TYPE() for optimization. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-15object.c: two literalsnobu
* object.c (rb_mod_to_s): concatenate two literals. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38837 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-29object.c: singleton class clonenobu
* object.c (rb_obj_clone): attach clone to its singleton class during cloning singleton class so that singleton_method_added will be called on it. based on the patch by shiba (satoshi shiba)[Bug #5283] in [ruby-dev:44477]. [Bug #5283] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-22internal.h: quote unprintablenobu
* internal.h (QUOTE, QUOTE_ID): quote unprintable chars in strings and IDs. [Bug #7574] [ruby-dev:46749] * string.c (rb_str_quote_unprintable): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-22object.c: no nested symbolnobu
* object.c (rb_mod_const_get): symbol cannot be nested constant name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-22object.c: defer creating stringnobu
* object.c (rb_mod_const_get): defer creating partinal name string until needed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-22object.c: check more strictlynobu
* object.c (rb_mod_const_get): check more strictly. [ruby-dev:46748] [Bug #7573] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-21* object.c (rb_obj_hash): shouldn't assume object_id can be long.usa
based on a patch by Heesob Park at [ruby-core:51060]. cf. [Backport #7454] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-19object.c: nul in const namenobu
* object.c (rb_mod_const_get): nul byte is invalid as constant name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-13* object.c (Init_Object): no needs to override with same method.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-13 * object.c (Init_Object): use rb_mod_init_copy for Class#initialize_copycharliesome
* class.c (rb_class_init_copy): rename to class_init_copy_check, performs type checks on arguments to prevent reinitialization of initialized class [ruby-core:50869] [Bug #7557] * class.c (rb_mod_init_copy): use class_init_copy_check if receiver is T_CLASS * test/ruby/test_class.rb (class TestClass): related test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-06* revised r37993 to avoid SEGV/ILL in tests. In r37993, a methodshugo
entry with VM_METHOD_TYPE_REFINED holds only the original method definition, so ci->me is set to a method entry allocated in the stack, and it causes SEGV/ILL. In this commit, a method entry with VM_METHOD_TYPE_REFINED holds the whole original method entry. Furthermore, rb_thread_mark() is changed to mark cfp->klass to avoid GC for iclasses created by copy_refinement_iclass(). * vm_method.c (rb_method_entry_make): add a method entry with VM_METHOD_TYPE_REFINED to the class refined by the refinement if the target module is a refinement. When a method entry with VM_METHOD_TYPE_UNDEF is invoked by vm_call_method(), a method with the same name is searched in refinements. If such a method is found, the method is invoked. Otherwise, the original method in the refined class (rb_method_definition_t::body.orig_me) is invoked. This change is made to simplify the normal method lookup and to improve the performance of normal method calls. * vm_method.c (EXPR1, search_method, rb_method_entry), vm_eval.c (rb_call0, rb_search_method_entry): do not use refinements for method lookup. * vm_insnhelper.c (vm_call_method): search methods in refinements if ci->me is VM_METHOD_TYPE_REFINED. If the method is called by super (i.e., ci->call == vm_call_super_method), skip the same method entry as the current method to avoid infinite call of the same method. * class.c (include_modules_at): add a refined method entry for each method defined in a module included in a refinement. * class.c (rb_prepend_module): set an empty table to RCLASS_M_TBL(klass) to add refined method entries, because refinements should have priority over prepended modules. * proc.c (mnew): use rb_method_entry_with_refinements() to get a refined method. * vm.c (rb_thread_mark): mark cfp->klass for iclasses created by copy_refinement_iclass(). * vm.c (Init_VM), cont.c (fiber_init): initialize th->cfp->klass. * test/ruby/test_refinement.rb (test_inline_method_cache): do not skip the test because it should pass successfully. * test/ruby/test_refinement.rb (test_redefine_refined_method): new test for the case a refined method is redefined. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-03object.c: test bits at oncenobu
* object.c (rb_obj_clone): test TAINT and UNTRUSTED bits at once. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-01object.c: make remove_instance_variable publicnobu
* object.c (Init_Object): make remove_instance_variable public. [Feature #6539] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30* revert r37993 to avoid SEGV in tests.shugo
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29* vm_method.c (rb_method_entry_make): add a method entry withshugo
VM_METHOD_TYPE_REFINED to the class refined by the refinement if the target module is a refinement. When a method entry with VM_METHOD_TYPE_UNDEF is invoked by vm_call_method(), a method with the same name is searched in refinements. If such a method is found, the method is invoked. Otherwise, the original method in the refined class (rb_method_definition_t::body.orig_def) is invoked. This change is made to simplify the normal method lookup and to improve the performance of normal method calls. * vm_method.c (EXPR1, search_method, rb_method_entry), vm_eval.c (rb_call0, rb_search_method_entry): do not use refinements for method lookup. * vm_insnhelper.c (vm_call_method): search methods in refinements if ci->me is VM_METHOD_TYPE_REFINED. If the method is called by super (i.e., ci->call == vm_call_super_method), skip the same method entry as the current method to avoid infinite call of the same method. * class.c (include_modules_at): add a refined method entry for each method defined in a module included in a refinement. * class.c (rb_prepend_module): set an empty table to RCLASS_M_TBL(klass) to add refined method entries, because refinements should have priority over prepended modules. * proc.c (mnew): use rb_method_entry_with_refinements() to get a refined method. * test/ruby/test_refinement.rb (test_inline_method_cache): do not skip the test because it should pass successfully. * test/ruby/test_refinement.rb (test_redefine_refined_method): new test for the case a refined method is redefined. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-16object.c: suppress warningnobu
* object.c (rb_obj_alloc): suppress unused variable warning. * tool/gen_dummy_probes.rb: define dtrace disabling macro. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-16adjust indentnobu
* object.c (rb_obj_alloc): adjust indent. * vm.c (vm_collect_usage_{insn,operand,register}): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37689 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-12* probes.d: add DTrace probe declarations. [ruby-core:27448]tenderlove
* array.c (empty_ary_alloc, ary_new): added array create DTrace probe. * compile.c (rb_insns_name): allowing DTrace probes to access instruction sequence name. * Makefile.in: translate probes.d file to appropriate header file. * common.mk: declare dependencies on the DTrace header. * configure.in: add a test for existence of DTrace. * eval.c (setup_exception): add a probe for when an exception is raised. * gc.c: Add DTrace probes for mark begin and end, and sweep begin and end. * hash.c (empty_hash_alloc): Add a probe for hash allocation. * insns.def: Add probes for function entry and return. * internal.h: function declaration for compile.c change. * load.c (rb_f_load): add probes for `load` entry and exit, require entry and exit, and wrapping search_required for load path search. * object.c (rb_obj_alloc): added a probe for general object creation. * parse.y (yycompile0): added a probe around parse and compile phase. * string.c (empty_str_alloc, str_new): DTrace probes for string allocation. * test/dtrace/*: tests for DTrace probes. * vm.c (vm_invoke_proc): add probes for function return on exception raise, hash create, and instruction sequence execution. * vm_core.h: add probe declarations for function entry and exit. * vm_dump.c: add probes header file. * vm_eval.c (vm_call0_cfunc, vm_call0_cfunc_with_frame): add probe on function entry and return. * vm_exec.c: expose instruction number to instruction name function. * vm_insnshelper.c: add function entry and exit probes for cfunc methods. * vm_insnhelper.h: vm usage information is always collected, so uncomment the functions. 12 19:14:50 2012 Akinori MUSHA <knu@iDaemons.org> * configure.in (isinf, isnan): isinf() and isnan() are macros on DragonFly which cannot be found by AC_REPLACE_FUNCS(). This workaround enforces the fact that they exist on DragonFly. 12 15:59:38 2012 Shugo Maeda <shugo@ruby-lang.org> * vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo), vm_insnhelper.c (vm_search_method): revert r37616 because it's too slow. [ruby-dev:46477] * test/ruby/test_refinement.rb (test_inline_method_cache): skip the test until the bug is fixed efficiently. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-07object.c: inadvertent symbolnobu
* object.c (rb_mod_const_get): avoid inadvertent symbol creation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06* object.c (rb_mod_const_get): Fix constant missing exception classtenderlove
and message to maintain backwards compatibility. Constant search should start at Object when constant starts with '::' * test/ruby/test_module.rb: test for fixes git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-02* object.c (rb_mod_to_s): Module#{to_s,inspect}, when invoked onshugo
a refinement, returns a string in the format #<refinement:C@M>, where C is a refined class and M is a module at which the refinemet is defined. * eval.c (rb_mod_refine): store information on a refinement for the above change. * test/ruby/test_refinement.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-27* object.c (rb_mod_const_get): make sure the constant name istenderlove
converted to a string before searching. [ruby-core:48405] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-26* object.c (rb_mod_const_get): const_get accepts qualified constanttenderlove
strings. e.g. Object.const_get("Foo::Bar::Baz") [ruby-core:41404] * test/ruby/test_module.rb: tests for new behavior git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37335 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-20* include/ruby/ruby.h: add C APIs.nari
VALUE rb_newobj_of(VALUE klass, VALUE flags) #define NEWOBJ_OF(obj,type,klass,flags) These allow to change a allocation strategy depending on klass or flags. * gc.c: ditto * array.c: use new C API. * bignum.c: ditto * class.c: ditto * complex.c: ditto * ext/socket/ancdata.c: ditto * ext/socket/option.c: ditto * hash.c: ditto * io.c: ditto * marshal.c: ditto * numeric.c: ditto * object.c: ditto * random.c: ditto * range.c: ditto * rational.c: ditto * re.c: ditto * string.c: ditto * struct.c: ditto [Feature #7177][Feature #7047] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-08internal.h: allocator function in rb_classext_tnobu
* internal.h (struct rb_classext_struct): move allocator function into rb_classext_t from ordinary method table. [ruby-dev:46121] [Feature #6993] * object.c (rb_obj_alloc): call allocator function directly. * vm_method.c (rb_define_alloc_func, rb_undef_alloc_func) (rb_get_alloc_func): use allocator function in rb_classext_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-17object.c: preserve encodingsnobu
* object.c (rb_any_to_s, rb_obj_inspect): preserve encodings of class name and instance variable names. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-16object.c: forbid uninitialized classnobu
* object.c (rb_class_initialize): forbid inheriting uninitialized class. another class tree not based on BasicObject cannot exist. [ruby-core:47148][Bug #6863] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-15Kernel#inspect: improve consistency and do not call #to_s.eregon
* object.c (rb_obj_inspect): Kernel#inspect: do not call #to_s. A class can now benefit from the nice default #inspect even if it defines #to_s. Also, there is no more unexpected change in #inspect result. * NEWS: Add note about the change. * bignum.c, io.c, numeric.c, object.c, proc.c, vm.c (Init_*): Adapt internal structures (by aliasing #inspect to #to_s) so they don't rely on the removed behavior (#inspect calling overridden #to_s). * test/ruby/test_object.rb (test_inspect): add tests for Kernel#inspect. * lib/pp.rb (class PP): do not call #to_s anymore, as #inspect no more does (mame). * test/test_pp.rb (class PPInspectTest): remove related assertion (mame). [ruby-core:43238][Feature #6130] * test/drb/drbtest.rb (DRbCore#teardown, DRbAry#teardown): adapt DRb tests with the new change (shirosaki). [ruby-core:47182][Bug #6866] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-15Revert r36699 and r36700. [Feature #6130]naruse
Revert "Kernel#inspect: improve consistency and do not call #to_s." Revert "update PP with recent Kernel#inspect change. Patch by Yusuke Endoh." r36699 cause test-all failure on test/drb/test_drb.rb and test/drb/test_drbssl.rb. Run test-all before commit. Moreover its ChangeLog formst is wrong: see CommitterHowto https://bugs.ruby-lang.org/projects/ruby/wiki/CommitterHowto#ChangeLog git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-14Kernel#inspect: improve consistency and do not call #to_s.eregon
A class can now benefit from the nice default #inspect even if it defines #to_s. Also, there is no more unexpected change in #inspect result. Internal structures have been adapted so they don't rely on the removed behavior (#inspect calling overridden #to_s). * object.c (rb_obj_inspect): Kernel#inspect: do not call #to_s. * test/ruby/test_object.rb (test_inspect): add tests for Kernel#inspect. * bignum.c, io.c, numeric.c, object.c, proc.c, vm.c (Init_*): alias #inspect to #to_s where it was expected. [ruby-core:43238][Feature #6130] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36699 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-02* eval.c (rb_mod_using): new method Module#using. [experimental]shugo
* eval.c (rb_mod_refine): new method Module#refine. [experimental] * eval.c (f_using): new method Kernel#using. [experimental] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-19* variable.c (rb_mod_class_variables): return inherited variablesshugo
except when the optional argument is set to false. [ruby-dev:44034] [Bug #4971] * variable.c (rb_mod_constants): fix typo in documentation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-02* object.c (Init_Object): Added RDoc location pointers fordrbrain
Kernel#methods, Kernel#protected_methods, Kernel#private_methods and Kernel#public_methods. [Bug #6666] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36272 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-27Module#prependnobu
* class.c (rb_prepend_module): prepend module into another module. * eval.c (rb_mod_prepend): new method Module#prepend. [Feature #1102] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-19* object.c: Fix typo in rdocmarcandre
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-05obj_init_copynobu
* object.c (rb_obj_init_copy): should check if trusted too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-01class_or_module_requirednobu
* object.c (class_or_module_required): extract check for class or module. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-31* object.c (Init_Object): Restored Kernel documentation based ondrbrain
Pickaxe book documentation. Patch by Zachary Scott. [ruby-trunk - Feature #6521] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-31* object.c (rb_equal): Let Object be a link in #=== documentation.drbrain
Patch by Zachary Scott. [ruby-trunk - Feature #6518] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35854 b2dd03c8-39d4-4d8f-98ff-823fe69b080e