rggen-core 0.19.0 → 0.23.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/rggen +2 -2
- data/lib/rggen/core.rb +7 -4
- data/lib/rggen/core/base/component.rb +16 -7
- data/lib/rggen/core/base/component_factory.rb +12 -9
- data/lib/rggen/core/base/component_layer_extension.rb +194 -0
- data/lib/rggen/core/base/feature_layer_extension.rb +158 -0
- data/lib/rggen/core/builder/builder.rb +38 -52
- data/lib/rggen/core/builder/component_entry.rb +3 -2
- data/lib/rggen/core/builder/component_registry.rb +22 -17
- data/lib/rggen/core/builder/feature_registry.rb +6 -9
- data/lib/rggen/core/builder/input_component_registry.rb +43 -10
- data/lib/rggen/core/builder/layer.rb +132 -0
- data/lib/rggen/core/builder/loader_registry.rb +48 -0
- data/lib/rggen/core/builder/plugin_manager.rb +140 -0
- data/lib/rggen/core/configuration.rb +3 -2
- data/lib/rggen/core/configuration/component.rb +5 -0
- data/lib/rggen/core/configuration/component_factory.rb +1 -1
- data/lib/rggen/core/configuration/hash_loader.rb +4 -2
- data/lib/rggen/core/configuration/input_data.rb +15 -0
- data/lib/rggen/core/dsl.rb +3 -1
- data/lib/rggen/core/exceptions.rb +9 -4
- data/lib/rggen/core/generator.rb +3 -3
- data/lib/rggen/core/input_base/component_factory.rb +37 -6
- data/lib/rggen/core/input_base/feature.rb +3 -3
- data/lib/rggen/core/input_base/input_data.rb +13 -10
- data/lib/rggen/core/input_base/input_value_extractor.rb +34 -0
- data/lib/rggen/core/input_base/loader.rb +64 -21
- data/lib/rggen/core/input_base/yaml_loader.rb +5 -4
- data/lib/rggen/core/options.rb +18 -14
- data/lib/rggen/core/output_base/code_generator.rb +10 -23
- data/lib/rggen/core/output_base/component.rb +42 -39
- data/lib/rggen/core/output_base/component_factory.rb +4 -0
- data/lib/rggen/core/output_base/feature.rb +6 -7
- data/lib/rggen/core/printers.rb +11 -7
- data/lib/rggen/core/register_map.rb +6 -5
- data/lib/rggen/core/register_map/component.rb +4 -3
- data/lib/rggen/core/register_map/component_factory.rb +18 -1
- data/lib/rggen/core/register_map/feature.rb +2 -2
- data/lib/rggen/core/register_map/hash_loader.rb +61 -27
- data/lib/rggen/core/register_map/input_data.rb +30 -16
- data/lib/rggen/core/register_map/loader.rb +1 -1
- data/lib/rggen/core/register_map/ruby_loader.rb +1 -1
- data/lib/rggen/core/utility/attribute_setter.rb +4 -0
- data/lib/rggen/core/utility/code_utility.rb +8 -2
- data/lib/rggen/core/utility/error_utility.rb +33 -6
- data/lib/rggen/core/version.rb +2 -2
- metadata +10 -7
- data/lib/rggen/core/base/hierarchical_accessors.rb +0 -91
- data/lib/rggen/core/base/hierarchical_feature_accessors.rb +0 -83
- data/lib/rggen/core/builder/category.rb +0 -116
- data/lib/rggen/core/builder/plugins.rb +0 -77
@@ -1,83 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RgGen
|
4
|
-
module Core
|
5
|
-
module Base
|
6
|
-
module HierarchicalFeatureAccessors
|
7
|
-
module RegisterMap
|
8
|
-
def hierarchy
|
9
|
-
:register_map
|
10
|
-
end
|
11
|
-
|
12
|
-
def register_map
|
13
|
-
@component
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
module RegisterBlock
|
18
|
-
def hierarchy
|
19
|
-
:register_block
|
20
|
-
end
|
21
|
-
|
22
|
-
def register_map
|
23
|
-
register_block.parent
|
24
|
-
end
|
25
|
-
|
26
|
-
def register_block
|
27
|
-
@component
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
module Register
|
32
|
-
def hierarchy
|
33
|
-
:register
|
34
|
-
end
|
35
|
-
|
36
|
-
def register_map
|
37
|
-
register_block.parent
|
38
|
-
end
|
39
|
-
|
40
|
-
def register_block
|
41
|
-
register.parent
|
42
|
-
end
|
43
|
-
|
44
|
-
def register
|
45
|
-
@component
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
module BitField
|
50
|
-
def hierarchy
|
51
|
-
:bit_field
|
52
|
-
end
|
53
|
-
|
54
|
-
def register_map
|
55
|
-
register_block.parent
|
56
|
-
end
|
57
|
-
|
58
|
-
def register_block
|
59
|
-
register.parent
|
60
|
-
end
|
61
|
-
|
62
|
-
def register
|
63
|
-
bit_field.parent
|
64
|
-
end
|
65
|
-
|
66
|
-
def bit_field
|
67
|
-
@component
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
private
|
72
|
-
|
73
|
-
ACCESSOR_EXTENSIONS = [
|
74
|
-
RegisterMap, RegisterBlock, Register, BitField
|
75
|
-
].freeze
|
76
|
-
|
77
|
-
def define_hierarchical_accessors
|
78
|
-
extend ACCESSOR_EXTENSIONS[@component.level]
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
@@ -1,116 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RgGen
|
4
|
-
module Core
|
5
|
-
module Builder
|
6
|
-
class Category
|
7
|
-
class Proxy
|
8
|
-
def initialize(body)
|
9
|
-
body.call(self)
|
10
|
-
end
|
11
|
-
|
12
|
-
attr_setter :method
|
13
|
-
attr_setter :list_names
|
14
|
-
attr_setter :feature_names
|
15
|
-
|
16
|
-
def shared_context(&body)
|
17
|
-
if block_given?
|
18
|
-
@shared_context ||= Object.new
|
19
|
-
@shared_context.instance_eval(&body)
|
20
|
-
end
|
21
|
-
@shared_context
|
22
|
-
end
|
23
|
-
|
24
|
-
def register_execution(registry, args, body)
|
25
|
-
@executions ||= []
|
26
|
-
@executions << { registry: registry, args: args, body: body }
|
27
|
-
end
|
28
|
-
|
29
|
-
def execute(category, body)
|
30
|
-
Docile.dsl_eval(category, &body)
|
31
|
-
Array(@executions).each { |execution| call_execution(execution) }
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def call_execution(execution)
|
37
|
-
send_args = [
|
38
|
-
list_names, feature_names, shared_context, *execution[:args]
|
39
|
-
].compact
|
40
|
-
execution[:registry].__send__(
|
41
|
-
method, *send_args, &execution[:body]
|
42
|
-
)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def initialize(name)
|
47
|
-
@name = name
|
48
|
-
@feature_registries = {}
|
49
|
-
end
|
50
|
-
|
51
|
-
def add_feature_registry(name, registry)
|
52
|
-
@feature_registries[name] = registry
|
53
|
-
define_proxy_call(name)
|
54
|
-
end
|
55
|
-
|
56
|
-
def shared_context(&body)
|
57
|
-
block_given? && @proxy&.shared_context(&body)
|
58
|
-
end
|
59
|
-
|
60
|
-
def define_simple_feature(feature_names, &body)
|
61
|
-
do_proxy_call(body) do |proxy|
|
62
|
-
proxy.method(__method__)
|
63
|
-
proxy.feature_names(feature_names)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def define_list_feature(list_names, &body)
|
68
|
-
do_proxy_call(body) do |proxy|
|
69
|
-
proxy.method(__method__)
|
70
|
-
proxy.list_names(list_names)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def define_list_item_feature(list_name, feature_names, &body)
|
75
|
-
do_proxy_call(body) do |proxy|
|
76
|
-
proxy.method(__method__)
|
77
|
-
proxy.list_names(list_name)
|
78
|
-
proxy.feature_names(feature_names)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def enable(feature_or_list_names, feature_names = nil)
|
83
|
-
@feature_registries.each_value do |registry|
|
84
|
-
registry.enable(feature_or_list_names, feature_names)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def disable(feature_or_list_names = nil, feature_names = nil)
|
89
|
-
@feature_registries.each_value do |registry|
|
90
|
-
registry.disable(*[feature_or_list_names, feature_names].compact)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def delete(feature_or_list_names = nil, feature_names = nil)
|
95
|
-
@feature_registries.each_value do |registry|
|
96
|
-
registry.delete(*[feature_or_list_names, feature_names].compact)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
private
|
101
|
-
|
102
|
-
def define_proxy_call(name)
|
103
|
-
define_singleton_method(name) do |*args, &body|
|
104
|
-
@proxy.register_execution(@feature_registries[name], args, body)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
def do_proxy_call(body, &proxy_block)
|
109
|
-
@proxy = Proxy.new(proxy_block)
|
110
|
-
@proxy.execute(self, body)
|
111
|
-
remove_instance_variable(:@proxy)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RgGen
|
4
|
-
module Core
|
5
|
-
module Builder
|
6
|
-
class Plugin
|
7
|
-
DEFAULT_PLUGIN_VERSION = '0.0.0'
|
8
|
-
|
9
|
-
def initialize(name, module_or_version, &block)
|
10
|
-
@name = name
|
11
|
-
@block = block
|
12
|
-
@version, @plugin_module =
|
13
|
-
if module_or_version.is_a?(Module)
|
14
|
-
[extract_version(module_or_version), module_or_version]
|
15
|
-
else
|
16
|
-
[module_or_version || DEFAULT_PLUGIN_VERSION]
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
attr_reader :name
|
21
|
-
attr_reader :version
|
22
|
-
|
23
|
-
def default_setup(builder)
|
24
|
-
@plugin_module &&
|
25
|
-
begin
|
26
|
-
@plugin_module.respond_to?(:default_setup) &&
|
27
|
-
@plugin_module.default_setup(builder)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def optional_setup(builder)
|
32
|
-
@block &&
|
33
|
-
if @plugin_module
|
34
|
-
@plugin_module.instance_exec(builder, &@block)
|
35
|
-
else
|
36
|
-
@block.call(builder)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def version_info
|
41
|
-
"#{name} #{version}"
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
def extract_version(plugin_module)
|
47
|
-
if plugin_module.const_defined?(:VERSION)
|
48
|
-
plugin_module.const_get(:VERSION)
|
49
|
-
elsif plugin_module.respond_to?(:version)
|
50
|
-
plugin_module.version
|
51
|
-
else
|
52
|
-
DEFAULT_PLUGIN_VERSION
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
class Plugins
|
58
|
-
def initialize
|
59
|
-
@plugins = []
|
60
|
-
end
|
61
|
-
|
62
|
-
def add(name, module_or_version, &block)
|
63
|
-
@plugins << Plugin.new(name, module_or_version, &block)
|
64
|
-
end
|
65
|
-
|
66
|
-
def activate(builder)
|
67
|
-
@plugins.each { |plugin| plugin.default_setup(builder) }
|
68
|
-
@plugins.each { |plugin| plugin.optional_setup(builder) }
|
69
|
-
end
|
70
|
-
|
71
|
-
def version_info
|
72
|
-
@plugins.map(&:version_info)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|