33 package com.google.protobuf.jruby;
35 import org.jruby.Ruby;
36 import org.jruby.RubyClass;
37 import org.jruby.RubyModule;
38 import org.jruby.RubyObject;
39 import org.jruby.anno.JRubyClass;
40 import org.jruby.anno.JRubyMethod;
41 import org.jruby.runtime.ObjectAllocator;
42 import org.jruby.runtime.ThreadContext;
43 import org.jruby.runtime.builtin.IRubyObject;
45 @JRubyClass(
name =
"OneofBuilderContext")
48 RubyModule
protobuf = runtime.getClassFromPath(
"Google::Protobuf");
49 RubyModule
internal =
protobuf.defineModuleUnder(
"Internal");
50 RubyClass cRubyOneofBuidlerContext =
internal.defineClassUnder(
"OneofBuilderContext", runtime.getObject(),
new ObjectAllocator() {
52 public IRubyObject allocate(Ruby ruby, RubyClass rubyClass) {
60 super(ruby, rubyClass);
70 @JRubyMethod(
required = 3, optional = 1)
71 public IRubyObject optional(ThreadContext
context, IRubyObject[]
args) {
75 IRubyObject typeClass =
args.length > 3 ?
args[3] :
context.runtime.getNil();