org.jruby.Ruby.getTopSelf()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(141)

本文整理了Java中org.jruby.Ruby.getTopSelf方法的一些代码示例,展示了Ruby.getTopSelf的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getTopSelf方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getTopSelf

Ruby.getTopSelf介绍

[英]Getter for property rubyTopSelf.
[中]属性rubyTopSelf的Getter。

代码示例

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

private RubyObject getReceiverObject(Object receiver) {
  if (receiver == null || !(receiver instanceof IRubyObject)) return (RubyObject)provider.getRuntime().getTopSelf();
  else if (receiver instanceof RubyObject) return (RubyObject)receiver;
  else return (RubyObject)((IRubyObject)receiver).getRuntime().getTopSelf();
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

private RubyObject getReceiverObject(Object receiver) {
  if (receiver == null || !(receiver instanceof IRubyObject)) return (RubyObject)provider.getRuntime().getTopSelf();
  else if (receiver instanceof RubyObject) return (RubyObject)receiver;
  else return (RubyObject)((IRubyObject)receiver).getRuntime().getTopSelf();
}

代码示例来源:origin: org.jruby/jruby-complete

private RubyObject getReceiverObject(Object receiver) {
  Ruby runtime = container.getProvider().getRuntime();
  if (receiver == null || !(receiver instanceof IRubyObject)) {
    return (RubyObject)runtime.getTopSelf();
  }
  else if (receiver instanceof RubyObject) return (RubyObject)receiver;
  else return (RubyObject)((IRubyObject)receiver).getRuntime().getTopSelf();
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

private RubyObject getReceiverObject(Object receiver) {
  Ruby runtime = container.getProvider().getRuntime();
  if (receiver == null || !(receiver instanceof IRubyObject)) {
    return (RubyObject)runtime.getTopSelf();
  }
  else if (receiver instanceof RubyObject) return (RubyObject)receiver;
  else return (RubyObject)((IRubyObject)receiver).getRuntime().getTopSelf();
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

private RubyObject getReceiverObject(Object receiver) {
  Ruby runtime = container.getProvider().getRuntime();
  if (receiver == null || !(receiver instanceof IRubyObject)) {
    return (RubyObject)runtime.getTopSelf();
  }
  else if (receiver instanceof RubyObject) return (RubyObject)receiver;
  else return (RubyObject)((IRubyObject)receiver).getRuntime().getTopSelf();
}

代码示例来源:origin: org.jruby/jruby-core

private RubyObject getReceiverObject(Object receiver) {
  Ruby runtime = container.getProvider().getRuntime();
  if (receiver == null || !(receiver instanceof IRubyObject)) {
    return (RubyObject)runtime.getTopSelf();
  }
  else if (receiver instanceof RubyObject) return (RubyObject)receiver;
  else return (RubyObject)((IRubyObject)receiver).getRuntime().getTopSelf();
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/**
 * Returns the value in BiVariable type to which the specified key is mapped,
 * or {@code null} if this map contains no mapping for the key.
 * 
 * @param key is the key whose associated BiVariable object is to be returned
 * @return the BiVariable type object to which the specified key is mapped, or
 *         {@code null} if this map contains no mapping for the key
 */
@Deprecated
public BiVariable getVariable(String key) {
  return getVariable((RubyObject)provider.getRuntime().getTopSelf(), key);
}

代码示例来源:origin: org.jruby/jruby-complete

/**
 * This is used for the "gets" loop, and we bypass 'load' to use an
 * already-prepared, already-pushed scope for the script body.
 */
public IRubyObject runScriptBody(Script script) {
  return script.__file__(getCurrentContext(), getTopSelf(), Block.NULL_BLOCK);
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public void loadScript(Script script, boolean wrap) {
  IRubyObject self = getTopSelf();
  ThreadContext context = getCurrentContext();
  try {
    script.load(context, self, wrap);
  } catch (JumpException.ReturnJump rj) {
    return;
  }
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/**
 * Removes the mapping for a key from this map if it is present in a top level.
 *
 * <p>Returns the value to which this map previously associated the key,
 * or <tt>null</tt> if the map contained no mapping for the key.
 * @param key the key whose mapping is to be removed from the map
 * @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 key) {
  return removeFrom(provider.getRuntime().getTopSelf(), key);
}

代码示例来源:origin: org.jruby/yecht

public IRubyObject create(Ruby runtime, org.yecht.Node n, Data.Str ds) throws java.io.UnsupportedEncodingException {
    IRubyObject year = runtime.newFixnum(Integer.parseInt(new String(ds.ptr.buffer, 0, 4, "ISO-8859-1")));
    IRubyObject mon = runtime.newFixnum(Integer.parseInt(new String(ds.ptr.buffer, 5, 2, "ISO-8859-1")));
    IRubyObject day = runtime.newFixnum(Integer.parseInt(new String(ds.ptr.buffer, 8, 2, "ISO-8859-1")));
  
    RubyKernel.require(runtime.getTopSelf(), runtime.newString("date"), Block.NULL_BLOCK);
    return runtime.getClass("Date").callMethod(runtime.getCurrentContext(), "new", new IRubyObject[] {year, mon, day});
  }
});

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public IRubyObject runScript(Script script, boolean wrap) {
  ThreadContext context = getCurrentContext();
  
  try {
    return script.load(context, getTopSelf(), wrap);
  } catch (JumpException.ReturnJump rj) {
    return (IRubyObject) rj.getValue();
  }
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public IRubyObject runScript(Script script, boolean wrap) {
  ThreadContext context = getCurrentContext();
  
  try {
    return script.load(context, getTopSelf(), wrap);
  } catch (JumpException.ReturnJump rj) {
    return (IRubyObject) rj.getValue();
  }
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/**
 * Retrieves instance 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 instance variables.
 */
public static void retrieve(RubyObject receiver, BiVariableMap vars) {
  if (vars.isLazy()) return;
  updateInstanceVar(receiver, vars);
  updateInstanceVar((RubyObject)receiver.getRuntime().getTopSelf(), vars);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/**
 * Retrieves instance 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 instance variables.
 */
public static void retrieve(RubyObject receiver, BiVariableMap vars) {
  if (vars.isLazy()) return;
  updateInstanceVar(receiver, vars);
  updateInstanceVar((RubyObject)receiver.getRuntime().getTopSelf(), vars);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public IRubyObject runInterpreter(ThreadContext context, Node rootNode, IRubyObject self) {
  assert rootNode != null : "scriptNode is not null";
  try {
    if (getInstanceConfig().getCompileMode() == CompileMode.OFFIR) {
      return Interpreter.interpret(this, rootNode, self);
    } else {
      return ASTInterpreter.INTERPRET_ROOT(this, context, rootNode, getTopSelf(), Block.NULL_BLOCK);
    }
  } catch (JumpException.ReturnJump rj) {
    return (IRubyObject) rj.getValue();
  }
}

代码示例来源:origin: org.jruby/jruby-complete

public IRubyObject getInstanceVariable(IRubyObject obj, String variableName) {
  BiVariableMap map = container.getVarMap();
  synchronized (map) {
    if (map.containsKey(variableName)) {
      BiVariable bv = map.getVariable((RubyObject)container.getProvider().getRuntime().getTopSelf(), variableName);
      return bv.getRubyObject();
    }
  }
  return null;
}

代码示例来源:origin: org.jruby/jruby-complete

public static void preLoadCommon(ThreadContext context, StaticScope staticScope, boolean wrap) {
  RubyModule objectClass = context.runtime.getObject();
  if (wrap) {
    objectClass = RubyModule.newModule(context.runtime);
  }
  staticScope.setModule(objectClass);
  DynamicScope scope = DynamicScope.newDynamicScope(staticScope);
  // Each root node has a top-level scope that we need to push
  context.preScopedBody(scope);
  context.preNodeEval(context.runtime.getTopSelf());
}

代码示例来源:origin: org.jruby/jruby-core

public IRubyObject getInstanceVariable(IRubyObject obj, String variableName) {
  BiVariableMap map = container.getVarMap();
  synchronized (map) {
    if (map.containsKey(variableName)) {
      BiVariable bv = map.getVariable((RubyObject)container.getProvider().getRuntime().getTopSelf(), variableName);
      return bv.getRubyObject();
    }
  }
  return null;
}

代码示例来源:origin: org.jruby/jruby-core

public static void preLoadCommon(ThreadContext context, StaticScope staticScope, boolean wrap) {
  RubyModule objectClass = context.runtime.getObject();
  if (wrap) {
    objectClass = RubyModule.newModule(context.runtime);
  }
  staticScope.setModule(objectClass);
  DynamicScope scope = DynamicScope.newDynamicScope(staticScope);
  // Each root node has a top-level scope that we need to push
  context.preScopedBody(scope);
  context.preNodeEval(context.runtime.getTopSelf());
}

相关文章

Ruby类方法