[macruby-changes] [5106] MacRuby/trunk/ext/socket/socket.c

source_changes at macosforge.org source_changes at macosforge.org
Mon Jan 3 03:33:48 PST 2011


Revision: 5106
          http://trac.macosforge.org/projects/ruby/changeset/5106
Author:   watson1978 at gmail.com
Date:     2011-01-03 03:33:43 -0800 (Mon, 03 Jan 2011)
Log Message:
-----------
protocol will be optional argument with Socket.new(domain, type, protocol).

Test Script:
{{{
require 'socket'
require 'test/unit/assertions.rb'
include Test::Unit::Assertions

assert_nothing_raised{ Socket.new(Socket::AF_INET, Socket::SOCK_STREAM) }

puts :ok
}}}

Modified Paths:
--------------
    MacRuby/trunk/ext/socket/socket.c

Modified: MacRuby/trunk/ext/socket/socket.c
===================================================================
--- MacRuby/trunk/ext/socket/socket.c	2011-01-03 08:44:00 UTC (rev 5105)
+++ MacRuby/trunk/ext/socket/socket.c	2011-01-03 11:33:43 UTC (rev 5106)
@@ -2258,11 +2258,16 @@
 }
 
 static VALUE
-sock_initialize(VALUE sock, SEL sel, VALUE domain, VALUE type, VALUE protocol)
+sock_initialize(VALUE sock, SEL sel, int argc, VALUE *argv)
 {
+    VALUE domain, type, protocol;
     int fd;
     int d, t;
 
+    rb_scan_args(argc, argv, "21", &domain, &type, &protocol);
+    if (NIL_P(protocol))
+        protocol = INT2FIX(0);
+
     rb_secure(3);
     setup_domain_and_type(domain, &d, type, &t);
     fd = ruby_socket(d, t, NUM2INT(protocol));
@@ -3654,7 +3659,7 @@
 
     rb_cSocket = rb_define_class("Socket", rb_cBasicSocket);
 
-    rb_objc_define_method(rb_cSocket, "initialize", sock_initialize, 3);
+    rb_objc_define_method(rb_cSocket, "initialize", sock_initialize, -1);
     rb_objc_define_method(rb_cSocket, "connect", sock_connect, 1);
     rb_objc_define_method(rb_cSocket, "connect_nonblock", sock_connect_nonblock, 1);
     rb_objc_define_method(rb_cSocket, "bind", sock_bind, 1);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20110103/65051688/attachment.html>


More information about the macruby-changes mailing list