RuCodeGen 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. data/LICENSE +25 -0
  2. data/README +34 -0
  3. data/Rakefile +32 -0
  4. data/docs/Principle +152 -0
  5. data/docs/ValueIncapsulator +195 -0
  6. data/docs/examples/cpp/custom/submit_deliver +909 -0
  7. data/docs/examples/cpp/value_incapsulator/cfg +127 -0
  8. data/docs/examples/cpp/value_incapsulator/host_config +51 -0
  9. data/examples/cpp/custom/submit_deliver/submit_deliver.rb +43 -0
  10. data/examples/cpp/custom/submit_deliver/submit_deliver_gen.rb +326 -0
  11. data/examples/cpp/value_incapsulator/cfg.decl.hpp +51 -0
  12. data/examples/cpp/value_incapsulator/cfg.impl.cpp +63 -0
  13. data/examples/cpp/value_incapsulator/cg-cfg.rb +19 -0
  14. data/examples/cpp/value_incapsulator/cg-cfg.test.cpp +15 -0
  15. data/examples/cpp/value_incapsulator/cg-host_config.rb +12 -0
  16. data/examples/cpp/value_incapsulator/cout.log +4 -0
  17. data/examples/cpp/value_incapsulator/host_config.impl.cpp +21 -0
  18. data/examples/cpp/value_incapsulator/host_config.impl.hpp +21 -0
  19. data/lib/rucodegen/begin_end.rb +26 -0
  20. data/lib/rucodegen/codegen.rb +4 -0
  21. data/lib/rucodegen/filename_producer.rb +57 -0
  22. data/lib/rucodegen/generation_initiator.rb +92 -0
  23. data/lib/rucodegen/generators.rb +36 -0
  24. data/lib/rucodegen/run_mode.rb +89 -0
  25. data/lib/rucodegen/value_incapsulator.rb +331 -0
  26. data/lib/rucodegen.rb +4 -0
  27. data/tests/generators_test_extension.rb +23 -0
  28. data/tests/tc_class_attribute.rb +87 -0
  29. data/tests/tc_codegen_initiator.rb +164 -0
  30. data/tests/tc_filename_producer.rb +54 -0
  31. data/tests/tc_generators.rb +55 -0
  32. data/tests/tc_run_mode.rb +72 -0
  33. data/tests/tc_value_incapsulator.rb +193 -0
  34. data/tests/tc_value_incapsulator_gen.rb +479 -0
  35. data/tests/ts_rucodegen.rb +11 -0
  36. metadata +98 -0
@@ -0,0 +1,479 @@
1
+ $:.unshift( File.dirname( __FILE__ ) + "/../lib" )
2
+
3
+ require 'test/unit'
4
+
5
+ require 'rucodegen/value_incapsulator'
6
+
7
+ class TC_ValueIncapsulatorGeneration < Test::Unit::TestCase
8
+ def test_decl_empty_class
9
+ vi = cpp_value_incapsulator "cfg_t" do |c|
10
+ c.decl_file :script_relative => "test_empty_class.hpp"
11
+ c.impl_file :script_relative => "test_empty_class.cpp"
12
+ end
13
+
14
+ generation_result = %q{
15
+ class cfg_t
16
+ {
17
+ private :
18
+
19
+ public :
20
+ cfg_t();
21
+
22
+
23
+ };
24
+ }
25
+
26
+ assert_equal( generation_result,
27
+ RuCodeGen::ValueIncapsulator::Generation::generate_decl(
28
+ vi ) )
29
+ end
30
+
31
+ def test_decl_with_attributes_no_prefix_no_suffix
32
+ vi = cpp_value_incapsulator "cfg_t" do |c|
33
+ c.decl_file :script_relative =>
34
+ "test_decl_with_attributes_no_prefix_no_suffix.hpp"
35
+ c.impl_file :script_relative =>
36
+ "test_decl_with_attributes_no_prefix_no_suffix.cpp"
37
+
38
+ c.attr :listening_mbox, "std::string"
39
+ c.attr :interception_priority, "int", :default => 2
40
+ c.attr :low_watermark, "unsigned int"
41
+ c.attr :high_watermark, "unsigned int"
42
+ c.attr :cprov_high_watermark, "unsigned int"
43
+ c.attr :max_life_time, "unsigned int", :default => 60
44
+ c.attr :check_life_time_period, "unsigned int", :default => 5
45
+ end
46
+
47
+ generation_result = %q{
48
+ class cfg_t
49
+ {
50
+ private :
51
+ std::string listening_mbox;
52
+ int interception_priority;
53
+ unsigned int low_watermark;
54
+ unsigned int high_watermark;
55
+ unsigned int cprov_high_watermark;
56
+ unsigned int max_life_time;
57
+ unsigned int check_life_time_period;
58
+
59
+ public :
60
+ cfg_t();
61
+
62
+ const std::string &
63
+ listening_mbox() const;
64
+ void
65
+ listening_mbox( const std::string & v__ );
66
+ int
67
+ interception_priority() const;
68
+ void
69
+ interception_priority( int v__ );
70
+ unsigned int
71
+ low_watermark() const;
72
+ void
73
+ low_watermark( unsigned int v__ );
74
+ unsigned int
75
+ high_watermark() const;
76
+ void
77
+ high_watermark( unsigned int v__ );
78
+ unsigned int
79
+ cprov_high_watermark() const;
80
+ void
81
+ cprov_high_watermark( unsigned int v__ );
82
+ unsigned int
83
+ max_life_time() const;
84
+ void
85
+ max_life_time( unsigned int v__ );
86
+ unsigned int
87
+ check_life_time_period() const;
88
+ void
89
+ check_life_time_period( unsigned int v__ );
90
+
91
+ };
92
+ }
93
+
94
+ assert_equal( generation_result,
95
+ RuCodeGen::ValueIncapsulator::Generation::generate_decl(
96
+ vi ) )
97
+ end
98
+
99
+ def test_decl_with_attributes_with_prefix_no_suffix
100
+ vi = cpp_value_incapsulator "cfg_t" do |c|
101
+ c.decl_file :script_relative =>
102
+ "test_decl_with_attributes_with_prefix_no_suffix.hpp"
103
+ c.impl_file :script_relative =>
104
+ "test_decl_with_attributes_with_prefix_no_suffix.cpp"
105
+ c.attr_prefix "m_"
106
+ c.attr :listening_mbox, "std::string"
107
+ c.attr :interception_priority, "int", :default => 2
108
+ end
109
+
110
+ generation_result = %q{
111
+ class cfg_t
112
+ {
113
+ private :
114
+ std::string m_listening_mbox;
115
+ int m_interception_priority;
116
+
117
+ public :
118
+ cfg_t();
119
+
120
+ const std::string &
121
+ listening_mbox() const;
122
+ void
123
+ listening_mbox( const std::string & v__ );
124
+ int
125
+ interception_priority() const;
126
+ void
127
+ interception_priority( int v__ );
128
+
129
+ };
130
+ }
131
+
132
+ assert_equal( generation_result,
133
+ RuCodeGen::ValueIncapsulator::Generation::generate_decl(
134
+ vi ) )
135
+ end
136
+
137
+ def test_decl_with_attributes_no_prefix_with_suffix
138
+ vi = cpp_value_incapsulator "cfg_t" do |c|
139
+ c.decl_file :script_relative =>
140
+ "test_decl_with_attributes_no_prefix_with_suffix.hpp"
141
+ c.impl_file :script_relative =>
142
+ "test_decl_with_attributes_no_prefix_with_suffix.cpp"
143
+ c.attr_suffix "_"
144
+ c.attr :listening_mbox, "std::string"
145
+ c.attr :interception_priority, "int", :default => 2
146
+ end
147
+
148
+ generation_result = %q{
149
+ class cfg_t
150
+ {
151
+ private :
152
+ std::string listening_mbox_;
153
+ int interception_priority_;
154
+
155
+ public :
156
+ cfg_t();
157
+
158
+ const std::string &
159
+ listening_mbox() const;
160
+ void
161
+ listening_mbox( const std::string & v__ );
162
+ int
163
+ interception_priority() const;
164
+ void
165
+ interception_priority( int v__ );
166
+
167
+ };
168
+ }
169
+
170
+ assert_equal( generation_result,
171
+ RuCodeGen::ValueIncapsulator::Generation::generate_decl(
172
+ vi ) )
173
+ end
174
+
175
+ def test_decl_with_attributes_with_prefix_with_suffix
176
+ vi = cpp_value_incapsulator "cfg_t" do |c|
177
+ c.decl_file :script_relative =>
178
+ "test_decl_with_attributes_with_prefix_with_suffix.hpp"
179
+ c.impl_file :script_relative =>
180
+ "test_decl_with_attributes_with_prefix_with_suffix.cpp"
181
+ c.attr_prefix "m_"
182
+ c.attr_suffix "_"
183
+ c.attr :listening_mbox, "std::string"
184
+ c.attr :interception_priority, "int", :default => 2
185
+ end
186
+
187
+ generation_result = %q{
188
+ class cfg_t
189
+ {
190
+ private :
191
+ std::string m_listening_mbox_;
192
+ int m_interception_priority_;
193
+
194
+ public :
195
+ cfg_t();
196
+
197
+ const std::string &
198
+ listening_mbox() const;
199
+ void
200
+ listening_mbox( const std::string & v__ );
201
+ int
202
+ interception_priority() const;
203
+ void
204
+ interception_priority( int v__ );
205
+
206
+ };
207
+ }
208
+
209
+ assert_equal( generation_result,
210
+ RuCodeGen::ValueIncapsulator::Generation::generate_decl(
211
+ vi ) )
212
+ end
213
+
214
+ def test_decl_with_getter_prefix
215
+ vi = cpp_value_incapsulator "cfg_t" do |c|
216
+ c.decl_file :script_relative =>
217
+ "test_decl_with_getter_prefix.hpp"
218
+ c.impl_file :script_relative =>
219
+ "test_decl_with_getter_prefix.cpp"
220
+ c.getter_prefix "query_"
221
+ c.attr :listening_mbox, "std::string"
222
+ c.attr :interception_priority, "int", :default => 2
223
+ end
224
+
225
+ generation_result = %q{
226
+ class cfg_t
227
+ {
228
+ private :
229
+ std::string listening_mbox;
230
+ int interception_priority;
231
+
232
+ public :
233
+ cfg_t();
234
+
235
+ const std::string &
236
+ query_listening_mbox() const;
237
+ void
238
+ listening_mbox( const std::string & v__ );
239
+ int
240
+ query_interception_priority() const;
241
+ void
242
+ interception_priority( int v__ );
243
+
244
+ };
245
+ }
246
+
247
+ assert_equal( generation_result,
248
+ RuCodeGen::ValueIncapsulator::Generation::generate_decl(
249
+ vi ) )
250
+ end
251
+
252
+ def test_decl_with_setter_prefix
253
+ vi = cpp_value_incapsulator "cfg_t" do |c|
254
+ c.decl_file :script_relative =>
255
+ "test_decl_with_setter_prefix.hpp"
256
+ c.impl_file :script_relative =>
257
+ "test_decl_with_setter_prefix.cpp"
258
+ c.setter_prefix "set_"
259
+ c.attr :listening_mbox, "std::string"
260
+ c.attr :interception_priority, "int", :default => 2
261
+ end
262
+
263
+ generation_result = %q{
264
+ class cfg_t
265
+ {
266
+ private :
267
+ std::string listening_mbox;
268
+ int interception_priority;
269
+
270
+ public :
271
+ cfg_t();
272
+
273
+ const std::string &
274
+ listening_mbox() const;
275
+ void
276
+ set_listening_mbox( const std::string & v__ );
277
+ int
278
+ interception_priority() const;
279
+ void
280
+ set_interception_priority( int v__ );
281
+
282
+ };
283
+ }
284
+
285
+ assert_equal( generation_result,
286
+ RuCodeGen::ValueIncapsulator::Generation::generate_decl(
287
+ vi ) )
288
+ end
289
+
290
+ def test_decl_getter_returns_value
291
+ vi = cpp_value_incapsulator "cfg_t" do |c|
292
+ c.decl_file :script_relative =>
293
+ "test_decl_getter_returns_value.hpp"
294
+ c.impl_file :script_relative =>
295
+ "test_decl_getter_returns_value.cpp"
296
+ c.setter_prefix "set_"
297
+ c.attr :listening_mbox, "std::string",
298
+ :getter_returns_value => true
299
+
300
+ c.attr :created_at, "std::time_t",
301
+ :getter_returns_value => true
302
+ end
303
+
304
+ generation_result = %q{
305
+ class cfg_t
306
+ {
307
+ private :
308
+ std::string listening_mbox;
309
+ std::time_t created_at;
310
+
311
+ public :
312
+ cfg_t();
313
+
314
+ std::string
315
+ listening_mbox() const;
316
+ void
317
+ set_listening_mbox( std::string v__ );
318
+ std::time_t
319
+ created_at() const;
320
+ void
321
+ set_created_at( std::time_t v__ );
322
+
323
+ };
324
+ }
325
+
326
+ assert_equal( generation_result,
327
+ RuCodeGen::ValueIncapsulator::Generation::generate_decl(
328
+ vi ) )
329
+ end
330
+
331
+ def test_impl_empty_class
332
+ vi = cpp_value_incapsulator "cfg_t" do |c|
333
+ c.decl_file :script_relative =>
334
+ "test_impl_empty_class.hpp"
335
+ c.impl_file :script_relative =>
336
+ "test_impl_empty_class.cpp"
337
+ end
338
+
339
+ generation_result = %q{
340
+ cfg_t::cfg_t()
341
+
342
+ {}
343
+
344
+
345
+ }
346
+
347
+ assert_equal( generation_result,
348
+ RuCodeGen::ValueIncapsulator::Generation::generate_impl(
349
+ vi ) )
350
+ end
351
+
352
+ def test_impl_no_default_values
353
+ vi = cpp_value_incapsulator "cfg_t" do |c|
354
+ c.decl_file :script_relative =>
355
+ "test_impl_no_default_values.hpp"
356
+ c.impl_file :script_relative =>
357
+ "test_impl_no_default_values.cpp"
358
+ c.attr_prefix "m_"
359
+
360
+ c.attr :listening_mbox, "std::string"
361
+ c.attr :created_at, "ACE_Date_Time"
362
+ end
363
+
364
+ generation_result = %q{
365
+ cfg_t::cfg_t()
366
+ : m_listening_mbox()
367
+ , m_created_at()
368
+
369
+ {}
370
+
371
+ const std::string &
372
+ cfg_t::listening_mbox() const
373
+ { return m_listening_mbox; }
374
+ void
375
+ cfg_t::listening_mbox( const std::string & v__ )
376
+ { m_listening_mbox = v__; }
377
+ const ACE_Date_Time &
378
+ cfg_t::created_at() const
379
+ { return m_created_at; }
380
+ void
381
+ cfg_t::created_at( const ACE_Date_Time & v__ )
382
+ { m_created_at = v__; }
383
+
384
+ }
385
+
386
+ assert_equal( generation_result,
387
+ RuCodeGen::ValueIncapsulator::Generation::generate_impl(
388
+ vi ) )
389
+ end
390
+
391
+ def test_impl_with_default_values
392
+ vi = cpp_value_incapsulator "cfg_t" do |c|
393
+ c.decl_file :script_relative =>
394
+ "test_impl_with_default_values.hpp"
395
+ c.impl_file :script_relative =>
396
+ "test_impl_with_default_values.cpp"
397
+ c.attr_prefix "m_"
398
+
399
+ c.attr :listening_mbox, "std::string", :default => "hello"
400
+ c.attr :created_at, "ACE_Date_Time",
401
+ :default => :"ACE_Date_Time::now()"
402
+ c.attr :priority, "int"
403
+ c.attr :life_time, "unsigned int", :default => 34
404
+ end
405
+
406
+ generation_result = %q{
407
+ cfg_t::cfg_t()
408
+ : m_listening_mbox("hello")
409
+ , m_created_at(ACE_Date_Time::now())
410
+ , m_priority(0)
411
+ , m_life_time(34)
412
+
413
+ {}
414
+
415
+ const std::string &
416
+ cfg_t::listening_mbox() const
417
+ { return m_listening_mbox; }
418
+ void
419
+ cfg_t::listening_mbox( const std::string & v__ )
420
+ { m_listening_mbox = v__; }
421
+ const ACE_Date_Time &
422
+ cfg_t::created_at() const
423
+ { return m_created_at; }
424
+ void
425
+ cfg_t::created_at( const ACE_Date_Time & v__ )
426
+ { m_created_at = v__; }
427
+ int
428
+ cfg_t::priority() const
429
+ { return m_priority; }
430
+ void
431
+ cfg_t::priority( int v__ )
432
+ { m_priority = v__; }
433
+ unsigned int
434
+ cfg_t::life_time() const
435
+ { return m_life_time; }
436
+ void
437
+ cfg_t::life_time( unsigned int v__ )
438
+ { m_life_time = v__; }
439
+
440
+ }
441
+
442
+ assert_equal( generation_result,
443
+ RuCodeGen::ValueIncapsulator::Generation::generate_impl(
444
+ vi ) )
445
+ end
446
+
447
+ def test_impl_with_default_values_and_getter_returns_value
448
+ vi = cpp_value_incapsulator "cfg_t" do |c|
449
+ c.decl_file :script_relative =>
450
+ "test_impl_with_default_values_and_getter_returns_value.hpp"
451
+ c.impl_file :script_relative =>
452
+ "test_impl_with_default_values_and_getter_returns_value.cpp"
453
+ c.attr_prefix "m_"
454
+
455
+ c.attr :listening_mbox, "std::string", :default => "hello",
456
+ :getter_returns_value => true
457
+ end
458
+
459
+ generation_result = %q{
460
+ cfg_t::cfg_t()
461
+ : m_listening_mbox("hello")
462
+
463
+ {}
464
+
465
+ std::string
466
+ cfg_t::listening_mbox() const
467
+ { return m_listening_mbox; }
468
+ void
469
+ cfg_t::listening_mbox( std::string v__ )
470
+ { m_listening_mbox = v__; }
471
+
472
+ }
473
+
474
+ assert_equal( generation_result,
475
+ RuCodeGen::ValueIncapsulator::Generation::generate_impl(
476
+ vi ) )
477
+ end
478
+ end
479
+
@@ -0,0 +1,11 @@
1
+ $:.unshift( File.dirname( __FILE__ ) )
2
+
3
+ require 'test/unit'
4
+
5
+ require 'tc_generators'
6
+ require 'tc_filename_producer'
7
+ require 'tc_run_mode'
8
+ require 'tc_codegen_initiator'
9
+ require 'tc_class_attribute'
10
+ require 'tc_value_incapsulator'
11
+ require 'tc_value_incapsulator_gen'
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.10
3
+ specification_version: 1
4
+ name: RuCodeGen
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.1.0
7
+ date: 2005-11-16
8
+ summary: Simple code generation tool
9
+ require_paths:
10
+ - lib
11
+ email: eao197@yahoo.com
12
+ homepage: http://eao197.narod.ru/projects
13
+ rubyforge_project:
14
+ description:
15
+ autorequire: rucodegen
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ -
22
+ - ">"
23
+ - !ruby/object:Gem::Version
24
+ version: 0.0.0
25
+ version:
26
+ platform: ruby
27
+ authors:
28
+ - Yauheni Akhotnikau
29
+ files:
30
+ - tests/generators_test_extension.rb
31
+ - tests/tc_class_attribute.rb
32
+ - tests/tc_codegen_initiator.rb
33
+ - tests/tc_filename_producer.rb
34
+ - tests/tc_generators.rb
35
+ - tests/tc_run_mode.rb
36
+ - tests/tc_value_incapsulator.rb
37
+ - tests/tc_value_incapsulator_gen.rb
38
+ - tests/ts_rucodegen.rb
39
+ - lib/rucodegen
40
+ - lib/rucodegen.rb
41
+ - lib/rucodegen/begin_end.rb
42
+ - lib/rucodegen/codegen.rb
43
+ - lib/rucodegen/filename_producer.rb
44
+ - lib/rucodegen/generation_initiator.rb
45
+ - lib/rucodegen/generators.rb
46
+ - lib/rucodegen/run_mode.rb
47
+ - lib/rucodegen/value_incapsulator.rb
48
+ - docs/examples
49
+ - docs/Principle
50
+ - docs/ValueIncapsulator
51
+ - docs/examples/cpp
52
+ - docs/examples/cpp/custom
53
+ - docs/examples/cpp/value_incapsulator
54
+ - docs/examples/cpp/custom/submit_deliver
55
+ - docs/examples/cpp/value_incapsulator/cfg
56
+ - docs/examples/cpp/value_incapsulator/host_config
57
+ - examples/cpp
58
+ - examples/cpp/custom
59
+ - examples/cpp/value_incapsulator
60
+ - examples/cpp/custom/submit_deliver
61
+ - examples/cpp/custom/submit_deliver/submit_deliver.rb
62
+ - examples/cpp/custom/submit_deliver/submit_deliver_gen.rb
63
+ - examples/cpp/value_incapsulator/cfg.decl.hpp
64
+ - examples/cpp/value_incapsulator/cfg.impl.cpp
65
+ - examples/cpp/value_incapsulator/cg-cfg.rb
66
+ - examples/cpp/value_incapsulator/cg-cfg.test.cpp
67
+ - examples/cpp/value_incapsulator/cg-host_config.rb
68
+ - examples/cpp/value_incapsulator/cout.log
69
+ - examples/cpp/value_incapsulator/host_config.impl.cpp
70
+ - examples/cpp/value_incapsulator/host_config.impl.hpp
71
+ - README
72
+ - Rakefile
73
+ - LICENSE
74
+ test_files:
75
+ - tests/ts_rucodegen.rb
76
+ rdoc_options:
77
+ - "-c"
78
+ - windows-1251
79
+ - "-S"
80
+ - "--main"
81
+ - README
82
+ extra_rdoc_files:
83
+ - README
84
+ - Rakefile
85
+ - LICENSE
86
+ - docs/examples
87
+ - docs/Principle
88
+ - docs/ValueIncapsulator
89
+ - docs/examples/cpp
90
+ - docs/examples/cpp/custom
91
+ - docs/examples/cpp/value_incapsulator
92
+ - docs/examples/cpp/custom/submit_deliver
93
+ - docs/examples/cpp/value_incapsulator/cfg
94
+ - docs/examples/cpp/value_incapsulator/host_config
95
+ executables: []
96
+ extensions: []
97
+ requirements: []
98
+ dependencies: []