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

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

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

RubyModule.isIncluded介绍

[英]Is this module one that in an included one (e.g. an IncludedModuleWrapper).
[中]该模块是否包含在包含模块中(例如,包含模块包装器)。

代码示例

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

private RubyClass getAlreadyActivatedRefinementWrapper(RubyClass classWeAreRefining, RubyModule refinement) {
  // We have already encountered at least one refine on this class.  Return that wrapper.
  RubyClass moduleWrapperForRefinement = activatedRefinements.get(classWeAreRefining);
  if (moduleWrapperForRefinement == null) return classWeAreRefining;
  for (RubyModule c = moduleWrapperForRefinement; c != null && c.isIncluded(); c = c.getSuperClass()) {
    if (c.getNonIncludedClass() == refinement) return null;
  }
  return moduleWrapperForRefinement;
}

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

private RubyClass getAlreadyActivatedRefinementWrapper(RubyClass classWeAreRefining, RubyModule refinement) {
  // We have already encountered at least one refine on this class.  Return that wrapper.
  RubyClass moduleWrapperForRefinement = activatedRefinements.get(classWeAreRefining);
  if (moduleWrapperForRefinement == null) return classWeAreRefining;
  for (RubyModule c = moduleWrapperForRefinement; c != null && c.isIncluded(); c = c.getSuperClass()) {
    if (c.getNonIncludedClass() == refinement) return null;
  }
  return moduleWrapperForRefinement;
}

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

/**
 * Calculate, based on given RubyModule, which class in its hierarchy
 * should be used to determine protected access.
 *
 * @param cls The class from which to calculate
 * @return The class to be used for protected access checking.
 */
protected static RubyModule calculateProtectedClass(RubyModule cls) {
  // singleton classes don't get their own visibility domain
  if (cls.isSingleton()) cls = cls.getSuperClass();
  while (cls.isIncluded()) cls = cls.getMetaClass();
  // For visibility we need real meta class and not anonymous one from class << self
  if (cls instanceof MetaClass) cls = ((MetaClass) cls).getRealClass();
  return cls;
}

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

/**
 * Calculate, based on given RubyModule, which class in its hierarchy
 * should be used to determine protected access.
 *
 * @param cls The class from which to calculate
 * @return The class to be used for protected access checking.
 */
protected static RubyModule calculateProtectedClass(RubyModule cls) {
  // singleton classes don't get their own visibility domain
  if (cls.isSingleton()) cls = cls.getSuperClass();
  while (cls.isIncluded()) cls = cls.getMetaClass();
  // For visibility we need real meta class and not anonymous one from class << self
  if (cls instanceof MetaClass) cls = ((MetaClass) cls).getRealClass();
  return cls;
}

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

final void populateInstanceMethodNames(final Set<String> seen, final RubyArray ary, Visibility visibility,
                    boolean obj, boolean not, boolean recur) {
  Ruby runtime = getRuntime();
  RubyModule mod = this;
  boolean prepended = false;
  if (!recur && methodLocation != this) {
    mod = methodLocation;
    prepended = true;
  }
  for (; mod != null; mod = mod.getSuperClass()) {
    mod.addMethodSymbols(runtime, seen, ary, not, visibility);
    if (!prepended && mod.isIncluded()) continue;
    if (obj && mod.isSingleton()) continue;
    if (!recur) break;
  }
}

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

final void populateInstanceMethodNames(final Set<String> seen, final RubyArray ary, Visibility visibility,
                    boolean obj, boolean not, boolean recur) {
  Ruby runtime = getRuntime();
  RubyModule mod = this;
  boolean prepended = false;
  if (!recur && methodLocation != this) {
    mod = methodLocation;
    prepended = true;
  }
  for (; mod != null; mod = mod.getSuperClass()) {
    mod.addMethodSymbols(runtime, seen, ary, not, visibility);
    if (!prepended && mod.isIncluded()) continue;
    if (obj && mod.isSingleton()) continue;
    if (!recur) break;
  }
}

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

@JRubyMethod(name = "==", required = 1)
@Override
public IRubyObject op_equal(ThreadContext context, IRubyObject other) {
  if(!(other instanceof RubyModule)) return context.fals;
  RubyModule otherModule = (RubyModule) other;
  if(otherModule.isIncluded()) {
    return context.runtime.newBoolean(otherModule.isSame(this));
  } else {
    return context.runtime.newBoolean(isSame(otherModule));
  }
}

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

@JRubyMethod(name = "==", required = 1)
@Override
public IRubyObject op_equal(ThreadContext context, IRubyObject other) {
  if(!(other instanceof RubyModule)) return context.fals;
  RubyModule otherModule = (RubyModule) other;
  if(otherModule.isIncluded()) {
    return context.runtime.newBoolean(otherModule.isSame(this));
  } else {
    return context.runtime.newBoolean(isSame(otherModule));
  }
}

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

/**
 * Calculate, based on given RubyModule, which class in its hierarchy
 * should be used to determine protected access.
 *
 * @param cls The class from which to calculate
 * @return The class to be used for protected access checking.
 */
protected static RubyModule calculateProtectedClass(RubyModule cls) {
  // singleton classes don't get their own visibility domain
  if (cls.isSingleton()) cls = cls.getSuperClass();
  while (cls.isIncluded()) cls = cls.getMetaClass();
  // For visibility we need real meta class and not anonymous one from class << self
  if (cls instanceof MetaClass) cls = ((MetaClass) cls).getRealClass();
  if (cls instanceof PrependedModule) cls = ((PrependedModule) cls).getNonIncludedClass();
  return cls;
}

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

/**
 * Calculate, based on given RubyModule, which class in its hierarchy
 * should be used to determine protected access.
 *
 * @param cls The class from which to calculate
 * @return The class to be used for protected access checking.
 */
protected static RubyModule calculateProtectedClass(RubyModule cls) {
  // singleton classes don't get their own visibility domain
  if (cls.isSingleton()) cls = cls.getSuperClass();
  while (cls.isIncluded()) cls = cls.getMetaClass();
  // For visibility we need real meta class and not anonymous one from class << self
  if (cls instanceof MetaClass) cls = ((MetaClass) cls).getRealClass();
  if (cls instanceof PrependedModule) cls = ((PrependedModule) cls).getNonIncludedClass();
  return cls;
}

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

/** rb_mod_included_modules
 *
 */
@JRubyMethod(name = "included_modules")
public RubyArray included_modules(ThreadContext context) {
  RubyArray ary = context.runtime.newArray();
  for (RubyModule p = getSuperClass(); p != null; p = p.getSuperClass()) {
    if (p.isIncluded()) {
      ary.append(p.getNonIncludedClass());
    }
  }
  return ary;
}

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

/** rb_mod_included_modules
 *
 */
@JRubyMethod(name = "included_modules")
public RubyArray included_modules(ThreadContext context) {
  RubyArray ary = context.runtime.newArray();
  for (RubyModule p = getSuperClass(); p != null; p = p.getSuperClass()) {
    if (p.isIncluded()) {
      ary.append(p.getNonIncludedClass());
    }
  }
  return ary;
}

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

/** rb_mod_included_modules
 *
 */
@JRubyMethod(name = "included_modules")
public RubyArray included_modules(ThreadContext context) {
  RubyArray ary = context.runtime.newArray();
  for (RubyModule p = getSuperClass(); p != null; p = p.getSuperClass()) {
    if (p.isIncluded()) {
      ary.append(p.getNonIncludedClass());
    }
  }
  return ary;
}

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

/** rb_mod_included_modules
 *
 */
@JRubyMethod(name = "included_modules")
public RubyArray included_modules(ThreadContext context) {
  RubyArray ary = context.runtime.newArray();
  for (RubyModule p = getSuperClass(); p != null; p = p.getSuperClass()) {
    if (p.isIncluded()) {
      ary.append(p.getNonIncludedClass());
    }
  }
  return ary;
}

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

@JRubyMethod(name = "autoload?")
  public static IRubyObject autoload_p(ThreadContext context, IRubyObject self, IRubyObject symbol) {
    final Ruby runtime = context.runtime;
    final String name = TypeConverter.checkID(symbol).idString();
    RubyModule mod = RubyKernel.getModuleForAutoload(runtime, self);
    for (/* RubyModule mod = (RubyModule) self */; mod != null; mod = mod.getSuperClass()) {
      final IRubyObject loadedValue = mod.fetchConstant(name);
      if ( loadedValue != null && loadedValue != UNDEF ) return context.nil;
      final RubyString file;
      if ( mod.isIncluded() ) {
        file = mod.getNonIncludedClass().getAutoloadFile(name);
      }
      else {
        file = mod.getAutoloadFile(name);
      }
      if ( file != null ) { // due explicit requires still need to :
        if ( runtime.getLoadService().featureAlreadyLoaded(file.asJavaString()) ) {
          // TODO in which case the auto-load never finish-es ?!
          return context.nil;
        }
        return file;
      }
    }
    return context.nil;
  }
}

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

@JRubyMethod(name = "autoload?")
  public static IRubyObject autoload_p(ThreadContext context, IRubyObject self, IRubyObject symbol) {
    final Ruby runtime = context.runtime;
    final String name = TypeConverter.checkID(symbol).idString();
    RubyModule mod = RubyKernel.getModuleForAutoload(runtime, self);
    for (/* RubyModule mod = (RubyModule) self */; mod != null; mod = mod.getSuperClass()) {
      final IRubyObject loadedValue = mod.fetchConstant(name);
      if ( loadedValue != null && loadedValue != UNDEF ) return context.nil;
      final RubyString file;
      if ( mod.isIncluded() ) {
        file = mod.getNonIncludedClass().getAutoloadFile(name);
      }
      else {
        file = mod.getAutoloadFile(name);
      }
      if ( file != null ) { // due explicit requires still need to :
        if ( runtime.getLoadService().featureAlreadyLoaded(file.asJavaString()) ) {
          // TODO in which case the auto-load never finish-es ?!
          return context.nil;
        }
        return file;
      }
    }
    return context.nil;
  }
}

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

public IRubyObject newMethod(IRubyObject receiver, final String methodName, boolean bound, Visibility visibility, boolean respondToMissing, boolean priv) {
  DynamicMethod method = searchMethod(methodName);
  if (method.isUndefined() || (visibility != null && method.getVisibility() != visibility)) {
    if (respondToMissing) { // 1.9 behavior
      if (receiver.respondsToMissing(methodName, priv)) {
        method = new RespondToMissingMethod(this, PUBLIC, methodName);
      } else {
        throw getRuntime().newNameError("undefined method `" + methodName + "' for class `" + getName() + '\'', methodName);
      }
    } else {
      throw getRuntime().newNameError("undefined method `" + methodName + "' for class `" + getName() + '\'', methodName);
    }
  }
  RubyModule implementationModule = method.getDefinedClass();
  RubyModule originModule = this;
  while (originModule != implementationModule && (originModule.isSingleton() || originModule.isIncluded())) {
    originModule = originModule.getSuperClass();
  }
  AbstractRubyMethod newMethod;
  if (bound) {
    newMethod = RubyMethod.newMethod(implementationModule, methodName, originModule, methodName, method, receiver);
  } else {
    newMethod = RubyUnboundMethod.newUnboundMethod(implementationModule, methodName, originModule, methodName, method);
  }
  newMethod.infectBy(this);
  return newMethod;
}

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

public IRubyObject newMethod(IRubyObject receiver, final String methodName, boolean bound, Visibility visibility, boolean respondToMissing, boolean priv) {
  DynamicMethod method = searchMethod(methodName);
  if (method.isUndefined() || (visibility != null && method.getVisibility() != visibility)) {
    if (respondToMissing) { // 1.9 behavior
      if (receiver.respondsToMissing(methodName, priv)) {
        method = new RespondToMissingMethod(this, PUBLIC, methodName);
      } else {
        throw getRuntime().newNameError("undefined method `" + methodName + "' for class `" + getName() + '\'', methodName);
      }
    } else {
      throw getRuntime().newNameError("undefined method `" + methodName + "' for class `" + getName() + '\'', methodName);
    }
  }
  RubyModule implementationModule = method.getDefinedClass();
  RubyModule originModule = this;
  while (originModule != implementationModule && (originModule.isSingleton() || originModule.isIncluded())) {
    originModule = originModule.getSuperClass();
  }
  AbstractRubyMethod newMethod;
  if (bound) {
    newMethod = RubyMethod.newMethod(implementationModule, methodName, originModule, methodName, method, receiver);
  } else {
    newMethod = RubyUnboundMethod.newUnboundMethod(implementationModule, methodName, originModule, methodName, method);
  }
  newMethod.infectBy(this);
  return newMethod;
}

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

if (definedClass.isIncluded()) {
  definedClass = definedClass.getMetaClass();

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

if (definedClass.isIncluded()) {
  definedClass = definedClass.getMetaClass();

相关文章

微信公众号

最新文章

更多

RubyModule类方法