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

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

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

RubyModule.getInstanceVariable介绍

暂无

代码示例

代码示例来源:origin: bazelbuild/bazel

@JRubyMethod(meta = true, name = "descriptor")
  public static IRubyObject getDescriptor(ThreadContext context, IRubyObject recv) {
    return ((RubyModule) recv).getInstanceVariable(Utils.DESCRIPTOR_INSTANCE_VAR);
  }
}

代码示例来源:origin: bazelbuild/bazel

protected static void validateTypeClass(ThreadContext context, Descriptors.FieldDescriptor.Type type, IRubyObject value) {
  Ruby runtime = context.runtime;
  if (!(value instanceof RubyModule)) {
    throw runtime.newArgumentError("TypeClass has incorrect type");
  }
  RubyModule klass = (RubyModule) value;
  IRubyObject descriptor = klass.getInstanceVariable(DESCRIPTOR_INSTANCE_VAR);
  if (descriptor.isNil()) {
    throw runtime.newArgumentError("Type class has no descriptor. Please pass a " +
        "class or enum as returned by the DescriptorPool.");
  }
  if (type == Descriptors.FieldDescriptor.Type.MESSAGE) {
    if (! (descriptor instanceof RubyDescriptor)) {
      throw runtime.newArgumentError("Descriptor has an incorrect type");
    }
  } else if (type == Descriptors.FieldDescriptor.Type.ENUM) {
    if (! (descriptor instanceof RubyEnumDescriptor)) {
      throw runtime.newArgumentError("Descriptor has an incorrect type");
    }
  }
}

代码示例来源:origin: bazelbuild/bazel

if (value instanceof RubySymbol) {
  Descriptors.EnumDescriptor enumDescriptor =
      ((RubyEnumDescriptor) typeClass.getInstanceVariable(DESCRIPTOR_INSTANCE_VAR)).getDescriptor();
  val = enumDescriptor.findValueByName(value.asJavaString());
  if (val == null)

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

/**
 * Returns the (reified or proxied) Java class if the passed Ruby module/class has one.
 * @param context
 * @param type
 * @return Java proxy class, Java reified class or nil
 */
public static IRubyObject java_class(final ThreadContext context, final RubyModule type) {
  IRubyObject java_class = type.getInstanceVariable("@java_class");
  if ( java_class == null ) { // || java_class.isNil()
    if ( type.respondsTo("java_class") ) { // NOTE: quite bad since built-in Ruby classes will return
      // a Ruby Java proxy for java.lang.Class while Java proxies will return a JavaClass instance !
      java_class = Helpers.invoke(context, type, "java_class");
    }
    else java_class = context.nil; // we return != null (just like callMethod would)
  }
  return java_class;
}

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

/**
 * Returns the (reified or proxied) Java class if the passed Ruby module/class has one.
 * @param context
 * @param type
 * @return Java proxy class, Java reified class or nil
 */
public static IRubyObject java_class(final ThreadContext context, final RubyModule type) {
  IRubyObject java_class = type.getInstanceVariable("@java_class");
  if ( java_class == null ) { // || java_class.isNil()
    if ( type.respondsTo("java_class") ) { // NOTE: quite bad since built-in Ruby classes will return
      // a Ruby Java proxy for java.lang.Class while Java proxies will return a JavaClass instance !
      java_class = Helpers.invoke(context, type, "java_class");
    }
    else java_class = context.nil; // we return != null (just like callMethod would)
  }
  return java_class;
}

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

private static RubyModule getProxyOrPackageUnderPackage(ThreadContext context, final Ruby runtime,
    RubyModule parentPackage, String sym) {
  IRubyObject packageNameObj = parentPackage.getInstanceVariable("@package_name");
  if (packageNameObj == null) {
    throw runtime.newArgumentError("invalid package module");

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

private static RubyModule getProxyOrPackageUnderPackage(ThreadContext context, final Ruby runtime,
    RubyModule parentPackage, String sym) {
  IRubyObject packageNameObj = parentPackage.getInstanceVariable("@package_name");
  if (packageNameObj == null) {
    throw runtime.newArgumentError("invalid package module");

相关文章

微信公众号

最新文章

更多

RubyModule类方法