autoc 1.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGES.md +3 -0
  3. data/README.md +149 -0
  4. data/cmake/AutoC.cmake +39 -0
  5. data/lib/autoc/allocators.rb +51 -0
  6. data/lib/autoc/association.rb +126 -0
  7. data/lib/autoc/box.rb +311 -0
  8. data/lib/autoc/cmake.rb +54 -0
  9. data/lib/autoc/collection.rb +83 -110
  10. data/lib/autoc/composite.rb +333 -0
  11. data/lib/autoc/cstring.rb +263 -0
  12. data/lib/autoc/function.rb +247 -0
  13. data/lib/autoc/hash_map.rb +328 -0
  14. data/lib/autoc/hash_set.rb +339 -0
  15. data/lib/autoc/hashers.rb +102 -0
  16. data/lib/autoc/list.rb +444 -0
  17. data/lib/autoc/module.rb +434 -0
  18. data/lib/autoc/openmp.rb +15 -0
  19. data/lib/autoc/primitive.rb +27 -0
  20. data/lib/autoc/ranges.rb +707 -0
  21. data/lib/autoc/record.rb +247 -0
  22. data/lib/autoc/scaffold/docs.rb +117 -0
  23. data/lib/autoc/scaffold/generic_value.rb +86 -0
  24. data/lib/autoc/scaffold/project.rb +75 -0
  25. data/lib/autoc/scaffold/test_cstring.rb +113 -0
  26. data/lib/autoc/scaffold/test_cstring_hash_set.rb +35 -0
  27. data/lib/autoc/scaffold/test_int_box.rb +22 -0
  28. data/lib/autoc/scaffold/test_int_hash_set.rb +448 -0
  29. data/lib/autoc/scaffold/test_int_list.rb +106 -0
  30. data/lib/autoc/scaffold/test_int_vector.rb +83 -0
  31. data/lib/autoc/scaffold/test_v2v_hash_map.rb +83 -0
  32. data/lib/autoc/scaffold/test_value_hash_set.rb +60 -0
  33. data/lib/autoc/scaffold/test_value_vector.rb +146 -0
  34. data/{test/test.rb → lib/autoc/scaffold/tests.rb} +179 -158
  35. data/lib/autoc/scaffold.rb +12 -0
  36. data/lib/autoc/sequential.rb +99 -0
  37. data/lib/autoc/set.rb +331 -0
  38. data/lib/autoc/std.rb +149 -0
  39. data/lib/autoc/type.rb +93 -531
  40. data/lib/autoc/vector.rb +290 -0
  41. data/lib/autoc.rb +4 -35
  42. metadata +55 -85
  43. data/.yardopts +0 -4
  44. data/CHANGES +0 -23
  45. data/README +0 -28
  46. data/doc/AutoC/Code.html +0 -523
  47. data/doc/AutoC/Collection.html +0 -1214
  48. data/doc/AutoC/HashMap.html +0 -1441
  49. data/doc/AutoC/HashSet.html +0 -916
  50. data/doc/AutoC/Iterators/Bidirectional.html +0 -204
  51. data/doc/AutoC/Iterators/Unidirectional.html +0 -200
  52. data/doc/AutoC/Iterators.html +0 -126
  53. data/doc/AutoC/List.html +0 -1039
  54. data/doc/AutoC/Maps.html +0 -290
  55. data/doc/AutoC/Module/File.html +0 -415
  56. data/doc/AutoC/Module/Header.html +0 -437
  57. data/doc/AutoC/Module/Source.html +0 -707
  58. data/doc/AutoC/Module.html +0 -948
  59. data/doc/AutoC/Priority.html +0 -138
  60. data/doc/AutoC/Queue.html +0 -1172
  61. data/doc/AutoC/Reference.html +0 -735
  62. data/doc/AutoC/Sets.html +0 -520
  63. data/doc/AutoC/String.html +0 -1394
  64. data/doc/AutoC/TreeMap.html +0 -1565
  65. data/doc/AutoC/TreeSet.html +0 -1447
  66. data/doc/AutoC/Type.html +0 -2148
  67. data/doc/AutoC/UserDefinedType.html +0 -1047
  68. data/doc/AutoC/Vector.html +0 -987
  69. data/doc/AutoC.html +0 -331
  70. data/doc/_index.html +0 -388
  71. data/doc/class_list.html +0 -51
  72. data/doc/css/common.css +0 -1
  73. data/doc/css/full_list.css +0 -58
  74. data/doc/css/style.css +0 -481
  75. data/doc/file.CHANGES.html +0 -117
  76. data/doc/file.README.html +0 -116
  77. data/doc/file_list.html +0 -61
  78. data/doc/frames.html +0 -17
  79. data/doc/index.html +0 -116
  80. data/doc/js/app.js +0 -243
  81. data/doc/js/full_list.js +0 -216
  82. data/doc/js/jquery.js +0 -4
  83. data/doc/method_list.html +0 -1307
  84. data/doc/top-level-namespace.html +0 -112
  85. data/lib/autoc/code.rb +0 -237
  86. data/lib/autoc/collection/hash_map.rb +0 -385
  87. data/lib/autoc/collection/hash_set.rb +0 -337
  88. data/lib/autoc/collection/iterator.rb +0 -39
  89. data/lib/autoc/collection/list.rb +0 -429
  90. data/lib/autoc/collection/map.rb +0 -41
  91. data/lib/autoc/collection/queue.rb +0 -517
  92. data/lib/autoc/collection/set.rb +0 -134
  93. data/lib/autoc/collection/tree_map.rb +0 -464
  94. data/lib/autoc/collection/tree_set.rb +0 -611
  95. data/lib/autoc/collection/vector.rb +0 -336
  96. data/lib/autoc/string.rb +0 -492
  97. data/test/test_auto.c +0 -7141
  98. data/test/test_auto.h +0 -753
  99. data/test/test_char_string.rb +0 -270
  100. data/test/test_int_list.rb +0 -35
  101. data/test/test_int_tree_set.rb +0 -111
  102. data/test/test_int_vector.rb +0 -34
  103. data/test/test_value_hash_map.rb +0 -162
  104. data/test/test_value_hash_set.rb +0 -173
  105. data/test/test_value_list.rb +0 -193
  106. data/test/test_value_queue.rb +0 -275
  107. data/test/test_value_tree_map.rb +0 -176
  108. data/test/test_value_tree_set.rb +0 -173
  109. data/test/test_value_vector.rb +0 -155
  110. data/test/value.rb +0 -80
@@ -1,112 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>
7
- Top Level Namespace
8
-
9
- &mdash; Documentation by YARD 0.9.5
10
-
11
- </title>
12
-
13
- <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
-
15
- <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
-
17
- <script type="text/javascript" charset="utf-8">
18
- pathId = "";
19
- relpath = '';
20
- </script>
21
-
22
-
23
- <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
-
25
- <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
-
27
-
28
- </head>
29
- <body>
30
- <div class="nav_wrap">
31
- <iframe id="nav" src="class_list.html"></iframe>
32
- <div id="resizer"></div>
33
- </div>
34
-
35
- <div id="main" tabindex="-1">
36
- <div id="header">
37
- <div id="menu">
38
-
39
- <a href="_index.html">Index</a> &raquo;
40
-
41
-
42
- <span class="title">Top Level Namespace</span>
43
-
44
- </div>
45
-
46
- <div id="search">
47
-
48
- <a class="full_list_link" id="class_list_link"
49
- href="class_list.html">
50
-
51
- <svg width="24" height="24">
52
- <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
- <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
- <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
- </svg>
56
- </a>
57
-
58
- </div>
59
- <div class="clear"></div>
60
- </div>
61
-
62
- <iframe id="search_frame" src="class_list.html"></iframe>
63
-
64
- <div id="content"><h1>Top Level Namespace
65
-
66
-
67
-
68
- </h1>
69
- <div class="box_info">
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
- </div>
82
-
83
- <h2>Defined Under Namespace</h2>
84
- <p class="children">
85
-
86
-
87
- <strong class="modules">Modules:</strong> <span class='object_link'><a href="AutoC.html" title="AutoC (module)">AutoC</a></span>
88
-
89
-
90
-
91
-
92
- </p>
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
- </div>
103
-
104
- <div id="footer">
105
- Generated on Wed Oct 12 12:27:11 2016 by
106
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
107
- 0.9.5 (ruby-2.3.1).
108
- </div>
109
-
110
- </div>
111
- </body>
112
- </html>
data/lib/autoc/code.rb DELETED
@@ -1,237 +0,0 @@
1
- require "set"
2
-
3
-
4
- module AutoC
5
-
6
-
7
- # class Entity
8
- # def entities()
9
- # def priority()
10
- # def source_size()
11
- # def attach(source)
12
- # def write_intf(stream)
13
- # def write_defs(stream)
14
- # def write_decls(stream)
15
- # def hash()
16
- # def eql?(other)
17
- # end
18
-
19
-
20
- # Convert obj to string and return it.
21
- # Throw NameError is resulting string is not a valid C identifier.
22
- def self.c_id(obj)
23
- obj = obj.to_s
24
- raise NameError.new("'#{obj}' is not a valid C identifier", obj) if (/^[_a-zA-Z]\w*$/ =~ obj).nil?
25
- obj
26
- end
27
-
28
-
29
- # TODO min/max Fixnums
30
- module Priority
31
- DEFAULT = 0
32
- MIN = -1000
33
- MAX = +1000
34
- end
35
-
36
-
37
- # A no-op entity implementation with reasonable defaults
38
- class Code
39
- def entities; [] end
40
- def priority
41
- if entities.empty?
42
- Priority::DEFAULT
43
- else
44
- result = Priority::DEFAULT
45
- entities.each do |e|
46
- ep = e.priority
47
- result = ep if result > ep
48
- end
49
- result-1
50
- end
51
- end
52
- def source_size
53
- s = ::String.new
54
- write_decls(s)
55
- write_defs(s)
56
- s.size
57
- end
58
- def attach(source) source << self if source.smallest? end
59
- def write_intf(stream) end
60
- def write_defs(stream) end
61
- def write_decls(stream) end
62
- end # Code
63
-
64
-
65
- class Module
66
-
67
- def self.generate!(name, &block)
68
- m = self.new(name)
69
- block.call(m)
70
- m.generate!
71
- end
72
-
73
- attr_reader :name, :header, :smallest_source, :main_source
74
-
75
- def initialize(name)
76
- @entities = Set.new
77
- @source_size_threshold = 0
78
- @name = name.to_s # TODO validate
79
- end
80
-
81
- def <<(obj)
82
- obj.entities.each {|e| self << e} unless @entities.add?(obj).nil?
83
- self
84
- end
85
-
86
- def new_header
87
- Header.new(self)
88
- end
89
-
90
- def new_source(index)
91
- Source.new(self, index)
92
- end
93
-
94
- def source_count=(count)
95
- @source_count = count
96
- end
97
-
98
- def generate!
99
- @header = new_header
100
- @sources = []
101
- (1..source_count).each {|i| @sources << new_source(i)}
102
- @main_source = @sources.first
103
- @smallest_source = @main_source
104
- # It appears that computing the size of a source might be a fairly expensive operation so do it only when necessary
105
- refresh_smallest_source = source_count > 1
106
- @entities.each do |e|
107
- @header << e
108
- @smallest_source = @sources.sort_by {|s| s.size}.first if refresh_smallest_source
109
- @sources.each {|s| e.attach(s)}
110
- end
111
- @header.generate
112
- @sources.each {|s| s.generate}
113
- end
114
-
115
- def source_count
116
- if @source_count.nil?
117
- total = 0
118
- @entities.each {|e| total += e.source_size}
119
- count = @source_size_threshold > 0 ? (total/@source_size_threshold + 1) : 1
120
- @source_count = count > 0 ? count : 1
121
- else
122
- @source_count
123
- end
124
- end
125
-
126
- end # Module
127
-
128
-
129
- def self.priority_sort(entities, reverse = false)
130
- list = entities.to_a.sort! {|a,b| a.priority <=> b.priority}
131
- list.reverse! unless reverse
132
- list
133
- end # priority_sort
134
-
135
-
136
- class Module::File
137
-
138
- attr_reader :entities
139
-
140
- # def new_stream()
141
-
142
- # def write(stream)
143
-
144
- def initialize(m)
145
- @entities = Set.new
146
- @module = m
147
- end
148
-
149
- def generate
150
- stream = new_stream
151
- begin
152
- write(stream)
153
- ensure
154
- stream.close
155
- end
156
- end
157
-
158
- def <<(e)
159
- @entities << e
160
- self
161
- end
162
-
163
- end # File
164
-
165
-
166
- class Module::Header < Module::File
167
-
168
- attr_reader :file_name
169
-
170
- def initialize(*args)
171
- super
172
- @file_name = "#{@module.name.downcase}_auto.h"
173
- @guard_macro = "#{@module.name.upcase}_AUTO_H"
174
- end
175
-
176
- def new_stream
177
- ::File.new(@file_name, "w")
178
- end
179
-
180
- def write(stream)
181
- stream << %$
182
- /* AUTOMATICALLY GENERATED HEADER FILE. DO NOT MODIFY. */
183
- #ifndef #{@guard_macro}
184
- #define #{@guard_macro}
185
- $
186
- AutoC.priority_sort(entities).each {|e| e.write_intf(stream)}
187
- stream << %$
188
- #endif
189
- $
190
- stream << "\n" # DigitalMars C in strict ANSI (-A) mode complains about absent empty line at the very end so let's make it happy
191
- end
192
-
193
- end # Header
194
-
195
-
196
- class Module::Source < Module::File
197
-
198
- attr_reader :index, :file_name
199
-
200
- def initialize(m, i)
201
- super(m)
202
- @index = i
203
- @file_name = @module.source_count > 1 ? "#{@module.name.downcase}_auto#{index}.c" : "#{@module.name.downcase}_auto.c"
204
- end
205
-
206
- def main?
207
- equal?(@module.main_source)
208
- end
209
-
210
- def smallest?
211
- equal?(@module.smallest_source)
212
- end
213
-
214
- def size
215
- size = 0
216
- @entities.each {|e| size += e.source_size}
217
- size
218
- end
219
-
220
- def new_stream
221
- ::File.new(@file_name, "w")
222
- end
223
-
224
- def write(stream)
225
- stream << %$
226
- /* AUTOMATICALLY GENERATED SOURCE FILE. DO NOT MODIFY. */
227
- #include "#{@module.header.file_name}"
228
- $
229
- sorted = AutoC.priority_sort(entities)
230
- sorted.each {|e| e.write_decls(stream)}
231
- sorted.each {|e| e.write_defs(stream)}
232
- end
233
-
234
- end # Source
235
-
236
-
237
- end # AutoC