Граф коммитов

1605 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada 5b287481be
Removed non-RUBY_INTEGER_UNIFICATION code 2020-03-21 16:59:55 +09:00
K.Takata e89ebdcb87
Fix typos (#2958)
* Fix a typo

* Fix typos in st.[ch]
2020-03-11 00:43:12 -07:00
卜部昌平 ada2f71c70 rb_check_safe_obj no longer exists
Commit e91c39f1c0 deleted definition of it.
Though I'm not sure if we can delete public API like this, it no longer
works nontheless.  Having declaration without definiton is worse than
having nothing at all.  Just delete the declartion too.
2020-03-07 19:06:10 +09:00
卜部昌平 62c2b8c74e kill USE_RGENGC=0
This compile-time option has been broken for years (at least since
commit 49369ef173, according to git
bisect).  Let's delete codes that no longer works.
2020-02-26 16:00:10 +09:00
卜部昌平 7586355423 comma at the end of enum is a C++11ism
Comma at the end of enum is allowed in C since C99. We can use them
internally.  However when it comes to extension libraries, they could be
written in different C++ versions.  We cannot assume sometihng.  Public
headers shall keep compatibilities.
2020-02-20 11:46:54 +09:00
Nobuyoshi Nakada 0742585e7e
Consitified `rb_scan_args_set` 2020-02-14 15:56:37 +09:00
Jeremy Evans 50065dad7f Remove rb_eval_cmd
This was related to $SAFE, and was deprecated in 2.7.  I missed it
earlier when removing the other $SAFE-related code.
2020-02-11 08:46:44 -08:00
Nobuyoshi Nakada db69c50987
Parenthesized macro arguments 2020-02-03 14:19:02 +09:00
Nobuyoshi Nakada 0ab7f2f222
Make `rb_scan_args_kw` inline too 2020-02-03 13:07:34 +09:00
Nobuyoshi Nakada fae537259d
Removed no longer used variable `last_hash`
1. By substituting `n_var` with its initializer, `0 < n_var` is
   equivalent to `argc > argi + n_trail`.
2. As `argi` is non-negative, so `argi + n_trail >= n_trail`, and
   the above expression is equivalent to `argc > n_trail`.
3. Therefore, `f_last` is always false, and `last_hash` is no
   longer used.
2020-02-02 23:09:25 +09:00
卜部昌平 f31dc8a458 a bit terse Doxygen comments [ci skip]
Creative use of `@copydoc` Doxygen command and abusing its half-broken C
parser let us delete some lines of documentations, while preserving
document coverages.
2020-01-31 13:10:55 +09:00
卜部昌平 cdd75d4e7f support C++ std::nullptr_t
C++ keyword `nullptr` represents a null pointer (note also that NULL is
an integer in C++ due to its design flaw).  Its type is `std::nullptr_t`,
defined in <cstddef> standard header.  Why not support it when the
backend implementation can take a null pointer as an argument.
2020-01-31 13:01:52 +09:00
Kazuhiro NISHIYAMA 3023696505
Fix a typo [ci skip] 2020-01-29 08:30:39 +09:00
卜部昌平 83d6487ae5 fix rb_define_global_function to take const VALUE*
It was unable for rb_define_global_function to take VALUE(*)(int argc,
const VLAUE *argv, VALUE self) -style function.  Test added.
2020-01-28 17:29:57 +09:00
卜部昌平 3c3eb418f9 improved support for rb_f_notimplement
rb_f_notimplement should be accepted for all possible arities.

Test provided for that.
2020-01-28 17:09:42 +09:00
卜部昌平 7cf5d547e4 delete duplicated function overload
The `using engine<...snip...>::define;` line already defines this
function.  We don't have to repeat.
2020-01-28 17:09:42 +09:00
卜部昌平 03df02e871 fix typo
Add missing `*`.
2020-01-28 17:09:42 +09:00
卜部昌平 0a2e0db483 delete RB_METHOD_DEFINITION_DECL_1
This macro is no longer useful.  Just expand it.
2020-01-28 15:42:57 +09:00
卜部昌平 31fc34c969 delete unreachable branch
Case of __cplusplus is handled in cxxanyargs.hpp now.  These deleted
codes no longer reachable.
2020-01-28 15:42:57 +09:00
卜部昌平 01825e8bff template metaprogramming instead of macros
C++ (and myself) hates macros.  If we could do the same thing in both
preprocessor and template, we shall choose template.  This particular
part of the ruby header is one of such situations.
2020-01-28 15:42:57 +09:00
卜部昌平 ab33b3d691 move macros around
Would like to edit them in forthcoming commit.
2020-01-28 15:42:57 +09:00
Jeremy Evans e91c39f1c0 Remove special handling of $SAFE and related C-APIs
These were all deprecated in Ruby 2.7.
2020-01-22 09:09:47 -08:00
Nobuyoshi Nakada 661e07c97e
Moved the definition of `rb_define_method_if_constexpr`
Inside the block where `RB_METHOD_DEFINITION_DECL` family are
defined.
2020-01-09 21:32:26 +09:00
Yusuke Endoh 44a164c26f include/ruby/ruby.h: remove a variable tmp_buffer as it does not change
It is no longer used due to beae6cbf0f.
Coverity Scan found this.
2020-01-05 11:39:35 +09:00
Yusuke Endoh c7f01d889b include/ruby/ruby.h: remove last_idx that is no longer variable
Due to beae6cbf0f, the variable last_idx
is no longer changed and always -1.  This change simplifies the code by
removing the variable.  Coverity Scan pointed out this.
2020-01-05 11:39:35 +09:00
Jeremy Evans beae6cbf0f Fully separate positional arguments and keyword arguments
This removes the warnings added in 2.7, and changes the behavior
so that a final positional hash is not treated as keywords or
vice-versa.

To handle the arg_setup_block splat case correctly with keyword
arguments, we need to check if we are taking a keyword hash.
That case didn't have a test, but it affects real-world code,
so add a test for it.

This removes rb_empty_keyword_given_p() and related code, as
that is not needed in Ruby 3.  The empty keyword case is the
same as the no keyword case in Ruby 3.

This changes rb_scan_args to implement keyword argument
separation for C functions when the : character is used.
For backwards compatibility, it returns a duped hash.
This is a bad idea for performance, but not duping the hash
breaks at least Enumerator::ArithmeticSequence#inspect.

Instead of having RB_PASS_CALLED_KEYWORDS be a number,
simplify the code by just making it be rb_keyword_given_p().
2020-01-02 18:40:45 -08:00
卜部昌平 1dd149d3b1 re-add io.h and encoding.h into internal.h
This is tentative.  For the sake of simplicity we partially revert
commits e9cb552ec9, ee85a6e72b and 51edb30042.  Will decouple them
once again when we are ready.
2019-12-26 20:45:12 +09:00
Yukihiro "Matz" Matsumoto 537a1cd5a9 2.8.0 (tentative; to be 3.0.0) development has started. 2019-12-26 10:55:58 +09:00
Marc-Andre Lafortune 819b604037 Reword keyword arguments warning messages to convey these are deprecation warnings 2019-12-23 16:47:33 -05:00
Yusuke Endoh f7aee58498 vm_args.c: rephrase the warning message of keyword argument separation
(old)
test.rb:4: warning: The last argument is used as the keyword parameter
test.rb:1: warning: for `foo' defined here; maybe ** should be added to the call?

(new)
test.rb:4: warning: The last argument is used as keyword parameters; maybe ** should be added to the call
test.rb:1: warning: The called method `foo' is defined here
2019-12-20 19:41:15 +09:00
Nobuyoshi Nakada db16629008
Fixed misspellings
Fixed misspellings reported at [Bug #16437], only in ruby and rubyspec.
2019-12-20 09:32:42 +09:00
卜部昌平 ec931ee9e1 forward declare struct timespec
... like we do so for struct timeval at several hundreds of lines above.
Depending on OS/Compiler, this can be the first place for the struct to
appear.  To make sure the struct is global, we need a forward
declaration at this point.
2019-12-10 11:43:55 +09:00
Jeremy Evans c257303ae7 Deprecate rb_eval_cmd, add rb_eval_cmd_kw
rb_eval_cmd takes a safe level, and now that $SAFE is deprecated,
it should be deprecated as well.

Replace with rb_eval_cmd_kw, which takes a keyword flag.  Switch
the two callers to this function.
2019-11-18 01:00:25 +02:00
Jeremy Evans ffd0820ab3 Deprecate taint/trust and related methods, and make the methods no-ops
This removes the related tests, and puts the related specs behind
version guards.  This affects all code in lib, including some
libraries that may want to support older versions of Ruby.
2019-11-18 01:00:25 +02:00
Jeremy Evans c5c05460ac Warn on access/modify of $SAFE, and remove effects of modifying $SAFE
This removes the security features added by $SAFE = 1, and warns for access
or modification of $SAFE from Ruby-level, as well as warning when calling
all public C functions related to $SAFE.

This modifies some internal functions that took a safe level argument
to no longer take the argument.

rb_require_safe now warns, rb_require_string has been added as a
version that takes a VALUE and does not warn.

One public C function that still takes a safe level argument and that
this doesn't warn for is rb_eval_cmd.  We may want to consider
adding an alternative method that does not take a safe level argument,
and warn for rb_eval_cmd.
2019-11-18 01:00:25 +02:00
Aaron Patterson d0d743ad45
Remove duplicate code
These functions are the same, so remove one.

Co-authored-by: John Hawthorn <john@hawthorn.email>
2019-11-06 16:31:55 -08:00
卜部昌平 72f997edf6 mark functions that do not return NULL as such.
Apply __attribute__((__returns_nonnull__)) when available.
2019-11-01 16:58:19 +09:00
卜部昌平 2c889e9b05 RUBY_ATTR_ALOC_SIZE for clang
clang also supports __attribute__((__alloc_size__)) so why not use
it when the compiler says it does.
2019-11-01 16:58:19 +09:00
Nobuyoshi Nakada ad4da86669
Check for nonnull attribute in configure 2019-10-29 16:38:15 +09:00
Yusuke Endoh 281f754126 include/ruby/backward/cxxanyargs.hpp: call `va_end` before return
Coverity Scan complains it.
2019-10-24 08:30:33 +09:00
Nobuyoshi Nakada 1d91feaf13
Limit strict RUBY_METHOD_FUNC in C++
Limit strict function signature check with RUBY_METHOD_FUNC in C++
to bundled libraries only.  [Bug #16271]
2019-10-23 20:18:32 +09:00
Nobuyoshi Nakada 7ebf9da788
Also moved fallback definition of __has_attribute 2019-10-12 22:09:49 +09:00
Nobuyoshi Nakada 710bc00379
Moved RB_METHOD_DEFINITION_DECL to intern.h
This macro is used here before defined in ruby.h.
2019-10-12 17:47:28 +09:00
卜部昌平 a220410be7 annotate malloc-ish functions
Make them gcc friendly.  Note that realloc canot be __malloc__
attributed, according to the GCC manual.
2019-10-09 12:12:28 +09:00
Jeremy Evans c0eae130b1 Note RB_PASS_EMPTY_KEYWORDS and RB_SCAN_ARGS_EMPTY_KEYWORDS will be removed
There is no need for these in Ruby 3.0, and the plan is to
remove them.
2019-10-07 13:51:21 -07:00
Yusuke Endoh 113bef6976 array.c (rb_mem_clear): remove "register" from arguments
to suppress the following warning:

```
compiling cxxanyargs.cpp
In file included from cxxanyargs.cpp:1:
In file included from ../../.././include/ruby/ruby.h:2150:
../../.././include/ruby/intern.h:56:19: warning: 'register' storage class specifier is deprecated and incompatible with C++17 [-Wdeprecated-register]
void rb_mem_clear(register VALUE*, register long);
                  ^~~~~~~~~
../../.././include/ruby/intern.h:56:36: warning: 'register' storage class specifier is deprecated and incompatible with C++17 [-Wdeprecated-register]
void rb_mem_clear(register VALUE*, register long);
                                   ^~~~~~~~~
```
2019-10-04 16:07:46 +09:00
Jeremy Evans 3073404e74 Add rb_enumeratorize_with_size_kw and related macros
Currently, there is not a way to create a sized enumerator in C
with a different set of arguments than provided by Ruby, and
correctly handle keyword arguments.  This function allows that.

The need for this is fairly uncommon, but it occurs at least in
Enumerator.produce, which takes arugments from Ruby but calls
rb_enumeratorize_with_size with a different set of arguments.
2019-09-30 07:06:42 -07:00
Jeremy Evans 649a64ae29 Add three more C-API functions for handling keywords
This adds rb_funcall_passing_block_kw, rb_funcallv_public_kw,
and rb_yield_splat_kw.  This functions are necessary to easily
handle cases where rb_funcall_passing_block, rb_funcallv_public,
and rb_yield_splat are currently used and a keyword argument
separation warning is raised.
2019-09-29 18:31:08 -07:00
Jeremy Evans 660c7e050f Fix more keyword separation issues
This fixes instance_exec and similar methods. It also fixes
Enumerator::Yielder#yield, rb_yield_block, and a couple of cases
with Proc#{<<,>>}.

This support requires the addition of rb_yield_values_kw, similar to
rb_yield_values2, for passing the keyword flag.

Unlike earlier attempts at this, this does not modify the rb_block_call_func
type or add a separate function type.  The functions of type
rb_block_call_func are called by Ruby with a separate VM frame, and we can
get the keyword flag information from the VM frame flags, so it doesn't need
to be passed as a function argument.

These changes require the following VM functions accept a keyword flag:

* vm_yield_with_cref
* vm_yield
* vm_yield_with_block
2019-09-26 19:24:58 -07:00
Nobuyoshi Nakada 0c6f36668a
Adjusted spaces [ci skip] 2019-09-27 10:20:56 +09:00