Package org.jruby

Examples of org.jruby.RubyString$EmptyByteListHolder


        IRubyObject scriptLines = runtime.getObject().fastGetConstantAt("SCRIPT_LINES__");
        RubyArray list = null;
       
        if (!configuration.isEvalParse() && scriptLines != null) {
            if (scriptLines instanceof RubyHash) {
                RubyString filename = runtime.newString(file);
                ThreadContext context = runtime.getCurrentContext();
                IRubyObject object = ((RubyHash) scriptLines).op_aref(context, filename);
               
                list = (RubyArray) (object instanceof RubyArray ? object : runtime.newArray());
               
View Full Code Here


        return visitor.visitDSymbolNode(this);
    }
   
    @Override
    public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
        RubyString string = DStrNode.buildDynamicString(runtime, context, self, aBlock, this);
  
        return runtime.newSymbol(string.toString());
    }
View Full Code Here

     * </p>
     */
    private static final class StringMarshaller implements Marshaller {
        public final Object marshal(Invocation invocation, IRubyObject parameter) {
            // Ruby strings are UTF-8, so should be able to just copy directly
            RubyString s = parameter.asString();
            ByteList bl = s.getByteList();
            final Memory memory = new Memory(bl.length() + 1);
            memory.write(0, bl.unsafeBytes(), bl.begin(), bl.length());
            memory.setByte(bl.length(), (byte) 0);
            return memory;
        }
View Full Code Here

    public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
        return buildDynamicString(runtime, context, self, aBlock, this);
    }
   
    public static RubyString buildDynamicString(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock, ListNode list) {
        RubyString string = runtime.newString(new ByteList());
       
        int size = list.size();
        for (int i = 0; i < size; i++) {
            DStrNode.appendToString(runtime, context, self, aBlock, string, list.get(i));
        }
View Full Code Here

        return allocate(context, sizeArg, clearArg.isTrue());
    }
    @JRubyMethod(name = { "alloc_in", "__alloc_in", "__alloc_heap_in", "__alloc_direct_in" }, meta = true)
    public static JNABuffer allocateInput(ThreadContext context, IRubyObject recv, IRubyObject arg) {
        if (arg instanceof RubyString) {
            final RubyString s = (RubyString) arg;
            final int size = Util.int32Value(s.length());
            final ByteList bl = s.getByteList();
            final JNAMemoryIO io = JNAMemoryIO.allocateDirect(size);
            io.put(0, bl.unsafeBytes(), bl.begin(), bl.length());
            io.putByte(bl.length(), (byte) 0);
            return new JNABuffer(context.getRuntime(), io, 0, size);
        } else {
View Full Code Here

            script.append("$failed").append('\n');

            RubyArray lastFailed = (RubyArray)runtime.executeScript(script.toString(), scriptName() + "_generated_test.rb");
           
            if (!lastFailed.isEmpty()) {
                RubyString message = (RubyString) lastFailed.callMethod(lastFailed.getRuntime().getCurrentContext(), "to_s");
                fail(scriptName() + " failed, complete failure list follows:\n" + message.toString());
            }

            System.out.flush(); // Without a flush Ant will miss some of our output
        }
View Full Code Here

     * the result. If no valid JSON document can be created this method raises
     * a GeneratorError exception.
     */
    @JRubyMethod
    public IRubyObject generate(ThreadContext context, IRubyObject obj) {
        RubyString result = Generator.generateJson(context, obj, this);
        if (!quirksMode && !objectOrArrayLiteral(result)) {
            throw Utils.newException(context, Utils.M_GENERATOR_ERROR,
                    "only generation of JSON objects or arrays allowed");
        }
        return result;
View Full Code Here

        depth = RubyNumeric.fix2int(vDepth);
        return vDepth;
    }

    private ByteList prepareByteList(ThreadContext context, IRubyObject value) {
        RubyString str = value.convertToString();
        RuntimeInfo info = RuntimeInfo.forRuntime(context.getRuntime());
        if (info.encodingsSupported() && str.encoding(context) != info.utf8.get()) {
            str = (RubyString)str.encode(context, info.utf8.get());
        }
        return str.getByteList().dup();
    }
View Full Code Here

            addPath((String) iter.next());
        }

        // add $RUBYLIB paths
        RubyHash env = (RubyHash) runtime.getObject().fastGetConstant("ENV");
        RubyString env_rubylib = runtime.newString("RUBYLIB");
        if (env.has_key_p(env_rubylib).isTrue()) {
            String rubylib = env.op_aref(runtime.getCurrentContext(), env_rubylib).toString();
            String[] paths = rubylib.split(File.pathSeparator);
            for (int i = 0; i < paths.length; i++) {
                addPath(paths[i]);
View Full Code Here

        }
    }
   
    protected boolean tryLoadingLibraryOrScript(Ruby runtime, SearchState state) {
        // attempt to load the found library
        RubyString loadNameRubyString = RubyString.newString(runtime, state.loadName);
        try {
            synchronized (loadedFeaturesInternal) {
                if (featureAlreadyLoaded(loadNameRubyString)) {
                    return false;
                } else {
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.