1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/include/ruby
卜部昌平 9ef51b0b89 drop-in type check for rb_define_method
The rb_define_method function takes a pointer to ANYARGS-ed functions,
which in fact varies 18 different prototypes.  We still need to
preserve ANYARGS for storages but why not check the consistencies if
possible.

Q&As:

Q: Where did the magic number "18" came from in the description above?

A: Count the case branch of vm_method.c:call_cfunc_invoker_func().
   Note also that the 18 branches has lasted for at least 25 years.
   See also 200e0ee2fd.

Q: What is this __weakref__ thing?

A: That is a kind of function overloading mechanism that GCC provides.
   In this case for instance rb_define_method0 is an alias of
   rb_define_method, with a strong type.

Q: What is this __transparent_union__ thing?

A: That is another kind of function overloading mechanism that GCC
   provides.  In this case the attributed function pointer is either
   VALUE(*)(int,VALUE*,VALUE) or VALUE(*)(int,const VALUE*,VALUE).

   This is better than void* or ANYARGS because we can reject all
   other possibilities than the two.

Q: What does this rb_define_method macro mean?

A: It selects appropriate alias of the rb_define_method function,
   depending on the arity.

Q: Why the prototype change of rb_f_notimplement?

A: Function pointer to rb_f_notimplement is special cased in
   vm_method.c:rb_add_method_cfunc().  That should be handled by the
   __builtin_choose_expr chain inside of rb_define_method macro
   expansion.  In order to do so, comparison like (func ==
   rb_f_notimplement) is inappropriate for __builtin_choose_expr's
   expression (which must be a compile-time integer constant but the
   address of rb_f_notimplement is not fixed until the linker).  So
   instead we are using __builtin_types_compatible_p, and in doing so
   we need to distinguish rb_f_notimplement from others, by type.
2019-08-29 18:34:09 +09:00
..
backward * include/ruby/backward/util.h: Good-by Borland-C. 2015-10-18 05:41:34 +00:00
assert.h Revert "Always evaluate the expression RUBY_ASSERT_MESG_WHEN just once" 2019-08-05 08:55:09 +09:00
backward.h Renamed ruby_finalize_{0,1} 2019-08-13 09:47:08 +09:00
debug.h Revert "vm_trace: implement postponed_jobs as st_table" 2018-10-23 03:47:45 +00:00
defines.h Remove IA64 support. 2019-06-19 23:30:04 +12:00
encoding.h rb_enc_alias 2018-06-28 23:46:59 +00:00
intern.h drop-in type check for rb_define_method 2019-08-29 18:34:09 +09:00
io.h io.c: export rb_io_extract_modeenc 2019-08-14 11:20:58 +09:00
missing.h include/ruby/missing.h: defined(__cplusplus) before using __cplusplus 2018-06-05 14:16:50 +00:00
onigmo.h Reduce ONIG_NREGION from 10 to 4: power of 2 and testing revealed most pattern matches are less than or equal to 4 results 2019-05-07 21:58:55 +09:00
oniguruma.h Merge Onigmo 6.0.0 2016-12-10 17:47:04 +00:00
re.h Remove member char_offset_updated from struct rmatch as member char_offset_num_allocated can serve the same purpose as that predicate 2019-04-24 02:02:05 +09:00
regex.h
ruby.h drop-in type check for rb_define_method 2019-08-29 18:34:09 +09:00
st.h struct st_hash_type now free from ANYARGS 2019-08-27 15:52:26 +09:00
subst.h
thread.h introduce rb_nogvl C-API to mark ubf as async-signal-safe 2019-01-04 13:14:11 +00:00
thread_native.h
util.h util.h: remove my_getcwd 2017-11-26 01:36:33 +00:00
version.h version.h (RUBY_VERSION): 2.7.0 development has started. 2018-12-25 13:45:17 +00:00
vm.h ViewVC of svn.ruby-lang.org was shutdown status. 2019-04-22 19:37:22 +09:00
win32.h Fix errno at seeking socket/pipe on Windows 2019-07-25 06:39:40 +09:00