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 =
"EnumBuilderContext")
48 RubyModule protobuf = runtime.getClassFromPath(
"Google::Protobuf");
49 RubyClass
cMessageBuilderContext = protobuf.defineClassUnder(
"EnumBuilderContext", runtime.getObject(),
new ObjectAllocator() {
51 public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
63 public IRubyObject
initialize(ThreadContext context, IRubyObject enumDescriptor) {
76 public IRubyObject
value(ThreadContext context, IRubyObject
name, IRubyObject
number) {
77 this.enumDescriptor.addValue(context,
name,
number);
78 return context.runtime.getNil();