Skip to content

Commit 8c7b140

Browse files
committed
Remove rb_iterate deprecated since 1.9
1 parent 2ac4cc0 commit 8c7b140

File tree

6 files changed

+33
-125
lines changed

6 files changed

+33
-125
lines changed

ext/-test-/cxxanyargs/cxxanyargs.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -97,31 +97,6 @@ struct test_rb_define_hooked_variable {
9797
};
9898
VALUE test_rb_define_hooked_variable::v = Qundef;
9999

100-
namespace test_rb_iterate {
101-
VALUE
102-
iter(VALUE self)
103-
{
104-
return rb_funcall(self, rb_intern("yield"), 0);
105-
}
106-
107-
VALUE
108-
block(RB_BLOCK_CALL_FUNC_ARGLIST(arg, param))
109-
{
110-
return rb_funcall(arg, rb_intern("=="), 1, param);
111-
}
112-
113-
VALUE
114-
test(VALUE self)
115-
{
116-
#ifdef HAVE_NULLPTR
117-
rb_iterate(iter, self, nullptr, self);
118-
#endif
119-
120-
rb_iterate(iter, self, RUBY_METHOD_FUNC(block), self); // old
121-
return rb_iterate(iter, self, block, self); // new
122-
}
123-
}
124-
125100
namespace test_rb_block_call {
126101
VALUE
127102
block(RB_BLOCK_CALL_FUNC_ARGLIST(arg, param))
@@ -936,7 +911,6 @@ Init_cxxanyargs(void)
936911

937912
test(rb_define_virtual_variable);
938913
test(rb_define_hooked_variable);
939-
test(rb_iterate);
940914
test(rb_block_call);
941915
test(rb_rescue);
942916
test(rb_rescue2);

include/ruby/backward/cxxanyargs.hpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -190,33 +190,6 @@ rb_define_hooked_variable(const char *q, VALUE *w, std::nullptr_t e, void_type *
190190
/// @name Exceptions and tag jumps
191191
/// @{
192192

193-
// RUBY_CXX_DEPRECATED("by rb_block_call since 1.9")
194-
RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
195-
/// @brief Old way to implement iterators.
196-
/// @param[in] q A function that can yield.
197-
/// @param[in] w Passed to `q`.
198-
/// @param[in] e What is to be yielded.
199-
/// @param[in] r Passed to `e`.
200-
/// @return The return value of `q`.
201-
/// @note `e` can be nullptr.
202-
/// @deprecated This function is obsoleted since long before 2.x era. Do not
203-
/// use it any longer. rb_block_call() is provided instead.
204-
inline VALUE
205-
rb_iterate(onearg_type *q, VALUE w, type *e, VALUE r)
206-
{
207-
rb_block_call_func_t t = reinterpret_cast<rb_block_call_func_t>(e);
208-
return backward::rb_iterate_deprecated(q, w, t, r);
209-
}
210-
211-
#ifdef HAVE_NULLPTR
212-
RUBY_CXX_DEPRECATED("by rb_block_call since 1.9")
213-
inline VALUE
214-
rb_iterate(onearg_type *q, VALUE w, std::nullptr_t e, VALUE r)
215-
{
216-
return backward::rb_iterate_deprecated(q, w, e, r);
217-
}
218-
#endif
219-
220193
RUBY_CXX_DEPRECATED("Use of ANYARGS in this function is deprecated")
221194
/// @brief Call a method with a block.
222195
/// @param[in] q The self.

include/ruby/internal/iterator.h

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -265,48 +265,6 @@ int rb_block_given_p(void);
265265
*/
266266
void rb_need_block(void);
267267

268-
#ifndef __cplusplus
269-
RBIMPL_ATTR_DEPRECATED(("by: rb_block_call since 1.9"))
270-
#endif
271-
/**
272-
* Old way to iterate a block.
273-
*
274-
* @deprecated This is an old API. Use rb_block_call() instead.
275-
* @warning The passed function must at least once call a ruby method
276-
* (to handle interrupts etc.)
277-
* @param[in] func1 A function that could yield a value.
278-
* @param[in,out] data1 Passed to `func1`
279-
* @param[in] proc A function acts as a block.
280-
* @param[in,out] data2 Passed to `proc` as the data2 parameter.
281-
* @return What `func1` returns.
282-
*/
283-
VALUE rb_iterate(VALUE (*func1)(VALUE), VALUE data1, rb_block_call_func_t proc, VALUE data2);
284-
285-
#ifdef __cplusplus
286-
namespace ruby {
287-
namespace backward {
288-
/**
289-
* Old way to iterate a block.
290-
*
291-
* @deprecated This is an old API. Use rb_block_call() instead.
292-
* @warning The passed function must at least once call a ruby method
293-
* (to handle interrupts etc.)
294-
* @param[in] iter A function that could yield a value.
295-
* @param[in,out] data1 Passed to `func1`
296-
* @param[in] bl A function acts as a block.
297-
* @param[in,out] data2 Passed to `proc` as the data2 parameter.
298-
* @return What `func1` returns.
299-
*/
300-
static inline VALUE
301-
rb_iterate_deprecated(VALUE (*iter)(VALUE), VALUE data1, rb_block_call_func_t bl, VALUE data2)
302-
{
303-
return ::rb_iterate(iter, data1, bl, data2);
304-
}}}
305-
306-
RBIMPL_ATTR_DEPRECATED(("by: rb_block_call since 1.9"))
307-
VALUE rb_iterate(VALUE (*func1)(VALUE), VALUE data1, rb_block_call_func_t proc, VALUE data2);
308-
#endif
309-
310268
/**
311269
* Identical to rb_funcallv(), except it additionally passes a function as a
312270
* block. When the method yields, `proc` is called with the yielded value as

spec/ruby/optional/capi/array_spec.rb

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -343,37 +343,39 @@
343343
end
344344
end
345345

346-
describe "rb_iterate" do
347-
it "calls an callback function as a block passed to an method" do
348-
s = [1,2,3,4]
349-
s2 = @s.rb_iterate(s)
346+
ruby_version_is ""..."4.0" do
347+
describe "rb_iterate" do
348+
it "calls an callback function as a block passed to an method" do
349+
s = [1,2,3,4]
350+
s2 = @s.rb_iterate(s)
350351

351-
s2.should == s
352+
s2.should == s
352353

353-
# Make sure they're different objects
354-
s2.equal?(s).should be_false
355-
end
354+
# Make sure they're different objects
355+
s2.equal?(s).should be_false
356+
end
356357

357-
it "calls a function with the other function available as a block" do
358-
h = {a: 1, b: 2}
358+
it "calls a function with the other function available as a block" do
359+
h = {a: 1, b: 2}
359360

360-
@s.rb_iterate_each_pair(h).sort.should == [1,2]
361-
end
361+
@s.rb_iterate_each_pair(h).sort.should == [1,2]
362+
end
362363

363-
it "calls a function which can yield into the original block" do
364-
s2 = []
364+
it "calls a function which can yield into the original block" do
365+
s2 = []
365366

366-
o = Object.new
367-
def o.each
368-
yield 1
369-
yield 2
370-
yield 3
371-
yield 4
372-
end
367+
o = Object.new
368+
def o.each
369+
yield 1
370+
yield 2
371+
yield 3
372+
yield 4
373+
end
373374

374-
@s.rb_iterate_then_yield(o) { |x| s2 << x }
375+
@s.rb_iterate_then_yield(o) { |x| s2 << x }
375376

376-
s2.should == [1,2,3,4]
377+
s2.should == [1,2,3,4]
378+
end
377379
end
378380
end
379381

spec/ruby/optional/capi/ext/array_spec.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,15 @@ static VALUE copy_ary(RB_BLOCK_CALL_FUNC_ARGLIST(el, new_ary)) {
196196
return rb_ary_push(new_ary, el);
197197
}
198198

199+
#ifndef RUBY_VERSION_IS_4_0
199200
static VALUE array_spec_rb_iterate(VALUE self, VALUE ary) {
200201
VALUE new_ary = rb_ary_new();
201202

202203
rb_iterate(rb_each, ary, copy_ary, new_ary);
203204

204205
return new_ary;
205206
}
207+
#endif
206208

207209
static VALUE array_spec_rb_block_call(VALUE self, VALUE ary) {
208210
VALUE new_ary = rb_ary_new();
@@ -216,6 +218,7 @@ static VALUE sub_pair(RB_BLOCK_CALL_FUNC_ARGLIST(el, holder)) {
216218
return rb_ary_push(holder, rb_ary_entry(el, 1));
217219
}
218220

221+
#ifndef RUBY_VERSION_IS_4_0
219222
static VALUE each_pair(VALUE obj) {
220223
return rb_funcall(obj, rb_intern("each_pair"), 0);
221224
}
@@ -227,6 +230,7 @@ static VALUE array_spec_rb_iterate_each_pair(VALUE self, VALUE obj) {
227230

228231
return new_ary;
229232
}
233+
#endif
230234

231235
static VALUE array_spec_rb_block_call_each_pair(VALUE self, VALUE obj) {
232236
VALUE new_ary = rb_ary_new();
@@ -241,10 +245,12 @@ static VALUE iter_yield(RB_BLOCK_CALL_FUNC_ARGLIST(el, ary)) {
241245
return Qnil;
242246
}
243247

248+
#ifndef RUBY_VERSION_IS_4_0
244249
static VALUE array_spec_rb_iterate_then_yield(VALUE self, VALUE obj) {
245250
rb_iterate(rb_each, obj, iter_yield, obj);
246251
return Qnil;
247252
}
253+
#endif
248254

249255
static VALUE array_spec_rb_block_call_then_yield(VALUE self, VALUE obj) {
250256
rb_block_call(obj, rb_intern("each"), 0, 0, iter_yield, obj);
@@ -308,9 +314,11 @@ void Init_array_spec(void) {
308314
rb_define_method(cls, "rb_ary_plus", array_spec_rb_ary_plus, 2);
309315
rb_define_method(cls, "rb_ary_unshift", array_spec_rb_ary_unshift, 2);
310316
rb_define_method(cls, "rb_assoc_new", array_spec_rb_assoc_new, 2);
317+
#ifndef RUBY_VERSION_IS_4_0
311318
rb_define_method(cls, "rb_iterate", array_spec_rb_iterate, 1);
312319
rb_define_method(cls, "rb_iterate_each_pair", array_spec_rb_iterate_each_pair, 1);
313320
rb_define_method(cls, "rb_iterate_then_yield", array_spec_rb_iterate_then_yield, 1);
321+
#endif
314322
rb_define_method(cls, "rb_block_call", array_spec_rb_block_call, 1);
315323
rb_define_method(cls, "rb_block_call_each_pair", array_spec_rb_block_call_each_pair, 1);
316324
rb_define_method(cls, "rb_block_call_then_yield", array_spec_rb_block_call_then_yield, 1);

vm_eval.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,13 +1533,6 @@ rb_iterate_internal(VALUE (* it_proc)(VALUE), VALUE data1,
15331533
GET_EC());
15341534
}
15351535

1536-
VALUE
1537-
rb_iterate(VALUE (* it_proc)(VALUE), VALUE data1,
1538-
rb_block_call_func_t bl_proc, VALUE data2)
1539-
{
1540-
return rb_iterate_internal(it_proc, data1, bl_proc, data2);
1541-
}
1542-
15431536
struct iter_method_arg {
15441537
VALUE obj;
15451538
ID mid;

0 commit comments

Comments
 (0)