33 package com.google.protobuf.jruby;
40 import org.jruby.anno.JRubyClass;
41 import org.jruby.anno.JRubyMethod;
42 import org.jruby.runtime.Block;
43 import org.jruby.runtime.ObjectAllocator;
44 import org.jruby.runtime.ThreadContext;
45 import org.jruby.runtime.builtin.IRubyObject;
47 @JRubyClass(
name =
"FileDescriptor")
50 RubyModule mProtobuf = runtime.getClassFromPath(
"Google::Protobuf");
51 cFileDescriptor = mProtobuf.defineClassUnder(
"FileDescriptor", runtime.getObject(),
new ObjectAllocator() {
53 public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
67 super(runtime, klazz);
76 @JRubyMethod(
name =
"name")
77 public IRubyObject getName(ThreadContext
context) {
78 String
name = fileDescriptor.getName();
91 @JRubyMethod(
name =
"syntax")
92 public IRubyObject getSyntax(ThreadContext
context) {
93 switch (fileDescriptor.getSyntax()) {
95 return context.runtime.newSymbol(
"proto2");
97 return context.runtime.newSymbol(
"proto3");