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

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

本文整理了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

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

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

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

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

  1. private RubyObject getReceiverObject(Object receiver) {
  2. Ruby runtime = container.getProvider().getRuntime();
  3. if (receiver == null || !(receiver instanceof IRubyObject)) {
  4. return (RubyObject)runtime.getTopSelf();
  5. }
  6. else if (receiver instanceof RubyObject) return (RubyObject)receiver;
  7. else return (RubyObject)((IRubyObject)receiver).getRuntime().getTopSelf();
  8. }

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

  1. private RubyObject getReceiverObject(Object receiver) {
  2. Ruby runtime = container.getProvider().getRuntime();
  3. if (receiver == null || !(receiver instanceof IRubyObject)) {
  4. return (RubyObject)runtime.getTopSelf();
  5. }
  6. else if (receiver instanceof RubyObject) return (RubyObject)receiver;
  7. else return (RubyObject)((IRubyObject)receiver).getRuntime().getTopSelf();
  8. }

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

  1. private RubyObject getReceiverObject(Object receiver) {
  2. Ruby runtime = container.getProvider().getRuntime();
  3. if (receiver == null || !(receiver instanceof IRubyObject)) {
  4. return (RubyObject)runtime.getTopSelf();
  5. }
  6. else if (receiver instanceof RubyObject) return (RubyObject)receiver;
  7. else return (RubyObject)((IRubyObject)receiver).getRuntime().getTopSelf();
  8. }

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

  1. private RubyObject getReceiverObject(Object receiver) {
  2. Ruby runtime = container.getProvider().getRuntime();
  3. if (receiver == null || !(receiver instanceof IRubyObject)) {
  4. return (RubyObject)runtime.getTopSelf();
  5. }
  6. else if (receiver instanceof RubyObject) return (RubyObject)receiver;
  7. else return (RubyObject)((IRubyObject)receiver).getRuntime().getTopSelf();
  8. }

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

  1. /**
  2. * Returns the value in BiVariable type to which the specified key is mapped,
  3. * or {@code null} if this map contains no mapping for the key.
  4. *
  5. * @param key is the key whose associated BiVariable object is to be returned
  6. * @return the BiVariable type object to which the specified key is mapped, or
  7. * {@code null} if this map contains no mapping for the key
  8. */
  9. @Deprecated
  10. public BiVariable getVariable(String key) {
  11. return getVariable((RubyObject)provider.getRuntime().getTopSelf(), key);
  12. }

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

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

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

  1. public void loadScript(Script script, boolean wrap) {
  2. IRubyObject self = getTopSelf();
  3. ThreadContext context = getCurrentContext();
  4. try {
  5. script.load(context, self, wrap);
  6. } catch (JumpException.ReturnJump rj) {
  7. return;
  8. }
  9. }

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

  1. /**
  2. * Removes the mapping for a key from this map if it is present in a top level.
  3. *
  4. * <p>Returns the value to which this map previously associated the key,
  5. * or <tt>null</tt> if the map contained no mapping for the key.
  6. * @param key the key whose mapping is to be removed from the map
  7. * @return the previous value associated with <tt>key</tt>, or
  8. * <tt>null</tt> if there was no mapping for <tt>key</tt>.
  9. */
  10. public V remove(Object key) {
  11. return removeFrom(provider.getRuntime().getTopSelf(), key);
  12. }

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

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

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

  1. public IRubyObject runScript(Script script, boolean wrap) {
  2. ThreadContext context = getCurrentContext();
  3. try {
  4. return script.load(context, getTopSelf(), wrap);
  5. } catch (JumpException.ReturnJump rj) {
  6. return (IRubyObject) rj.getValue();
  7. }
  8. }

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

  1. public IRubyObject runScript(Script script, boolean wrap) {
  2. ThreadContext context = getCurrentContext();
  3. try {
  4. return script.load(context, getTopSelf(), wrap);
  5. } catch (JumpException.ReturnJump rj) {
  6. return (IRubyObject) rj.getValue();
  7. }
  8. }

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

  1. /**
  2. * Retrieves instance variables from Ruby after the evaluation.
  3. *
  4. * @param runtime Ruby runtime
  5. * @param receiver receiver object returned when a script is evaluated.
  6. * @param vars map to save retrieved instance variables.
  7. */
  8. public static void retrieve(RubyObject receiver, BiVariableMap vars) {
  9. if (vars.isLazy()) return;
  10. updateInstanceVar(receiver, vars);
  11. updateInstanceVar((RubyObject)receiver.getRuntime().getTopSelf(), vars);
  12. }

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

  1. /**
  2. * Retrieves instance variables from Ruby after the evaluation.
  3. *
  4. * @param runtime Ruby runtime
  5. * @param receiver receiver object returned when a script is evaluated.
  6. * @param vars map to save retrieved instance variables.
  7. */
  8. public static void retrieve(RubyObject receiver, BiVariableMap vars) {
  9. if (vars.isLazy()) return;
  10. updateInstanceVar(receiver, vars);
  11. updateInstanceVar((RubyObject)receiver.getRuntime().getTopSelf(), vars);
  12. }

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

  1. public IRubyObject runInterpreter(ThreadContext context, Node rootNode, IRubyObject self) {
  2. assert rootNode != null : "scriptNode is not null";
  3. try {
  4. if (getInstanceConfig().getCompileMode() == CompileMode.OFFIR) {
  5. return Interpreter.interpret(this, rootNode, self);
  6. } else {
  7. return ASTInterpreter.INTERPRET_ROOT(this, context, rootNode, getTopSelf(), Block.NULL_BLOCK);
  8. }
  9. } catch (JumpException.ReturnJump rj) {
  10. return (IRubyObject) rj.getValue();
  11. }
  12. }

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

  1. public IRubyObject getInstanceVariable(IRubyObject obj, String variableName) {
  2. BiVariableMap map = container.getVarMap();
  3. synchronized (map) {
  4. if (map.containsKey(variableName)) {
  5. BiVariable bv = map.getVariable((RubyObject)container.getProvider().getRuntime().getTopSelf(), variableName);
  6. return bv.getRubyObject();
  7. }
  8. }
  9. return null;
  10. }

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

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

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

  1. public IRubyObject getInstanceVariable(IRubyObject obj, String variableName) {
  2. BiVariableMap map = container.getVarMap();
  3. synchronized (map) {
  4. if (map.containsKey(variableName)) {
  5. BiVariable bv = map.getVariable((RubyObject)container.getProvider().getRuntime().getTopSelf(), variableName);
  6. return bv.getRubyObject();
  7. }
  8. }
  9. return null;
  10. }

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

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

相关文章

Ruby类方法