[前][次][番号順一覧][スレッド一覧]

ruby-changes:44193

From: nobu <ko1@a...>
Date: Tue, 27 Sep 2016 15:23:41 +0900 (JST)
Subject: [ruby-changes:44193] nobu:r56266 (trunk): iseq.c: kwarg to compile

nobu	2016-09-27 15:23:36 +0900 (Tue, 27 Sep 2016)

  New Revision: 56266

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56266

  Log:
    iseq.c: kwarg to compile
    
    * iseq.c (iseqw_s_compile, iseqw_s_compile_file): allow keyword
      arguments as the options.

  Modified files:
    trunk/iseq.c
Index: iseq.c
===================================================================
--- iseq.c	(revision 56265)
+++ iseq.c	(revision 56266)
@@ -781,9 +781,18 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/iseq.c#L781
 iseqw_s_compile(int argc, VALUE *argv, VALUE self)
 {
     VALUE src, file = Qnil, path = Qnil, line = INT2FIX(1), opt = Qnil;
+    int i;
+
     rb_secure(1);
 
-    rb_scan_args(argc, argv, "14", &src, &file, &path, &line, &opt);
+    i = rb_scan_args(argc, argv, "1*:", &src, NULL, &opt);
+    if (i > 4+NIL_P(opt)) rb_error_arity(argc, 1, 5);
+    switch (i) {
+      case 5: opt = argv[--i];
+      case 4: line = argv[--i];
+      case 3: path = argv[--i];
+      case 2: file = argv[--i];
+    }
     if (NIL_P(file)) file = rb_fstring_cstr("<compiled>");
     if (NIL_P(line)) line = INT2FIX(1);
 
@@ -818,9 +827,14 @@ iseqw_s_compile_file(int argc, VALUE *ar https://github.com/ruby/ruby/blob/trunk/iseq.c#L827
     VALUE f;
     NODE *node;
     rb_compile_option_t option;
+    int i;
 
     rb_secure(1);
-    rb_scan_args(argc, argv, "11", &file, &opt);
+    i = rb_scan_args(argc, argv, "1*:", &file, NULL, &opt);
+    if (i > 1+NIL_P(opt)) rb_error_arity(argc, 1, 2);
+    switch (i) {
+      case 2: opt = argv[--i];
+    }
     FilePathValue(file);
     file = rb_fstring(file); /* rb_io_t->pathv gets frozen anyways */
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]