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); }
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); }
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()); }
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()); }
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); }
@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)); }
@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)); }
@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)); }
@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)); }
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)); }
static RubyModule define(final Ruby runtime, final RubyModule proxy) { proxy.includeModule( runtime.getEnumerable() ); // include Enumerable proxy.defineAnnotatedMethods(Iterable.class); return proxy; }
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)); }
static RubyModule define(final Ruby runtime, final RubyModule proxy) { proxy.includeModule( runtime.getEnumerable() ); // include Enumerable proxy.defineAnnotatedMethods(Enumeration.class); return proxy; }
static RubyModule define(final Ruby runtime, final RubyModule proxy) { proxy.includeModule( runtime.getEnumerable() ); // include Enumerable proxy.defineAnnotatedMethods(Iterator.class); return proxy; }
static RubyModule define(final Ruby runtime, final RubyModule proxy) { proxy.includeModule( runtime.getEnumerable() ); // include Enumerable proxy.defineAnnotatedMethods(Iterable.class); return proxy; }
@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; }
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; }
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; }
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; }
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); }