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

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

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

Ruby.getEnumerable介绍

暂无

代码示例

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

  1. public static void createRubyDescriptor(Ruby runtime) {
  2. RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf");
  3. RubyClass cDescriptor = protobuf.defineClassUnder("Descriptor", runtime.getObject(), new ObjectAllocator() {
  4. @Override
  5. public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
  6. return new RubyDescriptor(runtime, klazz);
  7. }
  8. });
  9. cDescriptor.includeModule(runtime.getEnumerable());
  10. cDescriptor.defineAnnotatedMethods(RubyDescriptor.class);
  11. }

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

  1. public static void createRubyEnumDescriptor(Ruby runtime) {
  2. RubyModule mProtobuf = runtime.getClassFromPath("Google::Protobuf");
  3. RubyClass cEnumDescriptor = mProtobuf.defineClassUnder("EnumDescriptor", runtime.getObject(), new ObjectAllocator() {
  4. @Override
  5. public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
  6. return new RubyEnumDescriptor(runtime, klazz);
  7. }
  8. });
  9. cEnumDescriptor.includeModule(runtime.getEnumerable());
  10. cEnumDescriptor.defineAnnotatedMethods(RubyEnumDescriptor.class);
  11. }

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

  1. public static void createRubyOneofDescriptor(Ruby runtime) {
  2. RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf");
  3. RubyClass cRubyOneofDescriptor = protobuf.defineClassUnder("OneofDescriptor", runtime.getObject(), new ObjectAllocator() {
  4. @Override
  5. public IRubyObject allocate(Ruby ruby, RubyClass rubyClass) {
  6. return new RubyOneofDescriptor(ruby, rubyClass);
  7. }
  8. });
  9. cRubyOneofDescriptor.defineAnnotatedMethods(RubyOneofDescriptor.class);
  10. cRubyOneofDescriptor.includeModule(runtime.getEnumerable());
  11. }

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

  1. public static void createRubyRepeatedField(Ruby runtime) {
  2. RubyModule mProtobuf = runtime.getClassFromPath("Google::Protobuf");
  3. RubyClass cRepeatedField = mProtobuf.defineClassUnder("RepeatedField", runtime.getObject(),
  4. new ObjectAllocator() {
  5. @Override
  6. public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
  7. return new RubyRepeatedField(runtime, klazz);
  8. }
  9. });
  10. cRepeatedField.defineAnnotatedMethods(RubyRepeatedField.class);
  11. cRepeatedField.includeModule(runtime.getEnumerable());
  12. }

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

  1. public static void createRubyMap(Ruby runtime) {
  2. RubyModule protobuf = runtime.getClassFromPath("Google::Protobuf");
  3. RubyClass cMap = protobuf.defineClassUnder("Map", runtime.getObject(), new ObjectAllocator() {
  4. @Override
  5. public IRubyObject allocate(Ruby ruby, RubyClass rubyClass) {
  6. return new RubyMap(ruby, rubyClass);
  7. }
  8. });
  9. cMap.includeModule(runtime.getEnumerable());
  10. cMap.defineAnnotatedMethods(RubyMap.class);
  11. }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  1. public static RubyClass createStructClass(Ruby runtime) {
  2. RubyClass structClass = runtime.defineClass("Struct", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
  3. runtime.setStructClass(structClass);
  4. structClass.setClassIndex(ClassIndex.STRUCT);
  5. structClass.includeModule(runtime.getEnumerable());
  6. structClass.setReifiedClass(RubyStruct.class);
  7. structClass.defineAnnotatedMethods(RubyStruct.class);
  8. return structClass;
  9. }

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

  1. public static RubyClass createHashClass(Ruby runtime) {
  2. RubyClass hashc = runtime.defineClass("Hash", runtime.getObject(), HASH_ALLOCATOR);
  3. runtime.setHash(hashc);
  4. hashc.setClassIndex(ClassIndex.HASH);
  5. hashc.setReifiedClass(RubyHash.class);
  6. hashc.kindOf = new RubyModule.JavaClassKindOf(RubyHash.class);
  7. hashc.includeModule(runtime.getEnumerable());
  8. hashc.defineAnnotatedMethods(RubyHash.class);
  9. return hashc;
  10. }

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

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

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

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

相关文章

Ruby类方法