Package org.jruby

Examples of org.jruby.RubyString$EmptyByteListHolder


                frame.getName().equals(previousFrame.getName()) &&
                frame.getFile().equals(previousFrame.getFile())) {
            return;
        }
       
        RubyString traceLine;
        if (previousFrame.getName() != null) {
            traceLine = RubyString.newString(runtime, frame.getFile() + ':' + (frame.getLine() + 1) + ":in `" + previousFrame.getName() + '\'');
        } else {
            traceLine = RubyString.newString(runtime, frame.getFile() + ':' + (frame.getLine() + 1));
        }
View Full Code Here


                frame.getMethodName().equals(previousFrame.getMethodName()) &&
                frame.getFileName().equals(previousFrame.getFileName())) {
            return;
        }
       
        RubyString traceLine;
        if (previousFrame.getMethodName() == UNKNOWN_NAME) {
            traceLine = RubyString.newString(runtime, frame.getFileName() + ':' + (frame.getLineNumber()));
        } else {
            traceLine = RubyString.newString(runtime, frame.getFileName() + ':' + (frame.getLineNumber()) + ":in `" + previousFrame.getMethodName() + '\'');
        }
View Full Code Here

    public static IRubyObject createRawBacktrace(Ruby runtime, StackTraceElement[] stackTrace, boolean filter) {
        RubyArray traceArray = RubyArray.newArray(runtime);
        for (int i = 17; i < stackTrace.length; i++) {
            StackTraceElement element = stackTrace[i];
            if (filter && element.getClassName().startsWith("org.jruby")) continue;
            RubyString str = RubyString.newString(runtime, createRubyBacktraceString(element));
            traceArray.append(str);
        }
       
        return traceArray;
    }
View Full Code Here

        for (int i = 17; i < stackTrace.length; i++) {
            StackTraceElement element = stackTrace[i];
            int index = element.getMethodName().indexOf("$RUBY$");
            if (index < 0) continue;
            String unmangledMethod = element.getMethodName().substring(index + 6);
            RubyString str = RubyString.newString(runtime, element.getFileName() + ":" + element.getLineNumber() + ":in `" + unmangledMethod + "'");
            traceArray.append(str);
        }
       
        return traceArray;
    }
View Full Code Here

           
            // look for mangling markers for compiled Ruby in method name
            int index = element.getMethodName().indexOf("$RUBY$");
            if (index >= 0) {
                String unmangledMethod = element.getMethodName().substring(index + 6);
                RubyString str = RubyString.newString(runtime, element.getFileName() + ":" + element.getLineNumber() + ":in `" + unmangledMethod + "'");
                traceArray.append(str);
               
                // if it's not a rescue or ensure, there's a frame associated, so decrement
                if (!(element.getMethodName().contains("__rescue__") || element.getMethodName().contains("__ensure__"))) {
                    rubyFrameIndex--;
                }
                continue;
            }
           
            // look for __file__ method name for compiled roots
            if (element.getMethodName().equals("__file__")) {
                RubyString str = RubyString.newString(runtime, element.getFileName() + ":" + element.getLineNumber() + ": `<toplevel>'");
                traceArray.append(str);
                rubyFrameIndex--;
                continue;
            }
           
            // look for mangling markers for bound, unframed methods in class name
            index = element.getClassName().indexOf("$RUBYINVOKER$");
            if (index >= 0) {
                // unframed invokers have no Ruby frames, so pull from class name
                // but use current frame as file and line
                String unmangledMethod = element.getClassName().substring(index + 13);
                Frame current = context.frameStack[rubyFrameIndex];
                RubyString str = RubyString.newString(runtime, current.getFile() + ":" + (current.getLine() + 1) + ":in `" + unmangledMethod + "'");
                traceArray.append(str);
                continue;
            }
           
            // look for mangling markers for bound, framed methods in class name
            index = element.getClassName().indexOf("$RUBYFRAMEDINVOKER$");
            if (index >= 0) {
                // framed invokers will have Ruby frames associated with them
                addBackTraceElement(traceArray, backtraceFrames[rubyFrameIndex], backtraceFrames[rubyFrameIndex - 1], FrameType.METHOD);
                rubyFrameIndex--;
                continue;
            }
           
            // try to mine out a Ruby frame using our list of interpreter entry-point markers
            String classMethod = element.getClassName() + "." + element.getMethodName();
            FrameType frameType = INTERPRETED_FRAMES.get(classMethod);
            if (frameType != null) {
                // Frame matches one of our markers for "interpreted" calls
                if (rubyFrameIndex == 0) {
                    addBackTraceElement(traceArray, backtraceFrames[rubyFrameIndex], backtraceFrames[rubyFrameIndex], frameType);
                } else {
                    addBackTraceElement(traceArray, backtraceFrames[rubyFrameIndex], backtraceFrames[rubyFrameIndex - 1], frameType);
                    rubyFrameIndex--;
                }
                continue;
            } else {
                // Frame is extraneous runtime information, skip it unless debug
                if (debug) {
                    RubyString str = RubyString.newString(runtime, createRubyBacktraceString(element));
                    traceArray.append(str);
                }
                continue;
            }
        }
View Full Code Here

   
    @Override
    public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
        if (once && onceRegexp != null) return onceRegexp;

        RubyString string = DStrNode.buildDynamicString(runtime, context, self, aBlock, this);

        RubyRegexp regexp = createRegexp(runtime, string);
       
        if (once) setOnceRegexp(regexp);
View Full Code Here

    public int read(final char[] arr, final int off, final int len) {
        final IRubyObject read = io.callMethod(io.getRuntime().getCurrentContext(),"read", io.getRuntime().newFixnum(len));
        if(read.isNil() || ((RubyString)read).getByteList().realSize == 0) {
            return -1;
        } else {
            final RubyString str = (RubyString)read;
            final ByteList val = str.getByteList();
            System.arraycopy(ByteList.plain(val.bytes,val.begin,val.realSize),0,arr,off,val.realSize);
            return val.realSize;
        }
    }
View Full Code Here

            this.channel = channel;
        }
       
        @JRubyMethod
        public static IRubyObject rbuf_fill(IRubyObject recv) {
            RubyString buf = (RubyString)recv.getInstanceVariables().getInstanceVariable("@rbuf");
            RubyIO io = (RubyIO)recv.getInstanceVariables().getInstanceVariable("@io");

            int timeout = RubyNumeric.fix2int(recv.getInstanceVariables().getInstanceVariable("@read_timeout")) * 1000;
            NativeImpl nim = (NativeImpl)recv.dataGetStruct();

            Selector selector = null;
            try {
                selector = Selector.open();
                nim.channel.configureBlocking(false);
                SelectionKey key = nim.channel.register(selector, SelectionKey.OP_READ);
                int n = selector.select(timeout);

                if(n > 0) {
                    IRubyObject readItems = io.read(new IRubyObject[]{recv.getRuntime().newFixnum(1024*16)});
                    return buf.concat(readItems);
                } else {
                    RubyClass exc = (RubyClass)(recv.getRuntime().getModule("Timeout").getConstant("Error"));
                    throw new RaiseException(RubyException.newException(recv.getRuntime(), exc, "execution expired"),false);
                }
            } catch(IOException exception) {
View Full Code Here

            if (s.length() > 0) {
                return new Character(s.charAt(0));
            }
            return new Character('\0');
        } else if (javaClass == String.class) {
            RubyString rubyString = (RubyString) rubyObject.callMethod(context, "to_s");
            ByteList bytes = rubyString.getByteList();
            try {
                return new String(bytes.unsafeBytes(), bytes.begin(), bytes.length(), "UTF8");
            } catch (UnsupportedEncodingException uee) {
                return new String(bytes.unsafeBytes(), bytes.begin(), bytes.length());
            }
View Full Code Here

    public IRubyObject send(ThreadContext context, IRubyObject[] args) {
        try {
            if (args.length >= 3) { // host and port given
                InetSocketAddress addr =
                        new InetSocketAddress(InetAddress.getByName(args[2].convertToString().toString()), RubyNumeric.fix2int(args[3]));
                RubyString data = args[0].convertToString();
                ByteBuffer buf = ByteBuffer.wrap(data.getBytes());
                ((DatagramChannel) this.getChannel()).send(buf, addr);
                return data.length();
            } else {
                RubyString data = args[0].convertToString();
                ByteBuffer buf = ByteBuffer.wrap(data.getBytes());
                ((DatagramChannel) this.getChannel()).write(buf);
                return data.length();
            }
        } catch (UnknownHostException e) {
            throw sockerr(context.getRuntime(), "send: name or service not known");
        } catch (IOException e) {
            throw sockerr(context.getRuntime(), "send: name or service not known");
View Full Code Here

TOP

Related Classes of org.jruby.RubyString$EmptyByteListHolder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.