rggen-c-header 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4150e4e77b8fee78e7832a812c4332ce5b56f016c1caa803c23dd2ee032fad55
4
- data.tar.gz: 372b8614c051deee871ab887a24930c02d8d93cc97401aa937541f1d6b5fcde9
3
+ metadata.gz: 5dbb6ddb7c867f003e9ba685413ac4d3deb5ae9978ef5e59cca1919de9c51378
4
+ data.tar.gz: 34f5d2b0bec9eba0c63bec761ec8927214c118ddf70d3b9a4ae17ca6f9cd5c54
5
5
  SHA512:
6
- metadata.gz: a01adcc5020ff80a58c547978cff3eadb24edacf9d96c861600fb9d5136f9a70190bf64a71205bea2c4270456e2134c1d3afbe73955a9c3c311459189c843e6d
7
- data.tar.gz: ba3d13e5ac18902391b2797bfbda75c78846ca0c240c9fc750195beab84875d8f8a03ed300ed63eb5e839c4c4e8a14a357c90968454f3cfd0e63abf55860293a
6
+ metadata.gz: a862a0468553d95a8bd094ebf309f53d0745c23619109491b30b968d1bf0200df2bb5d014c632791e04bffc54db4d13ae9447496cbd5541ef44f8a8863475b02
7
+ data.tar.gz: 7e97c33f3efe07cc93cfb3d09447393b2ddb121de7751cc07a1c1b44fa2d465ac24a20ca96f671544adcac708952050519c1b0a8c6611f1ddea854468b8cd771
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2022 Taichi Ishitani
3
+ Copyright (c) 2022-2023 Taichi Ishitani
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -41,7 +41,7 @@ Feedbacks, bus reports, questions and etc. are welcome! You can post them bu usi
41
41
 
42
42
  ## Copyright & License
43
43
 
44
- Copyright © 2022 Taichi Ishitani. RgGen::CHeader is licensed under the [MIT License](https://opensource.org/licenses/MIT), see [LICENSE](LICENSE) for futher details.
44
+ Copyright © 2022-2023 Taichi Ishitani. RgGen::CHeader is licensed under the [MIT License](https://opensource.org/licenses/MIT), see [LICENSE](LICENSE) for futher details.
45
45
 
46
46
  ## Code of Conduct
47
47
 
@@ -17,7 +17,7 @@ module RgGen
17
17
 
18
18
  def define_macro(name, value = nil)
19
19
  macro_definitions <<
20
- Utility::MacroDefinition.new(name.upcase, value)
20
+ Core::Utility::CodeUtility::MacroDefinition.new(name.upcase, value)
21
21
  end
22
22
 
23
23
  def define_struct(name, members)
@@ -23,17 +23,21 @@ RgGen.define_simple_feature(:register, :c_header) do
23
23
  end
24
24
 
25
25
  def byte_size
26
- array_size_upper_layer.inject(1, :*) * register.byte_size
26
+ register.byte_size(hierarchical: true)
27
27
  end
28
28
 
29
29
  def array?
30
- register_files.any?(&:array?) || register.array?
30
+ register.array?(hierarchical: true)
31
31
  end
32
32
 
33
33
  def shared_address?
34
34
  register.settings[:support_shared_address]
35
35
  end
36
36
 
37
+ def array_size
38
+ register.array_size(hierarchical: true)
39
+ end
40
+
37
41
  def define_array_macros
38
42
  size_list = array_size
39
43
  define_macro("#{full_name}_array_dimension", size_list.size)
@@ -53,31 +57,12 @@ RgGen.define_simple_feature(:register, :c_header) do
53
57
  end
54
58
 
55
59
  def address_list
56
- upper_address_list = register_file&.expanded_offset_addresses || [0]
57
- upper_address_list.product(local_address_list).map(&:sum)
58
- end
59
-
60
- def local_address_list
61
- Array.new(register.count) do |i|
62
- if shared_address?
63
- register.offset_address
64
- else
65
- register.offset_address + register.byte_width * i
66
- end
67
- end
60
+ register.expanded_offset_addresses
68
61
  end
69
62
 
70
63
  def array_suffix
71
64
  index_list = array_size.map { |size| size.times.to_a }
72
65
  index_list.first.product(*index_list[1..]).map { |index| index.join('_') }
73
66
  end
74
-
75
- def array_size_upper_layer
76
- register_files.flat_map(&:array_size).compact
77
- end
78
-
79
- def array_size
80
- [*register_files, register].flat_map(&:array_size).compact
81
- end
82
67
  end
83
68
  end
@@ -20,10 +20,8 @@ RgGen.define_simple_feature(:register_block, :c_header) do
20
20
  write_file '<%= register_block.name %>.h' do |f|
21
21
  f.include_guard
22
22
  f.include_file 'stdint.h'
23
+ f.macro_definitions register_block.macro_definitions
23
24
  f.body do |code|
24
- register_block.macro_definitions.each do |macro|
25
- code << macro << nl
26
- end
27
25
  register_block.struct_definitions.each do |struct|
28
26
  code << struct
29
27
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RgGen
4
4
  module CHeader
5
- VERSION = '0.2.0'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
@@ -3,7 +3,6 @@
3
3
  require_relative 'c_header/version'
4
4
  require_relative 'c_header/utility/declaration'
5
5
  require_relative 'c_header/utility/struct_definition'
6
- require_relative 'c_header/utility/macro_definition'
7
6
  require_relative 'c_header/utility/source_file'
8
7
  require_relative 'c_header/utility'
9
8
  require_relative 'c_header/struct_builder'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rggen-c-header
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taichi Ishitani
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-05 00:00:00.000000000 Z
11
+ date: 2023-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -45,7 +45,6 @@ files:
45
45
  - lib/rggen/c_header/struct_builder.rb
46
46
  - lib/rggen/c_header/utility.rb
47
47
  - lib/rggen/c_header/utility/declaration.rb
48
- - lib/rggen/c_header/utility/macro_definition.rb
49
48
  - lib/rggen/c_header/utility/source_file.rb
50
49
  - lib/rggen/c_header/utility/struct_definition.rb
51
50
  - lib/rggen/c_header/version.rb
@@ -66,15 +65,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
66
65
  requirements:
67
66
  - - ">="
68
67
  - !ruby/object:Gem::Version
69
- version: 2.6.0
68
+ version: 2.7.0
70
69
  required_rubygems_version: !ruby/object:Gem::Requirement
71
70
  requirements:
72
71
  - - ">="
73
72
  - !ruby/object:Gem::Version
74
73
  version: '0'
75
74
  requirements: []
76
- rubygems_version: 3.3.3
75
+ rubygems_version: 3.4.1
77
76
  signing_key:
78
77
  specification_version: 4
79
- summary: rggen-c-header-0.2.0
78
+ summary: rggen-c-header-0.3.0
80
79
  test_files: []
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RgGen
4
- module CHeader
5
- module Utility
6
- class MacroDefinition
7
- def initialize(name, value = nil)
8
- @name = name
9
- @value = value
10
- end
11
-
12
- def to_s
13
- @value && "#define #{@name} #{@value}" || "#define #{@name}"
14
- end
15
- end
16
- end
17
- end
18
- end