@JRubyMethod(meta = true) public static IRubyObject for_fd(ThreadContext context, IRubyObject _klass, IRubyObject _fileno) { Ruby runtime = context.runtime; int fileno = (int)_fileno.convertToInteger().getLongValue(); RubyClass klass = (RubyClass)_klass; ChannelFD fd = runtime.getFilenoUtil().getWrapperFromFileno(fileno); RubyBasicSocket basicSocket = (RubyBasicSocket)klass.getAllocator().allocate(runtime, klass); basicSocket.initSocket(fd); return basicSocket; }
@JRubyMethod(meta = true) public static IRubyObject for_fd(ThreadContext context, IRubyObject _klass, IRubyObject _fileno) { Ruby runtime = context.runtime; int fileno = (int)_fileno.convertToInteger().getLongValue(); RubyClass klass = (RubyClass)_klass; ChannelFD fd = runtime.getFilenoUtil().getWrapperFromFileno(fileno); RubyBasicSocket basicSocket = (RubyBasicSocket)klass.getAllocator().allocate(runtime, klass); basicSocket.initSocket(fd); return basicSocket; }
@JRubyMethod(meta = true) public static IRubyObject for_fd(ThreadContext context, IRubyObject socketClass, IRubyObject _fd) { Ruby runtime = context.runtime; if (_fd instanceof RubyFixnum) { int intFD = (int)((RubyFixnum)_fd).getLongValue(); ChannelFD fd = runtime.getFilenoUtil().getWrapperFromFileno(intFD); if (fd == null) { throw runtime.newErrnoEBADFError(); } RubySocket socket = (RubySocket)((RubyClass)socketClass).allocate(); socket.initFieldsFromDescriptor(runtime, fd); socket.initSocket(fd); return socket; } else { throw runtime.newTypeError(_fd, context.runtime.getFixnum()); } }
@JRubyMethod(meta = true) public static IRubyObject for_fd(ThreadContext context, IRubyObject socketClass, IRubyObject _fd) { Ruby runtime = context.runtime; if (_fd instanceof RubyFixnum) { int intFD = (int)((RubyFixnum)_fd).getLongValue(); ChannelFD fd = runtime.getFilenoUtil().getWrapperFromFileno(intFD); if (fd == null) { throw runtime.newErrnoEBADFError(); } RubySocket socket = (RubySocket)((RubyClass)socketClass).allocate(); socket.initFieldsFromDescriptor(runtime, fd); socket.initSocket(fd); return socket; } else { throw runtime.newTypeError(_fd, context.runtime.getFixnum()); } }
fd = runtime.getFilenoUtil().getWrapperFromFileno(fileno); ChannelFD descriptor = runtime.getFilenoUtil().getWrapperFromFileno(fileno);
fd = runtime.getFilenoUtil().getWrapperFromFileno(fileno); ChannelFD descriptor = runtime.getFilenoUtil().getWrapperFromFileno(fileno);