Examples of ThreadContext


Examples of org.jruby.runtime.ThreadContext

        return proxyClass;
    }

    public static IRubyObject concrete_proxy_inherited(IRubyObject recv, IRubyObject subclass) {
        Ruby runtime = recv.getRuntime();
        ThreadContext tc = runtime.getCurrentContext();
        JavaSupport javaSupport = runtime.getJavaSupport();
        RubyClass javaProxyClass = javaSupport.getJavaProxyClass().getMetaClass();
        RuntimeHelpers.invokeAs(tc, javaProxyClass, recv, "inherited", subclass,
                Block.NULL_BLOCK);
        return setupJavaSubclass(tc, subclass, recv.callMethod(tc, "java_class"));
View Full Code Here

Examples of org.jruby.runtime.ThreadContext

    @JRubyMethod(frame = true)
    public static IRubyObject each(IRubyObject self, Block block) {
        // Generator#each
        rewind(self,Block.NULL_BLOCK);
        ThreadContext ctx = self.getRuntime().getCurrentContext();
        while(next_p(self).isTrue()) {
            block.yield(ctx, next(self, Block.NULL_BLOCK));
        }
        return self;
    }
View Full Code Here

Examples of org.jruby.runtime.ThreadContext

                return a;
            }
        }

        public void run() {
            ThreadContext context = gen.getRuntime().getCurrentContext();
            if(enm != null) {
                RuntimeHelpers.invoke(context, enm, "each",
                        CallBlock.newCallClosure(enm,enm.getMetaClass().getRealClass(),Arity.noArguments(),ibc,context));
            } else {
                proc.call(context, new IRubyObject[]{gen});
View Full Code Here

Examples of org.jruby.runtime.ThreadContext

            buffer = buffer.substring(0, cursor);
            int index = buffer.lastIndexOf(" ");
            if (index != -1) {
                buffer = buffer.substring(index + 1);
            }
            ThreadContext context = procCompletor.getRuntime().getCurrentContext();

            IRubyObject comps = RuntimeHelpers
                    .invoke(context, procCompletor, "call", procCompletor.getRuntime().newString(buffer))
                    .callMethod(context, "to_a");
            if (comps instanceof List) {
View Full Code Here

Examples of org.jruby.runtime.ThreadContext

    };

    public static RubyClass createScannerClass(final Ruby runtime) {
        RubyClass scannerClass = runtime.defineClass("StringScanner", runtime.getObject(), STRINGSCANNER_ALLOCATOR);
        scannerClass.defineAnnotatedMethods(RubyStringScanner.class);
        ThreadContext context = runtime.getCurrentContext();
        scannerClass.setConstant("Version", runtime.newString("0.7.0").freeze(context));
        scannerClass.setConstant("Id", runtime.newString("$Id: strscan.c 13506 2007-09-24 08:56:24Z nobu $").freeze(context));

        RubyClass standardError = runtime.getStandardError();
        RubyClass error = scannerClass.defineClassUnder(
View Full Code Here

Examples of org.jruby.runtime.ThreadContext

   
    public static RubyClass createFileClass(Ruby runtime) {
        RubyClass fileClass = runtime.defineClass("File", runtime.getIO(), FILE_ALLOCATOR);
        runtime.setFile(fileClass);
        RubyString separator = runtime.newString("/");
        ThreadContext context = runtime.getCurrentContext();
       
        fileClass.kindOf = new RubyModule.KindOf() {
            @Override
            public boolean isKindOf(IRubyObject obj, RubyModule type) {
                return obj instanceof RubyFile;
View Full Code Here

Examples of org.jruby.runtime.ThreadContext

    private static RubyThread adoptThread(final IRubyObject recv, Thread t, Block block) {
        final Ruby runtime = recv.getRuntime();
        final RubyThread rubyThread = new RubyThread(runtime, (RubyClass) recv);
       
        rubyThread.threadImpl = new NativeThread(rubyThread, t);
        ThreadContext context = runtime.getThreadService().registerNewThread(rubyThread);
       
        context.preAdoptThread();
       
        // set to default thread group
        runtime.getDefaultThreadGroup().addDirectly(rubyThread);
       
        return rubyThread;
View Full Code Here

Examples of org.jruby.runtime.ThreadContext

            }
            return lastException;
        }

        IRubyObject exception;
        ThreadContext context = getRuntime().getCurrentContext();
       
        if(args.length == 1) {
            if(args[0] instanceof RubyString) {
                return runtime.getRuntimeError().newInstance(context, args, block);
            }
View Full Code Here

Examples of org.jruby.runtime.ThreadContext

*/
public class JRubyEngine extends BSFEngineImpl {
    private Ruby runtime;

    public Object apply(String file, int line, int col, Object funcBody, Vector paramNames, Vector args) {
        ThreadContext context = runtime.getCurrentContext();
        try {
            // add a new method conext
            String[] names = new String[paramNames.size()];
            paramNames.toArray(names);

            context.preBsfApply(names);
           
            // FIXME: This is broken.  We are assigning BSF globals as local vars in the top-level
            // scope.  This may be ok, but we are overwriting $~ and $_.  Leaving for now.
            DynamicScope scope = context.getCurrentScope();

            // set global variables
            for (int i = 0, size = args.size(); i < size; i++) {
                scope.setValue(i, JavaEmbedUtils.javaToRuby(runtime, args.get(i)), 0);
            }

          // See eval todo about why this is commented out
            //runtime.setPosition(file, line);

            Node node = runtime.parseEval(file, funcBody.toString(), null, 0);
            IRubyObject result = node.interpret(runtime, context, runtime.getTopSelf(), Block.NULL_BLOCK);
            return JavaEmbedUtils.rubyToJava(runtime, result, Object.class);
        } catch (StackOverflowError sfe) {
            throw runtime.newSystemStackError("stack level too deep");
        } finally {
            context.postBsfApply();
        }
    }
View Full Code Here

Examples of org.jruby.runtime.ThreadContext

        return runtime.evalScriptlet(s1);
    }

    public static Object constructRubyRange(final Constructor ctor, final Node node) {
        final Ruby runtime = ((JRubyConstructor)ctor).runtime;
        ThreadContext context = runtime.getCurrentContext();
        if (node instanceof org.jvyamlb.nodes.ScalarNode) {
            String s1 = ctor.constructScalar(node).toString();
            String first;
            String second;
            boolean exc = 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.