org.jruby.RubyModule.setInternalVariable()方法的使用及代码示例

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

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

RubyModule.setInternalVariable介绍

暂无

代码示例

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

/**
 * Behaves similarly to {@link #setClassVar(String, IRubyObject)}. If the
 * specified internal variable is found in this class/module <em>or an ancestor</em>,
 * it is set where found.  Otherwise it is set in this module.
 *
 * @param name the internal variable name
 * @param value the internal variable value
 * @see #searchInternalModuleVariable(String)
 */
public void setInternalModuleVariable(final String name, final IRubyObject value) {
  for (RubyModule module = this; module != null; module = module.getSuperClass()) {
    if (module.hasInternalVariable(name)) {
      module.setInternalVariable(name, value);
      return;
    }
  }
  setInternalVariable(name, value);
}

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

/**
 * Behaves similarly to {@link #setClassVar(String, IRubyObject)}. If the
 * specified internal variable is found in this class/module <em>or an ancestor</em>,
 * it is set where found.  Otherwise it is set in this module.
 *
 * @param name the internal variable name
 * @param value the internal variable value
 * @see #searchInternalModuleVariable(String)
 */
public void setInternalModuleVariable(final String name, final IRubyObject value) {
  for (RubyModule module = this; module != null; module = module.getSuperClass()) {
    if (module.hasInternalVariable(name)) {
      module.setInternalVariable(name, value);
      return;
    }
  }
  setInternalVariable(name, value);
}

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

/**
 * Behaves similarly to {@link #setClassVar(String, IRubyObject)}. If the
 * specified internal variable is found in this class/module <em>or an ancestor</em>,
 * it is set where found.  Otherwise it is set in this module. 
 * 
 * @param name the internal variable name
 * @param value the internal variable value
 * @see #searchInternalModuleVariable(String)
 */
public void setInternalModuleVariable(final String name, final IRubyObject value) {
  for (RubyModule module = this; module != null; module = module.getSuperClass()) {
    if (module.hasInternalVariable(name)) {
      module.setInternalVariable(name, value);
      return;
    }
  }
  setInternalVariable(name, value);
}

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

/**
 * Behaves similarly to {@link #setClassVar(String, IRubyObject)}. If the
 * specified internal variable is found in this class/module <em>or an ancestor</em>,
 * it is set where found.  Otherwise it is set in this module. 
 * 
 * @param name the internal variable name
 * @param value the internal variable value
 * @see #searchInternalModuleVariable(String)
 */
public void setInternalModuleVariable(final String name, final IRubyObject value) {
  for (RubyModule module = this; module != null; module = module.getSuperClass()) {
    if (module.hasInternalVariable(name)) {
      module.setInternalVariable(name, value);
      return;
    }
  }
  setInternalVariable(name, value);
}

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

public static void define(RubyModule timeout) {
  // Timeout module methods
  timeout.defineAnnotatedMethods(Timeout.class);
  timeout.setInternalVariable(
      EXECUTOR_VARIABLE,
      new ScheduledThreadPoolExecutor(Runtime.getRuntime().availableProcessors(), new DaemonThreadFactory()));
}

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

public static void define(RubyModule timeout) {
  // Timeout module methods
  timeout.defineAnnotatedMethods(Timeout.class);
  timeout.setInternalVariable(
      EXECUTOR_VARIABLE,
      new ScheduledThreadPoolExecutor(Runtime.getRuntime().availableProcessors(), new DaemonThreadFactory()));
}

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

@JRubyMethod(name = "reference_required", module=true, optional = 1)
  public static IRubyObject reference_required(ThreadContext context, IRubyObject self, IRubyObject[] args) {
    module(self).setInternalVariable("reference_required", context.runtime.newBoolean(args.length < 1 || args[0].isTrue()));
    return self;
  }
}

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

@JRubyMethod(name = "reference_required", module=true, optional = 1)
  public static IRubyObject reference_required(ThreadContext context, IRubyObject self, IRubyObject[] args) {
    module(self).setInternalVariable("reference_required", context.runtime.newBoolean(args.length < 1 || args[0].isTrue()));
    return self;
  }
}

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

@JRubyMethod(name = "reference_required", module=true, optional = 1)
  public static IRubyObject reference_required(ThreadContext context, IRubyObject self, IRubyObject[] args) {
    module(self).setInternalVariable("reference_required", context.runtime.newBoolean(args.length < 1 || args[0].isTrue()));
    return self;
  }
}

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

@JRubyMethod(name = "reference_required", module=true, optional = 1)
  public static IRubyObject reference_required(ThreadContext context, IRubyObject self, IRubyObject[] args) {
    module(self).setInternalVariable("reference_required", context.runtime.newBoolean(args.length < 1 || args[0].isTrue()));
    return self;
  }
}

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

ancestor.setInternalVariable("__java_ovrd_methods", methodNames);
} else {
  names.addAll(methodNames);

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

@JRubyMethod(name = "native_type", module=true, optional = 1)
public static IRubyObject native_type(ThreadContext context, IRubyObject self, IRubyObject[] args) {
  RubyModule m = module(self);
  if (args.length == 0) {
    if (!m.hasInternalVariable("native_type")) {
      throw context.runtime.newNotImplementedError("native_type method not overridden and no native_type set");
    }
    return (Type) m.getInternalVariable("native_type");
  } else if (args.length == 1) {
    Type type = Util.findType(context, args[0]);
    m.setInternalVariable("native_type", type);
    return type;
  } else {
    throw context.runtime.newArgumentError("incorrect arguments");
  }
}

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

ancestor.setInternalVariable("__java_ovrd_methods", methodNames);
} else {
  names.addAll(methodNames);

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

@JRubyMethod(name = "native_type", module=true, optional = 1)
public static IRubyObject native_type(ThreadContext context, IRubyObject self, IRubyObject[] args) {
  RubyModule m = module(self);
  if (args.length == 0) {
    if (!m.hasInternalVariable("native_type")) {
      throw context.runtime.newNotImplementedError("native_type method not overridden and no native_type set");
    }
    return (Type) m.getInternalVariable("native_type");
  } else if (args.length == 1) {
    Type type = Util.findType(context, args[0]);
    m.setInternalVariable("native_type", type);
    return type;
  } else {
    throw context.runtime.newArgumentError("incorrect arguments");
  }
}

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

@JRubyMethod(name = "native_type", module=true, optional = 1)
public static IRubyObject native_type(ThreadContext context, IRubyObject self, IRubyObject[] args) {
  RubyModule m = module(self);
  if (args.length == 0) {
    if (!m.hasInternalVariable("native_type")) {
      throw context.runtime.newNotImplementedError("native_type method not overridden and no native_type set");
    }
    return (Type) m.getInternalVariable("native_type");
  } else if (args.length == 1) {
    Type type = Util.findType(context, args[0]);
    m.setInternalVariable("native_type", type);
    return type;
  } else {
    throw context.runtime.newArgumentError("incorrect arguments");
  }
}

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

@JRubyMethod(name = "native_type", module=true, optional = 1)
public static IRubyObject native_type(ThreadContext context, IRubyObject self, IRubyObject[] args) {
  RubyModule m = module(self);
  if (args.length == 0) {
    if (!m.hasInternalVariable("native_type")) {
      throw context.runtime.newNotImplementedError("native_type method not overridden and no native_type set");
    }
    return (Type) m.getInternalVariable("native_type");
  } else if (args.length == 1) {
    Type type = Util.findType(context, args[0]);
    m.setInternalVariable("native_type", type);
    return type;
  } else {
    throw context.runtime.newArgumentError("incorrect arguments");
  }
}

代码示例来源:origin: headius/jo

public void load(Ruby runtime, boolean wrap) throws IOException {
  RubyModule jo = runtime.defineModule("Jo");
  final ExecutorService executor = Executors.newCachedThreadPool(new ThreadFactory() {
    public Thread newThread(Runnable r) {
      Thread t = new Thread(r);
      t.setDaemon(true);
      return t;
    }
  });
  jo.setInternalVariable("executor", executor);
  RubyClass joFuture = jo.defineClassUnder("Future", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
  RubyClass joChannel = jo.defineClassUnder("Channel", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
  
  jo.defineAnnotatedMethods(JoMethods.class);
  joFuture.defineAnnotatedMethods(JoFuture.class);
  joChannel.defineAnnotatedMethods(JoChannel.class);
  
  runtime.addFinalizer(new Finalizable() {
    public void finalize() {
      executor.shutdown();
    }
  });
}

相关文章

微信公众号

最新文章

更多

RubyModule类方法