private Variables(Ruby runtime) { super(runtime); //we have to copy variables from the origin one to this GlobalVariables vars = runtime.getGlobalVariables(); for (Iterator it = vars.getNames().iterator(); it.hasNext();) { final String nm = (String) it.next(); set(nm, vars.get(nm)); } }
private Variables(Ruby runtime) { super(runtime); //we have to copy variables from the origin one to this GlobalVariables vars = runtime.getGlobalVariables(); for (Iterator it = vars.getNames().iterator(); it.hasNext();) { final String nm = (String)it.next(); set(nm, vars.get(nm)); } }
/** * Retrieves a global variable by key from Ruby runtime after the evaluation. * This method is used when eager retrieval is off. * * @param runtime Ruby runtime * @param vars map to save a retrieved global variable. * @param key name of the global variable */ public static void retrieveByKey(Ruby runtime, BiVariableMap vars, String key) { GlobalVariables gvars = runtime.getGlobalVariables(); // if the specified key doesn't exist, this method is called before the // evaluation. Don't update value in this case. String rubyKey = ("$" + key).intern(); if (!gvars.getNames().contains(rubyKey)) return; // the specified key is found, so let's update IRubyObject value = gvars.get(rubyKey); updateLocalGlobal((RubyObject)runtime.getTopSelf(), vars, key, value); }
/** * Retrieves a global variable by key from Ruby runtime after the evaluation. * This method is used when eager retrieval is off. * * @param runtime Ruby runtime * @param vars map to save a retrieved global variable. * @param key name of the global variable */ public static void retrieveByKey(Ruby runtime, BiVariableMap vars, String key) { GlobalVariables gvars = runtime.getGlobalVariables(); // if the specified key doesn't exist, this method is called before the // evaluation. Don't update value in this case. String rubyKey = ("$" + key).intern(); if (!gvars.getNames().contains(rubyKey)) return; // the specified key is found, so let's update IRubyObject value = gvars.get(rubyKey); updateLocalGlobal((RubyObject)runtime.getTopSelf(), vars, key, value); }
/** * Retrieves a global variable by key from Ruby runtime after the evaluation. * This method is used when eager retrieval is off. * * @param runtime Ruby runtime * @param vars map to save a retrieved global variable. * @param name name of the global variable */ public static void retrieveByKey(final Ruby runtime, final BiVariableMap vars, final String name) { final GlobalVariables globalVars = runtime.getGlobalVariables(); // if the specified key doesn't exist, this method is called before the // evaluation. Don't update value in this case. final String gName = ("$" + name).intern(); if ( ! globalVars.getNames().contains(gName) ) return; // the specified key is found, so let's update final IRubyObject value = globalVars.get(gName); updateLocalGlobal((RubyObject) runtime.getTopSelf(), vars, name, value); }
/** * Retrieves a global variable by key from Ruby after the evaluation. * * @param runtime Ruby runtime * @param receiver receiver object returned when a script is evaluated. * @param vars map to save a retrieved global variable. * @param key name of the global variable */ public static void retrieveByKey(Ruby runtime, BiVariableMap vars, String key) { GlobalVariables globalVars = runtime.getGlobalVariables(); // if the specified key doesn't exist, this method is called before the // evaluation. Don't update value in this case. if ( ! globalVars.getNames().contains(key) ) return; // the specified key is found, so let's update IRubyObject value = globalVars.get(key); updateGlobalVar(vars, (RubyObject) runtime.getTopSelf(), key, value); }
/** * Retrieves a global variable by key from Ruby after the evaluation. * * @param runtime Ruby runtime * @param receiver receiver object returned when a script is evaluated. * @param vars map to save a retrieved global variable. * @param key name of the global variable */ public static void retrieveByKey(Ruby runtime, BiVariableMap vars, String key) { GlobalVariables globalVars = runtime.getGlobalVariables(); // if the specified key doesn't exist, this method is called before the // evaluation. Don't update value in this case. if ( ! globalVars.getNames().contains(key) ) return; // the specified key is found, so let's update IRubyObject value = globalVars.get(key); updateGlobalVar(vars, (RubyObject) runtime.getTopSelf(), key, value); }
/** * Retrieves a global variable by key from Ruby after the evaluation. * * @param runtime Ruby runtime * @param receiver receiver object returned when a script is evaluated. * @param vars map to save a retrieved global variable. * @param key name of the global variable */ public static void retrieveByKey(Ruby runtime, BiVariableMap vars, String key) { GlobalVariables gvars = runtime.getGlobalVariables(); // if the specified key doesn't exist, this method is called before the // evaluation. Don't update value in this case. if (!gvars.getNames().contains(key)) return; // the specified key is found, so let's update IRubyObject value = gvars.get(key); updateGlobalVar(vars, (RubyObject)runtime.getTopSelf(), key, value); }
/** * Retrieves a global variable by key from Ruby after the evaluation. * * @param runtime Ruby runtime * @param receiver receiver object returned when a script is evaluated. * @param vars map to save a retrieved global variable. * @param key name of the global variable */ public static void retrieveByKey(Ruby runtime, BiVariableMap vars, String key) { GlobalVariables gvars = runtime.getGlobalVariables(); // if the specified key doesn't exist, this method is called before the // evaluation. Don't update value in this case. if (!gvars.getNames().contains(key)) return; // the specified key is found, so let's update IRubyObject value = gvars.get(key); updateGlobalVar(vars, (RubyObject)runtime.getTopSelf(), key, value); }
/** Returns an Array with the names of all global variables. * */ @JRubyMethod(name = "global_variables", module = true, visibility = PRIVATE) public static RubyArray global_variables(ThreadContext context, IRubyObject recv) { Ruby runtime = context.runtime; RubyArray globalVariables = runtime.newArray(); for (String globalVariableName : runtime.getGlobalVariables().getNames()) { globalVariables.append(runtime.newString(globalVariableName)); } return globalVariables; }
@JRubyMethod(name = "global_variables", module = true, visibility = PRIVATE, compat = RUBY1_9) public static RubyArray global_variables19(ThreadContext context, IRubyObject recv) { Ruby runtime = context.runtime; RubyArray globalVariables = runtime.newArray(); for (String globalVariableName : runtime.getGlobalVariables().getNames()) { globalVariables.append(runtime.newSymbol(globalVariableName)); } return globalVariables; }
@JRubyMethod(name = "global_variables", module = true, visibility = PRIVATE, compat = RUBY1_9) public static RubyArray global_variables19(ThreadContext context, IRubyObject recv) { Ruby runtime = context.runtime; RubyArray globalVariables = runtime.newArray(); for (String globalVariableName : runtime.getGlobalVariables().getNames()) { globalVariables.append(runtime.newSymbol(globalVariableName)); } return globalVariables; }
/** Returns an Array with the names of all global variables. * */ @JRubyMethod(name = "global_variables", module = true, visibility = PRIVATE) public static RubyArray global_variables(ThreadContext context, IRubyObject recv) { Ruby runtime = context.runtime; RubyArray globalVariables = runtime.newArray(); for (String globalVariableName : runtime.getGlobalVariables().getNames()) { globalVariables.append(runtime.newString(globalVariableName)); } return globalVariables; }
/** * @param context * @param recv * @return an Array with the names of all global variables. */ @JRubyMethod(name = "global_variables", module = true, visibility = PRIVATE) public static RubyArray global_variables(ThreadContext context, IRubyObject recv) { Ruby runtime = context.runtime; RubyArray globalVariables = runtime.newArray(); for (String globalVariableName : runtime.getGlobalVariables().getNames()) { globalVariables.append(runtime.newSymbol(globalVariableName)); } return globalVariables; }
/** * @param context * @param recv * @return an Array with the names of all global variables. */ @JRubyMethod(name = "global_variables", module = true, visibility = PRIVATE) public static RubyArray global_variables(ThreadContext context, IRubyObject recv) { Ruby runtime = context.runtime; RubyArray globalVariables = runtime.newArray(); for (String globalVariableName : runtime.getGlobalVariables().getNames()) { globalVariables.append(runtime.newSymbol(globalVariableName)); } return globalVariables; }
/** * Retrieves global variables eagerly from Ruby right after the evaluation. The * variable names to be retrieved must be in a variable map. * * @param receiver receiver object returned when a script is evaluated. * @param vars map to save retrieved global variables. */ public static void retrieve(final RubyObject receiver, final BiVariableMap vars) { if ( vars.isLazy() ) return; final GlobalVariables globalVars = receiver.getRuntime().getGlobalVariables(); for ( final String name : globalVars.getNames() ) { if ( isPredefined(name) ) continue; final IRubyObject value = globalVars.get(name); String javaName = name.substring(1); // eliminates a preceding character, "$" updateLocalGlobal(getTopSelf(receiver), vars, javaName, value); } }
/** * Retrieves global variables eagerly from Ruby right after the evaluation. The * variable names to be retrieved must be in a variable map. * * @param receiver receiver object returned when a script is evaluated. * @param vars map to save retrieved global variables. */ public static void retrieve(final RubyObject receiver, final BiVariableMap vars) { if ( vars.isLazy() ) return; final GlobalVariables globalVars = receiver.getRuntime().getGlobalVariables(); for ( final String name : globalVars.getNames() ) { if ( isPredefined(name) ) continue; final IRubyObject value = globalVars.get(name); String javaName = name.substring(1); // eliminates a preceding character, "$" updateLocalGlobal(getTopSelf(receiver), vars, javaName, value); } }
/** * Retrieves global variables from Ruby after the evaluation. * * @param runtime Ruby runtime * @param receiver receiver object returned when a script is evaluated. * @param vars map to save retrieved global variables. */ public static void retrieve(IRubyObject receiver, BiVariableMap vars) { if ( vars.isLazy() ) return; GlobalVariables globalVars = receiver.getRuntime().getGlobalVariables(); for ( final String name : globalVars.getNames() ) { if ( isPredefined(name) ) continue; IRubyObject value = globalVars.get(name); // receiver of gvar should to topSelf always updateGlobalVar(vars, getTopSelf(receiver), name, value); } }
/** * Retrieves global variables from Ruby after the evaluation. * * @param runtime Ruby runtime * @param receiver receiver object returned when a script is evaluated. * @param vars map to save retrieved global variables. */ public static void retrieve(IRubyObject receiver, BiVariableMap vars) { if ( vars.isLazy() ) return; GlobalVariables globalVars = receiver.getRuntime().getGlobalVariables(); for ( final String name : globalVars.getNames() ) { if ( isPredefined(name) ) continue; IRubyObject value = globalVars.get(name); // receiver of gvar should to topSelf always updateGlobalVar(vars, getTopSelf(receiver), name, value); } }
/** * Retrieves global variables from Ruby after the evaluation. * * @param runtime Ruby runtime * @param receiver receiver object returned when a script is evaluated. * @param vars map to save retrieved global variables. */ public static void retrieve(IRubyObject receiver, BiVariableMap vars) { if (vars.isLazy()) return; GlobalVariables gvars = receiver.getRuntime().getGlobalVariables(); Set<String> names = gvars.getNames(); for (String name : names) { if (isPredefined(name)) { continue; } IRubyObject value = gvars.get(name); // reciever of gvar should to topSelf always updateGlobalVar(vars, (RubyObject)receiver.getRuntime().getTopSelf(), name, value); } }