File: ruby_193_compatible.h

package info (click to toggle)
ruby-concurrent 1.1.6%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 30,284 kB
  • sloc: ruby: 30,875; java: 6,117; ansic: 288; makefile: 9; sh: 6
file content (28 lines) | stat: -rw-r--r-- 828 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#ifndef rb_check_arity

// https://github.com/ruby/ruby/blob/ruby_2_0_0/include/ruby/intern.h
// rb_check_arity was added in Ruby 2.0

#define UNLIMITED_ARGUMENTS (-1)

static inline VALUE rb_error_arity(int argc, int min, int max)
{
  VALUE err_mess = 0;
  if (min == max) {
    err_mess = rb_sprintf("wrong number of arguments (%d for %d)", argc, min);
  }
  else if (max == UNLIMITED_ARGUMENTS) {
    err_mess = rb_sprintf("wrong number of arguments (%d for %d+)", argc, min);
  }
  else {
    err_mess = rb_sprintf("wrong number of arguments (%d for %d..%d)", argc, min, max);
  }
  return rb_exc_new3(rb_eTypeError, err_mess);
}

#define rb_check_arity(argc, min, max) do { \
  if (((argc) < (min)) || ((argc) > (max) && (max) != UNLIMITED_ARGUMENTS)) \
  rb_exc_raise(rb_error_arity(argc, min, max)); \
} while(0)

#endif