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

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

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

Ruby.getEnumerable介绍

暂无

代码示例

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

public static void createRubyDescriptor(Ruby runtime) {
  RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf");
  RubyClass cDescriptor = protobuf.defineClassUnder("Descriptor", runtime.getObject(), new ObjectAllocator() {
    @Override
    public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
      return new RubyDescriptor(runtime, klazz);
    }
  });
  cDescriptor.includeModule(runtime.getEnumerable());
  cDescriptor.defineAnnotatedMethods(RubyDescriptor.class);
}

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

public static void createRubyEnumDescriptor(Ruby runtime) {
  RubyModule mProtobuf = runtime.getClassFromPath("Google::Protobuf");
  RubyClass cEnumDescriptor = mProtobuf.defineClassUnder("EnumDescriptor", runtime.getObject(), new ObjectAllocator() {
    @Override
    public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
      return new RubyEnumDescriptor(runtime, klazz);
    }
  });
  cEnumDescriptor.includeModule(runtime.getEnumerable());
  cEnumDescriptor.defineAnnotatedMethods(RubyEnumDescriptor.class);
}

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

public static void createRubyOneofDescriptor(Ruby runtime) {
  RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf");
  RubyClass cRubyOneofDescriptor = protobuf.defineClassUnder("OneofDescriptor", runtime.getObject(), new ObjectAllocator() {
    @Override
    public IRubyObject allocate(Ruby ruby, RubyClass rubyClass) {
      return new RubyOneofDescriptor(ruby, rubyClass);
    }
  });
  cRubyOneofDescriptor.defineAnnotatedMethods(RubyOneofDescriptor.class);
  cRubyOneofDescriptor.includeModule(runtime.getEnumerable());
}

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

public static void createRubyRepeatedField(Ruby runtime) {
  RubyModule mProtobuf = runtime.getClassFromPath("Google::Protobuf");
  RubyClass cRepeatedField = mProtobuf.defineClassUnder("RepeatedField", runtime.getObject(),
      new ObjectAllocator() {
        @Override
        public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
          return new RubyRepeatedField(runtime, klazz);
        }
      });
  cRepeatedField.defineAnnotatedMethods(RubyRepeatedField.class);
  cRepeatedField.includeModule(runtime.getEnumerable());
}

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

public static void createRubyMap(Ruby runtime) {
  RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf");
  RubyClass cMap = protobuf.defineClassUnder("Map", runtime.getObject(), new ObjectAllocator() {
    @Override
    public IRubyObject allocate(Ruby ruby, RubyClass rubyClass) {
      return new RubyMap(ruby, rubyClass);
    }
  });
  cMap.includeModule(runtime.getEnumerable());
  cMap.defineAnnotatedMethods(RubyMap.class);
}

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

@Deprecated
public static IRubyObject callEach19(Ruby runtime, ThreadContext context, IRubyObject self,
    BlockCallback callback) {
  return Helpers.invoke(context, self, "each", CallBlock19.newCallClosure(self, runtime.getEnumerable(),
      Signature.OPTIONAL, callback, context));
}

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

@Deprecated
public static IRubyObject callEach(Ruby runtime, ThreadContext context, IRubyObject self, IRubyObject[] args,
    BlockCallback callback) {
  return Helpers.invoke(context, self, "each", args, CallBlock.newCallClosure(self, runtime.getEnumerable(), Signature.OPTIONAL, callback, context));
}

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

@Deprecated
public static IRubyObject callEach19(Ruby runtime, ThreadContext context, IRubyObject self,
    Arity arity, BlockCallback callback) {
  return Helpers.invoke(context, self, "each", CallBlock19.newCallClosure(self, runtime.getEnumerable(),
      arity, callback, context));
}

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

@Deprecated
public static IRubyObject callEach(Ruby runtime, ThreadContext context, IRubyObject self, IRubyObject[] args,
    Arity arity, BlockCallback callback) {
  return Helpers.invoke(context, self, "each", args, CallBlock.newCallClosure(self, runtime.getEnumerable(), arity, callback, context));
}

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

public static IRubyObject callEach19(Ruby runtime, ThreadContext context, IRubyObject self,
                   Signature signature, BlockCallback callback) {
  return Helpers.invoke(context, self, "each", CallBlock19.newCallClosure(self, runtime.getEnumerable(),
      signature, callback, context));
}

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

static RubyModule define(final Ruby runtime, final RubyModule proxy) {
  proxy.includeModule( runtime.getEnumerable() ); // include Enumerable
  proxy.defineAnnotatedMethods(Iterable.class);
  return proxy;
}

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

public static IRubyObject callEach(Ruby runtime, ThreadContext context, IRubyObject self,
                  Signature signature, BlockCallback callback) {
  return Helpers.invoke(context, self, "each", CallBlock.newCallClosure(self, runtime.getEnumerable(),
      signature, callback, context));
}

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

static RubyModule define(final Ruby runtime, final RubyModule proxy) {
  proxy.includeModule( runtime.getEnumerable() ); // include Enumerable
  proxy.defineAnnotatedMethods(Enumeration.class);
  return proxy;
}

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

static RubyModule define(final Ruby runtime, final RubyModule proxy) {
  proxy.includeModule( runtime.getEnumerable() ); // include Enumerable
  proxy.defineAnnotatedMethods(Iterator.class);
  return proxy;
}

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

static RubyModule define(final Ruby runtime, final RubyModule proxy) {
  proxy.includeModule( runtime.getEnumerable() ); // include Enumerable
  proxy.defineAnnotatedMethods(Iterable.class);
  return proxy;
}

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

@JRubyMethod(name = {"to_a", "entries"}, rest = true)
public static IRubyObject to_a(ThreadContext context, IRubyObject self, IRubyObject[] args) {
  final Ruby runtime = context.runtime;
  final RubyArray result = runtime.newArray();
  Helpers.invoke(context, self, "each", args, CallBlock.newCallClosure(self, runtime.getEnumerable(),
      Signature.OPTIONAL, new AppendBlockCallback(result), context));
  result.infectBy(self);
  return result;
}

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

public static RubyClass createStructClass(Ruby runtime) {
  RubyClass structClass = runtime.defineClass("Struct", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
  runtime.setStructClass(structClass);
  structClass.setClassIndex(ClassIndex.STRUCT);
  structClass.includeModule(runtime.getEnumerable());
  structClass.setReifiedClass(RubyStruct.class);
  structClass.defineAnnotatedMethods(RubyStruct.class);
  return structClass;
}

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

public static RubyClass createHashClass(Ruby runtime) {
  RubyClass hashc = runtime.defineClass("Hash", runtime.getObject(), HASH_ALLOCATOR);
  runtime.setHash(hashc);
  hashc.setClassIndex(ClassIndex.HASH);
  hashc.setReifiedClass(RubyHash.class);
  hashc.kindOf = new RubyModule.JavaClassKindOf(RubyHash.class);
  hashc.includeModule(runtime.getEnumerable());
  hashc.defineAnnotatedMethods(RubyHash.class);
  return hashc;
}

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

static RubyClass createSetClass(final Ruby runtime) {
  RubyClass Set = runtime.defineClass("Set", runtime.getObject(), ALLOCATOR);
  Set.setReifiedClass(RubySet.class);
  Set.includeModule(runtime.getEnumerable());
  Set.defineAnnotatedMethods(RubySet.class);
  Set.setMarshal(new SetMarshal(Set.getMarshal()));
  runtime.getLoadService().require("jruby/set.rb");
  return Set;
}

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

public static void initArgsFile(final Ruby runtime) {
  RubyClass argfClass = runtime.defineClass("ARGFClass", runtime.getObject(), ARGF_ALLOCATOR);
  argfClass.includeModule(runtime.getEnumerable());
  argfClass.defineAnnotatedMethods(RubyArgsFile.class);
  IRubyObject argsFile = argfClass.newInstance(runtime.getCurrentContext(), new IRubyObject[] { null }, (Block) null);
  runtime.setArgsFile(argsFile);
  runtime.getGlobalVariables().defineReadonly("$<", new ArgsFileAccessor(runtime), GlobalVariable.Scope.GLOBAL);
  runtime.defineGlobalConstant("ARGF", argsFile);
  runtime.defineReadonlyVariable("$FILENAME", runtime.newString("-"), GlobalVariable.Scope.GLOBAL);
}

相关文章

Ruby类方法