Package org.jruby

Examples of org.jruby.RubySymbol$SymbolTable$SymbolEntry


                break;
            case 'm' :
                rubyObj = RubyModule.unmarshalFrom(this);
                break;
            case 'e':
                RubySymbol moduleName = (RubySymbol) unmarshalObject();
                RubyModule tp = null;
                try {
                    tp = runtime.getClassFromPath(moduleName.asJavaString());
                } catch (RaiseException e) {
                    if (runtime.getModule("NameError").isInstance(e.getException())) {
                        throw runtime.newArgumentError("undefined class/module " + moduleName.asJavaString());
                    }
                    throw e;
                }

                rubyObj = unmarshalObject();
View Full Code Here


        }
        return (int) result;
    }

    private IRubyObject defaultObjectUnmarshal() throws IOException {
        RubySymbol className = (RubySymbol) unmarshalObject(false);

        RubyClass type = null;
        try {
            type = getClassFromPath(runtime, className.toString());
        } catch (RaiseException e) {
            if (runtime.getModule("NameError").isInstance(e.getException())) {
                throw runtime.newArgumentError("undefined class/module " + className.asJavaString());
            }

            throw e;
        }
View Full Code Here

            cls.getVariableAccessorForWrite(name).set(object, value);
        }
    }

    private IRubyObject uclassUnmarshall() throws IOException {
        RubySymbol className = (RubySymbol)unmarshalObject(false);

        RubyClass type = (RubyClass)runtime.getClassFromPath(className.asJavaString());

        // singleton, raise error
        if (type.isSingleton()) throw runtime.newTypeError("singleton can't be loaded");

        // All "C" marshalled objects descend from core classes, which are all at least RubyObject
View Full Code Here

        }
        return callback;
    }

    public final RubySymbol getSymbol(ThreadContext context, int index, String name) {
        RubySymbol symbol = symbols[index];
        if (symbol == null) {
            return symbols[index] = context.runtime.newSymbol(name);
        }
        return symbol;
    }
View Full Code Here

                if (keywords != null) {
                    for (Node knode : keywords.childNodes()) {
                        KeywordArgNode kwarg = (KeywordArgNode)knode;
                        LocalAsgnNode kasgn = (LocalAsgnNode)kwarg.getAssignable();
                        String name = kasgn.getName();
                        RubySymbol sym = runtime.newSymbol(name);

                        if (keyValues.op_aref(context, sym).isNil()) {
                            kasgn.interpret(runtime, context, self, Block.NULL_BLOCK);
                        } else {
                            IRubyObject value = keyValues.delete(context, sym, Block.NULL_BLOCK);
View Full Code Here

        site.setTarget(handle);
        return site;
    }

    public static IRubyObject symbol(MutableCallSite site, String name, ThreadContext context) {
        RubySymbol symbol = RubySymbol.newSymbol(context.runtime, name);
        site.setTarget(Binder
                .from(IRubyObject.class, ThreadContext.class)
                .drop(0)
                .constant(symbol)
        );
View Full Code Here

        public static IRubyObject methodArgs(IRubyObject recv) {
            Ruby runtime = recv.getRuntime();
            RubyMethod rubyMethod = (RubyMethod)recv;
            RubyArray argsArray = RubyArray.newArray(runtime);
            DynamicMethod method = rubyMethod.getMethod();
            RubySymbol req = runtime.newSymbol("req");
            RubySymbol opt = runtime.newSymbol("opt");
            RubySymbol rest = runtime.newSymbol("rest");
            RubySymbol block = runtime.newSymbol("block");

            if (method instanceof MethodArgs2) {
                return RuntimeHelpers.parameterListToParameters(runtime, ((MethodArgs2)method).getParameterList(), true);
            } else if (method instanceof MethodArgs) {
                MethodArgs interpMethod = (MethodArgs)method;
                ArgsNode args = interpMethod.getArgsNode();
               
                ListNode requiredArgs = args.getPre();
                for (int i = 0; requiredArgs != null && i < requiredArgs.size(); i++) {
                    Node argNode = requiredArgs.get(i);
                    if (argNode instanceof MultipleAsgn19Node) {
                        argsArray.append(RubyArray.newArray(runtime, req));
                    } else {
                        argsArray.append(RubyArray.newArray(runtime, req, getNameFrom(runtime, (INameNode)argNode)));
                    }
                }
               
                ListNode optArgs = args.getOptArgs();
                for (int i = 0; optArgs != null && i < optArgs.size(); i++) {
                    argsArray.append(RubyArray.newArray(runtime, opt, getNameFrom(runtime, (INameNode) optArgs.get(i))));
                }

                if (args.getRestArg() >= 0) {
                    RestArgNode restArg = (RestArgNode) args.getRestArgNode();

                    if (restArg instanceof UnnamedRestArgNode) {
                        if (((UnnamedRestArgNode) restArg).isStar()) {
                            argsArray.append(RubyArray.newArray(runtime, rest));
                        }
                    } else {
                        argsArray.append(RubyArray.newArray(runtime, rest, getNameFrom(runtime, args.getRestArgNode())));
                    }
                }
               
                ListNode requiredArgsPost = args.getPost();
                for (int i = 0; requiredArgsPost != null && i < requiredArgsPost.size(); i++) {
                    Node argNode = requiredArgsPost.get(i);
                    if (argNode instanceof MultipleAsgn19Node) {
                        argsArray.append(RubyArray.newArray(runtime, req));
                    } else {
                        argsArray.append(RubyArray.newArray(runtime, req, getNameFrom(runtime, (INameNode) requiredArgsPost.get(i))));
                    }
                }

                if (args.getBlock() != null) {
                    argsArray.append(RubyArray.newArray(runtime, block, getNameFrom(runtime, args.getBlock())));
                }
            } else if (method instanceof IRMethodArgs) {
                for (String[] argParam: ((IRMethodArgs)method).getParameterList()) {
                    RubySymbol argType = runtime.newSymbol(argParam[0]);
                    if (argParam[1] == "") argsArray.append(RubyArray.newArray(runtime, argType));
                    else argsArray.append(RubyArray.newArray(runtime, argType, runtime.newSymbol(argParam[1])));
                }
            } else {
                if (method.getArity() == Arity.OPTIONAL) {
View Full Code Here

    public static IRubyObject connect(ThreadContext context, IRubyObject klazz, IRubyObject arg) {
        String uriOrMap = null;
        if (arg instanceof RubyString) {
            uriOrMap = DiametricUtils.rubyStringToJava(arg);
        } else if (arg instanceof RubyHash) {
            RubySymbol key = RubySymbol.newSymbol(context.getRuntime(), "uri");
            RubyString value = (RubyString)((RubyHash)arg).op_aref(context, key);
            uriOrMap = DiametricUtils.rubyStringToJava(value);
        } else {
            throw context.getRuntime().newArgumentError("Argument should be a String or Hash");
        }
View Full Code Here

            Var assoc_fn = DiametricService.getFn("clojure.core", "assoc");
            String[] keys = new String[] { "lang", "params", "code", "requires", "imports" };
            Class[] valueTypes =
                    new Class[] { RubySymbol.class, RubyArray.class, RubyString.class, RubyArray.class, RubyArray.class };
            for (int i = 0; i < keys.length; i++) {
                RubySymbol ruby_key = context.getRuntime().newSymbol(keys[i]);
                IRubyObject ruby_value = params.op_aref(context, ruby_key);
                if (ruby_value.isNil()) continue;
                clj_map = (PersistentArrayMap) assoc_fn.invoke(
                            clj_map,
                            DiametricService.keywords.get(ruby_key.toString()),
                            convertRubyValueToJava(context, ruby_value, valueTypes[i]));
            }
            RubyClass clazz = (RubyClass) context.getRuntime().getClassFromPath("Diametric::Persistence::Function");
            DiametricFunction ruby_function = (DiametricFunction) clazz.allocate();
            Var function_fn = DiametricService.getFn("datomic.api", "function");
View Full Code Here

        int index = 0;
        HashSet<RubySymbol> validKeySet = new HashSet<RubySymbol>();

        // Build the return values
        for(String key : validKeys) {
            RubySymbol keySym = context.runtime.newSymbol(key);
            if (options.containsKey(keySym)) {
                ret[index] = options.fastARef(keySym);
            } else {
                ret[index] = context.runtime.getNil();
            }
View Full Code Here

TOP

Related Classes of org.jruby.RubySymbol$SymbolTable$SymbolEntry

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.