Skip to content

Commit

Permalink
Merge pull request #170 from localshred/bj/symbol-fields
Browse files Browse the repository at this point in the history
Use a primitive field mapping from symbol to field class
  • Loading branch information
localshred committed Feb 17, 2014
2 parents 6bc3aeb + 7eb6de9 commit e6f1685
Show file tree
Hide file tree
Showing 16 changed files with 639 additions and 442 deletions.
51 changes: 40 additions & 11 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,56 @@
$: << ::File.expand_path('../', __FILE__)
$: << ::File.expand_path('../spec', __FILE__)

require "rubygems"
require "rubygems/package_task"
require "bundler/gem_tasks"
require "benchmark/tasks"
require 'fileutils'
require 'rubygems'
require 'rubygems/package_task'
require 'bundler/gem_tasks'
require 'benchmark/tasks'

require "rspec/core/rake_task"
require 'rspec/core/rake_task'

desc "Default: run specs."
desc 'Default: run specs.'
task :default => :spec

RSpec::Core::RakeTask.new(:spec)

desc "Run specs"
namespace :spec do
desc "Compile Test Protos in spec/supprt/"
task :compile_test_protos do |task, args|
desc 'Run specs'
namespace :compile do

desc 'Compile spec protos in spec/supprt/ directory'
task :spec do |task, args|
proto_path = ::File.expand_path('../spec/support/', __FILE__)
cmd = %Q{protoc --plugin=./bin/protoc-gen-ruby --ruby_out=#{proto_path} -I #{proto_path} #{File.join(proto_path, '**', '*.proto')}}

puts cmd
exec(cmd)
end

desc 'Compile rpc protos in protos/ directory'
task :rpc do |task, args|
proto_path = ::File.expand_path('../proto', __FILE__)
output_dir = ::File.expand_path('../tmp/rpc', __FILE__)
::FileUtils.mkdir_p(output_dir)

cmd = %Q{protoc --plugin=./bin/protoc-gen-ruby --ruby_out=#{output_dir} -I #{proto_path} #{File.join(proto_path, '**', '*.proto')}}

puts cmd
exec cmd
system(cmd)

files = {
'tmp/rpc/dynamic_discovery.pb.rb' => 'lib/protobuf/rpc',
'tmp/rpc/rpc.pb.rb' => 'lib/protobuf/rpc',
'tmp/rpc/google/protobuf/descriptor.pb.rb' => 'lib/protobuf/descriptors/google/protobuf',
'tmp/rpc/google/protobuf/compiler/plugin.pb.rb' => 'lib/protobuf/descriptors/google/protobuf/compiler'
}

files.each_pair do |source_file, destination_dir|
source_file = ::File.expand_path("../#{source_file}", __FILE__)
destination_dir = ::File.expand_path("../#{destination_dir}", __FILE__)
::FileUtils::Verbose.cp(source_file, destination_dir)
end
end

end

task :console do
Expand Down
33 changes: 17 additions & 16 deletions lib/protobuf/descriptors/google/protobuf/compiler/plugin.pb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,50 @@
#
require 'protobuf/message'


##
# Imports
#
require 'google/protobuf/descriptor.pb'

module Google

module Protobuf

module Compiler

##
# Message Classes
#
class CodeGeneratorRequest < ::Protobuf::Message; end
class CodeGeneratorResponse < ::Protobuf::Message
class File < ::Protobuf::Message; end

end




##
# Message Fields
#
class CodeGeneratorRequest
repeated ::Protobuf::Field::StringField, :file_to_generate, 1
optional ::Protobuf::Field::StringField, :parameter, 2
repeated :string, :file_to_generate, 1
optional :string, :parameter, 2
repeated ::Google::Protobuf::FileDescriptorProto, :proto_file, 15
end

class CodeGeneratorResponse
class File
optional ::Protobuf::Field::StringField, :name, 1
optional ::Protobuf::Field::StringField, :insertion_point, 2
optional ::Protobuf::Field::StringField, :content, 15
optional :string, :name, 1
optional :string, :insertion_point, 2
optional :string, :content, 15
end
optional ::Protobuf::Field::StringField, :error, 1

optional :string, :error, 1
repeated ::Google::Protobuf::Compiler::CodeGeneratorResponse::File, :file, 15
end



end

end

end

Loading

0 comments on commit e6f1685

Please sign in to comment.