class RgGen::Core::OutputBase::Component
Constants
- CodeGeneratorContext
Attributes
configuration[R]
register_map[R]
Public Instance Methods
add_feature(feature)
click to toggle source
Calls superclass method
RgGen::Core::Base::Component#add_feature
# File lib/rggen/core/output_base/component.rb, line 24 def add_feature(feature) super import_feature_methods(feature, :class) end
build()
click to toggle source
# File lib/rggen/core/output_base/component.rb, line 37 def build @features.each_value(&method(:build_feature)) @children.each(&:build) end
children?()
click to toggle source
# File lib/rggen/core/output_base/component.rb, line 20 def children? !register_map.children.empty? end
generate_code(code, kind, mode, target_or_range = nil, depth = 0)
click to toggle source
# File lib/rggen/core/output_base/component.rb, line 42 def generate_code(code, kind, mode, target_or_range = nil, depth = 0) code_generator_contexts(kind, mode, target_or_range, depth) .each { |context| context.generate(code) } end
post_initialize(configuration, register_map)
click to toggle source
# File lib/rggen/core/output_base/component.rb, line 12 def post_initialize(configuration, register_map) @configuration = configuration @register_map = register_map @need_children = register_map.need_children? define_layer_methods define_proxy_calls(@register_map, @register_map.properties) end
pre_build()
click to toggle source
# File lib/rggen/core/output_base/component.rb, line 33 def pre_build @features.each_value(&:pre_build) end
printables()
click to toggle source
# File lib/rggen/core/output_base/component.rb, line 29 def printables register_map.printables end
write_file(directory = nil)
click to toggle source
# File lib/rggen/core/output_base/component.rb, line 47 def write_file(directory = nil) @features.each_value { |feature| feature.write_file(directory) } @children.each { |component| component.write_file(directory) } end
Private Instance Methods
build_feature(feature)
click to toggle source
# File lib/rggen/core/output_base/component.rb, line 54 def build_feature(feature) feature.build import_feature_methods(feature, :object) end
code_generator_contexts(kind, mode, target_or_range, depth)
click to toggle source
# File lib/rggen/core/output_base/component.rb, line 70 def code_generator_contexts(kind, mode, target_or_range, depth) [ feature_code_generator_context(:pre_code, kind, target_or_range, depth), *main_code_generator_contexts(kind, mode, target_or_range, depth), feature_code_generator_context(:post_code, kind, target_or_range, depth) ].compact end
feature_code_generator_context(phase, kind, target_or_range, depth)
click to toggle source
# File lib/rggen/core/output_base/component.rb, line 78 def feature_code_generator_context(phase, kind, target_or_range, depth) (target_depth?(depth, target_or_range) || nil) && CodeGeneratorContext.new(@features.each_value, [phase, kind]) end
import_feature_methods(feature, scope)
click to toggle source
# File lib/rggen/core/output_base/component.rb, line 59 def import_feature_methods(feature, scope) methods = feature.exported_methods(scope) define_proxy_calls(feature, methods) end
main_code_generator_contexts(kind, mode, target_or_range, depth)
click to toggle source
# File lib/rggen/core/output_base/component.rb, line 93 def main_code_generator_contexts(kind, mode, target_or_range, depth) [ feature_code_generator_context(:main_code, kind, target_or_range, depth), CodeGeneratorContext.new(@children, [kind, mode, target_or_range, depth + 1]) ].tap { |contexts| mode == :bottom_up && contexts.reverse! } end
target_depth?(depth, target_or_range)
click to toggle source
# File lib/rggen/core/output_base/component.rb, line 83 def target_depth?(depth, target_or_range) if target_or_range.nil? true elsif target_or_range.respond_to?(:include?) target_or_range.include?(depth) else depth == target_or_range end end