Package org.jruby

Examples of org.jruby.RubyObject$Data


    }

    @Deprecated
    public static Object coerceJavaObjectToType(ThreadContext context, Object javaObject, Class target) {
        if (javaObject != null && isDuckTypeConvertable(javaObject.getClass(), target)) {
            RubyObject rubyObject = (RubyObject) javaObject;
            if (!rubyObject.respondsTo("java_object")) {
                return convertProcToInterface(context, rubyObject, target);
            }

            // can't be converted any more, return it
            return javaObject;
View Full Code Here


        List<AbstractBlock> rubyBlocks = delegate.blocks();

        for (int i = 0; i < rubyBlocks.size(); i++) {
            Object abstractBlock = rubyBlocks.get(i);
            if (!(abstractBlock instanceof RubyArray) && !(abstractBlock instanceof Block)) {
                RubyObject rubyObject = (RubyObject) abstractBlock;
                rubyBlocks.set(i, overrideRubyObjectToJavaObject(rubyObject));
            }
        }

        return rubyBlocks;
View Full Code Here

                selector));

        for (int i = 0; i < findBy.size(); i++) {
            Object abstractBlock = findBy.get(i);
            if (!(abstractBlock instanceof RubyArray) && !(abstractBlock instanceof AbstractBlock)) {
                RubyObject rubyObject = (RubyObject)abstractBlock;
                findBy.set(i, overrideRubyObjectToJavaObject(rubyObject));
            }

        }
        return findBy;
View Full Code Here

    }

    private static final BigInteger UINT64_BASE = BigInteger.valueOf(Long.MAX_VALUE).add(BigInteger.ONE);

    public static long ull2inum(Ruby runtime, long l) {
        RubyObject n = l < 0
                    ? RubyBignum.newBignum(runtime, BigInteger.valueOf(l & 0x7fffffffffffffffL).add(UINT64_BASE))
                    : runtime.newFixnum(l);

        Handle h = GC.lookup(n);
        if (h != null) {
View Full Code Here

     * @return the value in simple Java object to which the specified key is mapped, or
     *         {@code null} if this map contains no mapping for the key
     */
    public V get(Object receiver, Object key) {
        checkKey(key);
        RubyObject robj = getReceiverObject(receiver);
        // attemps to retrieve global variables
        if (lazy) VariableInterceptor.tryLazyRetrieval(provider.getLocalVariableBehavior(), this, robj, key);
        BiVariable var = getVariable(robj, (String)key);
        if (var == null) return null;
        else return (V) var.getJavaObject();
View Full Code Here

     * @return the previous value associated with <tt>key</tt>, or
     *         <tt>null</tt> if there was no mapping for <tt>key</tt>.
     */
    public V put (Object receiver, K key, V value) {
        checkKey(key);
        RubyObject robj = getReceiverObject(receiver);
        String name = ((String)key).intern();
        BiVariable v = getVariable(robj, name);
        Object oldValue = null;
        if (v != null) {
            // updates
            oldValue = v.getJavaObject();
            v.setJavaObject(robj.getRuntime(), value);
        } else {
            // creates new value
            v = VariableInterceptor.getVariableInstance(provider.getLocalVariableBehavior(), robj, name, value);
            if (v != null) {
                update(name, v);
View Full Code Here

    void inject(ManyVarsDynamicScope scope, int depth, IRubyObject receiver) {
        VariableInterceptor.inject(this, provider.getRuntime(), scope, depth, receiver);
    }

    void retrieve(IRubyObject receiver) {
        RubyObject robj = getReceiverObject(receiver);
        VariableInterceptor.retrieve(provider.getLocalVariableBehavior(), this, robj);
    }
View Full Code Here

     * @return the previous value associated with <tt>key</tt>, or
     *         <tt>null</tt> if there was no mapping for <tt>key</tt>.
     */
    public V remove(Object receiver, Object key) {
        checkKey(key);
        RubyObject robj = getReceiverObject(receiver);
        String name = ((String)key).intern();
        for (int i=0; i<varNames.size(); i++) {
            if (name.equals(varNames.get(i))) {
                BiVariable var = variables.get(i);
                if (var.getReceiver() == robj) {
View Full Code Here

    public static void retrieve(RubyObject receiver, BiVariableMap vars) {
        if (vars.isLazy()) return;
        // trying to get variables from receiver;
        updateClassVar(receiver, vars);
        // trying to get variables from topself.
        RubyObject topSelf = (RubyObject) receiver.getRuntime().getTopSelf();
        updateClassVar(topSelf, vars);
    }
View Full Code Here

        return adapter.callSuper(receiver, args, block);
    }

    public <T> T callMethod(Object receiver, String methodName, Class<T> returnType) {
        try {
            RubyObject rubyReceiver = getReceiverObject(receiver);
            return call(MethodType.CALLMETHOD_NOARG, returnType, rubyReceiver, methodName, null, null);
        } catch (InvokeFailedException e) {
            throw e;
        } catch (Throwable e) {
            throw new InvokeFailedException(e);
View Full Code Here

TOP

Related Classes of org.jruby.RubyObject$Data

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.