Examples of ByteList


Examples of org.jruby.util.ByteList

        if (backref != null && backref instanceof RubyMatchData) ((RubyMatchData)backref).use();

        IRubyObject s = RuntimeHelpers.invoke(
                context, this, "gsub",
                RubyRegexp.newRegexp(runtime, Numeric.ComplexPatterns.underscores_pat),
                runtime.newString(new ByteList(new byte[]{'_'})));

        RubyArray a = RubyRational.str_to_r_internal(context, s);

        frame.setBackRef(backref);
View Full Code Here

Examples of org.jruby.util.ByteList

       
   
    @JRubyMethod(name = "get_buffer", required = 2)
    public IRubyObject get_buffer(ThreadContext context, IRubyObject off, IRubyObject len_) {
        int len = Util.int32Value(len_);
        ByteList bl = new ByteList(len);
        getMemoryIO().get(getOffset(off), bl.unsafeBytes(), bl.begin(), len);
        bl.length(len);
        return context.getRuntime().newString(bl);
    }
View Full Code Here

Examples of org.jruby.util.ByteList

        bl.length(len);
        return context.getRuntime().newString(bl);
    }
    @JRubyMethod(name = "put_buffer", required = 3)
    public IRubyObject put_buffer(ThreadContext context, IRubyObject off, IRubyObject str, IRubyObject len_) {
        ByteList bl = str.convertToString().getByteList();
        int len = Math.min(bl.length(), Util.int32Value(len_));
        getMemoryIO().put(getOffset(off), bl.unsafeBytes(), bl.begin(), len);
        return context.getRuntime().newFixnum(len);
    }
View Full Code Here

Examples of org.jruby.util.ByteList

    }

    @Override
    public boolean matchMarker(ByteList match, boolean indent, boolean checkNewline) throws IOException {
        int length = match.length();
        ByteList buffer = new ByteList(length + 1);
       
        if (indent) {
            indentLoop(buffer);
        }
       
View Full Code Here

Examples of org.jruby.util.ByteList

        return oneAgo == '\n';
    }

    public String toString() {
        try {
            ByteList buffer = new ByteList(20);
            buffer.append(twoAgo);
            buffer.append(oneAgo);
            buffer.append(new byte[] {'-', '>'});
            int i = 0;
            for (; i < 20; i++) {
                int c = read();
                if (c == 0) {
                    i--;
                    break;
                }
                buffer.append(c);
            }
            for (; i >= 0; i++) {
                unread(buffer.charAt(i));
            }
            buffer.append(new byte[] {' ', '.', '.', '.'});
            return buffer.toString();
        } catch(Exception e) {
            return null;
        }
    }
View Full Code Here

Examples of org.jruby.util.ByteList

        }
    }

    @Override
    public ByteList readUntil(char marker) throws IOException {
        ByteList list = new ByteList(20);
        int c;
       
        for (c = read(); c != marker && c != RubyYaccLexer.EOF; c = read()) {
            list.append(c);
        }
       
        if (c == RubyYaccLexer.EOF) return null;
       
        unread(c);
View Full Code Here

Examples of org.jruby.util.ByteList

                return io;
            }
      ByteArrayOutputStream stringOutput = new ByteArrayOutputStream();
      dumpToStream(objectToDump, stringOutput, depthLimit);

            return RubyString.newString(recv.getRuntime(), new ByteList(stringOutput.toByteArray(),false));

        } catch (IOException ioe) {
            throw recv.getRuntime().newIOErrorFromException(ioe);
        }
View Full Code Here

Examples of org.jruby.util.ByteList

            InputStream rawInput;
            if (in != null && in.respondsTo("read")) {
                rawInput = inputStream(in);
            } else if (in != null && in.respondsTo("to_str")) {
                RubyString inString = (RubyString) RuntimeHelpers.invoke(context, in, "to_str");
                ByteList bytes = inString.getByteList();
                rawInput = new ByteArrayInputStream(bytes.unsafeBytes(), bytes.begin(), bytes.length());
            } else {
                throw recv.getRuntime().newTypeError("instance of IO needed");
            }
           
            UnmarshalStream input = new UnmarshalStream(recv.getRuntime(), rawInput, proc);
View Full Code Here

Examples of org.jruby.util.ByteList

           
            lexer.yaccValue = new Token(marker, lexer.getPosition());
            return Tokens.tSTRING_END;
        }

        ByteList str = new ByteList();
        ISourcePosition position;
       
        if ((flags & RubyYaccLexer.STR_FUNC_EXPAND) == 0) {
            do {
                str.append(src.readLineBytes());
                str.append('\n');
                if (src.peek(RubyYaccLexer.EOF)) syntaxError(src);
                position = lexer.getPosition();
            } while (!src.matchMarker(marker, indent, true));
        } else {
            int c = src.read();
            if (c == '#') {
                switch (c = src.read()) {
                case '$':
                case '@':
                    src.unread(c);
                    lexer.setValue(new Token("#" + c, lexer.getPosition()));
                    return Tokens.tSTRING_DVAR;
                case '{':
                    lexer.setValue(new Token("#" + c, lexer.getPosition()));
                    return Tokens.tSTRING_DBEG;
                }
                str.append('#');
            }

            src.unread(c);

            // MRI has extra pointer which makes our code look a little bit
            // more strange in
            // comparison
            do {
                if ((c = new StringTerm(flags, '\0', '\n').parseStringIntoBuffer(lexer, src, str)) == RubyYaccLexer.EOF) {
                    syntaxError(src);
                }
                if (c != '\n') {
                    lexer.yaccValue = new StrNode(lexer.getPosition(), str);
                    return Tokens.tSTRING_CONTENT;
                }
                str.append(src.read());
               
                if (src.peek(RubyYaccLexer.EOF)) syntaxError(src);
                position = lexer.getPosition();
            } while (!src.matchMarker(marker, indent, true));
        }
View Full Code Here

Examples of org.jruby.util.ByteList

    @JRubyMethod(name = "chr")
    public RubyString chr() {
        if (getLongValue() < 0 || getLongValue() > 0xff) {
            throw getRuntime().newRangeError(this.toString() + " out of char range");
        }
        return RubyString.newString(getRuntime(), new ByteList(new byte[]{(byte)getLongValue()}, false));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.