• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythongamewindowsbathyscaphephpguic翻訳omegattwitterframeworktestbtronarduinovb.net計画中(planning stage)directxpreviewerゲームエンジンdom

超漢字アプリケーション開発用のProtocol Buffersコンパイラの開発


Commit MetaInfo

Revisão0a7ff77f0fbb7a0b1df68d07b574a8f3874f5545 (tree)
Hora2015-03-09 01:46:49
Autorornse01 <ornse01@user...>
Commiterornse01

Mensagem de Log

change Protobuf::CGenerator to instantiaiton.

Mudança Sumário

Diff

--- a/src/protobuf/cgenerator.rb
+++ b/src/protobuf/cgenerator.rb
@@ -4,16 +4,20 @@ require 'pathname'
44 module Protobuf end
55
66 class Protobuf::CGenerator
7- def self.generate_header(msg_list)
8- msg_list = msg_list.map { |msg| Protobuf::CGenerator::Message.new msg }
7+ def initialize(msg_list)
8+ @msg_list = msg_list
9+ end
10+
11+ def generate_header
12+ msg_list = @msg_list.map { |msg| Protobuf::CGenerator::Message.new msg }
913 script = Pathname("../template.h.erb").expand_path(__FILE__).read()
1014
1115 erb = ERB.new(script, nil, '-');
1216 erb.result(binding)
1317 end
1418
15- def self.generate_source(header_file_name, msg_list)
16- msg_list = msg_list.map { |msg| Protobuf::CGenerator::Message.new msg }
19+ def generate_source(header_file_name)
20+ msg_list = @msg_list.map { |msg| Protobuf::CGenerator::Message.new msg }
1721 script = Pathname("../template.c.erb").expand_path(__FILE__).read()
1822
1923 erb = ERB.new(script, nil, '-');
--- a/src/protobufcompiler.rb
+++ b/src/protobufcompiler.rb
@@ -22,14 +22,15 @@ end
2222 class ProtobufCompiler
2323 def initialize(src)
2424 @ir = Protobuf::Parser.new().parse_start(src)
25+ @cgen = Protobuf::CGenerator.new @ir.enum_for(:each_message)
2526 end
2627
2728 def generate_header
28- Protobuf::CGenerator.generate_header @ir.enum_for(:each_message)
29+ @cgen.generate_header
2930 end
3031
3132 def generate_source(header_file_name)
32- Protobuf::CGenerator.generate_source header_file_name, @ir.enum_for(:each_message)
33+ @cgen.generate_source header_file_name
3334 end
3435 end
3536