Class: Protobuf::Generators::MessageGenerator
- Defined in:
- lib/protobuf/generators/message_generator.rb
Constant Summary
Constants included from Printable
Printable::PARENT_CLASS_ENUM, Printable::PARENT_CLASS_MESSAGE, Printable::PARENT_CLASS_SERVICE
Instance Attribute Summary
Attributes inherited from Base
#descriptor, #namespace, #options
Instance Method Summary collapse
- #compile ⇒ Object
- #compile_declaration ⇒ Object
- #compile_message ⇒ Object
-
#initialize(descriptor, indent_level, options = {}) ⇒ MessageGenerator
constructor
A new instance of MessageGenerator.
Methods inherited from Base
#fully_qualified_type_namespace, #run_once, #serialize_value, #to_s, #type_namespace, validate_tags
Methods included from Printable
Constructor Details
#initialize(descriptor, indent_level, options = {}) ⇒ MessageGenerator
Returns a new instance of MessageGenerator.
8 9 10 11 12 |
# File 'lib/protobuf/generators/message_generator.rb', line 8 def initialize(descriptor, indent_level, = {}) super @only_declarations = .fetch(:declaration) { false } @extension_fields = .fetch(:extension_fields) { {} } end |
Instance Method Details
#compile ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/protobuf/generators/message_generator.rb', line 14 def compile run_once(:compile) do if @only_declarations compile_declaration else end end end |
#compile_declaration ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/protobuf/generators/message_generator.rb', line 24 def compile_declaration run_once(:compile_declaration) do if printable? print_class(descriptor.name, :message) do group = GroupGenerator.new(current_indent) group.add_enums(descriptor.enum_type, :namespace => type_namespace) group.(descriptor.nested_type) print group.to_s end else print_class(descriptor.name, :message) end end end |
#compile_message ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/protobuf/generators/message_generator.rb', line 39 def run_once(:compile_message) do if printable? print_class(descriptor.name, nil) do group = GroupGenerator.new(current_indent) group.(descriptor.nested_type, :extension_fields => @extension_fields, :namespace => type_namespace) group.add_comment(:options, 'Message Options') group.(descriptor.) if group.(descriptor.field, descriptor) self.class.(fully_qualified_type_namespace, descriptor.field.map(&:number)) group.add_comment(:extension_range, 'Extension Fields') group.add_extension_ranges(descriptor.extension_range) do |extension_range| "extensions #{extension_range.start}...#{extension_range.end}" end group.add_extension_fields() group.order = [:message, :options, :field, :extension_range, :extension_field] print group.to_s end end end end |