Package org.jruby.runtime

Examples of org.jruby.runtime.ThreadContext


        }
    }

    public void loadScript(Script script) {
        IRubyObject self = getTopSelf();
        ThreadContext context = getCurrentContext();

        try {
            secure(4); /* should alter global state */

            context.preNodeEval(objectClass, self);
           
            script.load(context, self, IRubyObject.NULL_ARRAY, Block.NULL_BLOCK);
        } catch (JumpException.ReturnJump rj) {
            return;
        } finally {
            context.postNodeEval();
        }
    }
View Full Code Here


    }

    @JRubyMethod(name = "count", frame = true, compat = CompatVersion.RUBY1_9)
    public static IRubyObject count(ThreadContext context, IRubyObject self, final Block block) {
        final Ruby runtime = context.getRuntime();
        final ThreadContext localContext = context;
        final int result[];
       
        if (block.isGiven()) {
            result = new int[] { 0 };
            callEach(runtime, context, self, new BlockCallback() {
View Full Code Here

    }
   
    @JRubyMethod(name = "count", frame = true, compat = CompatVersion.RUBY1_9)
    public static IRubyObject count(ThreadContext context, IRubyObject self, final IRubyObject arg, final Block block) {
        final Ruby runtime = context.getRuntime();
        final ThreadContext localContext = context;
        final int result[] = new int[] { 0 };
       
        if (block.isGiven()) runtime.getWarnings().warn(ID.BLOCK_UNUSED , "given block not used");
       
        callEach(runtime, context, self, new BlockCallback() {
View Full Code Here

    }   

    @JRubyMethod(name = "first", compat = CompatVersion.RUBY1_9)
    public static IRubyObject first_0(ThreadContext context, IRubyObject self) {
        final Ruby runtime = context.getRuntime();
        final ThreadContext localContext = context;
       
        final IRubyObject[] holder = new IRubyObject[]{runtime.getNil()};

        try {
            callEach(runtime, context, self, new BlockCallback() {
View Full Code Here

    @JRubyMethod(name = "first", compat = CompatVersion.RUBY1_9)
    public static IRubyObject first_1(ThreadContext context, IRubyObject self, final IRubyObject num) {
        final Ruby runtime = context.getRuntime();
        final RubyArray result = runtime.newArray();
        final ThreadContext localContext = context;

        if(RubyNumeric.fix2int(num) < 0) {
            throw runtime.newArgumentError("negative index");
        }
View Full Code Here

    }

    @JRubyMethod(name = "sort_by", frame = true)
    public static IRubyObject sort_by(ThreadContext context, IRubyObject self, final Block block) {
        final Ruby runtime = context.getRuntime();
        final ThreadContext localContext = context; // MUST NOT be used across threads

        if (self instanceof RubyArray) {
            RubyArray selfArray = (RubyArray) self;
            final IRubyObject[][] valuesAndCriteria = new IRubyObject[selfArray.size()][2];
View Full Code Here

    @JRubyMethod(name = {"detect", "find"}, frame = true)
    public static IRubyObject detect(ThreadContext context, IRubyObject self, IRubyObject ifnone, final Block block) {
        final Ruby runtime = context.getRuntime();
        final IRubyObject result[] = new IRubyObject[] { null };
        final ThreadContext localContext = context;

        try {
            callEach(runtime, context, self, new BlockCallback() {
                public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
                    checkContext(localContext, ctx, "detect/find");
View Full Code Here

    @JRubyMethod(name = "inject", frame = true)
    public static IRubyObject inject(ThreadContext context, IRubyObject self, IRubyObject init, final Block block) {
        final Ruby runtime = context.getRuntime();
        final IRubyObject result[] = new IRubyObject[] { init };
        final ThreadContext localContext = context;

        callEach(runtime, context, self, new BlockCallback() {
            public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
                checkContext(localContext, ctx, "inject");
                result[0] = result[0] == null ?
View Full Code Here

    }

    @JRubyMethod(name = {"include?", "member?"}, required = 1, frame = true)
    public static IRubyObject include_p(ThreadContext context, IRubyObject self, final IRubyObject arg) {
        final Ruby runtime = context.getRuntime();
        final ThreadContext localContext = context;

        try {
            callEach(runtime, context, self, new BlockCallback() {
                public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
                    checkContext(localContext, ctx, "include?/member?");
View Full Code Here

    @JRubyMethod(name = "max", frame = true)
    public static IRubyObject max(ThreadContext context, IRubyObject self, final Block block) {
        final Ruby runtime = context.getRuntime();
        final IRubyObject result[] = new IRubyObject[] { null };
        final ThreadContext localContext = context;

        if (block.isGiven()) {
            callEach(runtime, context, self, new BlockCallback() {
                public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
                    checkContext(localContext, ctx, "max{}");
View Full Code Here

TOP

Related Classes of org.jruby.runtime.ThreadContext

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.