org.jruby.RubyClass.hasVariables()方法的使用及代码示例

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

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

RubyClass.hasVariables介绍

暂无

代码示例

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

/** w_extended
 * 
 */
private RubyClass dumpExtended(RubyClass type) throws IOException {
  if(type.isSingleton()) {
    if (hasSingletonMethods(type) || type.hasVariables()) { // any ivars, since we don't have __attached__ ivar now
      throw type.getRuntime().newTypeError("singleton can't be dumped");
    }
    type = type.getSuperClass();
  }
  while(type.isIncluded()) {
    write('e');
    writeAndRegisterSymbol(((IncludedModuleWrapper)type).getNonIncludedClass().getName());
    type = type.getSuperClass();
  }
  return type;
}

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

/** w_extended
 * 
 */
private RubyClass dumpExtended(RubyClass type) throws IOException {
  if(type.isSingleton()) {
    if (hasSingletonMethods(type) || type.hasVariables()) { // any ivars, since we don't have __attached__ ivar now
      throw type.getRuntime().newTypeError("singleton can't be dumped");
    }
    type = type.getSuperClass();
  }
  while(type.isIncluded()) {
    write('e');
    writeAndRegisterSymbol(((IncludedModuleWrapper)type).getNonIncludedClass().getName());
    type = type.getSuperClass();
  }
  return type;
}

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

/** w_extended
 * 
 */
private RubyClass dumpExtended(RubyClass type) throws IOException {
  if(type.isSingleton()) {
    if (hasSingletonMethods(type) || type.hasVariables()) { // any ivars, since we don't have __attached__ ivar now
      throw type.getRuntime().newTypeError("singleton can't be dumped");
    }
    type = type.getSuperClass();
  }
  while(type.isIncluded()) {
    write('e');
    writeAndRegisterSymbol(RubySymbol.newSymbol(runtime, type.getNonIncludedClass().getName()).getBytes());
    type = type.getSuperClass();
  }
  return type;
}

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

/** w_extended
 * 
 */
private RubyClass dumpExtended(RubyClass type) throws IOException {
  if(type.isSingleton()) {
    if (hasSingletonMethods(type) || type.hasVariables()) { // any ivars, since we don't have __attached__ ivar now
      throw type.getRuntime().newTypeError("singleton can't be dumped");
    }
    type = type.getSuperClass();
  }
  while(type.isIncluded()) {
    write('e');
    writeAndRegisterSymbol(RubySymbol.newSymbol(runtime, type.getNonIncludedClass().getName()).getBytes());
    type = type.getSuperClass();
  }
  return type;
}

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

/** rb_singleton_class_clone
 *
 * Will make sure that if the current objects class is a
 * singleton, it will get cloned.
 *
 * @return either a real class, or a clone of the current singleton class
 */
protected RubyClass getSingletonClassCloneAndAttach(RubyBasicObject attach) {
  RubyClass klass = getMetaClass();
  if (!klass.isSingleton()) {
    return klass;
  }
  MetaClass clone = new MetaClass(getRuntime(), klass.getSuperClass(), attach);
  clone.flags = klass.flags;
  if (this instanceof RubyClass) {
    clone.setMetaClass(clone);
  } else {
    clone.setMetaClass(klass.getSingletonClassClone());
  }
  if (klass.hasVariables()) clone.syncVariables(klass);
  clone.syncConstants(klass);
  klass.cloneMethods(clone);
  ((MetaClass) clone.getMetaClass()).setAttached(clone);
  return clone;
}

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

/** rb_singleton_class_clone
 *
 * Will make sure that if the current objects class is a
 * singleton, it will get cloned.
 *
 * @return either a real class, or a clone of the current singleton class
 */
protected RubyClass getSingletonClassCloneAndAttach(RubyBasicObject attach) {
  RubyClass klass = getMetaClass();
  if (!klass.isSingleton()) {
    return klass;
  }
  MetaClass clone = new MetaClass(getRuntime(), klass.getSuperClass(), attach);
  clone.flags = klass.flags;
  if (this instanceof RubyClass) {
    clone.setMetaClass(clone);
  } else {
    clone.setMetaClass(klass.getSingletonClassClone());
  }
  if (klass.hasVariables()) clone.syncVariables(klass);
  clone.syncConstants(klass);
  klass.cloneMethods(clone);
  ((MetaClass) clone.getMetaClass()).setAttached(clone);
  return clone;
}

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

/** rb_singleton_class_clone
 *
 * Will make sure that if the current objects class is a
 * singleton, it will get cloned.
 *
 * @return either a real class, or a clone of the current singleton class
 */
protected RubyClass getSingletonClassClone() {
  RubyClass klass = getMetaClass();
  if (!klass.isSingleton()) {
    return klass;
  }
  MetaClass clone = new MetaClass(getRuntime(), klass.getSuperClass(), ((MetaClass) klass).getAttached());
  clone.flags = flags;
  if (this instanceof RubyClass) {
    clone.setMetaClass(clone);
  } else {
    clone.setMetaClass(klass.getSingletonClassClone());
  }
  if (klass.hasVariables()) {
    clone.syncVariables(klass);
  }
  clone.syncConstants(klass);
  klass.cloneMethods(clone);
  ((MetaClass) clone.getMetaClass()).setAttached(clone);
  return clone;
}

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

/** rb_singleton_class_clone
 *
 * Will make sure that if the current objects class is a
 * singleton, it will get cloned.
 *
 * @return either a real class, or a clone of the current singleton class
 */
protected RubyClass getSingletonClassClone() {
  RubyClass klass = getMetaClass();
  if (!klass.isSingleton()) {
    return klass;
  }
  MetaClass clone = new MetaClass(getRuntime(), klass.getSuperClass(), ((MetaClass) klass).getAttached());
  clone.flags = flags;
  if (this instanceof RubyClass) {
    clone.setMetaClass(clone);
  } else {
    clone.setMetaClass(klass.getSingletonClassClone());
  }
  if (klass.hasVariables()) {
    clone.syncVariables(klass);
  }
  clone.syncConstants(klass);
  klass.cloneMethods(clone);
  ((MetaClass) clone.getMetaClass()).setAttached(clone);
  return clone;
}

相关文章

微信公众号

最新文章

更多

RubyClass类方法